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

Contents of /contributions/modules/sidecontent/sidecontent.install

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


Revision 1.5 - (show annotations) (download) (as text)
Thu May 21 21:40:45 2009 UTC (6 months, 1 week ago) by MegaGrunt
Branch: MAIN
CVS Tags: DRUPAL-6--2-0-RC1, DRUPAL-6--2-0-BETA2, HEAD
Changes since 1.4: +10 -2 lines
File MIME type: text/x-php
- Fixed bug in database schema #465998
1 <?php
2 // $Id: sidecontent.install,v 1.4 2009/04/05 01:03:13 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 // Create tables.
13 drupal_install_schema('sidecontent');
14 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 ),
52 ),
53 'indexes' => array(
54 'nid' => array('nid')
55 ),
56 );
57
58 return $schema;
59 }
60
61 /*
62 * update module for UTF.
63 */
64 function sidecontent_update_1() {
65 $ret = array();
66 _system_update_utf8(array('sidecontent'));
67 return $ret;
68 }
69
70 /*
71 * add sidetitle colums
72 * in case anyone is updating from patch version
73 */
74 function sidecontent_update_2() {
75 $ret = array();
76
77 switch ($GLOBALS['db_type']) {
78 case 'mysql':
79 case 'mysqli':
80 $ret[] = update_sql("ALTER TABLE {sidecontent} ADD COLUMN sidetitle varchar(128) NOT NULL default '' AFTER format");
81 $ret[] = update_sql("ALTER TABLE {sidecontent} ADD PRIMARY KEY (`nid`)");
82 break;
83 case 'pgsql':
84 $ret[] = update_sql("ALTER TABLE {sidecontent} ADD COLUMN sidetitle varchar(128) NOT NULL default ''");
85 $ret[] = update_sql("ALTER TABLE {sidecontent} ADD PRIMARY KEY (`nid`)");
86 break;
87 }
88 return $ret;
89 }
90
91 /**
92 * Update base paths for relative URLs in sidecontent .
93 */
94 function sidecontent_update_3() {
95
96 require_once('database/updates.inc');
97 $ret = array();
98 drupal_set_message(t('Updating links in sidecontent blocks.'));
99
100 $result = db_query("SELECT * FROM {sidecontent}");
101
102 while ($sidecontent = db_fetch_object($result)) {
103
104 $sidecontent->sidecontent = _update_178_url_fix($sidecontent->sidecontent);
105
106 if ($sidecontent->sidecontent !== FALSE) {
107 db_query("UPDATE {sidecontent} SET sidecontent = '%s' WHERE nid = %d", $sidecontent->sidecontent, $sidecontent->nid);
108 }
109 }
110
111 return $ret;
112 }
113
114 function sidecontent_update_6001() {
115 $ret = array();
116 // had mistakenly set a default on a text field
117 db_field_set_no_default($ret, 'sidecontent', 'sidecontent');
118 // Rebuild schema cache
119 drupal_get_schema('sidecontent', TRUE);
120 return $ret;
121 }
122
123 /**
124 * Implementation of hook_uninstall().
125 */
126 function sidecontent_uninstall() {
127 // Remove tables.
128 drupal_uninstall_schema('sidecontent');
129
130 variable_del('sidecontent_title');
131 variable_del('sidecontent_print');
132 variable_del('sidecontent_show_input_format');
133 variable_del('sidecontent_show_in_group');
134 variable_del('sidecontent_group_description');
135 }

  ViewVC Help
Powered by ViewVC 1.1.2