You are here

email_verify.install in Email Verify 7.2

Install, update and uninstall functions for this module.

File

email_verify.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for this module.
 */

/**
 * Implements hook_install().
 *
 * Display a message to the admin about activating this module.
 */
function email_verify_install() {
  $t = get_t();
  $link = l($t('administrative settings page'), 'admin/config/system/email_verify');
  $message = $t('The Email Verify module has been installed and enabled. However, before it can be used, it must be activated and configured on its !adminpage.', array(
    '!adminpage' => $link,
  ));
  drupal_set_message($message);
}

/**
 * Implements hook_uninstall().
 *
 * Removes variables created by this module.
 */
function email_verify_uninstall() {

  // Get global variable array.
  global $conf;
  foreach (array_keys($conf) as $key) {

    // Find variables that have the module name prefixed.
    if (strpos($key, 'email_verify_') === 0) {
      variable_del($key);
    }
  }
}

/**
 * Implements hook_disable().
 */
function email_verify_disable() {
  $email_verify_active = variable_get('email_verify_active', NULL);
  if ($email_verify_active !== NULL) {

    // Inactivate this module.
    variable_set('email_verify_active', FALSE);
  }
}

/**
 * Changes the email_verify_on variable to email_verify_active.
 */
function email_verify_update_7100() {
  $email_verify_on = variable_get('email_verify_on', NULL);
  if ($email_verify_on !== NULL) {
    variable_set('email_verify_active', $email_verify_on);
    variable_del('email_verify_on');
  }
}

/**
 * Updates the selected forms for the new, more flexible way of selecting forms.
 */
function email_verify_update_7201() {
  $forms = variable_get('email_verify_forms', '');
  if (empty($forms)) {

    // The user registration form.
    $email_verify_user_registration = variable_get('email_verify_user_registration', NULL);
    if (!empty($email_verify_user_registration)) {

      // Add the form to the list.
      $forms .= "user_register_form, mail\n";

      // Delete the old variable.
      variable_del('email_verify_user_registration');
    }

    // The user profile form.
    $email_verify_user_profile = variable_get('email_verify_user_profile', NULL);
    if (!empty($email_verify_user_profile)) {

      // Add the form to the list.
      $forms .= "user_profile_form, mail\n";

      // Delete the old variable.
      variable_del('email_verify_user_profile');
    }

    // The site-wide contact form.
    $email_verify_site_contact = variable_get('email_verify_site_contact', NULL);
    if (!empty($email_verify_site_contact)) {

      // Add the form to the list.
      $forms .= "contact_site_form, mail\n";

      // Delete the old variable.
      variable_del('email_verify_site_contact');
    }

    // The personal contact form.
    $email_verify_personal_contact = variable_get('email_verify_personal_contact', NULL);
    if (!empty($email_verify_personal_contact)) {

      // Add the form to the list.
      $forms .= "contact_personal_form, mail\n";

      // Delete the old variable.
      variable_del('email_verify_personal_contact');
    }
    variable_set('email_verify_forms', $forms);
  }
}

/**
 * Sets the weight of Email Verify to a high number to process all forms.
 */
function email_verify_update_7202() {

  // Set the weight of this module as high as reasonable, so that its form_alter
  // hook gets called after other modules, because sometimes, the hook for this
  // module is called before the data is available to it.
  db_update('system')
    ->fields(array(
    'weight' => 1000,
  ))
    ->condition('name', 'email_verify', '=')
    ->execute();
}

Functions

Namesort descending Description
email_verify_disable Implements hook_disable().
email_verify_install Implements hook_install().
email_verify_uninstall Implements hook_uninstall().
email_verify_update_7100 Changes the email_verify_on variable to email_verify_active.
email_verify_update_7201 Updates the selected forms for the new, more flexible way of selecting forms.
email_verify_update_7202 Sets the weight of Email Verify to a high number to process all forms.