/[drupal]/contributions/modules/node_expire/node_expire.install
ViewVC logotype

Diff of /contributions/modules/node_expire/node_expire.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.3, Thu May 10 07:21:12 2007 UTC revision 1.4, Mon Jan 26 23:56:49 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  /* $Id: node_expire.install,v 1.2.2.1 2007/05/10 07:12:59 andyl56 Exp $ */  // $Id: $
3    
4  /**  /**
5   * Implamentation of hook_install()   * @file
6     * Install, uninstall and update the module.
7     */
8    
9    /**
10     * Implementation of hook_install().
11   */   */
12  function node_expire_install() {  function node_expire_install() {
13    switch ($GLOBALS['db_type']) {    drupal_install_schema('node_expire');
     case 'mysql':  
     case 'mysqli':  
       db_query("CREATE TABLE {node_expire} (  
         nid int(10) unsigned NOT NULL,  
         expire datetime default NULL,  
         expiresec VARCHAR(10) NOT NULL,  
         expiremode enum('date','onupdate','none') NOT NULL default 'none',  
         isroot tinyint(1) NOT NULL default '0',  
         lastnotify int(10) NOT NULL default '0',  
         PRIMARY KEY  (nid)  
       ) ENGINE=MyISAM;");  
   
       // For inheritance resons, we store information about every node. We're going to pre  
       db_query("INSERT IGNORE INTO {node_expire} (nid, expiremode) (SELECT nid, 'none' FROM {node});");  
     break;  
   }  
14  }  }
15    
16  /**  /**
17   * Migrate from old HEAD revision to my new version.   * Implementation of hook_schema().
18   */   */
19  function node_expire_1() {  function node_expire_schema() {
20    $ret = array();    $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    switch ($GLOBALS['db_type']) {    return $schema;
     case 'mysql':  
     case 'mysqli':  
       $ret[] = update_sql("ALTER TABLE {node_expire}  
         CHANGE nid nid INT( 10 ) NOT NULL,  
         ADD expiresec IVARCHAR(10) NOT NULL,  
         ADD expiremode ENUM( 'date', 'onupdate', 'none' ) NOT NULL DEFAULT 'none',  
         ADD isroot TINYINT( 1 ) NOT NULL DEFAULT '0',  
         ADD lastnotify INT( 10 ) NOT NULL DEFAULT '0',  
         DROP INDEX nid,  
         ADD PRIMARY KEY (nid);");  
   
       // For inheritance resons, we store information about every node. We're going to pre-fill in the data as "no expiration".  
       $ret[] = update_sql("INSERT IGNORE INTO {node_expire} (nid, expiremode) (SELECT nid, 'none' FROM {node});");  
       break;  
   }  
   
   // The old version didn't have the e-mail feature so  
   // let's disable it by default. The end user can always  
   // reenable it later.  
   variable_set('node-expire-enable-email', 0);  
   
   return $ret;  
49  }  }
50    
51  /**  /**
52   * Implamentation of hook_uninstall()   * Implementation of hook_uninstall().
53   */   */
54  function node_expire_uninstall() {  function node_expire_uninstall() {
55    db_query('DROP TABLE {node_expire}');    drupal_uninstall_schema('node_expire');
   variable_del('node-expire-body');  
   variable_del('node-expire-book-props');  
   variable_del('node-expire-cc');  
   variable_del('node-expire-enable-email');  
   variable_del('node-expire-node-visibility');  
   variable_del('node-expire-renotify');  
   variable_del('node-expire-subject');  
   variable_del('node-expire-unpublishtime');  
 }  
56    
57  ?>    // Delete global variable
58      variable_del('node_expire_ntypes');
59    }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.2