function taxonomy_access_fix_access in Taxonomy access fix 7
Same name and namespace in other branches
- 8 taxonomy_access_fix.module \taxonomy_access_fix_access()
- 7.2 taxonomy_access_fix.module \taxonomy_access_fix_access()
Creates an access callback for custom vocabulary access.
See also
taxonomy_access_fix_permission()
http://api.drupal.org/api/drupal/modules--taxonomy--taxonomy.module/func...
2 calls to taxonomy_access_fix_access()
- taxonomy_access_fix_form_taxonomy_overview_terms_alter in ./
taxonomy_access_fix.module - Implements hook_form_FORM_ID_alter() for taxonomy_overview_terms().
- taxonomy_access_fix_form_taxonomy_overview_vocabularies_alter in ./
taxonomy_access_fix.module - Implements hook_form_FORM_ID_alter() for taxonomy_overview_vocabularies().
1 string reference to 'taxonomy_access_fix_access'
- taxonomy_access_fix_menu_alter in ./
taxonomy_access_fix.module - Implements hook_menu_alter().
File
- ./
taxonomy_access_fix.module, line 147 - This file contains all hooks and callbacks for extra/improved Taxonomy permissions.
Code
function taxonomy_access_fix_access($op, $vocabulary = NULL) {
// Admin: always.
if (user_access('administer taxonomy')) {
return TRUE;
}
// Others: well, that depends.
switch ($op) {
case 'index':
// Only if they have >= 1 vocabulary access.
foreach (taxonomy_get_vocabularies() as $vid => $vocabulary) {
if (user_access('edit terms in ' . $vid) || user_access('delete terms in ' . $vid) || user_access('add terms in ' . $vid)) {
return TRUE;
}
}
break;
case 'list terms':
if ($vocabulary) {
$vid = $vocabulary->vid;
if (user_access('edit terms in ' . $vid) || user_access('delete terms in ' . $vid) || user_access('add terms in ' . $vid)) {
return TRUE;
}
}
break;
case 'reorder':
// If you can list terms, you can reorder. Not logic, but backward compatibility.
return taxonomy_access_fix_access('list terms', $vocabulary);
case 'add terms':
if ($vocabulary) {
$vid = $vocabulary->vid;
if (user_access('add terms in ' . $vid)) {
return TRUE;
}
}
break;
}
}