summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2015-02-19 10:25:38 +0100
committerAleksander Machniak <alec@alec.pl>2015-02-19 10:25:38 +0100
commit50b04366ee7472272e2576d17c609e1d26345221 (patch)
tree7cdd9dfa14f47487c0ea2c4b9d6d73ecd1067f97 /program
parent81d4ff214e7cf2253c270a8f8de533bebbf88c15 (diff)
parent3665d1e8ece98ea2093d464087b2cd856df73bd6 (diff)
Merge branch 'master' of github.com:roundcube/roundcubemail
Conflicts: CHANGELOG
Diffstat (limited to 'program')
-rw-r--r--program/include/rcmail.php8
-rw-r--r--program/lib/Roundcube/rcube_plugin_api.php45
-rw-r--r--program/steps/mail/sendmail.inc14
3 files changed, 52 insertions, 15 deletions
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 2327109c0..6e74560cb 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -93,6 +93,10 @@ class rcmail extends rcube
$this->filename = $basename;
}
+ // load all configured plugins
+ $this->plugins->load_plugins((array)$this->config->get('plugins', array()),
+ array('filesystem_attachments', 'jqueryui'));
+
// start session
$this->session_init();
@@ -124,10 +128,8 @@ class rcmail extends rcube
$GLOBALS['OUTPUT'] = $this->load_gui(!empty($_REQUEST['_framed']));
}
- // load plugins
+ // run init method on all the plugins
$this->plugins->init($this, $this->task);
- $this->plugins->load_plugins((array)$this->config->get('plugins', array()),
- array('filesystem_attachments', 'jqueryui'));
}
/**
diff --git a/program/lib/Roundcube/rcube_plugin_api.php b/program/lib/Roundcube/rcube_plugin_api.php
index 6b0fe2f08..8fd3253e0 100644
--- a/program/lib/Roundcube/rcube_plugin_api.php
+++ b/program/lib/Roundcube/rcube_plugin_api.php
@@ -34,6 +34,8 @@ class rcube_plugin_api
public $dir;
public $url = 'plugins/';
public $task = '';
+ public $initialized = false;
+
public $output;
public $handlers = array();
public $allowed_prefs = array();
@@ -85,12 +87,20 @@ class rcube_plugin_api
{
$this->task = $task;
$this->output = $app->output;
-
// register an internal hook
$this->register_hook('template_container', array($this, 'template_container_hook'));
-
// maybe also register a shudown function which triggers
// shutdown functions of all plugin objects
+
+ foreach ($this->plugins as $plugin) {
+ // ... task, request type and framed mode
+ if (!$this->filter($plugin)) {
+ $plugin->init();
+ }
+ }
+
+ // we have finished initializing all plugins
+ $this->initialized = true;
}
/**
@@ -171,14 +181,22 @@ class rcube_plugin_api
// check inheritance...
if (is_subclass_of($plugin, 'rcube_plugin')) {
// ... task, request type and framed mode
- if (($force || !$plugin->task || preg_match('/^('.$plugin->task.')$/i', $this->task))
- && (!$plugin->noajax || (is_object($this->output) && $this->output->type == 'html'))
- && (!$plugin->noframe || empty($_REQUEST['_framed']))
- ) {
+
+ // call onload method on plugin if it exists.
+ // this is useful if you want to be called early in the boot process
+ if (method_exists($plugin, 'onload')) {
+ $plugin->onload();
+ }
+
+ // init a plugin only if $force is set or if we're called after initialization
+ if (($force || $this->initialized)
+ && !$this->filter($plugin))
+ {
$plugin->init();
- $this->plugins[$plugin_name] = $plugin;
}
+ $this->plugins[$plugin_name] = $plugin;
+
if (!empty($plugin->allowed_prefs)) {
$this->allowed_prefs = array_merge($this->allowed_prefs, $plugin->allowed_prefs);
}
@@ -203,6 +221,19 @@ class rcube_plugin_api
}
/**
+ * check if we should prevent this plugin from initialising
+ *
+ * @param $plugin
+ * @return bool
+ */
+ private function filter($plugin)
+ {
+ return (($plugin->noajax && !(is_object($this->output) && $this->output->type == 'html') )
+ || ($plugin->task && !preg_match('/^('.$plugin->task.')$/i', $this->task))
+ || ($plugin->noframe && !empty($_REQUEST['_framed']))) ? true : false;
+ }
+
+ /**
* Get information about a specific plugin.
* This is either provided my a plugin's info() method or extracted from a package.xml or a composer.json file
*
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 715ee32cf..5843de43f 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -765,8 +765,10 @@ function rcmail_fix_emoticon_paths($mime_message)
// remove any null-byte characters before parsing
$body = preg_replace('/\x00/', '', $body);
- $searchstr = 'program/js/tinymce/plugins/emoticons/img/';
- $offset = 0;
+ $searchstr = 'program/js/tinymce/plugins/emoticons/img/';
+ $assets_dir = $RCMAIL->config->get('assets_dir');
+ $path = ($assets_dir ?: INSTALL_PATH) . '/' . $searchstr;
+ $offset = 0;
// keep track of added images, so they're only added once
$included_images = array();
@@ -779,12 +781,14 @@ function rcmail_fix_emoticon_paths($mime_message)
// sanitize image name so resulting attachment doesn't leave images dir
$image_name = preg_replace('/[^a-zA-Z0-9_\.\-]/i', '', $image_name);
- $img_file = INSTALL_PATH . '/' . $searchstr . $image_name;
+ $img_file = $path . $image_name;
- if (! in_array($image_name, $included_images)) {
+ if (!in_array($image_name, $included_images)) {
// add the image to the MIME message
- if (!$mime_message->addHTMLImage($img_file, 'image/gif', '', true, $image_name)) {
+ $res = $mime_message->addHTMLImage($img_file, 'image/gif', '', true, $image_name);
+ if (PEAR::isError($res)) {
$RCMAIL->output->show_message("emoticonerror", 'error');
+ continue;
}
array_push($included_images, $image_name);