3 * @file mod/lockview.php
6 use Friendica\Core\Hook;
7 use Friendica\Core\L10n;
8 use Friendica\Database\DBA;
9 use Friendica\Model\Group;
10 use Friendica\Model\Item;
12 function lockview_content(App $a)
14 $type = (($a->argc > 1) ? $a->argv[1] : 0);
15 if (is_numeric($type)) {
16 $item_id = intval($type);
19 $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
26 if (!in_array($type, ['item','photo','event'])) {
30 $fields = ['uid', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
31 $condition = ['id' => $item_id];
33 if ($type != 'item') {
34 $item = DBA::selectFirst($type, $fields, $condition);
36 $fields[] = 'private';
37 $item = Item::selectFirst($fields, $condition);
40 if (!DBA::isResult($item)) {
44 Hook::callAll('lockview_content', $item);
46 if ($item['uid'] != local_user()) {
47 echo L10n::t('Remote privacy information not available.') . '<br />';
51 if (isset($item['private'])
52 && $item['private'] == 1
53 && empty($item['allow_cid'])
54 && empty($item['allow_gid'])
55 && empty($item['deny_cid'])
56 && empty($item['deny_gid']))
58 echo L10n::t('Remote privacy information not available.') . '<br />';
62 $allowed_users = expand_acl($item['allow_cid']);
63 $allowed_groups = expand_acl($item['allow_gid']);
64 $deny_users = expand_acl($item['deny_cid']);
65 $deny_groups = expand_acl($item['deny_gid']);
67 $o = L10n::t('Visible to:') . '<br />';
70 if (count($allowed_groups)) {
71 $key = array_search(Group::FOLLOWERS, $allowed_groups);
73 $l[] = '<b>' . L10n::t('Followers') . '</b>';
74 unset($allowed_groups[$key]);
77 $key = array_search(Group::MUTUALS, $allowed_groups);
79 $l[] = '<b>' . L10n::t('Mutuals') . '</b>';
80 unset($allowed_groups[$key]);
84 $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
85 DBA::escape(implode(', ', $allowed_groups))
87 if (DBA::isResult($r)) {
89 $l[] = '<b>' . $rr['name'] . '</b>';
94 if (count($allowed_users)) {
95 $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
96 DBA::escape(implode(', ', $allowed_users))
98 if (DBA::isResult($r)) {
105 if (count($deny_groups)) {
106 $key = array_search(Group::FOLLOWERS, $deny_groups);
107 if ($key !== false) {
108 $l[] = '<b><strike>' . L10n::t('Followers') . '</strike></b>';
109 unset($deny_groups[$key]);
112 $key = array_search(Group::MUTUALS, $deny_groups);
113 if ($key !== false) {
114 $l[] = '<b><strike>' . L10n::t('Mutuals') . '</strike></b>';
115 unset($deny_groups[$key]);
118 $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
119 DBA::escape(implode(', ', $deny_groups))
121 if (DBA::isResult($r)) {
122 foreach ($r as $rr) {
123 $l[] = '<b><strike>' . $rr['name'] . '</strike></b>';
128 if (count($deny_users)) {
129 $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
130 DBA::escape(implode(', ', $deny_users))
132 if (DBA::isResult($r)) {
133 foreach ($r as $rr) {
134 $l[] = '<strike>' . $rr['name'] . '</strike>';
139 echo $o . implode(', ', $l);