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