popup_onload.install in Popup On Load 7
Same filename and directory in other branches
Install, update, and uninstall functions for the Popup On Load module.
File
popup_onload.installView source
<?php
/**
* @file
* Install, update, and uninstall functions for the Popup On Load module.
*/
/**
* Implements hook_schema().
*/
function popup_onload_schema() {
$schema = [];
$schema['popup_onload'] = [
'description' => 'The base table for popup entities.',
'fields' => [
'popup_id' => [
'description' => 'Primary Key: Identifier for a popup.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
],
'bundle_type' => [
'description' => 'The type of the popup.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
],
'language' => [
'description' => 'The language of the popup.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
],
'name' => [
'description' => 'The name of the popup - a human-readable identifier.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
],
'body' => [
'type' => 'text',
'not null' => FALSE,
'description' => 'The body of the popup.',
],
'format' => [
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'description' => 'Format of the popup\'s body.',
],
'width' => [
'description' => 'The width of the popup.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
],
'height' => [
'description' => 'The height of the popup.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
],
'fixed_position' => [
'description' => 'Indicate whether the popup position is fixed in the browser.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
],
'active_popup' => [
'description' => 'Provide option to deactivate popup.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 1,
],
'cookie_lifetime_single' => [
'description' => 'Provide ability to set cookie lifetime for single popup',
'type' => 'int',
'not null' => FALSE,
'default' => NULL,
],
],
'primary key' => [
'popup_id',
],
'indexes' => [
'bundle_type' => [
'bundle_type',
],
],
];
return $schema;
}
/**
* Implements hook_uninstall().
*/
function popup_onload_uninstall() {
field_attach_delete_bundle('popup_onload', 'popup_onload_basic');
// Include module to resolve constants' names.
require_once 'popup_onload.module';
// Delete all popup_onload-related variables.
variable_del(POPUP_ONLOAD_VAR_SORT_METHOD);
variable_del(POPUP_ONLOAD_VAR_COOKIE_NAME);
variable_del(POPUP_ONLOAD_VAR_COOKIE_LIFETIME);
variable_del(POPUP_ONLOAD_VAR_DISPLAY_DELAY);
variable_del(POPUP_ONLOAD_VAR_USE_RULES);
}
/**
* Implements hook_update_N().
*
* 1. Convert popup cookie lifetime value into seconds.
* 2. Add a variable with popup cookie name.
*/
function popup_onload_update_7101() {
$popup_cookie_lifetime = variable_get(POPUP_ONLOAD_VAR_COOKIE_LIFETIME, 14);
// Convert days to seconds.
variable_set(POPUP_ONLOAD_VAR_COOKIE_LIFETIME, $popup_cookie_lifetime * 24 * 60 * 60);
// Set default popup cookie name.
variable_set(POPUP_ONLOAD_VAR_COOKIE_NAME, 'popup_onload_cookie_name');
}
/**
* Implements hook_update_N().
*
* 1. Add active_popup field.
*/
function popup_onload_update_7102() {
db_add_field('popup_onload', 'active_popup', [
'description' => 'Provide option to deactivate popup.',
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 1,
]);
}
/**
* Implements hook_update_N().
*
* 1. Add cookie cookie_lifetime_single field.
*/
function popup_onload_update_7103() {
db_add_field('popup_onload', 'cookie_lifetime_single', [
'description' => 'Provide ability to set cookie lifetime for single popup',
'type' => 'int',
'not null' => FALSE,
'default' => NULL,
]);
}
Functions
Name | Description |
---|---|
popup_onload_schema | Implements hook_schema(). |
popup_onload_uninstall | Implements hook_uninstall(). |
popup_onload_update_7101 | Implements hook_update_N(). |
popup_onload_update_7102 | Implements hook_update_N(). |
popup_onload_update_7103 | Implements hook_update_N(). |