function taxonomy_permissions_permission in Taxonomy Permissions 7
Implements hook_permission().
File
Code
function taxonomy_permissions_permission() {
// Insert a 'View terms in X' permission ahead of every 'Edit terms in X'
// permission from taxonomy.module.
// Unlike core, we use the vocabulary machine_names in the permission
// machine_names, rather than the vids.
$perms = taxonomy_permission();
$vocabularies = taxonomy_get_vocabularies();
$new_perms = array();
$matches = array();
foreach ($perms as $key => $perm) {
if (preg_match('#edit terms in ([0-9]*)#', $key, $matches)) {
$vid = $matches[1];
$vocabulary = $vocabularies[$vid];
$new_perms[taxonomy_permissions_permission_name($vocabulary)] = array(
'title' => t('View terms in %vocabulary', array(
'%vocabulary' => $vocabulary->name,
)),
);
}
$new_perms[$key] = $perm;
}
return $new_perms;
}