[horde] Set "from_addr" as pre populated "enum" field

Michael M Slusarz slusarz at horde.org
Tue Mar 19 21:22:50 UTC 2013


Quoting lst_hoe02 at kwsoft.de:

> Zitat von Michael M Slusarz <slusarz at horde.org>:
>
>> Quoting lst_hoe02 at kwsoft.de:
>>
>>> Hello,
>>>
>>> we are on the way to Horde 5 and try to get the prefs.local.php  
>>> for Horde altered so a enum filed is used for the from_addr  
>>> preference, so the user is only able to choose the from_addr out  
>>> of a list of aliases obtained with a database query.
>>>
>>> What is the easiest way to use a Database query for standard SQL  
>>> source in prefs.local.php?
>>
>> Are you asking how to populate a preference field with dynamic  
>> results obtained from an SQL query?  Use the 'on_init' feature  
>> (see, e.g., the 'language' preference).
>
> No, the problem is how to get a Database Connection the "Horde" way.  
> The table to query is within the same scope as all the horde stuff,  
> but i'm not sure about the horde objects/functions to use. The hooks  
> examples are mostly LDAP and i have not yet found a SQL example.

$db = $GLOBALS['injector']->getInstance('Horde_Db_Adapter');

Returns the Horde_Db_Adapter object for the base Horde DB  
configuration.  
(http://dev.horde.org/api/master/lib/Db/classes/Horde_Db_Adapter.html)

>>> Is it correct to use $userId as logged in user?
>>
>> Not sure where you are getting $userId from?  Authenticated is  
>> always $registry->getAuth().
>
> So a simply username = $registry->getAuth() should do the trick?  
> Sorry for asking the obvious but i'm not a PHP coder at all.

Should be "$username = $registry->getAuth();"  But yes.



___________________________________
Michael Slusarz [slusarz at horde.org]



More information about the horde mailing list