[dev] [PATCH] First login hook

Etienne Goyer etienne.goyer at linuxquebec.com
Mon May 10 09:09:51 PDT 2004


Sorry for bumping this ... I was just wondering if this patch did not 
receive feedback because there is a problem with it, or because the 
feature is uninteresting, or just because the devs have been busy with 
something else lately.

Thanks for your time !

Etienne Goyer wrote:
> I am so distracted it's not even funny ....
> 
> Here is the patch.
> 
> Etienne Goyer wrote:
> 
>> Hi,
>>
>> To follow-up on the discussion from this morning about having an 
>> "instruction" first login maintenance task, I implemented a 
>> _horde_hook_firstlogin instead.  Example use for this hook :
>>
>> - Display a first time greeting message via the Notification class
>> - Send a greeting email
>> - Create approriate IMAP folders, especially the sent-mail since it is 
>> not created automatically by IMP on first use
>> - Log it, so you know who have used the webmail at least once
>>
>> ... etc, etc.  All this could be done with a first login maintenance 
>> task, but I think it is simpler to write/configure a hook than to 
>> write a full-blown maintenance task and is still worthwhile for site 
>> that do not have maintenance enabled.
>>
>> Comments ?
>>
>>
>> ------------------------------------------------------------------------
>>
>>
> 
> 
> ------------------------------------------------------------------------
> 
> diff -ruN horde.orig/config/conf.php horde/config/conf.php
> --- horde.orig/config/conf.php	2004-05-06 14:06:18.000000000 -0400
> +++ horde/config/conf.php	2004-05-06 14:20:22.000000000 -0400
> @@ -568,6 +568,11 @@
>  // There are examples for such functions in horde/config/hooks.php.dist.
>  $conf['hooks']['postauthenticate'] = false;
>  
> +// If this is set to true, the _horde_hook_firstlogin() function will be run.  
> +// You could do various thing, like displaying message to user, creating mail 
> +// folders, sending a greeting email, etc.
> +$conf['hooks']['firstlogin'] = true;
> +
>  // If this is set to true, the function _horde_hook_authldap() will be used
>  // to create and set the attributes needed to add/edit/delete users by the
>  // LDAP Auth driver
> diff -ruN horde.orig/config/hooks.php.dist horde/config/hooks.php.dist
> --- horde.orig/config/hooks.php.dist	2004-04-26 14:40:20.000000000 -0400
> +++ horde/config/hooks.php.dist	2004-05-06 15:19:16.000000000 -0400
> @@ -287,6 +287,23 @@
>      }
>  }
>  
> +// Here is an example for displaying informationnal messages on first login.
> +if (!function_exists('_horde_hook_firstlogin')) {
> +    function _horde_hook_firstlogin($userId)
> +    {
> +        global $language;
> +
> +        $notification = Notification::singleton();
> +        $message = _('Before sending email, it is imperative that you set your From: address. ');
> +        $message .= _('To do so, click "Mail", "Options", "Personnal Information", "Edit your identities", ');
> +        $message .= ('and add a "From:" address. ');
> +        $message .= _('You may also want to create your sent mail folders (by default, "Sent Items").');
> +
> +        $notification->push($message, 'horde.warning');
> +    }
> +}
> +
> +
>  // Here is an example of creating credentials needed by the LDAP Auth driver for
>  // adding/deleting/updating users.
>  if (!function_exists('_horde_hook_authldap')) {
> diff -ruN horde.orig/lib/Horde/Auth.php horde/lib/Horde/Auth.php
> --- horde.orig/lib/Horde/Auth.php	2004-04-02 12:38:51.000000000 -0500
> +++ horde/lib/Horde/Auth.php	2004-05-06 15:02:59.000000000 -0400
> @@ -608,7 +608,9 @@
>                  }
>              }
>          }
> -        if (!empty($old_login['time'])) {
> +        if (empty($old_login['time'])) {
> +            Auth::firstLogin($userId);
> +        } else {
>              $_SESSION['__auth']['last_login'] = $old_login['time'];
>          }
>  
> @@ -729,6 +731,25 @@
>      }
>  
>      /**
> +     * Run the _horde_hook_firstlogin if appropriate.
> +     *
> +     * @param string $userId  The Horde user name.
> +     *
> +     * @return string  The user name with the hook applied to it.
> +     */
> +    function firstLogin($userId)
> +    {
> +        global $conf;
> +
> +        if (!empty($conf['hooks']['firstlogin'])) {
> +            require_once HORDE_BASE . '/config/hooks.php';
> +            if (function_exists('_horde_hook_firstlogin')) {
> +                call_user_func('_horde_hook_firstLogin', $userId);
> +            }
> +        }
> +    }
> +
> +    /**
>       * Query the current Auth object to find out if it supports the
>       * given capability.
>       *
> 
> 
> ------------------------------------------------------------------------
> 
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
Url : http://lists.horde.org/archives/dev/attachments/20040510/d91b6bf7/signature.bin


More information about the dev mailing list