function simple_access_form in Simple Access 5.2
Same name and namespace in other branches
- 8.3 simple_access.module \simple_access_form()
- 5 simple_access.module \simple_access_form()
- 6.2 simple_access.module \simple_access_form()
- 7.2 simple_access.module \simple_access_form()
1 call to simple_access_form()
File
- ./
simple_access.module, line 356 - This module allows administrators to make nodes viewable by specific 'access groups'. Each access group can contain any number of roles. If a node is not assigned to any access groups, it will remain viewable by all users.
Code
function simple_access_form($node) {
// Get the array of checkbox options to use for each form element.
// If the "Show groups even when user is not a member" setting is
// enabled, or if the current user has 'administer nodes', let
// them choose from any of the SA groups.
$groups = simple_access_group_select();
$profiles = simple_access_get_profiles_select();
if (empty($groups) && empty($profiles) && !user_access('assign owner permissions')) {
return;
}
$user_groups = array_filter($node->simple_access, '_simple_access_filter_access');
$owner_priv = array_filter($node->simple_access_owner);
// set up the outer fieldset
$form['sa'] = array(
'#title' => t('Access'),
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => empty($user_groups) && empty($node->simple_access_profiles) && empty($owner_priv),
'#access' => user_access('assign access to profiles') || user_access('assign access to nodes') || user_access('administer nodes'),
);
if (!empty($profiles)) {
$form['sa']['simple_access_profiles'] = array(
'#type' => 'checkboxes',
'#title' => t('Access profile'),
'#default_value' => $node->simple_access_profiles,
'#options' => $profiles,
'#access' => user_access('assign access to profiles') || user_access('administer nodes'),
);
}
if (!empty($groups) || user_access('assign owner permissions')) {
$form['sa']['simple_access'] = array(
'#tree' => TRUE,
'#weight' => 5,
'#access' => user_access('assign access to nodes') || user_access('administer nodes') || user_access('assign owner permissions'),
'#theme' => 'simple_access_form',
);
// Load the owner perminisions.
$group = array(
'name' => t('Owner permissions'),
'access' => user_access('assign owner permissions') && $node->uid,
);
$access = array(
'owner' => $node->simple_access_owner,
);
$form['sa']['simple_access']['owner'] = simple_access_form_row('owner', $group, $access);
$form['sa']['simple_access']['owner']['#parents'] = array(
'simple_access_owner',
);
// See what form elements we should include. If not configured,
// only enable the 'view' elements by default.
$variable = variable_get('sa_display', array(
'view' => 1,
));
foreach ($groups as $gid => $group) {
$form['sa']['simple_access'][$gid] = simple_access_form_row($gid, $group, $node->simple_access);
}
}
return $form;
}