]> git.mxchange.org Git - friendica.git/blob - mod/notes.php
Merge pull request #6977 from annando/fix-reshare
[friendica.git] / mod / notes.php
1 <?php
2 /**
3  * @file mod/notes.php
4  */
5
6 use Friendica\App;
7 use Friendica\Content\Nav;
8 use Friendica\Content\Pager;
9 use Friendica\Core\L10n;
10 use Friendica\Database\DBA;
11 use Friendica\Model\Item;
12 use Friendica\Model\Profile;
13
14 function notes_init(App $a)
15 {
16         if (! local_user()) {
17                 return;
18         }
19
20         Nav::setSelected('home');
21 }
22
23
24 function notes_content(App $a, $update = false)
25 {
26         if (!local_user()) {
27                 notice(L10n::t('Permission denied.') . EOL);
28                 return;
29         }
30
31         $o = Profile::getTabs($a, true);
32
33         if (!$update) {
34                 $o .= '<h3>' . L10n::t('Personal Notes') . '</h3>';
35
36                 $x = [
37                         'is_owner' => true,
38                         'allow_location' => (($a->user['allow_location']) ? true : false),
39                         'default_location' => $a->user['default-location'],
40                         'nickname' => $a->user['nickname'],
41                         'lockstate' => 'lock',
42                         'acl' => '',
43                         'bang' => '',
44                         'visitor' => 'block',
45                         'profile_uid' => local_user(),
46                         'button' => L10n::t('Save'),
47                         'acl_data' => '',
48                 ];
49
50                 $o .= status_editor($a, $x, $a->contact['id']);
51         }
52
53         $condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT,
54                 'contact-id'=> $a->contact['id']];
55
56         $pager = new Pager($a->query_string, 40);
57
58         $params = ['order' => ['created' => true],
59                 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
60         $r = Item::selectThreadForUser(local_user(), ['uri'], $condition, $params);
61
62         $count = 0;
63
64         if (DBA::isResult($r)) {
65                 $notes = Item::inArray($r);
66
67                 $count = count($notes);
68
69                 $o .= conversation($a, $notes, $pager, 'notes', $update);
70         }
71
72         $o .= $pager->renderMinimal($count);
73
74         return $o;
75 }