Ejemplo n.º 1
0
 function GetAbsentEvents($arParams)
 {
     if (!isset($arParams['arUserIds'], $arParams['iblockId'])) {
         return false;
     }
     $iblockId = $arParams['iblockId'];
     $arUserIds = $arParams['arUserIds'];
     $fromLimit = $arParams['fromLimit'];
     $toLimit = $arParams['toLimit'];
     $RESULT = array();
     $A_RESULT = array();
     //SELECT
     $arSelect = array("ID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "NAME", "ACTIVE_FROM", "ACTIVE_TO", "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "TIMESTAMP_X", "CREATED_BY", "PROPERTY_*");
     //WHERE
     $arFilter = array("IBLOCK_ID" => $iblockId, "ACTIVE" => "Y", "CHECK_PERMISSIONS" => 'N', "PROPERTY_PRIVATE" => false, "PROPERTY_ACCESSIBILITY" => 'absent', "INCLUDE_SUBSECTIONS" => "Y");
     if (isset($arParams['fromLimit'])) {
         $arFilter[">=DATE_ACTIVE_TO"] = $fromLimit;
     }
     if (isset($arParams['toLimit'])) {
         $arFilter["<=DATE_ACTIVE_FROM"] = $toLimit;
     }
     if (is_array($arUserIds) && count($arUserIds) > 0) {
         $arFilter["CREATED_BY"] = $arUserIds;
     } elseif ($arUserIds !== false) {
         return false;
     }
     $arCalendarPrivStatus = array();
     $arSort = array('ACTIVE_FROM' => 'ASC');
     //Sort
     $rsElement = CIBlockElement::GetList($arSort, $arFilter, false, false, $arSelect);
     while ($obElement = $rsElement->GetNextElement()) {
         $arItem = $obElement->GetFields();
         $props = $obElement->GetProperties();
         if (isset($props['CONFIRMED']) && ($props['CONFIRMED']['VALUE_XML_ID'] == 'Q' || $props['CONFIRMED']['VALUE_XML_ID'] == 'N')) {
             continue;
         }
         $calendarId = $arItem['IBLOCK_SECTION_ID'];
         if (!$arCalendarPrivStatus[$calendarId]) {
             $arCalendarPrivStatus[$calendarId] = CECCalendar::GetPrivateStatus($iblockId, $calendarId, 'USER');
         }
         $privateStatus = $arCalendarPrivStatus[$calendarId];
         if ($privateStatus == 'private') {
             // event in private calendar
             continue;
         }
         //$props = $obElement->GetProperties();
         if (!isset($props['ACCESSIBILITY']['VALUE']) || $props['ACCESSIBILITY']['VALUE'] != 'absent') {
             continue;
         }
         if ($privateStatus == 'title') {
             $arItem['DETAIL_TEXT'] = '';
         } elseif ($privateStatus == 'time') {
             $arItem['~NAME'] = $arItem['NAME'] = GetMessage('EC_ACCESSIBILITY_ABSENT');
             $arItem['DETAIL_TEXT'] = '';
         }
         $arItem["DISPLAY_ACTIVE_FROM"] = CIBlockFormatProperties::DateFormat(getDateFormat(true), MakeTimeStamp($arItem["ACTIVE_FROM"]));
         $arItem["DISPLAY_ACTIVE_TO"] = CIBlockFormatProperties::DateFormat(getDateFormat(true), MakeTimeStamp($arItem["ACTIVE_TO"]));
         $perType = isset($props['PERIOD_TYPE']['VALUE']) && $props['PERIOD_TYPE']['VALUE'] != 'NONE' ? strtoupper($props['PERIOD_TYPE']['VALUE']) : false;
         if ($perType) {
             $count = isset($props['PERIOD_COUNT']['VALUE']) ? intval($props['PERIOD_COUNT']['VALUE']) : '';
             $length = isset($props['EVENT_LENGTH']['VALUE']) ? intval($props['EVENT_LENGTH']['VALUE']) : '';
             $additional = isset($props['PERIOD_ADDITIONAL']['VALUE']) ? $props['PERIOD_ADDITIONAL']['VALUE'] : '';
             $l1 = count($RESULT);
             CEventCalendar::DisplayPeriodicEvent($RESULT, array('arItem' => $arItem, 'perType' => $perType, 'count' => $count, 'length' => $length, 'additional' => $additional, 'fromLimit' => $fromLimit, 'toLimit' => $toLimit, 'bJS' => false, 'bSuperposed' => false));
             for ($i = $l1; $i < count($RESULT); $i++) {
                 CEventCalendar::HandleAbsentEvent($RESULT[$i], $arItem['CREATED_BY'], $A_RESULT);
             }
         } else {
             CEventCalendar::HandleElement($RESULT, $arItem, false, false, false);
             CEventCalendar::HandleAbsentEvent($RESULT[count($RESULT) - 1], $arItem['CREATED_BY'], $A_RESULT);
         }
     }
     if ($arParams['bList']) {
         return $RESULT;
     }
     return $A_RESULT;
 }