function og_group_form in Organic groups 5.2
Same name and namespace in other branches
- 5.8 og.module \og_group_form()
- 5 og.module \og_group_form()
- 5.3 og.module \og_group_form()
- 5.7 og.module \og_group_form()
- 6.2 og.module \og_group_form()
- 6 og.module \og_group_form()
Adds standard fields for any node configured to be a group node
Parameters
object $node:
1 call to og_group_form()
- og_form_alter in ./
og.module
File
- ./
og.module, line 1104
Code
function og_group_form($node) {
global $user;
$edit = $_POST['edit'];
// all group home pages are publically accessible as far as og is concerned. their posts may or may not be.
// change this via hook_form_alter() if you want subscriber only group home pages. this may become part of og.module one day
$form['og_public'] = array(
'#type' => 'value',
'#value' => TRUE,
);
$form['og_description'] = array(
'#type' => 'textfield',
'#title' => t('Description'),
'#default_value' => $node->og_description,
'#size' => 70,
'#maxlength' => 150,
'#required' => true,
'#description' => t('A brief description for the group details block and the group directory.'),
'#weight' => -4,
);
$form['og_website'] = array(
'#type' => 'textfield',
'#title' => t('Group website'),
'#default_value' => $node->og_website,
'#description' => t('If your group has its own website, enter the address here.'),
);
if ($node->nid) {
$default = $node->og_selective;
}
else {
$default = OG_OPEN;
}
$form['og_selective'] = array(
'#type' => 'radios',
'#title' => t('Subscription requests'),
'#default_value' => $default,
'#options' => array(
t('open - subscription requests are accepted immediately.'),
t('moderated - subscription requests must be approved.'),
t('invite only - subscriptions must be created by an administrator.'),
t('closed - subscriptions are fully administered by an administrator.'),
),
'#description' => t('How should subscription requests be handled in this group? When you select <em>closed</em>, users will not be able to subscribe <strong>or</strong> unsubscribe.'),
);
// registration checkbox
// get the visibility for normal users
$visibility = variable_get('og_visibility_registration', OG_REGISTRATION_CHOOSE_FALSE);
// admin can always choose - get right default
if (user_access('administer nodes')) {
$visibility = in_array($visibility, array(
OG_REGISTRATION_NEVER,
OG_REGISTRATION_CHOOSE_FALSE,
)) ? OG_REGISTRATION_CHOOSE_FALSE : OG_REGISTRATION_CHOOSE_TRUE;
}
$default = FALSE;
switch ($visibility) {
case OG_REGISTRATION_NEVER:
$form['og_register'] = array(
'#type' => 'value',
'#value' => 0,
);
break;
case OG_REGISTRATION_ALWAYS:
$form['og_register'] = array(
'#type' => 'value',
'#value' => 1,
);
break;
case OG_REGISTRATION_CHOOSE_TRUE:
$default = TRUE;
// fall through
case OG_REGISTRATION_CHOOSE_FALSE:
$form['og_register'] = array(
'#type' => 'checkbox',
'#title' => t('registration form'),
'#default_value' => $node->nid ? $node->og_register : $default,
'#description' => t('Should this group be available for subscription during registration?. If checked, a corresponding checkbox will be added to the registration form.'),
);
break;
}
// directory checkbox
$visibility = variable_get('og_visibility_directory', OG_DIRECTORY_CHOOSE_FALSE);
// override for admins - get right default
if (user_access('administer nodes')) {
$visibility = in_array($visibility, array(
OG_DIRECTORY_NEVER,
OG_DIRECTORY_CHOOSE_FALSE,
)) ? OG_DIRECTORY_CHOOSE_FALSE : OG_DIRECTORY_CHOOSE_TRUE;
}
$default = FALSE;
switch ($visibility) {
case OG_DIRECTORY_NEVER:
$form['og_directory'] = array(
'#type' => 'value',
'#value' => 0,
);
break;
case OG_DIRECTORY_ALWAYS:
$form['og_directory'] = array(
'#type' => 'value',
'#value' => 1,
);
break;
case OG_DIRECTORY_CHOOSE_TRUE:
$default = TRUE;
// fall through
case OG_DIRECTORY_CHOOSE_FALSE:
$form['og_directory'] = array(
'#type' => 'checkbox',
'#title' => t('list in groups directory'),
'#default_value' => $node->nid ? $node->og_directory : $default,
'#description' => t('Should this group appear on the !page?', array(
'!page' => l(t('list of groups page'), 'og'),
)),
);
break;
}
// language
if (module_exists('locale') && ($languages = locale_supported_languages())) {
if (count($languages['name']) > 1) {
$languages['name'] = array_map('check_plain', $languages['name']);
$form['locale']['og_language'] = array(
'#type' => 'radios',
'#title' => t('Language'),
'#default_value' => $node->og_language,
'#options' => $languages['name'],
'#description' => t('Selecting a different locale will change the interface language of the group. Users who have chosen a preferred language always see their chosen language.'),
);
}
}
$form['og_theme'] = system_theme_select_form(t('Selecting a different theme will change the look and feel of the group.'), $edit['theme'] ? $edit['theme'] : $node->og_theme, 2);
return $form;
}