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