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); }
public static function GetAbsent($users = false, $Params = array()) { global $DB; // Can be called from agent... So we have to create $USER if it is not exists $tempUser = CCalendar::TempUser(false, true); $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 CTimeZone::Disable(); if (count($arUsers) > 0) { $userQ = ' AND CA.USER_ID in (' . implode(',', $arUsers) . ')'; } else { $userQ = ''; } $strSql = "\n\t\t\tSELECT\n\t\t\t\tCA.EVENT_ID as ID, CA.USER_ID, CA.STATUS, CA.ACCESSIBILITY,\n\t\t\t\tCE.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,\n\t\t\t\tCES.SECT_ID\n\t\t\tFROM b_calendar_attendees CA\n\t\t\tLEFT JOIN\n\t\t\t\tb_calendar_event CE ON(CA.EVENT_ID=CE.ID)\n\t\t\tLEFT JOIN\n\t\t\t\tb_calendar_event_sect CES ON (CA.EVENT_ID=CES.EVENT_ID)\n\t\t\tWHERE\n\t\t\t\t\tCE.ID IS NOT NULL\n\t\t\t\tAND\n\t\t\t\t\tCE.DELETED='N'\n\t\t\t\tAND\n\t\t\t\t\tSTATUS='Y'\n\t\t\t\tAND\n\t\t\t\t\tCA.ACCESSIBILITY='absent'\n\t\t\t\t{$userQ}\n\t\t\t"; 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); } } CTimeZone::Enable(); $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')); CCalendar::TempUser($tempUser, false); return $result; }
$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', $fromTs); $event['FROM_MONTH_DAY'] = FormatDate('j', $fromTs); $event['FROM_MONTH'] = FormatDate('n', $fromTs); $arHost = CCalendar::GetUser($event['MEETING_HOST'], true); $arHost['AVATAR_SRC'] = CCalendar::GetUserAvatarSrc($arHost); $arHost['URL'] = CCalendar::GetUserUrl($event['MEETING_HOST'], $arParams["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']), 'm' => array('users' => array(), 'count' => 4, 'countMax' => 8, 'title' => GetMessage('EC_ATT_M'), 'id' => "bxview-att-cont-m-" . $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"], $arParams["PATH_TO_USER"]); $status = strtolower($att['STATUS']) == 'h' || $att['STATUS'] == '' ? 'y' : $att['STATUS']; // ?
public static function GetMeetingSection($userId, $bCreate = false) { if (isset(self::$meetingSections[$userId])) { return self::$meetingSections[$userId]; } $result = false; if ($userId > 0) { $set = CCalendar::GetUserSettings($userId); $result = $set['meetSection']; if ($result && !CCalendarSect::GetById($result, true, true)) { $result = false; } if (!$result) { $res = CCalendarSect::GetList(array('arFilter' => array('CAL_TYPE' => 'user', 'OWNER_ID' => $userId))); if ($res && count($res) > 0 && $res[0]['ID']) { $result = $res[0]['ID']; } if (!$result && $bCreate) { $defCalendar = CCalendarSect::CreateDefault(array('type' => 'user', 'ownerId' => $userId)); if ($defCalendar && $defCalendar['ID'] > 0) { $result = $defCalendar['ID']; } } if ($result) { $set['meetSection'] = $result; CCalendar::SetUserSettings($set, $userId); } } } self::$meetingSections[$userId] = $result; return $result; }
public function GetCTag($siteId, $account, $arPath) { $calendarId = $this->GetCalendarId($siteId, $account, $arPath); if ($calendarId == null) { return null; } $label = CCalendarSect::GetModificationLabel($calendarId); $label = MakeTimeStamp($label); return 'BX:' . $label; }
public static function GetAuthHash() { if (!isset(self::$authHashiCal) || empty(self::$authHashiCal)) { global $USER, $APPLICATION; self::$authHashiCal = $USER->AddHitAuthHash($APPLICATION->GetCurPage()); } return self::$authHashiCal; }
$arParams['OWNER_TYPE'] = 'user'; $arParams['CUR_USER'] = $USER->GetId(); $arResult['USER_FIELDS'] = $USER_FIELD_MANAGER->GetUserFields("CALENDAR_EVENT", $arParams['EVENT_ID'], LANGUAGE_ID); // Webdaw upload file UF $arParams["UPLOAD_WEBDAV_ELEMENT"] = $arResult['USER_FIELDS']['UF_WEBDAV_CAL_EVENT']; $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')
public static function ConvertEntity($ownerType, $ownerId, $sectionId, $iblockId, $createdBy) { $eventsCount = 0; $sectCount = 0; $bs = new CIBlockSection(); $ent_id = "IBLOCK_" . $iblockId . "_SECTION"; $result = array('eventsCount' => 0, 'sectCount' => 0); $bSetAccessFromCalendar = true; $Access = array('G2' => CCalendar::GetAccessTasksByName('calendar_section', 'calendar_denied')); // CONVERT ACCESS: if ($ownerType == 'user') { if (!CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $ownerId, "calendar")) { return $result; } // Read $read = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $ownerId, "calendar", 'view'); $taskId = CCalendar::GetAccessTasksByName('calendar_section', 'calendar_view'); if ($read == 'A') { // All users $Access['G2'] = $taskId; } elseif ($read == 'C') { // All autorized $Access['AU'] = $taskId; } elseif ($read == 'M' || $read == 'E') { // Friends $Access['SU' . $ownerId . '_F'] = $taskId; } elseif ($bSetAccessFromCalendar) { $bSetAccessFromCalendar = false; } // Write - will override read access $write = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $ownerId, "calendar", 'write'); $taskId = CCalendar::GetAccessTasksByName('calendar_section', 'calendar_edit'); if ($write == 'A') { // All users $Access['G2'] = $taskId; } elseif ($write == 'C') { // All autorized $Access['AU'] = $taskId; } elseif ($write == 'M' || $write == 'E') { // Friends $Access['SU' . $ownerId . '_F'] = $taskId; } } elseif ($ownerType == 'group') { if (!CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $ownerId, "calendar")) { return $result; } // Read $read = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $ownerId, "calendar", 'view'); $taskId = CCalendar::GetAccessTasksByName('calendar_section', 'calendar_view'); if ($read == 'A') { // Group owner $Access['SG' . $ownerId . '_A'] = $taskId; } elseif ($read == 'E') { // Group moderator $Access['SG' . $ownerId . '_E'] = $taskId; } elseif ($read == 'K') { // User $Access['SG' . $ownerId . '_K'] = $taskId; } elseif ($read == 'L') { // Authorized $Access['AU'] = $taskId; } elseif ($read == 'N') { // Authorized $Access['G2'] = $taskId; } // Write - will override read access $write = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $ownerId, "calendar", 'write'); $taskId = CCalendar::GetAccessTasksByName('calendar_section', 'calendar_edit'); if ($write == 'A') { // Group owner $Access['SG' . $ownerId . '_A'] = $taskId; } elseif ($write == 'E') { // Group moderator $Access['SG' . $ownerId . '_E'] = $taskId; } elseif ($write == 'K') { // User $Access['SG' . $ownerId . '_K'] = $taskId; } elseif ($write == 'L') { // Authorized $Access['AU'] = $taskId; } elseif ($write == 'N') { // Authorized $Access['G2'] = $taskId; } } else { $arGroupPerm = CIBlock::GetGroupPermissions($iblockId); $taskByLetter = array('D' => CCalendar::GetAccessTasksByName('calendar_section', 'calendar_denied'), 'R' => CCalendar::GetAccessTasksByName('calendar_section', 'calendar_view'), 'W' => CCalendar::GetAccessTasksByName('calendar_section', 'calendar_edit'), 'X' => CCalendar::GetAccessTasksByName('calendar_section', 'calendar_access')); foreach ($arGroupPerm as $groupId => $letter) { $Access['G' . $groupId] = $taskByLetter[$letter]; } } // 1. Fetch sections $arUserSections = CEventCalendar::GetCalendarList(array($iblockId, $sectionId, 0, $ownerType)); $calendarIndex = array(); foreach ($arUserSections as $section) { $arUF = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields($ent_id, $section['ID']); if (isset($arUF["UF_CAL_CONVERTED"]) && strlen($arUF["UF_CAL_CONVERTED"]['VALUE']) > 0) { continue; } $SectionAccess = array(); if ($bSetAccessFromCalendar && $ownerType == 'user') { if ($section['PRIVATE_STATUS'] == 'private') { $deniedTask = CCalendar::GetAccessTasksByName('calendar_section', 'calendar_denied'); $SectionAccess['G2'] = $deniedTask; } elseif ($section['PRIVATE_STATUS'] == 'time') { $viewTimeTask = CCalendar::GetAccessTasksByName('calendar_section', 'calendar_view_time'); $SectionAccess['G2'] = $viewTimeTask; } elseif ($section['PRIVATE_STATUS'] == 'title') { $viewTitleTask = CCalendar::GetAccessTasksByName('calendar_section', 'calendar_view_title'); $SectionAccess['G2'] = $viewTitleTask; } else { $SectionAccess = $Access; // nested from common access settings from socnet } } else { $SectionAccess = $Access; // G2 => denied } $new_sect_id = CCalendarSect::Edit(array('arFields' => array("CAL_TYPE" => $ownerType, "NAME" => $section['NAME'], "OWNER_ID" => $ownerId, "CREATED_BY" => $createdBy, "DESCRIPTION" => $section['DESCRIPTION'], "COLOR" => $section["COLOR"], "ACCESS" => $SectionAccess))); // Set converted property $bs->Update($section['ID'], array('UF_CAL_CONVERTED' => 1)); $calendarIndex[$section['ID']] = $new_sect_id; $sectCount++; } // 2. Create events $arEvents = CEventCalendar::GetCalendarEventsList(array($iblockId, $sectionId, 0), array()); foreach ($arEvents as $event) { if (!isset($calendarIndex[$event['IBLOCK_SECTION_ID']]) || $event['PROPERTY_PARENT'] > 0) { continue; } $arFields = array("CAL_TYPE" => $ownerType, "OWNER_ID" => $ownerId, "CREATED_BY" => $event["CREATED_BY"], "DT_FROM" => $event['ACTIVE_FROM'], "DT_TO" => $event['ACTIVE_TO'], 'NAME' => htmlspecialcharsback($event['NAME']), 'DESCRIPTION' => CCalendar::ParseHTMLToBB(htmlspecialcharsback($event['DETAIL_TEXT'])), 'SECTIONS' => array($calendarIndex[$event['IBLOCK_SECTION_ID']]), 'ACCESSIBILITY' => $event['PROPERTY_ACCESSIBILITY'], 'IMPORTANCE' => $event['PROPERTY_IMPORTANCE'], 'PRIVATE_EVENT' => $event['PROPERTY_PRIVATE'] && $event['PROPERTY_PRIVATE'] == 'true' ? '1' : '', 'RRULE' => array(), 'LOCATION' => array('NEW' => $event['PROPERTY_LOCATION'], 'RE_RESERVE' => 'N'), "REMIND" => array(), "IS_MEETING" => $event['PROPERTY_IS_MEETING'] == 'Y'); if (!empty($event['PROPERTY_REMIND_SETTINGS'])) { $ar = explode("_", $event["PROPERTY_REMIND_SETTINGS"]); if (count($ar) == 2) { $arFields["REMIND"][] = array('type' => $ar[1], 'count' => floatVal($ar[0])); } } if (isset($event["PROPERTY_PERIOD_TYPE"]) && in_array($event["PROPERTY_PERIOD_TYPE"], array("DAILY", "WEEKLY", "MONTHLY", "YEARLY"))) { $arFields['RRULE']['FREQ'] = $event["PROPERTY_PERIOD_TYPE"]; $arFields['RRULE']['INTERVAL'] = $event["PROPERTY_PERIOD_COUNT"]; if (!empty($event['PROPERTY_EVENT_LENGTH'])) { $arFields['DT_LENGTH'] = intval($event['PROPERTY_EVENT_LENGTH']); } if (!$arFields['DT_LENGTH']) { $arFields['DT_LENGTH'] = 86400; } if ($arFields['RRULE']['FREQ'] == "WEEKLY" && !empty($event['PROPERTY_PERIOD_ADDITIONAL'])) { $arFields['RRULE']['BYDAY'] = array(); $bydays = explode(',', $event['PROPERTY_PERIOD_ADDITIONAL']); foreach ($bydays as $day) { $day = CCalendar::WeekDayByInd($day); if ($day !== false) { $arFields['RRULE']['BYDAY'][] = $day; } } $arFields['RRULE']['BYDAY'] = implode(',', $arFields['RRULE']['BYDAY']); } $arFields['RRULE']['UNTIL'] = $event['ACTIVE_TO']; } if ($arFields['IS_MEETING']) { if ($event['PROPERTY_PARENT'] > 0) { continue; } $host = intVal($event['CREATED_BY']); $arFields['ATTENDEES'] = array(); if ($event['PROPERTY_HOST_IS_ABSENT'] == 'N') { $arFields['ATTENDEES'][] = $host; } $arGuests = CECEvent::GetGuests(self::$userIblockId, $event['ID']); $attendeesStatuses = array(); foreach ($arGuests as $userId => $ev) { $attendeesStatuses[$userId] = $ev['PROPERTY_VALUES']['CONFIRMED']; $arFields['ATTENDEES'][] = $userId; } $arFields['MEETING_HOST'] = $host; $arFields['MEETING'] = array('HOST_NAME' => CCalendar::GetUserName($host), 'TEXT' => is_array($event['PROPERTY_MEETING_TEXT']) && is_string($event['PROPERTY_MEETING_TEXT']['TEXT']) ? trim($event['PROPERTY_MEETING_TEXT']['TEXT']) : '', 'OPEN' => false, 'NOTIFY' => false, 'REINVITE' => false); } $new_event_id = CCalendar::SaveEvent(array('arFields' => $arFields, 'bAffectToDav' => false, 'attendeesStatuses' => $attendeesStatuses, 'bSendInvitations' => false)); $eventsCount++; } // 3. Set userfield $bs->Update($sectionId, array('UF_CAL_CONVERTED' => 1)); return array('eventsCount' => $eventsCount, 'sectCount' => $sectCount); }
} $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; } } $arResult['CAL_TYPE'] = $calType; $arResult['OWNER_ID'] = $ownerId; $arResult['USER_ID'] = $userId; $arResult['SECTIONS'] = array(); $sections = CCalendar::GetSectionList(array('CAL_TYPE' => $calType, 'OWNER_ID' => $ownerId)); if (empty($sections)) { $sections = array(CCalendarSect::CreateDefault(array('type' => $calType, 'ownerId' => $ownerId))); } foreach ($sections as $sect) { $arResult['SECTIONS'][] = array('ID' => $sect['ID'], 'NAME' => $sect['NAME']); } $this->IncludeComponentTemplate();
public static function SectionDelete($arParams = array(), $nav = null, $server = null) { $userId = CCalendar::GetCurUserId(); $methodName = "calendar.section.delete"; if (isset($arParams['type'])) { $type = $arParams['type']; } else { throw new Exception(GetMessage('CAL_REST_PARAM_EXCEPTION', array('#REST_METHOD#' => $methodName, '#PARAM_NAME#' => 'type'))); } if (isset($arParams['ownerId'])) { $ownerId = intval($arParams['ownerId']); } elseif ($type == 'user') { $ownerId = $userId; } else { throw new Exception(GetMessage('CAL_REST_PARAM_EXCEPTION', array('#REST_METHOD#' => $methodName, '#PARAM_NAME#' => 'ownerId'))); } if (isset($arParams['id']) && intVal($arParams['id']) > 0) { $id = intVal($arParams['id']); } else { throw new Exception(GetMessage('CAL_REST_SECT_ID_EXCEPTION')); } if (!CCalendar::IsPersonal($type, $ownerId, $userId) && !CCalendarSect::CanDo('calendar_edit_section', $id, $userId)) { throw new Exception(GetMessage('CAL_REST_ACCESS_DENIED')); } $res = CCalendar::DeleteSection($id); if (!$res) { throw new Exception(GetMessage('CAL_REST_SECTION_DELETE_ERROR')); } return $res; }
public static function GetAbsent($users = false, $Params = array()) { // Can be called from agent... So we have to create $USER if it is not exists $tempUser = CCalendar::TempUser(false, true); $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; } $arFilter = array('DELETED' => 'N', 'ACCESSIBILITY' => 'absent'); if ($users) { $arFilter['CREATED_BY'] = $users; } 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, 'parseRecursion' => true, 'getUserfields' => false, 'userId' => $curUserId, 'preciseLimits' => true, 'checkPermissions' => false, 'skipDeclined' => true)); $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['CREATED_BY']; 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) { $event = self::ApplyAccessRestrictions($event, $userId); } } $skipTime = $event['DT_SKIP_TIME'] === 'Y'; $fromTs = CCalendar::Timestamp($event['DATE_FROM'], false, !$skipTime); $toTs = CCalendar::Timestamp($event['DATE_TO'], false, !$skipTime); if ($event['DT_SKIP_TIME'] !== 'Y') { $fromTs -= $event['~USER_OFFSET_FROM']; $toTs -= $event['~USER_OFFSET_TO']; } $result[] = array('ID' => $event['ID'], 'NAME' => $event['NAME'], 'DATE_FROM' => CCalendar::Date($fromTs, !$skipTime, false), 'DATE_TO' => CCalendar::Date($toTs, !$skipTime, false), 'DT_FROM_TS' => $fromTs, 'DT_TO_TS' => $toTs, 'CREATED_BY' => $userId, 'DETAIL_TEXT' => '', 'USER_ID' => $userId); } // Sort by DATE_FROM_TS_UTC usort($result, array('CCalendar', '_NearestSort')); CCalendar::TempUser($tempUser, false); return $result; }
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 }
public static function OnSocNetGroupDelete($groupId) { $groupId = intVal($groupId); if ($groupId > 0) { $res = CCalendarSect::GetList(array('arFilter' => array('CAL_TYPE' => 'group', 'OWNER_ID' => $groupId), 'checkPermissions' => false)); foreach ($res as $sect) { CCalendarSect::Delete($sect['ID'], false); } } return true; }