Permalink
Browse files

- Fix imap_init hook broken in r3258 (#1486493)

  • Loading branch information...
1 parent 9194996 commit 48bc52e835bd5485f7443d54399e4fb0d36732d7 @alecpl alecpl committed Feb 13, 2010
Showing with 22 additions and 25 deletions.
  1. +1 −7 index.php
  2. +20 −5 program/include/rcmail.php
  3. +0 −9 program/include/rcube_plugin_api.php
  4. +1 −4 program/steps/mail/func.inc
View
@@ -30,15 +30,9 @@
// include environment
require_once 'program/include/iniset.php';
-// init application and start session with requested task
+// init application, start session, init output class, etc.
$RCMAIL = rcmail::get_instance();
-// init output class
-$OUTPUT = !empty($_REQUEST['_remote']) ? $RCMAIL->init_json() : $RCMAIL->load_gui(!empty($_REQUEST['_framed']));
-
-// init plugin API
-$RCMAIL->plugins->init();
-
// turn on output buffering
ob_start();
View
@@ -130,12 +130,17 @@ private function startup()
// set current task to session
$_SESSION['task'] = $this->task;
- // create IMAP object
- if ($this->task == 'login')
- $this->imap_init();
-
+ // init output class
+ if (!empty($_REQUEST['_remote']))
+ $GLOBALS['OUTPUT'] = $this->init_json();
+ else
+ $GLOBALS['OUTPUT'] = $this->load_gui(!empty($_REQUEST['_framed']));
+
// create plugin API and load plugins
$this->plugins = rcube_plugin_api::get_instance();
+
+ // init plugins
+ $this->plugins->init();
}
@@ -395,7 +400,11 @@ public function imap_init($connect = false)
// set global object for backward compatibility
$GLOBALS['IMAP'] = $this->imap;
-
+
+ $hook = $this->plugins->exec_hook('imap_init', array('fetch_headers' => $this->imap->fetch_add_headers));
+ if ($hook['fetch_headers'])
+ $this->imap->fetch_add_headers = $hook['fetch_headers'];
+
if ($connect)
$this->imap_connect();
}
@@ -409,6 +418,9 @@ public function imap_init($connect = false)
public function imap_connect()
{
$conn = false;
+
+ if (!$this->imap)
+ $this->imap_init();
if ($_SESSION['imap_host'] && !$this->imap->conn) {
if (!($conn = $this->imap->connect($_SESSION['imap_host'], $_SESSION['username'], $this->decrypt($_SESSION['password']), $_SESSION['imap_port'], $_SESSION['imap_ssl']))) {
@@ -494,6 +506,9 @@ function login($username, $pass, $host=NULL)
if ($user = rcube_user::query($username, $host))
$username = $user->data['username'];
+ if (!$this->imap)
+ $this->imap_init();
+
// exit if IMAP login failed
if (!($imap_login = $this->imap->connect($host, $username, $pass, $imap_port, $imap_ssl)))
return false;
@@ -150,15 +150,6 @@ public function init()
$this->register_hook('template_container', array($this, 'template_container_hook'));
// maybe also register a shudown function which triggers shutdown functions of all plugin objects
-
-
- // call imap_init right now
- // (should actually be done in rcmail::imap_init() but plugins are not initialized then)
- if ($rcmail->imap) {
- $hook = $this->exec_hook('imap_init', array('fetch_headers' => $rcmail->imap->fetch_add_headers));
- if ($hook['fetch_headers'])
- $rcmail->imap->fetch_add_headers = $hook['fetch_headers'];
- }
}
@@ -24,9 +24,6 @@ $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()) {
$RCMAIL->kill_session();
@@ -42,7 +39,7 @@ if (!in_array($RCMAIL->action, $NOIMAP_ACTIONS) && !$RCMAIL->imap_connect()) {
// set imap properties and session vars
if ($mbox = get_input_value('_mbox', RCUBE_INPUT_GPC))
$IMAP->set_mailbox(($_SESSION['mbox'] = $mbox));
-else
+else if ($IMAP)
$_SESSION['mbox'] = $IMAP->get_mailbox_name();
if (!empty($_GET['_page']))

0 comments on commit 48bc52e

Please sign in to comment.