| 1 |
<?php
|
| 2 |
// $Id: addanother.install,v 1.1 2009/01/15 23:22:22 robinmonks Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Uninstall and update routines for AddAnother module.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_uninstall().
|
| 11 |
*/
|
| 12 |
function addanother_uninstall() {
|
| 13 |
variable_del('addanother_nodetypes');
|
| 14 |
}
|
| 15 |
|
| 16 |
/**
|
| 17 |
* Port over to the new variable storage system.
|
| 18 |
*/
|
| 19 |
function addanother_update_1() {
|
| 20 |
$types = node_get_types();
|
| 21 |
$addanother_nodetypes = array();
|
| 22 |
foreach ($types as $type) {
|
| 23 |
$typeid = $type->type;
|
| 24 |
$keep = variable_get('addanother_'. $typeid, 0);
|
| 25 |
if ($keep) {
|
| 26 |
$addanother_nodetypes[$typeid] = $typeid;
|
| 27 |
}
|
| 28 |
variable_del('addanother_'. $typeid);
|
| 29 |
}
|
| 30 |
variable_set('addanother_nodetypes', $addanother_nodetypes);
|
| 31 |
return array();
|
| 32 |
}
|
| 33 |
|
| 34 |
/**
|
| 35 |
* Update permission name to 'use add another' instead of 'enable add another' to improve usability/consistency.
|
| 36 |
*/
|
| 37 |
function addanother_update_2() {
|
| 38 |
$ret = array();
|
| 39 |
$result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid");
|
| 40 |
while ($role = db_fetch_object($result)) {
|
| 41 |
$renamed_permission = preg_replace('/enable add another/', 'use add another', $role->perm);
|
| 42 |
if ($renamed_permission != $role->perm) {
|
| 43 |
$ret[] = update_sql("UPDATE {permission} SET perm = '$renamed_permission' WHERE rid = $role->rid");
|
| 44 |
}
|
| 45 |
}
|
| 46 |
return $ret;
|
| 47 |
}
|