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