/[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.2.1, Tue Jul 3 22:39:39 2007 UTC revision 1.3.2.2, Tue Jul 3 22:55:25 2007 UTC
# Line 0  Line 1 
1    <?php
2    // $Id: sidecontent.install,v 1.2.2.2 2006/10/21 22:05:50 MegaGrunt Exp $
3    /**
4     * @file
5     * Update file for the sidecontent module.
6     */
7    
8    /**
9     * Implementation of hook_install().
10     */
11    function sidecontent_install() {
12    
13      drupal_set_message('Installing sidecontent');
14    
15      switch ($GLOBALS['db_type']) {
16        case 'mysql':
17        case 'mysqli':
18          $success = db_query("CREATE TABLE IF NOT EXISTS {sidecontent} (
19                            `nid` int(10) NOT NULL default '0',
20                            `format` int(4) NOT NULL default '0',
21                            `sidetitle` varchar(128) NOT NULL default '',
22                            `sidecontent` longtext NOT NULL,
23                            PRIMARY KEY  (nid)
24                             ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
25          break;
26    
27        case 'pgsql':
28    
29           $success = db_query("CREATE TABLE {sidecontent} (
30                                nid int4 NOT NULL default '0',
31                                format int4 NOT NULL default '0',
32                                sidetitle varchar(128) NOT NULL default '',
33                                sidecontent text NOT NULL,
34                                PRIMARY KEY  (nid)
35                                );");
36          break;
37      }
38    
39      if ($success) {
40        drupal_set_message(t('Sidecontent module installed tables successfully.'));
41      }
42      else {
43        drupal_set_message(t('The installation of the sidecontent module database tables failed.'), 'error');
44      }
45    
46      return;
47    }
48    
49    /*
50     * update module for UTF.
51     */
52    function sidecontent_update_1() {
53      return _system_update_utf8(array('sidecontent'));
54    }
55    
56    /*
57     * add sidetitle colums
58     * in case anyone is updating from patch version
59     */
60    function sidecontent_update_2() {
61      $ret = array();
62    
63      switch ($GLOBALS['db_type']) {
64        case 'mysql':
65        case 'mysqli':
66          $ret[] = update_sql("ALTER TABLE {sidecontent} ADD COLUMN sidetitle varchar(128) NOT NULL default '' AFTER format");
67          $ret[] = update_sql("ALTER  TABLE {sidecontent}  ADD  PRIMARY  KEY (  `nid`  )");
68          break;
69        case 'pgsql':
70          $ret[] = update_sql("ALTER TABLE {sidecontent} ADD COLUMN sidetitle varchar(128) NOT NULL default ''");
71          $ret[] = update_sql("ALTER  TABLE {sidecontent}  ADD  PRIMARY  KEY (  nid  )");
72          break;
73      }
74      return $ret;
75    }
76    
77    /**
78     * Update base paths for relative URLs in sidecontent .
79     */
80    function sidecontent_update_3() {
81    
82      require_once('database/updates.inc');
83      $ret = array();
84      drupal_set_message(t('Updating links in sidecontent blocks.'));
85    
86      $result = db_query("SELECT * FROM {sidecontent}");
87    
88      while ($sidecontent = db_fetch_object($result)) {
89    
90       $sidecontent->sidecontent = _update_178_url_fix($sidecontent->sidecontent);
91    
92        if ($sidecontent->sidecontent !== FALSE) {
93          db_query("UPDATE {sidecontent} SET sidecontent = '%s' WHERE nid = %d", $sidecontent->sidecontent, $sidecontent->nid);
94        }
95      }
96    
97      return $ret;
98    }
99    
100    
101    /**
102    * Implementation of hook_uninstall().
103    */
104    function sidecontent_uninstall() {
105      db_query('DROP TABLE {sidecontent}');
106      variable_del('sidecontent_title');
107      variable_del('sidecontent_print');
108      variable_del('sidecontent_show_input_format');
109      variable_del('sidecontent_show_in_group');
110      variable_del('sidecontent_group_description');
111    }

Legend:
Removed from v.1.3.2.1  
changed lines
  Added in v.1.3.2.2

  ViewVC Help
Powered by ViewVC 1.1.2