function workbench_access_editor_form in Workbench Access 7
Generate a user overview form for a section.
Parameters
$access_type: The type of access requested (e.g.g taxonomy).
$access_type_id: The id for this specific access (here, a taxnomy term tid).
Return value
A form.
1 string reference to 'workbench_access_editor_form'
- workbench_access_editors in ./
workbench_access.admin.inc - Display the editors for a section.
File
- ./
workbench_access.admin.inc, line 623 - Workbench Access admin file.
Code
function workbench_access_editor_form($form, &$form_state, $access_type, $access_type_id) {
// Set proper breadcrumb trails.
$breadcrumb[] = l(t('Workbench Access'), 'admin/config/workbench/access');
$breadcrumb[] = l(t('Editors'), 'admin/config/workbench/access/editors');
workbench_access_breadcrumb($breadcrumb);
$form = array();
$active = workbench_access_get_active_tree();
$active['access_scheme']['access_id'] = $access_type_id;
if ($active['access_scheme']['access_type'] != $access_type || !isset($active['active'][$access_type_id])) {
drupal_access_denied();
drupal_exit();
}
// Get the list of user roles that can be assigned workbench access.
$roles = workbench_access_get_roles('access workbench access by role');
$query = db_select('users', 'u')
->fields('u', array(
'uid',
'name',
));
$query
->join('workbench_access_user', 'wau', 'u.uid = wau.uid');
$query
->condition('wau.access_scheme', $access_type)
->condition('wau.access_id', $access_type_id)
->extend('PagerDefault')
->limit(25);
// If all authorized users are not allowed, JOIN to user_roles.
if (!isset($roles[DRUPAL_AUTHENTICATED_RID])) {
$query
->join('users_roles', 'ur', 'u.uid = ur.uid');
$query
->condition('ur.rid', array_keys($roles), 'IN');
}
$result = $query
->execute();
$rows = array();
$form['users']['#tree'] = TRUE;
foreach ($result as $account) {
$form['users'][$account->uid]['name'] = array(
'#markup' => l(format_username($account), 'user/' . $account->uid),
);
$form['users'][$account->uid]['remove'] = array(
'#type' => 'checkbox',
'#title' => t('Remove'),
);
}
$form['add_user'] = array(
'#type' => 'textfield',
'#title' => t('Add editor'),
'#autocomplete_path' => 'workbench_access/autocomplete/' . $access_type . '/' . $access_type_id,
);
$form['workbench_access'] = array(
'#type' => 'value',
'#value' => $active['access_scheme'],
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Update editors'),
);
return $form;
}