]> git.mxchange.org Git - friendica.git/blob - mod/notes.php
Fixes:
[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\Core\L10n;
9 use Friendica\Database\DBA;
10 use Friendica\Database\DBM;
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         $profile = 0;
21
22         $which = $a->user['nickname'];
23
24         Nav::setSelected('home');
25
26         //Profile::load($a, $which, $profile);
27 }
28
29
30 function notes_content(App $a, $update = false)
31 {
32         if (!local_user()) {
33                 notice(L10n::t('Permission denied.') . EOL);
34                 return;
35         }
36
37         require_once 'include/security.php';
38         require_once 'include/conversation.php';
39
40         $o = Profile::getTabs($a, true);
41
42         if (!$update) {
43                 $o .= '<h3>' . L10n::t('Personal Notes') . '</h3>';
44
45                 $x = [
46                         'is_owner' => true,
47                         'allow_location' => (($a->user['allow_location']) ? true : false),
48                         'default_location' => $a->user['default-location'],
49                         'nickname' => $a->user['nickname'],
50                         'lockstate' => 'lock',
51                         'acl' => '',
52                         'bang' => '',
53                         'visitor' => 'block',
54                         'profile_uid' => local_user(),
55                         'button' => L10n::t('Save'),
56                         'acl_data' => '',
57                 ];
58
59                 $o .= status_editor($a, $x, $a->contact['id']);
60         }
61
62         $condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT,
63                 'wall' => false, 'allow_cid' => '<' . $a->contact['id'] . '>', 'contact-id'=> $a->contact['id']];
64
65         $a->set_pager_itemspage(40);
66
67         $params = ['order' => ['created' => true],
68                 'limit' => [$a->pager['start'], $a->pager['itemspage']]];
69         $r = Item::selectForUser(local_user(), ['id'], $condition, $params);
70
71         $count = 0;
72
73         if (DBM::is_result($r)) {
74                 $count = count($r);
75                 $parents_arr = [];
76
77                 while ($rr = Item::fetch($r)) {
78                         $parents_arr[] = $rr['id'];
79                 }
80                 DBA::close($r);
81
82                 $condition = ['uid' => local_user(), 'parent' => $parents_arr];
83                 $result = Item::selectForUser(local_user(), [], $condition);
84
85                 if (DBM::is_result($result)) {
86                         $items = conv_sort(Item::inArray($result), 'commented');
87                         $o .= conversation($a, $items, 'notes', $update);
88                 }
89         }
90
91         $o .= alt_pager($a, $count);
92
93         return $o;
94 }