From 3fc6218332c26b49cd1bfa7334a2c7f69adec87f Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Fri, 24 May 2013 11:53:12 +0000 Subject: [PATCH] Update threads history Do not show threads related with ignored or rejected invitations. --- src/messenger/webim/operator/history.php | 6 +++++- src/messenger/webim/operator/userhistory.php | 15 +++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/messenger/webim/operator/history.php b/src/messenger/webim/operator/history.php index 33377b41..2523d2f8 100644 --- a/src/messenger/webim/operator/history.php +++ b/src/messenger/webim/operator/history.php @@ -49,7 +49,9 @@ if ($query !== false) { $page['groupName'] = $groupName; $values = array( - ':query' => "%{$query}%" + ':query' => "%{$query}%", + ':invitation_accepted' => Thread::INVITATION_ACCEPTED, + ':invitation_not_invited' => Thread::INVITATION_NOT_INVITED ); $searchConditions = array(); @@ -75,6 +77,8 @@ if ($query !== false) { "{chatthread}, {indexedchatmessage}", array( "{indexedchatmessage}.threadid = {chatthread}.threadid", + "({chatthread}.invitationstate = :invitation_accepted " . + "OR {chatthread}.invitationstate = :invitation_not_invited)", "(" . implode(' or ', $searchConditions) . ")" ), "order by {chatthread}.dtmcreated DESC", diff --git a/src/messenger/webim/operator/userhistory.php b/src/messenger/webim/operator/userhistory.php index 58f52071..af8a7dfc 100644 --- a/src/messenger/webim/operator/userhistory.php +++ b/src/messenger/webim/operator/userhistory.php @@ -40,10 +40,17 @@ function threads_by_userid($userid) } return $db->query( - "select {chatthread}.* " . - "from {chatthread} " . - "where userid=? order by dtmcreated DESC", - array($userid), + "SELECT {chatthread}.* " . + "FROM {chatthread} " . + "WHERE userid=:user_id " . + "AND (invitationstate = :invitation_accepted " . + "OR invitationstate = :invitation_not_invited) " . + "ORDER BY dtmcreated DESC", + array( + ':user_id' => $userid, + ':invitation_accepted' => Thread::INVITATION_ACCEPTED, + ':invitation_not_invited' => Thread::INVITATION_NOT_INVITED + ), array('return_rows' => Database::RETURN_ALL_ROWS) ); }