ad.install in Advertisement 7.3
Same filename and directory in other branches
Installation file for the ad module.
File
ad.installView source
<?php
/**
* @file
* Installation file for the ad module.
*/
/**
* Implements hook_schema().
*/
function ad_schema() {
$schema['ad_node'] = array(
'description' => 'Stores extra node ad properties.',
'fields' => array(
'nid' => array(
'description' => 'Reference to the node table.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'total_clicks' => array(
'description' => 'Total clicks of an ad.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'total_impressions' => array(
'description' => 'Total impressions of an ad.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'nid',
),
);
return $schema;
}
/**
* Implements hook_modules_enabled().
*/
function ad_modules_enabled($modules) {
// Convert the "url" and "referrer" fields to TEXT to accommodate longer URLs.
// We perform this after "hook_modules_enabled()" has run, because this is the
// event that triggers base table creation by ECK via Features.
if (in_array('ad', $modules) && db_table_exists('eck_tracked_event')) {
$spec = array(
'description' => 'Text',
'type' => 'text',
'not null' => TRUE,
);
foreach ([
'url',
'referrer',
'user_agent',
'page_title',
] as $field) {
db_change_field('eck_tracked_event', $field, $field, $spec);
}
}
}
/**
* Implements hook_uninstall().
*/
function ad_uninstall() {
variable_del('ad_queue_info');
}
/**
* Converts the "url" and "referrer" fields to TEXT to accommodate longer URLs.
*/
function ad_update_7301() {
$spec = array(
'description' => 'Text',
'type' => 'text',
'not null' => TRUE,
);
foreach ([
'url',
'referrer',
] as $field) {
db_change_field('eck_tracked_event', $field, $field, $spec);
}
}
/**
* Converts the "user_agent" and "page_title" fields to TEXT.
*/
function ad_update_7302() {
$spec = array(
'description' => 'Text',
'type' => 'text',
'not null' => TRUE,
);
foreach ([
'user_agent',
'page_title',
] as $field) {
db_change_field('eck_tracked_event', $field, $field, $spec);
}
}
/**
* Migrates queue config to the new format.
*/
function ad_update_7303() {
if (variable_get('ad_queue_impressions')) {
$info['impression'] = TRUE;
variable_set('ad_queue_info', $info);
}
variable_del('ad_queue_impressions');
}
Functions
Name![]() |
Description |
---|---|
ad_modules_enabled | Implements hook_modules_enabled(). |
ad_schema | Implements hook_schema(). |
ad_uninstall | Implements hook_uninstall(). |
ad_update_7301 | Converts the "url" and "referrer" fields to TEXT to accommodate longer URLs. |
ad_update_7302 | Converts the "user_agent" and "page_title" fields to TEXT. |
ad_update_7303 | Migrates queue config to the new format. |