[dev] hooks

Joel Vandal jvandal at infoteck.qc.ca
Thu May 8 13:48:03 PDT 2003


Hi,

Why not add this code on config/hooks.php and move or create function or
group of functions on separate files... I've not test this code but I think
it can be a good solution for split hooks functions...

This function can probable be extended for all other config file that can be
huge... (ex. check if a config/"configfile" directory exist, if yes, read
all files...

$configdir = '/var/www/html/horde/config/hooks';
if ($d = @opendir($configdir)) {
    while ($f = readdir($d)) {
        if (ereg(".php$", $f)) {
            include_once '$configdir/' . $f;
        }
    }
    closedir($d);
}

Create a file like
:/var/www/html/horde/config/hooks/password_hook_userdn.php that contain the
hook(s) function(s).

// Here is an example _passwd_hook_userdn function that you can use to
provide
// your ldap server with a userdn so that you do not have to perform
anonymous
// binds.  The function takes Auth::getAuth() as a parameter
if (!function_exists('_passwd_hook_userdn')) {
    function _passwd_hook_userdn($auth)
    {
        return 'uid=' . $auth . ',o=example.com';
    }
}

--
Joel Vandal
Infoteck Internet

----- Original Message -----
From: "Marcus I. Ryan" <marcus at horde.org>
To: <dev at lists.horde.org>
Sent: Thursday, May 08, 2003 12:11 AM
Subject: Re: [dev] hooks


> My only comment on this is that, as somone who uses a lot of hooks,
> that one hooks.php file gets to be a lot to manage.  I suppose I
> personally could just split it out myself and include the other files
> where necessary, but it would be really nice if we could find an
> efficient way to split this out at least a little...the fine line
> between code efficiency and code management... :)
>
> --
> Marcus I. Ryan, marcus at horde.org
> -----------------------------------------------------------------------
>  "Love is a snowmobile racing across the tundra and then suddenly it
>  flips over, pinning you underneath.  At night, the ice weasels come."
>                  -- Matt Groening
> -----------------------------------------------------------------------
>
>
> Quoting Chuck Hagenbuch <chuck at horde.org>:
>
> > Quoting Marko Djukic <marko at oblo.com>:
> >
> > > would it make sense to have something like a
> > Horde::callHook($app,
> > > $function) which would check if it can require that app's hook
> > file and
> > > call the function. this would cut out a lot of the repetitive
> > code of
> > > including the hooks file, checking if the function exists,
> > calling the
> > > function etc. is there any advantage to distributing the
> > functions to
> > > their corresponding app's hook file? if not then just a simple
> > > callHook($function), and stick with the one
> > /horde/config/hooks.php
> >
> > Yeah, that sounds like it makes sense. The reason to split hooks
> > out would
> > be to save overhead if there was a lot of code in there; this would
> > probably lose its advantage if you were including even two hooks
> > files,
> > though, and I kinda like the idea of keeping it all centralized. So
> > I'd
> > vote for just the one file, and callHook($function).
> >
> > -chuck
> >
> > --
> > Charles Hagenbuch, <chuck at horde.org>
> > The alligators were there, too, in a bathtub inside the house.
> >
> > --
> > Horde developers mailing list
> > Frequently Asked Questions: http://horde.org/faq/
> > To unsubscribe, mail: dev-unsubscribe at lists.horde.org
> >
> >
>
>
>
> --
> Horde developers mailing list
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: dev-unsubscribe at lists.horde.org
>




More information about the dev mailing list