function _spaces_og_form_alter_node in Spaces 6.3
Same name and namespace in other branches
- 5.2 spaces_og.module \_spaces_og_form_alter_node()
- 6 spaces_og/spaces_og.module \_spaces_og_form_alter_node()
- 6.2 spaces_og/spaces_og.module \_spaces_og_form_alter_node()
- 7.3 spaces_og/spaces_og.pages.inc \_spaces_og_form_alter_node()
- 7 spaces_og/spaces_og.pages.inc \_spaces_og_form_alter_node()
Group-enabled node form_alter()
1 call to _spaces_og_form_alter_node()
- spaces_og_form_alter in spaces_og/
spaces_og.module - Implementation of hook_form_alter().
File
- spaces_og/
spaces_og.pages.inc, line 123
Code
function _spaces_og_form_alter_node(&$form, $form_state) {
global $user;
$space = spaces_get_space();
if ($group_types = og_get_types('group')) {
$typename = node_get_types('name', array_shift($group_types));
}
// Retrieve the content type label
/*
if (!empty($form['og_nodeapi']['visible']['og_groups'])) {
$form['og_groups'] = $form['og_nodeapi']['visible']['og_groups'];
$form['og_groups']['#title'] = t('Select a !typename', array('!typename' => $typename));
$form['og_groups']['#type'] = 'select';
$form['og_groups']['#multiple'] = FALSE;
unset($form['og_nodeapi']['visible']['og_groups']);
}
*/
// Recurse into og_options hiding all of them.
_spaces_og_make_hidden($form['og_nodeapi']);
// If this node is not associated with a group, we are not in a space and
// og_audience is required, we do not meet a legal condition. If the user has
// administer node permissions give her a list of groups to fix the situation.
// Otherwise issue an error.
$groups = !empty($form['#node']->og_groups) ? array_filter($form['#node']->og_groups) : array();
if (variable_get('og_audience_required', FALSE) && empty($groups)) {
if (user_access('administer nodes')) {
$form['spaces_og_audience'] = array(
'#type' => 'select',
'#title' => t('Group'),
'#description' => t('This node is supposted to be posted within a group but it is not. Select a group to fix the issue.'),
'#required' => TRUE,
'#options' => array(
t('Select a group'),
) + og_all_groups_options(),
);
}
else {
drupal_set_message(t('This content type is supposed to be posted within a group but it is not. You will not be able to save this node. Please contact a site administrator to fix the issue.'), 'error');
}
}
// We can only determine the privacy of this node if currently in
// a group space. Otherwise, it will be determined by the feature
// setting of the group targeted by the selector above.
if (isset($space->type) && $space->type == 'og') {
$form['spaces'] = array(
'#title' => t('Privacy'),
'#type' => 'fieldset',
'#weight' => 100,
);
switch ($form['#node']->og_public) {
case OG_VISIBLE_GROUPONLY:
$form['spaces']['#description'] = t('A post of this type is <strong>private</strong>. Only members of this !typename will be able to see it.', array(
'!typename' => strtolower($typename),
));
break;
case OG_VISIBLE_BOTH:
$form['spaces']['#description'] = t('A post of this type is <strong>public</strong>. All visitors will be able to see it.');
break;
}
}
}