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

Contents of /contributions/modules/simple_access/simple_access.install

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


Revision 1.15 - (show annotations) (download) (as text)
Sun Oct 11 00:50:57 2009 UTC (6 weeks, 3 days ago) by gordon
Branch: MAIN
CVS Tags: DRUPAL-7--2-0-ALPHA1, HEAD
Changes since 1.14: +1 -3 lines
File MIME type: text/x-php
* Clean up all the Admin pages and get them working with Drupal 7.

Now required Drupal 7.x-dev (2009 Oct 09) or better
1 <?php
2 // $Id: simple_access.install,v 1.14 2009/10/07 03:34:44 gordon Exp $
3
4 /**
5 * @file
6 * Installation for Simple Access
7 */
8
9 /**
10 * Implements hook_install().
11 */
12 function simple_access_install() {
13 db_update('system')
14 ->fields(array('weight' => 9))
15 ->condition('name', 'simple_access')
16 ->execute();
17
18 drupal_set_message(st('simple access has created the required tables.'));
19 }
20
21 /**
22 * Implements hook_uninstall().
23 */
24 function simple_access_uninstall() {
25 variable_del('sa_display');
26 variable_del('sa_showgroups');
27 drupal_set_message(t('simple access has been uninstalled'));
28 }
29
30 /**
31 * Implements hook_enable().
32 */
33 function simple_access_enable() {
34 drupal_set_message(t('To fully activate simple_access you also need to !rebuild_permissions.', array('!rebuild_permissions' => l(t('rebuild permissions'), 'admin/content/node-settings'))));
35 }
36
37 /**
38 * Implements hook_disable().
39 */
40 function simple_access_disable() {
41 drupal_set_message(t('To fully disable simple_access you also need to !rebuild_permissions.', array('!rebuild_permissions' => l(t('rebuild permissions'), 'admin/content/node-settings'))));
42 }
43
44 function simple_access_schema() {
45 $schema = array();
46
47 $schema['simple_access_node'] = array(
48 'description' => 'Define all permissions for each node',
49 'fields' => array(
50 'nid' => array(
51 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE,
52 'default' => 0,
53 ),
54 'gid' => array(
55 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE,
56 'default' => 0,
57 ),
58 'sa_view' => array(
59 'type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE,
60 'not null' => TRUE, 'default' => 0,
61 ),
62 'sa_update' => array(
63 'type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE,
64 'not null' => TRUE, 'default' => 0,
65 ),
66 'sa_delete' => array(
67 'type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE,
68 'not null' => TRUE, 'default' => 0,
69 ),
70 ),
71 'primary key' => array('nid', 'gid'),
72 );
73 $schema['simple_access_owner'] = array(
74 'fields' => array(
75 'nid' => array('type' => 'int', 'unsigned' => TRUE,
76 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
77 'sa_view' => array('type' => 'int', 'unsigned' => TRUE,
78 'size' => 'tiny', 'not null' => TRUE, 'default' => 0,
79 'disp-width' => '3'),
80 'sa_update' => array('type' => 'int', 'unsigned' => TRUE,
81 'size' => 'tiny', 'not null' => TRUE, 'default' => 0,
82 'disp-width' => '3'),
83 'sa_delete' => array('type' => 'int', 'unsigned' => TRUE,
84 'size' => 'tiny', 'not null' => TRUE, 'default' => 0,
85 'disp-width' => '3')),
86 'primary key' => array('nid'),
87 );
88 $schema['simple_access_groups'] = array(
89 'fields' => array(
90 'gid' => array(
91 'type' => 'serial', 'not null' => TRUE, 'disp-width' => '11'
92 ),
93 'name' => array(
94 'type' => 'varchar', 'length' => 50, 'not null' => TRUE,
95 ),
96 'weight' => array(
97 'type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0,
98 ),
99 ),
100 'primary key' => array('gid'),
101 );
102 $schema['simple_access_roles'] = array(
103 'fields' => array(
104 'gid' => array(
105 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE,
106 'default' => 0,
107 ),
108 'rid' => array(
109 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE,
110 'default' => 0,
111 ),
112 ),
113 'primary key' => array('gid', 'rid'),
114 );
115 $schema['simple_access_profiles'] = array(
116 'fields' => array(
117 'pid' => array(
118 'type' => 'serial', 'not null' => TRUE, 'disp-width' => '11'
119 ),
120 'name' => array(
121 'type' => 'varchar', 'length' => 50, 'not null' => TRUE,
122 ),
123 'weight' => array(
124 'type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0,
125 ),
126 ),
127 'primary key' => array('pid'),
128 );
129 $schema['simple_access_profiles_access'] = array(
130 'fields' => array(
131 'pid' => array(
132 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE,
133 'default' => 0,
134 ),
135 'gid' => array(
136 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE,
137 'default' => 0,
138 ),
139 'sa_view' => array(
140 'type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE,
141 'not null' => TRUE, 'default' => 0,
142 ),
143 'sa_update' => array(
144 'type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE,
145 'not null' => TRUE, 'default' => 0,
146 ),
147 'sa_delete' => array(
148 'type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE,
149 'not null' => TRUE, 'default' => 0,
150 ),
151 ),
152 'primary key' => array('pid', 'gid'),
153 );
154 $schema['simple_access_profiles_node'] = array(
155 'fields' => array(
156 'nid' => array(
157 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE,
158 'default' => 0,
159 ),
160 'pid' => array(
161 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE,
162 'default' => 0,
163 ),
164 ),
165 'primary keys' => array('nid', 'pid'),
166 );
167
168 return $schema;
169 }
170 /**
171 * Updates
172 */
173
174 function simple_access_update_5() {
175 $table = drupal_get_schema('simple_access_owner');
176 db_create_table($ret, 'simple_access_owner', $table);
177
178 $ret[] = update_sql('INSERT INTO {simple_access_owner} SELECT DISTINCT(nid), 1, 1, 1 FROM {simple_access_node}');
179 return $ret;
180 }
181
182 function simple_access_update_7() {
183 $ret = array();
184 db_change_field($ret, 'simple_access_groups', 'weight', 'weight', array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0));
185
186 return $ret;
187 }
188
189 /**
190 * Recreate the profile tables
191 */
192 function simple_access_update_6200() {
193 $ret = array();
194
195 if (!db_table_exists('simple_access_profiles')) {
196 db_create_table($ret, 'simple_access_profiles', array(
197 'fields' => array(
198 'pid' => array(
199 'type' => 'serial', 'not null' => TRUE, 'disp-width' => '11'
200 ),
201 'name' => array(
202 'type' => 'varchar', 'length' => 50, 'not null' => TRUE,
203 ),
204 'weight' => array(
205 'type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0,
206 ),
207 ),
208 'primary key' => array('pid'),
209 ));
210 db_create_table($ret, 'simple_access_profiles_access', array(
211 'fields' => array(
212 'pid' => array(
213 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE,
214 'default' => 0,
215 ),
216 'gid' => array(
217 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE,
218 'default' => 0,
219 ),
220 'sa_view' => array(
221 'type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE,
222 'not null' => TRUE, 'default' => 0,
223 ),
224 'sa_update' => array(
225 'type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE,
226 'not null' => TRUE, 'default' => 0,
227 ),
228 'sa_delete' => array(
229 'type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE,
230 'not null' => TRUE, 'default' => 0,
231 ),
232 ),
233 'primary key' => array('pid', 'gid'),
234 ));
235 db_create_table($ret, 'simple_access_profiles_node', array(
236 'fields' => array(
237 'nid' => array(
238 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE,
239 'default' => 0,
240 ),
241 'pid' => array(
242 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE,
243 'default' => 0,
244 ),
245 ),
246 'primary keys' => array('nid', 'pid'),
247 ));
248 }
249
250 return $ret;
251 }
252
253 /**
254 * Change weight of simple access to after other modules like og
255 */
256 function simple_access_update_6201() {
257 $ret = array();
258
259 $ret[] = update_sql("UPDATE {system} SET weight = 9 WHERE name = 'simple_access'");
260
261 return $ret;
262 }

  ViewVC Help
Powered by ViewVC 1.1.2