You are here

jquery_calendar.install in jQuery World Calendars API 7

Same filename and directory in other branches
  1. 3.x jquery_calendar.install

Implements necessary hooks for un/installation.

File

jquery_calendar.install
View source
<?php

/**
 * @file
 * Implements necessary hooks for un/installation.
 */

/**
 * @return array
 */
function _jquery_calendar_variables() {
  return array(
    'jquery_calendar_compression_level' => 'normal',
    'jquery_calendar_datepicker_theme' => 'smoothness',
  );
}

/**
 * Implements hook_requirements().
 */
function jquery_calendar_requirements($phase) {

  // Module API is not available at this point.
  drupal_load('module', 'jquery_calendar');

  // Return the $requirements array.
  return _jquery_calendar_requirements_check();
}

/**
 * Implements hook_enable().
 */
function jquery_calendar_enable() {

  // Notify user.
  drupal_set_message(st('jQuery Calendar API has been installed. Please set your settings in <a href="!link">configuration page</a>.', array(
    '!link' => url('admin/config/user-interface/jquery-calendar'),
  )));
}

/**
 * Implements hook_install().
 */
function jquery_calendar_install() {
  _jquery_calendar_variables_set(_jquery_calendar_variables());
}

/**
 * Implements hook_uninstall().
 */
function jquery_calendar_uninstall() {
  _jquery_calendar_variables_del(_jquery_calendar_variables());
}

/**
 * @param $variables
 */
function _jquery_calendar_variables_set($variables) {
  foreach ($variables as $key => $val) {
    variable_set($key, $val);
  }
}

/**
 * @param $variables
 */
function _jquery_calendar_variables_del($variables) {
  $variables = array_keys($variables);
  foreach ($variables as $variable) {
    variable_del($variable);
  }
}