From 79ef87a1e4155899443419c8309ba28dc5de9af4 Mon Sep 17 00:00:00 2001 From: Julio Date: Fri, 27 Dec 2019 15:46:05 +0100 Subject: [PATCH] Announcements, use resources [WIP] --- public/main/inc/lib/AnnouncementManager.php | 35 ++++++++++----------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/public/main/inc/lib/AnnouncementManager.php b/public/main/inc/lib/AnnouncementManager.php index 9337b6ecd7..12c2ce1c1a 100644 --- a/public/main/inc/lib/AnnouncementManager.php +++ b/public/main/inc/lib/AnnouncementManager.php @@ -1,4 +1,5 @@ find($announcementId); + $courseId = (int) $courseId; $userId = (int) $userId; $groupId = (int) $groupId; @@ -425,26 +428,18 @@ class AnnouncementManager return ''; } - global $charset; - $html = ''; - $result = self::getAnnouncementInfoById( + $course = api_get_course_entity(api_get_course_int_id()); + $session = api_get_session_entity(api_get_session_id()); + + $announcement = self::getAnnouncementInfoById( $id, api_get_course_int_id(), api_get_user_id(), api_get_group_id() ); - if (empty($result)) { - return ''; - } - - /** @var CAnnouncement $announcement */ - $announcement = $result['announcement']; - /** @var CItemProperty $itemProperty */ - $itemProperty = $result['item_property']; - - if (empty($announcement) || empty($itemProperty)) { + if (empty($announcement)) { return ''; } @@ -462,7 +457,7 @@ class AnnouncementManager $image_visibility = 'invisible'; $alt_visibility = get_lang('Visible'); - if ($itemProperty->getVisibility() === 1) { + if ($announcement->isVisible($course, $session)) { $image_visibility = 'visible'; $alt_visibility = get_lang('Hide'); } @@ -471,7 +466,7 @@ class AnnouncementManager Display::return_icon($image_visibility.'.png', $alt_visibility, '', ICON_SIZE_SMALL).""; if (api_is_allowed_to_edit(false, true)) { - $modify_icons .= "". + $modify_icons .= "". Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL). ""; } @@ -490,7 +485,7 @@ class AnnouncementManager $html .= "$content"; $html .= ""; $html .= "".get_lang('Latest update')." : "; - $lastEdit = $itemProperty->getLasteditDate(); + $lastEdit = $announcement->getResourceNode()->getUpdatedAt(); $html .= Display::dateToStringAgoAndLongDate($lastEdit); $html .= ""; @@ -1311,6 +1306,8 @@ class AnnouncementManager */ public static function sent_to($tool, $id) { + return []; + $table = Database::get_course_table(TABLE_ITEM_PROPERTY); $tool = Database::escape_string($tool); $id = (int) $id;