From be98dfc2c0bdc4f911c6daa94e3fddc29afc89a8 Mon Sep 17 00:00:00 2001 From: alecpl Date: Mon, 16 Apr 2012 11:59:08 +0000 Subject: [PATCH] - Replace some references to rcmail with rcube --- program/include/rcube.php | 20 ++++++++-------- program/include/rcube_cache.php | 8 +++---- program/include/rcube_config.php | 12 ++++------ program/include/rcube_image.php | 16 ++++++------- program/include/rcube_imap.php | 20 ++++++++-------- program/include/rcube_ldap.php | 14 +++++------ program/include/rcube_mdb2.php | 10 ++++---- program/include/rcube_message.php | 4 ++-- program/include/rcube_mime.php | 2 +- program/include/rcube_output_html.php | 2 +- program/include/rcube_output_json.php | 2 +- program/include/rcube_plugin.php | 6 ++--- program/include/rcube_session.php | 4 ++-- program/include/rcube_smtp.php | 28 +++++++++++----------- program/include/rcube_spellchecker.php | 2 +- program/include/rcube_user.php | 32 +++++++++++++------------- 16 files changed, 88 insertions(+), 94 deletions(-) diff --git a/program/include/rcube.php b/program/include/rcube.php index 61cee8dba..97596e703 100644 --- a/program/include/rcube.php +++ b/program/include/rcube.php @@ -2,7 +2,7 @@ /* +-----------------------------------------------------------------------+ - | program/include/rcmail.php | + | program/include/rcube.php | | | | This file is part of the Roundcube Webmail client | | Copyright (C) 2008-2012, The Roundcube Dev Team | @@ -36,7 +36,7 @@ class rcube const INIT_WITH_PLUGINS = 2; /** - * Singleton instace of rcmail + * Singleton instace of rcube * * @var rcmail */ @@ -109,7 +109,7 @@ class rcube /** * This implements the 'singleton' design pattern * - * @return rcmail The one and only instance + * @return rcube The one and only instance */ static function get_instance() { @@ -718,7 +718,7 @@ class rcube /*- * Trim PHP's padding and the canary byte; see note in - * rcmail::encrypt() and http://php.net/mcrypt_generic#68082 + * rcube::encrypt() and http://php.net/mcrypt_generic#68082 */ $clear = substr(rtrim($clear, "\0"), 0, -1); @@ -848,15 +848,13 @@ class rcube { $args = func_get_args(); - if (class_exists('rcmail', false)) { + if (class_exists('rcube', false)) { $rcube = self::get_instance(); - if (is_object($rcube->plugins)) { - $plugin = $rcube->plugins->exec_hook('console', array('args' => $args)); - if ($plugin['abort']) { - return; - } - $args = $plugin['args']; + $plugin = $rcube->plugins->exec_hook('console', array('args' => $args)); + if ($plugin['abort']) { + return; } + $args = $plugin['args']; } $msg = array(); diff --git a/program/include/rcube_cache.php b/program/include/rcube_cache.php index 3e6bc0f32..6d7a9eacd 100644 --- a/program/include/rcube_cache.php +++ b/program/include/rcube_cache.php @@ -66,12 +66,12 @@ class rcube_cache */ function __construct($type, $userid, $prefix='', $ttl=0, $packed=true) { - $rcmail = rcube::get_instance(); - $type = strtolower($type); + $rcube = rcube::get_instance(); + $type = strtolower($type); if ($type == 'memcache') { $this->type = 'memcache'; - $this->db = $rcmail->get_memcache(); + $this->db = $rcube->get_memcache(); } else if ($type == 'apc') { $this->type = 'apc'; @@ -79,7 +79,7 @@ class rcube_cache } else { $this->type = 'db'; - $this->db = $rcmail->get_dbh(); + $this->db = $rcube->get_dbh(); } $this->userid = (int) $userid; diff --git a/program/include/rcube_config.php b/program/include/rcube_config.php index 5cc8571c9..5fb5bee80 100644 --- a/program/include/rcube_config.php +++ b/program/include/rcube_config.php @@ -186,19 +186,15 @@ class rcube_config $result = $def; } - $rcmail = rcube::get_instance(); + $rcube = rcube::get_instance(); if ($name == 'timezone' && isset($this->prop['_timezone_value'])) $result = $this->prop['_timezone_value']; - if (is_object($rcmail->plugins)) { - $plugin = $rcmail->plugins->exec_hook('config_get', array( - 'name' => $name, 'default' => $def, 'result' => $result)); + $plugin = $rcube->plugins->exec_hook('config_get', array( + 'name' => $name, 'default' => $def, 'result' => $result)); - return $plugin['result']; - } - - return $result; + return $plugin['result']; } diff --git a/program/include/rcube_image.php b/program/include/rcube_image.php index 79dcad691..c42b4af2b 100644 --- a/program/include/rcube_image.php +++ b/program/include/rcube_image.php @@ -73,10 +73,10 @@ class rcube_image */ public function resize($size, $filename = null) { - $result = false; - $rcmail = rcmail::get_instance(); - $convert = $rcmail->config->get('im_convert_path', false); - $props = $this->props(); + $result = false; + $rcube = rcube::get_instance(); + $convert = $rcmail->config->get('im_convert_path', false); + $props = $this->props(); if (!$filename) { $filename = $this->image_file; @@ -98,7 +98,7 @@ class rcube_image $p['-opts'] = array('-resize' => $size.'>'); if (in_array($type, explode(',', $p['types']))) { // Valid type? - $result = rcmail::exec($convert . ' 2>&1 -flatten -auto-orient -colorspace RGB -quality {quality} {-opts} {in} {type}:{out}', $p) === ''; + $result = rcube::exec($convert . ' 2>&1 -flatten -auto-orient -colorspace RGB -quality {quality} {-opts} {in} {type}:{out}', $p) === ''; } if ($result) { @@ -161,11 +161,11 @@ class rcube_image */ private function identify() { - $rcmail = rcmail::get_instance(); + $rcube = rcube::get_instance(); - if ($cmd = $rcmail->config->get('im_identify_path')) { + if ($cmd = $rcube->config->get('im_identify_path')) { $args = array('in' => $this->image_file, 'format' => "%m %[fx:w] %[fx:h]"); - $id = rcmail::exec($cmd. ' 2>/dev/null -format {format} {in}', $args); + $id = rcube::exec($cmd. ' 2>/dev/null -format {format} {in}', $args); if ($id) { return explode(' ', strtolower($id)); diff --git a/program/include/rcube_imap.php b/program/include/rcube_imap.php index 1b34ecfe2..3fc779b88 100644 --- a/program/include/rcube_imap.php +++ b/program/include/rcube_imap.php @@ -2598,7 +2598,7 @@ class rcube_imap extends rcube_storage } // Give plugins a chance to provide a list of folders - $data = rcmail::get_instance()->plugins->exec_hook('storage_folders', + $data = rcube::get_instance()->plugins->exec_hook('storage_folders', array('root' => $root, 'name' => $name, 'filter' => $filter, 'mode' => 'LIST')); if (isset($data['folders'])) { @@ -3508,7 +3508,7 @@ class rcube_imap extends rcube_storage /** * Enable or disable indexes caching * - * @param string $type Cache type (@see rcmail::get_cache) + * @param string $type Cache type (@see rcube::get_cache) */ public function set_caching($type) { @@ -3530,9 +3530,9 @@ class rcube_imap extends rcube_storage protected function get_cache_engine() { if ($this->caching && !$this->cache) { - $rcmail = rcube::get_instance(); - $ttl = $rcmail->config->get('message_cache_lifetime', '10d') - mktime(); - $this->cache = $rcmail->get_cache('IMAP', $this->caching, $ttl); + $rcube = rcube::get_instance(); + $ttl = $rcube->config->get('message_cache_lifetime', '10d') - mktime(); + $this->cache = $rcube->get_cache('IMAP', $this->caching, $ttl); } return $this->cache; @@ -3585,7 +3585,7 @@ class rcube_imap extends rcube_storage public function expunge_cache() { if ($this->mcache) { - $ttl = rcmail::get_instance()->config->get('message_cache_lifetime', '10d'); + $ttl = rcube::get_instance()->config->get('message_cache_lifetime', '10d'); $this->mcache->expunge($ttl); } @@ -3625,10 +3625,10 @@ class rcube_imap extends rcube_storage protected function get_mcache_engine() { if ($this->messages_caching && !$this->mcache) { - $rcmail = rcube::get_instance(); - if ($dbh = $rcmail->get_dbh()) { + $rcube = rcube::get_instance(); + if ($dbh = $rcube->get_dbh()) { $this->mcache = new rcube_imap_cache( - $dbh, $this, $rcmail->get_user_id(), $this->options['skip_deleted']); + $dbh, $this, $rcube->get_user_id(), $this->options['skip_deleted']); } } @@ -3852,7 +3852,7 @@ class rcube_imap extends rcube_storage */ public function debug_handler(&$imap, $message) { - rcmail::write_log('imap', $message); + rcube::write_log('imap', $message); } diff --git a/program/include/rcube_ldap.php b/program/include/rcube_ldap.php index 0b25e63b3..88b7cd05b 100644 --- a/program/include/rcube_ldap.php +++ b/program/include/rcube_ldap.php @@ -163,8 +163,8 @@ class rcube_ldap extends rcube_addressbook $this->mail_domain = $mail_domain; // initialize cache - $rcmail = rcmail::get_instance(); - $this->cache = $rcmail->get_cache('LDAP.' . asciiwords($this->prop['name']), 'db', 600); + $rcube = rcube::get_instance(); + $this->cache = $rcube->get_cache('LDAP.' . asciiwords($this->prop['name']), 'db', 600); $this->_connect(); } @@ -175,7 +175,7 @@ class rcube_ldap extends rcube_addressbook */ private function _connect() { - $RCMAIL = rcmail::get_instance(); + $rcube = rcube::get_instance(); if (!function_exists('ldap_connect')) rcube::raise_error(array('code' => 100, 'type' => 'ldap', @@ -194,7 +194,7 @@ class rcube_ldap extends rcube_addressbook foreach ($this->prop['hosts'] as $host) { - $host = idn_to_ascii(rcube_utils::parse_host($host)); + $host = rcube_utils::idn_to_ascii(rcube_utils::parse_host($host)); $hostname = $host.($this->prop['port'] ? ':'.$this->prop['port'] : ''); $this->_debug("C: Connect [$hostname] [{$this->prop['name']}]"); @@ -243,11 +243,11 @@ class rcube_ldap extends rcube_addressbook if ($this->prop['user_specific']) { // No password set, use the session password if (empty($bind_pass)) { - $bind_pass = $RCMAIL->decrypt($_SESSION['password']); + $bind_pass = $rcube->decrypt($_SESSION['password']); } // Get the pieces needed for variable replacement. - if ($fu = $RCMAIL->get_user_name()) + if ($fu = $rcube->get_user_name()) list($u, $d) = explode('@', $fu); else $d = $this->mail_domain; @@ -1562,7 +1562,7 @@ class rcube_ldap extends rcube_addressbook private function _debug($str) { if ($this->debug) { - rcmail::write_log('ldap', $str); + rcube::write_log('ldap', $str); } } diff --git a/program/include/rcube_mdb2.php b/program/include/rcube_mdb2.php index 0139bdc65..7c431dfa6 100644 --- a/program/include/rcube_mdb2.php +++ b/program/include/rcube_mdb2.php @@ -826,7 +826,7 @@ class rcube_mdb2 if ($scope != 'prepare') { $debug_output = sprintf('%s(%d): %s;', $scope, $db->db_index, rtrim($message, ';')); - rcmail::write_log('sql', $debug_output); + rcube::write_log('sql', $debug_output); } } @@ -840,12 +840,12 @@ class rcube_mdb2 */ public function table_name($table) { - $rcmail = rcube::get_instance(); + $rcube = rcube::get_instance(); // return table name if configured $config_key = 'db_table_'.$table; - if ($name = $rcmail->config->get($config_key)) { + if ($name = $rcube->config->get($config_key)) { return $name; } @@ -863,12 +863,12 @@ class rcube_mdb2 */ public function sequence_name($sequence) { - $rcmail = rcube::get_instance(); + $rcube = rcube::get_instance(); // return sequence name if configured $config_key = 'db_sequence_'.$sequence; - if ($name = $rcmail->config->get($config_key)) { + if ($name = $rcube->config->get($config_key)) { return $name; } diff --git a/program/include/rcube_message.php b/program/include/rcube_message.php index ee17fcd4a..dafbe3201 100644 --- a/program/include/rcube_message.php +++ b/program/include/rcube_message.php @@ -33,9 +33,9 @@ class rcube_message { /** - * Instace of rcmail. + * Instace of framework class. * - * @var rcmail + * @var rcube */ private $app; diff --git a/program/include/rcube_mime.php b/program/include/rcube_mime.php index 3cfb4e960..64ce67d5f 100644 --- a/program/include/rcube_mime.php +++ b/program/include/rcube_mime.php @@ -46,7 +46,7 @@ class rcube_mime self::$default_charset = $default_charset; } else { - self::$default_charset = rcmail::get_instance()->config->get('default_charset', RCMAIL_CHARSET); + self::$default_charset = rcube::get_instance()->config->get('default_charset', RCMAIL_CHARSET); } } diff --git a/program/include/rcube_output_html.php b/program/include/rcube_output_html.php index 878606266..237bc817b 100644 --- a/program/include/rcube_output_html.php +++ b/program/include/rcube_output_html.php @@ -1206,7 +1206,7 @@ class rcube_output_html extends rcube_output array($this, 'file_callback'), $output); // trigger hook with final HTML content to be sent - $hook = rcmail::get_instance()->plugins->exec_hook("send_page", array('content' => $output)); + $hook = $this->app->plugins->exec_hook("send_page", array('content' => $output)); if (!$hook['abort']) { if ($this->charset != RCMAIL_CHARSET) { echo rcube_charset::convert($hook['content'], RCMAIL_CHARSET, $this->charset); diff --git a/program/include/rcube_output_json.php b/program/include/rcube_output_json.php index 1d9d6edf6..d48dd35c1 100644 --- a/program/include/rcube_output_json.php +++ b/program/include/rcube_output_json.php @@ -170,7 +170,7 @@ class rcube_output_json extends rcube_output */ public function redirect($p = array(), $delay = 1) { - $location = rcmail::get_instance()->url($p); + $location = $this->app->url($p); $this->remote_response(sprintf("window.setTimeout(function(){ %s.redirect('%s',true); }, %d);", rcmail::JS_OBJECT_NAME, $location, $delay)); exit; diff --git a/program/include/rcube_plugin.php b/program/include/rcube_plugin.php index e20f7ce6a..7048392e5 100644 --- a/program/include/rcube_plugin.php +++ b/program/include/rcube_plugin.php @@ -110,8 +110,8 @@ abstract class rcube_plugin public function load_config($fname = 'config.inc.php') { $fpath = $this->home.'/'.$fname; - $rcmail = rcube::get_instance(); - if (is_file($fpath) && !$rcmail->config->load_from_file($fpath)) { + $rcube = rcube::get_instance(); + if (is_file($fpath) && !$rcube->config->load_from_file($fpath)) { rcube::raise_error(array( 'code' => 527, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, @@ -177,7 +177,7 @@ abstract class rcube_plugin foreach ($texts as $key => $value) $add[$domain.'.'.$key] = $value; - $rcmail = rcube::get_instance(); + $rcmail = rcmail::get_instance(); $rcmail->load_language($lang, $add); // add labels to client diff --git a/program/include/rcube_session.php b/program/include/rcube_session.php index f26989d98..6f7d90bd4 100644 --- a/program/include/rcube_session.php +++ b/program/include/rcube_session.php @@ -65,7 +65,7 @@ class rcube_session // use memcache backend if ($config->get('session_storage', 'db') == 'memcache') { - $this->memcache = rcmail::get_instance()->get_memcache(); + $this->memcache = rcube::get_instance()->get_memcache(); // set custom functions for PHP session management if memcache is available if ($this->memcache) { @@ -632,7 +632,7 @@ class rcube_session function log($line) { if ($this->logging) - rcmail::write_log('session', $line); + rcube::write_log('session', $line); } } diff --git a/program/include/rcube_smtp.php b/program/include/rcube_smtp.php index 0ff07adaf..8bea14e96 100644 --- a/program/include/rcube_smtp.php +++ b/program/include/rcube_smtp.php @@ -52,7 +52,7 @@ class rcube_smtp */ public function connect($host=null, $port=null, $user=null, $pass=null) { - $RCMAIL = rcube::get_instance(); + $rcube = rcube::get_instance(); // disconnect/destroy $this->conn $this->disconnect(); @@ -61,16 +61,16 @@ class rcube_smtp $this->error = $this->response = null; // let plugins alter smtp connection config - $CONFIG = $RCMAIL->plugins->exec_hook('smtp_connect', array( - 'smtp_server' => $host ? $host : $RCMAIL->config->get('smtp_server'), - 'smtp_port' => $port ? $port : $RCMAIL->config->get('smtp_port', 25), - 'smtp_user' => $user ? $user : $RCMAIL->config->get('smtp_user'), - 'smtp_pass' => $pass ? $pass : $RCMAIL->config->get('smtp_pass'), - 'smtp_auth_cid' => $RCMAIL->config->get('smtp_auth_cid'), - 'smtp_auth_pw' => $RCMAIL->config->get('smtp_auth_pw'), - 'smtp_auth_type' => $RCMAIL->config->get('smtp_auth_type'), - 'smtp_helo_host' => $RCMAIL->config->get('smtp_helo_host'), - 'smtp_timeout' => $RCMAIL->config->get('smtp_timeout'), + $CONFIG = $rcube->plugins->exec_hook('smtp_connect', array( + 'smtp_server' => $host ? $host : $rcube->config->get('smtp_server'), + 'smtp_port' => $port ? $port : $rcube->config->get('smtp_port', 25), + 'smtp_user' => $user ? $user : $rcube->config->get('smtp_user'), + 'smtp_pass' => $pass ? $pass : $rcube->config->get('smtp_pass'), + 'smtp_auth_cid' => $rcube->config->get('smtp_auth_cid'), + 'smtp_auth_pw' => $rcube->config->get('smtp_auth_pw'), + 'smtp_auth_type' => $rcube->config->get('smtp_auth_type'), + 'smtp_helo_host' => $rcube->config->get('smtp_helo_host'), + 'smtp_timeout' => $rcube->config->get('smtp_timeout'), 'smtp_auth_callbacks' => array(), )); @@ -109,7 +109,7 @@ class rcube_smtp $this->conn = new Net_SMTP($smtp_host, $smtp_port, $helo_host); - if ($RCMAIL->config->get('smtp_debug')) + if ($rcube->config->get('smtp_debug')) $this->conn->setDebug(true, array($this, 'debug_handler')); // register authentication methods @@ -138,7 +138,7 @@ class rcube_smtp } $smtp_user = str_replace('%u', $_SESSION['username'], $CONFIG['smtp_user']); - $smtp_pass = str_replace('%p', $RCMAIL->decrypt($_SESSION['password']), $CONFIG['smtp_pass']); + $smtp_pass = str_replace('%p', $rcube->decrypt($_SESSION['password']), $CONFIG['smtp_pass']); $smtp_auth_type = empty($CONFIG['smtp_auth_type']) ? NULL : $CONFIG['smtp_auth_type']; if (!empty($CONFIG['smtp_auth_cid'])) { @@ -338,7 +338,7 @@ class rcube_smtp */ public function debug_handler(&$smtp, $message) { - rcmail::write_log('smtp', preg_replace('/\r\n$/', '', $message)); + rcube::write_log('smtp', preg_replace('/\r\n$/', '', $message)); } diff --git a/program/include/rcube_spellchecker.php b/program/include/rcube_spellchecker.php index 8dfc3ead1..fc8a7d5ca 100644 --- a/program/include/rcube_spellchecker.php +++ b/program/include/rcube_spellchecker.php @@ -56,7 +56,7 @@ class rcube_spellchecker */ function __construct($lang = 'en') { - $this->rc = rcmail::get_instance(); + $this->rc = rcube::get_instance(); $this->engine = $this->rc->config->get('spellcheck_engine', 'googie'); $this->lang = $lang ? $lang : 'en'; diff --git a/program/include/rcube_user.php b/program/include/rcube_user.php index 804267459..7a00c2116 100644 --- a/program/include/rcube_user.php +++ b/program/include/rcube_user.php @@ -44,9 +44,9 @@ class rcube_user private $db; /** - * rcmail object. + * Framework object. * - * @var rcmail + * @var rcube */ private $rc; @@ -61,7 +61,7 @@ class rcube_user */ function __construct($id = null, $sql_arr = null) { - $this->rc = rcmail::get_instance(); + $this->rc = rcube::get_instance(); $this->db = $this->rc->get_dbh(); if ($id && !$sql_arr) { @@ -400,7 +400,7 @@ class rcube_user */ static function query($user, $host) { - $dbh = rcmail::get_instance()->get_dbh(); + $dbh = rcube::get_instance()->get_dbh(); // query for matching user name $query = "SELECT * FROM ".$dbh->table_name('users')." WHERE mail_host = ? AND %s = ?"; @@ -431,14 +431,14 @@ class rcube_user { $user_name = ''; $user_email = ''; - $rcmail = rcmail::get_instance(); + $rcube = rcube::get_instance(); // try to resolve user in virtuser table and file if ($email_list = self::user2email($user, false, true)) { $user_email = is_array($email_list[0]) ? $email_list[0]['email'] : $email_list[0]; } - $data = $rcmail->plugins->exec_hook('user_create', + $data = $rcube->plugins->exec_hook('user_create', array('user'=>$user, 'user_name'=>$user_name, 'user_email'=>$user_email, 'host'=>$host)); // plugin aborted this operation @@ -448,7 +448,7 @@ class rcube_user $user_name = $data['user_name']; $user_email = $data['user_email']; - $dbh = $rcmail->get_dbh(); + $dbh = $rcube->get_dbh(); $dbh->query( "INSERT INTO ".$dbh->table_name('users'). @@ -462,9 +462,9 @@ class rcube_user if ($user_id = $dbh->insert_id('users')) { // create rcube_user instance to make plugin hooks work $user_instance = new rcube_user($user_id); - $rcmail->user = $user_instance; + $rcube->user = $user_instance; - $mail_domain = $rcmail->config->mail_domain($host); + $mail_domain = $rcube->config->mail_domain($host); if ($user_email == '') { $user_email = strpos($user, '@') ? $user : sprintf('%s@%s', $user, $mail_domain); @@ -476,7 +476,7 @@ class rcube_user if (empty($email_list)) $email_list[] = strip_newlines($user_email); // identities_level check - else if (count($email_list) > 1 && $rcmail->config->get('identities_level', 0) > 1) + else if (count($email_list) > 1 && $rcube->config->get('identities_level', 0) > 1) $email_list = array($email_list[0]); // create new identities records @@ -497,11 +497,11 @@ class rcube_user $record['user_id'] = $user_id; $record['standard'] = $standard; - $plugin = $rcmail->plugins->exec_hook('identity_create', + $plugin = $rcube->plugins->exec_hook('identity_create', array('login' => true, 'record' => $record)); if (!$plugin['abort'] && $plugin['record']['email']) { - $rcmail->user->insert_identity($plugin['record']); + $rcube->user->insert_identity($plugin['record']); } $standard = 0; } @@ -527,8 +527,8 @@ class rcube_user */ static function email2user($email) { - $rcmail = rcmail::get_instance(); - $plugin = $rcmail->plugins->exec_hook('email2user', + $rcube = rcube::get_instance(); + $plugin = $rcube->plugins->exec_hook('email2user', array('email' => $email, 'user' => NULL)); return $plugin['user']; @@ -545,8 +545,8 @@ class rcube_user */ static function user2email($user, $first=true, $extended=false) { - $rcmail = rcmail::get_instance(); - $plugin = $rcmail->plugins->exec_hook('user2email', + $rcube = rcube::get_instance(); + $plugin = $rcube->plugins->exec_hook('user2email', array('email' => NULL, 'user' => $user, 'first' => $first, 'extended' => $extended));