diff options
author | zottel <github@zottel.net> | 2015-09-25 11:19:42 +0200 |
---|---|---|
committer | zottel <github@zottel.net> | 2015-09-25 11:19:42 +0200 |
commit | a7b2d23e9b59805a35380478ca3501fc315edb78 (patch) | |
tree | a2f6517fa09b83419403b93663e3ccd187fa3fbf /include/message.php | |
parent | 03fb13e7497457d5fe69fc8ed007e5e49a2d6d8a (diff) | |
parent | ba94f824b992f9ed787a71c2956388e975058ca8 (diff) | |
download | volse-hubzilla-a7b2d23e9b59805a35380478ca3501fc315edb78.tar.gz volse-hubzilla-a7b2d23e9b59805a35380478ca3501fc315edb78.tar.bz2 volse-hubzilla-a7b2d23e9b59805a35380478ca3501fc315edb78.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'include/message.php')
-rw-r--r-- | include/message.php | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/include/message.php b/include/message.php index efe1a7710..4b0236db8 100644 --- a/include/message.php +++ b/include/message.php @@ -262,18 +262,30 @@ function private_messages_list($uid, $mailbox = '', $start = 0, $numitems = 0) { ); if(! $x) return array(); - if($mailbox === 'inbox') - $where = " and sender_xchan != '" . dbesc($x[0]['channel_hash']) . "' "; - elseif($mailbox === 'outbox') - $where = " and sender_xchan = '" . dbesc($x[0]['channel_hash']) . "' "; + + $channel_hash = dbesc($x[0]['channel_hash']); + $local_channel = intval(local_channel()); + + switch($mailbox) { + + case 'inbox': + $sql = "SELECT * FROM mail WHERE channel_id = $local_channel AND from_xchan != '$channel_hash' ORDER BY created DESC $limit"; + break; + + case 'outbox': + $sql = "SELECT * FROM mail WHERE channel_id = $local_channel AND from_xchan = '$channel_hash' ORDER BY created DESC $limit"; + break; + + case 'combined': + $sql = "SELECT * FROM ( SELECT * FROM mail WHERE channel_id = $local_channel ORDER BY created DESC $limit ) AS temp_table GROUP BY parent_mid ORDER BY created DESC"; + break; + + } + } - // For different orderings, consider applying usort on the results. We thought of doing that - // inside this function or having some preset sorts, but don't wish to limit app developers. - - $r = q("SELECT * from mail WHERE channel_id = %d $where order by created desc $limit", - intval(local_channel()) - ); + $r = q($sql); + if(! $r) { return array(); } @@ -437,4 +449,4 @@ function private_messages_fetch_conversation($channel_id, $messageitem_id, $upda return $messages; -}
\ No newline at end of file +} |