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