function taxonomy_access_get_default_grants in Taxonomy Access Control 5
Same name and namespace in other branches
- 5.2 taxonomy_access.module \taxonomy_access_get_default_grants()
- 6 taxonomy_access.module \taxonomy_access_get_default_grants()
Gets default permissions for a given role
Parameters
$role: The role to retrieve the permissions for. Can be the name or the role id or blank for all term permissions.
Return value
A two dimensional hash of the form $grants[vid][grant] where vid is the vocab id and grant is the permission (i.e. 'view','delete',ect.) this entry in the hash is true if permission is granted, false otherwise
1 call to taxonomy_access_get_default_grants()
- _taxonomy_access_permissions_form in ./
taxonomy_access_admin.inc - Generating the category permissions form for choosen user role.
File
- ./
taxonomy_access.module, line 370 - Allows administrators to specify how each category (in the taxonomy) can be used by various roles.
Code
function taxonomy_access_get_default_grants($role) {
if (!isset($role)) {
return false;
}
if (isset($role) && !is_numeric($role)) {
$role = db_result(db_query("SELECT rid FROM {role} WHERE name='{$role}'"));
}
$result = db_query("SELECT * FROM {term_access_defaults} WHERE rid='{$role}'");
$grants = array();
while ($grant = db_fetch_array($result)) {
$vid = $grant['vid'];
foreach ($grant as $key => $grant_val) {
if (strpos($key, 'grant_') !== FALSE) {
$grant_name = '';
$grant_name = str_replace('grant_', '', $key);
if (!isset($grants[$vid][$grant_name]) || !$grants[$vid][$grant_name]) {
// If there's conflicting DB rules, take the most lenient
$grants[$vid][$grant_name] = $grant_val;
}
}
}
}
return $grants;
}