You are here

function notifications_autosubscribe_form_alter in Notifications 5

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

Implementation of hook_form_alter()

Adds autosubscribe checkbox to user edit form.

File

notifications_autosubscribe/notifications_autosubscribe.module, line 39

Code

function notifications_autosubscribe_form_alter($form_id, &$form) {
  switch ($form_id) {
    case 'user_edit':
      if (isset($form['messaging'])) {
        $form['messaging']['notifications_auto'] = array(
          '#type' => 'checkbox',
          '#title' => t('Autosubscribe'),
          '#default_value' => notifications_user_setting('auto', $form['_account']['#value']),
          '#description' => t('Checking this box allows you to automatically subscribe to any thread you create or post a comment to.'),
        );
      }
      break;
    case 'notifications_content_settings_form':
      $form['notifications_default_auto'] = array(
        '#type' => 'checkbox',
        '#title' => t('Set all users to "autosubscribe" by default'),
        '#default_value' => variable_get('notifications_default_auto', 0),
        '#description' => t('Sets each users "autosubscribe" profile option.'),
        '#weight' => -10,
      );
      break;
  }
}