user_registrationpassword.install 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * @file
  4. * Uninstall function to clean up variables data.
  5. */
  6. /**
  7. * Implements hook_install().
  8. */
  9. function user_registrationpassword_install() {
  10. $t = get_t();
  11. // Set the correct default configuration settings
  12. // so the module needs no more configuration.
  13. // Enable account registration without e-mail confirmation.
  14. variable_set('user_register', 1);
  15. // Disable e-mail verification.
  16. variable_set('user_email_verification', 0);
  17. // Prevent standard notification email to administrators and to user.
  18. variable_set('user_mail_register_pending_approval_notify', 0);
  19. // Save the original activation email template to a temporally
  20. // variable, so we can revive them when we uninstall the module.
  21. variable_set('user_registrationpassword_user_mail_status_activated_subject_original', variable_get('user_mail_status_activated_subject', ''));
  22. variable_set('user_registrationpassword_user_mail_status_activated_body_original', variable_get('user_mail_status_activated_body', ''));
  23. // Set basic e-mail template variable for the
  24. // account activation e-mail so it makes sense.
  25. variable_set('user_mail_status_activated_subject', $t('Account details for [user:name] at [site:name]'));
  26. variable_set('user_mail_status_activated_body', $t('[user:name],
  27. Your account at [site:name] has been activated.
  28. You will be able to log in to [site:login-url] in the future using:
  29. username: [user:name]
  30. password: your password.
  31. -- [site:name] team'));
  32. }
  33. /**
  34. * Implements hook_uninstall().
  35. */
  36. function user_registrationpassword_uninstall() {
  37. // Reset system variables back to defauls.
  38. variable_del('user_mail_register_pending_approval_notify');
  39. // Reset the original (or previous adapted) ativation email template.
  40. variable_set('user_mail_status_activated_subject', variable_get('user_registrationpassword_user_mail_status_activated_subject_original', ''));
  41. variable_set('user_mail_status_activated_body', variable_get('user_registrationpassword_user_mail_status_activated_body_original', ''));
  42. // Delete all variables related to user_registrationpassword.
  43. db_delete('variable')
  44. ->condition('name', db_like('user_registrationpassword_') . '%', 'LIKE')
  45. ->execute();
  46. }
  47. /**
  48. * Update 7000 updates the name of the variable.
  49. */
  50. function user_registrationpassword_update_7000() {
  51. // Copy the value of the user_registrationpassword variable
  52. // to the user_registrationpassword_registration variable.
  53. variable_set('user_registrationpassword_registration', variable_get('user_registrationpassword', 2));
  54. // Delete the user_registrationpassword variable.
  55. variable_del('user_registrationpassword');
  56. }