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