diff --git a/drupal/sites/default/boinc/modules/boinccore/boinccore.module b/drupal/sites/default/boinc/modules/boinccore/boinccore.module index 638cad764d..36ec03ee87 100644 --- a/drupal/sites/default/boinc/modules/boinccore/boinccore.module +++ b/drupal/sites/default/boinc/modules/boinccore/boinccore.module @@ -340,11 +340,17 @@ function boinccore_url_pagination_handler($type, $object_id) { $object = _comment_load($object_id); if ($object) { $path = "node/{$object->nid}"; - // See how many comments there are before this comment... + // Get the sort order + $gt_lt = '<'; + $comment_order = (isset($user->sort)) ? $user->sort : variable_get('comment_default_order_forum', 2); + if ($comment_order == COMMENT_ORDER_NEWEST_FIRST) { + $gt_lt = '>'; + } + // See how many comments there are before (or after) this comment... $comment_offset = db_result(db_query(' SELECT COUNT(*) FROM {comments} - WHERE nid = %d AND status = 0 AND timestamp < %d', - $object->nid, $object->timestamp)); + WHERE nid = %d AND status = 0 AND timestamp %s %d', + $object->nid, $gt_lt, $object->timestamp)); if ($comment_offset) { // Get the number of comments per page if ($user->comments_per_page) { diff --git a/drupal/sites/default/boinc/modules/boincwork/includes/boincwork.forms.inc b/drupal/sites/default/boinc/modules/boincwork/includes/boincwork.forms.inc index fe9f1eb557..d57199abb1 100644 --- a/drupal/sites/default/boinc/modules/boincwork/includes/boincwork.forms.inc +++ b/drupal/sites/default/boinc/modules/boincwork/includes/boincwork.forms.inc @@ -1055,7 +1055,8 @@ function communityprefs_form(&$form_state) { $default = array( 'pm_send_notification' => '', // This is set already in pm_email_notify_user 'friend_notification' => isset($account->friend_notification) ? $account->friend_notification : 0, - 'comments_per_page' => (isset($account->comments_per_page) AND $account->comments_per_page) ? $account->comments_per_page : variable_get('comment_default_per_page_forum', 50) + 'comments_per_page' => (isset($account->comments_per_page) AND $account->comments_per_page) ? $account->comments_per_page : variable_get('comment_default_per_page_forum', 50), + 'comments_order' => (isset($account->sort) AND $account->sort) ? $account->sort : variable_get('comment_default_order_forum', COMMENT_ORDER_OLDEST_FIRST), ); // General options @@ -1134,6 +1135,12 @@ function communityprefs_form(&$form_state) { // Can't have a typical Drupal form suffix on a select box? $form['forums']['comments_per_page_suffix'] = array( '#value' => '' . t('comments per page') . '' + ); + $form['forums']['comments_order'] = array( + '#type' => 'select', + '#title' => t('Sort comments in discussions'), + '#options' => array(1 => t('Newest post first'), 2 => t('Oldest post first')), + '#default_value' => $default['comments_order'] ); // Signature (pulled from user_edit_form): if (variable_get('user_signatures', 0) && module_exists('comment')) { @@ -1205,7 +1212,8 @@ function communityprefs_form_submit($form, &$form_state) { 'signature_format' => $edit['signature_format'], 'timezone' => $edit['timezone'], 'friend_notification' => $edit['friend_notification'], - 'comments_per_page' => $edit['comments_per_page'] + 'comments_per_page' => $edit['comments_per_page'], + 'sort' => $edit['comments_order'], )); }