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