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

Contents of /contributions/modules/sections/sections.install

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


Revision 1.12 - (show annotations) (download) (as text)
Sun Jun 1 13:13:56 2008 UTC (17 months, 3 weeks ago) by hass
Branch: MAIN
CVS Tags: HEAD
Changes since 1.11: +11 -1 lines
File MIME type: text/x-php
Clear menu cache for menu changes (commit #109196).
1 <?php
2 /* $Id: sections.install,v 1.10.2.6 2008/06/01 13:12:32 hass Exp $ */
3
4 function sections_install() {
5 drupal_install_schema('sections');
6
7 // Set modul weight to negative value to be the first called.
8 db_query("UPDATE {system} SET weight = '-10' WHERE name = 'sections'");
9 }
10
11 /**
12 * Implementation of hook_uninstall().
13 */
14 function sections_uninstall() {
15 drupal_uninstall_schema('sections');
16 }
17
18 /**
19 * Implementation of hook_schema().
20 */
21 function sections_schema() {
22 $schema['sections_data'] = array(
23 'description' => t('Stores section settings.'),
24 'fields' => array(
25 'sid' => array(
26 'type' => 'serial',
27 'not null' => TRUE,
28 'description' => t('Primary Key: Unique section ID.'),
29 ),
30 'name' => array(
31 'type' => 'varchar',
32 'length' => 255,
33 'not null' => TRUE,
34 'default' => '',
35 'description' => t('The name of this section.'),
36 ),
37 'status' => array(
38 'type' => 'int',
39 'not null' => TRUE,
40 'default' => 0,
41 'size' => 'tiny',
42 'description' => t('Section enabled status. (1 = enabled, 0 = disabled)'),
43 ),
44 'path' => array(
45 'type' => 'text',
46 'not null' => FALSE,
47 'description' => t('Internal path or URL alias with or without placeholders this section will apply (relative to Drupal root.)'),
48 ),
49 'theme' => array(
50 'type' => 'varchar',
51 'length' => 255,
52 'not null' => TRUE,
53 'default' => '',
54 'description' => t('The theme under which the section settings apply.')
55 ),
56 'visibility' => array(
57 'type' => 'int',
58 'not null' => TRUE,
59 'default' => 0,
60 'size' => 'tiny',
61 'description' => t('Flag to indicate how to show sections on pages. (0 = Show on all pages except listed pages, 1 = Show only on listed pages, 2 = Use custom PHP code to determine visibility)'),
62 ),
63 'weight' => array(
64 'type' => 'int',
65 'not null' => TRUE,
66 'default' => 0,
67 'description' => t('Section weight within sections.'),
68 )
69 ),
70 'primary key' => array('sid')
71 );
72
73 $schema['sections_roles'] = array(
74 'description' => t('Sets up access permissions for sections based on user roles'),
75 'fields' => array(
76 'rid' => array(
77 'type' => 'int',
78 'unsigned' => TRUE,
79 'not null' => TRUE,
80 'description' => t("The user's role ID from {users_roles}.rid."),
81 ),
82 'sid' => array(
83 'type' => 'int',
84 'unsigned' => TRUE,
85 'not null' => TRUE,
86 'description' => t("The section's ID from {sections_data}.sid."),
87 ),
88 ),
89 'primary key' => array(
90 'rid',
91 'sid',
92 ),
93 'indexes' => array(
94 'rid' => array('rid'),
95 ),
96 );
97
98 return $schema;
99 }
100
101 function sections_update_3() {
102 $ret = array();
103 db_change_field($ret, 'sections_data', 'sid', 'sid', array('type' => 'serial', 'not null' => TRUE));
104 db_change_field($ret, 'sections_data', 'name', 'name', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
105 db_change_field($ret, 'sections_data', 'status', 'status', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'));
106 db_change_field($ret, 'sections_data', 'template', 'theme', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
107 db_change_field($ret, 'sections_data', 'visibility', 'visibility', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'));
108 db_change_field($ret, 'sections_data', 'weight', 'weight', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
109 return $ret;
110 }
111
112 function sections_update_4() {
113 // Set modul weight to negative value to be the first called.
114 $ret[] = update_sql("UPDATE {system} SET weight = '-10' WHERE name = 'sections'");
115 return $ret;
116 }
117
118 /**
119 * Add sections per roles feature.
120 */
121 function sections_update_6000() {
122
123 $schema['sections_roles'] = array(
124 'description' => t('Sets up access permissions for sections based on user roles'),
125 'fields' => array(
126 'rid' => array(
127 'type' => 'int',
128 'unsigned' => TRUE,
129 'not null' => TRUE,
130 'description' => t("The user's role ID from {users_roles}.rid."),
131 ),
132 'sid' => array(
133 'type' => 'int',
134 'unsigned' => TRUE,
135 'not null' => TRUE,
136 'description' => t("The section's ID from {sections_data}.sid."),
137 ),
138 ),
139 'primary key' => array(
140 'rid',
141 'sid',
142 ),
143 'indexes' => array(
144 'rid' => array('rid'),
145 ),
146 );
147
148 db_create_table($ret, 'sections_roles', $schema['sections_roles']);
149 return $ret;
150 }
151
152 /**
153 * Clear menu cache for menu changes (commit #109196).
154 */
155 function sections_update_6001() {
156 $ret = array();
157 cache_clear_all();
158 menu_rebuild();
159 return $ret;
160 }

  ViewVC Help
Powered by ViewVC 1.1.2