You are here

users_export.install in Users Export 7.2

Same filename and directory in other branches
  1. 8 users_export.install

Handles installation steps for users_export.

File

users_export.install
View source
<?php

/**
 * @file
 * Handles installation steps for users_export.
 *
 * @ingroup users_export
 */

/**
 * Implements hook_uninstall().
 */
function users_export_uninstall() {
  $vars = db_select('variable', 'v')
    ->fields('v', array(
    'name',
  ))
    ->condition('name', 'users_export%', 'LIKE')
    ->execute()
    ->fetchCol();
  foreach ($vars as $var) {
    variable_del($var);
  }
  $tables = array(
    'block',
    'block_role',
  );
  foreach ($tables as $table) {
    if (db_table_exists($table)) {
      db_delete($table)
        ->condition('module', 'users_export')
        ->execute();
    }
  }
}

/**
 * Implements hook_enable().
 */
function users_export_enable() {
  drupal_set_message(t('You may export users by visiting <a href="@url">@url</a>.', array(
    '@url' => url('admin/people/export'),
  )));
}

/**
 * Update from 7.x-1.1 to 7.x-2.0.
 */
function users_export_update_7001(&$sandbox) {
  $output = array();
  try {
    variable_del('users_export_type');
    if (!module_exists('loft_data_grids')) {
      $output[] = 'You must immediately install the Loft Data Grids module; refer to the README for instructions.' . "\n";
    }
  } catch (Exception $e) {
    throw new DrupalUpdateException('FAILED: Update from 7.x-1.0 to 7.x-2.0');
  }
  return implode("<br />", $output);
}

/**
 * Manual step(s) required, PLEASE READ NEXT PAGE...
 */
function users_export_update_7002(&$sandbox) {
  $output = array();
  if (!function_exists('loft_data_grids_info')) {
    $output[] = st('You must install the latest 2.x version of <a href="!url">Loft Data Grids</a> immediately; update instructions are found within the module\'s README file.', array(
      '!url' => url('http://www.intheloftstudios.com/packages/php/drupal_loft_data_grids'),
    ));
  }
  $output[] = st('Export format options are now controlled by Loft Data Grids; please <a href="!url">manually migrate your permissions</a> from <em>Users Export</em> to <em>Loft Data Grids</em> now.', array(
    '!url' => url('admin/people/permissions'),
  ));
  return implode("<br />", $output);
}

/**
 * Implements hook_requirements().
 */
function users_export_requirements($phase) {
  $reqs = array();
  $t = get_t();
  if ($phase == 'runtime') {
    $modules = array();
    if (!module_exists('loft_data_grids')) {
      $modules[] = 'loft_data_grids';
    }
    if ($modules) {
      $reqs['users_export'] = array(
        'title' => $t('Users Export Dependencies'),
        'description' => $t('The following module(s) need to be enabled: %modules', array(
          '%modules' => implode(', ', $modules),
        )),
        'severity' => REQUIREMENT_ERROR,
        'value' => $t('Missing'),
      );
    }
    if (!function_exists('loft_data_grids_info')) {
      $reqs['users_export'] = array(
        'title' => $t('Users Export'),
        'description' => $t('Please upgrade <a href="!url">Loft Data Grids</a> to the 2.x branch immediately!', array(
          '!url' => url('http://www.intheloftstudios.com/packages/php/drupal_loft_data_grids'),
        )),
        'severity' => REQUIREMENT_ERROR,
        'value' => $t('Outdated dependency'),
      );
    }
  }
  return $reqs;
}

Related topics

Functions

Namesort descending Description
users_export_enable Implements hook_enable().
users_export_requirements Implements hook_requirements().
users_export_uninstall Implements hook_uninstall().
users_export_update_7001 Update from 7.x-1.1 to 7.x-2.0.
users_export_update_7002 Manual step(s) required, PLEASE READ NEXT PAGE...