function og_notifications_form_alter in Organic groups 6
Same name and namespace in other branches
- 5.8 og_notifications/og_notifications.module \og_notifications_form_alter()
- 5 og_notifications/og_notifications.module \og_notifications_form_alter()
- 5.3 og_notifications/og_notifications.module \og_notifications_form_alter()
- 5.7 og_notifications/og_notifications.module \og_notifications_form_alter()
- 6.2 modules/og_notifications/og_notifications.module \og_notifications_form_alter()
Implementation of hook_form_alter().
File
- modules/
og_notifications/ og_notifications.module, line 79 - Provide notifications and messaging support for organic groups.
Code
function og_notifications_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
case 'notifications_content_settings_form':
$form['group'] = array(
'#type' => 'fieldset',
'#title' => t('Group subscriptions'),
'#collapsible' => TRUE,
'#weight' => 0,
);
// General content settings
$select = array();
$nodetypes = node_get_types();
$ogtypes = og_get_types('group_post');
foreach ($ogtypes as $ntype) {
$select[$ntype] = $nodetypes[$ntype]->name;
}
$form['group']['og_notifications_content_types'] = array(
'#type' => 'checkboxes',
'#title' => t('Allowed content types'),
'#default_value' => variable_get('og_notifications_content_types', array()),
'#options' => $select,
'#description' => t('Select specific content types which should be <em>allowed</em> for subscriptions to <em>group + content type</em>.'),
'#multiple' => TRUE,
);
break;
case 'user_profile_form':
// Insert autosubscribe option into the messaging section of the user edit
// form.
// user_profile_form is, oddly enough, also the form_id for forms in other
// sub-tabs such as those added by the profile module.
if (!arg(3)) {
$account = $form['_account']['#value'];
$form['messaging']['og_notifications_autosubscribe'] = array(
'#type' => 'checkbox',
'#title' => t('Automatically enable notifications for any groups that I join.'),
'#description' => t('Group notifications can also be <a href="!manage-url">customized</a> in greater detail if required.', array(
'!manage-url' => url('user/' . $account->uid . '/notifications/group'),
)),
'#default_value' => og_notifications_user_autosubscribe_get($account->uid),
);
}
break;
case 'og_admin_settings':
unset($form['og_new_node_subject'], $form['og_new_node_body']);
$form['og_settings']['notifications']['#description'] = t('Node event notifications can be configured via the <a href="!url">messaging templates</a> interface.', array(
'!url' => url('admin/messaging/template'),
));
// Default autosubscription setting.
$form['og_settings']['notifications']['og_notifications_autosubscribe'] = array(
'#type' => 'checkbox',
'#title' => t('Autosubscribe users to any groups that they join.'),
'#description' => t('Automatically enable notifications by default. Users can override this via their account page. Changing this setting will only affect new users and those who have not overridden the system default.'),
'#default_value' => variable_get('og_notifications_autosubscribe', 1),
'#weight' => -5,
);
break;
}
}