4 use Friendica\Database\DBM;
6 function notes_init(App $a) {
14 $which = $a->user['nickname'];
16 nav_set_selected('home');
18 // profile_load($a,$which,$profile);
23 function notes_content(App $a, $update = false) {
26 notice( t('Permission denied.') . EOL);
30 require_once("include/bbcode.php");
31 require_once('include/security.php');
32 require_once('include/conversation.php');
33 require_once('include/acl_selectors.php');
39 $remote_contact = false;
41 $contact_id = $_SESSION['cid'];
42 $contact = $a->contact;
47 $o .= profile_tabs($a,True);
50 $o .= '<h3>' . t('Personal Notes') . '</h3>';
56 'is_owner' => $is_owner,
57 'allow_location' => (($a->user['allow_location']) ? true : false),
58 'default_location' => $a->user['default-location'],
59 'nickname' => $a->user['nickname'],
60 'lockstate' => 'lock',
64 'profile_uid' => local_user(),
65 'button' => t('Save'),
69 $o .= status_editor($a,$x,$a->contact['id']);
73 // Construct permissions
75 // default permissions - anonymous user
77 $sql_extra = " AND `item`.`allow_cid` = '<" . $a->contact['id'] . ">' ";
79 $r = q("SELECT COUNT(*) AS `total`
81 WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
82 AND `contact`.`self` AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
84 item_joins(), item_condition(),
89 if (DBM::is_result($r)) {
90 $a->set_pager_total($r[0]['total']);
91 $a->set_pager_itemspage(40);
94 $r = q("SELECT `item`.`id` AS `item_id` FROM `item` %s
95 WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
96 AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
98 ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
99 item_joins(), item_condition(),
100 intval(local_user()),
101 intval($a->pager['start']),
102 intval($a->pager['itemspage'])
106 $parents_arr = array();
109 if (DBM::is_result($r)) {
111 $parents_arr[] = $rr['item_id'];
112 $parents_str = implode(', ', $parents_arr);
114 $r = q("SELECT %s FROM `item` %s
115 WHERE %s AND `item`.`uid` = %d AND `item`.`parent` IN (%s)
117 ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ",
118 item_fieldlists(), item_joins(), item_condition(),
119 intval(local_user()),
123 if (DBM::is_result($r)) {
124 $items = conv_sort($r,"`commented`");
126 $o .= conversation($a,$items,'notes',$update);