]> git.mxchange.org Git - friendica.git/blobdiff - mod/notes.php
Catch HTTPExceptions in App::runFrontend()
[friendica.git] / mod / notes.php
index 99114add8c87a6e2971f65f0795b19d3b17eca3d..6ecc819240ff67d817f27dc9ee91c7aa540d61ec 100644 (file)
@@ -2,12 +2,14 @@
 /**
  * @file mod/notes.php
  */
+
 use Friendica\App;
 use Friendica\Content\Nav;
+use Friendica\Content\Pager;
 use Friendica\Core\L10n;
-use Friendica\Database\DBM;
-use Friendica\Model\Profile;
+use Friendica\Database\DBA;
 use Friendica\Model\Item;
+use Friendica\Model\Profile;
 
 function notes_init(App $a)
 {
@@ -32,9 +34,6 @@ function notes_content(App $a, $update = false)
                return;
        }
 
-       require_once 'include/security.php';
-       require_once 'include/conversation.php';
-
        $o = Profile::getTabs($a, true);
 
        if (!$update) {
@@ -57,35 +56,26 @@ 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,
+               'contact-id'=> $a->contact['id']];
 
-       $a->set_pager_total($notes);
-       $a->set_pager_itemspage(40);
+       $pager = new Pager($a->query_string, 40);
 
        $params = ['order' => ['created' => true],
-               'limit' => [$a->pager['start'], $a->pager['itemspage']]];
-       $r = Item::selectForUser(local_user(), ['item_id'], $condition, $params);
-
-       if (DBM::is_result($r)) {
-               $parents_arr = [];
-
-               while ($rr = Item::fetch($r)) {
-                       $parents_arr[] = $rr['item_id'];
-               }
-               dba::close($r);
-
-               $condition = ['uid' => local_user(), 'parent' => $parents_arr];
-               $result = Item::selectForUser(local_user(), [], $condition);
-               if (DBM::is_result($result)) {
-                       $items = conv_sort(Item::inArray($result), 'commented');
-                       $o .= conversation($a, $items, 'notes', $update);
-               }
+               'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
+       $r = Item::selectThreadForUser(local_user(), ['uri'], $condition, $params);
+
+       $count = 0;
+
+       if (DBA::isResult($r)) {
+               $notes = Item::inArray($r);
+
+               $count = count($notes);
+
+               $o .= conversation($a, $notes, $pager, 'notes', $update);
        }
 
-       $o .= paginate($a);
+       $o .= $pager->renderMinimal($count);
+
        return $o;
 }