/** * Configure permissions. * * @todo this is here because I cannot add it inside module due to SQL error: * SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'module' cannot * be null. * * {@inheritdoc} */ function osha_configure_permissions() { if ($role = user_role_load_by_name('administrator')) { $vocabularies = array('activity', 'article_types', 'esener', 'nace_codes', 'section', 'thesaurus', 'wiki_categories', 'workflow_status', 'publication_types', 'newsletter_sections'); $permissions = array(); foreach ($vocabularies as $voc_name) { if ($voc = taxonomy_vocabulary_machine_name_load($voc_name)) { $permissions[] = 'add terms in ' . $voc_name; $permissions[] = 'edit terms in ' . $voc->vid; $permissions[] = 'delete terms in ' . $voc->vid; } } $permissions[] = 'access workbench access by role'; $permissions[] = 'translate taxonomy_term entities'; $permissions[] = 'edit any content in rejected'; $permissions[] = 'edit any content in approved'; $permissions[] = 'edit any content in final_draft'; $permissions[] = 'edit any content in to_be_approved'; // Workbench access permissions. $moderated_types = workbench_moderation_moderate_node_types(); $transitions = workbench_moderation_transitions(); foreach ($transitions as $transition) { $permissions[] = "moderate content from {$transition->from_name} to {$transition->to_name}"; foreach ($moderated_types as $node_type) { //@todo: $permissions[] = "moderate $node_type state from {$transition->from_name} to {$transition->to_name}"; } } $permissions[] = 'create moderators_group entity collections'; $permissions[] = 'edit moderators_group entity collections'; $permissions[] = 'view moderators_group entity collections'; $permissions[] = 'delete moderators_group entity collections'; $permissions[] = 'add content to moderators_group entity collections'; $permissions[] = 'manage content in moderators_group entity collections'; user_role_grant_permissions($role->rid, $permissions); user_role_revoke_permissions($role->rid, array('use workbench_moderation needs review tab')); } $roles = array(OSHA_WORKFLOW_ROLE_TRANSLATION_MANAGER, OSHA_WORKFLOW_ROLE_TRANSLATION_LIAISON, OSHA_WORKFLOW_ROLE_LAYOUT_VALIDATOR, OSHA_WORKFLOW_ROLE_CONTENT_VALIDATOR); foreach ($roles as $role_name) { if ($role = user_role_load_by_name($role_name)) { user_role_grant_permissions($role->rid, array('access workbench')); } } }
/** * Grab a named node from the entity store and add moderation fields to it. * * @param String $name A named entity in the entity store. * @return \StdClass Node with additional moderation fields. * @throws \Exception */ public function getModerationNode($name) { /** @var \EntityDrupalWrapper $wrapper */ $wrapper = $this->getEntityStore()->retrieve_by_name($name); if ($wrapper === FALSE) { throw new \Exception("No entity with the name '{$name}' was found. Make sure it's created in the step."); } if ($wrapper->type() !== 'node') { $entity_type = $wrapper->type(); throw new \Exception("Only nodes types are supported by workbench_moderation, but {$entity_type} type given."); } if (!workbench_moderation_node_type_moderated($wrapper->getBundle())) { $types = implode(', ', workbench_moderation_moderate_node_types()); throw new \Exception("Nodes type '{$wrapper->getBundle()}' is not a moderated type. Types enabled are [{$types}]'."); } $node = $wrapper->raw(); workbench_moderation_node_data($node); return $node; }