]> git.mxchange.org Git - friendica.git/blob - mod/lockview.php
Class file relocations
[friendica.git] / mod / lockview.php
1 <?php
2
3 use Friendica\App;
4 use Friendica\Database\DBM;
5
6 function lockview_content(App $a) {
7
8         $type = (($a->argc > 1) ? $a->argv[1] : 0);
9         if (is_numeric($type)) {
10                 $item_id = intval($type);
11                 $type='item';
12         } else {
13                 $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
14         }
15
16         if(! $item_id)
17                 killme();
18
19         if (!in_array($type, array('item','photo','event')))
20                 killme();
21
22         $r = q("SELECT * FROM `%s` WHERE `id` = %d LIMIT 1",
23                 dbesc($type),
24                 intval($item_id)
25         );
26         if (! DBM::is_result($r)) {
27                 killme();
28         }
29         $item = $r[0];
30
31         call_hooks('lockview_content', $item);
32
33         if($item['uid'] != local_user()) {
34                 echo t('Remote privacy information not available.') . '<br />';
35                 killme();
36         }
37
38
39         if(($item['private'] == 1) && (! strlen($item['allow_cid'])) && (! strlen($item['allow_gid']))
40                 && (! strlen($item['deny_cid'])) && (! strlen($item['deny_gid']))) {
41
42                 echo t('Remote privacy information not available.') . '<br />';
43                 killme();
44         }
45
46         $allowed_users = expand_acl($item['allow_cid']);
47         $allowed_groups = expand_acl($item['allow_gid']);
48         $deny_users = expand_acl($item['deny_cid']);
49         $deny_groups = expand_acl($item['deny_gid']);
50
51         $o = t('Visible to:') . '<br />';
52         $l = array();
53
54         if(count($allowed_groups)) {
55                 $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
56                         dbesc(implode(', ', $allowed_groups))
57                 );
58                 if (DBM::is_result($r))
59                         foreach($r as $rr)
60                                 $l[] = '<b>' . $rr['name'] . '</b>';
61         }
62         if(count($allowed_users)) {
63                 $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
64                         dbesc(implode(', ',$allowed_users))
65                 );
66                 if (DBM::is_result($r))
67                         foreach($r as $rr)
68                                 $l[] = $rr['name'];
69
70         }
71
72         if(count($deny_groups)) {
73                 $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
74                         dbesc(implode(', ', $deny_groups))
75                 );
76                 if (DBM::is_result($r))
77                         foreach($r as $rr)
78                                 $l[] = '<b><strike>' . $rr['name'] . '</strike></b>';
79         }
80         if(count($deny_users)) {
81                 $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
82                         dbesc(implode(', ',$deny_users))
83                 );
84                 if (DBM::is_result($r))
85                         foreach($r as $rr)
86                                 $l[] = '<strike>' . $rr['name'] . '</strike>';
87
88         }
89
90         echo $o . implode(', ', $l);
91         killme();
92
93 }