template.php 2.0 KB

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