| 1 |
<?php
|
| 2 |
// $Id: autoassignrole.install,v 1.7.2.14 2009/08/25 13:04:44 cyberswat Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
*
|
| 7 |
* The autoassignrole.install file
|
| 8 |
*
|
| 9 |
* Installs the {autoassignrole} table and inserts default data as well as
|
| 10 |
* provides uninstall functionality.
|
| 11 |
*/
|
| 12 |
|
| 13 |
/**
|
| 14 |
* Implementation of hook_install().
|
| 15 |
*/
|
| 16 |
function autoassignrole_install() {
|
| 17 |
drupal_install_schema('autoassignrole');
|
| 18 |
$sql = "INSERT into {autoassignrole} (arid,value) VALUES ('%s', '%s')";
|
| 19 |
db_query($sql, 'auto_roles', serialize(array()));
|
| 20 |
db_query($sql, 'auto_active', 0);
|
| 21 |
db_query($sql, 'user_active', 0);
|
| 22 |
db_query($sql, 'user_roles', serialize(array()));
|
| 23 |
db_query($sql, 'user_required', 0);
|
| 24 |
db_query($sql, 'user_multiple', 0);
|
| 25 |
db_query($sql, 'user_description', '');
|
| 26 |
db_query($sql, 'user_title', t("Role"));
|
| 27 |
db_query($sql, 'user_fieldset_title', t("User Roles"));
|
| 28 |
db_query($sql, 'user_sort', 'SORT_ASC');
|
| 29 |
db_query($sql, 'user_selection', 2);
|
| 30 |
db_query($sql, 'page_active', 0);
|
| 31 |
db_query($sql, 'auto_admin_active', 0);
|
| 32 |
db_query($sql, 'node_user_register', '');
|
| 33 |
}
|
| 34 |
|
| 35 |
/**
|
| 36 |
* Implementation of hook_uninstall().
|
| 37 |
*/
|
| 38 |
function autoassignrole_uninstall() {
|
| 39 |
drupal_uninstall_schema('autoassignrole');
|
| 40 |
}
|
| 41 |
|
| 42 |
/**
|
| 43 |
* Implementation of hook_schema().
|
| 44 |
*/
|
| 45 |
function autoassignrole_schema() {
|
| 46 |
$schema['autoassignrole'] = array(
|
| 47 |
'description' => t('Stores autoassignrole variables.'),
|
| 48 |
'fields' => array(
|
| 49 |
'arid' => array(
|
| 50 |
'type' => 'varchar',
|
| 51 |
'length' => 38,
|
| 52 |
'not null' => TRUE,
|
| 53 |
'default' => '',
|
| 54 |
'description' => t('The id for this setting.'),
|
| 55 |
),
|
| 56 |
'value' => array(
|
| 57 |
'type' => 'text',
|
| 58 |
'not null' => FALSE,
|
| 59 |
'description' => t('The value for this setting.'),
|
| 60 |
),
|
| 61 |
),
|
| 62 |
'primary key' => array('arid'),
|
| 63 |
);
|
| 64 |
$schema['autoassignrole_page'] = array(
|
| 65 |
'description' => t('Stores autoassignrole page information.'),
|
| 66 |
'fields' => array(
|
| 67 |
'rid' => array(
|
| 68 |
'type' => 'int',
|
| 69 |
'not null' => TRUE,
|
| 70 |
'description' => t('The rid for this page.'),
|
| 71 |
),
|
| 72 |
'display' => array(
|
| 73 |
'type' => 'text',
|
| 74 |
'not null' => TRUE,
|
| 75 |
'description' => t('How to display the navigation to this page.'),
|
| 76 |
),
|
| 77 |
'path' => array(
|
| 78 |
'type' => 'varchar',
|
| 79 |
'length' => 255,
|
| 80 |
'not null' => TRUE,
|
| 81 |
'description' => t('The path for this page.'),
|
| 82 |
),
|
| 83 |
'menu' => array(
|
| 84 |
'type' => 'varchar',
|
| 85 |
'length' => 255,
|
| 86 |
'not null' => TRUE,
|
| 87 |
'description' => t('The default parent menu for this menu item.'),
|
| 88 |
),
|
| 89 |
'title' => array(
|
| 90 |
'type' => 'text',
|
| 91 |
'not null' => TRUE,
|
| 92 |
'description' => t('The title for this page.'),
|
| 93 |
),
|
| 94 |
'description' => array(
|
| 95 |
'type' => 'text',
|
| 96 |
'size' => 'big',
|
| 97 |
'not null' => FALSE,
|
| 98 |
'description' => t('The description for this page.'),
|
| 99 |
),
|
| 100 |
'format' => array(
|
| 101 |
'type' => 'int',
|
| 102 |
'size' => 'tiny',
|
| 103 |
'not null' => FALSE,
|
| 104 |
'description' => t('The filter format to use on the description.'),
|
| 105 |
),
|
| 106 |
'weight' => array(
|
| 107 |
'type' => 'int',
|
| 108 |
'size' => 'tiny',
|
| 109 |
'not null' => FALSE,
|
| 110 |
'default' => 0,
|
| 111 |
'description' => t('The weight of this item.'),
|
| 112 |
),
|
| 113 |
'registration' => array(
|
| 114 |
'type' => 'int',
|
| 115 |
'size' => 'tiny',
|
| 116 |
'not null' => FALSE,
|
| 117 |
'default' => 0,
|
| 118 |
'description' => t('Should this item replace the default user registration page.'),
|
| 119 |
),
|
| 120 |
),
|
| 121 |
'primary key' => array('rid'),
|
| 122 |
);
|
| 123 |
return $schema;
|
| 124 |
}
|
| 125 |
function autoassignrole_update_6000() {
|
| 126 |
$items = array();
|
| 127 |
$sql = "SELECT name FROM {variable} WHERE name LIKE 'AUTOASSIGNROLE_%%'";
|
| 128 |
$vars = db_query($sql);
|
| 129 |
while ($var = db_fetch_object($vars)) {
|
| 130 |
variable_del($var->name);
|
| 131 |
}
|
| 132 |
$items[] = array("success" => 1, "query" => "Cleaned up old variables and installed new table");
|
| 133 |
|
| 134 |
autoassignrole_install();
|
| 135 |
return $items;
|
| 136 |
}
|
| 137 |
|
| 138 |
function autoassignrole_update_6001() {
|
| 139 |
$ret = array();
|
| 140 |
|
| 141 |
// Rename the old contrib actions table if it exists so the contrib version
|
| 142 |
// of the module can do something with the old data.
|
| 143 |
if (!db_table_exists('autoassignrole_page')) {
|
| 144 |
$schema['autoassignrole_page'] = array(
|
| 145 |
'description' => t('Stores autoassignrole page information.'),
|
| 146 |
'fields' => array(
|
| 147 |
'rid' => array(
|
| 148 |
'type' => 'int',
|
| 149 |
'not null' => TRUE,
|
| 150 |
'description' => t('The rid for this page.'),
|
| 151 |
),
|
| 152 |
'display' => array(
|
| 153 |
'type' => 'text',
|
| 154 |
'not null' => TRUE,
|
| 155 |
'description' => t('How to display the navigation to this page.'),
|
| 156 |
),
|
| 157 |
'path' => array(
|
| 158 |
'type' => 'varchar',
|
| 159 |
'length' => 255,
|
| 160 |
'not null' => TRUE,
|
| 161 |
'description' => t('The path for this page.'),
|
| 162 |
),
|
| 163 |
'menu' => array(
|
| 164 |
'type' => 'varchar',
|
| 165 |
'length' => 255,
|
| 166 |
'not null' => TRUE,
|
| 167 |
'description' => t('The default parent menu for this menu item.'),
|
| 168 |
),
|
| 169 |
'title' => array(
|
| 170 |
'type' => 'text',
|
| 171 |
'not null' => TRUE,
|
| 172 |
'description' => t('The title for this page.'),
|
| 173 |
),
|
| 174 |
'description' => array(
|
| 175 |
'type' => 'text',
|
| 176 |
'size' => 'big',
|
| 177 |
'not null' => FALSE,
|
| 178 |
'description' => t('The description for this page.'),
|
| 179 |
),
|
| 180 |
'format' => array(
|
| 181 |
'type' => 'int',
|
| 182 |
'size' => 'tiny',
|
| 183 |
'not null' => FALSE,
|
| 184 |
'description' => t('The filter format to use on the description.'),
|
| 185 |
),
|
| 186 |
'weight' => array(
|
| 187 |
'type' => 'int',
|
| 188 |
'size' => 'tiny',
|
| 189 |
'not null' => FALSE,
|
| 190 |
'default' => 0,
|
| 191 |
'description' => t('The weight of this item.'),
|
| 192 |
),
|
| 193 |
'registration' => array(
|
| 194 |
'type' => 'int',
|
| 195 |
'size' => 'tiny',
|
| 196 |
'not null' => FALSE,
|
| 197 |
'default' => 0,
|
| 198 |
'description' => t('Should this item replace the default user registration page.'),
|
| 199 |
),
|
| 200 |
),
|
| 201 |
'primary key' => array('rid'),
|
| 202 |
);
|
| 203 |
|
| 204 |
db_create_table($ret, 'autoassignrole_page', $schema['autoassignrole_page']);
|
| 205 |
}
|
| 206 |
|
| 207 |
return $ret;
|
| 208 |
}
|
| 209 |
|
| 210 |
function autoassignrole_update_6002() {
|
| 211 |
$ret = array();
|
| 212 |
if (!db_column_exists('autoassignrole_page', 'menu')) {
|
| 213 |
$ret[] = update_sql('ALTER TABLE {autoassignrole_page} ADD menu VARCHAR(255)');
|
| 214 |
}
|
| 215 |
return $ret;
|
| 216 |
}
|
| 217 |
|
| 218 |
function autoassignrole_update_6003() {
|
| 219 |
$ret = array();
|
| 220 |
if (!db_column_exists('autoassignrole_page', 'registration')) {
|
| 221 |
$ret[] = update_sql('ALTER TABLE {autoassignrole_page} ADD registration TINYINT default 0');
|
| 222 |
}
|
| 223 |
return $ret;
|
| 224 |
}
|
| 225 |
|
| 226 |
function autoassignrole_update_6004() {
|
| 227 |
$value = db_fetch_object(db_query("SELECT arid FROM {autoassignrole} WHERE arid = '%s'", 'auto_admin_active'));
|
| 228 |
if (!$value->arid) {
|
| 229 |
$sql = "";
|
| 230 |
$ret[] = update_sql("INSERT into {autoassignrole} (arid,value) VALUES ('auto_admin_active', '0')");
|
| 231 |
}
|
| 232 |
return $ret;
|
| 233 |
}
|
| 234 |
function autoassignrole_update_6005() {
|
| 235 |
$value = db_fetch_object(db_query("SELECT arid FROM {autoassignrole} WHERE arid = '%s'", 'node_user_register'));
|
| 236 |
if (!$value->arid) {
|
| 237 |
$sql = "";
|
| 238 |
$ret[] = update_sql("INSERT into {autoassignrole} (arid,value) VALUES ('node_user_register', '')");
|
| 239 |
}
|
| 240 |
return $ret;
|
| 241 |
}
|