]> git.mxchange.org Git - friendica.git/blob - mod/notes.php
Merge pull request #3149 from annando/1601-new-diaspora-mention
[friendica.git] / mod / notes.php
1 <?php
2
3 function notes_init(App $a) {
4
5         if (! local_user()) {
6                 return;
7         }
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
20 function notes_content(App $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` %s
78                 WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
79                 AND `contact`.`self` AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
80                 $sql_extra ",
81                 item_joins(), item_condition(),
82                 intval(local_user())
83
84         );
85
86         if (dbm::is_result($r)) {
87                 $a->set_pager_total($r[0]['total']);
88                 $a->set_pager_itemspage(40);
89         }
90
91         $r = q("SELECT `item`.`id` AS `item_id` FROM `item` %s
92                 WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
93                 AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
94                 $sql_extra
95                 ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
96                 item_joins(), item_condition(),
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 (dbm::is_result($r)) {
107                 foreach($r as $rr)
108                         $parents_arr[] = $rr['item_id'];
109                 $parents_str = implode(', ', $parents_arr);
110
111                 $r = q("SELECT %s FROM `item` %s
112                         WHERE %s AND `item`.`uid` = %d AND `item`.`parent` IN (%s)
113                         $sql_extra
114                         ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ",
115                         item_fieldlists(), item_joins(), item_condition(),
116                         intval(local_user()),
117                         dbesc($parents_str)
118                 );
119
120                 if (dbm::is_result($r)) {
121                         $items = conv_sort($r,"`commented`");
122
123                         $o .= conversation($a,$items,'notes',$update);
124                 }
125         }
126
127
128         $o .= paginate($a);
129         return $o;
130 }