You are here

function workbench_moderation_admin_check_role_form in Workbench Moderation 7.3

Same name and namespace in other branches
  1. 7 workbench_moderation.admin.inc \workbench_moderation_admin_check_role_form()

Check proper permissions for moderation roles.

This helper administration form checks whether roles have the appropriate permissions to use moderation as intended.

1 string reference to 'workbench_moderation_admin_check_role_form'
workbench_moderation_menu in ./workbench_moderation.module
Implements hook_menu().

File

./workbench_moderation.admin.inc, line 316
Administrative functions for Workbench Moderation.

Code

function workbench_moderation_admin_check_role_form($form, &$form_state) {
  $form = array();
  $roles = user_roles();
  $form['role'] = array(
    '#type' => 'select',
    '#title' => t('Drupal role'),
    '#description' => t('Select a role to check.'),
    '#options' => $roles,
  );
  $form['moderation_task'] = array(
    '#type' => 'select',
    '#title' => t('Moderation task'),
    '#description' => t('Select a moderation task that the role should be able to perform.'),
    '#options' => array(
      'author' => t('Author moderated content'),
      'editor' => t('Edit moderated content'),
      'moderator' => t('Moderate content'),
      'publisher' => t('Publish moderated content'),
    ),
  );
  $types = drupal_map_assoc(workbench_moderation_moderate_node_types());
  $all_types = node_type_get_types();
  foreach ($types as $type) {
    $types[$type] = $all_types[$type]->name;
  }
  $form['types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Content types'),
    '#description' => t('Select any content types on which the user should have the ability to perform the moderation task.'),
    '#options' => $types,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Check permissions'),
  );
  if (empty($types)) {
    drupal_set_message(t('Moderation is not enabled for any content types. Visit the <a href="@content_type_administration_page">content type administration page</a> to enable moderation for one or more types.', array(
      '@content_type_administration_page' => url('admin/structure/types'),
    )), 'warning');
    $form['#disabled'] = TRUE;
  }
  return $form;
}