public static function ModifyEvent($calendarId, $arFields) { list($iblockId, $sectionId, $subSectionId, $ownerType, $ownerId) = $calendarId; $ownerType = strtoupper($ownerType); $cal = self::GetInstance(); $arFields["ACTIVE"] = "Y"; $arFields["IBLOCK_SECTION"] = $subSectionId > 0 ? $subSectionId : $sectionId; $arFields["IBLOCK_ID"] = $iblockId; if ($arFields["NAME"] == '') { $arFields["NAME"] = GetMessage('EC_NONAME_EVENT'); } $eventId = isset($arFields["ID"]) && intval($arFields["ID"]) > 0 ? intval($arFields["ID"]) : 0; unset($arFields["ID"]); if ($ownerType == 'USER' && $ownerId > 0) { $arFields['CREATED_BY'] = $ownerId; } $arFieldsNew = array(); $arPropertiesNew = array(); $len = strlen("PROPERTY_"); foreach ($arFields as $key => $value) { if (substr($key, 0, $len) == "PROPERTY_") { $arPropertiesNew[substr($key, $len)] = $value; } else { $arFieldsNew[$key] = $value; } } $accessibility = CECEvent::GetAccessibility($iblockId, $eventId); if ($accessibility == 'absent' && $accessibility == 'quest' && $arPropertiesNew['ACCESSIBILITY'] != $accessibility) { $arPropertiesNew['ACCESSIBILITY'] = $accessibility; } if (count($arPropertiesNew) > 0) { $arFieldsNew["PROPERTY_VALUES"] = $arPropertiesNew; } $bs = new CIBlockElement(); $res = false; if ($eventId > 0) { $res = $bs->Update($eventId, $arFieldsNew, false); } else { $eventId = $bs->Add($arFieldsNew, false); $eventId = intval($eventId); $res = $eventId > 0; } CEventCalendar::ClearCache('event_calendar/events/' . $iblockId . '/'); return $res ? $eventId : $bs->LAST_ERROR; }