function og_access_alter_nongroup_form in Organic groups 5.8
Same name and namespace in other branches
- 5 og_access.module \og_access_alter_nongroup_form()
- 5.3 og_access.module \og_access_alter_nongroup_form()
- 5.7 og_access.module \og_access_alter_nongroup_form()
- 6.2 modules/og_access/og_access.module \og_access_alter_nongroup_form()
- 6 modules/og_access/og_access.module \og_access_alter_nongroup_form()
1 call to og_access_alter_nongroup_form()
- og_access_form_alter in ./og_access.module
- Implementation of hook_form_alter().
File
- ./og_access.module, line 91
Code
function og_access_alter_nongroup_form(&$form, $node) {
global $user;
if (og_is_group_post_type($node->type)) {
$vis = variable_get('og_visibility', 0);
if (user_access('administer organic groups')) {
if ($vis < 2) {
$vis = $vis == OG_VISIBLE_GROUPONLY ? OG_VISIBLE_CHOOSE_PRIVATE : OG_VISIBLE_CHOOSE_PUBLIC;
}
}
elseif (!og_get_subscriptions($user->uid)) {
$vis = OG_VISIBLE_BOTH;
}
$groups = $form['og_initial_groups']['#value'];
$selected_groups = isset($form['#post']['og_groups']) ? array_filter($form['#post']['og_groups']) : $groups;
if (count($selected_groups)) {
foreach ($selected_groups as $gid) {
$group_node = new stdClass();
$group_node->nid = $gid;
og_load_group($group_node);
if ($group_node->og_private) {
$vis = variable_get('og_visibility', 0) == OG_VISIBLE_BOTH ? OG_VISIBLE_GROUPONLY : OG_VISIBLE_CHOOSE_PRIVATE;
break;
}
}
}
else {
}
switch ($vis) {
case OG_VISIBLE_BOTH:
$form['og_nodeapi']['og_public'] = array(
'#type' => 'value',
'#value' => 1,
);
break;
case OG_VISIBLE_GROUPONLY:
$form['og_nodeapi']['og_public'] = array(
'#type' => 'value',
'#value' => 0,
);
break;
case OG_VISIBLE_CHOOSE_PUBLIC:
$form['og_nodeapi']['visible']['og_public'] = array(
'#type' => 'checkbox',
'#title' => t('Public'),
'#default_value' => $node->nid ? $node->og_public : 1,
'#description' => t('Show this post to everyone, or only to members of the groups checked above. Posts without any groups are always <em>Public</em>.'),
'#weight' => 2,
);
break;
case OG_VISIBLE_CHOOSE_PRIVATE:
$form['og_nodeapi']['visible']['og_public'] = array(
'#type' => 'checkbox',
'#title' => t('Public'),
'#default_value' => $node->nid ? $node->og_public : 0,
'#description' => t('Show this post to everyone, or only to members of the groups checked above. Posts without any groups are always <em>Public</em>.'),
'#weight' => 2,
);
break;
}
if (count($form['og_nodeapi']['visible']) > 1) {
$form['og_nodeapi']['#type'] = 'fieldset';
$form['og_nodeapi']['#title'] = t('Groups');
$form['og_nodeapi']['#collapsible'] = TRUE;
$form['og_nodeapi']['#collapsed'] = $selected_groups ? TRUE : FALSE;
}
}
}