From ff3ff5e370b52c970111c0d17cf353c6a0ffb122 Mon Sep 17 00:00:00 2001 From: merelendor Date: Thu, 8 Sep 2022 14:48:44 +0300 Subject: [PATCH] account announcements API --- api/index.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/api/index.php b/api/index.php index a10c094..f1d71ec 100644 --- a/api/index.php +++ b/api/index.php @@ -1103,6 +1103,31 @@ switch($PARAM_1) } break; + case "announcements": + { + if(CModule::IncludeModule('iblock')) + { + $announcements = []; + $announcements_res = CIBlockElement::GetList(["SORT" => "ASC"], ["ACTIVE" => "Y", "IBLOCK_ID" => 24], false, []); + while ($announcements_ob_element = $announcements_res->GetNextElement()) + { + $announcements_ar_res = $announcements_ob_element->GetFields(); + $announcements_ar_res['PROPERTIES'] = $announcements_ob_element->GetProperties(); + + $announcements[] = [ + "title" => $announcements_ar_res['NAME'], + "content" => $announcements_ar_res['PREVIEW_TEXT'], + "url" => !empty($announcements_ar_res['PROPERTIES']['URL']['VALUE']) ? $announcements_ar_res['PROPERTIES']['URL']['VALUE'] : null, + ]; + } + + print json_encode([ + "announcements" => $announcements, + ]); + } + } + break; + case "regions": { if(CModule::IncludeModule('iblock'))