[Svn] r4857 - in trunk/roundcubemail: program/include program/steps/addressbook skins/default skins/default/templates

trac at roundcube.net trac at roundcube.net
Thu Jun 16 14:20:19 CEST 2011


Author: alec
Date: 2011-06-16 07:20:19 -0500 (Thu, 16 Jun 2011)
New Revision: 4857

Modified:
   trunk/roundcubemail/program/include/rcube_addressbook.php
   trunk/roundcubemail/program/include/rcube_contacts.php
   trunk/roundcubemail/program/include/rcube_ldap.php
   trunk/roundcubemail/program/steps/addressbook/func.inc
   trunk/roundcubemail/program/steps/addressbook/show.inc
   trunk/roundcubemail/skins/default/addressbook.css
   trunk/roundcubemail/skins/default/templates/contact.html
Log:
- Add addressbook name in contact info frame (#1487958)


Modified: trunk/roundcubemail/program/include/rcube_addressbook.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_addressbook.php	2011-06-15 13:21:49 UTC (rev 4856)
+++ trunk/roundcubemail/program/include/rcube_addressbook.php	2011-06-16 12:20:19 UTC (rev 4857)
@@ -33,7 +33,7 @@
     const ERROR_INCOMPLETE = 3;
     const ERROR_SAVING = 4;
     const ERROR_SEARCH = 5;
-    
+
     /** public properties (mandatory) */
     public $primary_key;
     public $groups = false;
@@ -43,10 +43,15 @@
     public $list_page = 1;
     public $page_size = 10;
     public $coltypes = array('name' => array('limit'=>1), 'firstname' => array('limit'=>1), 'surname' => array('limit'=>1), 'email' => array('limit'=>1));
-    
+
     protected $error;
 
     /**
+     * Returns addressbook name (e.g. for addressbooks listing)
+     */
+    abstract function get_name();
+
+    /**
      * Save a search string for future listings
      *
      * @param mixed Search params to use in listing method, obtained by get_search_set()
@@ -129,7 +134,7 @@
     {
       return $this->error;
     }
-    
+
     /**
      * Setter for errors for internal use
      *
@@ -378,7 +383,7 @@
                 }
             }
         }
-      
+
         return $out;
     }
 
@@ -397,7 +402,7 @@
             array('/[\s;\+\-\/]+/i', '/(\d)[-.\s]+(\d)/', '/\s\w{1,3}\s/'),
             array(' ', '\\1\\2', ' '),
             $str));
-        
+
         foreach ($arr as $i => $part) {
             if (utf8_encode(utf8_decode($part)) == $part) {  // is latin-1 ?
                 $arr[$i] = utf8_encode(strtr(strtolower(strtr(utf8_decode($part),
@@ -408,7 +413,7 @@
             else
                 $arr[$i] = mb_strtolower($part);
         }
-        
+
         return join(" ", $arr);
     }
 

Modified: trunk/roundcubemail/program/include/rcube_contacts.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_contacts.php	2011-06-15 13:21:49 UTC (rev 4856)
+++ trunk/roundcubemail/program/include/rcube_contacts.php	2011-06-16 12:20:19 UTC (rev 4857)
@@ -41,6 +41,7 @@
     private $user_id = 0;
     private $filter = null;
     private $result = null;
+    private $name;
     private $cache;
     private $table_cols = array('name', 'email', 'firstname', 'surname');
     private $fulltext_cols = array('name', 'firstname', 'surname', 'middlename', 'nickname',
@@ -76,9 +77,18 @@
 
 
     /**
+     * Returns addressbook name
+     */
+     function get_name()
+     {
+        return $this->name;
+     }
+
+
+    /**
      * Save a search string for future listings
      *
-     * @param  string SQL params to use in listing method
+     * @param string SQL params to use in listing method
      */
     function set_search_set($filter)
     {

Modified: trunk/roundcubemail/program/include/rcube_ldap.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_ldap.php	2011-06-15 13:21:49 UTC (rev 4856)
+++ trunk/roundcubemail/program/include/rcube_ldap.php	2011-06-16 12:20:19 UTC (rev 4857)
@@ -292,12 +292,13 @@
 
 
     /**
-    * Bind connection with DN and password
-    *
-    * @param string Bind DN
-    * @param string Bind password
-    * @return boolean True on success, False on error
-    */
+     * Bind connection with DN and password
+     *
+     * @param string Bind DN
+     * @param string Bind password
+     *
+     * @return boolean True on success, False on error
+     */
     private function _bind($dn, $pass)
     {
         if (!$this->conn) {
@@ -324,8 +325,8 @@
 
 
     /**
-    * Close connection to LDAP server
-    */
+     * Close connection to LDAP server
+     */
     function close()
     {
         if ($this->conn)
@@ -338,11 +339,21 @@
 
 
     /**
-    * Set internal list page
-    *
-    * @param  number  Page number to list
-    * @access public
-    */
+     * Returns address book name
+     *
+     * @return string Address book name
+     */
+    function get_name()
+    {
+        return $this->prop['name'];
+    }
+
+
+    /**
+     * Set internal list page
+     *
+     * @param number $page Page number to list
+     */
     function set_page($page)
     {
         $this->list_page = (int)$page;
@@ -350,11 +361,10 @@
 
 
     /**
-    * Set internal page size
-    *
-    * @param  number  Number of messages to display on one page
-    * @access public
-    */
+     * Set internal page size
+     *
+     * @param number $size Number of messages to display on one page
+     */
     function set_pagesize($size)
     {
         $this->page_size = (int)$size;
@@ -362,10 +372,10 @@
 
 
     /**
-    * Save a search string for future listings
-    *
-    * @param string Filter string
-    */
+     * Save a search string for future listings
+     *
+     * @param string $filter Filter string
+     */
     function set_search_set($filter)
     {
         $this->filter = $filter;
@@ -373,10 +383,10 @@
 
 
     /**
-    * Getter for saved search properties
-    *
-    * @return mixed Search properties used by this class
-    */
+     * Getter for saved search properties
+     *
+     * @return mixed Search properties used by this class
+     */
     function get_search_set()
     {
         return $this->filter;
@@ -384,8 +394,8 @@
 
 
     /**
-    * Reset all saved results and search parameters
-    */
+     * Reset all saved results and search parameters
+     */
     function reset()
     {
         $this->result = null;
@@ -395,12 +405,13 @@
 
 
     /**
-    * List the current set of contact records
-    *
-    * @param  array  List of cols to show
-    * @param  int    Only return this number of records
-    * @return array  Indexed list of contact records, each a hash array
-    */
+     * List the current set of contact records
+     *
+     * @param  array  List of cols to show
+     * @param  int    Only return this number of records
+     *
+     * @return array  Indexed list of contact records, each a hash array
+     */
     function list_records($cols=null, $subset=0)
     {
         // add general filter to query
@@ -453,17 +464,17 @@
 
 
     /**
-    * Search contacts
-    *
-    * @param mixed   $fields   The field name of array of field names to search in
-    * @param mixed   $value    Search value (or array of values when $fields is array)
-    * @param boolean $strict   True for strict, False for partial (fuzzy) matching
-    * @param boolean $select   True if results are requested, False if count only
-    * @param boolean $nocount  (Not used)
-    * @param array   $required List of fields that cannot be empty
-    *
-    * @return array  Indexed list of contact records and 'count' value
-    */
+     * Search contacts
+     *
+     * @param mixed   $fields   The field name of array of field names to search in
+     * @param mixed   $value    Search value (or array of values when $fields is array)
+     * @param boolean $strict   True for strict, False for partial (fuzzy) matching
+     * @param boolean $select   True if results are requested, False if count only
+     * @param boolean $nocount  (Not used)
+     * @param array   $required List of fields that cannot be empty
+     *
+     * @return array  Indexed list of contact records and 'count' value
+     */
     function search($fields, $value, $strict=false, $select=true, $nocount=false, $required=array())
     {
         // special treatment for ID-based search
@@ -543,10 +554,10 @@
 
 
     /**
-    * Count number of available contacts in database
-    *
-    * @return object rcube_result_set Resultset with values for 'count' and 'first'
-    */
+     * Count number of available contacts in database
+     *
+     * @return object rcube_result_set Resultset with values for 'count' and 'first'
+     */
     function count()
     {
         $count = 0;
@@ -570,10 +581,10 @@
 
 
     /**
-    * Return the last result set
-    *
-    * @return object rcube_result_set Current resultset or NULL if nothing selected yet
-    */
+     * Return the last result set
+     *
+     * @return object rcube_result_set Current resultset or NULL if nothing selected yet
+     */
     function get_result()
     {
         return $this->result;
@@ -581,12 +592,13 @@
 
 
     /**
-    * Get a specific contact record
-    *
-    * @param mixed   Record identifier
-    * @param boolean Return as associative array
-    * @return mixed  Hash array or rcube_result_set with all record fields
-    */
+     * Get a specific contact record
+     *
+     * @param mixed   Record identifier
+     * @param boolean Return as associative array
+     *
+     * @return mixed  Hash array or rcube_result_set with all record fields
+     */
     function get_record($dn, $assoc=false)
     {
         $res = null;
@@ -624,6 +636,7 @@
      * If input not valid, the message to display can be fetched using get_error()
      *
      * @param array Assoziative array with data to save
+     *
      * @return boolean True if input is valid, False if not.
      */
     public function validate($save_data)
@@ -633,18 +646,19 @@
             $this->set_error('warning', 'nonamewarning');
             return false;
         }
-        
+
         // validate e-mail addresses
         return parent::validate($save_data);
     }
 
 
     /**
-    * Create a new contact record
-    *
-    * @param array    Hash array with save data
-    * @return encoded record ID on success, False on error
-    */
+     * Create a new contact record
+     *
+     * @param array    Hash array with save data
+     *
+     * @return encoded record ID on success, False on error
+     */
     function insert($save_cols)
     {
         // Map out the column names to their LDAP ones to build the new entry.
@@ -698,12 +712,13 @@
 
 
     /**
-    * Update a specific contact record
-    *
-    * @param mixed Record identifier
-    * @param array Hash array with save data
-    * @return boolean True on success, False on error
-    */
+     * Update a specific contact record
+     *
+     * @param mixed Record identifier
+     * @param array Hash array with save data
+     *
+     * @return boolean True on success, False on error
+     */
     function update($id, $save_cols)
     {
         $record = $this->get_record($id, true);
@@ -713,6 +728,7 @@
         $newdata = array();
         $replacedata = array();
         $deletedata = array();
+
         foreach ($this->fieldmap as $col => $fld) {
             $val = $save_cols[$col];
             if ($fld) {
@@ -816,11 +832,12 @@
 
 
     /**
-    * Mark one or more contact records as deleted
-    *
-    * @param array  Record identifiers
-    * @return boolean True on success, False on error
-    */
+     * Mark one or more contact records as deleted
+     *
+     * @param array  Record identifiers
+     *
+     * @return boolean True on success, False on error
+     */
     function delete($ids)
     {
         if (!is_array($ids)) {
@@ -856,10 +873,8 @@
 
 
     /**
-    * Execute the LDAP search based on the stored credentials
-    *
-    * @access private
-    */
+     * Execute the LDAP search based on the stored credentials
+     */
     private function _exec_search($count = false)
     {
         if ($this->ready)
@@ -894,7 +909,7 @@
 
         return false;
     }
-    
+
     /**
      * Set server controls for Virtual List View (paginated listing)
      */
@@ -917,8 +932,8 @@
 
 
     /**
-    * @access private
-    */
+     * Converts LDAP entry into an array
+     */
     private function _ldap2result($rec)
     {
         $out = array();
@@ -947,8 +962,8 @@
 
 
     /**
-    * @access private
-    */
+     * Return real field name (from fields map)
+     */
     private function _map_field($field)
     {
         return $this->fieldmap[$field];
@@ -956,9 +971,9 @@
 
 
     /**
-    * @access private
-    */
-    private function _attr_name($name)
+     * Returns unified attribute name (resolving aliases)
+     */
+    private static function _attr_name($name)
     {
         // list of known attribute aliases
         $aliases = array(
@@ -973,8 +988,8 @@
 
 
     /**
-    * @access private
-    */
+     * Prints debug info to the log
+     */
     private function _debug($str)
     {
         if ($this->debug)
@@ -983,9 +998,14 @@
 
 
     /**
-    * @static
-    */
-    private function _quote_string($str, $dn=false)
+     * Quotes attribute value string
+     *
+     * @param string $str Attribute value
+     * @param bool   $dn  True if the attribute is a DN
+     *
+     * @return string Quoted string
+     */
+    private static function _quote_string($str, $dn=false)
     {
         // take firt entry if array given
         if (is_array($str))
@@ -1295,7 +1315,7 @@
 
         # construct the string from right to left
         $str = "020100"; # contentCount
-        
+
         $ber_val = self::_ber_encode_int($offset);  // returns encoded integer value in hex format
 
         // calculate octet length of $ber_val
@@ -1357,7 +1377,7 @@
     {
         $val = dechex($offset);
         $prefix = '';
-        
+
         // check if bit 8 of high byte is 1
         if (preg_match('/^[89abcdef]/', $val))
             $prefix = '00';

Modified: trunk/roundcubemail/program/steps/addressbook/func.inc
===================================================================
--- trunk/roundcubemail/program/steps/addressbook/func.inc	2011-06-15 13:21:49 UTC (rev 4856)
+++ trunk/roundcubemail/program/steps/addressbook/func.inc	2011-06-16 12:20:19 UTC (rev 4857)
@@ -81,6 +81,7 @@
     $OUTPUT->set_env('address_sources', $js_list);
 
     $OUTPUT->set_pagetitle(rcube_label('addressbook'));
+    $_SESSION['addressbooks_count'] = count($js_list);
 
     $CONTACTS = rcmail_contact_source($source, true);
 }

Modified: trunk/roundcubemail/program/steps/addressbook/show.inc
===================================================================
--- trunk/roundcubemail/program/steps/addressbook/show.inc	2011-06-15 13:21:49 UTC (rev 4856)
+++ trunk/roundcubemail/program/steps/addressbook/show.inc	2011-06-16 12:20:19 UTC (rev 4857)
@@ -32,6 +32,15 @@
     $OUTPU