]> git.mxchange.org Git - friendica.git/blob - mod/notes.php
Many t() calls
[friendica.git] / mod / notes.php
1 <?php
2 /**
3  * @file mod/notes.php
4  */
5 use Friendica\App;
6 use Friendica\Content\Nav;
7 use Friendica\Core\L10n;
8 use Friendica\Database\DBM;
9 use Friendica\Model\Profile;
10
11 function notes_init(App $a) {
12
13         if (! local_user()) {
14                 return;
15         }
16
17         $profile = 0;
18
19         $which = $a->user['nickname'];
20
21         Nav::setSelected('home');
22
23         //Profile::load($a, $which, $profile);
24
25 }
26
27
28 function notes_content(App $a, $update = false) {
29
30         if (! local_user()) {
31                 notice(L10n::t('Permission denied.') . EOL);
32                 return;
33         }
34
35         require_once("include/bbcode.php");
36         require_once('include/security.php');
37         require_once('include/conversation.php');
38         require_once('include/acl_selectors.php');
39         $groups = [];
40
41
42         $o = '';
43
44         $remote_contact = false;
45
46         $contact_id = $_SESSION['cid'];
47         $contact = $a->contact;
48
49         $is_owner = true;
50
51         $o ="";
52         $o .= Profile::getTabs($a, true);
53
54         if(! $update) {
55                 $o .= '<h3>' . t('Personal Notes') . '</h3>';
56
57                 $commpage = false;
58                 $commvisitor = false;
59
60                 $x = [
61                         'is_owner' => $is_owner,
62                         'allow_location' => (($a->user['allow_location']) ? true : false),
63                         'default_location' => $a->user['default-location'],
64                         'nickname' => $a->user['nickname'],
65                         'lockstate' => 'lock',
66                         'acl' => '',
67                         'bang' => '',
68                         'visitor' => 'block',
69                         'profile_uid' => local_user(),
70                         'button' => t('Save'),
71                         'acl_data' => '',
72                 ];
73
74                 $o .= status_editor($a,$x,$a->contact['id']);
75
76         }
77
78         // Construct permissions
79
80         // default permissions - anonymous user
81
82         $sql_extra = " AND `item`.`allow_cid` = '<" . $a->contact['id'] . ">' ";
83
84         $r = q("SELECT COUNT(*) AS `total`
85                 FROM `item` %s
86                 WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
87                 AND `contact`.`self` AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
88                 $sql_extra ",
89                 item_joins(), item_condition(),
90                 intval(local_user())
91
92         );
93
94         if (DBM::is_result($r)) {
95                 $a->set_pager_total($r[0]['total']);
96                 $a->set_pager_itemspage(40);
97         }
98
99         $r = q("SELECT `item`.`id` AS `item_id` FROM `item` %s
100                 WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
101                 AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
102                 $sql_extra
103                 ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
104                 item_joins(), item_condition(),
105                 intval(local_user()),
106                 intval($a->pager['start']),
107                 intval($a->pager['itemspage'])
108
109         );
110
111         $parents_arr = [];
112         $parents_str = '';
113
114         if (DBM::is_result($r)) {
115                 foreach($r as $rr)
116                         $parents_arr[] = $rr['item_id'];
117                 $parents_str = implode(', ', $parents_arr);
118
119                 $r = q("SELECT %s FROM `item` %s
120                         WHERE %s AND `item`.`uid` = %d AND `item`.`parent` IN (%s)
121                         $sql_extra
122                         ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ",
123                         item_fieldlists(), item_joins(), item_condition(),
124                         intval(local_user()),
125                         dbesc($parents_str)
126                 );
127
128                 if (DBM::is_result($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 }