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;
12 function notes_init(App $a)
20 $which = $a->user['nickname'];
22 Nav::setSelected('home');
24 //Profile::load($a, $which, $profile);
28 function notes_content(App $a, $update = false)
31 notice(L10n::t('Permission denied.') . EOL);
35 require_once 'include/security.php';
36 require_once 'include/conversation.php';
42 $remote_contact = false;
44 $contact_id = $_SESSION['cid'];
45 $contact = $a->contact;
50 $o .= Profile::getTabs($a, true);
53 $o .= '<h3>' . L10n::t('Personal Notes') . '</h3>';
59 'is_owner' => $is_owner,
60 'allow_location' => (($a->user['allow_location']) ? true : false),
61 'default_location' => $a->user['default-location'],
62 'nickname' => $a->user['nickname'],
63 'lockstate' => 'lock',
67 'profile_uid' => local_user(),
68 'button' => L10n::t('Save'),
72 $o .= status_editor($a, $x, $a->contact['id']);
75 // Construct permissions
77 // default permissions - anonymous user
79 $sql_extra = " AND `item`.`allow_cid` = '<" . $a->contact['id'] . ">' ";
81 $r = q("SELECT COUNT(*) AS `total`
83 WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
84 AND `contact`.`self` AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
86 item_joins(local_user()),
91 if (DBM::is_result($r)) {
92 $a->set_pager_total($r[0]['total']);
93 $a->set_pager_itemspage(40);
96 $r = q("SELECT `item`.`id` AS `item_id` FROM `item` %s
97 WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
98 AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
100 ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
101 item_joins(local_user()),
103 intval(local_user()),
104 intval($a->pager['start']),
105 intval($a->pager['itemspage'])
112 if (DBM::is_result($r)) {
113 foreach ($r as $rr) {
114 $parents_arr[] = $rr['item_id'];
117 $condition = ['uid' => local_user(), 'parent' => $parents_arr];
118 $result = Item::select(local_user(), [], $condition);
119 if (DBM::is_result($result)) {
120 $items = conv_sort(dba::inArray($result), 'commented');
121 $o .= conversation($a, $items, 'notes', $update);