function og_subgroups_node_form_validate in Subgroups for Organic groups 6
Validate the group node form
1 string reference to 'og_subgroups_node_form_validate'
- og_subgroups_add_group_select_form in includes/
form.inc - Add form components to select group parents on the group node form
File
- ./
og_subgroups.module, line 423 - Maintains a hierarchy of groups created by the orgainc groups module.
Code
function og_subgroups_node_form_validate(&$form, &$form_state) {
if (isset($form_state['values']['nid']) && isset($form_state['values']['og_parent'])) {
og_subgroups_include('tree');
// Extract the node id
$node = new stdClass();
$node->nid = $form_state['values']['nid'];
// Extract the selected parent
$parent = new stdClass();
$parent->nid = $form_state['values']['og_parent'];
// Make sure the chosen parent is not the node we're editing
if ($node->nid == $parent->nid) {
form_set_error('og_parent', t('You cannot set the parent of this group to be the group itself.'));
}
// Make sure the selected parent is not a child of the node we're editing
if ($parent->nid && og_subgroups_group_is_child($node, $parent)) {
form_set_error('og_parent', t('You cannot set a child of this group to be the parent.'));
}
// Check if forced-privacy is enabled
if (variable_get('og_subgroups_inherit_privacy', 0)) {
// Only check if this group is not set to private
if (!$form_state['values']['og_private']) {
// See if the parent group is private
$sql = "SELECT og_private FROM {og} WHERE nid = %d";
$is_private = db_result(db_query($sql, $parent->nid));
if ($is_private) {
// This group must be private
form_set_error('og_private', t('The selected parent for this group is a private group. This group must also be private.'));
}
}
}
}
}