From ada090cbc68d6f5ece847639bd0a31f3cca7b7eb Mon Sep 17 00:00:00 2001 From: Ilyassbennanii Date: Thu, 16 Oct 2025 05:17:41 +0100 Subject: [PATCH] Announcements: Enable announcements to be visible to ANONYMOUS users - refs #5200 --- public/main/admin/system_announcements.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/public/main/admin/system_announcements.php b/public/main/admin/system_announcements.php index b066ff0b447..be7acc8d201 100644 --- a/public/main/admin/system_announcements.php +++ b/public/main/admin/system_announcements.php @@ -37,6 +37,11 @@ $visibleList = api_get_user_roles(); +if (!array_key_exists('ROLE_ANONYMOUS', $visibleList)) { +// Prefix to make it appear at the top; adapt the label if needed + $visibleList = array_merge(['ROLE_ANONYMOUS' => get_lang('Anonymous')], $visibleList); +} + $tool_name = null; if (empty($_GET['lang'])) { $_GET['lang'] = $_SESSION['user_language_choice'] ?? null; @@ -438,7 +443,12 @@ function showCareer() { $row[] = $announcement->getTitle(); $row[] = api_convert_and_format_date($announcement->getDateStart()); $row[] = api_convert_and_format_date($announcement->getDateEnd()); - $row[] = implode(', ', $announcement->getRoles()); + $announcementRoles = $announcement->getRoles(); // tableau d'identifiants + $displayRoles = []; + foreach ($announcementRoles as $r) { + $displayRoles[] = $visibleList[$r] ?? $r; + } + $row[] = implode(', ', $displayRoles); $row[] = $announcement->getLang(); $confirmMsg = addslashes(api_htmlentities(get_lang('Please confirm your choice')));