public static function BookAccess::deleteGrants in Book access 6.2
Same name and namespace in other branches
- 7.2 book_access.module \BookAccess::deleteGrants()
Deletes the book access grants from the database.
Parameters
$value: The value to look for. param $field The database field where to look the value. The currently accepted values are 'bid', 'nid', 'uid', 'rid'.
$types: An array of grants types for which the function deletes records; the currently used values are 'author', 'role', 'user'. When this parameter is not passed, the method
2 calls to BookAccess::deleteGrants()
- book_access_nodeapi in ./
book_access.module - Implements hook_nodeapi().
- book_access_user in ./
book_access.module - Implements hook_user().
File
- ./
book_access.module, line 203 - Allows to set the access control for book nodes on a per book basis. It is based on forum_access.module and tac_lite.module.
Class
- BookAccess
- @file
Code
public static function deleteGrants($value, $field = 'nid', array $types = NULL) {
if (isset($types)) {
$tables = array();
foreach ($types as $type) {
switch ($type) {
case 'author':
case 'role':
case 'user':
$tables[] = "book_access_{$type}";
break;
}
}
}
else {
switch ($field) {
case 'bid':
case 'nid':
$tables = array(
'book_access_author',
'book_access_role',
'book_access_user',
);
break;
case 'uid':
$tables = array(
'book_access_author',
'book_access_user',
);
break;
case 'rid':
$tables = array(
'book_access_role',
);
break;
default:
$tables = array();
}
}
foreach ($tables as $table) {
db_query("DELETE FROM {" . $table . "} WHERE {$field} = %d", $value);
}
}