function _comment_get_display_setting

6.x comment.module _comment_get_display_setting($setting, $node)

Return a current comment display setting

Parameters

$setting: can be one of these: 'mode', 'sort', 'comments_per_page'

$node: The comment node in question.

3 calls to _comment_get_display_setting()
comment_new_page_count in drupal-6.x/modules/comment/comment.module
Calculate page number for first new comment.
comment_render in drupal-6.x/modules/comment/comment.module
Renders comment(s).
template_preprocess_comment_wrapper in drupal-6.x/modules/comment/comment.module
Process variables for comment-wrapper.tpl.php.

File

drupal-6.x/modules/comment/comment.module, line 1890
Enables users to comment on published content.

Code

function _comment_get_display_setting($setting, $node) {
  global $user;

  if (isset($_GET[$setting])) {
    $value = $_GET[$setting];
  }
  else {
    // get the setting's site default
    switch ($setting) {
      case 'mode':
        $default = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED_EXPANDED);
        break;
      case 'sort':
        $default = variable_get('comment_default_order_' . $node->type, COMMENT_ORDER_NEWEST_FIRST);
        break;
      case 'comments_per_page':
        $default = variable_get('comment_default_per_page_' . $node->type, 50);
    }
    if (variable_get('comment_controls_' . $node->type, COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_HIDDEN) {
      // if comment controls are disabled use site default
      $value = $default;
    }
    else {
      // otherwise use the user's setting if set
      if (isset($user->$setting) && $user->$setting) {
        $value = $user->$setting;
      }
      else if (isset($_SESSION['comment_' . $setting]) && $_SESSION['comment_' . $setting]) {
        $value = $_SESSION['comment_' . $setting];
      }
      else {
        $value = $default;
      }
    }
  }
  return $value;
}