You are here

function _comment_get_display_setting in Drupal 5

Same name and namespace in other branches
  1. 4 modules/comment.module \_comment_get_display_setting()
  2. 6 modules/comment/comment.module \_comment_get_display_setting()

Return a current comment display setting

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

1 call to _comment_get_display_setting()
comment_render in modules/comment/comment.module
Renders comment(s).

File

modules/comment/comment.module, line 1910
Enables users to comment on published content.

Code

function _comment_get_display_setting($setting) {
  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', COMMENT_MODE_THREADED_EXPANDED);
        break;
      case 'sort':
        $default = variable_get('comment_default_order', COMMENT_ORDER_NEWEST_FIRST);
        break;
      case 'comments_per_page':
        $default = variable_get('comment_default_per_page', '50');
    }
    if (variable_get('comment_controls', 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 ($user->{$setting}) {
        $value = $user->{$setting};
      }
      else {
        if ($_SESSION['comment_' . $setting]) {
          $value = $_SESSION['comment_' . $setting];
        }
        else {
          $value = $default;
        }
      }
    }
  }
  return $value;
}