3 * @file mod/lockview.php
6 use Friendica\Core\Hook;
7 use Friendica\Core\L10n;
8 use Friendica\Database\DBA;
10 use Friendica\Model\Group;
11 use Friendica\Model\Item;
13 function lockview_content(App $a)
15 $type = (($a->argc > 1) ? $a->argv[1] : 0);
16 if (is_numeric($type)) {
17 $item_id = intval($type);
20 $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
27 if (!in_array($type, ['item','photo','event'])) {
31 $fields = ['uid', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
32 $condition = ['id' => $item_id];
34 if ($type != 'item') {
35 $item = DBA::selectFirst($type, $fields, $condition);
37 $fields[] = 'private';
38 $item = Item::selectFirst($fields, $condition);
41 if (!DBA::isResult($item)) {
45 Hook::callAll('lockview_content', $item);
47 if ($item['uid'] != local_user()) {
48 echo L10n::t('Remote privacy information not available.') . '<br />';
52 if (isset($item['private'])
53 && $item['private'] == 1
54 && empty($item['allow_cid'])
55 && empty($item['allow_gid'])
56 && empty($item['deny_cid'])
57 && empty($item['deny_gid']))
59 echo L10n::t('Remote privacy information not available.') . '<br />';
63 $aclFormatter = DI::aclFormatter();
65 $allowed_users = $aclFormatter->expand($item['allow_cid']);
66 $allowed_groups = $aclFormatter->expand($item['allow_gid']);
67 $deny_users = $aclFormatter->expand($item['deny_cid']);
68 $deny_groups = $aclFormatter->expand($item['deny_gid']);
70 $o = L10n::t('Visible to:') . '<br />';
73 if (count($allowed_groups)) {
74 $key = array_search(Group::FOLLOWERS, $allowed_groups);
76 $l[] = '<b>' . L10n::t('Followers') . '</b>';
77 unset($allowed_groups[$key]);
80 $key = array_search(Group::MUTUALS, $allowed_groups);
82 $l[] = '<b>' . L10n::t('Mutuals') . '</b>';
83 unset($allowed_groups[$key]);
87 $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
88 DBA::escape(implode(', ', $allowed_groups))
90 if (DBA::isResult($r)) {
92 $l[] = '<b>' . $rr['name'] . '</b>';
97 if (count($allowed_users)) {
98 $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
99 DBA::escape(implode(', ', $allowed_users))
101 if (DBA::isResult($r)) {
102 foreach ($r as $rr) {
108 if (count($deny_groups)) {
109 $key = array_search(Group::FOLLOWERS, $deny_groups);
110 if ($key !== false) {
111 $l[] = '<b><strike>' . L10n::t('Followers') . '</strike></b>';
112 unset($deny_groups[$key]);
115 $key = array_search(Group::MUTUALS, $deny_groups);
116 if ($key !== false) {
117 $l[] = '<b><strike>' . L10n::t('Mutuals') . '</strike></b>';
118 unset($deny_groups[$key]);
121 $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
122 DBA::escape(implode(', ', $deny_groups))
124 if (DBA::isResult($r)) {
125 foreach ($r as $rr) {
126 $l[] = '<b><strike>' . $rr['name'] . '</strike></b>';
131 if (count($deny_users)) {
132 $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
133 DBA::escape(implode(', ', $deny_users))
135 if (DBA::isResult($r)) {
136 foreach ($r as $rr) {
137 $l[] = '<strike>' . $rr['name'] . '</strike>';
142 echo $o . implode(', ', $l);