| 1 |
<?php
|
| 2 |
// $Id: og_user_roles.install,v 1.9 2009/06/16 21:44:47 sun Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_schema().
|
| 6 |
*/
|
| 7 |
function og_user_roles_schema() {
|
| 8 |
$schema['og_users_roles'] = array(
|
| 9 |
'fields' => array(
|
| 10 |
'gid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
| 11 |
'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
| 12 |
'rid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
| 13 |
),
|
| 14 |
'primary key' => array('gid', 'uid', 'rid'),
|
| 15 |
);
|
| 16 |
$schema['og_users_roles_group'] = array(
|
| 17 |
'fields' => array(
|
| 18 |
'gid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
| 19 |
'default_role' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
| 20 |
),
|
| 21 |
'primary key' => array('gid'),
|
| 22 |
);
|
| 23 |
return $schema;
|
| 24 |
}
|
| 25 |
|
| 26 |
/**
|
| 27 |
* Implementation of hook_install().
|
| 28 |
*/
|
| 29 |
function og_user_roles_install() {
|
| 30 |
drupal_install_schema('og_user_roles');
|
| 31 |
// Decrease module weight.
|
| 32 |
// @see og_user_roles_init()
|
| 33 |
db_query("UPDATE {system} SET weight = -1 WHERE type = 'module' AND name = 'og_user_roles'");
|
| 34 |
// Ensure that conflicting og_roles module is disabled.
|
| 35 |
module_disable(array('og_roles'));
|
| 36 |
}
|
| 37 |
|
| 38 |
/**
|
| 39 |
* Implementation of hook_uninstall().
|
| 40 |
*/
|
| 41 |
function og_user_roles_uninstall() {
|
| 42 |
drupal_uninstall_schema('og_user_roles');
|
| 43 |
|
| 44 |
// Delete variables.
|
| 45 |
db_query("DELETE FROM {variable} WHERE name LIKE 'og_user_roles_%%'");
|
| 46 |
}
|
| 47 |
|
| 48 |
/**
|
| 49 |
* Remove {og_user_test} and {multinode_access} tables.
|
| 50 |
*/
|
| 51 |
function og_user_roles_update_6200() {
|
| 52 |
$ret = array();
|
| 53 |
db_drop_table($ret, 'og_user_test');
|
| 54 |
db_drop_table($ret, 'multinode_access');
|
| 55 |
return $ret;
|
| 56 |
}
|
| 57 |
|
| 58 |
/**
|
| 59 |
* Decrease module weight.
|
| 60 |
*
|
| 61 |
* @see og_user_roles_init()
|
| 62 |
*/
|
| 63 |
function og_user_roles_update_6201() {
|
| 64 |
$ret = array();
|
| 65 |
$ret[] = update_sql("UPDATE {system} SET weight = -1 WHERE type = 'module' AND name = 'og_user_roles'");
|
| 66 |
return $ret;
|
| 67 |
}
|
| 68 |
|
| 69 |
/**
|
| 70 |
* Remove obsolete {og_user_test}.ogr_id column.
|
| 71 |
*/
|
| 72 |
function og_user_roles_update_6202() {
|
| 73 |
$ret = array();
|
| 74 |
db_drop_field($ret, 'og_users_roles', 'ogr_id');
|
| 75 |
variable_del('og_user_roles_counter');
|
| 76 |
return $ret;
|
| 77 |
}
|
| 78 |
|
| 79 |
/**
|
| 80 |
* Clean up and remove obsolete variables.
|
| 81 |
*/
|
| 82 |
function og_user_roles_update_6203() {
|
| 83 |
$ret = array();
|
| 84 |
|
| 85 |
// Convert remaining variables.
|
| 86 |
variable_del('og_user_roles_assign_basicgrouprole');
|
| 87 |
if ($default_role = variable_get('og_user_roles_basicgrouprole_value', NULL)) {
|
| 88 |
variable_set('og_user_roles_default_role', $default_role);
|
| 89 |
}
|
| 90 |
variable_del('og_user_roles_basicgrouprole_value');
|
| 91 |
|
| 92 |
variable_del('og_user_roles_assign_admingrouprole');
|
| 93 |
if ($admin_role = variable_get('og_user_roles_admingrouprole_value', NULL)) {
|
| 94 |
variable_set('og_user_roles_default_admin_role', $admin_role);
|
| 95 |
}
|
| 96 |
variable_del('og_user_roles_admingrouprole_value');
|
| 97 |
|
| 98 |
// Remove other variables of removed features.
|
| 99 |
db_query("DELETE FROM {variable} WHERE name LIKE 'oglogo_%%'");
|
| 100 |
db_query("DELETE FROM {variable} WHERE name LIKE 'og_user_roles_assign_nopublic_%%'");
|
| 101 |
db_query("DELETE FROM {variable} WHERE name LIKE 'og_user_roles_assign_regcode_%%'");
|
| 102 |
db_query("DELETE FROM {variable} WHERE name LIKE 'og_user_roles_assign_regcoderole_%%'");
|
| 103 |
db_query("DELETE FROM {variable} WHERE name LIKE 'og_user_roles_delete_regcode_%%'");
|
| 104 |
db_query("DELETE FROM {variable} WHERE name LIKE 'og_user_roles_links_content_%%'");
|
| 105 |
db_query("DELETE FROM {variable} WHERE name LIKE 'og_user_roles_links_remove_%%'");
|
| 106 |
db_query("DELETE FROM {variable} WHERE name LIKE 'og_user_roles_logo_%%'");
|
| 107 |
db_query("DELETE FROM {variable} WHERE name LIKE 'og_user_roles_regcode_value_%%'");
|
| 108 |
db_query("DELETE FROM {variable} WHERE name LIKE 'og_user_roles_regcoderole_value_%%'");
|
| 109 |
|
| 110 |
$ret[] = array('success' => TRUE, 'query' => 'Obsolete variables have been removed.');
|
| 111 |
return $ret;
|
| 112 |
}
|
| 113 |
|
| 114 |
/**
|
| 115 |
* Create {og_users_roles_group} table.
|
| 116 |
*/
|
| 117 |
function og_user_roles_update_6204() {
|
| 118 |
$ret = array();
|
| 119 |
if (db_table_exists('og_users_roles_group')) {
|
| 120 |
return $ret;
|
| 121 |
}
|
| 122 |
db_create_table($ret, 'og_users_roles_group', array(
|
| 123 |
'fields' => array(
|
| 124 |
'gid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
| 125 |
'default_role' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
| 126 |
),
|
| 127 |
'primary key' => array('gid'),
|
| 128 |
));
|
| 129 |
return $ret;
|
| 130 |
}
|
| 131 |
|