| 1 |
<?php
|
| 2 |
// $Id: node_expire.install,v 1.4 2009/01/26 23:56:49 brmassa Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Install, uninstall and update the module.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_install().
|
| 11 |
*/
|
| 12 |
function node_expire_install() {
|
| 13 |
drupal_install_schema('node_expire');
|
| 14 |
}
|
| 15 |
|
| 16 |
/**
|
| 17 |
* Implementation of hook_schema().
|
| 18 |
*/
|
| 19 |
function node_expire_schema() {
|
| 20 |
$schema['node_expire'] = array(
|
| 21 |
'description' => t('Alerts administrators of possibly outdated materials, and optionally unpublishes them.'),
|
| 22 |
'fields' => array(
|
| 23 |
'nid' => array(
|
| 24 |
'description' => 'Node ID from {node}.nid.',
|
| 25 |
'type' => 'int',
|
| 26 |
'unsigned' => TRUE,
|
| 27 |
'not null' => TRUE
|
| 28 |
),
|
| 29 |
'expire' => array(
|
| 30 |
'type' => 'int',
|
| 31 |
'default' => 0,
|
| 32 |
'unsigned' => TRUE,
|
| 33 |
'not null' => TRUE
|
| 34 |
),
|
| 35 |
'expired' => array(
|
| 36 |
'type' => 'int',
|
| 37 |
'size' => 'tiny',
|
| 38 |
'default' => 0,
|
| 39 |
'not null' => TRUE
|
| 40 |
),
|
| 41 |
),
|
| 42 |
'primary key' => array('nid'),
|
| 43 |
'indexes' => array(
|
| 44 |
'expire_expired' => array('expire', 'expired'),
|
| 45 |
),
|
| 46 |
);
|
| 47 |
|
| 48 |
return $schema;
|
| 49 |
}
|
| 50 |
|
| 51 |
/**
|
| 52 |
* Implementation of hook_uninstall().
|
| 53 |
*/
|
| 54 |
function node_expire_uninstall() {
|
| 55 |
drupal_uninstall_schema('node_expire');
|
| 56 |
|
| 57 |
// Delete global variable
|
| 58 |
variable_del('node_expire_ntypes');
|
| 59 |
}
|
| 60 |
|
| 61 |
/**
|
| 62 |
* Implementation of hook_uninstall().
|
| 63 |
*
|
| 64 |
* Include the max date allowed values. Only new nodes
|
| 65 |
* (or edited ones) will be affected
|
| 66 |
*/
|
| 67 |
function node_expire_update_6200() {
|
| 68 |
if ($ntypes = variable_get('node_expire_ntypes', array())) {
|
| 69 |
foreach ($ntypes as $ntype => $default) {
|
| 70 |
$ntypes[$ntype] = array('default' => $default, 'max' => '');
|
| 71 |
}
|
| 72 |
variable_set('node_expire_ntypes', $ntypes);
|
| 73 |
}
|
| 74 |
|
| 75 |
$update[] = 'Include the max date allowed values. Only new nodes (or edited ones) will be affected';
|
| 76 |
return $update;
|
| 77 |
}
|