aboutsummaryrefslogtreecommitdiffstats
path: root/include/message.php
diff options
context:
space:
mode:
authormrjive <mrjive@mrjive.it>2015-09-29 08:01:51 +0200
committermrjive <mrjive@mrjive.it>2015-09-29 08:01:51 +0200
commit11c1573b55f278a664a90a2872d06a40b3ac3026 (patch)
tree4061879d490fec39ab01d3feeb575b86586fb7f8 /include/message.php
parent006ca4421a7027ccee4612beb99a1f9976146070 (diff)
parentb3525b865784ff5d2d5a76b913b8c86d139cc0f3 (diff)
downloadvolse-hubzilla-11c1573b55f278a664a90a2872d06a40b3ac3026.tar.gz
volse-hubzilla-11c1573b55f278a664a90a2872d06a40b3ac3026.tar.bz2
volse-hubzilla-11c1573b55f278a664a90a2872d06a40b3ac3026.zip
Merge pull request #5 from redmatrix/master
updating from original codebase
Diffstat (limited to 'include/message.php')
-rw-r--r--include/message.php34
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
+}