3 if(! function_exists('notes_init')) {
4 function notes_init(&$a) {
11 $which = $a->user['nickname'];
13 nav_set_selected('home');
15 // profile_load($a,$which,$profile);
19 if(! function_exists('notes_content')) {
20 function notes_content(&$a,$update = false) {
23 notice( t('Permission denied.') . EOL);
27 require_once("include/bbcode.php");
28 require_once('include/security.php');
29 require_once('include/conversation.php');
30 require_once('include/acl_selectors.php');
36 $remote_contact = false;
38 $contact_id = $_SESSION['cid'];
39 $contact = $a->contact;
44 $o .= profile_tabs($a,True);
47 $o .= '<h3>' . t('Personal Notes') . '</h3>';
53 'is_owner' => $is_owner,
54 'allow_location' => (($a->user['allow_location']) ? true : false),
55 'default_location' => $a->user['default-location'],
56 'nickname' => $a->user['nickname'],
57 'lockstate' => 'lock',
61 'profile_uid' => local_user(),
62 'button' => t('Save'),
66 $o .= status_editor($a,$x,$a->contact['id']);
70 // Construct permissions
72 // default permissions - anonymous user
74 $sql_extra = " AND `allow_cid` = '<" . $a->contact['id'] . ">' ";
76 $r = q("SELECT COUNT(*) AS `total`
77 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
78 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0
79 AND `item`.`deleted` = 0 AND `item`.`type` = 'note'
80 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self` = 1
81 AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 0
88 $a->set_pager_total($r[0]['total']);
89 $a->set_pager_itemspage(40);
92 $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact-uid`
93 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
94 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
95 and `item`.`moderated` = 0 AND `item`.`type` = 'note'
96 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self` = 1
97 AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 0
99 ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
100 intval(local_user()),
101 intval($a->pager['start']),
102 intval($a->pager['itemspage'])
106 $parents_arr = array();
111 $parents_arr[] = $rr['item_id'];
112 $parents_str = implode(', ', $parents_arr);
114 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
115 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`network`, `contact`.`rel`,
116 `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
117 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
118 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
119 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
120 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
121 AND `item`.`parent` IN ( %s )
123 ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ",
124 intval(local_user()),
129 $items = conv_sort($r,"`commented`");
131 $o .= conversation($a,$items,'notes',$update);