]> git.mxchange.org Git - friendica.git/blobdiff - mod/notes.php
Uncommon logger levels in Friendica (#5453)
[friendica.git] / mod / notes.php
index fb42408c60387a8cbc11f994d61a7ba5884cd399..f83195ff1ccdb1e1a16f75375d8df20bd1b27ad9 100644 (file)
@@ -2,12 +2,14 @@
 /**
  * @file mod/notes.php
  */
+
 use Friendica\App;
 use Friendica\Content\Nav;
 use Friendica\Core\L10n;
+use Friendica\Database\DBA;
 use Friendica\Database\DBM;
-use Friendica\Model\Profile;
 use Friendica\Model\Item;
+use Friendica\Model\Profile;
 
 function notes_init(App $a)
 {
@@ -57,35 +59,31 @@ function notes_content(App $a, $update = false)
                $o .= status_editor($a, $x, $a->contact['id']);
        }
 
-       $condition = ["`uid` = ? AND `type` = 'note' AND `id` = `parent` AND NOT `wall`
-               AND `allow_cid` = ? AND `contact-id` = ?",
-               local_user(), '<' . $a->contact['id'] . '>', $a->contact['id']];
-
-       $notes = dba::count('item', $condition);
+       $condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT,
+               'wall' => false, 'allow_cid' => '<' . $a->contact['id'] . '>', 'contact-id'=> $a->contact['id']];
 
-       $a->set_pager_total($notes);
        $a->set_pager_itemspage(40);
 
        $params = ['order' => ['created' => true],
                'limit' => [$a->pager['start'], $a->pager['itemspage']]];
-       $r = Item::select(local_user(), ['item_id'], $condition, $params);
+       $r = Item::selectForUser(local_user(), ['id'], $condition, $params);
 
        if (DBM::is_result($r)) {
                $parents_arr = [];
 
-               while ($rr = dba::fetch($r)) {
-                       $parents_arr[] = $rr['item_id'];
+               while ($rr = Item::fetch($r)) {
+                       $parents_arr[] = $rr['id'];
                }
-               dba::close($r);
+               DBA::close($r);
 
                $condition = ['uid' => local_user(), 'parent' => $parents_arr];
-               $result = Item::select(local_user(), [], $condition);
+               $result = Item::selectForUser(local_user(), [], $condition);
                if (DBM::is_result($result)) {
-                       $items = conv_sort(dba::inArray($result), 'commented');
+                       $items = conv_sort(Item::inArray($result), 'commented');
                        $o .= conversation($a, $items, 'notes', $update);
                }
        }
 
-       $o .= paginate($a);
+       $o .= alt_pager($a, count($r));
        return $o;
 }