3 * @file mod/lockview.php
6 use Friendica\Core\Hook;
7 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 DI::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 DI::l10n()->t('Remote privacy information not available.') . '<br />';
62 $aclFormatter = DI::aclFormatter();
64 $allowed_users = $aclFormatter->expand($item['allow_cid']);
65 $allowed_groups = $aclFormatter->expand($item['allow_gid']);
66 $deny_users = $aclFormatter->expand($item['deny_cid']);
67 $deny_groups = $aclFormatter->expand($item['deny_gid']);
69 $o = DI::l10n()->t('Visible to:') . '<br />';
72 if (count($allowed_groups)) {
73 $key = array_search(Group::FOLLOWERS, $allowed_groups);
75 $l[] = '<b>' . DI::l10n()->t('Followers') . '</b>';
76 unset($allowed_groups[$key]);
79 $key = array_search(Group::MUTUALS, $allowed_groups);
81 $l[] = '<b>' . DI::l10n()->t('Mutuals') . '</b>';
82 unset($allowed_groups[$key]);
86 $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
87 DBA::escape(implode(', ', $allowed_groups))
89 if (DBA::isResult($r)) {
91 $l[] = '<b>' . $rr['name'] . '</b>';
96 if (count($allowed_users)) {
97 $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
98 DBA::escape(implode(', ', $allowed_users))
100 if (DBA::isResult($r)) {
101 foreach ($r as $rr) {
107 if (count($deny_groups)) {
108 $key = array_search(Group::FOLLOWERS, $deny_groups);
109 if ($key !== false) {
110 $l[] = '<b><strike>' . DI::l10n()->t('Followers') . '</strike></b>';
111 unset($deny_groups[$key]);
114 $key = array_search(Group::MUTUALS, $deny_groups);
115 if ($key !== false) {
116 $l[] = '<b><strike>' . DI::l10n()->t('Mutuals') . '</strike></b>';
117 unset($deny_groups[$key]);
120 $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
121 DBA::escape(implode(', ', $deny_groups))
123 if (DBA::isResult($r)) {
124 foreach ($r as $rr) {
125 $l[] = '<b><strike>' . $rr['name'] . '</strike></b>';
130 if (count($deny_users)) {
131 $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
132 DBA::escape(implode(', ', $deny_users))
134 if (DBA::isResult($r)) {
135 foreach ($r as $rr) {
136 $l[] = '<strike>' . $rr['name'] . '</strike>';
141 echo $o . implode(', ', $l);