[horde] Re: Some user hooks questions

Ben Chavet ben at horde.org
Sat Apr 23 20:44:22 PDT 2005


> Alright, I was thinking a little bit too hard for this.  The hook in
> the Wiki is
> actually a little bit buggy.

This caught my attention and made me look at my hook functions a little 
closer because I thought you were referring to the hook I put in the 
wiki. Turns out it wasn't mine, but it was a good excercise, anyway :)

> unless I'm mistaken, $user will always be some value, so the is_null check is
> bogus.

It's still a good idea to check for it.  Since there is a default 
value, it is an optional parameter, and there is no guarantee it will 
not be null.

And, just for the sake of discussion, this is what I use for my fullname hook:

if (!function_exists('_prefs_hook_fullname')) {
    function _prefs_hook_fullname($user = null)
    {
        $ldapServer = 'calmit-pdc.unl.edu';
        $ldapPort = '389';
        $searchBase = 'ou=Users,dc=calmit,dc=unl,dc=edu';

        $bind_dn = 'cn=calmit,ou=DSA,dc=calmit,dc=unl,dc=edu';
        $bind_passwd = 'v6yr9kpw';

        $ds = ldap_connect($ldapServer, $ldapPort);
        $bind = ldap_bind($ds, $bind_dn, $bind_password);

        if (is_null($user)) {
            $user = Auth::getAuth();
        }

        $searchResult = @ldap_search($ds, $searchBase, 'uid=' . $user);
        $information = @ldap_get_entries($ds, $searchResult);

        ldap_close($ds);

        return $information[0]['displayname'][0];
    }
}




More information about the horde mailing list