3 * @copyright Copyright (C) 2010-2021, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 use Friendica\Content\Nav;
24 use Friendica\Content\Pager;
25 use Friendica\Database\DBA;
27 use Friendica\Model\Item;
28 use Friendica\Model\Post;
29 use Friendica\Module\BaseProfile;
31 function notes_init(App $a)
37 Nav::setSelected('home');
41 function notes_content(App $a, $update = false)
44 notice(DI::l10n()->t('Permission denied.'));
48 $o = BaseProfile::getTabsHTML($a, 'notes', true);
51 $o .= '<h3>' . DI::l10n()->t('Personal Notes') . '</h3>';
55 'allow_location' => (($a->user['allow_location']) ? true : false),
56 'default_location' => $a->user['default-location'],
57 'nickname' => $a->user['nickname'],
58 'lockstate' => 'lock',
59 'acl' => \Friendica\Core\ACL::getSelfOnlyHTML(local_user(), DI::l10n()->t('Personal notes are visible only by yourself.')),
62 'profile_uid' => local_user(),
63 'button' => DI::l10n()->t('Save'),
67 $o .= status_editor($a, $x, $a->contact['id']);
70 $condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT,
71 'contact-id'=> $a->contact['id']];
73 if (DI::mode()->isMobile()) {
74 $itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
75 DI::config()->get('system', 'itemspage_network_mobile'));
77 $itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
78 DI::config()->get('system', 'itemspage_network'));
81 $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemsPerPage);
83 $params = ['order' => ['created' => true],
84 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
85 $r = Post::selectThreadForUser(local_user(), ['uri-id'], $condition, $params);
89 if (DBA::isResult($r)) {
90 $notes = Post::toArray($r);
92 $count = count($notes);
94 $o .= conversation($a, $notes, 'notes', $update);
97 $o .= $pager->renderMinimal($count);