You are here

user_registrationpassword.install in User registration password 7

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() {

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

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

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

  // Set the registration variable to 2, register
  // with pass, but require confirmation.
  variable_set('user_registrationpassword_registration', USER_REGISTRATIONPASSWORD_VERIFICATION_PASS);

  // Save the original activation email template to a temporally
  // variable, so we can revive them when we uninstall the module.
  variable_set('user_registrationpassword_user_mail_status_activated_subject_original', variable_get('user_mail_status_activated_subject', ''));
  variable_set('user_registrationpassword_user_mail_status_activated_body_original', variable_get('user_mail_status_activated_body', ''));

  // Set basic e-mail template variable for the
  // account activation e-mail so it makes sense.
  variable_set('user_mail_status_activated_subject', 'Account details for [user:name] at [site:name]');
  variable_set('user_mail_status_activated_body', '[user:name],

Your account at [site:name] has been activated.

You will be able to log in to [site:login-url] in the future using:

username: [user:name]
password: your password.

-- [site:name] team');
}

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

  // Reset system variables back to save defauls.
  variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
  variable_set('user_email_verification', TRUE);
  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_registrationpassword_user_mail_status_activated_subject_original', ''));
  variable_set('user_mail_status_activated_body', variable_get('user_registrationpassword_user_mail_status_activated_body_original', ''));

  // Delete all variables related to user_registrationpassword.
  db_delete('variable')
    ->condition('name', db_like('user_registrationpassword_') . '%', 'LIKE')
    ->execute();
}

/**
 * Update 7000 updates the name of the variable.
 */
function user_registrationpassword_update_7000() {

  // Copy the value of the user_registrationpassword variable
  // to the user_registrationpassword_registration variable.
  variable_set('user_registrationpassword_registration', variable_get('user_registrationpassword', USER_REGISTRATIONPASSWORD_VERIFICATION_PASS));

  // Delete the user_registrationpassword variable.
  variable_del('user_registrationpassword');
}

/**
 * Update 7001 updates all static variables.
 */
function user_registrationpassword_update_7001() {
  if (variable_get('user_registrationpassword_registration', '') == 0) {
    variable_set('user_registrationpassword_registration', 'none');
  }
  if (variable_get('user_registrationpassword_registration', '') == 1) {
    variable_set('user_registrationpassword_registration', 'default');
  }
  if (variable_get('user_registrationpassword_registration', '') == 2) {
    variable_set('user_registrationpassword_registration', 'with-pass');
  }
}

/**
 * Update 7002 rebuilds the registry.
 */
function user_registrationpassword_update_7002() {
  registry_rebuild();
}

Functions

Namesort descending Description
user_registrationpassword_install Implements hook_install().
user_registrationpassword_uninstall Implements hook_uninstall().
user_registrationpassword_update_7000 Update 7000 updates the name of the variable.
user_registrationpassword_update_7001 Update 7001 updates all static variables.
user_registrationpassword_update_7002 Update 7002 rebuilds the registry.