]> git.mxchange.org Git - friendica.git/blob - mod/notes.php
a25d090ed701faad32ab49fb2dbc7012b13d8e2f
[friendica.git] / mod / notes.php
1 <?php
2
3 function notes_init(&$a) {
4
5         if(! local_user())
6                 return;
7
8         $profile = 0;
9
10         $which = $a->user['nickname'];
11
12         nav_set_selected('home');
13
14 //      profile_load($a,$which,$profile);
15
16 }
17
18
19 function notes_content(&$a,$update = false) {
20
21         if(! local_user()) {
22                 notice( t('Permission denied.') . EOL);
23                 return;
24         }
25
26         require_once("include/bbcode.php");
27         require_once('include/security.php');
28         require_once('include/conversation.php');
29         require_once('include/acl_selectors.php');
30         $groups = array();
31
32
33         $o = '';
34
35         $remote_contact = false;
36
37         $contact_id = $_SESSION['cid'];
38         $contact = $a->contact;
39
40         $is_owner = true;
41
42         $o ="";
43         $o .= profile_tabs($a,True);
44
45         if(! $update) {
46                 $o .= '<h3>' . t('Personal Notes') . '</h3>';
47
48                 $commpage = false;
49                 $commvisitor = false;
50
51                 $x = array(
52                         'is_owner' => $is_owner,
53                         'allow_location' => (($a->user['allow_location']) ? true : false),
54                         'default_location' => $a->user['default-location'],
55                         'nickname' => $a->user['nickname'],
56                         'lockstate' => 'lock',
57                         'acl' => '',
58                         'bang' => '',
59                         'visitor' => 'block',
60                         'profile_uid' => local_user(),
61                         'button' => t('Save'),
62                         'acl_data' => '',
63                 );
64
65                 $o .= status_editor($a,$x,$a->contact['id']);
66
67         }
68
69         // Construct permissions
70
71         // default permissions - anonymous user
72
73         $sql_extra = " AND `allow_cid` = '<" . $a->contact['id'] . ">' ";
74
75         $r = q("SELECT COUNT(*) AS `total`
76                 FROM `item` %s
77                 WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
78                 AND `contact`.`self` AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
79                 $sql_extra ",
80                 item_joins(), item_condition(),
81                 intval(local_user())
82
83         );
84
85         if(count($r)) {
86                 $a->set_pager_total($r[0]['total']);
87                 $a->set_pager_itemspage(40);
88         }
89
90         $r = q("SELECT `item`.`id` AS `item_id` FROM `item` %s
91                 WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
92                 AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
93                 $sql_extra
94                 ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
95                 item_joins(), item_condition(),
96                 intval(local_user()),
97                 intval($a->pager['start']),
98                 intval($a->pager['itemspage'])
99
100         );
101
102         $parents_arr = array();
103         $parents_str = '';
104
105         if(count($r)) {
106                 foreach($r as $rr)
107                         $parents_arr[] = $rr['item_id'];
108                 $parents_str = implode(', ', $parents_arr);
109
110                 $r = q("SELECT %s FROM `item` %s
111                         WHERE %s AND `item`.`uid` = %d AND `item`.`parent` IN (%s)
112                         $sql_extra
113                         ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ",
114                         item_fieldlists(), item_joins(), item_condition(),
115                         intval(local_user()),
116                         dbesc($parents_str)
117                 );
118
119                 if(count($r)) {
120                         $items = conv_sort($r,"`commented`");
121
122                         $o .= conversation($a,$items,'notes',$update);
123                 }
124         }
125
126
127         $o .= paginate($a);
128         return $o;
129 }