node_expire.install in Node expire 7
Same filename and directory in other branches
Install, uninstall and update the module.
File
node_expire.installView source
<?php
/**
* @file
* Install, uninstall and update the module.
*/
/**
* Implements hook_schema().
*/
function node_expire_schema() {
$schema['node_expire'] = array(
'description' => 'Alerts administrators of possibly outdated materials, and optionally unpublishes them.',
'fields' => array(
'nid' => array(
'description' => 'Node ID from {node}.nid.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'expire' => array(
'type' => 'int',
'default' => 0,
'unsigned' => TRUE,
'not null' => TRUE,
),
'expired' => array(
'type' => 'int',
'size' => 'tiny',
'default' => 0,
'not null' => TRUE,
),
'lastnotify' => array(
'type' => 'int',
'default' => 0,
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'primary key' => array(
'nid',
),
'indexes' => array(
'expire_expired_lastnotify' => array(
'expire',
'expired',
'lastnotify',
),
),
);
return $schema;
}
/**
* Implements hook_uninstall().
*/
function node_expire_uninstall() {
// TODO The drupal_(un)install_schema
// functions are called automatically in D7.
// drupal_uninstall_schema('node_expire').
//
// Delete global variable.
variable_del('node_expire_ntypes');
// Delete configuration variables.
variable_del('node_expire_handle_content_expiry');
variable_del('node_expire_date_entry_elements');
variable_del('node_expire_past_date_allowed');
// Delete node type related variables.
$types = node_type_get_types();
foreach ($types as $type) {
variable_del('node_expire_' . $type->type);
variable_del('node_expire_enabled_' . $type->type);
variable_del('node_expire_max_' . $type->type);
variable_del('node_expire_required_' . $type->type);
}
}
/**
* Implements hook_update_N().
*
* Include the max date allowed values. Only new nodes
* (or edited ones) will be affected
*/
function node_expire_update_6200() {
if ($ntypes = variable_get('node_expire_ntypes', array())) {
foreach ($ntypes as $ntype => $default) {
$ntypes[$ntype] = array(
'default' => $default,
'max' => '',
);
}
variable_set('node_expire_ntypes', $ntypes);
}
// $update[]
// = 'Include the max date allowed values.
// Only new nodes (or edited ones) will be affected';
// hook_update_N() no longer returns a $ret array. Instead, return
// nothing or a translated string indicating the update ran successfully.
// See http://drupal.org/node/224333#update_sql. /* $update */
return t('TODO Add a descriptive string here to show in the UI.');
}
/**
* Implements hook_update_N().
*
* New field 'lastnotify'. Holds last notified timestamp.
*/
function node_expire_update_6201() {
// $ret = array();
if (!db_field_exists('node_expire', 'lastnotify')) {
db_add_field('node_expire', 'lastnotify', array(
'type' => 'int',
'default' => 0,
'unsigned' => TRUE,
'not null' => TRUE,
));
}
db_drop_index('node_expire', 'expire_expired');
db_add_index('node_expire', 'expire_expired_lastnotify', array(
'expire',
'expired',
'lastnotify',
));
// hook_update_N() no longer returns a $ret array. Instead, return
// nothing or a translated string indicating the update ran successfully.
// See http://drupal.org/node/224333#update_sql. /* $ret */
return t('TODO Add a descriptive string here to show in the UI.');
}
Functions
Name | Description |
---|---|
node_expire_schema | Implements hook_schema(). |
node_expire_uninstall | Implements hook_uninstall(). |
node_expire_update_6200 | Implements hook_update_N(). |
node_expire_update_6201 | Implements hook_update_N(). |