You are here

user_registrationpassword.install in User registration password 6

Uninstall function to clean up variables data.

File

user_registrationpassword.install
View source
<?php

/**
 * @file
 * Uninstall function to clean up variables data.
 */

/**
 * Implements hook_install().
 */
function user_registrationpassword_install() {
  $t = get_t();

  // Set the correct default configuration settings
  // so the module needs no more configuration.
  // Enable account registration without e-mail confirmation.
  variable_set('user_register', 1);

  // Disable e-mail verification.
  variable_set('user_email_verification', 0);

  // Prevent standard notification email to administrators and to user.
  variable_set('user_mail_register_pending_approval_notify', 0);
  variable_set('user_mail_register_no_approval_required_notify', 0);

  // Save the original activation email template to a temporally
  // variable, so we can re-install it when we disable the module.
  variable_set('user_mail_status_activated_subject_original', variable_get('user_mail_status_activated_subject', ''));
  variable_set('user_mail_status_activated_body_original', variable_get('user_mail_status_activated_body', ''));

  // Set basic e-mail template variable for the verification
  // e-mail so it makes sense to new users.
  variable_set('user_mail_status_activated_subject', $t('Account details for !username at !site', $variables, $langcode));
  variable_set('user_mail_status_activated_body', $t("!username,\n\nYour account at !site has been activated.\n\nYou will be able to log in to !login_uri in the future using:\n\nusername: !username\npassword: your password.\n\n--  !site team\n"));
}

/**
 * Implements hook_uninstall().
 */
function user_registrationpassword_uninstall() {

  // Delete all variables related to user_registrationpassword.
  variable_del('user_registrationpassword_registration');
  variable_del('user_registrationpassword_register_subject');
  variable_del('user_registrationpassword_register_body');

  // And reset system variables to origin.
  variable_del('user_register');
  variable_del('user_email_verification');
  variable_del('user_mail_register_pending_approval_notify');
  variable_del('user_mail_register_no_approval_required_notify');

  // Reset the original (or previous adapted) ativation email template.
  variable_set('user_mail_status_activated_subject', variable_get('user_mail_status_activated_subject_original', ''));
  variable_set('user_mail_status_activated_body', variable_get('user_mail_status_activated_body_original', ''));
}