6 use Friendica\Content\Nav;
7 use Friendica\Database\DBM;
8 use Friendica\Model\Profile;
10 function notes_init(App $a) {
18 $which = $a->user['nickname'];
20 Nav::setSelected('home');
22 //Profile::load($a, $which, $profile);
27 function notes_content(App $a, $update = false) {
30 notice( t('Permission denied.') . EOL);
34 require_once("include/bbcode.php");
35 require_once('include/security.php');
36 require_once('include/conversation.php');
37 require_once('include/acl_selectors.php');
43 $remote_contact = false;
45 $contact_id = $_SESSION['cid'];
46 $contact = $a->contact;
51 $o .= Profile::getTabs($a, true);
54 $o .= '<h3>' . t('Personal Notes') . '</h3>';
60 'is_owner' => $is_owner,
61 'allow_location' => (($a->user['allow_location']) ? true : false),
62 'default_location' => $a->user['default-location'],
63 'nickname' => $a->user['nickname'],
64 'lockstate' => 'lock',
68 'profile_uid' => local_user(),
69 'button' => t('Save'),
73 $o .= status_editor($a,$x,$a->contact['id']);
77 // Construct permissions
79 // default permissions - anonymous user
81 $sql_extra = " AND `item`.`allow_cid` = '<" . $a->contact['id'] . ">' ";
83 $r = q("SELECT COUNT(*) AS `total`
85 WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
86 AND `contact`.`self` AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
88 item_joins(), item_condition(),
93 if (DBM::is_result($r)) {
94 $a->set_pager_total($r[0]['total']);
95 $a->set_pager_itemspage(40);
98 $r = q("SELECT `item`.`id` AS `item_id` FROM `item` %s
99 WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
100 AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
102 ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
103 item_joins(), item_condition(),
104 intval(local_user()),
105 intval($a->pager['start']),
106 intval($a->pager['itemspage'])
113 if (DBM::is_result($r)) {
115 $parents_arr[] = $rr['item_id'];
116 $parents_str = implode(', ', $parents_arr);
118 $r = q("SELECT %s FROM `item` %s
119 WHERE %s AND `item`.`uid` = %d AND `item`.`parent` IN (%s)
121 ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ",
122 item_fieldlists(), item_joins(), item_condition(),
123 intval(local_user()),
127 if (DBM::is_result($r)) {
128 $items = conv_sort($r,"`commented`");
130 $o .= conversation($a,$items,'notes',$update);