You are here

function _forum_get_topic_order in Drupal 7

Same name and namespace in other branches
  1. 4 modules/forum.module \_forum_get_topic_order()
  2. 5 modules/forum/forum.module \_forum_get_topic_order()
  3. 6 modules/forum/forum.module \_forum_get_topic_order()

Gets topic sorting information based on an integer code.

Parameters

$sortby: One of the following integers indicating the sort criteria:

  • 1: Date - newest first.
  • 2: Date - oldest first.
  • 3: Posts with the most comments first.
  • 4: Posts with the least comments first.

Return value

An array with the following values:

  • field: A field for an SQL query.
  • sort: 'asc' or 'desc'.
1 call to _forum_get_topic_order()
forum_get_topics in modules/forum/forum.module
Gets all the topics in a forum.

File

modules/forum/forum.module, line 1317
Provides discussion forums.

Code

function _forum_get_topic_order($sortby) {
  switch ($sortby) {
    case 1:
      return array(
        'field' => 'f.last_comment_timestamp',
        'sort' => 'desc',
      );
      break;
    case 2:
      return array(
        'field' => 'f.last_comment_timestamp',
        'sort' => 'asc',
      );
      break;
    case 3:
      return array(
        'field' => 'f.comment_count',
        'sort' => 'desc',
      );
      break;
    case 4:
      return array(
        'field' => 'f.comment_count',
        'sort' => 'asc',
      );
      break;
  }
}