template.php 2.4 KB

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