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

Contents of /contributions/modules/acl/acl.install

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


Revision 1.11 - (show annotations) (download) (as text)
Sun Oct 18 23:37:41 2009 UTC (5 weeks, 5 days ago) by salvis
Branch: MAIN
CVS Tags: HEAD
Changes since 1.10: +8 -4 lines
File MIME type: text/x-php
Clean up some minor coder issues (no functional changes).
1 <?php
2 // $Id: acl.install,v 1.10 2009/01/03 19:01:13 salvis Exp $
3
4 /**
5 * @file
6 * Install, update and uninstall functions for the acl module.
7 */
8
9 /**
10 * Implementation of hook_install().
11 */
12 function acl_install() {
13 drupal_install_schema('acl');
14 }
15
16 /**
17 * Implementation of hook_schema().
18 */
19 function acl_schema() {
20 $schema['acl'] = array(
21 'description' => t('The base Access Control Lists table.'),
22 'fields' => array(
23 'acl_id' => array(
24 'description' => t('Primary key: unique ACL ID.'),
25 'type' => 'serial',
26 'not null' => TRUE),
27 'module' => array(
28 'description' => t('The name of the module that created this ACL entry.'),
29 'type' => 'varchar',
30 'length' => 255,
31 'not null' => TRUE),
32 'name' => array(
33 'description' => t('A name (or other identifying information) for this ACL entry, given by the module that created it.'),
34 'type' => 'varchar',
35 'length' => 255)),
36 'primary key' => array('acl_id'),
37 );
38 $schema['acl_user'] = array(
39 'description' => t('Identifies {users} to which the referenced {acl} entry applies.'),
40 'fields' => array(
41 'acl_id' => array(
42 'description' => t('The {acl}.acl_id of the entry.'),
43 'type' => 'int',
44 'not null' => TRUE,
45 'default' => 0),
46 'uid' => array(
47 'description' => t('The {user}.uid to which this {acl} entry applies.'),
48 'type' => 'int',
49 'not null' => TRUE,
50 'default' => 0)),
51 'primary key' => array('acl_id', 'uid'),
52 'indexes' => array(
53 'uid' => array('uid')),
54 );
55 $schema['acl_node'] = array(
56 'description' => t('Identifies {node}s to which the referenced {acl} entry applies and defines the permissions granted.'),
57 'fields' => array(
58 'acl_id' => array(
59 'description' => t('The {acl}.acl_id of the entry.'),
60 'type' => 'int',
61 'not null' => TRUE,
62 'default' => 0),
63 'nid' => array(
64 'description' => t('The {node}.nid to grant permissions for.'),
65 'type' => 'int',
66 'not null' => TRUE,
67 'default' => 0),
68 'grant_view' => array(
69 'description' => t('Whether to grant "view" permission.'),
70 'type' => 'int',
71 'size' => 'tiny',
72 'unsigned' => TRUE,
73 'not null' => TRUE,
74 'default' => 0),
75 'grant_update' => array(
76 'description' => t('Whether to grant "update" permission.'),
77 'type' => 'int',
78 'size' => 'tiny',
79 'unsigned' => TRUE,
80 'not null' => TRUE,
81 'default' => 0),
82 'grant_delete' => array(
83 'description' => t('Whether to grant "delete" permission.'),
84 'type' => 'int',
85 'size' => 'tiny',
86 'unsigned' => TRUE,
87 'not null' => TRUE,
88 'default' => 0),
89 'priority' => array(
90 'description' => t('The priority of this grant record (for hook_node_access_records()).'),
91 'type' => 'int',
92 'size' => 'small',
93 'not null' => TRUE,
94 'default' => 0)),
95 'primary key' => array('acl_id', 'nid'),
96 'indexes' => array(
97 'nid' => array('nid')),
98 );
99 return $schema;
100 }
101
102
103 /*
104 * Implementation of hook_uninstall().
105 */
106 function acl_uninstall() {
107 drupal_uninstall_schema('acl');
108 }
109
110 /**
111 * Fixes primary keys
112 */
113 function acl_update_2() {
114 $ret = array();
115 // drop the previously created indexes (except for acl_user.uid)
116 db_drop_index($ret, 'acl', 'acl_id');
117 db_drop_index($ret, 'acl_user', 'acl_id');
118 db_drop_index($ret, 'acl_node', 'acl_id');
119 db_drop_index($ret, 'acl_node', 'nid');
120 // create new indexes (as primary keys this time)
121 db_add_primary_key($ret, 'acl', array('acl_id'));
122 db_add_primary_key($ret, 'acl_user', array('acl_id', 'uid'));
123 db_add_primary_key($ret, 'acl_node', array('acl_id', 'nid'));
124 return $ret;
125 }
126
127 /**
128 * Put back acl_node(nid) index for deleting nodes and clean up {acl_node}.
129 */
130 function acl_update_4() {
131 $ret = array();
132 db_add_index($ret, 'acl_node', 'nid', array('nid'));
133 $ret[] = update_sql("DELETE FROM {acl_node} WHERE nid NOT IN (SELECT nid FROM {node})");
134 return $ret;
135 }
136
137 /**
138 * Clean up {acl_user}.
139 */
140 function acl_update_5() {
141 $ret = array();
142 $ret[] = update_sql("DELETE FROM {acl_user} WHERE uid NOT IN (SELECT uid FROM {users})");
143 return $ret;
144 }
145
146 /**
147 * Add 'priority' column.
148 */
149 function acl_update_6() {
150 $ret = array();
151 db_add_field($ret, 'acl_node', 'priority', array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0));
152 return $ret;
153 }
154
155 /**
156 * Change acl_id to auto-increment.
157 */
158 function acl_update_6000() {
159 $ret = array();
160 db_change_field($ret, 'acl', 'acl_id', 'acl_id', array('type' => 'serial', 'not null' => TRUE));
161 // (Dropping and recreating the primary key on an auto_increment column would cause a MySQL failure.)
162 db_change_field($ret, 'acl', 'module', 'module', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE));
163 db_change_field($ret, 'acl', 'name', 'name', array('type' => 'varchar', 'length' => 255));
164 return $ret;
165 }

  ViewVC Help
Powered by ViewVC 1.1.2