[prev in list] [next in list] [prev in thread] [next in thread]
List: horde
Subject: Re: [horde] update preferences cache
From: Jan Schneider <jan () horde ! org>
Date: 2008-11-30 10:24:39
Message-ID: 20081130112439.17696osu8gtk0z4s () neo ! wg ! de
[Download RAW message or body]
Zitat von Aleksey Chudov <aleksey@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@lists.horde.org
>
Jan.
--
Do you need professional PHP or Horde consulting?
http://horde.org/consulting/
--
Horde mailing list - Join the hunt: http://horde.org/bounties/#horde
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: horde-unsubscribe@lists.horde.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic