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