]> git.mxchange.org Git - friendica.git/blob - mod/notes.php
Improve Console/Config display for array values
[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` = ? AND `type` = 'note' AND `gravity` = ? AND NOT `wall`
61                 AND `allow_cid` = ? AND `contact-id` = ?",
62                 local_user(), GRAVITY_PARENT, '<' . $a->contact['id'] . '>', $a->contact['id']];
63
64         $notes = dba::count('item', $condition);
65
66         $a->set_pager_total($notes);
67         $a->set_pager_itemspage(40);
68
69         $params = ['order' => ['created' => true],
70                 'limit' => [$a->pager['start'], $a->pager['itemspage']]];
71         $r = Item::selectForUser(local_user(), ['id'], $condition, $params);
72
73         if (DBM::is_result($r)) {
74                 $parents_arr = [];
75
76                 while ($rr = Item::fetch($r)) {
77                         $parents_arr[] = $rr['id'];
78                 }
79                 dba::close($r);
80
81                 $condition = ['uid' => local_user(), 'parent' => $parents_arr];
82                 $result = Item::selectForUser(local_user(), [], $condition);
83                 if (DBM::is_result($result)) {
84                         $items = conv_sort(Item::inArray($result), 'commented');
85                         $o .= conversation($a, $items, 'notes', $update);
86                 }
87         }
88
89         $o .= paginate($a);
90         return $o;
91 }