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

Diff of /contributions/modules/sidecontent/sidecontent.install

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

revision 1.3, Tue Jul 3 22:39:39 2007 UTC revision 1.4, Sun Apr 5 01:03:13 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: sidecontent.install,v 1.2.2.2 2006/10/21 22:05:50 MegaGrunt Exp $  // $Id: sidecontent.install,v 1.3.2.2 2007/07/03 22:55:25 MegaGrunt Exp $
3  /**  /**
4   * @file   * @file
5   * Update file for the sidecontent module.   * Update file for the Sidecontent module.
6   */   */
7    
8  /**  /**
9   * Implementation of hook_install().   * Implementation of hook_install().
10   */   */
11  function sidecontent_install() {  function sidecontent_install() {
12      // Create tables.
13    drupal_set_message('Installing sidecontent');    drupal_install_schema('sidecontent');
   
   switch ($GLOBALS['db_type']) {  
     case 'mysql':  
     case 'mysqli':  
       $success = db_query("CREATE TABLE IF NOT EXISTS {sidecontent} (  
                         `nid` int(10) NOT NULL default '0',  
                         `format` int(4) NOT NULL default '0',  
                         `sidetitle` varchar(128) NOT NULL default '',  
                         `sidecontent` longtext NOT NULL,  
                         PRIMARY KEY  (nid)  
                          ) /*!40100 DEFAULT CHARACTER SET utf8 */;");  
       break;  
   
     case 'pgsql':  
   
        $success = db_query("CREATE TABLE {sidecontent} (  
                             nid int4 NOT NULL default '0',  
                             format int4 NOT NULL default '0',  
                             sidetitle varchar(128) NOT NULL default '',  
                             sidecontent text NOT NULL,  
                             PRIMARY KEY  (nid)  
                             );");  
       break;  
   }  
   
   if ($success) {  
     drupal_set_message(t('Sidecontent module installed tables successfully.'));  
   }  
   else {  
     drupal_set_message(t('The installation of the sidecontent module database tables failed.'), 'error');  
   }  
   
14    return;    return;
15  }  }
16    
17    /**
18    * Implementation of hook_schema().
19    */
20    function sidecontent_schema() {
21    
22      $schema['sidecontent'] = array(
23        'description' => t("Sidecontent title and content."),
24        'fields' => array(
25          'nid' => array(
26            'description' => t("ID key of node related to block."),
27            'type' => 'int',
28            'not null' => TRUE,
29            'default' => 0,
30            'disp-width' => '10'
31          ),
32          'format' => array(
33            'description' => t("ID of Input Filter used by block content."),
34            'type' => 'int',
35            'not null' => TRUE,
36            'default' => 0,
37            'disp-width' => '10'
38          ),
39          'sidetitle' => array(
40            'description' => t("Block title."),
41            'type' => 'varchar',
42            'length' => '128',
43            'not null' => TRUE,
44            'default' => ''
45          ),
46                'sidecontent' => array(
47                  'description' => t("Block content."),
48                  'type' => 'text',
49                  'size' => 'big',
50                  'not null' => TRUE,
51            'default' => ''
52                ),
53        ),
54        'indexes' => array(
55          'nid' => array('nid')
56        ),
57      );
58    
59      return $schema;
60    }
61    
62  /*  /*
63   * update module for UTF.   * update module for UTF.
64   */   */
65  function sidecontent_update_1() {  function sidecontent_update_1() {
66    return _system_update_utf8(array('sidecontent'));    $ret = array();
67      _system_update_utf8(array('sidecontent'));
68      return $ret;
69  }  }
70    
71  /*  /*
# Line 64  function sidecontent_update_2() { Line 79  function sidecontent_update_2() {
79      case 'mysql':      case 'mysql':
80      case 'mysqli':      case 'mysqli':
81        $ret[] = update_sql("ALTER TABLE {sidecontent} ADD COLUMN sidetitle varchar(128) NOT NULL default '' AFTER format");        $ret[] = update_sql("ALTER TABLE {sidecontent} ADD COLUMN sidetitle varchar(128) NOT NULL default '' AFTER format");
82        $ret[] = update_sql("ALTER  TABLE {sidecontent}  ADD  PRIMARY  KEY (  `nid`  )");        $ret[] = update_sql("ALTER  TABLE {sidecontent}  ADD  PRIMARY  KEY (`nid`)");
83        break;        break;
84      case 'pgsql':      case 'pgsql':
85        $ret[] = update_sql("ALTER TABLE {sidecontent} ADD COLUMN sidetitle varchar(128) NOT NULL default ''");        $ret[] = update_sql("ALTER TABLE {sidecontent} ADD COLUMN sidetitle varchar(128) NOT NULL default ''");
86        $ret[] = update_sql("ALTER  TABLE {sidecontent}  ADD  PRIMARY  KEY (  nid  )");        $ret[] = update_sql("ALTER  TABLE {sidecontent}  ADD  PRIMARY  KEY (`nid`)");
87        break;        break;
88    }    }
89    return $ret;    return $ret;
# Line 97  function sidecontent_update_3() { Line 112  function sidecontent_update_3() {
112    return $ret;    return $ret;
113  }  }
114    
   
115  /**  /**
116  * Implementation of hook_uninstall().  * Implementation of hook_uninstall().
117  */  */
118  function sidecontent_uninstall() {  function sidecontent_uninstall() {
119    db_query('DROP TABLE {sidecontent}');    // Remove tables.
120      drupal_uninstall_schema('sidecontent');
121    
122    variable_del('sidecontent_title');    variable_del('sidecontent_title');
123    variable_del('sidecontent_print');    variable_del('sidecontent_print');
124    variable_del('sidecontent_show_input_format');    variable_del('sidecontent_show_input_format');

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

  ViewVC Help
Powered by ViewVC 1.1.2