]> git.mxchange.org Git - friendica.git/blob - mod/notes.php
Merge pull request #2324 from rabuzarus/0502_vier_dark
[friendica.git] / mod / notes.php
1 <?php
2
3 if(! function_exists('notes_init')) {
4 function notes_init(&$a) {
5
6         if(! local_user())
7                 return;
8
9         $profile = 0;
10
11         $which = $a->user['nickname'];
12
13         nav_set_selected('home');
14
15 //      profile_load($a,$which,$profile);
16 }
17 }
18
19 if(! function_exists('notes_content')) {
20 function notes_content(&$a,$update = false) {
21
22         if(! local_user()) {
23                 notice( t('Permission denied.') . EOL);
24                 return;
25         }
26
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');
31         $groups = array();
32
33
34         $o = '';
35
36         $remote_contact = false;
37
38         $contact_id = $_SESSION['cid'];
39         $contact = $a->contact;
40
41         $is_owner = true;
42
43         $o ="";
44         $o .= profile_tabs($a,True);
45
46         if(! $update) {
47                 $o .= '<h3>' . t('Personal Notes') . '</h3>';
48
49                 $commpage = false;
50                 $commvisitor = false;
51
52                 $x = array(
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',
58                         'acl' => '',
59                         'bang' => '',
60                         'visitor' => 'block',
61                         'profile_uid' => local_user(),
62                         'button' => t('Save'),
63                         'acl_data' => '',
64                 );
65
66                 $o .= status_editor($a,$x,$a->contact['id']);
67
68         }
69
70         // Construct permissions
71
72         // default permissions - anonymous user
73
74         $sql_extra = " AND `allow_cid` = '<" . $a->contact['id'] . ">' ";
75
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
82                 $sql_extra ",
83                 intval(local_user())
84
85         );
86
87         if(count($r)) {
88                 $a->set_pager_total($r[0]['total']);
89                 $a->set_pager_itemspage(40);
90         }
91
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
98                 $sql_extra
99                 ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
100                 intval(local_user()),
101                 intval($a->pager['start']),
102                 intval($a->pager['itemspage'])
103
104         );
105
106         $parents_arr = array();
107         $parents_str = '';
108
109         if(count($r)) {
110                 foreach($r as $rr)
111                         $parents_arr[] = $rr['item_id'];
112                 $parents_str = implode(', ', $parents_arr);
113
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 )
122                         $sql_extra
123                         ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ",
124                         intval(local_user()),
125                         dbesc($parents_str)
126                 );
127
128                 if(count($r)) {
129                         $items = conv_sort($r,"`commented`");
130
131                         $o .= conversation($a,$items,'notes',$update);
132                 }
133         }
134
135
136         $o .= paginate($a);
137         return $o;
138 }
139 }