[dev] generic hook to add a user in turba #2

steve mailling at gmx.co.uk
Thu Feb 5 14:26:53 PST 2004


I forgot some other patches to make it working properly, sorry.
RCS file: /repository/framework/Auth/Auth.php,v
retrieving revision 1.117
diff -w -b -r1.117 Auth.php
719a720,731
 >      * Get extra data from a user.
 >      *
 >      * @access public
 >      *
 >      * @return Row of data with the published data.
 >      *
 >      */
 >     function getExtra($userId) {
 >         return PEAR::raiseError('unsupported');
 >     }
 >
 >     /**

At this time, I just have a patch for the sql driver, but it should be easy 
to add the fields for other drivers

RCS file: /repository/framework/Auth/Auth/sql.php,v
retrieving revision 1.62
diff -w -b -r1.62 sql.php
74a75
 >                               'turba'       => true,
138a140
 >             Horde::logMessage(sprintf('Impossible to access the 
authentification database for the user %s - issue with: %s', $userId, 
$query), __FILE__, __LINE__, PEAR_LOG_DEBUG);
154c156
<     function addUser($userId, $credentials)
---
 >     function addUser($userId, $credentials, $extras = array())
159c161
<         $query = sprintf('INSERT INTO %s (%s, %s) VALUES (%s, %s)',
---
 >         $query = sprintf('INSERT INTO %s (%s, %s, %s, %s) VALUES (%s, 
%s, %s, %s)',
162a165,166
 >                          $this->_params['turba_id_field'],
 >                          $this->_params['turba_source_field'],
167c171,174
< 
$this->_params['show_encryption'])));
---
 > 
$this->_params['show_encryption'])),
 >                          (isset($extras['turba_id'])) ? 
$this->_db->quote($extras['turba_id']) : $this->_db->quote($userId),
 >                          (isset($extras['turba_source'])) ? 
$this->_db->quote($extras['turba_source']) : 'localsql');
 >
170a178
 >             Horde::logMessage(sprintf('Impossible to add the user %s - 
issue with: %s', $userId, $query), __FILE__, __LINE__, PEAR_LOG_DEBUG);
188c196
<     function updateUser($oldID, $newID, $credentials)
---
 >     function updateUser($oldID, $newID, $credentials, $extras = array())
192a201,202
 > //Even if the userID changes, we don't need to update the extras, the 
link stays fine
 >         if (count($extras) == 0) {
204a215,231
 >         } else {
 >             $query = sprintf('UPDATE %s SET %s = %s, %s = %s, %s = %s, 
%s = %s WHERE %s = %s',
 >                              $this->_params['table'],
 >                              $this->_params['username_field'],
 >                              $this->_db->quote($newID),
 >                              $this->_params['password_field'],
 > 
$this->_db->quote($this->getCryptedPassword($credentials['password'],
 >                                                                      '',
 > 
$this->_params['encryption'],
 > 
$this->_params['show_encryption'])),
 >                              $this->_params['turba_id_field'],
 >                              $this->_db->quote($extras['turba_id']),
 >                              $this->_params['turba_source_field'],
 >                              $this->_db->quote($extras['turba_source']),
 >                              $this->_params['username_field'],
 >                              $this->_db->quote($oldID));
 >         }
207a235
 >             Horde::logMessage(sprintf('Impossible to update the user %s 
- issue with: %s', $oldID, $query), __FILE__, __LINE__, PEAR_LOG_DEBUG);
274a303,327
 >      * Get extra data from a user.
 >      *
 >      * @access public
 >      *
 >      * @return Row of data with the published data.
 >      *
 >      */
 >     function getExtra($userId) {
 >         /* _connect() will die with Horde::fatal() upon failure. */
 >         $this->_connect();
 >
 >         /* Build the SQL query. */
 >         $query = sprintf('SELECT %s, %s, %s FROM %s WHERE %s = %s',
 >                          $this->_params['username_field'],
 >                          $this->_params['turba_id_field'],
 >                          $this->_params['turba_source_field'],
 >                          $this->_params['table'],
 >                          $this->_params['username_field'],
 >                          $this->_db->quote($userId));
 >
 >         $result = $this->_db->getRow($query, null, DB_FETCHMODE_ASSOC);
 >         return $result;
 >     }
 >
 >     /**
340a394,399
 >             }
 >             if (empty($this->_params['turba_id_field'])) {
 >                 $this->_params['turba_id_field'] = 'turba_id';
 >             }
 >             if (empty($this->_params['turba_source_field'])) {
 >                 $this->_params['turba_source_field'] = 'turba_source';



More information about the dev mailing list