public function getDataToShow() { $event = \CCalendarEvent::getById($this->entityId); if (empty($event)) { return array(); } $members = array(); if ($event['IS_MEETING']) { if (is_array($event['~ATTENDEES'])) { foreach ($event['~ATTENDEES'] as $user) { $members[] = array("NAME" => $user['DISPLAY_NAME'], "LINK" => \CComponentEngine::makePathFromTemplate($this->getPathToUser(), array("user_id" => $user['USER_ID'])), 'AVATAR_SRC' => $user['AVATAR'], "IS_EXTRANET" => "N"); } } } else { $by = "id"; $order = "asc"; $userRow = \CUser::getList($by, $order, array("ID_EQUAL_EXACT" => $event['CREATED_BY'], "ACTIVE" => "Y"), array("SELECT" => array('ID', 'NAME', 'LAST_NAME', 'LOGIN', 'PERSONAL_PHOTO')))->fetch(); if ($userRow) { $name = trim($userRow['NAME'] . ' ' . $userRow['LAST_NAME']); if ($name == '') { $name = trim($userRow['LOGIN']); } $members[] = array("NAME" => $name, "LINK" => \CComponentEngine::makePathFromTemplate($this->getPathToUser(), array("user_id" => $event['CREATED_BY'])), 'AVATAR_SRC' => Ui\Avatar::getPerson($userRow['PERSONAL_PHOTO']), "IS_EXTRANET" => "N"); } } return array('TITLE' => Loc::getMessage('DISK_UF_CAL_EVENT_CONNECTOR_TITLE') . ": " . $event['NAME'], 'DETAIL_URL' => null, 'DESCRIPTION' => Ui\Text::killTags($event['DESCRIPTION']), 'MEMBERS' => $members); }
public static function GetList($arOrder = array('CREATED_DATE' => 'DESC'), $arFilter = array(), $arSelect = array(), $nPageTop = false) { // Fix for #27449 if (!CModule::IncludeModule('calendar')) { $obRes = new CDBResult(); $obRes->InitFromArray(array()); return $obRes; } global $USER; $ENTITY_ID = 'CALENDAR_EVENT'; $arElement = $GLOBALS['USER_FIELD_MANAGER']->GetUserFields($ENTITY_ID, 0, LANGUAGE_ID); if ($arElement == false || !isset($arElement['UF_CRM_CAL_EVENT'])) { $arFields = array(); $arFields['ENTITY_ID'] = $ENTITY_ID; $arFields['FIELD_NAME'] = 'UF_CRM_CAL_EVENT'; $arFields['USER_TYPE_ID'] = 'crm'; $arFields['EDIT_FORM_LABEL'][LANGUAGE_ID] = GetMessage('CRM_UF_NAME'); $arFields['LIST_COLUMN_LABEL'][LANGUAGE_ID] = GetMessage('CRM_UF_NAME'); $arFields['LIST_FILTER_LABEL'][LANGUAGE_ID] = GetMessage('CRM_UF_NAME'); $arFields['SETTINGS']['LEAD'] = 'Y'; $arFields['SETTINGS']['CONTACT'] = 'Y'; $arFields['SETTINGS']['COMPANY'] = 'Y'; $arFields['SETTINGS']['DEAL'] = 'Y'; $arFields['MULTIPLE'] = 'Y'; $CAllUserTypeEntity = new CUserTypeEntity(); $CAllUserTypeEntity->Add($arFields); } if (isset($arFilter['ENTITY_TYPE']) && isset($arFilter['ENTITY_ID'])) { $arFilter['ENTITY_TYPE'] = CUserTypeCrm::GetShortEntityType($arFilter['ENTITY_TYPE']); $arFilter['UF_CRM_CAL_EVENT'] = $arFilter['ENTITY_TYPE'] . '_' . $arFilter['ENTITY_ID']; unset($arFilter['ENTITY_TYPE'], $arFilter['ENTITY_ID']); } else { if (!empty($arFilter['ENTITY_TYPE'])) { $arFilter['ENTITY_TYPE'] = CUserTypeCrm::GetShortEntityType($arFilter['ENTITY_TYPE']); $arFilter['%UF_CRM_CAL_EVENT'] = $arFilter['ENTITY_TYPE'] . '_'; unset($arFilter['ENTITY_TYPE']); } else { $arFilter['!=UF_CRM_CAL_EVENT'] = ''; } } $arFilter['CAL_TYPE'] = 'user'; $arFilter['DELETED'] = 'N'; if (isset($arFilter['OWNER_ID']) && is_array($arFilter['OWNER_ID'])) { $arFilter['OWNER_ID'] = current($arFilter['OWNER_ID']); } $arCal = CCalendarEvent::GetList(array('arFilter' => $arFilter, 'parseRecursion' => false, 'userId' => $USER->GetID(), 'fetchAttendees' => false, 'fetchMeetings' => true)); $obRes = new CDBResult(); $obRes->InitFromArray($arCal); return $obRes; }
public static function ConvertCalEvents($checkPerms = true, $regEvent = true) { if (!(IsModuleInstalled('calendar') && CModule::IncludeModule('calendar'))) { return 0; } $arEvents = CCalendarEvent::GetList(array('arFilter' => array('!UF_CRM_CAL_EVENT' => null, 'DELETED' => 'N'), 'getUserfields' => true)); $total = 0; foreach ($arEvents as $arEvent) { $eventID = $arEvent['ID']; $count = CCrmActivity::GetCount(array('@TYPE_ID' => array(CCrmActivityType::Call, CCrmActivityType::Meeting), '=ASSOCIATED_ENTITY_ID' => $eventID)); if ($count === 0 && CCrmActivity::CreateFromCalendarEvent($eventID, $arEvent, $checkPerms, $regEvent) > 0) { $total++; } } return $total; }
protected static function getEvent($arParams) { global $USER; $arEvents = CCalendarEvent::GetList(array('arFilter' => array("ID" => $arParams['ID'], "DELETED" => "N"), 'parseRecursion' => true, 'fetchAttendees' => true, 'checkPermissions' => true)); if (is_array($arEvents) && count($arEvents) > 0) { $arEvent = $arEvents[0]; if ($arEvent['IS_MEETING']) { $arGuests = $arEvent['~ATTENDEES']; $arEvent['GUESTS'] = array(); foreach ($arGuests as $guest) { $arEvent['GUESTS'][] = array('id' => $guest['USER_ID'], 'name' => CUser::FormatName(CSite::GetNameFormat(null, $arParams['SITE_ID']), $guest, true), 'status' => $guest['STATUS'], 'accessibility' => $guest['ACCESSIBILITY'], 'bHost' => $guest['USER_ID'] == $arEvent['MEETING_HOST']); if ($guest['USER_ID'] == $USER->GetID()) { $arEvent['STATUS'] = $guest['STATUS']; } } } $set = CCalendar::GetSettings(); $url = str_replace('#user_id#', $arEvent['CREATED_BY'], $set['path_to_user_calendar']) . '?EVENT_ID=' . $arEvent['ID']; return array('ID' => $arEvent['ID'], 'NAME' => $arEvent['NAME'], 'DETAIL_TEXT' => $arEvent['DESCRIPTION'], 'DATE_FROM' => $arEvent['DT_FROM'], 'DATE_TO' => $arEvent['DT_TO'], 'ACCESSIBILITY' => $arEvent['ACCESSIBILITY'], 'IMPORTANCE' => $arEvent['IMPORTANCE'], 'STATUS' => $arEvent['STATUS'], 'IS_MEETING' => $arEvent['IS_MEETING'] ? 'Y' : 'N', 'GUESTS' => $arEvent['GUESTS'], 'URL' => $url); } }
if ($arParams['TYPE'] == 1 || !$calendar2) { if ($arParams['IBLOCK_ID'] <= 0) { $arParams['IBLOCK_ID'] = COption::GetOptionInt('intranet', $arParams['TYPE'] == 1 ? 'iblock_absence' : 'iblock_calendar'); } $arSelect = array('ID', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'DATE_ACTIVE_FROM', 'DATE_ACTIVE_TO', 'NAME', 'PREVIEW_TEXT', 'DETAIL_TEXT'); if ($arParams['TYPE'] == 1) { $arSelect = array_merge($arSelect, array('PROPERTY_USER', 'PROPERTY_FINISH_STATE', 'PROPERTY_STATE', 'PROPERTY_ABSENCE_TYPE')); } else { $arSelect = array_merge($arSelect, array('PROPERTY_PERIOD_TYPE', 'PROPERTY_PERIOD_COUNT', 'PROPERTY_EVENT_LENGTH', 'PROPERTY_PERIOD_ADDITIONAL')); } $dbRes = CIBlockElement::GetList(array(), array('IBLOCK_ID' => $arParams['IBLOCK_ID'], 'ID' => $arParams['ID']), false, false, $arSelect); $arResult['ENTRY'] = $dbRes->Fetch(); $arResult['ENTRY']['DATE_ACTIVE_FROM'] = MakeTimeStamp($arResult['ENTRY']['DATE_ACTIVE_FROM']); $arResult['ENTRY']['DATE_ACTIVE_TO'] = MakeTimeStamp($arResult['ENTRY']['DATE_ACTIVE_TO']); } else { $arEvent = CCalendarEvent::GetById($arParams['ID']); $arResult['ENTRY'] = array('ID' => $arEvent['ID'], 'NAME' => $arEvent['NAME'], 'PREVIEW_TEXT' => '', 'DETAIL_TEXT' => $arEvent['DESCRIPTION'], 'DATE_ACTIVE_FROM' => $arEvent['DT_FROM_TS'] + date('Z') - date('Z', $arEvent['DT_FROM_TS']), 'DATE_ACTIVE_TO' => $arEvent['DT_TO_TS'] + date('Z') - date('Z', $arEvent['DT_TO_TS']), 'USER' => $arEvent['CREATED_BY'], 'PROPERTY_PERIOD_TYPE_VALUE' => 'NONE'); if ($arEvent['RRULE']) { $arRRule = array(); $arRRuleStr = explode(';', $arEvent['RRULE']); foreach ($arRRuleStr as $str) { list($param, $value) = explode('=', $str); $arRRule[$param] = $value; } $arResult['ENTRY']['PROPERTY_PERIOD_TYPE_VALUE'] = $arRRule['FREQ']; } } if ($arResult['ENTRY']) { $arResult['ENTRY']['DATE_ACTIVE_FROM'] = FormatDate($DB->DateFormatToPhp(CSite::GetDateFormat(CIntranetUtils::IsDateTime($arResult['ENTRY']['DATE_ACTIVE_FROM']) ? 'FULL' : 'SHORT', $arParams['SITE_ID'], true)), $arResult['ENTRY']['DATE_ACTIVE_FROM']); $arResult['ENTRY']['DATE_ACTIVE_TO'] = FormatDate($DB->DateFormatToPhp(CSite::GetDateFormat(CIntranetUtils::IsDateTime($arResult['ENTRY']['DATE_ACTIVE_TO']) ? 'FULL' : 'SHORT', $arParams['SITE_ID'], true)), $arResult['ENTRY']['DATE_ACTIVE_TO']); if ($arParams['TYPE'] == 1) {
public static function FixForumCommentURL($arData) { if( in_array($arData["MODULE_ID"], array("forum", "FORUM")) && $arData['ENTITY_TYPE_ID'] === 'FORUM_POST' && intval($arData['PARAM1']) > 0 && preg_match('/^EVENT_([0-9]+)/', $arData["TITLE"], $match) ) { $arCalendarSettings = CCalendar::GetSettings(); $forumID = $arCalendarSettings["forum_id"]; $eventID = intval($match[1]); if ( intval($arData['PARAM1']) == $forumID && $eventID > 0 && !empty($arCalendarSettings["pathes"]) && ($arCalendarEvent = CCalendarEvent::GetById($eventID)) && strlen($arCalendarEvent["CAL_TYPE"]) > 0 && in_array($arCalendarEvent["CAL_TYPE"], array("user", "group")) && intval($arCalendarEvent["OWNER_ID"]) > 0 ) { foreach ($arData['LID'] as $siteId => $value) { $messageUrl = false; if ( array_key_exists($siteId, $arCalendarSettings["pathes"]) && is_array($arCalendarSettings["pathes"][$siteId]) && !empty($arCalendarSettings["pathes"][$siteId]) ) { if ($arCalendarEvent["CAL_TYPE"] == "user") { if ( array_key_exists("path_to_user_calendar", $arCalendarSettings["pathes"][$siteId]) && !empty($arCalendarSettings["pathes"][$siteId]["path_to_user_calendar"]) ) { $messageUrl = CComponentEngine::MakePathFromTemplate( $arCalendarSettings["pathes"][$siteId]["path_to_user_calendar"], array( "user_id" => $arCalendarEvent['OWNER_ID'], ) ); } } else { if ( array_key_exists("path_to_group_calendar", $arCalendarSettings["pathes"][$siteId]) && !empty($arCalendarSettings["pathes"][$siteId]["path_to_group_calendar"]) ) { $messageUrl = CComponentEngine::MakePathFromTemplate( $arCalendarSettings["pathes"][$siteId]["path_to_group_calendar"], array( "group_id" => $arCalendarEvent['OWNER_ID'], ) ); } } } $arData['LID'][$siteId] = ($messageUrl ? $messageUrl."?EVENT_ID=".$arCalendarEvent["ID"]."&MID=".$arData['ENTITY_ID']."#message".$arData['ENTITY_ID'] : ""); } return $arData; } return array( "TITLE" => "", "BODY" => "" ); } }
if ($arResult['NEW']) { } else { $Event = CCalendarEvent::GetList(array('arFilter' => array("ID" => $eventId, "OWNER_ID" => $userId, "DELETED" => "N"), 'parseRecursion' => false, 'fetchAttendees' => true, 'fetchMeetings' => true, 'checkPermissions' => true, 'setDefaultLimit' => false)); if ($Event && is_array($Event[0])) { $Event = $Event[0]; if ($Event['IS_MEETING']) { foreach ($Event['~ATTENDEES'] as $attendee) { $attendee['DISPLAY_NAME'] = CCalendar::GetUserName($attendee); $arAttendees[] = $attendee; } unset($Event['~ATTENDEES']); $arResult['ATTENDEES'] = $arAttendees; } $Event['~LOCATION'] = $Event['LOCATION'] !== '' ? CCalendar::GetTextLocation($Event["LOCATION"]) : ''; if ($Event['RRULE'] !== '') { $Event['RRULE'] = CCalendarEvent::ParseRRULE($Event['RRULE']); if (is_array($Event['RRULE']) && !isset($Event['RRULE']['UNTIL'])) { $Event['RRULE']['UNTIL'] = $Event['DT_TO_TS']; } $Event['DT_TO_TS'] = $Event['DT_FROM_TS'] + intval($Event['DT_LENGTH']); } $arResult['EVENT'] = $Event; $calType = $Event['CAL_TYPE']; $ownerId = $Event['OWNER_ID']; } else { $Event = array(); // Event is not found $arResult['DELETED'] = "Y"; $arResult['EVENT_ID'] = $eventId; } }
private static function FormatICal($section, $events) { global $APPLICATION; $res = 'BEGIN:VCALENDAR' . "\n" . 'PRODID:-//Bitrix//Bitrix Calendar//EN' . "\n" . 'VERSION:2.0' . "\n" . 'CALSCALE:GREGORIAN' . "\n" . 'METHOD:PUBLISH' . "\n" . 'X-WR-CALNAME:' . self::_ICalPaste($section['NAME']) . "\n" . 'X-WR-CALDESC:' . self::_ICalPaste($section['DESCRIPTION']) . "\n"; $localTime = new DateTime(); $localOffset = $localTime->getOffset(); foreach ($events as $event) { $fromTs = CCalendar::Timestamp($event['DATE_FROM']); $toTs = CCalendar::Timestamp($event['DATE_TO']); if ($event['DT_SKIP_TIME'] === "Y") { $dtStart = date("Ymd", $fromTs); $dtEnd = date("Ymd", $toTs + CCalendar::GetDayLen()); } else { $fromTsUTC = $fromTs - $event['TZ_OFFSET_FROM']; $toTsUTC = $toTs - $event['TZ_OFFSET_TO']; $dtStart = date("Ymd\\THis\\Z", $fromTsUTC); $dtEnd = date("Ymd\\THis\\Z", $toTsUTC); } $dtStamp = str_replace('T000000Z', '', date("Ymd\\THisZ", CCalendar::Timestamp($event['TIMESTAMP_X']) - $localOffset)); $uid = md5(uniqid(rand(), true) . $event['ID']) . '@bitrix'; $period = ''; $rrule = CCalendarEvent::ParseRRULE($event['RRULE']); if ($rrule && isset($rrule['FREQ']) && $rrule['FREQ'] != 'NONE') { $period = 'RRULE:FREQ=' . $rrule['FREQ'] . ';'; $period .= 'INTERVAL=' . $rrule['INTERVAL'] . ';'; if ($rrule['FREQ'] == 'WEEKLY') { $period .= 'BYDAY=' . implode(',', $rrule['BYDAY']) . ';'; } $until = date("Ymd", $event['DATE_TO_TS_UTC']); if ($until != '20380101') { $period .= 'UNTIL=' . $until . ';'; } $period .= 'WKST=MO'; $period .= "\n"; } $res .= 'BEGIN:VEVENT' . "\n"; if ($event['DT_SKIP_TIME'] === "Y") { $res .= 'DTSTART;VALUE=DATE:' . $dtStart . "\n" . 'DTEND;VALUE=DATE:' . $dtEnd . "\n"; } else { $res .= 'DTSTART;VALUE=DATE-TIME:' . $dtStart . "\n" . 'DTEND;VALUE=DATE-TIME:' . $dtEnd . "\n"; } $res .= 'DTSTAMP:' . $dtStamp . "\n" . 'UID:' . $uid . "\n" . 'SUMMARY:' . self::_ICalPaste($event['NAME']) . "\n" . 'DESCRIPTION:' . self::_ICalPaste($event['DESCRIPTION']) . "\n" . $period . "\n" . 'CLASS:PRIVATE' . "\n" . 'LOCATION:' . self::_ICalPaste(CCalendar::GetTextLocation($event['LOCATION'])) . "\n" . 'SEQUENCE:0' . "\n" . 'STATUS:CONFIRMED' . "\n" . 'TRANSP:TRANSPARENT' . "\n" . 'END:VEVENT' . "\n"; } $res .= 'END:VCALENDAR'; if (!defined('BX_UTF') || BX_UTF !== true) { $res = $APPLICATION->ConvertCharset($res, LANG_CHARSET, 'UTF-8'); } return $res; }
public static function DeleteEvent($eventId) { if (self::IsNewCalendar()) { CCalendarEvent::Delete(array('id' => $eventId, 'bMarkDeleted' => true)); } }
public function GetEvents($date) { $arEvents = array(); if (CBXFeatures::IsFeatureEnabled('Calendar')) { $ts = CTimeMan::RemoveHoursTS(MakeTimeStamp($date)); if ($ts > 0) { $calendar2 = COption::GetOptionString("intranet", "calendar_2", "N") == "Y" && CModule::IncludeModule('calendar'); if ($calendar2) { $arFilter = array('arFilter' => array("OWNER_ID" => $this->USER_ID, "FROM_LIMIT" => ConvertTimeStamp($ts, 'FULL'), "TO_LIMIT" => ConvertTimeStamp($ts + 86399, 'FULL')), 'parseRecursion' => true, 'userId' => $this->USER_ID, 'skipDeclined' => true, 'fetchAttendees' => false, 'fetchMeetings' => true); $arNewEvents = CCalendarEvent::GetList($arFilter); if (count($arNewEvents) > 0) { foreach ($arNewEvents as $arEvent) { if ($arEvent['RRULE']) { $ts_from = MakeTimeStamp($arEvent['DT_FROM']); $ts_to = MakeTimeStamp($arEvent['DT_TO']); if ($ts_to < $ts || $ts_from > $ts + 86399) { continue; } } $arEvents[] = array('ID' => $arEvent['ID'], 'OWNER_ID' => $this->USER_ID, 'CREATED_BY' => $arEvent['CREATED_BY'], 'NAME' => $arEvent['NAME'], 'DETAIL_TEXT' => $arEvent['DESCRIPTION'], 'DATE_FROM' => $arEvent['DT_FROM'], 'DATE_TO' => $arEvent['DT_TO'], 'IMPORTANCE' => $arEvent['IMPORTANCE'], 'ACCESSIBILITY' => $arEvent['ACCESSIBILITY']); } } } else { $arEvents = CEventCalendar::GetNearestEventsList(array('userId' => $this->USER_ID, 'bCurUserList' => true, 'fromLimit' => ConvertTimeStamp($ts, 'FULL'), 'toLimit' => ConvertTimeStamp($ts + 86399, 'FULL'), 'iblockId' => COption::GetOptionInt('intranet', 'iblock_calendar'))); foreach ($arEvents as $key => $event) { if ($event['STATUS'] === 'N') { unset($arEvents[$key]); } } } return array_values($arEvents); } } return false; }
public static function GetAbsent($users = false, $Params = array()) { global $DB; $curUserId = isset($Params['userId']) ? intVal($Params['userId']) : CCalendar::GetCurUserId(); $arUsers = array(); if ($users !== false && is_array($users)) { foreach($users as $id) { if ($id > 0) $arUsers[] = intVal($id); } } if (!count($arUsers)) $users = false; // Part 1: select ordinary events $arFilter = array( 'CAL_TYPE' => 'user', 'DELETED' => 'N', 'ACCESSIBILITY' => 'absent' ); if (isset($Params['fromLimit'])) $arFilter['FROM_LIMIT'] = CCalendar::Date(CCalendar::Timestamp($Params['fromLimit'], false), true, false); if (isset($Params['toLimit'])) $arFilter['TO_LIMIT'] = CCalendar::Date(CCalendar::Timestamp($Params['toLimit'], false), true, false); $arEvents = CCalendarEvent::GetList( array( 'arFilter' => $arFilter, 'getUserfields' => false, 'parseRecursion' => true, 'fetchAttendees' => false, 'fetchMeetings' => true, 'userId' => $curUserId, 'checkPermissions' => false, 'preciseLimits' => true ) ); // Part 2: select attendees if (count($arUsers) > 0) $userQ = ' AND CA.USER_ID in ('.implode(',',$arUsers).')'; else $userQ = ''; $strSql = " SELECT CA.EVENT_ID as ID, CA.USER_ID, CA.STATUS, CA.ACCESSIBILITY, CE.CAL_TYPE,CE.OWNER_ID,CE.NAME,".$DB->DateToCharFunction("CE.DT_FROM")." as DT_FROM,".$DB->DateToCharFunction("CE.DT_TO")." as DT_TO, CE.DT_LENGTH, CE.PRIVATE_EVENT, CE.ACCESSIBILITY, CE.IMPORTANCE, CE.IS_MEETING, CE.MEETING_HOST, CE.MEETING, CE.LOCATION, CE.RRULE, CE.EXRULE, CE.RDATE, CE.EXDATE, CES.SECT_ID FROM b_calendar_attendees CA LEFT JOIN b_calendar_event CE ON(CA.EVENT_ID=CE.ID) LEFT JOIN b_calendar_event_sect CES ON (CA.EVENT_ID=CES.EVENT_ID) WHERE CE.ID IS NOT NULL AND STATUS='Y' AND CA.ACCESSIBILITY='absent' $userQ "; if(isset($arFilter['FROM_LIMIT'])) { $strSql .= "AND "; if (strtoupper($DB->type) == "MYSQL") $strSql .= "CE.DT_TO>=FROM_UNIXTIME('".MkDateTime(FmtDate($arFilter['FROM_LIMIT'],"D.M.Y"),"d.m.Y")."')"; elseif(strtoupper($DB->type) == "MSSQL") $strSql .= "CE.DT_TO>=".$DB->CharToDateFunction($arFilter['FROM_LIMIT'], "SHORT"); elseif(strtoupper($DB->type) == "ORACLE") $strSql .= "CE.DT_TO>=TO_DATE('".FmtDate($arFilter['FROM_LIMIT'], "D.M.Y")." 00:00:00','dd.mm.yyyy hh24:mi:ss')"; } if($arFilter['TO_LIMIT']) { $strSql .= "AND "; if (strtoupper($DB->type) == "MYSQL") $strSql .= "CE.DT_FROM<=FROM_UNIXTIME('".MkDateTime(FmtDate($arFilter['TO_LIMIT'],"D.M.Y")." 23:59:59","d.m.Y H:i:s")."')"; elseif(strtoupper($DB->type) == "MSSQL") $strSql .= "CE.DT_FROM<=dateadd(day, 1, ".$DB->CharToDateFunction($arFilter['TO_LIMIT'], "SHORT").")"; elseif(strtoupper($DB->type) == "ORACLE") $strSql .= "CE.DT_FROM<=TO_DATE('".FmtDate($arFilter['TO_LIMIT'], "D.M.Y")." 23:59:59','dd.mm.yyyy hh24:mi:ss')"; } $res = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__); $arEvents2 = array(); while($event = $res->Fetch()) { $event = self::PreHandleEvent($event); if ($event['CAL_TYPE'] == 'user' && $event['IS_MEETING'] && $event['OWNER_ID'] == $event['USER_ID']) continue; if (self::CheckRecurcion($event)) self::ParseRecursion($arEvents2, $event, array( 'fromLimit' => $arFilter["FROM_LIMIT"], 'toLimit' => $arFilter["TO_LIMIT"], )); else self::HandleEvent($arEvents2, $event); } $arEvents = array_merge($arEvents, $arEvents2); $bSocNet = CModule::IncludeModule("socialnetwork"); $result = array(); $settings = CCalendar::GetSettings(array('request' => false)); foreach($arEvents as $event) { $userId = isset($event['USER_ID']) ? $event['USER_ID'] : $event['OWNER_ID']; if ($users !== false && !in_array($userId, $arUsers)) continue; if ($bSocNet && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $userId, "calendar")) continue; if ((!$event['CAL_TYPE'] != 'user' || $curUserId != $event['OWNER_ID']) && $curUserId != $event['CREATED_BY'] && !isset($arUserMeeting[$event['ID']])) { $sectId = $event['SECT_ID']; if (!$event['ACCESSIBILITY']) $event['ACCESSIBILITY'] = 'busy'; $private = $event['PRIVATE_EVENT'] && $event['CAL_TYPE'] == 'user'; $bManager = false; if (!$private && CCalendar::IsIntranetEnabled() && CModule::IncludeModule('intranet') && $event['CAL_TYPE'] == 'user' && $settings['dep_manager_sub']) $bManager = in_array($curUserId, CCalendar::GetUserManagers($event['OWNER_ID'], true)); if ($private || (!CCalendarSect::CanDo('calendar_view_full', $sectId) && !$bManager)) { if ($private) { $event['NAME'] = '['.GetMessage('EC_ACCESSIBILITY_'.strtoupper($event['ACCESSIBILITY'])).']'; } else { if (!CCalendarSect::CanDo('calendar_view_title', $sectId)) $event['NAME'] = '['.GetMessage('EC_ACCESSIBILITY_'.strtoupper($event['ACCESSIBILITY'])).']'; else $event['NAME'] = $event['NAME'].' ['.GetMessage('EC_ACCESSIBILITY_'.strtoupper($event['ACCESSIBILITY'])).']'; } } } $result[] = array( 'ID' => $event['ID'], 'NAME' => $event['NAME'], 'DATE_FROM' => $event['DT_FROM'], 'DATE_TO' => $event['DT_TO'], 'DT_FROM_TS' => $event['DT_FROM_TS'], 'DT_TO_TS' => $event['DT_TO_TS'], 'CREATED_BY' => $userId, 'DETAIL_TEXT' => '', 'USER_ID' => $userId ); } // Sort by DT_FROM_TS usort($result, array('CCalendar', '_NearestSort')); return $result; }
public static function EditCalendarEventEntry($arFields = array(), $arUFFields = array(), $arAccessCodes = array(), $params = array()) { global $DB; if ($arFields['SECTION']) { $arFields['SECTIONS'] = array($arFields['SECTION']); } $arFields["OWNER_ID"] = $params["userId"]; $arFields["CAL_TYPE"] = $params["type"]; // Add author for new event //if (!$arFields["ID"] && !empty($arAccessCodes)) if (!$arFields["ID"]) { $arAccessCodes[] = 'U' . $params["userId"]; } $arAccessCodes = array_unique($arAccessCodes); $arAttendees = CCalendar::GetDestinationUsers($arAccessCodes); if (trim($arFields["NAME"]) === '') { $arFields["NAME"] = GetMessage('EC_DEFAULT_EVENT_NAME'); } $arFields['IS_MEETING'] = !empty($arAttendees) && $arAttendees != array($params["userId"]); if (isset($arFields['RRULE']) && !empty($arFields['RRULE'])) { if (is_array($arFields['RRULE']['BYDAY'])) { $arFields['RRULE']['BYDAY'] = implode(',', $arFields['RRULE']['BYDAY']); } } if ($arFields['IS_MEETING']) { $arFields['ATTENDEES_CODES'] = $arAccessCodes; $arFields['ATTENDEES'] = $arAttendees; $arFields['MEETING_HOST'] = $params["userId"]; $arFields['MEETING'] = array('HOST_NAME' => CCalendar::GetUserName($params["userId"]), 'TEXT' => '', 'OPEN' => false, 'NOTIFY' => true, 'REINVITE' => false); } else { $arFields['ATTENDEES'] = false; } $eventId = CCalendar::SaveEvent(array('arFields' => $arFields, 'autoDetectSection' => true)); if ($eventId > 0) { if (count($arUFFields) > 0) { CCalendarEvent::UpdateUserFields($eventId, $arUFFields); } foreach ($arAccessCodes as $key => $value) { if ($value == "UA") { unset($arAccessCodes[$key]); $arAccessCodes[] = "G2"; break; } } if ($arFields['IS_MEETING'] && !empty($arUFFields['UF_WEBDAV_CAL_EVENT'])) { $UF = $GLOBALS['USER_FIELD_MANAGER']->GetUserFields("CALENDAR_EVENT", $eventId, LANGUAGE_ID); CCalendar::UpdateUFRights($arUFFields['UF_WEBDAV_CAL_EVENT'], $arAccessCodes, $UF['UF_WEBDAV_CAL_EVENT']); } $arSoFields = array("ENTITY_TYPE" => SONET_SUBSCRIBE_ENTITY_USER, "ENTITY_ID" => $params["userId"], "USER_ID" => $params["userId"], "=LOG_DATE" => $DB->CurrentTimeFunction(), "TITLE_TEMPLATE" => "#TITLE#", "TITLE" => $arFields["NAME"], "MESSAGE" => '', "TEXT_MESSAGE" => ''); $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "calendar", "SOURCE_ID" => $eventId), false, false, array("ID")); $arCodes = array(); foreach ($arAccessCodes as $value) { if (substr($value, 0, 2) === 'SG') { $arCodes[] = $value . '_K'; } $arCodes[] = $value; } $arCodes = array_unique($arCodes); if ($arRes = $dbRes->Fetch()) { CSocNetLog::Update($arRes["ID"], $arSoFields); CSocNetLogRights::DeleteByLogID($arRes["ID"]); CSocNetLogRights::Add($arRes["ID"], $arCodes); } else { $arSoFields = array_merge($arSoFields, array("EVENT_ID" => "calendar", "SITE_ID" => SITE_ID, "SOURCE_ID" => $eventId, "ENABLE_COMMENTS" => "Y", "CALLBACK_FUNC" => false)); $logID = CSocNetLog::Add($arSoFields, false); CSocNetLogRights::Add($logID, $arCodes); } } }
protected static function plannerActionShow($arParams) { global $DB, $USER; $res = false; if ($arParams['ID'] > 0) { $event = self::getEvent(array('ID' => $arParams['ID'], 'SITE_ID' => $arParams['SITE_ID'])); if ($event) { $today = ConvertTimeStamp(time() + CTimeZone::GetOffset(), 'SHORT'); $now = time(); $res = array('ID' => $event['ID'], 'NAME' => $event['NAME'], 'DESCRIPTION' => CCalendarEvent::ParseText($event['DETAIL_TEXT'], $event['ID'], $event['UF_WEBDAV_CAL_EVENT']), 'URL' => '/company/personal/user/' . $USER->GetID() . '/calendar/?EVENT_ID=' . $event['ID'], 'DATE_FROM' => MakeTimeStamp($event['DATE_FROM']), 'DATE_TO' => MakeTimeStamp($event['DATE_TO']), 'STATUS' => $event['STATUS']); $res['DATE_FROM_TODAY'] = ConvertTimeStamp(MakeTimeStamp($res['DATE_FROM']), 'SHORT') == $today; $res['DATE_TO_TODAY'] = ConvertTimeStamp(MakeTimeStamp($res['DATE_TO']), 'SHORT') == $today; if ($res['DATE_FROM_TODAY']) { if (IsAmPmMode()) { $res['DATE_F'] = FormatDate("today g:i a", $res['DATE_FROM']); $res['DATE_T'] = FormatDate("g:i a", $res['DATE_TO']); } else { $res['DATE_F'] = FormatDate("today H:i", $res['DATE_FROM']); $res['DATE_T'] = FormatDate("H:i", $res['DATE_TO']); } if ($res['DATE_TO_TODAY']) { $res['DATE_F'] .= ' - ' . $res['DATE_T']; } if ($res['DATE_FROM'] > $now) { $res['DATE_F_TO'] = GetMessage('TM_IN') . ' ' . FormatDate('Hdiff', time() * 2 - ($res['DATE_FROM'] - CTimeZone::GetOffset())); } } else { if ($res['DATE_TO_TODAY']) { $res['DATE_F'] = FormatDate(str_replace(array('#today#', '#time#'), array('today', 'H:i'), GetMessage('TM_TILL')), $res['DATE_TO']); } else { $fmt = preg_replace('/:s$/', '', $DB->DateFormatToPHP(CSite::GetDateFormat("FULL"))); $res['DATE_F'] = FormatDate($fmt, $res['DATE_FROM']); $res['DATE_F_TO'] = FormatDate($fmt, $res['DATE_TO']); } } if ($event['IS_MEETING'] == 'Y') { $arGuests = array('Y' => array(), 'N' => array(), 'Q' => array()); foreach ($event['GUESTS'] as $key => $guest) { $guest['url'] = str_replace(array('#ID#', '#USER_ID#'), $guest['id'], COption::GetOptionString('intranet', 'path_user', '/company/personal/user/#USER_ID#/', $arParams['SITE_ID'])); if ($guest['bHost']) { $res['HOST'] = $guest; } else { $arGuests[$guest['status']][] = $guest; } } $res['GUESTS'] = array_merge($arGuests['Y'], $arGuests['N'], $arGuests['Q']); } if (strlen($res['DESCRIPTION']) > 150) { $res['DESCRIPTION'] = CUtil::closetags(substr($res['DESCRIPTION'], 0, 150)) . '...'; } $res = array('EVENT' => $res); } } else { $res = array('error' => 'event not found'); } return $res; }
public static function DialogViewEvent($Params) { global $APPLICATION, $USER_FIELD_MANAGER; $id = $Params['id']; $event = $Params['event']; $event['~DT_FROM_TS'] = $event['DT_FROM_TS']; $event['~DT_TO_TS'] = $event['DT_TO_TS']; $event['DT_FROM_TS'] = $Params['fromTs']; $event['DT_TO_TS'] = $Params['fromTs'] + $event['DT_LENGTH']; $UF = $USER_FIELD_MANAGER->GetUserFields("CALENDAR_EVENT", $event['ID'], LANGUAGE_ID); $event['UF_CRM_CAL_EVENT'] = $UF['UF_CRM_CAL_EVENT']; if (empty($event['UF_CRM_CAL_EVENT']['VALUE'])) { $event['UF_CRM_CAL_EVENT'] = false; } $event['UF_WEBDAV_CAL_EVENT'] = $UF['UF_WEBDAV_CAL_EVENT']; if (empty($event['UF_WEBDAV_CAL_EVENT']['VALUE'])) { $event['UF_WEBDAV_CAL_EVENT'] = false; } $event['FROM_WEEK_DAY'] = FormatDate('D', $event['DT_FROM_TS']); $event['FROM_MONTH_DAY'] = FormatDate('j', $event['DT_FROM_TS']); $event['FROM_MONTH'] = FormatDate('n', $event['DT_FROM_TS']); $arHost = CCalendar::GetUser($event['MEETING_HOST'], true); $arHost['AVATAR_SRC'] = CCalendar::GetUserAvatarSrc($arHost); $arHost['URL'] = CCalendar::GetUserUrl($event['MEETING_HOST'], $Params["PATH_TO_USER"]); $arHost['DISPLAY_NAME'] = CCalendar::GetUserName($arHost); $curUserStatus = ''; $userId = CCalendar::GetCurUserId(); $viewComments = CCalendar::IsPersonal($event['CAL_TYPE'], $event['OWNER_ID'], $userId) || CCalendarSect::CanDo('calendar_view_full', $event['SECT_ID'], $userId); if ($event['IS_MEETING'] && empty($event['ATTENDEES_CODES'])) { $event['ATTENDEES_CODES'] = CCalendarEvent::CheckEndUpdateAttendeesCodes($event); } if ($event['IS_MEETING']) { $attendees = array('y' => array('users' => array(), 'count' => 4, 'countMax' => 8, 'title' => GetMessage('EC_ATT_Y'), 'id' => "bxview-att-cont-y-" . $event['ID']), 'n' => array('users' => array(), 'count' => 2, 'countMax' => 3, 'title' => GetMessage('EC_ATT_N'), 'id' => "bxview-att-cont-n-" . $event['ID']), 'q' => array('users' => array(), 'count' => 2, 'countMax' => 3, 'title' => GetMessage('EC_ATT_Q'), 'id' => "bxview-att-cont-q-" . $event['ID'])); if (is_array($event['~ATTENDEES'])) { foreach ($event['~ATTENDEES'] as $att) { if ($userId == $att["USER_ID"]) { $curUserStatus = $att['STATUS']; $viewComments = true; } $att['AVATAR_SRC'] = CCalendar::GetUserAvatarSrc($att); $att['URL'] = CCalendar::GetUserUrl($att["USER_ID"], $Params["PATH_TO_USER"]); $attendees[strtolower($att['STATUS'])]['users'][] = $att; } } } $arTabs = array(array('name' => GetMessage('EC_BASIC'), 'title' => GetMessage('EC_BASIC_TITLE'), 'id' => $id . "view-tab-0", 'active' => true), array('name' => GetMessage('EC_EDEV_ADD_TAB'), 'title' => GetMessage('EC_EDEV_ADD_TAB_TITLE'), 'id' => $id . "view-tab-1")); ?> <div id="bxec_view_ed_<?php echo $id; ?> " class="bxec-popup"> <div style="width: 700px; height: 1px;"></div> <div class="bxec-d-tabs" id="<?php echo $id; ?> _viewev_tabs"> <?php foreach ($arTabs as $tab) { ?> <div class="bxec-d-tab <?php if ($tab['active']) { echo 'bxec-d-tab-act'; } ?> " title="<?php echo isset($tab['title']) ? $tab['title'] : $tab['name']; ?> " id="<?php echo $tab['id']; ?> " <?php if ($tab['show'] === false) { echo 'style="display:none;"'; } ?> > <b></b><div><span><?php echo $tab['name']; ?> </span></div><i></i> </div> <?php } ?> </div> <div class="bxec-d-cont"> <?php /* ####### TAB 0 : BASIC ####### */ ?> <div id="<?php echo $id; ?> view-tab-0-cont" class="bxec-d-cont-div" style="display: block;"> <div class="bx-cal-view-icon"> <div class="bx-cal-view-icon-day"><?php echo $event['FROM_WEEK_DAY']; ?> </div> <div class="bx-cal-view-icon-date"><?php echo $event['FROM_MONTH_DAY']; ?> </div> </div> <div class="bx-cal-view-text"> <table> <tr> <td class="bx-cal-view-text-cell-l"><?php echo GetMessage('EC_T_NAME'); ?> :</td> <td class="bx-cal-view-text-cell-r"><span class="bx-cal-view-name"><?php echo htmlspecialcharsEx($event['NAME']); ?> </span></td> </tr> <tr> <td class="bx-cal-view-text-cell-l"><?php echo GetMessage('EC_DATE'); ?> :</td> <td class="bx-cal-view-text-cell-r bx-cal-view-from-to"> <?php echo CCalendar::GetFromToHtml($event['DT_FROM_TS'], $event['DT_TO_TS'], $event['DT_SKIP_TIME'] == 'Y', $event['DT_LENGTH']); ?> </td> </tr> <?php if ($event['RRULE']) { ?> <?php $event['RRULE'] = CCalendarEvent::ParseRRULE($event['RRULE']); switch ($event['RRULE']['FREQ']) { case 'DAILY': if ($event['RRULE']['INTERVAL'] == 1) { $repeatHTML = GetMessage('EC_RRULE_EVERY_DAY'); } else { $repeatHTML = GetMessage('EC_RRULE_EVERY_DAY_1', array('#DAY#' => $event['RRULE']['INTERVAL'])); } break; case 'WEEKLY': $daysList = array(); foreach ($event['RRULE']['BYDAY'] as $day) { $daysList[] = GetMessage('EC_' . $day); } $daysList = implode(', ', $daysList); if ($event['RRULE']['INTERVAL'] == 1) { $repeatHTML = GetMessage('EC_RRULE_EVERY_WEEK', array('#DAYS_LIST#' => $daysList)); } else { $repeatHTML = GetMessage('EC_RRULE_EVERY_WEEK_1', array('#WEEK#' => $event['RRULE']['INTERVAL'], '#DAYS_LIST#' => $daysList)); } break; case 'MONTHLY': if ($event['RRULE']['INTERVAL'] == 1) { $repeatHTML = GetMessage('EC_RRULE_EVERY_MONTH'); } else { $repeatHTML = GetMessage('EC_RRULE_EVERY_MONTH_1', array('#MONTH#' => $event['RRULE']['INTERVAL'])); } break; case 'YEARLY': if ($event['RRULE']['INTERVAL'] == 1) { $repeatHTML = GetMessage('EC_RRULE_EVERY_YEAR', array('#DAY#' => $event['FROM_MONTH_DAY'], '#MONTH#' => $event['FROM_MONTH'])); } else { $repeatHTML = GetMessage('EC_RRULE_EVERY_YEAR_1', array('#YEAR#' => $event['RRULE']['INTERVAL'], '#DAY#' => $event['FROM_MONTH_DAY'], '#MONTH#' => $event['FROM_MONTH'])); } break; } $repeatHTML .= '<br>' . GetMessage('EC_RRULE_FROM', array('#FROM_DATE#' => FormatDate(CCalendar::DFormat(false), $event['~DT_FROM_TS']))); if (date('dmY', $event['RRULE']['UNTIL']) != '01012038') { $repeatHTML .= ' ' . GetMessage('EC_RRULE_UNTIL', array('#UNTIL_DATE#' => FormatDate(CCalendar::DFormat(false), $event['RRULE']['UNTIL']))); } ?> <tr> <td class="bx-cal-view-text-cell-l"><?php echo GetMessage('EC_T_REPEAT'); ?> :</td> <td class="bx-cal-view-text-cell-r"><?php echo $repeatHTML; ?> </td> </tr> <?php } ?> <?php if (!empty($event['LOCATION'])) { ?> <tr> <td class="bx-cal-view-text-cell-l"><?php echo GetMessage('EC_LOCATION'); ?> :</td> <td class="bx-cal-view-text-cell-r"><span class="bx-cal-location"><?php echo htmlspecialcharsEx(CCalendar::GetTextLocation($event['LOCATION'])); ?> </span></td> </tr> <?php } ?> </table> </div> <?php if (!empty($event['~DESCRIPTION'])) { ?> <div class="bx-cal-view-description"> <div class="feed-cal-view-desc-title"><?php echo GetMessage('EC_T_DESC'); ?> :</div> <div class="bx-cal-view-desc-cont"><?php echo $event['~DESCRIPTION']; ?> </div> </div> <?php } ?> <?php if ($event['UF_WEBDAV_CAL_EVENT']) { ?> <div class="bx-cal-view-files" id="bx-cal-view-files-<?php echo $id; echo $event['ID']; ?> "> <?php $APPLICATION->IncludeComponent("bitrix:system.field.view", $event['UF_WEBDAV_CAL_EVENT']["USER_TYPE"]["USER_TYPE_ID"], array("arUserField" => $event['UF_WEBDAV_CAL_EVENT']), null, array("HIDE_ICONS" => "Y")); ?> </div> <?php } ?> <?php if ($event['UF_CRM_CAL_EVENT']) { ?> <div class="bx-cal-view-crm"> <div class="bxec-crm-title"><?php echo htmlspecialcharsbx($event['UF_CRM_CAL_EVENT']["EDIT_FORM_LABEL"]); ?> :</div> <?php $APPLICATION->IncludeComponent("bitrix:system.field.view", $event['UF_CRM_CAL_EVENT']["USER_TYPE"]["USER_TYPE_ID"], array("arUserField" => $event['UF_CRM_CAL_EVENT']), null, array("HIDE_ICONS" => "Y")); ?> </div> <?php } ?> <div id="<?php echo $id; ?> bxec_view_uf_group" class="bxec-popup-row" style="display: none;"> <div class="bxec-popup-row-title"><?php echo GetMessage('EC_EDEV_ADD_TAB'); ?> </div> <div id="<?php echo $id; ?> bxec_view_uf_cont"></div> </div> <?php if ($Params['bSocNet'] && $event['IS_MEETING']) { ?> <div class="bx-cal-view-meeting-cnt"> <table> <tr> <td class="bx-cal-view-att-cell-l bx-cal-bot-border"><span><?php echo GetMessage('EC_EDEV_HOST'); ?> :</span></td> <td class="bx-cal-view-att-cell-r bx-cal-bot-border"> <a title="<?php echo htmlspecialcharsbx($arHost['DISPLAY_NAME']); ?> " href="<?php echo $arHost['URL']; ?> " target="_blank" class="bxcal-att-popup-img bxcal-att-popup-att-full"><span class="bxcal-att-popup-avatar-outer"><span class="bxcal-att-popup-avatar"><img src="<?php echo $arHost['AVATAR_SRC']; ?> " width="<?php echo $Params['AVATAR_SIZE']; ?> " height="<?php echo $Params['AVATAR_SIZE']; ?> " /></span></span><span class="bxcal-att-name"><?php echo htmlspecialcharsbx($arHost['DISPLAY_NAME']); ?> </span></a> </td> </tr> <tr> <td class="bx-cal-view-att-cell-l"></td> <td class="bx-cal-view-att-cell-r" style="padding-top: 5px;"> <div class="bx-cal-view-title"><?php echo GetMessage('EC_EDEV_GUESTS'); ?> </div> <div class="bx-cal-att-dest-cont"> <?php $arDest = CCalendar::GetFormatedDestination($event['ATTENDEES_CODES']); $cnt = count($arDest); for ($i = 0; $i < $cnt; $i++) { $dest = $arDest[$i]; ?> <span class="bx-cal-att-dest-block"><?php echo $dest['TITLE']; ?> </span><?php if ($i < count($arDest) - 1) { echo ', '; } } ?> </div> </td> </tr> <?php foreach ($attendees as $arAtt) { if (empty($arAtt['users'])) { continue; } ?> <tr> <td class="bx-cal-view-att-cell-l"><?php echo $arAtt['title']; ?> :</td> <td class="bx-cal-view-att-cell-r"> <div class="bx-cal-view-att-cont" id="<?php echo $arAtt['id']; ?> "> <?php $cnt = 0; $bShowAll = count($arAtt['users']) <= $arAtt['countMax']; foreach ($arAtt['users'] as $att) { $cnt++; if (!$bShowAll && $cnt > $arAtt['count']) { ?> <a title="<?php echo htmlspecialcharsbx($att['DISPLAY_NAME']); ?> " href="<?php echo $att['URL']; ?> " target="_blank" class="bxcal-att-popup-img bxcal-att-popup-img-hidden"><span class="bxcal-att-popup-avatar-outer"><span class="bxcal-att-popup-avatar"><img src="<?php echo $att['AVATAR_SRC']; ?> " width="<?php echo $Params['AVATAR_SIZE']; ?> " height="<?php echo $Params['AVATAR_SIZE']; ?> " /></span></span><span class="bxcal-att-name"><?php echo htmlspecialcharsbx($att['DISPLAY_NAME']); ?> </span></a> <?php } else { ?> <a title="<?php echo htmlspecialcharsbx($att['DISPLAY_NAME']); ?> " href="<?php echo $att['URL']; ?> " target="_blank" class="bxcal-att-popup-img"><span class="bxcal-att-popup-avatar-outer"><span class="bxcal-att-popup-avatar"><img src="<?php echo $att['AVATAR_SRC']; ?> " width="<?php echo $Params['AVATAR_SIZE']; ?> " height="<?php echo $Params['AVATAR_SIZE']; ?> " /></span></span><span class="bxcal-att-name"><?php echo htmlspecialcharsbx($att['DISPLAY_NAME']); ?> </span></a> <?php } } if (!$bShowAll) { ?> <span data-bx-more-users="<?php echo $arAtt['id']; ?> " class="bxcal-more-attendees"><?php echo CCalendar::GetMoreAttendeesMessage(count($arAtt['users']) - $arAtt['count']); ?> </span> <?php } ?> </div> </td> </tr> <?php } /*foreach($attendees as $arAtt)*/ ?> <?php if (!empty($event['MEETING']['TEXT'])) { ?> <tr> <td class="bx-cal-view-att-cell-l" style="padding-top: 3px;"><?php echo GetMessage('EC_MEETING_TEXT2'); ?> :</td> <td class="bx-cal-view-att-cell-r"><pre><?php echo htmlspecialcharsEx($event['MEETING']['TEXT']); ?> </pre></td> </tr> <?php } /*if (!empty($event['MEETING']['TEXT']))*/ ?> </table> <div class="bxc-confirm-row"> <?php if ($curUserStatus == 'Q') { /* User still haven't take a decision*/ ?> <div id="<?php echo $id; ?> status-conf-cnt2" class="bxc-conf-cnt"> <span data-bx-set-status="Y" class="popup-window-button popup-window-button-accept" title="<?php echo GetMessage('EC_EDEV_CONF_Y_TITLE'); ?> "><span class="popup-window-button-left"></span><span class="popup-window-button-text"><?php echo GetMessage('EC_ACCEPT_MEETING'); ?> </span><span class="popup-window-button-right"></span></span> <a data-bx-set-status="N" class="bxc-decline-link" href="javascript:void(0)" title="<?php echo GetMessage('EC_EDEV_CONF_N_TITLE'); ?> " id="<?php echo $id; ?> decline-link-2"><?php echo GetMessage('EC_EDEV_CONF_N'); ?> </a> </div> <?php } elseif ($curUserStatus == 'Y') { /* User accepts inviting */ ?> <div id="<?php echo $id; ?> status-conf-cnt1" class="bxc-conf-cnt"> <span><?php echo GetMessage('EC_ACCEPTED_STATUS'); ?> </span> <a data-bx-set-status="N" class="bxc-decline-link" href="javascript:void(0)" title="<?php echo GetMessage('EC_EDEV_CONF_N_TITLE'); ?> "><?php echo GetMessage('EC_EDEV_CONF_N'); ?> </a> </div> <?php } elseif ($curUserStatus == 'N') { /* User declines inviting*/ ?> <div class="bxc-conf-cnt"> <span class="bxc-conf-label"><?php echo GetMessage('EC_DECLINE_INFO'); ?> </span>. <a data-bx-set-status="Y" href="javascript:void(0)" title="<?php echo GetMessage('EC_ACCEPT_MEETING_2'); ?> "><?php echo GetMessage('EC_ACCEPT_MEETING'); ?> </a> </div> <?php } elseif ($event['MEETING']['OPEN']) { /* it's open meeting*/ ?> <div class="bxc-conf-cnt"> <span class="bxc-conf-label" title="<?php echo GetMessage('EC_OPEN_MEETING_TITLE'); ?> "><?php echo GetMessage('EC_OPEN_MEETING'); ?> :</span> <span data-bx-set-status="Y" class="popup-window-button popup-window-button-accept" title="<?php echo GetMessage('EC_EDEV_CONF_Y_TITLE'); ?> "><span class="popup-window-button-left"></span><span class="popup-window-button-text"><?php echo GetMessage('EC_ACCEPT_MEETING'); ?> </span><span class="popup-window-button-right"></span></span> </div> <?php } ?> </div> </div> <?php } /*$event['IS_MEETING'])*/ ?> </div> <?php /* ####### END TAB 0 ####### */ ?> <?php /* ####### TAB 1 : ADDITIONAL ####### */ ?> <div id="<?php echo $id; ?> view-tab-1-cont" class="bxec-d-cont-div"> <div class="bx-cal-view-text-additional"> <table> <?php if ($Params['sectionName'] != '') { ?> <tr> <td class="bx-cal-view-text-cell-l"><?php echo GetMessage('EC_T_CALENDAR'); ?> :</td> <td class="bx-cal-view-text-cell-r"><?php echo htmlspecialcharsEx($Params['sectionName']); ?> </td> </tr> <?php } ?> <?php if ($event['IMPORTANCE'] != '') { ?> <tr> <td class="bx-cal-view-text-cell-l"><?php echo GetMessage('EC_IMPORTANCE_TITLE'); ?> :</td> <td class="bx-cal-view-text-cell-r"><?php echo GetMessage("EC_IMPORTANCE_" . strtoupper($event['IMPORTANCE'])); ?> </td> </tr> <?php } ?> <?php if ($event['ACCESSIBILITY'] != '' && $Params['bIntranet']) { ?> <tr> <td class="bx-cal-view-text-cell-l"><?php echo GetMessage('EC_ACCESSIBILITY_TITLE'); ?> :</td> <td class="bx-cal-view-text-cell-r"><?php echo GetMessage("EC_ACCESSIBILITY_" . strtoupper($event['ACCESSIBILITY'])); ?> </td> </tr> <?php } ?> <?php if ($event['PRIVATE_EVENT'] && $Params['bIntranet']) { ?> <tr> <td class="bx-cal-view-text-cell-l"><?php echo GetMessage('EC_EDDIV_SPECIAL_NOTES'); ?> :</td> <td class="bx-cal-view-text-cell-r"><?php echo GetMessage('EC_PRIVATE_EVENT'); ?> </td> </tr> <?php } ?> </table> </div> </div> <?php /* ####### END TAB 1 ####### */ ?> </div> <?php if ($viewComments) { ?> <div class="bxec-d-cont-comments-title"> <?php echo GetMessage('EC_COMMENTS'); ?> </div> <div class="bxec-d-cont bxec-d-cont-comments"> <?php if ($userId == $event['OWNER_ID']) { $permission = "Y"; } else { $permission = 'M'; } $set = CCalendar::GetSettings(); // A < E < I < M < Q < U < Y // A - NO ACCESS, E - READ, I - ANSWER // M - NEW TOPIC // Q - MODERATE, U - EDIT, Y - FULL_ACCESS $APPLICATION->IncludeComponent("bitrix:forum.comments", "bitrix24", array("FORUM_ID" => $set['forum_id'], "ENTITY_TYPE" => "EV", "ENTITY_ID" => $event['ID'], "ENTITY_XML_ID" => "EVENT_" . $event['ID'], "PERMISSION" => $permission, "URL_TEMPLATES_PROFILE_VIEW" => $set['path_to_user'], "SHOW_RATING" => "Y", "SHOW_LINK_TO_MESSAGE" => "N", "BIND_VIEWER" => "Y"), false, array('HIDE_ICONS' => 'Y')); ?> </div> <?php } ?> </div> <?php }
$eventId = intVal($_REQUEST['event_id']); if ($event_feed_action == 'delete_event') { $res = CCalendar::DeleteEvent($eventId); if ($res) { echo '#EVENT_FEED_RESULT_OK#'; } } else { $status = false; if ($event_feed_action == 'decline') { $status = 'N'; } elseif ($event_feed_action == 'accept') { $status = 'Y'; } if ($status && $eventId) { CCalendarEvent::SetMeetingStatus($userId, $eventId, $status); $Events = CCalendarEvent::GetList(array('arFilter' => array("ID" => $eventId, "DELETED" => "N"), 'parseRecursion' => false, 'fetchAttendees' => true, 'checkPermissions' => true, 'setDefaultLimit' => false)); if ($Events && is_array($Events[0]) && $Events[0]['IS_MEETING']) { $ajaxParams = $_REQUEST['ajax_params']; if ($ajaxParams["MOBILE"] == "Y") { $result = array('ACCEPTED_ATTENDEES_COUNT' => 0, 'DECLINED_ATTENDEES_COUNT' => 0); foreach ($Events[0]['~ATTENDEES'] as $i => $att) { if ($att['STATUS'] == "Y") { $result['ACCEPTED_ATTENDEES_COUNT']++; } elseif ($att['STATUS'] == "N") { $result['DECLINED_ATTENDEES_COUNT']++; } } if ($result['ACCEPTED_ATTENDEES_COUNT'] > 0) { $result['ACCEPTED_ATTENDEES_MESSAGE'] = CCalendar::GetAttendeesMessage($result['ACCEPTED_ATTENDEES_COUNT']); } if ($result['DECLINED_ATTENDEES_COUNT'] > 0) {
if ($Events && is_array($Events[0])) { $arResult['EVENT'] = $Events[0]; } if (!$arResult['EVENT']) { $Events = CCalendarEvent::GetList(array('arFilter' => array("ID" => $arParams['EVENT_ID'], "DELETED" => false), 'parseRecursion' => false, 'checkPermissions' => false, 'setDefaultLimit' => false)); // Clean damaged event from livefeed if (!$Events || !is_array($Events[0])) { CCalendarLiveFeed::OnDeleteCalendarEventEntry($arParams['EVENT_ID']); } return false; } if ($arResult['EVENT']['LOCATION'] !== '') { $arResult['EVENT']['LOCATION'] = CCalendar::GetTextLocation($arResult['EVENT']["LOCATION"]); } global $USER_FIELD_MANAGER; $UF = CCalendarEvent::GetEventUserFields($arResult['EVENT']); $arResult['UF_CRM_CAL_EVENT'] = $UF['UF_CRM_CAL_EVENT']; if (empty($arResult['UF_CRM_CAL_EVENT']['VALUE'])) { $arResult['UF_CRM_CAL_EVENT'] = false; } $arResult['UF_WEBDAV_CAL_EVENT'] = $UF['UF_WEBDAV_CAL_EVENT']; if (empty($arResult['UF_WEBDAV_CAL_EVENT']['VALUE'])) { $arResult['UF_WEBDAV_CAL_EVENT'] = false; } $arParams['ATTENDEES_SHOWN_COUNT'] = 4; $arParams['ATTENDEES_SHOWN_COUNT_MAX'] = 8; $arParams['AVATAR_SIZE'] = 30; if (!isset($arParams['EVENT_TEMPLATE_URL'])) { $editUrl = CCalendar::GetPath('user', '#USER_ID#'); $arParams['EVENT_TEMPLATE_URL'] = $editUrl . (strpos($editUrl, "?") === false ? '?' : '&') . 'EVENT_ID=#EVENT_ID#'; }
function InstallService($serviceID, $serviceStage) { $wizard =& $this->GetWizard(); if (CModule::IncludeModule("iblock")) { $type = substr($serviceID, 0, -1); if ($type == "iblockElement") { $dbItem = CIBlockElement::GetList(array(), array("=IBLOCK_CODE" => $serviceStage), false, false, array("ID")); while ($arItem = $dbItem->Fetch()) { CIBlockElement::Delete($arItem["ID"]); } } elseif ($type == "iblockSectionElement") { $dbItem = CIBlockElement::GetList(array(), array("=IBLOCK_CODE" => $serviceStage), false, false, array("ID")); while ($arItem = $dbItem->Fetch()) { CIBlockElement::Delete($arItem["ID"]); } $dbItem = CIBlockSection::GetList(array(), array("=IBLOCK_CODE" => $serviceStage), false, array("ID")); while ($arItem = $dbItem->Fetch()) { CIBlockSection::Delete($arItem["ID"]); } } elseif ($serviceID == "iblockDepartmentsElement") { $dbItem = CIBlockSection::GetList(array(), array("=IBLOCK_CODE" => "departments")); while ($arItem = $dbItem->Fetch()) { if ($arItem["DEPTH_LEVEL"] > 2) { CIBlockSection::Delete($arItem["ID"]); } } } elseif ($serviceID == "tasks") { if (CModule::IncludeModule("tasks")) { $dbItem = CTasks::GetList(array(), array("SITE_ID" => $wizard->GetVar("siteID"))); while ($arItem = $dbItem->Fetch()) { CTasks::Delete($arItem["ID"]); } } } elseif ($serviceID == "calendar") { if (CModule::IncludeModule("calendar")) { $dbItem = CCalendarEvent::GetList(); foreach ($dbItem as $arItem) { CCalendarEvent::Delete(array("id" => $arItem["ID"])); } } } elseif ($serviceID == "meeting") { if (CModule::IncludeModule("meeting")) { $dbItem = CMeeting::GetList(array(), array()); while ($arItem = $dbItem->Fetch()) { if ($arItem["ID"]) { CMeeting::Delete($arItem["ID"]); } } } } elseif ($serviceID == "user") { if ($serviceStage == "user") { $dbUser = CUser::GetList($by = "ID", $order = "DESC", array(">ID" => 1)); while ($arUser = $dbUser->Fetch()) { CUser::Delete($arUser["ID"]); } } } elseif ($serviceID == "crm") { if ($serviceStage == "crm") { if (CModule::IncludeModule('crm')) { $CCrmLead = new CCrmLead(); $resLead = CCrmLead::GetList(array(), array(), array(), false); while ($rowLead = $resLead->Fetch()) { $CCrmLead->Delete($rowLead["ID"]); } $CCrmContact = new CCrmContact(); $resContact = CCrmContact::GetList(array(), array(), array(), false); while ($rowContact = $resContact->Fetch()) { $CCrmContact->Delete($rowContact["ID"]); } $CCrmCompany = new CCrmCompany(); $resCompany = CCrmCompany::GetList(array(), array(), array(), false); while ($rowCompany = $resCompany->Fetch()) { $CCrmCompany->Delete($rowCompany["ID"]); } $CCrmDeal = new CCrmDeal(); $resDeal = CCrmDeal::GetList(array(), array(), array(), false); while ($rowDeal = $resDeal->Fetch()) { $CCrmDeal->Delete($rowDeal["ID"]); } } } } elseif ($serviceID == "cache") { require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/cache_html.php"; if ($serviceStage == "cache1") { BXClearCache(true); } elseif ($serviceStage == "cache2") { $GLOBALS["CACHE_MANAGER"]->CleanAll(); } elseif ($serviceStage == "cache3") { $GLOBALS["stackCacheManager"]->CleanAll(); } elseif ($serviceStage == "cache4") { CHTMLPagesCache::CleanAll(); } COption::SetOptionString("main", "wizard_clear_exec", "Y", false, $wizard->GetVar("siteID")); } } }
$arParams['SECTIONS'] = CCalendar::GetSectionList(array( 'CAL_TYPE' => $arParams['OWNER_TYPE'], 'OWNER_ID' => $arParams['CUR_USER'] )); if (empty($arParams['SECTIONS'])) { $defCalendar = CCalendarSect::CreateDefault(array( 'type' => $arParams['OWNER_TYPE'], 'ownerId' => $arParams['CUR_USER'] )); $arParams['SECTIONS'][] = $defCalendar; CCalendar::SetCurUserMeetingSection($defCalendar['ID']); } $arParams['EVENT'] = CCalendarEvent::GetById($arParams['EVENT_ID']); $arParams["DESTINATION"] = (is_array($arParams["DESTINATION"]) && IsModuleInstalled("socialnetwork") ? $arParams["DESTINATION"] : array()); $arParams["DESTINATION"] = (array_key_exists("VALUE", $arParams["DESTINATION"]) ? $arParams["DESTINATION"]["VALUE"] : $arParams["DESTINATION"]); $users = array(); foreach ($arParams["DESTINATION"]['USERS'] as $key => $entry) { if ($entry['isExtranet'] == 'N') $users[$key] = $entry; } $arParams["DESTINATION"]['USERS'] = $users; // Empty destination for new events if (!$arParams['EVENT_ID'])
public static function RefreshCalendarBindings() { if (!(IsModuleInstalled('calendar') && CModule::IncludeModule('calendar'))) { return false; } global $DB; $dbResult = $DB->Query('SELECT OWNER_ID, OWNER_TYPE_ID, ASSOCIATED_ENTITY_ID FROM ' . CCrmActivity::TABLE_NAME . ' WHERE OWNER_ID > 0 AND OWNER_TYPE_ID > 0 AND ASSOCIATED_ENTITY_ID > 0 AND TYPE_ID IN (' . CCrmActivityType::Call . ', ' . CCrmActivityType::Meeting . ')', false, 'File: ' . __FILE__ . '<br>Line: ' . __LINE__); if (!$dbResult) { return false; } while ($arResult = $dbResult->Fetch()) { $ownerID = intval($arResult['OWNER_ID']); $ownerTypeID = intval($arResult['OWNER_TYPE_ID']); $assocEntityID = intval($arResult['ASSOCIATED_ENTITY_ID']); if ($ownerID > 0 && $ownerTypeID > 0 && $assocEntityID > 0) { CCalendarEvent::UpdateUserFields($assocEntityID, array('UF_CRM_CAL_EVENT' => array(CUserTypeCrm::GetShortEntityType(CCrmOwnerType::ResolveName($ownerTypeID)) . '_' . $ownerID))); } } return true; }
public static function CanView($eventId, $userId) { CModule::IncludeModule("calendar"); $Event = CCalendarEvent::GetList( array( 'arFilter' => array( "ID" => $eventId, ), 'parseRecursion' => false, 'fetchAttendees' => true, 'checkPermissions' => true, 'userId' => $userId, ) ); if ($Event && is_array($Event[0])) { // Event partly accessible if (!isset($Event[0]['DESCRIPTION'], $Event[0]['IS_MEETING'], $Event[0]['LOCATION'])) return false; return true; } return false; }
?> " data-bx-hint="<?php echo $timezoneHint; ?> " class="bx-cal-view-timezon-icon feed-event-view-timezon-icon"></span> <?php } ?> </td> </tr> <?php if (isset($event['RRULE']) && $event['RRULE'] !== '') { ?> <?php $RRULE = CCalendarEvent::ParseRRULE($event['RRULE']); switch ($RRULE['FREQ']) { case 'DAILY': if ($RRULE['INTERVAL'] == 1) { $repeatHTML = GetMessage('EC_RRULE_EVERY_DAY'); } else { $repeatHTML = GetMessage('EC_RRULE_EVERY_DAY_1', array('#DAY#' => $RRULE['INTERVAL'])); } break; case 'WEEKLY': $daysList = array(); foreach ($RRULE['BYDAY'] as $day) { $daysList[] = GetMessage('EC_' . $day); } $daysList = implode(', ', $daysList); if ($RRULE['INTERVAL'] == 1) {
private static function FormatICal($Section, $Events) { $res = 'BEGIN:VCALENDAR PRODID:-//Bitrix//Bitrix Calendar//EN VERSION:2.0 CALSCALE:GREGORIAN METHOD:PUBLISH X-WR-CALNAME:' . self::_ICalPaste($Section['NAME']) . ' X-WR-CALDESC:' . self::_ICalPaste($Section['DESCRIPTION']) . "\n"; $localTime = new DateTime(); $localOffset = $localTime->getOffset(); $h24 = CCalendar::GetDayLen(); foreach ($Events as $event) { //$fts = CCalendar::Timestamp($event['DT_FROM']); //$tts = CCalendar::Timestamp($event['DT_TO']); $fts = $event['DT_FROM_TS']; $tts = $event['DT_TO_TS']; if ($event['DT_SKIP_TIME'] == 'Y') { $dtStart = date("Ymd", $event['DT_FROM_TS']); if ($event['DT_LENGTH'] == $h24) { $dtEnd = $dtStart; } else { $dtEnd = date("Ymd", $event['DT_TO_TS'] - $h24); } } else { $dtStart = date("Ymd\\THis\\Z", $event['DT_FROM_TS'] - $localOffset); $dtEnd = date("Ymd\\THis\\Z", $event['DT_TO_TS'] - $localOffset); } $dtStamp = str_replace('T000000Z', '', date("Ymd\\THisZ", CCalendar::Timestamp($event['TIMESTAMP_X']) - $localOffset)); $uid = md5(uniqid(rand(), true) . $event['ID']) . '@bitrix'; $period = ''; $rrule = CCalendarEvent::ParseRRULE($event['RRULE']); if ($rrule && isset($rrule['FREQ']) && $rrule['FREQ'] != 'NONE') { $period = 'RRULE:FREQ=' . $rrule['FREQ'] . ';'; $period .= 'INTERVAL=' . $rrule['INTERVAL'] . ';'; if ($rrule['FREQ'] == 'WEEKLY') { $period .= 'BYDAY=' . implode(',', $rrule['BYDAY']) . ';'; } if ($event['DT_SKIP_TIME'] == 'Y') { if ($event['DT_LENGTH'] == $h24) { $dtEnd_ = $dtStart; } else { $dtEnd_ = date("Ymd", $event['DT_FROM_TS'] + $event['DT_LENGTH'] - $h24 - $localOffset); } } else { $dtEnd_ = date("Ymd\\THisZ", $event['DT_FROM_TS'] + $event['DT_LENGTH'] - $localOffset); } if (date("Ymd", $tts) != '20380101') { $period .= 'UNTIL=' . $dtEnd . ';'; } $period .= 'WKST=MO'; $dtEnd = $dtEnd_; $period .= "\n"; } $res .= 'BEGIN:VEVENT DTSTART;VALUE=DATE:' . $dtStart . ' DTEND;VALUE=DATE:' . $dtEnd . ' DTSTAMP:' . $dtStamp . ' UID:' . $uid . ' SUMMARY:' . self::_ICalPaste($event['NAME']) . ' DESCRIPTION:' . self::_ICalPaste($event['DESCRIPTION']) . "\n" . $period . ' CLASS:PRIVATE LOCATION:' . self::_ICalPaste(CCalendar::GetTextLocation($event['LOCATION'])) . ' SEQUENCE:0 STATUS:CONFIRMED TRANSP:TRANSPARENT END:VEVENT' . "\n"; } $res .= 'END:VCALENDAR'; if (!defined('BX_UTF') || BX_UTF !== true) { $res = $GLOBALS["APPLICATION"]->ConvertCharset($res, LANG_CHARSET, 'UTF-8'); } return $res; }
$attendees = array('y' => array('users' => array(), 'count' => 4, 'countMax' => 8, 'title' => GetMessage('EC_ATT_Y'), 'id' => "bxview-att-cont-y-" . $event['ID']), 'n' => array('users' => array(), 'count' => 2, 'countMax' => 3, 'title' => GetMessage('EC_ATT_N'), 'id' => "bxview-att-cont-n-" . $event['ID']), 'q' => array('users' => array(), 'count' => 2, 'countMax' => 3, 'title' => GetMessage('EC_ATT_Q'), 'id' => "bxview-att-cont-q-" . $event['ID'])); $userIds = array(); if (is_array($event['~ATTENDEES']) && count($event['~ATTENDEES']) > 0) { foreach ($event['~ATTENDEES'] as $i => $att) { $userIds[] = $att["USER_ID"]; if ($userId == $att["USER_ID"]) { $curUserStatus = $att['STATUS']; } $att['AVATAR_SRC'] = CCalendar::GetUserAvatarSrc($att); $att['URL'] = CCalendar::GetUserUrl($att["USER_ID"], $arParams["PATH_TO_USER"]); $attendees[strtolower($att['STATUS'])]['users'][] = $att; } } } if ($event['IS_MEETING'] && empty($event['ATTENDEES_CODES'])) { $event['ATTENDEES_CODES'] = CCalendarEvent::CheckEndUpdateAttendeesCodes($event); } $arParams['event'] = $event; $arParams['UF'] = $UF; $arTabs = array(array('name' => GetMessage('EC_EDEV_EVENT'), 'title' => GetMessage('EC_EDEV_EVENT_TITLE'), 'id' => $id . "ed-tab-0", 'active' => true), array('name' => GetMessage('EC_T_DESC'), 'title' => GetMessage('EC_T_DESC_TITLE'), 'id' => $id . "ed-tab-1"), array('name' => GetMessage('EC_EDEV_GUESTS'), 'title' => GetMessage('EC_EDEV_GUESTS_TITLE'), 'id' => $id . "ed-tab-2", "show" => !!$arParams['bSocNet']), array('name' => GetMessage('EC_EDEV_ADD_TAB'), 'title' => GetMessage('EC_EDEV_ADD_TAB_TITLE'), 'id' => $id . "ed-tab-3")); if ($arParams['bSocNet']) { CSocNetTools::InitGlobalExtranetArrays(); $DESTINATION = CCalendar::GetSocNetDestination(false, $arParams['event']['ATTENDEES_CODES']); } $addWidthStyle = IsAmPmMode() ? ' ampm-width' : ''; ?> <form enctype="multipart/form-data" method="POST" name="event_edit_form" id="<?php echo $id; ?> _form"> <input type="hidden" value="Y" name="skip_unescape"/>
public static function SyncCalendarItems($connectionType, $calendarId, $arCalendarItems) { self::$silentErrorMode = true; // $arCalendarItems: //Array( // [0] => Array( // [XML_ID] => AAATAGFudGlfYn... // [MODIFICATION_LABEL] => DwAAABYAAA... // ) // [1] => Array( // [XML_ID] => AAATAGFudGlfYnVn... // [MODIFICATION_LABEL] => DwAAABYAAAAQ... // ) //) list($sectionId, $entityType, $entityId) = $calendarId; $entityType = strtolower($entityType); if ($connectionType == 'exchange') { $xmlIdField = "DAV_EXCH_LABEL"; } elseif ($connectionType == 'caldav') { $xmlIdField = "CAL_DAV_LABEL"; } else { return array(); } $arCalendarItemsMap = array(); foreach ($arCalendarItems as $value) { $arCalendarItemsMap[$value["XML_ID"]] = $value["MODIFICATION_LABEL"]; } $arModified = array(); $arEvents = CCalendarEvent::GetList(array('arFilter' => array('CAL_TYPE' => $entityType, 'OWNER_ID' => $entityId, 'SECTION' => $sectionId), 'getUserfields' => false, 'parseRecursion' => false, 'fetchAttendees' => false, 'fetchMeetings' => false, 'userId' => $entityType == 'user' ? $entityId : '0')); foreach ($arEvents as $Event) { if (isset($arCalendarItemsMap[$Event["DAV_XML_ID"]])) { if ($Event[$xmlIdField] != $arCalendarItemsMap[$Event["DAV_XML_ID"]]) { $arModified[$Event["DAV_XML_ID"]] = $Event["ID"]; } unset($arCalendarItemsMap[$Event["DAV_XML_ID"]]); } else { self::DeleteCalendarEvent($calendarId, $Event["ID"], self::$userId, $Event); } } $arResult = array(); foreach ($arCalendarItems as $value) { if (array_key_exists($value["XML_ID"], $arModified)) { $arResult[] = array("XML_ID" => $value["XML_ID"], "ID" => $arModified[$value["XML_ID"]]); } } foreach ($arCalendarItemsMap as $key => $value) { $arResult[] = array("XML_ID" => $key, "ID" => 0); } self::$silentErrorMode = false; return $arResult; }
} $arResult['VALUES']['REMIND_LEN'] = $intRemLen; $arResult['VALUES']['REMIND_TYPE'] = $strRemType; $arResult['VALUES']['PRIORITY'] = $strPriority; if (false == $boolError) { $strEntityShort = CUserTypeCrm::GetShortEntityType($arResult['ENTITY_TYPE']) . '_'; foreach ($arID as $intID => $iUserID) { $arCrmEvents = array(); $arCrmEvents[] = $strEntityShort . $intID; $arFields = array('CAL_TYPE' => 'user', 'OWNER_ID' => $iUserID, 'NAME' => $arResult['VALUES']['CALENDAR_TOPIC'], 'DT_FROM' => $arResult['VALUES']['CALENDAR_FROM'], 'DT_TO' => $arResult['VALUES']['CALENDAR_TO'], 'DESCRIPTION' => $arResult['VALUES']['CALENDAR_DESC'], 'IMPORTANCE' => $strPriority); if ('Y' == $arResult['VALUES']['REMIND_FLAG']) { $arFields['REMIND'] = array(array('type' => $strRemType, 'count' => $intRemLen)); } $intEventID = CCalendar::SaveEvent(array('arFields' => $arFields, 'userId' => $iUserID, 'autoDetectSection' => true, 'autoCreateSection' => true)); if (0 < intval($intEventID)) { CCalendarEvent::UpdateUserFields($intEventID, array('UF_CRM_CAL_EVENT' => $arCrmEvents)); } else { $boolError = true; $arResult['ERROR_MESSAGE'][] = GetMessage('BX_CRM_CACA_ERR_ADD_FAIL'); } } } if (true == $boolError) { $arKeys = array_keys($arDefResult['VALUES']); foreach ($arKeys as $strKey) { if (!isset($arResult['VALUES'][$strKey])) { $arResult['VALUES'][$strKey] = ''; } } } } else {
public function UpdateListItems($listName, $updates) { global $USER; $arStatusValues = array_flip($this->arStatusValues); $arPriorityValues = array_flip($this->arPriorityValues); if (!$listName_original = CIntranetUtils::checkGUID($listName)) return new CSoapFault('Data error', 'Wrong GUID - '.$listName); $obResponse = new CXMLCreator('Results'); $listName = ToUpper(CIntranetUtils::makeGUID($listName_original)); $arSections = CCalendarSect::GetList(array('arFilter' => array('XML_ID' => $listName_original))); if (!$arSections || !is_array($arSections[0])) return new CSoapFault( 'List not found', 'List with '.$listName.' GUID not found' ); $arSection = $arSections[0]; $bGroup = $arSection['CAL_TYPE'] == 'group'; $calType = $arSection['CAL_TYPE']; $ownerId = $arSection['OWNER_ID']; if ($bGroup) { CModule::IncludeModule('socialnetwork'); $arGroupTmp = CSocNetGroup::GetByID($arSection['SOCNET_GROUP_ID']); if ($arGroupTmp["CLOSED"] == "Y") if (COption::GetOptionString("socialnetwork", "work_with_closed_groups", "N") != "Y") return new CSoapFault('Cannot modify archive group calendar', 'Cannot modify archive group calendar'); } $obBatch = $updates->children[0]; $atrONERROR = $obBatch->getAttribute('OnError'); $atrDATEINUTC = $obBatch->getAttribute('DateInUtc'); $atrPROPERTIES = $obBatch->getAttribute('Properties'); $arChanges = $obBatch->children; $arResultIDs = array(); $dateStart = ConvertTimeStamp(strtotime('-1 hour'), 'FULL'); $arResponseRows = array(); $arReplicationIDs = array(); $userId = (is_object($USER) && $USER->GetID()) ? $USER->GetID() : 1; foreach ($arChanges as $obMethod) { $arData = array('_command' => $obMethod->getAttribute('Cmd')); foreach ($obMethod->children as $obField) { $name = $obField->getAttribute('Name'); if ($name == 'MetaInfo') $name .= '_'.$obField->getAttribute('Property'); $arData[$name] = $obField->content; } if ($arData['_command'] == 'Delete') { $obRes = new CXMLCreator('Result'); $obRes->setAttribute('ID', $obMethod->getAttribute('ID').','.$arData['_command']); $obRes->setAttribute('List', $listName); $obRes->addChild($obNode = new CXMLCreator('ErrorCode')); $res = CCalendar::DeleteEvent($arData['ID']); if ($res === true) $obNode->setData('0x00000000'); else $obNode->setData('0x81020014'); /* 0x00000000 - ok 0x81020015 - data conflict 0x81020014 - generic error such as invalid value for Field 0x81020016 - item does not exist */ $obResponse->addChild($obRes); } elseif ($arData['_command'] == 'New' || $arData['_command'] == 'Update') { $q = ToLower($arData['Description']); if (($pos = strrpos($q, '</body>')) !== false) $arData['Description'] = substr($arData['Description'], 0, $pos); if (($pos = strpos($q, '<body>')) !== false) $arData['Description'] = substr($arData['Description'], $pos + 6); $arData['Description'] = str_replace('</DIV>', "\r\n</DIV>", $arData['Description']); $arData['Description'] = str_replace(array(" ", " "), "", $arData['Description']); $arData['Description'] = preg_replace("/<![^>]*>/", '', $arData['Description']); //$arData['Description'] = strip_tags($arData['Description']); $arData['Description'] = trim($arData['Description']); $arData['Location'] = trim($arData['Location']); if (isset($arData['EventDate'])) { $arData['EventDate'] = $this->__makeTS($arData['EventDate']); $arData['EndDate'] = $this->__makeTS($arData['EndDate']) + ($arData['fAllDayEvent'] ? -86340 : 0); $TZBias = intval(date('Z', $arData['EventDate'])); } $arData['EventType'] = intval($arData['EventType']); if ($arData['EventType'] == 2) $arData['EventType'] = 0; if ($arData['EventType'] > 2 /* || ($arData['EventType'] == 1 && !$arData['RecurrenceData'])*/) return new CSoapFault( 'Unsupported event type', 'Event type unsupported' ); $arData['fRecurrence'] = intval($arData['fRecurrence']); $arData['RRULE'] = ''; $id = $arData['_command'] == 'New' ? 0 : intVal($arData['ID']); if ($arData['RecurrenceData']) { //$xmlstr = $arData['XMLTZone']; //$arData['XMLTZone'] = new CDataXML(); //$arData['XMLTZone']->LoadString($xmlstr); $xmlstr = $arData['RecurrenceData']; $obRecurData = new CDataXML(); $obRecurData->LoadString($xmlstr); /* <recurrence> <rule> <firstDayOfWeek>mo</firstDayOfWeek> <repeat> <weekly mo='TRUE' tu='TRUE' th='TRUE' sa='TRUE' weekFrequency='1' /> </repeat> <repeatForever>FALSE</repeatForever> </rule> </recurrence> <deleteExceptions>true</deleteExceptions> */ $obRecurRule = $obRecurData->tree->children[0]->children[0]; $obRecurRepeat = $obRecurRule->children[1]; $obNode = $obRecurRepeat->children[0]; $arData['RRULE'] = array(); switch($obNode->name) { case 'daily': // hack. we have no "work days" daily recurence if ($obNode->getAttribute('weekday') == 'TRUE') { $arData['RRULE']['FREQ'] = 'WEEKLY'; $arData['RRULE']['BYDAY'] = 'MO,TU,WE,TH,FR'; $arData['RRULE']['INTERVAL'] = 1; } else { $arData['RRULE']['FREQ'] = 'DAILY'; $arData['RRULE']['INTERVAL'] = $obNode->getAttribute('dayFrequency'); } $time_end = strtotime( date(date('Y-m-d', $arData['EventDate']).' H:i:s', $arData['EndDate']) ); $arData['DT_LENGTH'] = $time_end - $arData['EventDate']; break; case 'weekly': $arData['RRULE']['FREQ'] = 'WEEKLY'; $arData['RRULE']['BYDAY'] = ''; $arWeekDays = array('mo', 'tu', 'we', 'th', 'fr', 'sa', 'su'); foreach ($arWeekDays as $day => $value) { if ($obNode->getAttribute($value)) $arData['RRULE']['BYDAY'][] = strtoupper($value); } $arData['RRULE']['BYDAY'] = implode(',', $arData['RRULE']['BYDAY']); $arData['RRULE']['INTERVAL'] = $obNode->getAttribute('weekFrequency'); $time_end = strtotime(date(date('Y-m-d', $arData['EventDate']).' H:i:s', $arData['EndDate'])); $arData['DT_LENGTH'] = $time_end - $arData['EventDate']; break; case 'monthly': $arData['RRULE']['FREQ'] = 'MONTHLY'; $arData['RRULE']['INTERVAL'] = $obNode->getAttribute('monthFrequency'); $time_end = strtotime(date(date('Y-m', $arData['EventDate']).'-d H:i:s', $arData['EndDate'])); $arData['DT_LENGTH'] = $time_end - $arData['EventDate']; break; case 'yearly': $arData['RRULE']['FREQ'] = 'YEARLY'; $arData['RRULE']['INTERVAL'] = $obNode->getAttribute('yearFrequency'); $time_end = strtotime(date(date('Y', $arData['EventDate']).'-m-d H:i:s', $arData['EndDate'])); $arData['DT_LENGTH'] = $time_end - $arData['EventDate']; break; } if ($arData['DT_LENGTH'] == 0 && isset($arData['RRULE']['FREQ'])) $arData['DT_LENGTH'] = 86400; $obWhile = $obRecurRule->children[2]; if ($obWhile->name == 'repeatForever') { $arData['EndDate'] = MakeTimeStamp(''); } elseif ($obWhile->name == 'windowEnd') { $arData['EndDate'] = $this->__makeTS($obWhile->textContent()); $arData['RRULE']['UNTIL'] = ConvertTimeStamp($arData['EndDate'], 'FULL'); } } elseif($arData['fRecurrence'] == -1 && $id > 0) { $arData['RRULE'] = -1; } if (isset($arData['EventDate'])) { $skipTime = $arData['fAllDayEvent'] ? 'Y' : 'N'; $TZBias = $arData['fAllDayEvent'] ? 0 : $TZBias; $arData['EventDate'] += $TZBias; $arData['EndDate'] += $TZBias; // $arData["DT_FROM"] = ConvertTimeStamp($arData['EventDate'], 'FULL'); // $arData["DT_TO"] = ConvertTimeStamp($arData['EndDate'], 'FULL'); } else { $arData["DT_FROM"] = -1; $arData["DT_TO"] = -1; } // fields $arFields = array( "ID" => $id, 'CAL_TYPE' => $calType, 'OWNER_ID' => $ownerId, 'CREATED_BY' => $userId, 'DT_FROM_TS' => $arData['EventDate'], 'DT_TO_TS' => $arData['EndDate'], 'DT_SKIP_TIME' => $skipTime, // "DT_FROM" => $arData["DT_FROM"], // "DT_TO" => $arData["DT_TO"], 'NAME' => $arData['Title'], 'DESCRIPTION' => CCalendar::ParseHTMLToBB($arData['Description']), 'SECTIONS' => array($arSection['ID']), 'ACCESSIBILITY' => $arStatusValues[$arData['MetaInfo_BusyStatus']], 'IMPORTANCE' => $arPriorityValues[$arData['MetaInfo_Priority']], 'RRULE' => $arData['RRULE'], 'LOCATION' => CCalendar::UnParseTextLocation($arData['Location']) ); if (isset($arData['DT_LENGTH']) && $arData['DT_LENGTH'] > 0) $arFields['DT_LENGTH'] = $arData['DT_LENGTH']; $EventID = CCalendar::SaveEvent( array( 'arFields' => $arFields, 'fromWebservice' => true ) ); if ($EventID) { // dirty hack $arReplicationIDs[$EventID] = $arData['MetaInfo_ReplicationID']; $arResponseRows[$EventID] = new CXMLCreator('Result'); $arResponseRows[$EventID]->setAttribute('ID', $obMethod->getAttribute('ID').','.$arData['_command']); $arResponseRows[$EventID]->setAttribute('List', $listName); $arResponseRows[$EventID]->addChild($obNode = new CXMLCreator('ErrorCode')); $obNode->setData('0x00000000'); //$arResponseRows[$EventID]->setAttribute('Version', 3); } } } $userId = (is_object($USER) && $USER->GetID()) ? $USER->GetID() : 1; $fetchMeetings = CCalendar::GetMeetingSection($userId) == $arSection['ID']; $arEvents = CCalendarEvent::GetList( array( 'arFilter' => array( 'CAL_TYPE' => $calType, 'OWNER_ID' => $ownerId, 'SECTION' => $arSection['ID'], //'INCLUDE_INVITINGS' => 'N' ), 'getUserfields' => false, 'parseRecursion' => false, 'fetchAttendees' => false, 'fetchMeetings' => $fetchMeetings, 'userId' => $userId ) ); foreach ($arEvents as $key => $event) { if ($arResponseRows[$event['ID']]) { $obRow = $this->__getRow($event, $listName, $last_change = 0); $obRow->setAttribute('xmlns:z', "#RowsetSchema"); if ($arReplicationIDs[$event['ID']]) $obRow->setAttribute('MetaInfo_ReplicationID', $arReplicationIDs[$event['ID']]); $arResponseRows[$event['ID']]->addChild($obRow); } $obResponse->addChild($arResponseRows[$event['ID']]); } return array('UpdateListItemsResult' => $obResponse); }
<tr> <td class="feed-calendar-view-text-cell-l"><?php echo GetMessage('ECLFV_EVENT_START'); ?> :</td> <td class="feed-calendar-view-text-cell-r" id="feed-event-view-from-<?php echo $id; ?> "></td> </tr> <?php if (isset($arResult['EVENT']['RRULE']) && $arResult['EVENT']['RRULE'] !== '') { ?> <?php $RRULE = CCalendarEvent::ParseRRULE($arResult['EVENT']['RRULE']); switch ($RRULE['FREQ']) { case 'DAILY': if ($RRULE['INTERVAL'] == 1) { $repeatHTML = GetMessage('EC_RRULE_EVERY_DAY'); } else { $repeatHTML = GetMessage('EC_RRULE_EVERY_DAY_1', array('#DAY#' => $RRULE['INTERVAL'])); } break; case 'WEEKLY': $daysList = array(); foreach ($RRULE['BYDAY'] as $day) { $daysList[] = GetMessage('EC_' . $day); } $daysList = implode(', ', $daysList); if ($RRULE['INTERVAL'] == 1) {
public static function CanView($eventId, $userId) { CModule::IncludeModule("calendar"); $Event = CCalendarEvent::GetList(array('arFilter' => array("ID" => $eventId), 'parseRecursion' => false, 'fetchAttendees' => true, 'checkPermissions' => true, 'userId' => $userId)); if ($Event && is_array($Event[0])) { // Event is not partly accessible - so it was not cleaned before by ApplyAccessRestrictions if (isset($Event[0]['DESCRIPTION']) || isset($Event[0]['IS_MEETING']) || isset($Event[0]['LOCATION'])) { return true; } } return false; }
public static function MeetingParamsSet($arParams = array(), $nav = null, $server = null) { $userId = CCalendar::GetCurUserId(); $methodName = "calendar.meeting.params.set"; $necessaryParams = array('eventId'); foreach ($necessaryParams as $param) { if (!isset($arParams[$param]) || empty($arParams[$param])) { throw new Exception(GetMessage('CAL_REST_PARAM_EXCEPTION', array('#PARAM_NAME#' => $param, '#REST_METHOD#' => $methodName))); } } $result = CCalendarEvent::SetMeetingParams($userId, intVal($arParams['eventId']), array('ACCESSIBILITY' => $arParams['accessibility'], 'REMIND' => $arParams['remind'])); if (!$result) { throw new Exception(GetMessage('CAL_REST_GET_DATA_ERROR')); } return true; }