Changeset cc90ed1 in github


Ignore:
Timestamp:
Jun 16, 2011 8:20:19 AM (2 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
3ddca3b
Parents:
1a03432
Message:
  • Add addressbook name in contact info frame (#1487958)
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • program/include/rcube_addressbook.php

    re848180 rcc90ed1  
    3434    const ERROR_SAVING = 4; 
    3535    const ERROR_SEARCH = 5; 
    36      
     36 
    3737    /** public properties (mandatory) */ 
    3838    public $primary_key; 
     
    4444    public $page_size = 10; 
    4545    public $coltypes = array('name' => array('limit'=>1), 'firstname' => array('limit'=>1), 'surname' => array('limit'=>1), 'email' => array('limit'=>1)); 
    46      
     46 
    4747    protected $error; 
     48 
     49    /** 
     50     * Returns addressbook name (e.g. for addressbooks listing) 
     51     */ 
     52    abstract function get_name(); 
    4853 
    4954    /** 
     
    130135      return $this->error; 
    131136    } 
    132      
     137 
    133138    /** 
    134139     * Setter for errors for internal use 
     
    379384            } 
    380385        } 
    381        
     386 
    382387        return $out; 
    383388    } 
     
    398403            array(' ', '\\1\\2', ' '), 
    399404            $str)); 
    400          
     405 
    401406        foreach ($arr as $i => $part) { 
    402407            if (utf8_encode(utf8_decode($part)) == $part) {  // is latin-1 ? 
     
    409414                $arr[$i] = mb_strtolower($part); 
    410415        } 
    411          
     416 
    412417        return join(" ", $arr); 
    413418    } 
  • program/include/rcube_contacts.php

    r62e2254 rcc90ed1  
    4242    private $filter = null; 
    4343    private $result = null; 
     44    private $name; 
    4445    private $cache; 
    4546    private $table_cols = array('name', 'email', 'firstname', 'surname'); 
     
    7778 
    7879    /** 
     80     * Returns addressbook name 
     81     */ 
     82     function get_name() 
     83     { 
     84        return $this->name; 
     85     } 
     86 
     87 
     88    /** 
    7989     * Save a search string for future listings 
    8090     * 
    81      * @param  string SQL params to use in listing method 
     91     * @param string SQL params to use in listing method 
    8292     */ 
    8393    function set_search_set($filter) 
  • program/include/rcube_ldap.php

    rfd89754 rcc90ed1  
    293293 
    294294    /** 
    295     * Bind connection with DN and password 
    296     * 
    297     * @param string Bind DN 
    298     * @param string Bind password 
    299     * @return boolean True on success, False on error 
    300     */ 
     295     * Bind connection with DN and password 
     296     * 
     297     * @param string Bind DN 
     298     * @param string Bind password 
     299     * 
     300     * @return boolean True on success, False on error 
     301     */ 
    301302    private function _bind($dn, $pass) 
    302303    { 
     
    325326 
    326327    /** 
    327     * Close connection to LDAP server 
    328     */ 
     328     * Close connection to LDAP server 
     329     */ 
    329330    function close() 
    330331    { 
     
    339340 
    340341    /** 
    341     * Set internal list page 
    342     * 
    343     * @param  number  Page number to list 
    344     * @access public 
    345     */ 
     342     * Returns address book name 
     343     * 
     344     * @return string Address book name 
     345     */ 
     346    function get_name() 
     347    { 
     348        return $this->prop['name']; 
     349    } 
     350 
     351 
     352    /** 
     353     * Set internal list page 
     354     * 
     355     * @param number $page Page number to list 
     356     */ 
    346357    function set_page($page) 
    347358    { 
     
    351362 
    352363    /** 
    353     * Set internal page size 
    354     * 
    355     * @param  number  Number of messages to display on one page 
    356     * @access public 
    357     */ 
     364     * Set internal page size 
     365     * 
     366     * @param number $size Number of messages to display on one page 
     367     */ 
    358368    function set_pagesize($size) 
    359369    { 
     
    363373 
    364374    /** 
    365     * Save a search string for future listings 
    366     * 
    367     * @param string Filter string 
    368     */ 
     375     * Save a search string for future listings 
     376     * 
     377     * @param string $filter Filter string 
     378     */ 
    369379    function set_search_set($filter) 
    370380    { 
     
    374384 
    375385    /** 
    376     * Getter for saved search properties 
    377     * 
    378     * @return mixed Search properties used by this class 
    379     */ 
     386     * Getter for saved search properties 
     387     * 
     388     * @return mixed Search properties used by this class 
     389     */ 
    380390    function get_search_set() 
    381391    { 
     
    385395 
    386396    /** 
    387     * Reset all saved results and search parameters 
    388     */ 
     397     * Reset all saved results and search parameters 
     398     */ 
    389399    function reset() 
    390400    { 
     
    396406 
    397407    /** 
    398     * List the current set of contact records 
    399     * 
    400     * @param  array  List of cols to show 
    401     * @param  int    Only return this number of records 
    402     * @return array  Indexed list of contact records, each a hash array 
    403     */ 
     408     * List the current set of contact records 
     409     * 
     410     * @param  array  List of cols to show 
     411     * @param  int    Only return this number of records 
     412     * 
     413     * @return array  Indexed list of contact records, each a hash array 
     414     */ 
    404415    function list_records($cols=null, $subset=0) 
    405416    { 
     
    454465 
    455466    /** 
    456     * Search contacts 
    457     * 
    458     * @param mixed   $fields   The field name of array of field names to search in 
    459     * @param mixed   $value    Search value (or array of values when $fields is array) 
    460     * @param boolean $strict   True for strict, False for partial (fuzzy) matching 
    461     * @param boolean $select   True if results are requested, False if count only 
    462     * @param boolean $nocount  (Not used) 
    463     * @param array   $required List of fields that cannot be empty 
    464     * 
    465     * @return array  Indexed list of contact records and 'count' value 
    466     */ 
     467     * Search contacts 
     468     * 
     469     * @param mixed   $fields   The field name of array of field names to search in 
     470     * @param mixed   $value    Search value (or array of values when $fields is array) 
     471     * @param boolean $strict   True for strict, False for partial (fuzzy) matching 
     472     * @param boolean $select   True if results are requested, False if count only 
     473     * @param boolean $nocount  (Not used) 
     474     * @param array   $required List of fields that cannot be empty 
     475     * 
     476     * @return array  Indexed list of contact records and 'count' value 
     477     */ 
    467478    function search($fields, $value, $strict=false, $select=true, $nocount=false, $required=array()) 
    468479    { 
     
    544555 
    545556    /** 
    546     * Count number of available contacts in database 
    547     * 
    548     * @return object rcube_result_set Resultset with values for 'count' and 'first' 
    549     */ 
     557     * Count number of available contacts in database 
     558     * 
     559     * @return object rcube_result_set Resultset with values for 'count' and 'first' 
     560     */ 
    550561    function count() 
    551562    { 
     
    571582 
    572583    /** 
    573     * Return the last result set 
    574     * 
    575     * @return object rcube_result_set Current resultset or NULL if nothing selected yet 
    576     */ 
     584     * Return the last result set 
     585     * 
     586     * @return object rcube_result_set Current resultset or NULL if nothing selected yet 
     587     */ 
    577588    function get_result() 
    578589    { 
     
    582593 
    583594    /** 
    584     * Get a specific contact record 
    585     * 
    586     * @param mixed   Record identifier 
    587     * @param boolean Return as associative array 
    588     * @return mixed  Hash array or rcube_result_set with all record fields 
    589     */ 
     595     * Get a specific contact record 
     596     * 
     597     * @param mixed   Record identifier 
     598     * @param boolean Return as associative array 
     599     * 
     600     * @return mixed  Hash array or rcube_result_set with all record fields 
     601     */ 
    590602    function get_record($dn, $assoc=false) 
    591603    { 
     
    625637     * 
    626638     * @param array Assoziative array with data to save 
     639     * 
    627640     * @return boolean True if input is valid, False if not. 
    628641     */ 
     
    634647            return false; 
    635648        } 
    636          
     649 
    637650        // validate e-mail addresses 
    638651        return parent::validate($save_data); 
     
    641654 
    642655    /** 
    643     * Create a new contact record 
    644     * 
    645     * @param array    Hash array with save data 
    646     * @return encoded record ID on success, False on error 
    647     */ 
     656     * Create a new contact record 
     657     * 
     658     * @param array    Hash array with save data 
     659     * 
     660     * @return encoded record ID on success, False on error 
     661     */ 
    648662    function insert($save_cols) 
    649663    { 
     
    699713 
    700714    /** 
    701     * Update a specific contact record 
    702     * 
    703     * @param mixed Record identifier 
    704     * @param array Hash array with save data 
    705     * @return boolean True on success, False on error 
    706     */ 
     715     * Update a specific contact record 
     716     * 
     717     * @param mixed Record identifier 
     718     * @param array Hash array with save data 
     719     * 
     720     * @return boolean True on success, False on error 
     721     */ 
    707722    function update($id, $save_cols) 
    708723    { 
     
    714729        $replacedata = array(); 
    715730        $deletedata = array(); 
     731 
    716732        foreach ($this->fieldmap as $col => $fld) { 
    717733            $val = $save_cols[$col]; 
     
    817833 
    818834    /** 
    819     * Mark one or more contact records as deleted 
    820     * 
    821     * @param array  Record identifiers 
    822     * @return boolean True on success, False on error 
    823     */ 
     835     * Mark one or more contact records as deleted 
     836     * 
     837     * @param array  Record identifiers 
     838     * 
     839     * @return boolean True on success, False on error 
     840     */ 
    824841    function delete($ids) 
    825842    { 
     
    857874 
    858875    /** 
    859     * Execute the LDAP search based on the stored credentials 
    860     * 
    861     * @access private 
    862     */ 
     876     * Execute the LDAP search based on the stored credentials 
     877     */ 
    863878    private function _exec_search($count = false) 
    864879    { 
     
    895910        return false; 
    896911    } 
    897      
     912 
    898913    /** 
    899914     * Set server controls for Virtual List View (paginated listing) 
     
    918933 
    919934    /** 
    920     * @access private 
    921     */ 
     935     * Converts LDAP entry into an array 
     936     */ 
    922937    private function _ldap2result($rec) 
    923938    { 
     
    948963 
    949964    /** 
    950     * @access private 
    951     */ 
     965     * Return real field name (from fields map) 
     966     */ 
    952967    private function _map_field($field) 
    953968    { 
     
    957972 
    958973    /** 
    959     * @access private 
    960     */ 
    961     private function _attr_name($name) 
     974     * Returns unified attribute name (resolving aliases) 
     975     */ 
     976    private static function _attr_name($name) 
    962977    { 
    963978        // list of known attribute aliases 
     
    974989 
    975990    /** 
    976     * @access private 
    977     */ 
     991     * Prints debug info to the log 
     992     */ 
    978993    private function _debug($str) 
    979994    { 
     
    984999 
    9851000    /** 
    986     * @static 
    987     */ 
    988     private function _quote_string($str, $dn=false) 
     1001     * Quotes attribute value string 
     1002     * 
     1003     * @param string $str Attribute value 
     1004     * @param bool   $dn  True if the attribute is a DN 
     1005     * 
     1006     * @return string Quoted string 
     1007     */ 
     1008    private static function _quote_string($str, $dn=false) 
    9891009    { 
    9901010        // take firt entry if array given 
     
    12961316        # construct the string from right to left 
    12971317        $str = "020100"; # contentCount 
    1298          
     1318 
    12991319        $ber_val = self::_ber_encode_int($offset);  // returns encoded integer value in hex format 
    13001320 
     
    13581378        $val = dechex($offset); 
    13591379        $prefix = ''; 
    1360          
     1380 
    13611381        // check if bit 8 of high byte is 1 
    13621382        if (preg_match('/^[89abcdef]/', $val)) 
  • program/steps/addressbook/func.inc

    rca7dda4 rcc90ed1  
    8282 
    8383    $OUTPUT->set_pagetitle(rcube_label('addressbook')); 
     84    $_SESSION['addressbooks_count'] = count($js_list); 
    8485 
    8586    $CONTACTS = rcmail_contact_source($source, true); 
  • program/steps/addressbook/show.inc

    recf295f rcc90ed1  
    3333} 
    3434 
     35// get address book name (for display) 
     36if ($_SESSION['addressbooks_count'] > 1) { 
     37    $name = $CONTACTS->get_name(); 
     38    if (!$name && $source == 0) { 
     39        $name = rcube_label('personaladrbook'); 
     40    } 
     41    $OUTPUT->set_env('sourcename', $name); 
     42} 
     43 
    3544// return raw photo of the given contact 
    3645if ($RCMAIL->action == 'photo') { 
  • skins/default/addressbook.css

    re9a9f2f6 rcc90ed1  
    385385        padding: 2px; 
    386386} 
     387 
     388#sourcename 
     389{ 
     390  color: #666; 
     391  font-size: 10px; 
     392  margin-left: 2px; 
     393} 
  • skins/default/templates/contact.html

    r0501b63 rcc90ed1  
    1010<div id="contact-title" class="boxtitle"><roundcube:label name="contactproperties" /></div> 
    1111<div id="contact-details" class="boxcontent"> 
     12  <roundcube:if condition="strlen(env:sourcename)" /> 
     13    <div id="sourcename"><roundcube:label name="addressbook" />: <roundcube:var name="env:sourcename" /></div> 
     14  <roundcube:endif /> 
     15 
    1216  <div id="contactphoto"><roundcube:object name="contactphoto" id="contactpic" placeholder="/images/contactpic.png" /></div> 
    1317  <roundcube:object name="contacthead" id="contacthead" /> 
Note: See TracChangeset for help on using the changeset viewer.