]> git.mxchange.org Git - friendica.git/blob - mod/notes.php
Move Composer autoload require out of boot.php
[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         $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         $o = Profile::getTabs($a, true);
38
39         if (!$update) {
40                 $o .= '<h3>' . L10n::t('Personal Notes') . '</h3>';
41
42                 $x = [
43                         'is_owner' => true,
44                         'allow_location' => (($a->user['allow_location']) ? true : false),
45                         'default_location' => $a->user['default-location'],
46                         'nickname' => $a->user['nickname'],
47                         'lockstate' => 'lock',
48                         'acl' => '',
49                         'bang' => '',
50                         'visitor' => 'block',
51                         'profile_uid' => local_user(),
52                         'button' => L10n::t('Save'),
53                         'acl_data' => '',
54                 ];
55
56                 $o .= status_editor($a, $x, $a->contact['id']);
57         }
58
59         $condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT,
60                 'contact-id'=> $a->contact['id']];
61
62         $pager = new Pager($a->query_string, 40);
63
64         $params = ['order' => ['created' => true],
65                 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
66         $r = Item::selectThreadForUser(local_user(), ['uri'], $condition, $params);
67
68         $count = 0;
69
70         if (DBA::isResult($r)) {
71                 $notes = Item::inArray($r);
72
73                 $count = count($notes);
74
75                 $o .= conversation($a, $notes, $pager, 'notes', $update);
76         }
77
78         $o .= $pager->renderMinimal($count);
79
80         return $o;
81 }