]> git.mxchange.org Git - friendica.git/commitdiff
changes on api_direct_messages_box to allow to retrieve conversations and all messages
authorMax Weller <igitt@max-weller.de>
Sat, 23 Jun 2012 17:29:58 +0000 (19:29 +0200)
committerMax Weller <igitt@max-weller.de>
Sat, 23 Jun 2012 17:29:58 +0000 (19:29 +0200)
include/api.php

index e0e759b6182b1b16157fdcca31c07ce5bcb58a0c..e22bcc9e9ade42cf59f90fccb8b2ee03f57845ba 100644 (file)
                
                $start = $page*$count;
                
-       
+    $profile_url = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
                if ($box=="sentbox") {
-                       $sql_extra = "`from-url`='".dbesc( $a->get_baseurl() . '/profile/' . $a->user['nickname'] )."'";
+                       $sql_extra = "`from-url`='".dbesc( $profile_url )."'";
                } elseif ($box=="conversation") {
       $sql_extra = "`parent-uri`='".dbesc( $_GET["uri"] )  ."'";
                } elseif ($box=="all") {
       $sql_extra = "true";
                } elseif ($box=="inbox") {
-                       $sql_extra = "`from-url`!='".dbesc( $a->get_baseurl() . '/profile/' . $a->user['nickname'] )."'";
+                       $sql_extra = "`from-url`!='".dbesc( $profile_url )."'";
                }
                
                $r = q("SELECT * FROM `mail` WHERE uid=%d AND $sql_extra ORDER BY created DESC LIMIT %d,%d",
                
                $ret = Array();
                foreach($r as $item){
-                       switch ($box){
-                               case "inbox":
+                       if ($box == "inbox" || $item['from-url'] != $profile_url){
                                        $recipient = $user_info;
                                        $sender = api_get_user($a,$item['contact-id']);
-                                       break;
-                               case "sentbox":
+      } elseif ($box == "sentbox" || $item['from-url'] != $profile_url){
                                        $recipient = api_get_user($a,$item['contact-id']);
                                        $sender = $user_info;
-                                       break;
                        }
                                
                        $ret[]=Array(
                                'recipient_id'=> $recipient['id'],
                                'recipient_screen_name'=> $recipient['screen_name'],
                                'recipient'=> $recipient,
-                               
-                               
                        );
       //don't send title to regular StatusNET requests to avoid confusing these apps
                        if (isset($_GET["getText"])) {
       } else {
         $ret['text'] = $item['title']."\n".html2plain(bbcode($item['body']), 0);
       }
-      
-      
-                               
                }