[horde] update preferences cache

Jan Schneider jan at horde.org
Sun Nov 30 10:24:39 UTC 2008


Zitat von Aleksey Chudov <aleksey at bb.lv>:

> Jan Schneider wrote:
>
>> You want to use a preference hook for the from_addr preference instead.
>>
>> Jan.
>
> Thanks!
> The problem has solved with preference hook _prefs_hook_from_addr.
> Is it possible to use existing database connection, without creating  
> new connection at each users login?

Use DB::connect() instead of MDB2::singleton().

> Now my code looks as follows:
>
> ------------------------------------------------------------------------------------  
> <?php
> require_once 'MDB2.php';
> if (!function_exists('_prefs_hook_from_addr')) {
>   function _prefs_hook_from_addr($name = null)
>   {
>       if (is_null($name)) {
>           $name = Auth::getAuth();
>       }
>       if (!empty($name)) {
>           $dsn = array(
>               'phptype'  => $GLOBALS['conf']['auth']['params']['phptype'],
>               'username' => $GLOBALS['conf']['auth']['params']['username'],
>               'password' => $GLOBALS['conf']['auth']['params']['password'],
>               'hostspec' => $GLOBALS['conf']['auth']['params']['hostspec'],
>               'database' => $GLOBALS['conf']['auth']['params']['database'],
>           );
>           $_db = &MDB2::singleton($dsn);
>           if(PEAR::isError($_db)) {
>               die($_db->getMessage());
>           }
>           $query = "SELECT alias FROM virtual WHERE username = " .  
> $_db->quote($name);
>           $res = $_db->query($query);
>           if(PEAR::isError($res)) {
>               die($res->getMessage());
>           }
>           while($row = $res->fetchRow()) {
>               $mail = $row[0];
>           }
>           return (empty($mail) ? '' : $mail);
>       }
>       return '';
>   }
> }
> --
> Horde mailing list - Join the hunt: http://horde.org/bounties/#horde
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: horde-unsubscribe at lists.horde.org
>



Jan.

-- 
Do you need professional PHP or Horde consulting?
http://horde.org/consulting/



More information about the horde mailing list