[horde] prefs_hook and $registry->call()
Paul Ezvan
paul at ezvan.fr
Mon Oct 6 14:53:36 UTC 2008
Le vendredi 3 octobre 2008 19:14:34 Chuck Hagenbuch, vous avez écrit :
> Quoting Paul Ezvan <paul at ezvan.fr>:
> > I am using Horde groupware on a telecare platform. I want to set a
> > theme according the user group. For this purpose I have created a
> > little application which stores the theme associated to a group in
> > the database. Now I want to set the theme, I use for this
> > _prefs_hook_theme() in hooks.php but I want to call my app's api in.
> > When I call it though the registry, the registry uses again
> > hooks.php and call again _prefs_hook_theme() and I get into an
> > infinite loop. Is there another way to call an application through
> > hooks.php ?
>
> No, but can you check the current application ($registry->getApp()) in
> your hook, and avoid making the registry call if you're already in
> your application?
>
> -chuck
In the loop when I print $registry->getApp() it is always 'horde'. So I made a
test to return null when the app is horde. Then I get a PEAR error
"permission_denied" though the variable $username given to the hook function
is set. What I am doing wrong ?
Here is the code :
if (!function_exists('_prefs_hook_theme')) {
function _prefs_hook_theme($username = null)
{
if (is_null($username)) {
return null;
}
global $registry, $themeset;
Horde::logMessage('hooktheme ' . $username,__FILE__, __LINE__,
PEAR_LOG_DEBUG);
Horde::logMessage('hooktheme ' . $registry->getApp(),__FILE__, __LINE__,
PEAR_LOG_DEBUG);
if($registry->getApp() == 'horde') {
return $themeset;
}
$themeset = $registry->call('vermeil/theme', $registry-
>call('vermeil/group'));
Horde::logMessage('hooktheme ' . $themeset,__FILE__,__LINE__,
PEAR_LOG_DEBUG);
return $themeset;
}
}
Thanks,
Paul Ezvan
More information about the horde
mailing list