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'; |
22 | |
23 | /** |
24 | * This is the function that is specific to your backend. It takes |
25 | * the current password (as supplied by the user) and the desired |
26 | * new password. It will return an array of messages. If everything |
27 | * was successful, the array will be empty. Else, it will contain |
28 | * the errormessage(s). |
29 | * Constants to be used for these messages: |
30 | * CPW_CURRENT_NOMATCH -> "Your current password is not correct." |
31 | * CPW_INVALID_PW -> "Your new password contains invalid characters." |
32 | * |
33 | * @param array data The username/currentpw/newpw data. |
34 | * @return array Array of error messages. |
35 | */ |
36 | function cpw_template_dochange($data) |
37 | { |
38 | // unfortunately, we can only pass one parameter to a hook function, |
39 | // so we have to pass it as an array. |
40 | $username = $data['username']; |
41 | $curpw = $data['curpw']; |
42 | $newpw = $data['newpw']; |
43 | |
44 | $msgs = array(); |
45 | |
46 | // your code here to change the password for $username from |
47 | // $currentpw into $newpw. |
48 | user_error('No valid backend defined: this is just a template', E_USER_ERROR); |
49 | |
50 | return $msgs; |
51 | } |