calendar_systems.install in Calendar Systems 7.3
Contains Calendar Systems installation hooks.
File
calendar_systems.installView source
<?php
/**
* @file
* Contains Calendar Systems installation hooks.
*/
/**
* 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) {
$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'),
)),
'description' => $t('Required core patch for calendar systems to fully work'),
'severity' => REQUIREMENT_WARNING,
);
if (_calendar_systems_install_patch_applied() === TRUE) {
$requirements['calendar_systems_patch']['value'] = $t('Core patch is applied');
$requirements['calendar_systems_patch']['severity'] = REQUIREMENT_OK;
}
elseif (_calendar_systems_install_patch_applied() == '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;
}
/**
* Internal helper to check whether the required patch is applied or not.
*
* @return
* Boolean value.
*/
function _calendar_systems_install_patch_applied() {
$content = file_get_contents(DRUPAL_ROOT . '/includes/common.inc');
// Check against patch fingerprint:
$patch_applied = strpos($content, 'foreach (module_implements(\'format_date\') AS $module) {') !== FALSE ? TRUE : FALSE;
$new_patch_applied = strpos($content, 'foreach (module_implements(\'format_date_calendar_systems\') AS $module) {') !== FALSE ? TRUE : FALSE;
if (!$new_patch_applied && $patch_applied) {
return 'outdated';
}
if ($new_patch_applied) {
return TRUE;
}
return $patch_applied;
}
Functions
Name | Description |
---|---|
calendar_systems_enable | Implements hook_enable(). |
calendar_systems_requirements | Implements hook_requirements(). |
calendar_systems_schema | Implements hook_schema(). |
_calendar_systems_install_patch_applied | Internal helper to check whether the required patch is applied or not. |