| | |
| | | public $imap; |
| | | public $output; |
| | | public $plugins; |
| | | public $task = 'mail'; |
| | | public $task; |
| | | public $action = ''; |
| | | public $comm_path = './'; |
| | | |
| | |
| | | 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(); |
| | | |
| | |
| | | // 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'); |
| | |
| | | // set current task to session |
| | | $_SESSION['task'] = $this->task; |
| | | |
| | | // create IMAP object |
| | | if ($this->task == 'mail') |
| | | $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(); |
| | | } |
| | | |
| | | |
| | |
| | | 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) |
| | |
| | | $GLOBALS['USER'] = $this->user; |
| | | |
| | | // overwrite config with user preferences |
| | | $this->config->merge((array)$this->user->get_prefs()); |
| | | $this->config->set_user_prefs((array)$this->user->get_prefs()); |
| | | } |
| | | |
| | | $_SESSION['language'] = $this->user->language = $this->language_prop($this->config->get('language', $_SESSION['language'])); |
| | |
| | | |
| | | // 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(); |
| | | } |
| | |
| | | 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']))) { |
| | |
| | | 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; |