Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

[2.2.4] Private Messages - Change display order?

ZhaanZhaan ✭✭
edited May 2014 in Vanilla 2.0 - 2.8

Hiya! I've got a question for you VF gurus: how can I make conversations display the latest messages on top? As in, newest to oldest (from top to bottom) instead of the opposite. My users have been complaining about this for some time now, but I'm not sure how to fix it.

Is it doable somehow? I'd appreciate any help!

Comments

  • R_JR_J Admin

    In theory you would have to hook into the conversationmessage model (https://github.com/vanilla/vanilla/blob/master/applications/conversations/models/class.conversationmessagemodel.php#L57) but the way the event is fired, you will not be able to change the sort order. So the easiest solution would be to change 'asc' to 'desc' in line 72. Since you are using alpha software, it doesn't make it much worse... :-/

    But you could also do something positive: how about making a pull request like that?

          $this->SQL
             ->Select('cm.*')
             ->Select('iu.Name', '', 'InsertName')
             ->Select('iu.Email', '', 'InsertEmail')
             ->Select('iu.Photo', '', 'InsertPhoto')
             ->From('ConversationMessage cm')
             ->Join('Conversation c', 'cm.ConversationID = c.ConversationID')
             ->Join('UserConversation uc', 'c.ConversationID = uc.ConversationID and uc.UserID = '.$ViewingUserID, 'left')
             ->Join('User iu', 'cm.InsertUserID = iu.UserID', 'left')
             ->BeginWhereGroup()
             ->Where('uc.DateCleared is null')
             ->OrWhere('uc.DateCleared <', 'cm.DateInserted', TRUE, FALSE) // Make sure that cleared conversations do not show up unless they have new messages added.
             ->EndWhereGroup()
             ->Where('cm.ConversationID', $ConversationID)
             ->OrderBy('cm.DateInserted', 'asc')
             ->Limit($Limit, $Offset);
          $this->FireEvent('BeforeGet');
          return $this->SQL->Get();
    
Sign In or Register to comment.