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

Contents of /contributions/modules/pageroute/pageroute.install

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


Revision 1.10 - (show annotations) (download) (as text)
Sun Apr 29 18:32:48 2007 UTC (2 years, 6 months ago) by fago
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
Changes since 1.9: +9 -1 lines
File MIME type: text/x-php
added the possibility to make a page that doesn't appear as tab if tab like submit buttons are enabled,
fixed a possible wrong handling of the destination paramter with the PAGEROUTE_NONE redirect target
1 <?php
2 // $Id: pageroute.install,v 1.9 2007/03/12 20:23:49 fago Exp $
3
4 function pageroute_install() {
5
6 switch ($GLOBALS['db_type']) {
7 case 'mysqli':
8 case 'mysql':
9 db_query("CREATE TABLE if not exists {pageroute_routes} (
10 prid int(10) unsigned NOT NULL,
11 path varchar(127) NOT NULL,
12 options mediumtext NOT NULL,
13 PRIMARY KEY(prid)
14 ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
15
16 db_query("CREATE TABLE if not exists {pageroute_pages} (
17 prid int(10) unsigned NOT NULL,
18 name varchar(63) NOT NULL,
19 type varchar(32) NOT NULL,
20 title varchar(255) NOT NULL,
21 options mediumtext NOT NULL,
22 weight tinyint(4) NOT NULL,
23 PRIMARY KEY(prid, name)
24 ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
25
26 break;
27 case 'pgsql':
28 db_query("CREATE TABLE {pageroute_routes} (
29 prid integer NOT NULL,
30 path varchar(127) NOT NULL,
31 options text NOT NULL,
32 PRIMARY KEY(prid)
33 )");
34
35 db_query("CREATE TABLE {pageroute_pages} (
36 prid integer NOT NULL,
37 name varchar(63) NOT NULL,
38 type varchar(32) NOT NULL,
39 title varchar(255) NOT NULL,
40 options text NOT NULL,
41 weight smallint NOT NULL,
42 PRIMARY KEY(prid, name)
43 )");
44
45 default:
46 break;
47 }
48 }
49
50 function pageroute_uninstall() {
51 db_query("DROP TABLE {pageroute_pages}");
52 db_query("DROP TABLE {pageroute_routes}");
53 }
54
55 function pageroute_update_1() {
56 $ret = array();
57 db_add_column($ret, 'pageroute_routes', 'options', 'varchar(255) NOT NULL');
58 return $ret;
59 }
60
61 function pageroute_update_2() {
62 $ret = array();
63 switch ($GLOBALS['db_type']) {
64 case 'mysqli':
65 case 'mysql':
66 $ret[] = update_sql("ALTER TABLE {pageroute_pages} CHANGE `options` `options` mediumtext");
67 break;
68 case 'pgsql':
69 db_change_column($ret, 'pageroute_pages', 'options', 'options', 'text', array("not null" => TRUE));
70 break;
71 }
72 return $ret;
73 }
74
75 function pageroute_update_3() {
76 $lonely_node_types = pageroute_ui_get_lonely_node_types();
77 if (!$lonely_node_types) {
78 return array();
79 }
80
81 $result = db_query("SELECT * FROM {pageroute_pages}");
82
83 while ($page = db_fetch_object($result)) {
84 $page->options = unserialize($page->options);
85 if (in_array($page->options['content-type'], array_keys($lonely_node_types))) {
86 db_query("UPDATE {pageroute_pages} SET type = %d WHERE prid = %d AND name = '%s'",
87 NODE_MANAGE_LONELY, $page->prid, $page->name);
88 }
89 }
90 return array();
91 }
92
93 function pageroute_update_4() {
94 $ret = array();
95 $ret[] = update_sql("ALTER TABLE {pageroute_pages} MODIFY type varchar(32) NOT NULL");
96
97 $result = db_query("SELECT * FROM {pageroute_pages}");
98 while ($page = db_fetch_object($result)) {
99 switch ($page->type) {
100 case 1:
101 $new_type = 'add';
102 break;
103 case 2:
104 $new_type = 'view';
105 break;
106 case 3:
107 $new_type = 'manage';
108 break;
109 case 4:
110 $new_type = 'manage_lonely';
111 break;
112 default:
113 break 2;
114 }
115 $ret[] = update_sql("UPDATE {pageroute_pages} SET type = '$new_type' ".
116 "WHERE prid = ". intval($page->prid) .
117 " AND name = '". db_escape_string($page->name) ."'");
118 }
119 return $ret;
120 }
121
122 function pageroute_update_5() {
123 $ret = array();
124 switch ($GLOBALS['db_type']) {
125 case 'mysqli':
126 case 'mysql':
127 $ret[] = update_sql("ALTER TABLE {pageroute_routes} CHANGE `options` `options` mediumtext");
128 break;
129 case 'pgsql':
130 db_change_column($ret, 'pageroute_routes', 'options', 'options', 'text', array("not null" => TRUE));
131 break;
132 }
133 return $ret;
134 }
135
136 function pageroute_update_6() {
137 $ret = array();
138 $ret[] = update_sql("UPDATE {pageroute_pages} SET type = 'user_edit' WHERE type = 'user edit'");
139 return $ret;
140 }
141
142 /*
143 * Clears the menu cache so that the route objects and their page index is rebuilt
144 */
145 function pageroute_update_7() {
146 cache_clear_all('*', 'cache_menu', TRUE);
147 return array();
148 }

  ViewVC Help
Powered by ViewVC 1.1.2