]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Contact.php
The "file" variable isn't stored anymore in the item table
[friendica.git] / src / Model / Contact.php
index bf5b276dd2e39c621c38ed20ab875a70226a5955..fe9869c6f88065386a8a918b11ac88e555e5096a 100644 (file)
@@ -1055,24 +1055,26 @@ class Contact extends BaseObject
                }
 
                if (in_array($r[0]["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""])) {
-                       $sql = "(`item`.`uid` = 0 OR (`item`.`uid` = %d AND NOT `item`.`global`))";
+                       $sql = "(`item`.`uid` = 0 OR (`item`.`uid` = ? AND NOT `item`.`global`))";
                } else {
-                       $sql = "`item`.`uid` = %d";
+                       $sql = "`item`.`uid` = ?";
                }
 
                $author_id = intval($r[0]["author-id"]);
 
                $contact = ($r[0]["contact-type"] == ACCOUNT_TYPE_COMMUNITY ? 'owner-id' : 'author-id');
 
-               $r = q(item_query(local_user()) . " AND `item`.`" . $contact . "` = %d AND " . $sql .
-                       " AND `item`.`verb` = '%s' ORDER BY `item`.`created` DESC LIMIT %d, %d",
-                       intval($author_id), intval(local_user()), dbesc(ACTIVITY_POST),
-                       intval($a->pager['start']), intval($a->pager['itemspage'])
-               );
+               $condition = ["`$contact` = ? AND `gravity` IN (?, ?) AND " . $sql,
+                       $author_id, GRAVITY_PARENT, GRAVITY_COMMENT, local_user()];
+               $params = ['order' => ['created' => true],
+                       'limit' => [$a->pager['start'], $a->pager['itemspage']]];
+               $r = Item::selectForUser(local_user(), [], $condition, $params);
+
+               $items = Item::inArray($r);
 
-               $o = conversation($a, $r, 'contact-posts', false);
+               $o = conversation($a, $items, 'contact-posts', false);
 
-               $o .= alt_pager($a, count($r));
+               $o .= alt_pager($a, count($items));
 
                return $o;
        }