<?php
/**
- * @copyright Copyright (C) 2010-2023, the Friendica project
+ * @copyright Copyright (C) 2010-2024, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\APContact;
-use Friendica\Model\Group;
+use Friendica\Model\Circle;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\Tag;
exit;
}
- $allowed_users = $model['allow_cid'];
- $allowed_groups = $model['allow_gid'];
- $deny_users = $model['deny_cid'];
- $deny_groups = $model['deny_gid'];
+ if (!empty($model['allow_cid']) || !empty($model['allow_gid']) || !empty($model['deny_cid']) || !empty($model['deny_gid'])) {
+ $receivers = $this->fetchReceiversFromACL($model);
+ }
+
+ $this->httpExit(DI::l10n()->t('Visible to:') . '<br />' . $receivers);
+ }
+
+ /**
+ * Fetch a list of receivers based on the ACL data
+ *
+ * @param array $model
+ * @return string
+ */
+ private function fetchReceiversFromACL(array $model)
+ {
+ $allowed_users = $model['allow_cid'];
+ $allowed_circles = $model['allow_gid'];
+ $deny_users = $model['deny_cid'];
+ $deny_circles = $model['deny_gid'];
- $o = DI::l10n()->t('Visible to:') . '<br />';
$l = [];
- if (count($allowed_groups)) {
- $key = array_search(Group::FOLLOWERS, $allowed_groups);
+ if (count($allowed_circles)) {
+ $key = array_search(Circle::FOLLOWERS, $allowed_circles);
if ($key !== false) {
$l[] = '<b>' . DI::l10n()->t('Followers') . '</b>';
- unset($allowed_groups[$key]);
+ unset($allowed_circles[$key]);
}
- $key = array_search(Group::MUTUALS, $allowed_groups);
+ $key = array_search(Circle::MUTUALS, $allowed_circles);
if ($key !== false) {
$l[] = '<b>' . DI::l10n()->t('Mutuals') . '</b>';
- unset($allowed_groups[$key]);
+ unset($allowed_circles[$key]);
}
- foreach (DI::dba()->selectToArray('group', ['name'], ['id' => $allowed_groups]) as $group) {
- $l[] = '<b>' . $group['name'] . '</b>';
+ foreach (DI::dba()->selectToArray('group', ['name'], ['id' => $allowed_circles]) as $circle) {
+ $l[] = '<b>' . $circle['name'] . '</b>';
}
}
$l[] = $contact['name'];
}
- if (count($deny_groups)) {
- $key = array_search(Group::FOLLOWERS, $deny_groups);
+ if (count($deny_circles)) {
+ $key = array_search(Circle::FOLLOWERS, $deny_circles);
if ($key !== false) {
$l[] = '<b><strike>' . DI::l10n()->t('Followers') . '</strike></b>';
- unset($deny_groups[$key]);
+ unset($deny_circles[$key]);
}
- $key = array_search(Group::MUTUALS, $deny_groups);
+ $key = array_search(Circle::MUTUALS, $deny_circles);
if ($key !== false) {
$l[] = '<b><strike>' . DI::l10n()->t('Mutuals') . '</strike></b>';
- unset($deny_groups[$key]);
+ unset($deny_circles[$key]);
}
- foreach (DI::dba()->selectToArray('group', ['name'], ['id' => $allowed_groups]) as $group) {
- $l[] = '<b><strike>' . $group['name'] . '</strike></b>';
+ foreach (DI::dba()->selectToArray('group', ['name'], ['id' => $allowed_circles]) as $circle) {
+ $l[] = '<b><strike>' . $circle['name'] . '</strike></b>';
}
}
$l[] = '<strike>' . $contact['name'] . '</strike>';
}
- if (!empty($l)) {
- System::httpExit($o . implode(', ', $l));
- } else {
- System::httpExit($o . $receivers);;
- }
+ return implode(', ', $l);
}
/**