4 use Friendica\Core\Addon;
5 use Friendica\Database\DBM;
7 function lockview_content(App $a) {
9 $type = (($a->argc > 1) ? $a->argv[1] : 0);
10 if (is_numeric($type)) {
11 $item_id = intval($type);
14 $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
20 if (!in_array($type, ['item','photo','event']))
23 $r = q("SELECT * FROM `%s` WHERE `id` = %d LIMIT 1",
27 if (! DBM::is_result($r)) {
32 Addon::callHooks('lockview_content', $item);
34 if($item['uid'] != local_user()) {
35 echo t('Remote privacy information not available.') . '<br />';
40 if(($item['private'] == 1) && (! strlen($item['allow_cid'])) && (! strlen($item['allow_gid']))
41 && (! strlen($item['deny_cid'])) && (! strlen($item['deny_gid']))) {
43 echo t('Remote privacy information not available.') . '<br />';
47 $allowed_users = expand_acl($item['allow_cid']);
48 $allowed_groups = expand_acl($item['allow_gid']);
49 $deny_users = expand_acl($item['deny_cid']);
50 $deny_groups = expand_acl($item['deny_gid']);
52 $o = t('Visible to:') . '<br />';
55 if(count($allowed_groups)) {
56 $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
57 dbesc(implode(', ', $allowed_groups))
59 if (DBM::is_result($r))
61 $l[] = '<b>' . $rr['name'] . '</b>';
63 if(count($allowed_users)) {
64 $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
65 dbesc(implode(', ',$allowed_users))
67 if (DBM::is_result($r))
73 if(count($deny_groups)) {
74 $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
75 dbesc(implode(', ', $deny_groups))
77 if (DBM::is_result($r))
79 $l[] = '<b><strike>' . $rr['name'] . '</strike></b>';
81 if(count($deny_users)) {
82 $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
83 dbesc(implode(', ',$deny_users))
85 if (DBM::is_result($r))
87 $l[] = '<strike>' . $rr['name'] . '</strike>';
91 echo $o . implode(', ', $l);