| 1 |
<?php
|
| 2 |
//$Id$
|
| 3 |
|
| 4 |
// role_weights.install
|
| 5 |
|
| 6 |
function role_weights_install() {
|
| 7 |
|
| 8 |
// Create tables.
|
| 9 |
drupal_install_schema('role_weights');
|
| 10 |
|
| 11 |
db_query("INSERT INTO {role_weights} (rid, weight) VALUES (1, 0)");
|
| 12 |
db_query("INSERT INTO {role_weights} (rid, weight) VALUES (2, -1)");
|
| 13 |
}
|
| 14 |
|
| 15 |
function role_weights_schema() {
|
| 16 |
$schema['role_weights'] = array(
|
| 17 |
'fields' => array(
|
| 18 |
'rid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
| 19 |
'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny')
|
| 20 |
),
|
| 21 |
'primary key' => array('rid'),
|
| 22 |
);
|
| 23 |
|
| 24 |
return $schema;
|
| 25 |
}
|
| 26 |
|
| 27 |
function role_weights_uninstall() {
|
| 28 |
// Remove tables.
|
| 29 |
drupal_uninstall_schema('role_weights');
|
| 30 |
}
|
| 31 |
|
| 32 |
/* updates */
|
| 33 |
function role_weights_update_1() {
|
| 34 |
// invert the weights of all role_weights set
|
| 35 |
// part of reversing our weights to coincide with Drupal standards: http://drupal.org/node/75877
|
| 36 |
$items = array();
|
| 37 |
$items[] = update_sql("UPDATE {role_weights} SET weight = 0 - weight");
|
| 38 |
return $items;
|
| 39 |
}
|
| 40 |
|