[turba] writing a turba driver

Mathieu Legare legare@uqtr.ca
Tue, 11 Jun 2002 15:30:00 -0400


Hi,

I just begun writing a simple turba driver for searching into
a CCSO nameserver (ph server) based on the SQL driver (sql.ph).

I have only implemented read-only features.  The problem is that
is always return the first element found even if there is more 
than one match.  Printing debbuging information in lib/Driver/ph.php
show me that it found more than one matchs :

in lib/Driver/ph.php - search method :

function search($criteria, $fields, $strict_fields = array(), 
                $match = TURBA_SEARCH_AND)
{
   $results = array();

   $k=0;
   while(reading input lines from the opened socket)
   {
      if(reading a new match)
      {
         $results[$k] = $entry;
         $k++;
         $entry = array();
      }
      ...
      $entry[$key] = ltrim($value);
   }
Horde::logMessage(sprintf('PH search by %s: criteria = %s; fields = "%s"; count = %d',
                  Auth::getAuth(), $crit, implode(',',$fields), count($results)),
                  __FILE__, __LINE__, LOG_DEBUG);
   return $results;
}

in turba/lib/api.php I added a debug lines :
function turbaExpandAddresses(
{
...
            foreach ($names as $name) {
                $criteria = array();
                if (isset($fields[$source])) {
                    foreach ($fields[$source] as $field) {
                        $criteria[$field] = trim($name);
                    }
                }
                if (count($criteria) == 0) {
                    $criteria['name'] = trim($name);
                }
                $res = $driver->search($criteria, 'lastname', TURBA_SEARCH_OR);
                if (!isset($results[$name])) {
                    $results[$name] = array();
                }

        Horde::logMessage(sprintf('SEARCH by %s: count = %d; source = %s',
                                  Auth::getAuth(), $res->count(), $source), __FILE__, __LINE__, LOG_DEBUG)
...
}

here is my sources.php :

$cfgSources['uqbottin'] = array(
     'title' => 'PH Server',
      'type' => 'ph',
      'params' => array(
          'server' => 'ph.foobar.com',
          'port'   => 105 
      ),
    'map' => array(
        'name' => 'name',
        'unite' => 'unite_administrative',
        'email' => 'poste_electronique',
        'login' => 'code d\'usager',
    ),
    'search' => array(
        'name', 
        'unite',
        'email',
    ),
    'strict' => array(
        'name'
    ),
      'readonly' => true,
      'public' => true,
      'admin' => array(),
      'export' => false
);

Here is some lines of my horde log :

Jun 11 15:40:10 HORDE [debug] [turba] PH search by foo: criteria = bar; fields = "name,unite_administrative,poste_electronique,code d'usager"; count = 31 [on line 115 of "/var/www/html/horde/turba/lib/Driver/ph.php"]

Jun 11 15:40:10 HORDE [debug] [turba] SEARCH by foo: count = 1; source = uqbottin [on line 50 of "/var/www/html/horde/turba/lib/api.php"]


Why does it says I have 31 matchs inside the Turba_Driver and 
only 1 match in api.php ? 

In IMP or Turba, only the very first match that has been matched by the query 
in showed...
 
Thanks and have a nice day,
-- 
Mathieu Legare, analyste en informatique (systeme/webmestre)
Service de soutien pédagogique et technologique
Universite du Quebec a Trois-Rivieres
Tel   : (819) 376-5011 x2439
Email : legare@uqtr.ca