function notifications_content_form_alter in Notifications 6
Same name and namespace in other branches
- 6.4 notifications_content/notifications_content.module \notifications_content_form_alter()
- 6.2 notifications_content/notifications_content.module \notifications_content_form_alter()
- 6.3 notifications_content/notifications_content.module \notifications_content_form_alter()
Implementation of hook_form_alter().
File
- notifications_content/
notifications_content.module, line 103 - Subscriptions to content events
Code
function notifications_content_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'comment_form':
// Load the node which is possibly cached to get the node type
$node = node_load($form['nid']['#value']);
if (notifications_content_type_enabled($node->type)) {
$form['notifications']['notifications_content_disable'] = array(
'#type' => 'checkbox',
'#title' => t('Do not send notifications for this comment.'),
'#default_value' => 0,
'#access' => user_access('skip notifications'),
);
}
break;
case 'node_type_form':
if (isset($form['identity']['type'])) {
// Hack for modules with different weights to add options here
if (!isset($form['notifications'])) {
$form['notifications'] = array();
}
$form['notifications'] += array(
'#type' => 'fieldset',
'#title' => t('Subscription settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['notifications']['notifications_content_type'] = array(
'#type' => 'checkboxes',
'#title' => t('Allowed subscription types'),
'#default_value' => notifications_content_type_enabled($form['#node_type']->type),
'#options' => _notifications_content_type_options(),
'#description' => t('Enable different subscription options for this content type.'),
'#weight' => -10,
);
if (!variable_get('notifications_content_per_type', 0)) {
$form['notifications']['notifications_content_type']['#disabled'] = TRUE;
$form['notifications']['notifications_content_type']['#description'] .= ' <strong>' . t('To enable these options check the <a href="@notifications-settings">Notifications content settings</a>', array(
'@notifications-settings' => url('admin/messaging/notifications/content'),
)) . '</strong>';
}
}
break;
default:
// Node form. Option to disable notifications
if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] . '_node_form' == $form_id) {
$types = notifications_content_types(NULL);
if (notifications_content_type_enabled($node->type)) {
$noprevious = !isset($form['notifications']);
$form['notifications']['#type'] = 'fieldset';
$form['notifications']['#title'] = t('Notifications');
$form['notifications']['#collapsible'] = TRUE;
$form['notifications']['#weight'] = 1;
//don't want to hide/change access on modules that already used the notifications fieldset for something
if ($noprevious) {
$form['notifications']['#collapsed'] = TRUE;
$form['notifications']['#access'] = user_access('skip notifications');
}
$form['notifications']['notifications_content_disable'] = array(
'#type' => 'checkbox',
'#title' => t('Do not send notifications for this update.'),
'#default_value' => 0,
'#access' => user_access('skip notifications'),
);
}
}
}
}