addanother.install in Add Another 6
Same filename and directory in other branches
Uninstall and update routines for Add another module.
File
addanother.installView source
<?php
/**
* @file
* Uninstall and update routines for Add another module.
*/
/**
* Implementation of hook_uninstall().
*/
function addanother_uninstall() {
variable_del('addanother_nodetypes');
}
/**
* Port over to the new variable storage system.
*/
function addanother_update_1() {
$types = node_get_types();
$addanother_nodetypes = array();
foreach ($types as $type) {
$typeid = $type->type;
$keep = variable_get('addanother_' . $typeid, 0);
if ($keep) {
$addanother_nodetypes[$typeid] = $typeid;
}
variable_del('addanother_' . $typeid);
}
variable_set('addanother_nodetypes', $addanother_nodetypes);
return array();
}
/**
* Update permission name to 'use add another' instead of 'enable add another' to improve usability/consistency.
*/
function addanother_update_2() {
$ret = array();
$result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid");
while ($role = db_fetch_object($result)) {
$renamed_permission = preg_replace('/enable add another/', 'use add another', $role->perm);
if ($renamed_permission != $role->perm) {
$ret[] = update_sql("UPDATE {permission} SET perm = '{$renamed_permission}' WHERE rid = {$role->rid}");
}
}
return $ret;
}
Functions
Name | Description |
---|---|
addanother_uninstall | Implementation of hook_uninstall(). |
addanother_update_1 | Port over to the new variable storage system. |
addanother_update_2 | Update permission name to 'use add another' instead of 'enable add another' to improve usability/consistency. |