summaryrefslogtreecommitdiff
path: root/plugins/managesieve/managesieve.php
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/managesieve/managesieve.php')
-rw-r--r--plugins/managesieve/managesieve.php65
1 files changed, 51 insertions, 14 deletions
diff --git a/plugins/managesieve/managesieve.php b/plugins/managesieve/managesieve.php
index aa74c52b0..aba34251c 100644
--- a/plugins/managesieve/managesieve.php
+++ b/plugins/managesieve/managesieve.php
@@ -42,6 +42,7 @@ class managesieve extends rcube_plugin
// register actions
$this->register_action('plugin.managesieve', array($this, 'managesieve_actions'));
$this->register_action('plugin.managesieve-action', array($this, 'managesieve_actions'));
+ $this->register_action('plugin.managesieve-vacation', array($this, 'managesieve_actions'));
$this->register_action('plugin.managesieve-save', array($this, 'managesieve_save'));
if ($this->rc->task == 'settings') {
@@ -69,8 +70,25 @@ class managesieve extends rcube_plugin
}
// load localization
- $this->add_texts('localization/', array('filters','managefilters'));
- $this->include_script('managesieve.js');
+ $this->add_texts('localization/');
+
+ if (strpos($this->rc->action, 'plugin.managesieve') === 0) {
+ $this->include_script('managesieve.js');
+ }
+
+ // include styles
+ $skin_path = $this->local_skin_path();
+ if ($this->rc->task == 'settings') {
+ if (is_file($this->home . "/$skin_path/managesieve.css")) {
+ $this->include_stylesheet("$skin_path/managesieve.css");
+ }
+ }
+ else {
+ if (is_file($this->home . "/$skin_path/managesieve_mail.css")) {
+ $this->include_stylesheet("$skin_path/managesieve_mail.css");
+ }
+ }
+
$this->ui_initialized = true;
}
@@ -80,8 +98,30 @@ class managesieve extends rcube_plugin
*/
function settings_actions($args)
{
- // register as settings action
- $args['actions'][] = array('action' => 'plugin.managesieve', 'class' => 'filter', 'label' => 'filters', 'domain' => 'managesieve');
+ $this->load_config();
+
+ $vacation_mode = (int) $this->rc->config->get('managesieve_vacation');
+
+ // register Filters action
+ if ($vacation_mode != 2) {
+ $args['actions'][] = array(
+ 'action' => 'plugin.managesieve',
+ 'class' => 'filter',
+ 'label' => 'filters',
+ 'domain' => 'managesieve',
+ );
+ }
+
+ // register Vacation action
+ if ($vacation_mode > 0) {
+ $args['actions'][] = array(
+ 'action' => 'plugin.managesieve-vacation',
+ 'class' => 'vacation',
+ 'label' => 'vacation',
+ 'domain' => 'managesieve',
+ );
+ }
+
return $args;
}
@@ -101,12 +141,6 @@ class managesieve extends rcube_plugin
// include js script and localization
$this->init_ui();
- // include styles
- $skin_path = $this->local_skin_path();
- if (is_file($this->home . "/$skin_path/managesieve_mail.css")) {
- $this->include_stylesheet("$skin_path/managesieve_mail.css");
- }
-
// add 'Create filter' item to message menu
$this->api->add_content(html::tag('li', null,
$this->api->output->button(array(
@@ -163,9 +197,11 @@ class managesieve extends rcube_plugin
$this->rc->output->send();
}
- // handle other action
+ // handle other actions
+ $engine_type = $this->rc->action == 'plugin.managesieve-vacation' ? 'vacation' : '';
+ $engine = $this->get_engine($engine_type);
+
$this->init_ui();
- $engine = $this->get_engine();
$engine->actions();
}
@@ -189,7 +225,7 @@ class managesieve extends rcube_plugin
/**
* Initializes engine object
*/
- private function get_engine()
+ private function get_engine($type = null)
{
if (!$this->engine) {
$this->load_config();
@@ -199,7 +235,8 @@ class managesieve extends rcube_plugin
$include_path .= ini_get('include_path');
set_include_path($include_path);
- $this->engine = new rcube_sieve_engine($this);
+ $class_name = 'rcube_sieve_' . ($type ? $type : 'engine');
+ $this->engine = new $class_name($this);
}
return $this->engine;