function _forum_access_forum_grants_form in Forum Access 7
Same name and namespace in other branches
- 8 includes/forum_access.admin.inc \_forum_access_forum_grants_form()
1 call to _forum_access_forum_grants_form()
- _forum_access_forum_form in ./
forum_access.admin.inc - Rewrite the forum administration page with our new access rules.
File
- ./
forum_access.admin.inc, line 227 - forum_access.admin.inc
Code
function _forum_access_forum_grants_form(&$form_state, $is_container, $settings) {
$tr = 't';
$roles = user_roles();
$administer_forums_roles = user_roles(FALSE, 'administer forums');
$bypass_node_access_roles = user_roles(FALSE, 'bypass node access');
$form = array(
'#type' => 'item',
'#theme' => 'forum_access_table',
);
$forum_vocabulary = taxonomy_vocabulary_load(_forum_access_get_vid());
if ($is_container) {
$cols = array(
'view' => t('View this container'),
'create' => t('See this container in the %Forums selection list', array(
'%Forums' => $forum_vocabulary->name,
)),
);
}
else {
$cols = array(
'view' => t('View this forum'),
'create' => t('Post in this forum'),
'update' => t('Edit posts'),
'delete' => t('Delete posts'),
);
}
$form['col_ids'] = array(
'#type' => 'value',
'#value' => array_keys($cols),
);
foreach ($roles as $rid => $role) {
$form['rows'][$rid] = array(
'#type' => 'item',
'#markup' => check_plain($role),
);
$special = NULL;
if (isset($administer_forums_roles[$rid])) {
$special = t("This role has the '@administer_forums' permission, and granting 'View' enables the role holders to change the settings on this page, including Access Control!", array(
'@administer_forums' => $tr('administer forums'),
));
if (isset($bypass_node_access_roles[$rid])) {
$special .= ' ' . t("Because the role also has the '@bypass_node_access' permission, it has full access to all nodes either way.", array(
'@bypass_node_access' => $tr('bypass node access'),
));
}
}
elseif (isset($bypass_node_access_roles[$rid])) {
$special = t("This role has the '@bypass_node_access' permission and thus full access to all nodes.", array(
'@bypass_node_access' => $tr('bypass node access'),
));
}
if (isset($special)) {
$form['rows'][$rid] += array(
'#prefix' => '<em><span title="' . $special . '" class="forum-access-special-role">',
'#suffix' => '</span></em>',
'#disabled' => TRUE,
);
}
$roles[$rid] = '';
}
foreach ($cols as $cid => $ctitle) {
$form['checkboxes'][$cid] = array(
'#type' => 'checkboxes',
'#options' => $roles,
'#default_value' => $settings[$cid],
'#process' => array(
'form_process_checkboxes',
'_forum_access_process_grant_form_checkboxes',
),
);
$form['col_ids'][$cid] = array(
'#markup' => $ctitle,
'#tree' => TRUE,
);
}
$form_state['build_info']['files'][] = _forum_access_module_load_include('admin.inc');
$form['info1'] = array(
'#type' => 'item',
'#description' => t('For explanations of <em class="placeholder">special cases</em>, hover your mouse over role names.'),
);
if ($is_container) {
$form['info2'] = array(
'#type' => 'item',
'#description' => t('Users who can see any forum or container within this one should get the <strong><em>View</em></strong> grant. <br /> Users who can post to a forum within this container should get the <strong><em>See</em></strong> grant, so that the forum appears in the proper context in the %Forums selection list.', array(
'%Forums' => $forum_vocabulary->name,
)),
);
}
drupal_add_css(drupal_get_path('module', 'forum_access') . '/forum_access.css', array(
'preprocess' => FALSE,
));
return $form;
}