node_expire.install in Node expire 6.2
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.
*/
/**
* Implementation of hook_install().
*/
function node_expire_install() {
drupal_install_schema('node_expire');
}
/**
* Implementation of hook_schema().
*/
function node_expire_schema() {
$schema['node_expire'] = array(
'description' => t('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;
}
/**
* Implementation of hook_uninstall().
*/
function node_expire_uninstall() {
drupal_uninstall_schema('node_expire');
// Delete global variable
variable_del('node_expire_ntypes');
}
/**
* Implementation of 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';
return $update;
}
/**
* Implementation of hook_update_N().
*
* New field 'lastnotify'. Holds last notified timestamp.
*/
function node_expire_update_6201() {
$ret = array();
if (!db_column_exists('node_expire', 'lastnotify')) {
db_add_field($ret, 'node_expire', 'lastnotify', array(
'type' => 'int',
'default' => 0,
'unsigned' => TRUE,
'not null' => TRUE,
));
}
db_drop_index($ret, 'node_expire', 'expire_expired');
db_add_index($ret, 'node_expire', 'expire_expired_lastnotify', array(
'expire',
'expired',
'lastnotify',
));
return $ret;
}
Functions
Name | Description |
---|---|
node_expire_install | Implementation of hook_install(). |
node_expire_schema | Implementation of hook_schema(). |
node_expire_uninstall | Implementation of hook_uninstall(). |
node_expire_update_6200 | Implementation of hook_update_N(). |
node_expire_update_6201 | Implementation of hook_update_N(). |