Update threads history

Do not show threads related with ignored or rejected invitations.
This commit is contained in:
Dmitriy Simushev 2013-05-24 11:53:12 +00:00
parent bc287f0e11
commit 3fc6218332
2 changed files with 16 additions and 5 deletions

View File

@ -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",

View File

@ -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)
);
}