dynamic_background_node.install in Dynamic Background 7.2
Same filename and directory in other branches
Installes the database scheme and handles install and uninstall of the module.
File
modules/dynamic_background_node/dynamic_background_node.installView source
<?php
/**
* @file
* Installes the database scheme and handles install and uninstall of the
* module.
*/
/**
* Implements hook_uninstall().
*/
function dynamic_background_node_uninstall() {
// Remove settings.
variable_del('dynamic_background_node');
variable_del('dynamic_background_node_css');
variable_del('dynamic_background_node_image_style');
}
/**
* Update stored data to use the new database tables.
*/
function dynamic_background_node_update_7000() {
$query = db_select('dynamic_background_node', 'dbn');
$result = $query
->fields('dbn', array(
'nid',
'data',
))
->execute();
// Load the old stored image, as the old node extension used the array index
// and not the fid (doh).
$images = variable_get('dynamic_background_images', array());
while ($row = $result
->fetchObject()) {
$selected_images = unserialize($row->data);
foreach ($selected_images as $id => $selected) {
if ($selected['selected']) {
db_insert('dynamic_background_usage')
->fields(array(
'fid' => $images[$id]['fid'],
'type' => 'node',
'data' => $row->nid,
))
->execute();
}
}
}
}
/**
* Remove old database scheme.
*/
function dynamic_background_node_update_7001() {
db_query('drop table {dynamic_background_node}');
}
Functions
Name | Description |
---|---|
dynamic_background_node_uninstall | Implements hook_uninstall(). |
dynamic_background_node_update_7000 | Update stored data to use the new database tables. |
dynamic_background_node_update_7001 | Remove old database scheme. |