function _entity_translation_grant_edit_permissions in Entity Translation 7
Grant 'edit $type original values' permission to existing roles.
1 call to _entity_translation_grant_edit_permissions()
- entity_translation_update_7002 in ./
entity_translation.install - Grant 'edit original values' and 'edit shared field' permissions to roles which have entity editing permissions.
File
- ./
entity_translation.install, line 186 - Installation functions for Entity Translation module.
Code
function _entity_translation_grant_edit_permissions() {
variable_set('entity_translation_workflow_enabled', TRUE);
$permissions = array();
// Nodes.
$permissions['node'][] = 'bypass node access';
foreach (node_permissions_get_configured_types() as $type) {
$permissions['node'][] = "edit own {$type} content";
$permissions['node'][] = "edit any {$type} content";
}
// Comments.
if (module_exists('comment')) {
$permissions['comment'][] = 'administer comments';
$permissions['comment'][] = 'edit own comments';
}
// Taxonomy terms.
if (module_exists('taxonomy')) {
$permissions['taxonomy_term'][] = 'administer taxonomy';
foreach (taxonomy_get_vocabularies() as $vocabulary) {
$permissions['taxonomy_term'][] = "edit terms in {$vocabulary->vid}";
}
}
$assignments = array();
foreach ($permissions as $entity_type => $permissions_filter) {
if (entity_translation_enabled($entity_type)) {
$permission = "edit {$entity_type} original values";
$assignments[] = _entity_translation_grant_permission($permission, $permissions_filter);
$permission = "edit {$entity_type} translation shared fields";
$assignments[] = _entity_translation_grant_permission($permission, $permissions_filter);
}
}
$assignments = '<ul><li>' . implode('</li><li>', $assignments) . '</li></ul>';
$t = get_t();
return $t('The following permissions have been assigned to existing roles: !assignments', array(
'!assignments' => $assignments,
));
}