You are here

webform_mysql_views.install in Webform MySQL Views 6.2

Same filename and directory in other branches
  1. 6 webform_mysql_views.install
  2. 7 webform_mysql_views.install

Webform MySQL Views module install/schema hooks.

File

webform_mysql_views.install
View source
<?php

// $Id$

/**
 * @file
 * Webform MySQL Views module install/schema hooks.
 */

// Define the minimum required MySQL version needed by this module.
define('WEBFORM_MYSQL_VIEWS_MINIMUM_MYSQL', '5.0');

/**
 * Implementation of hook_uninstall().
 */
function webform_mysql_views_uninstall() {

  //Get list of views in the system, if any
  $views = variable_get('webform_mysql_views_views', array());
  foreach ($views as $key => $val) {
    db_query("DROP VIEW {%s}" . $val);
  }

  //Delete module variables
  variable_del('webform_mysql_views_meets_reqs');
  variable_del('webform_mysql_views_views');
}

/**
 * Implementation of hook_requirements().
 *
 * Check Drupal environment for module requirements
 */
function webform_mysql_views_requirements($phase) {
  global $db_url;
  $t = get_t();
  $requirements = array();

  // Cope with a site that uses multiple db_urls.
  if (!is_array($db_url)) {
    $_dburl = $db_url;
  }
  else {
    $_dburl = $db_url['default'];
  }
  $requirements['webform_mysql_views'] = array(
    'title' => $t('Webform MySQL Views'),
  );
  if (substr($_dburl, 0, 5) != 'mysql') {
    $requirements['webform_mysql_views']['severity'] = REQUIREMENT_ERROR;
    $requirements['webform_mysql_views']['value'] = $t('Unsupported.');
    $requirements['webform_mysql_views']['description'] = $t('This module is only compatible with the MySQL backend.');
  }
  else {
    if (version_compare(db_version(), WEBFORM_MYSQL_VIEWS_MINIMUM_MYSQL) < 0) {
      $requirements['webform_mysql_views']['severity'] = REQUIREMENT_ERROR;
      $requirements['webform_mysql_views']['value'] = $t('Unsupported.');
      $requirements['webform_mysql_views']['description'] = $t('Your MySQL Server is too old. Webform MySQL Views requires at least MySQL %minimum but you are using %version.', array(
        '%minimum' => WEBFORM_MYSQL_VIEWS_MINIMUM_MYSQL,
        '%version' => db_version(),
      ));
    }
    else {
      $requirements['webform_mysql_views']['severity'] = REQUIREMENT_OK;
      $requirements['webform_mysql_views']['value'] = $t('You are using MySQL version %version.', array(
        '%version' => db_version(),
      ));
    }
  }

  // Let the user know that upload.module could add some useful things.
  if (!module_exists('upload')) {
    $requirements['webform_mysql_views_upload'] = array(
      'title' => $t('Upload'),
      'severity' => REQUIREMENT_WARNING,
      'value' => $t('The upload module is not enabled.'),
      'description' => $t('The upload module allows you to access attached files directly in !webform. You can enable it on the !link.', array(
        '!webform' => l('Webform MySQL Views', 'admin/content/webform/mysql'),
        '!link' => l('modules page', 'admin/build/modules'),
      )),
    );
  }

  // Let the user know that upload.module could add some useful things.
  if (!module_exists('date_api')) {
    $requirements['webform_mysql_views_date_api'] = array(
      'title' => $t('Date API'),
      'severity' => REQUIREMENT_WARNING,
      'value' => $t('The date_api module is not enabled.'),
      'description' => $t('The date_api module allows you to filter by date components in !webform. date_api is part of <a href="http://drupal.org/project/date">date</a> and if installed, you can enable it on the !link.', array(
        '!webform' => l('Webform MySQL Views', 'admin/content/webform/mysql'),
        '!link' => l('modules page', 'admin/build/modules'),
      )),
    );
  }
  return $requirements;
}

Functions

Constants