[horde] Horde_Db 2.1.0 trashed Installation
lst_hoe02 at kwsoft.de
lst_hoe02 at kwsoft.de
Wed Mar 5 12:41:11 UTC 2014
Zitat von Jan Schneider <jan at horde.org>:
> Zitat von lst_hoe02 at kwsoft.de:
>
>> Zitat von Jan Schneider <jan at horde.org>:
>>
>>> Zitat von lst_hoe02 at kwsoft.de:
>>>
>>>> Zitat von Jan Schneider <jan at horde.org>:
>>>>
>>>>> Zitat von lst_hoe02 at kwsoft.de:
>>>>>
>>>>>> Zitat von lst_hoe02 at kwsoft.de:
>>>>>>
>>>>>>> Ok, will try out and let you (and maybe others) know about the results.
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>> Andreas
>>>>>>
>>>>>> Close but not there :-(
>>>>>>
>>>>>>
>>>>>> in horde/config/hooks.php:
>>>>>>
>>>>>> class Horde_Hooks
>>>>>> {
>>>>>> // PREFERENCES INIT: See above for documentation.
>>>>>> public function prefs_init($pref, $value, $username, $scope_ob)
>>>>>> {
>>>>>> switch ($pref) {
>>>>>> case 'from_addr':
>>>>>> // You are responsible for bringing in to the local scope any
>>>>>> // information you need. You can "global" anything else you
>>>>>> // need.
>>>>>> //
>>>>>> // Returns an address: either just the user@ side or a full
>>>>>> // address.
>>>>>>
>>>>>> $db_results =
>>>>>> $GLOBALS['injector']->getInstance('Horde_Db_Adapter')
>>>>>> ->selectValues('SELECT alias FROM
>>>>>> postfix_virtual_aliases WHERE user_uid = ?',
>>>>>>
>>>>>> array($GLOBALS['registry']->getAuth())
>>>>>> );
>>>>>> return array($db_results);
>>>>>
>>>>> $db_results already contains an array of values, don't wrap it
>>>>> into another array.
>>>>
>>>>
>>>> Ok, is now return &db_results;
>>>>
>>>>
>>>>>>
>>>>>> }
>>>>>> }
>>>>>> }
>>>>>>
>>>>>>
>>>>>>
>>>>>> in horde/config/prefs.local.php :
>>>>>>
>>>>>> $_prefs['from_addr'] = array(
>>>>>> 'value' => '',
>>>>>
>>>>> This needs to be an empty array, not a string, since you changed
>>>>> the type to enum.
>>>>
>>>> Not sure about this. Should it be 'value' => array(), ??
>>>>
>>>> Thanks
>>>>
>>>> Andreas
>>>
>>> Yes
>>
>> Still got this and an empty drop down field:
>>
>> HORDE: [horde] PHP ERROR: Invalid argument supplied for foreach()
>> [pid 1391 on line 525 of "/usr/share/php/Horde/Core/Prefs/Ui.php"]
>>
>> The query is executed as expected but looks like Ui.php does not
>> expect an enum ?
>>
>> Any idea to get this working?
>>
>> Regards
>>
>> Andreas
>
> Ah wait, this is my fault. The prefs_init hook is used to provide
> the *default* value of the preference, not the *possible* values.
> The default value is of course still a string, and that's what the
> prefs hook should return. If you want to set a default value at all.
>
> I don't think it's possible at the moment to set the available
> values, i.e. the value for the 'enum' entry, through a hook. So you
> may have to return back to set the 'enum' to the $db_results value
> in the prefs.local.php file.
>
> Only if you want to set the provide the default value, i.e. the
> default from address, too, you need to use the hook.
Ah, okay. I think that was the reason for this in the prefs.local.php
after all. We provide a drop down list with the *possible* values to
prevent misstype and missuse so the user can only choose valid and
his/her own addresses. So i will *port* it back to prefs.local.php and
see if this code is working with Horde_Db 2.1.0.
Thanks
Andreas
More information about the horde
mailing list