summaryrefslogtreecommitdiff
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
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'.
-rw-r--r--CHANGELOG1
-rw-r--r--index.php10
-rw-r--r--plugins/archive/archive.php3
-rw-r--r--plugins/autologon/autologon.php3
-rw-r--r--plugins/help/help.php6
-rw-r--r--plugins/http_authentication/http_authentication.php3
-rw-r--r--plugins/markasjunk/markasjunk.php3
-rw-r--r--plugins/new_user_identity/new_user_identity.php2
-rw-r--r--plugins/squirrelmail_usercopy/squirrelmail_usercopy.php2
-rw-r--r--program/include/rcmail.php20
-rw-r--r--program/include/rcube_plugin_api.php2
-rw-r--r--program/steps/mail/func.inc2
12 files changed, 34 insertions, 23 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 6416ca3ab..8578fdc08 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG RoundCube Webmail
===========================
+- Fix setting task name according to auth state
- Password: fix vpopmaild driver (#1486478)
- Add workaround for MySQL bug [http://bugs.mysql.com/bug.php?id=46293] (#1486474)
- Fix quoted text wrapping when replying to an HTML email in plain text (#1484141)
diff --git a/index.php b/index.php
index e3c542ba2..7251b533c 100644
--- a/index.php
+++ b/index.php
@@ -80,7 +80,7 @@ $RCMAIL->set_task($startup['task']);
$RCMAIL->action = $startup['action'];
// try to log in
-if ($RCMAIL->action=='login' && $RCMAIL->task=='mail') {
+if ($RCMAIL->task == 'login' && $RCMAIL->action == 'login') {
// purge the session in case of new login when a session already exists
$RCMAIL->kill_session();
@@ -117,6 +117,8 @@ if ($RCMAIL->action=='login' && $RCMAIL->task=='mail') {
if ($url = get_input_value('_url', RCUBE_INPUT_POST))
parse_str($url, $query);
+ $RCMAIL->set_task('mail');
+
// allow plugins to control the redirect url after login success
$redir = $RCMAIL->plugins->exec_hook('login_after', $query + array('task' => $RCMAIL->task));
unset($redir['abort']);
@@ -132,7 +134,7 @@ if ($RCMAIL->action=='login' && $RCMAIL->task=='mail') {
}
// end session
-else if ($RCMAIL->task=='logout' && isset($_SESSION['user_id'])) {
+else if ($RCMAIL->task == 'logout' && isset($_SESSION['user_id'])) {
$userdata = array('user' => $_SESSION['username'], 'host' => $_SESSION['imap_host'], 'lang' => $RCMAIL->user->language);
$OUTPUT->show_message('loggedout');
$RCMAIL->logout_actions();
@@ -141,7 +143,7 @@ else if ($RCMAIL->task=='logout' && isset($_SESSION['user_id'])) {
}
// check session and auth cookie
-else if ($RCMAIL->action != 'login' && $_SESSION['user_id'] && $RCMAIL->action != 'send') {
+else if ($RCMAIL->task != 'login' && $_SESSION['user_id'] && $RCMAIL->action != 'send') {
if (!$RCMAIL->authenticate_session()) {
$OUTPUT->show_message('sessionerror', 'error');
$RCMAIL->kill_session();
@@ -168,7 +170,7 @@ else if (!empty($_POST) && !$request_check_whitelist[$RCMAIL->action] && !$RCMAI
if (empty($RCMAIL->user->ID)) {
if ($OUTPUT->ajax_call)
$OUTPUT->redirect(array(), 2000);
-
+
if (!empty($_REQUEST['_framed']))
$OUTPUT->command('redirect', '?');
diff --git a/plugins/archive/archive.php b/plugins/archive/archive.php
index d2269baba..939faf8ba 100644
--- a/plugins/archive/archive.php
+++ b/plugins/archive/archive.php
@@ -17,9 +17,6 @@ class archive extends rcube_plugin
{
$rcmail = rcmail::get_instance();
- if (!$rcmail->user->ID)
- return;
-
$this->register_action('plugin.archive', array($this, 'request_action'));
// There is no "Archived flags"
diff --git a/plugins/autologon/autologon.php b/plugins/autologon/autologon.php
index c40f2d4eb..bc3d2ee76 100644
--- a/plugins/autologon/autologon.php
+++ b/plugins/autologon/autologon.php
@@ -6,6 +6,7 @@
*/
class autologon extends rcube_plugin
{
+ public $task = 'login';
function init()
{
@@ -18,7 +19,7 @@ class autologon extends rcube_plugin
$rcmail = rcmail::get_instance();
// change action to login
- if ($args['task'] == 'mail' && empty($args['action']) && empty($_SESSION['user_id']) && !empty($_GET['_autologin']) && $this->is_localhost())
+ if (empty($_SESSION['user_id']) && !empty($_GET['_autologin']) && $this->is_localhost())
$args['action'] = 'login';
return $args;
diff --git a/plugins/help/help.php b/plugins/help/help.php
index 94d06542c..a7b3d5793 100644
--- a/plugins/help/help.php
+++ b/plugins/help/help.php
@@ -12,13 +12,13 @@
class help extends rcube_plugin
{
+ // all task excluding 'login' and 'logout'
+ public $task = '?(?!login|logout).*';
+
function init()
{
$rcmail = rcmail::get_instance();
- if (!$rcmail->user->ID)
- return;
-
$this->add_texts('localization/', false);
// register actions
diff --git a/plugins/http_authentication/http_authentication.php b/plugins/http_authentication/http_authentication.php
index 57422a74d..7c2296614 100644
--- a/plugins/http_authentication/http_authentication.php
+++ b/plugins/http_authentication/http_authentication.php
@@ -10,6 +10,7 @@
*/
class http_authentication extends rcube_plugin
{
+ public $task = 'login';
function init()
{
@@ -20,7 +21,7 @@ class http_authentication extends rcube_plugin
function startup($args)
{
// change action to login
- if ($args['task'] == 'mail' && empty($args['action']) && empty($_SESSION['user_id'])
+ if (empty($args['action']) && empty($_SESSION['user_id'])
&& !empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW']))
$args['action'] = 'login';
diff --git a/plugins/markasjunk/markasjunk.php b/plugins/markasjunk/markasjunk.php
index 9f75590c8..046645872 100644
--- a/plugins/markasjunk/markasjunk.php
+++ b/plugins/markasjunk/markasjunk.php
@@ -17,9 +17,6 @@ class markasjunk extends rcube_plugin
{
$rcmail = rcmail::get_instance();
- if (!$rcmail->user->ID)
- return;
-
$this->register_action('plugin.markasjunk', array($this, 'request_action'));
if ($rcmail->action == '' || $rcmail->action == 'show') {
diff --git a/plugins/new_user_identity/new_user_identity.php b/plugins/new_user_identity/new_user_identity.php
index 78c99522d..43eeae9dd 100644
--- a/plugins/new_user_identity/new_user_identity.php
+++ b/plugins/new_user_identity/new_user_identity.php
@@ -22,6 +22,8 @@
*/
class new_user_identity extends rcube_plugin
{
+ public $task = 'login';
+
function init()
{
$this->add_hook('create_user', array($this, 'lookup_user_name'));
diff --git a/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php b/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php
index 4a14ff2c9..aff2f494f 100644
--- a/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php
+++ b/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php
@@ -10,6 +10,8 @@
*/
class squirrelmail_usercopy extends rcube_plugin
{
+ public $task = 'login|settings';
+
private $prefs = null;
private $abook = array();
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()) {