You are here

function comment_notify_settings in Comment Notify 7

Same name and namespace in other branches
  1. 5.2 comment_notify.module \comment_notify_settings()
  2. 5 comment_notify.module \comment_notify_settings()
  3. 6 comment_notify.module \comment_notify_settings()

Page callback for administrative settings form.

1 string reference to 'comment_notify_settings'
comment_notify_menu in ./comment_notify.module
Implements hook_menu().

File

./comment_notify.module, line 603
This module provides comment follow-up e-mail notification for anonymous and registered users.

Code

function comment_notify_settings() {
  module_load_include('inc', 'comment_notify', 'comment_notify');
  $form['comment_notify_settings'] = array();

  // Only perform comment_notify for certain node types.
  $enabled_types = comment_notify_variable_registry_get('node_types');
  $anonymous_problems = array();
  foreach (node_type_get_names() as $type => $name) {
    $checkboxes[$type] = check_plain($name);

    // If they don't have the ability to leave contact info, then we make a
    // report.
    if (isset($enabled_types[$type]) && $enabled_types[$type] && variable_get('comment_anonymous_' . $type, COMMENT_ANONYMOUS_MAYNOT_CONTACT) == COMMENT_ANONYMOUS_MAYNOT_CONTACT) {
      $account = drupal_anonymous_user();
      if (user_access('subscribe to comments', $account)) {
        $anonymous_problems[] = l(t('@content-type', array(
          '@content-type' => $name,
        )), 'admin/structure/types/manage/' . $type);
      }
    }
  }
  if (!empty($anonymous_problems)) {
    drupal_set_message(t('Anonymous commenters have the permission to subscribe to comments but cannot leave their contact information on the following content types: !types.  You should either disable subscriptions on those types here, revoke the permission for anonymous users, or enable anonymous users to leave their contact information in the comment settings.', array(
      '!types' => implode(', ', $anonymous_problems),
    )), 'status', FALSE);
  }
  $form['comment_notify_settings']['comment_notify_node_types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Content types to enable for comment notification'),
    '#default_value' => $enabled_types,
    '#options' => $checkboxes,
    '#description' => t('Comments on content types enabled here will have the option of comment notification.'),
  );
  $form['comment_notify_settings']['comment_notify_available_alerts'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Available subscription modes'),
    '#return_value' => 1,
    '#default_value' => comment_notify_variable_registry_get('available_alerts'),
    '#description' => t('Choose which notification subscription styles are available for users'),
    '#options' => array(
      COMMENT_NOTIFY_NODE => t('All comments'),
      COMMENT_NOTIFY_COMMENT => t('Replies to my comment'),
    ),
  );
  $available_options[COMMENT_NOTIFY_DISABLED] = t('No notifications');
  $available_options += _comment_notify_options();
  $form['comment_notify_settings']['comment_notify_default_anon_mailalert'] = array(
    '#type' => 'select',
    '#title' => t('Default state for the notification selection box for anonymous users'),
    '#return_value' => 1,
    '#default_value' => comment_notify_variable_registry_get('default_anon_mailalert'),
    '#options' => $available_options,
  );
  $form['comment_notify_settings']['comment_notify_default_registered_mailalert'] = array(
    '#type' => 'select',
    '#title' => t('Default state for the notification selection box for registered users'),
    '#return_value' => 1,
    '#default_value' => comment_notify_variable_registry_get('default_registered_mailalert'),
    '#description' => t('This flag presets the flag for the follow-up notification on the form that anon users will see when posting a comment'),
    '#options' => $available_options,
  );
  $form['comment_notify_settings']['comment_notify_node_notify_default_mailalert'] = array(
    '#type' => 'checkbox',
    '#title' => t('Subscribe users to their node follow-up notification emails by default'),
    '#default_value' => comment_notify_variable_registry_get('node_notify_default_mailalert'),
    '#description' => t('If this is checked, new users will receive e-mail notifications for follow-ups on their nodes by default until they individually disable the feature.'),
  );
  $form['comment_notify_settings']['comment_notify_comment_notify_default_mailtext'] = array(
    '#type' => 'textarea',
    '#title' => t('Default mail text for sending out notifications to commenters'),
    '#default_value' => comment_notify_variable_registry_get('comment_notify_default_mailtext'),
    '#return_value' => 1,
    '#cols' => 80,
    '#rows' => 15,
    '#token_types' => array(
      'comment',
    ),
    '#element_validate' => array(
      'token_element_validate',
    ),
  );
  $form['comment_notify_settings']['comment_notify_node_notify_default_mailtext'] = array(
    '#type' => 'textarea',
    '#title' => t('Default mail text for sending out the notifications to node authors'),
    '#default_value' => comment_notify_variable_registry_get('node_notify_default_mailtext'),
    '#return_value' => 1,
    '#cols' => 80,
    '#rows' => 15,
    '#token_types' => array(
      'comment',
    ),
    '#element_validate' => array(
      'token_element_validate',
    ),
  );
  $form['comment_notify_settings']['token_help'] = array(
    '#theme' => 'token_tree',
    '#token_types' => array(
      'comment',
    ),
  );
  $form['#validate'] = array(
    'comment_notify_settings_validate',
  );
  return system_settings_form($form);
}