copyright update
[squirrelmail.git] / plugins / change_password / backend / template.php
CommitLineData
27663afe 1<?php
4b4abf93 2
21b8ca51 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 *
47ccfad4 13 * @copyright &copy; 2003-2006 The SquirrelMail Project Team
4b4abf93 14 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
21b8ca51 15 * @version $Id$
16 * @package plugins
17 * @subpackage change_password
27663afe 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 */
28global $squirrelmail_plugin_hooks;
91e0dccc 29$squirrelmail_plugin_hooks['change_password_dochange']['template'] =
30 'cpw_template_dochange';
31$squirrelmail_plugin_hooks['change_password_init']['template'] =
32 'cpw_template_init';
5c34b0bb 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 */
40function cpw_template_init()
41{
7bd637cf 42 global $color;
5c34b0bb 43
7bd637cf 44 /**
45 * If SM_PATH isn't defined, define it. Required to include files.
46 * @ignore
47 */
48 if (!defined('SM_PATH')) {
49 define('SM_PATH','../../../');
50 }
51
52 // load error_box() function
53 include_once(SM_PATH . 'functions/display_messages.php');
54
55 // plugin is not configured. Handle error gracefully.
56 error_box(_("No valid backend defined."),$color);
57 // close html and stop script execution
58 echo "</body></html>\n";
59 exit();
5c34b0bb 60}
61
27663afe 62
63/**
64 * This is the function that is specific to your backend. It takes
65 * the current password (as supplied by the user) and the desired
66 * new password. It will return an array of messages. If everything
67 * was successful, the array will be empty. Else, it will contain
68 * the errormessage(s).
69 * Constants to be used for these messages:
70 * CPW_CURRENT_NOMATCH -> "Your current password is not correct."
71 * CPW_INVALID_PW -> "Your new password contains invalid characters."
72 *
91e0dccc 73 * @param array data The username/currentpw/newpw data.
27663afe 74 * @return array Array of error messages.
75 */
76function cpw_template_dochange($data)
77{
78 // unfortunately, we can only pass one parameter to a hook function,
79 // so we have to pass it as an array.
80 $username = $data['username'];
81 $curpw = $data['curpw'];
82 $newpw = $data['newpw'];
83
84 $msgs = array();
85
86 // your code here to change the password for $username from
87 // $currentpw into $newpw.
88 user_error('No valid backend defined: this is just a template', E_USER_ERROR);
89
90 return $msgs;
91e0dccc 91}