From 395b74051ce974ced8a5abe378f66e9bcf0c8e34 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Wed, 27 Mar 2013 12:02:55 -0400 Subject: [PATCH] Whitelist configuration options (user preferences) that can be changed using save-pref command --- program/include/rcube_plugin.php | 45 +++++++++++++++++++++++++++++++++++++-------- 1 files changed, 37 insertions(+), 8 deletions(-) diff --git a/program/include/rcube_plugin.php b/program/include/rcube_plugin.php index 8ac8745..550c842 100644 --- a/program/include/rcube_plugin.php +++ b/program/include/rcube_plugin.php @@ -5,7 +5,7 @@ | program/include/rcube_plugin.php | | | | This file is part of the Roundcube Webmail client | - | Copyright (C) 2008-2009, Roundcube Dev. - Switzerland | + | Copyright (C) 2008-2009, The Roundcube Dev Team | | Licensed under the GNU GPL | | | | PURPOSE: | @@ -61,6 +61,14 @@ */ public $noframe = false; + /** + * A list of config option names that can be modified + * by the user via user interface (with save-pref command) + * + * @var array + */ + public $allowed_prefs; + protected $home; protected $urlbase; private $mytask; @@ -75,7 +83,7 @@ { $this->ID = get_class($this); $this->api = $api; - $this->home = $api->dir . DIRECTORY_SEPARATOR . $this->ID; + $this->home = $api->dir . $this->ID; $this->urlbase = $api->url . $this->ID . '/'; } @@ -83,7 +91,20 @@ * Initialization method, needs to be implemented by the plugin itself */ abstract function init(); - + + + /** + * Attempt to load the given plugin which is required for the current plugin + * + * @param string Plugin name + * @return boolean True on success, false on failure + */ + public function require_plugin($plugin_name) + { + return $this->api->load_plugin($plugin_name); + } + + /** * Load local config file from plugins directory. * The loaded values are patched over the global configuration. @@ -129,11 +150,19 @@ $lang = $_SESSION['language']; $locdir = slashify(realpath(slashify($this->home) . $dir)); $texts = array(); - + + // use buffering to handle empty lines/spaces after closing PHP tag + ob_start(); + foreach (array('en_US', $lang) as $lng) { - @include($locdir . $lng . '.inc'); - $texts = (array)$labels + (array)$messages + (array)$texts; + $fpath = $locdir . $lng . '.inc'; + if (is_file($fpath) && is_readable($fpath)) { + include($fpath); + $texts = (array)$labels + (array)$messages + (array)$texts; + } } + + ob_end_clean(); // prepend domain to text keys and add to the application texts repository if (!empty($texts)) { @@ -265,14 +294,14 @@ else return $fn; } - + /** * Provide path to the currently selected skin folder within the plugin directory * with a fallback to the default skin folder. * * @return string Skin path relative to plugins directory */ - protected function local_skin_path() + public function local_skin_path() { $skin_path = 'skins/'.$this->api->config->get('skin'); if (!is_dir(realpath(slashify($this->home) . $skin_path))) -- Gitblit v1.9.1