[Svn] r4442 - in trunk/plugins: kolab_addressbook kolab_core

trac at roundcube.net trac at roundcube.net
Sat Jan 22 14:51:26 CET 2011


Author: thomasb
Date: 2011-01-22 07:51:26 -0600 (Sat, 22 Jan 2011)
New Revision: 4442

Modified:
   trunk/plugins/kolab_addressbook/kolab_addressbook.php
   trunk/plugins/kolab_addressbook/rcube_kolab_contacts.php
   trunk/plugins/kolab_core/rcube_kolab.php
Log:
Spread Kolab-specific fields to the new form groups; check if connection to Kolab server succeeded; sort contacts by name

Modified: trunk/plugins/kolab_addressbook/kolab_addressbook.php
===================================================================
--- trunk/plugins/kolab_addressbook/kolab_addressbook.php	2011-01-21 17:41:05 UTC (rev 4441)
+++ trunk/plugins/kolab_addressbook/kolab_addressbook.php	2011-01-22 13:51:26 UTC (rev 4442)
@@ -120,23 +120,18 @@
         if (!is_a($GLOBALS['CONTACTS'], 'rcube_kolab_contacts'))
             return $p;
           
-        // extend the list of contact fields to be displayed in the 'info' section
-        if (is_array($p['form']['info'])) {
-            $p['form']['info']['content']['initials'] = array('size' => 6);
+        // extend the list of contact fields to be displayed in the 'personal' section
+        if (is_array($p['form']['personal'])) {
             $p['form']['info']['content']['officelocation'] = array('size' => 40);
-            $p['form']['info']['content']['profession'] = array('size' => 40);
-            $p['form']['info']['content']['children'] = array('size' => 40);
             
+            $p['form']['personal']['content']['initials'] = array('size' => 6);
+            $p['form']['personal']['content']['profession'] = array('size' => 40);
+            $p['form']['personal']['content']['children'] = array('size' => 40);
+            
             // re-order fields according to the coltypes list
-            $block = array();
-            $contacts = reset($this->sources);
-            foreach ($contacts->coltypes as $col => $prop) {
-                if (isset($p['form']['info']['content'][$col]))
-                    $block[$col] = $p['form']['info']['content'][$col];
-            }
+            $p['form']['info']['content'] = $this->_sort_form_fields($p['form']['info']['content']);
+            $p['form']['personal']['content'] = $this->_sort_form_fields($p['form']['personal']['content']);
             
-            $p['form']['info']['content'] = $block;
-            
             // define a separate section 'settings'
             $p['form']['settings'] = array(
                 'name'    => rcube_label('kolab_addressbook.settings'),
@@ -149,5 +144,18 @@
         
         return $p;
     }
+    
+    
+    private function _sort_form_fields($contents)
+    {
+      $block = array();
+      $contacts = reset($this->sources);
+      foreach ($contacts->coltypes as $col => $prop) {
+          if (isset($contents[$col]))
+              $block[$col] = $contents[$col];
+      }
+      
+      return $block;
+    }
 
 }

Modified: trunk/plugins/kolab_addressbook/rcube_kolab_contacts.php
===================================================================
--- trunk/plugins/kolab_addressbook/rcube_kolab_contacts.php	2011-01-21 17:41:05 UTC (rev 4441)
+++ trunk/plugins/kolab_addressbook/rcube_kolab_contacts.php	2011-01-22 13:51:26 UTC (rev 4442)
@@ -26,16 +26,16 @@
       'jobtitle'     => array('limit' => 1),
       'organization' => array('limit' => 1),
       'department'   => array('limit' => 1),
-      'gender'       => array('limit' => 1),
-      'initials'     => array('type' => 'text', 'size' => 6, 'limit' => 1, 'label' => 'kolab_addressbook.initials'),
       'email'        => array('subtypes' => null),
       'phone'        => array(),
+      'address'      => array('limit' => 2, 'subtypes' => array('home','business')),
+      'officelocation' => array('type' => 'text', 'size' => 40, 'limit' => 1, 'label' => 'kolab_addressbook.officelocation'),
+      'website'      => array('limit' => 1, 'subtypes' => null),
       'im'           => array('limit' => 1, 'subtypes' => null),
-      'website'      => array('limit' => 1, 'subtypes' => null),
-      'address'      => array('limit' => 2, 'subtypes' => array('home','business')),
+      'gender'       => array('limit' => 1),
+      'initials'     => array('type' => 'text', 'size' => 6, 'limit' => 1, 'label' => 'kolab_addressbook.initials'),
       'birthday'     => array('limit' => 1),
       'anniversary'  => array('limit' => 1),
-      'officelocation' => array('type' => 'text', 'size' => 40, 'limit' => 1, 'label' => 'kolab_addressbook.officelocation'),
       'profession'   => array('type' => 'text', 'size' => 40, 'limit' => 1, 'label' => 'kolab_addressbook.profession'),
       'manager'      => array('limit' => 1),
       'assistant'    => array('limit' => 1),
@@ -714,9 +714,19 @@
                 $this->id2uid[$id] = $record['uid'];
             }
 
-            // TODO: sort data arrays according to desired list sorting
+            // sort data arrays according to desired list sorting
+            uasort($this->contacts, array($this, '_sort_contacts_comp'));
         }
     }
+
+
+    /**
+     * Callback function for sorting contacts
+     */
+    private function _sort_contacts_comp($a, $b)
+    {
+      return strcasecmp($a['name'], $b['name']);
+    }
     
     
     /**

Modified: trunk/plugins/kolab_core/rcube_kolab.php
===================================================================
--- trunk/plugins/kolab_core/rcube_kolab.php	2011-01-21 17:41:05 UTC (rev 4441)
+++ trunk/plugins/kolab_core/rcube_kolab.php	2011-01-22 13:51:26 UTC (rev 4442)
@@ -15,6 +15,7 @@
 class rcube_kolab
 {
     private static $horde_auth;
+    private static $ready = false;
     
     
     /**
@@ -47,6 +48,7 @@
                 'remote_addr' => $_SERVER['REMOTE_ADDR'],
             );
             Auth::setCredential('password', $pwd);
+            self::$ready = true;
         }
         
         NLS::setCharset('UTF-8');
@@ -76,7 +78,7 @@
     {
         self::setup();
         $kolab = Kolab_List::singleton();
-        return $kolab->getByType($type);
+        return self::$ready ? $kolab->getByType($type) : array();
     }
 
     /**
@@ -90,7 +92,7 @@
     {
         self::setup();
         $kolab = Kolab_List::singleton();
-        return $kolab->getFolder($folder)->getData($data_type);
+        return self::$ready ? $kolab->getFolder($folder)->getData($data_type) : null;
     }
 
     /**

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list