mobile_tools.install in Mobile Tools 7.3
Same filename and directory in other branches
Instalation of the mobile_tools module
File
mobile_tools.installView source
<?php
/**
* @file
* Instalation of the mobile_tools module
*
*/
/**
* Implements hook_install().
*/
function mobile_tools_install() {
// @todo adjust module weight to alongside any dependency modules
}
/**
* Implements hook_enable().
*/
function mobile_tools_enable() {
if (variable_get('cache') == TRUE) {
drupal_set_message(t('Please note that page caching will only work for pages where no device group is active when using the default Drupal database cache.'), 'info');
}
}
/**
* Implements hook_schema().
*/
function mobile_tools_schema() {
$schema = array();
$schema['mobile_tools_device_group'] = array(
'description' => 'Store device groups for mobile tools',
'export' => array(
'key' => 'dgid',
'identifier' => 'device_group',
'default hook' => 'default_mobile_tools_device_groups',
'api' => array(
'owner' => 'mobile_tools',
'api' => 'default_mobile_tools_device_group',
'minimum_version' => 1,
'current_version' => 1,
),
),
'fields' => array(
'dgid' => array(
'description' => 'The machine-readable device group name',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'title' => array(
'description' => 'The human-readable title for this device group',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'purl_modifier' => array(
'description' => 'PURL Modifier',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'theme' => array(
'description' => 'Theme',
'type' => 'varchar',
'length' => 255,
'default' => '0',
),
'themekey_id' => array(
'description' => 'ThemeKey Rule ID',
'type' => 'int',
'not null' => FALSE,
'unsigned' => TRUE,
),
'description' => array(
'description' => 'The human-readable name of the device group',
'type' => 'text',
),
'detector' => array(
'type' => 'varchar',
'description' => 'Module responsible for device detection',
'default' => '',
'not null' => FALSE,
'length' => 255,
),
'detection_settings' => array(
'type' => 'blob',
'description' => 'Settings for enabled detection devices',
'serialize' => TRUE,
),
'weight' => array(
'type' => 'int',
'unsigned' => FALSE,
'description' => 'Weight of the device group',
'default' => 0,
'not null' => TRUE,
),
'httpheaders' => array(
'type' => 'blob',
'description' => 'HTTP Headers to include in the device group',
'serialize' => TRUE,
),
),
'primary key' => array(
'dgid',
),
);
return $schema;
}
/**
* Implements hook_uninstall().
*
* Removing the mobile user roles from the role table
* Cleanup of the variables
*/
function mobile_tools_uninstall() {
variable_del('mobile_tools_enable_view_modes');
variable_del('mobile_tools_enable_redirection');
variable_del('mobile_tools_global_httpheaders');
variable_del('mobile_tools_redirection_type');
variable_del('mobile_tools_redirection_auto');
}
/**
* Implements hook_update_N().
*
* Rename variable names with a dash to comply with Drupal coding standards.
*/
function mobile_tools_update_7200() {
// Load the t function in case it isn't loaded yet
$t = get_t();
$mt_device_detection = variable_get('mobile-tools-device-detection', 'mobile_tools');
$mt_device_capabilities = variable_get('mobile-tools-device-capabilities', 'wurfl');
$mt_device_capability = variable_get('mobile-tools-device-capability', 'wurfl');
$mt_theme_switch = variable_get('mobile-tools-theme-switch', 'mobile-tools-no-switch');
$mt_site_type_detection = variable_get('mobile-tools-site-type-detection', 'mobile_tools');
variable_set('mobile_tools_device_detection', $mt_device_detection);
variable_set('mobile_tools_device_capabilities', $mt_device_capabilities);
variable_set('mobile_tools_device_capability', $mt_device_capability);
variable_set('mobile_tools_theme_switch', $mt_theme_switch);
variable_set('mobile_tools_site_type_detection', $mt_site_type_detection);
variable_del('mobile-tools-device-detection');
variable_del('mobile-tools-device-capabilities');
variable_del('mobile-tools-device-capability');
variable_del('mobile-tools-theme-switch');
variable_del('mobile-tools-site-type-detection');
return $t('Renamed incorrect variable names.');
}
/**
* Implements hook_update_N().
*
* Removes all deprecated variables
*/
function mobile_tools_update_7201(&$sandbox) {
variable_del('mobile_tools_device_capability');
variable_del('mobile_tools_theme_switch');
variable_del('mobile_tools_site_type_detection');
variable_del('default_main_nodes_mobile');
variable_del('default_main_nodes_original');
variable_del('site_frontpage_mobile');
variable_del('desktop_notification');
variable_del('mobile_notification');
variable_del('mobile_tools_redirect_exceptions');
variable_del('mobile_tools_redirect_exceptions_type');
variable_del('mobile_tools_cookie_session');
variable_del('mobile_tools_desktop_url');
variable_del('mobile_tools_mobile_url');
variable_del('mobile_tools_theme_switch');
variable_del('mobile_tools_theme_name');
variable_del('mobile_tools_device_detection');
variable_del('mobile_tools_device_capabilities');
}
/**
* Implements hook_update_N().
*
* Add a weight column to device groups
*/
function mobile_tools_update_7301(&$sandbox) {
$field = array(
'type' => 'int',
'unsigned' => FALSE,
'description' => 'Weight of the device group',
'default' => 0,
'not null' => TRUE,
'initial' => 0,
);
db_add_field('mobile_tools_device_group', 'weight', $field, array(
'indexes' => array(
'weight' => array(
'weight',
),
),
));
}
/**
* Implements hook_update_N().
*
* Adds column to store themekey rule ID
*/
function mobile_tools_update_7302(&$sandbox) {
$field = array(
'description' => 'ThemeKey Rule ID',
'type' => 'int',
'not null' => FALSE,
'unsigned' => TRUE,
);
// We don't include the foreign key relationship since ThemeKey may not exist
// @todo change theme switch to be a separate module to fix this shortcoming
db_add_field('mobile_tools_device_group', 'themekey_id', $field);
}
/**
* Implements hook_update_N().
*
* Adds field to store http headers for each device group
*/
function mobile_tools_update_7303(&$sandbox) {
$field = array(
'type' => 'blob',
'description' => 'HTTP Headers to include in the device group',
'serialize' => TRUE,
);
db_add_field('mobile_tools_device_group', 'httpheaders', $field);
}
/**
* Implements hook_update_N().
*
* Adds field to store device detection methods.
*/
function mobile_tools_update_7304(&$sandbox) {
$field = array(
'type' => 'blob',
'description' => 'Type of device detection to use',
'serialize' => TRUE,
);
db_add_field('mobile_tools_device_group', 'detection', $field);
}
/**
* Implements hook_update_N().
*
* Adds field to store device detection method settings.
*/
function mobile_tools_update_7305(&$sandbox) {
$field = array(
'type' => 'blob',
'description' => 'Settings for enabled detection devices',
'serialize' => TRUE,
);
db_add_field('mobile_tools_device_group', 'detection_settings', $field);
}
/**
* Implements hook_update_N().
*
* Changing detection field to store name of module only and rename it.
* Warning, data will be lost.
*/
function mobile_tools_update_7306(&$sandbox) {
$field = array(
'type' => 'varchar',
'description' => 'Module responsible for device detection',
'default' => '',
'length' => 255,
'not null' => FALSE,
);
// Create the new field
db_add_field('mobile_tools_device_group', 'detector', $field);
// Drop the old field
db_drop_field('mobile_tools_device_group', 'detection');
}
/**
* Implements hook_update().
*/
function mobile_tools_update_7307(&$sandbox) {
// Force the update hook to run and force a cache clear to allow
// new PURL providers to appear.
cache_clear_all();
}
Functions
Name | Description |
---|---|
mobile_tools_enable | Implements hook_enable(). |
mobile_tools_install | Implements hook_install(). |
mobile_tools_schema | Implements hook_schema(). |
mobile_tools_uninstall | Implements hook_uninstall(). |
mobile_tools_update_7200 | Implements hook_update_N(). |
mobile_tools_update_7201 | Implements hook_update_N(). |
mobile_tools_update_7301 | Implements hook_update_N(). |
mobile_tools_update_7302 | Implements hook_update_N(). |
mobile_tools_update_7303 | Implements hook_update_N(). |
mobile_tools_update_7304 | Implements hook_update_N(). |
mobile_tools_update_7305 | Implements hook_update_N(). |
mobile_tools_update_7306 | Implements hook_update_N(). |
mobile_tools_update_7307 | Implements hook_update(). |