]> git.mxchange.org Git - friendica.git/blobdiff - mod/notes.php
And now the notes
[friendica.git] / mod / notes.php
index aa239fb0e0040b1aff493747bc2529c7ab9016ef..f1a82bd4579207df774950cf9a0b9eaf6342eae5 100644 (file)
@@ -7,6 +7,7 @@ use Friendica\Content\Nav;
 use Friendica\Core\L10n;
 use Friendica\Database\DBM;
 use Friendica\Model\Profile;
+use Friendica\Model\Item;
 
 function notes_init(App $a)
 {
@@ -82,7 +83,7 @@ function notes_content(App $a, $update = false)
                WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
                AND `contact`.`self` AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
                $sql_extra ",
-               item_joins(),
+               item_joins(local_user()),
                item_condition(),
                intval(local_user())
        );
@@ -97,7 +98,7 @@ function notes_content(App $a, $update = false)
                AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
                $sql_extra
                ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
-               item_joins(),
+               item_joins(local_user()),
                item_condition(),
                intval(local_user()),
                intval($a->pager['start']),
@@ -112,22 +113,11 @@ function notes_content(App $a, $update = false)
                foreach ($r as $rr) {
                        $parents_arr[] = $rr['item_id'];
                }
-               $parents_str = implode(', ', $parents_arr);
-
-               $r = q("SELECT %s FROM `item` %s
-                       WHERE %s AND `item`.`uid` = %d AND `item`.`parent` IN (%s)
-                       $sql_extra
-                       ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ",
-                       item_fieldlists(),
-                       item_joins(),
-                       item_condition(),
-                       intval(local_user()),
-                       dbesc($parents_str)
-               );
-
-               if (DBM::is_result($r)) {
-                       $items = conv_sort($r, "`commented`");
 
+               $condition = ['uid' => local_user(), 'parent' => $parents_arr];
+               $result = Item::select(local_user(), [], $condition);
+               if (DBM::is_result($result)) {
+                       $items = conv_sort(dba::inArray($result), 'commented');
                        $o .= conversation($a, $items, 'notes', $update);
                }
        }