Happy New Year!
[squirrelmail.git] / plugins / change_password / backend / template.php
1 <?php
2
3 /**
4 * Change password backend template
5 *
6 * This is a template for a password changing mechanism. Currently,
7 * this contains two parts: the first is to register your function
8 * in the squirrelmail_plugin_hooks global, and the second is
9 * the function that does the actual changing.
10 *
11 * Replace the word template everywhere with a name for your backend.
12 *
13 * @copyright 2003-2011 The SquirrelMail Project Team
14 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
15 * @version $Id$
16 * @package plugins
17 * @subpackage change_password
18 */
19
20 /**
21 * Config vars: here's room for config vars specific to your
22 * backend.
23 */
24
25 /**
26 * Define here the name of your password changing function.
27 */
28 global $squirrelmail_plugin_hooks;
29 $squirrelmail_plugin_hooks['change_password_dochange']['template'] =
30 'cpw_template_dochange';
31 $squirrelmail_plugin_hooks['change_password_init']['template'] =
32 'cpw_template_init';
33
34
35 /**
36 * Use this function to do any backend-specific initialization,
37 * e.g. checking requirements, before the password change form
38 * is displayed to the user.
39 */
40 function cpw_template_init()
41 {
42 global $oTemplate;
43
44 // plugin is not configured. Handle error gracefully.
45 error_box(_("No valid backend defined."));
46 // close html and stop script execution
47 $oTemplate->display('footer.tpl');
48 exit();
49 }
50
51
52 /**
53 * This is the function that is specific to your backend. It takes
54 * the current password (as supplied by the user) and the desired
55 * new password. It will return an array of messages. If everything
56 * was successful, the array will be empty. Else, it will contain
57 * the errormessage(s).
58 * Constants to be used for these messages:
59 * CPW_CURRENT_NOMATCH -> "Your current password is not correct."
60 * CPW_INVALID_PW -> "Your new password contains invalid characters."
61 *
62 * @param array data The username/currentpw/newpw data.
63 * @return array Array of error messages.
64 */
65 function cpw_template_dochange($data)
66 {
67 // unfortunately, we can only pass one parameter to a hook function,
68 // so we have to pass it as an array.
69 $username = $data['username'];
70 $curpw = $data['curpw'];
71 $newpw = $data['newpw'];
72
73 $msgs = array();
74
75 // your code here to change the password for $username from
76 // $currentpw into $newpw.
77 user_error('No valid backend defined: this is just a template', E_USER_ERROR);
78
79 return $msgs;
80 }