Summary | hook prefs_init |
Queue | Turba |
Queue Version | Git master |
Type | Bug |
State | Not A Bug |
Priority | 1. Low |
Owners | mrubinsk (at) horde (dot) org, slusarz (at) horde (dot) org |
Requester | rsalmon (at) mbpgroup (dot) com |
Created | 03/28/2011 (5217 days ago) |
Due | |
Updated | 04/05/2011 (5209 days ago) |
Assigned | 03/28/2011 (5217 days ago) |
Resolved | 04/04/2011 (5210 days ago) |
Github Issue Link | |
Github Pull Request | |
Milestone | |
Patch | No |
data in prefs_init. To do what you are trying to do here, you should
instead use the postauthenticate hook and set the value manually with
$prefs->setValue(pref_name, pref_value, array('nosave' => true));
data in prefs_init. To do what you are trying to do here, you
should instead use the postauthenticate hook and set the value
manually with $prefs->setValue(pref_name, pref_value, array('nosave'
=> true));
Assigned to Michael Slusarz
State ⇒ Not A Bug
data in prefs_init. To do what you are trying to do here, you should
instead use the postauthenticate hook and set the value manually with
$prefs->setValue(pref_name, pref_value, array('nosave' => true));
Bug #9728: prefs_init does not have application data available to it2 files changed, 12 insertions(+), 2 deletions(-)
http://git.horde.org/horde-git/-/commit/3c1cd2ecf619fa54dca0f8ec55bdd79f09384c74
prefs_init since the preferences need to be initialized BEFORE the
application is initialized. Chicken-and-egg problem.
prefs_init code needs to be self-contained within the hook at the
present time.
New Attachment: horde_debug_turba.txt
{ public function prefs_init($pref, $value, $username, $scope_ob)
{
Horde::debug(Turba::listShares());
Horde::debug($_SESSION);
}
}
Turba::listShares() always returns empty array and $_SESSION['turba']
is not set.
setting the default_dir pref, right? That pref only sets the value
that specifies what address book is used for adding/importing
contacts. The setting that specifies what address books are
*visible* is the "addressbooks" pref. Two different prefs.
but same issue, default_dir doesn't not set automatically using
provided example (ie default_dir is set to null).
you earlier that would be necessary to ensure the localsql source
was properly initialized, this is why it is failing to find the
default share, it hasn't been added to the cfgSources array yet. You
need to run the sources through Turba::getConfigFromShares() as I
mentioned on the mailing list (and you seem to have said you used in
an earlier comment).
this ticket, I can clearly see a hook for 'addressbooks' using
getConfigFromShares :
return
json_encode(array_keys(Turba::getConfigFromShares(Turba::availableSources())));
this is indeed inspired from our discussion on the mailing list.
More testing on hook for pref 'default_dir', the follwowing always
return false in turba/config/hooks.php
$GLOBALS['session']->get('turba', 'has_share')
setting the default_dir pref, right? That pref only sets the value
that specifies what address book is used for adding/importing
contacts. The setting that specifies what address books are *visible*
is the "addressbooks" pref. Two different prefs.
Also, the hook you posted does not contain the code I specified to you
earlier that would be necessary to ensure the localsql source was
properly initialized, this is why it is failing to find the default
share, it hasn't been added to the cfgSources array yet. You need to
run the sources through Turba::getConfigFromShares() as I mentioned on
the mailing list (and you seem to have said you used in an earlier
comment).
the problem. You are saying the hook is not finding it, but it's
listed. Is it, or is it not, listed if that user visits his prefs
page?
does not exist." if hook is enabled on pref 'addressbooks'.
If I login, go to Preferences, "Address Books ", I can see my personal
address book (ie localsql / t28kRogBqn9NgepUzGnnBqA) in the
unselected_sources list, never in the selected_sources list.
And since pref 'addressbooks' is locked, users can't change it (this
is the wanted behaviour).
pref_scope='turba';)
Looks like something does not initialize properly during the login
process (by the way : $conf['auth']['params']['app'] = 'imp'). I don't
mind debugging, but I don't know where to start.
the problem. You are saying the hook is not finding it, but it's
listed. Is it, or is it not, listed if that user visits his prefs
page? If you query the user's prefs storage, what is the value of
that pref?
it doesn't not appear in the first Horde::debug($newSources) call, but
it does in the following ones.
"localsql" in this list if it is using shares, it is replaced with
the share ids of all shares the user has access to.
I have not changed configuration of backend 'localsql'
(turba/config/backend.php)
address book in the list.
$_prefs['addressbooks']['locked'] = true;
$_prefs['addressbooks']['hook'] = true;
New Attachment: hooks.php
recent changes.
prefs.local.php :
$_prefs['addressbooks']['locked'] = true;
$_prefs['addressbooks']['hook'] = true;
$_prefs['default_dir']['locked'] = true;
$_prefs['default_dir']['hook'] = true;
New Attachment: horde_debug[1].txt
"localsql" in this list if it is using shares, it is replaced with
the share ids of all shares the user has access to.
I have not changed configuration of backend 'localsql'
(turba/config/backend.php)
prefs.local.php :
$_prefs['addressbooks']['locked'] = true;
$_prefs['addressbooks']['hook'] = true;
State ⇒ Feedback
2011-03-28T11:21:33+02:00 DEBUG: Variable information:
array(3) {
[0]=>
string(23) "t28kRogBqn9NgepUzGnnBqA"
[1]=>
string(9) "localldap"
[2]=>
string(10) "favourites"
}
What source is [0]? That looks like a share id. You won't see
"localsql" in this list if it is using shares, it is replaced with the
share ids of all shares the user has access to.
getConfigFromShares (turba/lib/Turba.php:523)
State ⇒ Assigned
probably be merged in a prefs_init function since hooks changed in
Horde.
Bug #9728: default_dir is no longer called as hook - move to prefs_init hook1 files changed, 28 insertions(+), 25 deletions(-)
http://git.horde.org/horde-git/-/commit/07445b77b221c5b1301817fb35a81cde62e79393
Priority ⇒ 1. Low
State ⇒ Unconfirmed
New Attachment: horde_debug.txt
Patch ⇒ No
Milestone ⇒
Queue ⇒ Turba
Summary ⇒ hook prefs_init
Type ⇒ Bug
probably be merged in a prefs_init function since hooks changed in
Horde.
Secondly,
I'm trying to setup a hook to automatically set pref 'addressbooks'.
So far, I've always been able to automatically set backends
'localldap' and 'favourites', but not backend 'localsql'.
Here is my hook :
public function prefs_init($pref, $value, $username, $scope_ob )
{
switch ($pref) {
case 'addressbooks':
$shares = Turba::listShares(true);
return
json_encode(array_keys(Turba::getConfigFromShares(Turba::availableSources())));
}
}
When I login I get a : addressbook 'localsql' does not exist.
I've added the following line right before the return call of
getConfigFromShares (turba/lib/Turba.php:523)
Attached is the output.
Looks like backend 'localsql' doesn't not get initialize properly
during login process.