[dev] [patch] Turba manages clients

Jason M. Felice jfelice at cronosys.com
Thu Aug 7 08:46:37 PDT 2003


The attached patch adds a config option for Turba so that Turba knows which
addressbook is for clients, adds a clientSearch() api, makes turba provide
clients/*, and updates whups to use this for it's clients (Hermes currently
calls down to whups, so it's okay).

-- 
 Jason M. Felice
 Cronosys, LLC <http://www.cronosys.com/>
 216.221.4600 x302
-------------- next part --------------
Index: config/registry.php.dist
===================================================================
RCS file: /repository/horde/config/registry.php.dist,v
retrieving revision 1.169
diff -u -r1.169 registry.php.dist
--- config/registry.php.dist	31 Jul 2003 03:32:50 -0000	1.169
+++ config/registry.php.dist	7 Aug 2003 15:41:16 -0000
@@ -145,7 +145,7 @@
     'name' => _("Address Book"),
     'allow_guests' => false,
     'status' => 'active',
-    'provides' => 'contacts',
+    'provides' => array('contacts', 'clients'),
     'menu_parent' => 'pim'
 );
 
Index: whups/config/conf.xml
===================================================================
RCS file: /repository/whups/config/conf.xml,v
retrieving revision 1.5
diff -u -r1.5 conf.xml
--- whups/config/conf.xml	17 Jul 2003 16:38:44 -0000	1.5
+++ whups/config/conf.xml	7 Aug 2003 15:41:16 -0000
@@ -111,23 +111,6 @@
   </configmultienum>
  </configsection>
 
- <configsection name="client">
-   <configheader>
-        Client Driver Settings
-   </configheader>
-
-   <configenum name="driver" desc="What type of client driver should we use?">
-    <values>
-     <value desc="Turba Addressbook">turba</value>
-     <value desc="None">none</value>
-    </values>
-   </configenum>
-
-   <configsection name="params">
-    <configstring name="addressbook" desc="Name of client addressbook (Turba only)">localsql</configstring>
-   </configsection>
- </configsection>
-
  <configsection name="menu">
    <configheader>
         Menu Settings
Index: turba/config/conf.xml
===================================================================
RCS file: /repository/turba/config/conf.xml,v
retrieving revision 1.2
diff -u -r1.2 conf.xml
--- turba/config/conf.xml	13 Aug 2002 03:50:00 -0000	1.2
+++ turba/config/conf.xml	7 Aug 2003 15:41:17 -0000
@@ -13,4 +13,12 @@
    </values>
   </configmultienum>
  </configsection>
+ <configsection name="client">
+   <configheader>
+        Settings for Clients
+   </configheader>
+
+   <configstring name="addressbook" desc="Name of client addressbook">localsql</configstring>
+ </configsection>
+
 </configuration>
Index: turba/lib/api.php
===================================================================
RCS file: /repository/turba/lib/api.php,v
retrieving revision 1.55
diff -u -r1.55 api.php
--- turba/lib/api.php	15 May 2003 17:18:40 -0000	1.55
+++ turba/lib/api.php	7 Aug 2003 15:41:17 -0000
@@ -22,6 +22,10 @@
     'args' => array('addresses', 'addressbooks', 'fields'),
     'type' => 'array');
 
+$_services['clientSearch'] = array(
+    'args' => array('addresses', 'fields'),
+    'type' => 'array');
+
 $_services['add'] = array(
     'args' => array('name', 'address', 'addressbook'),
     'type' => 'boolean');
@@ -76,7 +80,6 @@
     ini_get('arg_separator.output') . 'from_parameters=|from_parameters|' .
     ini_get('arg_separator.output') . 'url=|url|');
 
-
 function _turba_block($type, $params)
 {
     @define('TURBA_BASE', dirname(__FILE__) . '/..');
@@ -244,6 +247,13 @@
         }
     }
     return $results;
+}
+
+function _turba_clientSearch($names = array(), $addressbooks = array(), $fields = array())
+{
+    global $conf;
+    return _turba_search($names, array($conf['client']['addressbook']),
+        $fields);
 }
 
 function _turba_add($name = '', $address = '', $addressbook = '')
Index: whups/lib/Driver.php
===================================================================
RCS file: /repository/whups/lib/Driver.php,v
retrieving revision 1.53
diff -u -r1.53 Driver.php
--- whups/lib/Driver.php	30 Jul 2003 03:15:13 -0000	1.53
+++ whups/lib/Driver.php	7 Aug 2003 15:41:17 -0000
@@ -71,47 +71,27 @@
 
     function getClients($module = null, $ticket = null)
     {
-        /* Gets list of clients from the client source. */
+        /* Get client data from a Turba addressbook. */
+        global $registry;
         $clients = array();
-        global $conf;
-
-        if (!empty($conf['client']['driver'])) {
-            $clientsource = $conf['client']['driver'];
-        } else {
-            $clientsource = '';
-        }
-
-        switch ($clientsource) {
-        case 'turba':
-            /* Get client data from a Turba addressbook. */
-            if (!empty($conf['client']['params']['addressbook'])) {
-                $addressbook = $conf['client']['params']['addressbook'];
-                global $registry;
-                $clients = array();
-                $args = array('addresses' => array(''), 
-                              'addressbooks' => array($addressbook), 
-                              'fields' => array('name')
-                              );
-                $results = $registry->call('contacts/search', $args);
-                $clientlist = $results[''];
-                if (!empty($clientlist)) {
-                    foreach ($clientlist as $client) {
-                        $clients[$client['id']] = $client['name'];
-                    }
-                }
-                if (!empty($module)) {
-                    $clients = $this->filterClientLinks('module', $clients, $module);
-                }
-                if (!empty($ticket)) {
-                    $clients = $this->filterClientLinks('ticket', $clients, $ticket);
-                }
-                if (is_a('PEAR_Error', $clients)) {
-                    $notification->push(_("Could not access client list from Turba."));
-                }
-            } else {
-                $notification->push(_("No Turba addressbook specificified in Whups configuration."));
+        $args = array('addresses' => array(''), 
+                      'fields' => array('name')
+                      );
+        $results = $registry->call('clients/clientSearch', $args);
+        $clientlist = $results[''];
+        if (!empty($clientlist)) {
+            foreach ($clientlist as $client) {
+                $clients[$client['id']] = $client['name'];
             }
-            break;
+        }
+        if (!empty($module)) {
+            $clients = $this->filterClientLinks('module', $clients, $module);
+        }
+        if (!empty($ticket)) {
+            $clients = $this->filterClientLinks('ticket', $clients, $ticket);
+        }
+        if (is_a('PEAR_Error', $clients)) {
+            $notification->push(_("Could not access client list from Turba."));
         }
 
         return $clients;


More information about the dev mailing list