[dev] [PATCH] First login hook

Jan Schneider jan at horde.org
Thu Aug 26 13:21:05 PDT 2004


If you're still interested in this patch being included (I am), can update
the patch to the current code base?

Zitat von Etienne Goyer <etienne.goyer at linuxquebec.com>:

> This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
> --------------enig9DE611A78C93E16E0B3D48E7
> Content-Type: multipart/mixed; 
> boundary="------------050901050504060901070306"
>
> This is a multi-part message in MIME format.
> --------------050901050504060901070306
> Content-Type: text/plain; charset=us-ascii; format=flowed
> Content-Transfer-Encoding: 7bit
>
> 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 ?
>>
>>
>> ------------------------------------------------------------------------
>>
>>
>
>
> --------------050901050504060901070306
> Content-Type: text/x-patch;
>  name="firstlogin.patch"
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline;
>  filename="firstlogin.patch"
>
> 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.
>       *
>
> --------------050901050504060901070306--
>
> --------------enig9DE611A78C93E16E0B3D48E7
> Content-Type: application/pgp-signature; name="signature.asc"
> Content-Description: OpenPGP digital signature
> Content-Disposition: attachment; filename="signature.asc"
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.4 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFAmp770Q5b0DEGvMIRAn4NAJ9+BKq24D3D/n0X3jDF2SvcDY/WlACfRtpN
> bHYzIj7i4MvCirY7tduaNd4=
> =Wp4Q
> -----END PGP SIGNATURE-----
>
> --------------enig9DE611A78C93E16E0B3D48E7--
>



Jan.

--
Do you need professional PHP or Horde consulting?
http://horde.org/consulting.php


More information about the dev mailing list