You are here

function notifications_autosubscribe_notifications_node_form_alter in Notifications 6.4

Same name and namespace in other branches
  1. 5 notifications_autosubscribe/notifications_autosubscribe.module \notifications_autosubscribe_notifications_node_form_alter()
  2. 6 notifications_autosubscribe/notifications_autosubscribe.module \notifications_autosubscribe_notifications_node_form_alter()
  3. 6.2 notifications_autosubscribe/notifications_autosubscribe.module \notifications_autosubscribe_notifications_node_form_alter()
  4. 6.3 notifications_autosubscribe/notifications_autosubscribe.module \notifications_autosubscribe_notifications_node_form_alter()

Implementation of hook_notifications_node_form_alter

Replace normal 'thread' subscription by autosubscribe option

File

notifications_autosubscribe/notifications_autosubscribe.module, line 95
Notifications Autosubscribe module.

Code

function notifications_autosubscribe_notifications_node_form_alter(&$form) {
  global $user;
  if (!empty($form['subscriptions']['params']) && notifications_user_setting('auto', $form['subscriptions']['account']['#value'])) {
    foreach ($form['subscriptions']['params']['#value'] as $index => $current) {
      if ($current['type'] == 'thread' && empty($current->sid)) {
        $form['subscriptions']['autosubscribe'] = array(
          '#type' => 'checkbox',
          '#default_value' => 1,
          '#disabled' => TRUE,
          '#title' => $form['subscriptions']['options']['#options'][$index],
          '#description' => t('You are currently set to receive notifications for replies to content which you create. To change this default, uncheck the autosubscribe option in your user account settings.'),
        );
        unset($form['subscriptions']['options']['#options'][$index]);
      }
    }
  }
}