custom_pub.install in Custom Publishing Options 7
Same filename and directory in other branches
Install and update function for Custom Publishing Options.
File
custom_pub.installView source
<?php
/**
* @file
* Install and update function for Custom Publishing Options.
*/
/**
* Implements hook_install().
*/
function custom_pub_install() {
db_update('system')
->fields(array(
'weight' => 10,
))
->condition('name', 'custom_pub')
->execute();
}
/**
* Implements hook_uninstall().
*/
function custom_pub_uninstall() {
$types = variable_get('custom_pub_types', array());
foreach ($types as $type => $name) {
db_drop_field('node', $type);
}
variable_del('custom_pub_types');
variable_del('custom_pub_node_types');
}
/**
* Moves any existing custom publishing options over to Drupal 7.
*/
function custom_pub_update_7100() {
$types = variable_get('custom_pub_types', array());
$node_types = _node_types_build();
$node_types = array_keys($node_types);
$spec = array(
'description' => 'Custom publishing option.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
);
foreach ($types as $type) {
foreach ($type['node_types'] as $n_type => $name) {
if (!in_array($n_type, $node_types)) {
unset($types[$type['type']]['node_types'][$n_type]);
}
}
if (!db_field_exists('node', $type['type'])) {
db_add_field('node', $type['type'], $spec);
}
}
variable_set('custom_pub_types', $types);
}
/**
* Updates the Custom Publishing Options modules weight in the system table.
*/
function custom_pub_update_7101() {
db_update('system')
->fields(array(
'weight' => 10,
))
->condition('name', 'custom_pub')
->execute();
}
Functions
Name | Description |
---|---|
custom_pub_install | Implements hook_install(). |
custom_pub_uninstall | Implements hook_uninstall(). |
custom_pub_update_7100 | Moves any existing custom publishing options over to Drupal 7. |
custom_pub_update_7101 | Updates the Custom Publishing Options modules weight in the system table. |