You are here

function comment_notify_settings in Comment Notify 6

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. 7 comment_notify.module \comment_notify_settings()
1 string reference to 'comment_notify_settings'
comment_notify_menu in ./comment_notify.module
Implementation of hook_menu().

File

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

Code

function comment_notify_settings() {
  $form['comment_notify_settings'] = array();

  // Only perform comment_notify for certain node types (default, all)
  $enabled_types = variable_get('comment_notify_node_types', FALSE);
  $anonymous_problems = '';
  foreach (node_get_types('names') as $type => $name) {
    $type_url_str = str_replace('_', '-', $type);

    // Underscores in the content type need to be changed to hyphens for the path link.
    $checkboxes[$type] = check_plain($name);
    $default[] = $type;

    // 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 = user_load(array(
        'uid' => 0,
      ));
      if (user_access('subscribe to comments', $account)) {
        $anonymous_problems[] = l(t('@content-type', array(
          '@content-type' => $name,
        )), 'admin/content/node-type/' . $type_url_str);
      }
    }
  }
  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' => variable_get('comment_notify_node_types', $default),
    '#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' => variable_get('comment_notify_available_alerts', array(
      COMMENT_NOTIFY_NODE,
      COMMENT_NOTIFY_COMMENT,
    )),
    '#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' => variable_get('comment_notify_default_anon_mailalert', COMMENT_NOTIFY_NODE),
    '#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' => variable_get('comment_notify_default_registered_mailalert', COMMENT_NOTIFY_NODE),
    '#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']['node_notify_default_mailalert'] = array(
    '#type' => 'checkbox',
    '#title' => t('Subscribe users to their node follow-up notification emails by default'),
    '#default_value' => variable_get('node_notify_default_mailalert', FALSE),
    '#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_default_mailtext'] = array(
    '#type' => 'textarea',
    '#title' => t('Default mail text for sending out notifications to commenters'),
    '#description' => t('You can use the following variables to be replaced:
      <ul>
      <li>!cid = the comment id for the comment</li>
      <li>!commname = the username who posted the comment</li>
      <li>!commtext = the text of the posted comment</li>
      <li>!commsubj = the subject of the posted comment</li>
      <li>!comment_url = the full url of the post and comment - note: if you have paging enabled, this does not work correct - set your max comments per page so that all fit on one page or reverse order them</li>
      <li>!nid = the node id the comment was posted on</li>
      <li>!node_title = the title of the node that was commented on</li>
      <li>!node_teaser = the teaser of the node that was commented on</li>
      <li>!node_body = the body of the node that was commented on</li>
      <li>!mission = site_mission text</li>
      <li>!name = username receiving the alert</li>
      <li>!site = your site</li>
      <li>!uri = base_url of site</li>
      <li>!uri_brief = base_url of site w/o http</li>
      <li>!date = the current time</li>
      <li>!login_uri  uri to login the user</li>
      <li>!edit_uri = uri to edit user profile</li>
      <li>!link1 the QUICKLINK to disable future follow-up notifications for the user</li>
      </ul>'),
    '#default_value' => variable_get('comment_notify_default_mailtext', t(DEFAULT_MAILTEXT)),
    '#return_value' => 1,
    '#cols' => 80,
    '#rows' => 15,
  );
  $form['comment_notify_settings']['node_notify_default_mailtext'] = array(
    '#type' => 'textarea',
    '#title' => t('Default mail text for sending out the notifications to node authors'),
    '#description' => t('You can use the following variables to be replaced:
      <ul>
      <li>!cid = the comment id for the comment</li>
      <li>!commname = the username who posted the comment</li>
      <li>!commtext = the text of the posted comment</li>
      <li>!commsubj = the subject of the posted comment</li>
      <li>!comment_url = the full url of the post and comment - note: if you have paging enabled, this does not work correct - set your max comments per page so that all fit on one page or reverse order them</li>
      <li>!nid = the node id the comment was posted on</li>
      <li>!node_title = the title of the node that was commented on</li>
      <li>!node_teaser = the teaser of the node that was commented on</li>
      <li>!node_body = the body of the node that was commented on</li>
      <li>!mission = site_mission text</li>
      <li>!name = username receiving the alert</li>
      <li>!site = your site</li>
      <li>!uri = base_url of site</li>
      <li>!uri_brief = base_url of site w/o http</li>
      <li>!date = the current time</li>
      <li>!login_uri  uri to login the user</li>
      <li>!edit_uri = uri to edit user profile</li>
      </ul>'),
    '#default_value' => variable_get('node_notify_default_mailtext', t(AUTHOR_MAILTEXT)),
    '#return_value' => 1,
    '#cols' => 80,
    '#rows' => 15,
  );
  $form['#validate'] = array(
    'comment_notify_settings_validate',
  );
  return system_settings_form($form);
}