function taxonomy_access_update_5 in Taxonomy Access Control 6
Same name and namespace in other branches
- 5.2 taxonomy_access.install \taxonomy_access_update_5()
Move global default records from term_access to term_access_defaults.
File
- ./
taxonomy_access.install, line 29 - Install, update, and uninstall functions for Taxonomy Access Control.
Code
function taxonomy_access_update_5() {
$result = db_query('SELECT rid, grant_view, grant_update, grant_delete, grant_create, grant_list FROM {term_access} WHERE tid=0');
while ($row = db_fetch_array($result)) {
if ($row['rid'] > 0) {
// just in case we have a weird row with 0, 0
// Typecast each element to sanitize for use in update_sql.
foreach ($row as $key => $value) {
$row[$key] = (int) $value;
}
$row_ints = implode(", ", $row);
update_sql("INSERT INTO {term_access_defaults} (vid, rid, grant_view, grant_update, grant_delete, grant_create, grant_list) VALUES (0, {$row_ints})");
}
}
update_sql('DELETE FROM {term_access} WHERE tid=0');
return array();
}