Aleksander Machniak
2014-08-26 613f96839cbf63d475a4f56cb1841647bb23ad0c
plugins/managesieve/managesieve.php
@@ -37,11 +37,12 @@
    function init()
    {
        $this->rc = rcmail::get_instance();
        $this->rc = rcube::get_instance();
        // 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') {
@@ -53,7 +54,9 @@
            $this->add_hook('message_headers_output', array($this, 'mail_headers'));
            // inject Create Filter popup stuff
            if (empty($this->rc->action) || $this->rc->action == 'show') {
            if (empty($this->rc->action) || $this->rc->action == 'show'
                || strpos($this->rc->action, 'plugin.managesieve') === 0
            ) {
                $this->mail_task_handler();
            }
        }
@@ -69,8 +72,26 @@
        }
        // load localization
        $this->add_texts('localization/', array('filters','managefilters'));
        $this->include_script('managesieve.js');
        $this->add_texts('localization/');
        $sieve_action = strpos($this->rc->action, 'plugin.managesieve') === 0;
        if ($this->rc->task == 'mail' || $sieve_action) {
            $this->include_script('managesieve.js');
        }
        // include styles
        $skin_path = $this->local_skin_path();
        if ($this->rc->task == 'settings' || $sieve_action) {
            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 +101,32 @@
     */
    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',
                'title'  => 'filterstitle',
            );
        }
        // register Vacation action
        if ($vacation_mode > 0) {
            $args['actions'][] = array(
                'action' => 'plugin.managesieve-vacation',
                'class'  => 'vacation',
                'label'  => 'vacation',
                'domain' => 'managesieve',
                'title'  => 'vacationtitle',
            );
        }
        return $args;
    }
@@ -100,12 +145,6 @@
        // 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, 
@@ -163,9 +202,11 @@
            $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 +230,7 @@
    /**
     * Initializes engine object
     */
    private function get_engine()
    public function get_engine($type = null)
    {
        if (!$this->engine) {
            $this->load_config();
@@ -199,7 +240,8 @@
            $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;