Thomas Bruederli
2014-06-04 3412e50b54e3daac8745234e21ab6e72be0ed165
program/lib/Roundcube/rcube_plugin.php
@@ -60,6 +60,14 @@
     */
    public $noframe = false;
    /**
     * A list of config option names that can be modified
     * by the user via user interface (with save-prefs command)
     *
     * @var array
     */
    public $allowed_prefs;
    protected $home;
    protected $urlbase;
    private $mytask;
@@ -84,6 +92,16 @@
    abstract function init();
    /**
     * Provide information about this
     *
     * @return array Meta information about a plugin or false if not implemented
     */
    public static function info()
    {
        return false;
    }
    /**
     * Attempt to load the given plugin which is required for the current plugin
     *
     * @param string Plugin name
@@ -91,7 +109,7 @@
     */
    public function require_plugin($plugin_name)
    {
        return $this->api->load_plugin($plugin_name);
        return $this->api->load_plugin($plugin_name, true);
    }
    /**
@@ -107,12 +125,16 @@
        $fpath = $this->home.'/'.$fname;
        $rcube = rcube::get_instance();
        if (is_file($fpath) && !$rcube->config->load_from_file($fpath)) {
        if (($is_local = is_file($fpath)) && !$rcube->config->load_from_file($fpath)) {
            rcube::raise_error(array(
                'code' => 527, 'type' => 'php',
                'file' => __FILE__, 'line' => __LINE__,
                'message' => "Failed to load config from $fpath"), true, false);
            return false;
        }
        else if (!$is_local) {
            // Search plugin_name.inc.php file in any configured path
            return $rcube->config->load_from_file($this->ID . '.inc.php');
        }
        return true;
@@ -209,7 +231,7 @@
            $rcube->load_language($lang, $add);
            // add labels to client
            if ($add2client) {
            if ($add2client && method_exists($rcube->output, 'add_label')) {
                if (is_array($add2client)) {
                    $js_labels = array_map(array($this, 'label_map_callback'), $add2client);
                }
@@ -218,6 +240,24 @@
                }
                $rcube->output->add_label($js_labels);
            }
        }
    }
    /**
     * Wrapper for add_label() adding the plugin ID as domain
     */
    public function add_label()
    {
        $rcube = rcube::get_instance();
        if (method_exists($rcube->output, 'add_label')) {
            $args = func_get_args();
            if (count($args) == 1 && is_array($args[0])) {
                $args = $args[0];
            }
            $args = array_map(array($this, 'label_map_callback'), $args);
            $rcube->output->add_label($args);
        }
    }
@@ -237,7 +277,7 @@
    /**
     * Register this plugin to be responsible for a specific task
     *
     * @param string $task Task name (only characters [a-z0-9_.-] are allowed)
     * @param string $task Task name (only characters [a-z0-9_-] are allowed)
     */
    public function register_task($task)
    {
@@ -372,6 +412,10 @@
     */
    private function label_map_callback($key)
    {
        if (strpos($key, $this->ID.'.') === 0) {
            return $key;
        }
        return $this->ID.'.'.$key;
    }
}