]> git.mxchange.org Git - friendica.git/blob - mod/notes.php
add remove_user hook (it looks like dreamhost changed all my file permissions, this...
[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                 $celeb = false;
50
51
52
53                 $x = array(
54                         'is_owner' => $is_owner,
55                 'allow_location' => (($a->user['allow_location']) ? true : false),
56                 'default_location' => $a->user['default-location'],
57             'nickname' => $a->user['nickname'],
58                 'lockstate' => 'lock',
59                 'acl' => '',
60             'bang' => '',
61                 'visitor' => 'block',
62                     'profile_uid' => local_user(),
63                         'button' => t('Save')
64
65         );
66
67         $o .= status_editor($a,$x,$a->contact['id']);
68
69                 $o .= '<div id="live-notes"></div>' . "\r\n";
70                 $o .= "<script> var profile_uid = " . local_user() 
71                         . "; var netargs = '/?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
72
73         }
74
75         // Construct permissions
76
77         // default permissions - anonymous user
78         
79         $sql_extra = " AND `allow_cid` = '<" . $a->contact['id'] . ">' ";
80
81         $r = q("SELECT COUNT(*) AS `total`
82                 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
83                 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
84                 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 
85                 AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 0
86                 $sql_extra ",
87                 intval(local_user())
88
89         );
90
91         if(count($r)) {
92                 $a->set_pager_total($r[0]['total']);
93                 $a->set_pager_itemspage(40);
94         }
95
96         $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact-uid`
97                 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
98                 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
99                 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
100                 AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 0
101                 $sql_extra
102                 ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
103                 intval(local_user()),
104                 intval($a->pager['start']),
105                 intval($a->pager['itemspage'])
106
107         );
108
109         $parents_arr = array();
110         $parents_str = '';
111
112         if(count($r)) {
113                 foreach($r as $rr)
114                         $parents_arr[] = $rr['item_id'];
115                 $parents_str = implode(', ', $parents_arr);
116  
117                 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, 
118                         `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`, `contact`.`rel`, 
119                         `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, 
120                         `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
121                         FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
122                         WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
123                         AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
124                         AND `item`.`parent` IN ( %s )
125                         $sql_extra
126                         ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ",
127                         intval(local_user()),
128                         dbesc($parents_str)
129                 );
130         }
131
132         $o .= conversation($a,$r,'notes',$update);
133
134
135         $o .= paginate($a);
136         return $o;
137 }