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