6 use Friendica\Database\DBM;
7 use Friendica\Model\Profile;
9 function notes_init(App $a) {
17 $which = $a->user['nickname'];
19 nav_set_selected('home');
21 //Profile::load($a, $which, $profile);
26 function notes_content(App $a, $update = false) {
29 notice( t('Permission denied.') . EOL);
33 require_once("include/bbcode.php");
34 require_once('include/security.php');
35 require_once('include/conversation.php');
36 require_once('include/acl_selectors.php');
42 $remote_contact = false;
44 $contact_id = $_SESSION['cid'];
45 $contact = $a->contact;
50 $o .= Profile::getTabs($a, true);
53 $o .= '<h3>' . 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' => t('Save'),
72 $o .= status_editor($a,$x,$a->contact['id']);
76 // Construct permissions
78 // default permissions - anonymous user
80 $sql_extra = " AND `item`.`allow_cid` = '<" . $a->contact['id'] . ">' ";
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(), item_condition(),
92 if (DBM::is_result($r)) {
93 $a->set_pager_total($r[0]['total']);
94 $a->set_pager_itemspage(40);
97 $r = q("SELECT `item`.`id` AS `item_id` FROM `item` %s
98 WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
99 AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
101 ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
102 item_joins(), item_condition(),
103 intval(local_user()),
104 intval($a->pager['start']),
105 intval($a->pager['itemspage'])
109 $parents_arr = array();
112 if (DBM::is_result($r)) {
114 $parents_arr[] = $rr['item_id'];
115 $parents_str = implode(', ', $parents_arr);
117 $r = q("SELECT %s FROM `item` %s
118 WHERE %s AND `item`.`uid` = %d AND `item`.`parent` IN (%s)
120 ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ",
121 item_fieldlists(), item_joins(), item_condition(),
122 intval(local_user()),
126 if (DBM::is_result($r)) {
127 $items = conv_sort($r,"`commented`");
129 $o .= conversation($a,$items,'notes',$update);