alecpl
2012-04-16 be98dfc2c0bdc4f911c6daa94e3fddc29afc89a8
- Replace some references to rcmail with rcube


16 files modified
182 ■■■■ changed files
program/include/rcube.php 20 ●●●●● patch | view | raw | blame | history
program/include/rcube_cache.php 8 ●●●● patch | view | raw | blame | history
program/include/rcube_config.php 12 ●●●●● patch | view | raw | blame | history
program/include/rcube_image.php 16 ●●●● patch | view | raw | blame | history
program/include/rcube_imap.php 20 ●●●● patch | view | raw | blame | history
program/include/rcube_ldap.php 14 ●●●● patch | view | raw | blame | history
program/include/rcube_mdb2.php 10 ●●●● patch | view | raw | blame | history
program/include/rcube_message.php 4 ●●●● patch | view | raw | blame | history
program/include/rcube_mime.php 2 ●●● patch | view | raw | blame | history
program/include/rcube_output_html.php 2 ●●● patch | view | raw | blame | history
program/include/rcube_output_json.php 2 ●●● patch | view | raw | blame | history
program/include/rcube_plugin.php 6 ●●●● patch | view | raw | blame | history
program/include/rcube_session.php 4 ●●●● patch | view | raw | blame | history
program/include/rcube_smtp.php 28 ●●●● patch | view | raw | blame | history
program/include/rcube_spellchecker.php 2 ●●● patch | view | raw | blame | history
program/include/rcube_user.php 32 ●●●● patch | view | raw | blame | history
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 @@
  const INIT_WITH_PLUGINS = 2;
  /**
   * Singleton instace of rcmail
   * Singleton instace of rcube
   *
   * @var rcmail
   */
@@ -109,7 +109,7 @@
  /**
   * 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 @@
    /*-
     * 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 @@
    {
        $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();
program/include/rcube_cache.php
@@ -66,12 +66,12 @@
     */
    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 @@
        }
        else {
            $this->type = 'db';
            $this->db   = $rcmail->get_dbh();
            $this->db   = $rcube->get_dbh();
        }
        $this->userid    = (int) $userid;
program/include/rcube_config.php
@@ -186,19 +186,15 @@
            $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'];
    }
program/include/rcube_image.php
@@ -73,10 +73,10 @@
     */
    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 @@
            $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 @@
     */
    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));
program/include/rcube_imap.php
@@ -2598,7 +2598,7 @@
        }
        // 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 @@
    /**
     * 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 @@
    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 @@
    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 @@
    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 @@
     */
    public function debug_handler(&$imap, $message)
    {
        rcmail::write_log('imap', $message);
        rcube::write_log('imap', $message);
    }
program/include/rcube_ldap.php
@@ -163,8 +163,8 @@
        $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 @@
    */
    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 @@
        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 @@
        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 @@
    private function _debug($str)
    {
        if ($this->debug) {
            rcmail::write_log('ldap', $str);
            rcube::write_log('ldap', $str);
        }
    }
program/include/rcube_mdb2.php
@@ -826,7 +826,7 @@
        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 @@
     */
    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 @@
     */
    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;
        }
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;
program/include/rcube_mime.php
@@ -46,7 +46,7 @@
            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);
        }
    }
program/include/rcube_output_html.php
@@ -1206,7 +1206,7 @@
            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);
program/include/rcube_output_json.php
@@ -170,7 +170,7 @@
     */
    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;
program/include/rcube_plugin.php
@@ -110,8 +110,8 @@
  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 @@
      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
program/include/rcube_session.php
@@ -65,7 +65,7 @@
    // 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 @@
  function log($line)
  {
    if ($this->logging)
      rcmail::write_log('session', $line);
      rcube::write_log('session', $line);
  }
}
program/include/rcube_smtp.php
@@ -52,7 +52,7 @@
   */
  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 @@
    $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 @@
    $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 @@
    }
    $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 @@
   */
  public function debug_handler(&$smtp, $message)
  {
    rcmail::write_log('smtp', preg_replace('/\r\n$/', '', $message));
    rcube::write_log('smtp', preg_replace('/\r\n$/', '', $message));
  }
program/include/rcube_spellchecker.php
@@ -56,7 +56,7 @@
     */
    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';
program/include/rcube_user.php
@@ -44,9 +44,9 @@
    private $db;
    /**
     * rcmail object.
     * Framework object.
     *
     * @var rcmail
     * @var rcube
     */
    private $rc;
@@ -61,7 +61,7 @@
     */
    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 @@
     */
    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 @@
    {
        $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 @@
        $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 @@
        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 @@
            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 @@
                $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 @@
     */
    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 @@
     */
    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));