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 /// @todo We seem to need "Item::count" as function as well
82 $r = q("SELECT COUNT(*) AS `total`
84 WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
85 AND `contact`.`self` AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
87 item_joins(local_user()),
92 if (DBM::is_result($r)) {
93 $a->set_pager_total($r[0]['total']);
94 $a->set_pager_itemspage(40);
97 $condition = ["`uid` = ? AND `type` = 'note' AND NOT `wall`
98 AND `id` = `parent` AND `allow_cid` = ?",
99 local_user(), '<' . $a->contact['id'] . '>'];
100 $params = ['order' => ['created' => true],
101 'limit' => [$a->pager['start'], $a->pager['itemspage']]];
103 $r = Item::select(local_user(), ['item_id'], $condition, $params);
105 if (DBM::is_result($r)) {
108 while ($rr = dba::fetch($r)) {
109 $parents_arr[] = $rr['item_id'];
113 $condition = ['uid' => local_user(), 'parent' => $parents_arr];
114 $result = Item::select(local_user(), [], $condition);
115 if (DBM::is_result($result)) {
116 $items = conv_sort(dba::inArray($result), 'commented');
117 $o .= conversation($a, $items, 'notes', $update);