3 * @file mod/lockview.php
6 use Friendica\Core\Hook;
7 use Friendica\Core\L10n;
8 use Friendica\Database\DBA;
9 use Friendica\Model\Item;
11 function lockview_content(App $a)
13 $type = (($a->argc > 1) ? $a->argv[1] : 0);
14 if (is_numeric($type)) {
15 $item_id = intval($type);
18 $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
25 if (!in_array($type, ['item','photo','event'])) {
29 $fields = ['uid', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
30 $condition = ['id' => $item_id];
32 if ($type != 'item') {
33 $item = DBA::selectFirst($type, $fields, $condition);
35 $fields[] = 'private';
36 $item = Item::selectFirst($fields, $condition);
39 if (!DBA::isResult($item)) {
43 Hook::callAll('lockview_content', $item);
45 if ($item['uid'] != local_user()) {
46 echo L10n::t('Remote privacy information not available.') . '<br />';
50 if (isset($item['private'])
51 && $item['private'] == 1
52 && empty($item['allow_cid'])
53 && empty($item['allow_gid'])
54 && empty($item['deny_cid'])
55 && empty($item['deny_gid']))
57 echo L10n::t('Remote privacy information not available.') . '<br />';
61 $allowed_users = expand_acl($item['allow_cid']);
62 $allowed_groups = expand_acl($item['allow_gid']);
63 $deny_users = expand_acl($item['deny_cid']);
64 $deny_groups = expand_acl($item['deny_gid']);
66 $o = L10n::t('Visible to:') . '<br />';
69 if (count($allowed_groups)) {
70 $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
71 DBA::escape(implode(', ', $allowed_groups))
73 if (DBA::isResult($r)) {
75 $l[] = '<b>' . $rr['name'] . '</b>';
80 if (count($allowed_users)) {
81 $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
82 DBA::escape(implode(', ', $allowed_users))
84 if (DBA::isResult($r)) {
91 if (count($deny_groups)) {
92 $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
93 DBA::escape(implode(', ', $deny_groups))
95 if (DBA::isResult($r)) {
97 $l[] = '<b><strike>' . $rr['name'] . '</strike></b>';
102 if (count($deny_users)) {
103 $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
104 DBA::escape(implode(', ', $deny_users))
106 if (DBA::isResult($r)) {
107 foreach ($r as $rr) {
108 $l[] = '<strike>' . $rr['name'] . '</strike>';
113 echo $o . implode(', ', $l);