[horde] question on horde identities on_change hook
Jan Schneider
jan at horde.org
Wed Mar 29 12:43:11 UTC 2017
Zitat von Michael Menge <michael.menge at zdv.uni-tuebingen.de>:
> Quoting Jan Schneider <jan at horde.org>:
>
>> Zitat von Michael Menge <michael.menge at zdv.uni-tuebingen.de>:
>>
>>> Hi,
>>>
>>> I try to write an on_change hook for horde identities/from_addr.
>>> My goal is to restrict the
>>> addresses our users can configure in horde/imp to their own
>>> addresses and variants (plus-addressing).
>>> The address verification feature ($conf[user][verify_from_addr])
>>> could work but we don't want to
>>> allow external addresses and it should be unnecessary to send an
>>> email as we already know the
>>> allowed addresses.
>>>
>>>
>>>
>>> In horde/config/prefs.local.php I have the following function.
>>>
>>> $_prefs['from_addr']['on_change'] = function() {
>>> global $prefs, $registry;
>>> $data = $GLOBALS['registry']->getAuthInfo();
>>> $userID=$data['authId'];
>>> $value=$GLOBALS['prefs']->getValue('identities');
>>> $value2=$prefs->getValue('from_addr');
>>> Horde::logMessage("Horde Prefs call on_change for identities:
>>> ".$userID." value: ".$value." value2: ".$value2);
>>> myVerifyFunction($userID, $value);
>>> }
>>>
>>> This function is call every time the Identity UI/form is saved.
>>> But the value retrieved by getValue('identities') still contain
>>> the old value before the change.
>>> This is different then the other on_change calls in horde/imp
>>> prefs.php (e.g. language, use_trash, trash_folder)
>>> how can I retrieve the new value.
>>
>> This is because the from_addr preference, as being a part of the
>> identities preference, won't really get stored. You need to use
>> on_change hook for the identities preference instead.
>
> I tried that before, but if i use $_prefs['identities']['on_change']
> = function() { ....
> the hook is not called at all. I guess that is because 'identities'
> is a prefGroup?
It's both, but on_change is only set on prefs. Without looking at the
code, just to the description of on_change in prefs.php, it seems to
be tied to changing prefs through the *UI*. That would explain why it
isn't called on 'identities' that's updated implicitely. And it would
also explain why you cannot update the identites pref inside this
callback: it's updated *after* the form submission and thus also after
the on_change callback.
>> Though I'm not sure how you want to achieve what you explained,
>> because this callback is not used to verify the submitted value of
>> some sort.
>>
>
> We delete the identities with addresses that are not allowed. An
> alternative would be to
> prevent the usage using the same mech that verify_from_addr is using
> but i didn't look
> into how that is working jet.
>
>
> --------------------------------------------------------------------------------
> M.Menge Tel.: (49) 7071/29-70316
> Universität Tübingen Fax.: (49) 7071/29-5912
> Zentrum für Datenverarbeitung mail:
> michael.menge at zdv.uni-tuebingen.de
> Wächterstraße 76
> 72074 Tübingen
--
Jan Schneider
The Horde Project
https://www.horde.org/
More information about the horde
mailing list