Changeset 5829 in subversion


Ignore:
Timestamp:
Jan 27, 2012 4:56:11 AM (16 months ago)
Author:
alec
Message:
  • Provide general get_user_id/get_user_name methods, removing dependency on rcube_user in some classes
Location:
branches/devel-framework/roundcubemail/program/include
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/devel-framework/roundcubemail/program/include/rcmail.php

    r5828 r5829  
    24062406    } 
    24072407 
     2408 
     2409    /** 
     2410     * Getter for logged user ID. 
     2411     * 
     2412     * @return mixed User identifier 
     2413     */ 
     2414    public function get_user_id() 
     2415    { 
     2416        if (is_object($this->user)) { 
     2417            return $this->user->ID; 
     2418        } 
     2419    } 
     2420 
     2421 
     2422    /** 
     2423     * Getter for logged user name. 
     2424     * 
     2425     * @return string User name 
     2426     */ 
     2427    public function get_user_name() 
     2428    { 
     2429        if (is_object($this->user)) { 
     2430            return $this->user->get_username(); 
     2431        } 
     2432    } 
    24082433} 
  • branches/devel-framework/roundcubemail/program/include/rcube_imap.php

    r5828 r5829  
    36063606            if ($dbh = $rcmail->get_dbh()) { 
    36073607                $this->mcache = new rcube_imap_cache( 
    3608                     $dbh, $this, $rcmail->user->ID, $this->options['skip_deleted']); 
     3608                    $dbh, $this, $rcmail->get_user_id(), $this->options['skip_deleted']); 
    36093609            } 
    36103610        } 
  • branches/devel-framework/roundcubemail/program/include/rcube_imap_cache.php

    r5822 r5829  
    9393        $this->db           = $db; 
    9494        $this->imap         = $imap; 
    95         $this->userid       = (int)$userid; 
     95        $this->userid       = $userid; 
    9696        $this->skip_deleted = $skip_deleted; 
    9797    } 
     
    512512                "DELETE FROM ".$this->db->table_name('cache_messages') 
    513513                ." WHERE user_id = ?" 
    514                     ." AND mailbox = ".$this->db->quote($mailbox) 
     514                    ." AND mailbox = ?" 
    515515                    .($uids !== null ? " AND uid IN (".$this->db->array2list((array)$uids, 'integer').")" : ""), 
    516                 $this->userid); 
     516                $this->userid, $mailbox); 
    517517        } 
    518518 
     
    534534            $this->db->query( 
    535535                "DELETE FROM ".$this->db->table_name('cache_index') 
    536                 ." WHERE user_id = ".intval($this->userid) 
    537                     .(strlen($mailbox) ? " AND mailbox = ".$this->db->quote($mailbox) : "") 
     536                ." WHERE user_id = ?" 
     537                    .(strlen($mailbox) ? " AND mailbox = ".$this->db->quote($mailbox) : ""), 
     538                $this->userid 
    538539            ); 
    539540        } 
     
    542543                "UPDATE ".$this->db->table_name('cache_index') 
    543544                ." SET valid = 0" 
    544                 ." WHERE user_id = ".intval($this->userid) 
    545                     .(strlen($mailbox) ? " AND mailbox = ".$this->db->quote($mailbox) : "") 
     545                ." WHERE user_id = ?" 
     546                    .(strlen($mailbox) ? " AND mailbox = ".$this->db->quote($mailbox) : ""), 
     547                $this->userid 
    546548            ); 
    547549        } 
     
    567569        $this->db->query( 
    568570            "DELETE FROM ".$this->db->table_name('cache_thread') 
    569             ." WHERE user_id = ".intval($this->userid) 
    570                 .(strlen($mailbox) ? " AND mailbox = ".$this->db->quote($mailbox) : "") 
     571            ." WHERE user_id = ?" 
     572                .(strlen($mailbox) ? " AND mailbox = ".$this->db->quote($mailbox) : ""), 
     573            $this->userid 
    571574        ); 
    572575 
  • branches/devel-framework/roundcubemail/program/include/rcube_ldap.php

    r5828 r5829  
    6464    * Object constructor 
    6565    * 
    66     * @param array      LDAP connection properties 
    67     * @param boolean    Enables debug mode 
    68     * @param string     Current user mail domain name 
    69     * @param integer User-ID 
     66    * @param array       $p            LDAP connection properties 
     67    * @param boolean $debug        Enables debug mode 
     68    * @param string  $mail_domain  Current user mail domain name 
    7069    */ 
    71     function __construct($p, $debug=false, $mail_domain=NULL) 
     70    function __construct($p, $debug = false, $mail_domain = null) 
    7271    { 
    7372        $this->prop = $p; 
     
    155154    private function _connect() 
    156155    { 
    157         global $RCMAIL; 
     156        $RCMAIL = rcmail::get_instance(); 
    158157 
    159158        if (!function_exists('ldap_connect')) 
     
    227226 
    228227            // Get the pieces needed for variable replacement. 
    229             if ($fu = $RCMAIL->user->get_username()) 
     228            if ($fu = $RCMAIL->get_user_name()) 
    230229                list($u, $d) = explode('@', $fu); 
    231230            else 
  • branches/devel-framework/roundcubemail/program/include/rcube_spellchecker.php

    r5828 r5829  
    533533    { 
    534534        if (strcasecmp($this->options['dictionary'], 'shared') != 0) { 
    535             $userid = (int) $this->rc->user->ID; 
     535            $userid = $this->rc->get_user_id(); 
    536536        } 
    537537 
     
    548548                    "UPDATE ".$this->rc->db->table_name('dictionary') 
    549549                    ." SET data = ?" 
    550                     ." WHERE user_id " . ($plugin['userid'] ? "= ".$plugin['userid'] : "IS NULL") 
     550                    ." WHERE user_id " . ($plugin['userid'] ? "= ".$this->rc->db->quote($plugin['userid']) : "IS NULL") 
    551551                        ." AND " . $this->rc->db->quoteIdentifier('language') . " = ?", 
    552552                    implode(' ', $plugin['dictionary']), $plugin['language']); 
     
    556556                $this->rc->db->query( 
    557557                    "DELETE FROM " . $this->rc->db->table_name('dictionary') 
    558                     ." WHERE user_id " . ($plugin['userid'] ? "= ".$plugin['userid'] : "IS NULL") 
     558                    ." WHERE user_id " . ($plugin['userid'] ? "= ".$this->rc->db->quote($plugin['userid']) : "IS NULL") 
    559559                        ." AND " . $this->rc->db->quoteIdentifier('language') . " = ?", 
    560560                    $plugin['language']); 
     
    580580 
    581581        if (strcasecmp($this->options['dictionary'], 'shared') != 0) { 
    582             $userid = (int) $this->rc->user->ID; 
     582            $userid = $this->rc->get_user_id(); 
    583583        } 
    584584 
     
    590590            $this->rc->db->query( 
    591591                "SELECT data FROM ".$this->rc->db->table_name('dictionary') 
    592                 ." WHERE user_id ". ($plugin['userid'] ? "= ".$plugin['userid'] : "IS NULL") 
     592                ." WHERE user_id ". ($plugin['userid'] ? "= ".$this->rc->db->quote($plugin['userid']) : "IS NULL") 
    593593                    ." AND " . $this->rc->db->quoteIdentifier('language') . " = ?", 
    594594                $plugin['language']); 
  • branches/devel-framework/roundcubemail/program/include/rcube_user.php

    r5828 r5829  
    125125                // Check last write attempt time, try to write again (every 5 minutes) 
    126126                if ($_SESSION['preferences_time'] < time() - 5 * 60) { 
    127                     $saved_prefs = unserialize($_SESSION['preferences']); 
     127                    $saved_prefs = unserialize($_SESSION['preferences']); 
    128128                    $this->rc->session->remove('preferences'); 
    129                     $this->rc->session->remove('preferences_time'); 
     129                    $this->rc->session->remove('preferences_time'); 
    130130                    $this->save_prefs($saved_prefs); 
    131131                } 
Note: See TracChangeset for help on using the changeset viewer.