calendar_systems.install in Calendar Systems 8
Contains Calendar Systems installation hooks.
File
calendar_systems.installView source
<?php
/**
* @file
* Contains Calendar Systems installation hooks.
*/
/**
* @return array
*/
function _calendar_systems_variables() {
return array(
'calendar_systems_js_date_picker_core_text_date_fields' => '',
);
}
/**
* Implements hook_schema().
*/
function calendar_systems_schema() {
$schema = array();
$schema['calendar_systems'] = array(
'description' => 'Stores calendar systems profiles.',
'fields' => array(
'language' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
),
'calendar_system' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
),
'settings' => array(
'type' => 'text',
'size' => 'normal',
),
),
'primary key' => array(
'language',
),
);
return $schema;
}
/**
* Implements hook_enable().
*/
function calendar_systems_enable() {
drupal_set_message(t('Calendar systems has been successfully enabled. You might want to <a href="!link">configure its options</a>.', array(
'!link' => url('admin/config/regional/calendar-systems'),
)));
}
/**
* Implements hook_requirements().
*/
function calendar_systems_requirements($phase) {
require_once dirname(__FILE__) . '/calendar_systems.module';
$requirements = array();
// Ensure translations don't break at install time
$t = get_t();
if ($phase == 'runtime' || $phase == 'install') {
$requirements['calendar_systems_patch'] = array(
'title' => $t('Calendar Systems core patch'),
'value' => $t('Core patch is not applied, please follow the instructions in <a href="!readme-link">README.txt</a> file.', array(
'!readme-link' => url(drupal_get_path('module', 'calendar_systems') . '/README.txt', array(
'language' => (object) array(
'language' => FALSE,
),
)),
)),
'description' => $t('Required core patch for calendar systems to fully work'),
'severity' => REQUIREMENT_WARNING,
);
if (_calendar_systems_is_patch_applied(FALSE) === TRUE) {
$requirements['calendar_systems_patch']['value'] = $t('Core patch is applied');
$requirements['calendar_systems_patch']['severity'] = REQUIREMENT_OK;
}
elseif (_calendar_systems_is_patch_applied(FALSE) == 'outdated') {
$requirements['calendar_systems_patch']['value'] = $t('Core patch is applied but it\'s outdated, please follow the instructions in <a href="!readme-link">README.txt</a> file.', array(
'!readme-link' => url(drupal_get_path('module', 'calendar_systems') . '/README.txt'),
));
$requirements['calendar_systems_patch']['severity'] = REQUIREMENT_ERROR;
}
}
return $requirements;
}
/**
* Implements hook_install().
*/
function calendar_systems_install() {
_calendar_systems_variables_set(_calendar_systems_variables());
}
/**
* Implements hook_uninstall().
*/
function calendar_systems_uninstall() {
_calendar_systems_variables_del(_calendar_systems_variables());
}
/**
* @param $variables
*/
function _calendar_systems_variables_set($variables) {
foreach ($variables as $key => $val) {
variable_set($key, $val);
}
}
/**
* @param $variables
*/
function _calendar_systems_variables_del($variables) {
$variables = array_keys($variables);
foreach ($variables as $variable) {
variable_del($variable);
}
}
Functions
Name | Description |
---|---|
calendar_systems_enable | Implements hook_enable(). |
calendar_systems_install | Implements hook_install(). |
calendar_systems_requirements | Implements hook_requirements(). |
calendar_systems_schema | Implements hook_schema(). |
calendar_systems_uninstall | Implements hook_uninstall(). |
_calendar_systems_variables | |
_calendar_systems_variables_del | |
_calendar_systems_variables_set |