summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2010-02-06 18:12:49 +0000
committeralecpl <alec@alec.pl>2010-02-06 18:12:49 +0000
commit9b94eb64153a7dc6555d6b9a30a35296ce592f82 (patch)
treef4ae470d942d0e88446fa6c0e220338f5b220adc /program
parenta65bf3a14b617d4af6749bab9e6ac7668fb99292 (diff)
- Fix setting task name according to auth state. So, any action before user
is authenticated is assigned to 'login' task instead of 'mail'. Now binding plugins to 'login' task is possible and realy usefull. It's also possible to bind to all tasks excluding 'login'.
Diffstat (limited to 'program')
-rw-r--r--program/include/rcmail.php20
-rw-r--r--program/include/rcube_plugin_api.php2
-rw-r--r--program/steps/mail/func.inc2
3 files changed, 16 insertions, 8 deletions
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 3d26065d5..cd6187281 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -39,7 +39,7 @@ class rcmail
public $imap;
public $output;
public $plugins;
- public $task = 'mail';
+ public $task;
public $action = '';
public $comm_path = './';
@@ -91,10 +91,6 @@ class rcmail
openlog($syslog_id, LOG_ODELAY, $syslog_facility);
}
- // set task and action properties
- $this->set_task(get_input_value('_task', RCUBE_INPUT_GPC));
- $this->action = asciiwords(get_input_value('_action', RCUBE_INPUT_GPC));
-
// connect to database
$GLOBALS['DB'] = $this->get_dbh();
@@ -123,6 +119,10 @@ class rcmail
// create user object
$this->set_user(new rcube_user($_SESSION['user_id']));
+ // set task and action properties
+ $this->set_task(get_input_value('_task', RCUBE_INPUT_GPC));
+ $this->action = asciiwords(get_input_value('_action', RCUBE_INPUT_GPC));
+
// reset some session parameters when changing task
if ($_SESSION['task'] != $this->task)
rcube_sess_unset('page');
@@ -131,7 +131,7 @@ class rcmail
$_SESSION['task'] = $this->task;
// create IMAP object
- if ($this->task == 'mail')
+ if ($this->task == 'login')
$this->imap_init();
// create plugin API and load plugins
@@ -147,7 +147,13 @@ class rcmail
public function set_task($task)
{
$task = asciiwords($task);
- $this->task = $task ? $task : 'mail';
+
+ if ($this->user && $this->user->ID)
+ $task = !$task || $task == 'login' ? 'mail' : $task;
+ else
+ $task = 'login';
+
+ $this->task = $task;
$this->comm_path = $this->url(array('task' => $this->task));
if ($this->output)
diff --git a/program/include/rcube_plugin_api.php b/program/include/rcube_plugin_api.php
index 1eeadce3a..b19c0a3f4 100644
--- a/program/include/rcube_plugin_api.php
+++ b/program/include/rcube_plugin_api.php
@@ -90,7 +90,7 @@ class rcube_plugin_api
if (class_exists($plugin_name, false)) {
$plugin = new $plugin_name($this);
// check inheritance and task specification
- if (is_subclass_of($plugin, 'rcube_plugin') && (!$plugin->task || preg_match('/('.$plugin->task.')/i', $rcmail->task))) {
+ if (is_subclass_of($plugin, 'rcube_plugin') && (!$plugin->task || preg_match('/^('.$plugin->task.')$/i', $rcmail->task))) {
$plugin->init();
$this->plugins[] = $plugin;
}
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index e9adc1513..dea85c2c5 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -24,6 +24,8 @@ $EMAIL_ADDRESS_PATTERN = '([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9][a-z0-9\-\.]*\\.[a-
// actions that do not require imap connection
$NOIMAP_ACTIONS = array('spell', 'addcontact', 'autocomplete', 'upload', 'display-attachment', 'remove-attachment');
+// Init IMAP object
+$RCMAIL->imap_init();
// log in to imap server
if (!in_array($RCMAIL->action, $NOIMAP_ACTIONS) && !$RCMAIL->imap_connect()) {