Exemple #1
0
	public function __getRow($event, $listName, &$last_change)
	{
		global $APPLICATION, $USER;

		$arStatusValues = $this->arStatusValues;
		$arPriorityValues = $this->arPriorityValues;

		$first_week_day = COption::GetOptionString('calendar', 'week_start', 'MO');
		$first_week_day = strtolower($first_week_day);

		$change = MakeTimeStamp($event['TIMESTAMP_X']);
		if ($last_change < $change)
			$last_change = $change;

		$bRecurrent = (isset($event['RRULE']) && $event['RRULE'] != "") ? 1 : 0;
		$rrule = CCalendarEvent::ParseRRULE($event['RRULE']);

		$ts_start = $event['DT_FROM_TS'];
		$ts_finish = $event['DT_TO_TS'];
		$bAllDay = $event['DT_SKIP_TIME'] == 'Y' ? 1 : 0;

		$TZBias = intval(date('Z'));
		$TZBiasStart = intval(date('Z', $ts_start));

		$duration = $event['DT_LENGTH'];
		if ($bAllDay)
			$duration -= 20;

		//$duration = $bRecurrent ? $event['DT_LENGTH'] : ($ts_finish - $ts_start);

		if (!$bAllDay || defined('OLD_OUTLOOK_VERSION'))
		{
			$ts_start -= $TZBiasStart;
			$ts_finish -= $TZBiasStart;
		}

		$obRow = new CXMLCreator('z:row');
		$obRow->setAttribute('ows_ID', $event['ID']);
		$obRow->setAttribute('ows_Title', htmlspecialcharsback($event['NAME'])); // we have data htmlspecialchared yet

		$version = $event['VERSION'] ? $event['VERSION'] : 1;

		$obRow->setAttribute('ows_Attachments', 0);
		$obRow->setAttribute('ows_owshiddenversion', $version);
		$obRow->setAttribute('ows_MetaInfo_vti_versionhistory', md5($event['ID']).':'.$version);

		/*
			ows_MetaInfo_BusyStatus='2' - Editor
			ows_MetaInfo_IntendedBusyStatus='-1' - Creator

			values:
				-1 - Unspecified busy status. Protocol clients can choose to display one of the other values if BusyStatus is -1.
				0 - Free - ACCESSIBILITY => 'free'
				1 - Tentative - ACCESSIBILITY => 'quest'
				2 - Busy - ACCESSIBILITY => 'busy'
				3 - Out of Office - ACCESSIBILITY => 'absent'
		*/

		$status = $arStatusValues[$event['ACCESSIBILITY']];
		$obRow->setAttribute('ows_MetaInfo_BusyStatus', $status === null ? -1 : $status);
		$obRow->setAttribute('ows_MetaInfo_Priority', intval($arPriorityValues[$event['IMPORTANCE']]));

		$obRow->setAttribute('ows_Created', $this->__makeDateTime(MakeTimeStamp($event['DATE_CREATE'])-$TZBias));
		$obRow->setAttribute('ows_Modified', $this->__makeDateTime($change-$TZBias));
		$obRow->setAttribute('ows_EventType', $bRecurrent ? 1 : 0);

		$obRow->setAttribute('ows_Location', CCalendar::GetTextLocation($event['LOCATION']));
		$obRow->setAttribute('ows_Description', $event['~DESCRIPTION']); // Description parsed from BB-codes to HTML

		$obRow->setAttribute('ows_EventDate', $this->__makeDateTime($ts_start));
		$obRow->setAttribute('ows_EndDate', $this->__makeDateTime($ts_start + $event['DT_LENGTH']));

		//$obRow->setAttribute('ows_EndDate', $this->__makeDateTime(((false && $bRecurrent) ? $ts_start + $event['DT_LENGTH'] : $ts_finish) + ($bAllDay ? 86340 : 0)));
		//$obRow->setAttribute('ows_EndDate', $this->__makeDateTime(($bRecurrent ? $ts_start + $event['DT_LENGTH'] : $ts_finish) - ($bAllDay ? 20 : 0)));


		$obRow->setAttribute('ows_fAllDayEvent', $bAllDay);

		/* Recurrence */
		$obRow->setAttribute('ows_fRecurrence', $bRecurrent);
		if ($bRecurrent)
		{
			$obRow->setAttribute('ows_UID', CIntranetUtils::makeGUID(md5($event['ID'].'_'.$change)));
			$tz_data = '';
			$tz_data .= '<timeZoneRule>';
			$tz_data .= '<standardBias>'.(-intval(($TZBias - (date('I') ? 3600 : 0)) /60)).'</standardBias>';
			$tz_data .= '<additionalDaylightBias>-60</additionalDaylightBias>';

			$bUseTransition = COption::GetOptionString('intranet', 'tz_transition', 'Y') == 'Y';

			if ($bUseTransition)
			{
				$transition_standard = COption::GetOptionString('intranet', 'tz_transition_standard', '');
				$transition_daylight = COption::GetOptionString('intranet', 'tz_transition_daylight', '');
				if (!$transition_standard) $transition_standard = '<transitionRule month="10" day="su" weekdayOfMonth="last" /><transitionTime>3:0:0</transitionTime>';
				if (!$transition_daylight) $transition_daylight = '<transitionRule  month="3" day="su" weekdayOfMonth="last" /><transitionTime>2:0:0</transitionTime>';

				$tz_data .= '<standardDate>'.$transition_standard.'</standardDate><daylightDate>'.$transition_daylight.'</daylightDate>';
			}

			$tz_data .= '</timeZoneRule>';
			$obRow->setAttribute('ows_XMLTZone', $tz_data);
			//$obRow->setAttribute('ows_TimeZone', 7);

			$recurence_data = '';
			$recurence_data .= '<recurrence>';
			$recurence_data .= '<rule>';
			$recurence_data .= '<firstDayOfWeek>'.$first_week_day.'</firstDayOfWeek>';

			$recurence_data .= '<repeat>';
			switch($rrule['FREQ'])
			{
				case 'DAILY':
					$recurence_data .= '<daily dayFrequency="'.$rrule['INTERVAL'].'" />';
				break;

				case 'WEEKLY':
					$days = '';
					foreach ($rrule['BYDAY'] as $day)
						$days .= strtolower($day).'="TRUE" ';
					$recurence_data .= '<weekly '.$days.'weekFrequency="'.$rrule['INTERVAL'].'" />';
				break;

				case 'MONTHLY':
					$recurence_data .= '<monthly monthFrequency="'.$rrule['INTERVAL'].'" day="'.date('d', $ts_start).'" />';
				break;

				case 'YEARLY':
					$recurence_data .= '<yearly yearFrequency="'.$rrule['INTERVAL'].'" month="'.date('m', $ts_start).'" day="'.date('d', $ts_start).'" />';
				break;
			}
			$recurence_data .= '</repeat>';

			if (date('Y', $ts_finish) == '2038' || date('Y', $ts_finish) == '2037')
				$recurence_data .= '<repeatForever>FALSE</repeatForever>';
			else
				$recurence_data .= '<windowEnd>'.$this->__makeDateTime($ts_finish).'</windowEnd>';

			$recurence_data .= '</rule>';
			$recurence_data .= '</recurrence>';
			$obRow->setAttribute('ows_RecurrenceData', $recurence_data);

			//$obRow->setAttribute('ows_Duration', $event['DT_LENGTH'] + ($bAllDay ? 86340 : 0));
			//$obRow->setAttribute('ows_Duration', $event['DT_LENGTH'] - ($bAllDay ? 20 : 0));
			$obRow->setAttribute('ows_Duration', $duration);
		}
		else
		{
			//$obRow->setAttribute('ows_Duration', ($duration ? $duration : 86400) - 60);
			$obRow->setAttribute('ows_Duration', $duration);
		}

		$obRow->setAttribute('ows_UniqueId', $event['ID'].';#'.$listName);
		$obRow->setAttribute('ows_FSObjType', $event['ID'].';#0');
		$obRow->setAttribute('ows_Editor', $event['CREATED_BY'].';#'.CCalendar::GetUserName($event['CREATED_BY']));
		$obRow->setAttribute('ows_PermMask', '0x7fffffffffffffff');
		$obRow->setAttribute('ows_ContentTypeId', '0x01020005CE290982A58C439E00342702139D1A');

		return $obRow;
	}
 public static function GetAttendees($arEventIds = array())
 {
     global $DB;
     $arAttendees = array();
     if (!is_array($arEventIds)) {
         $arEventIds = array($arEventIds);
     }
     $strMeetIds = "";
     foreach ($arEventIds as $id) {
         if (intVal($id) > 0) {
             $strMeetIds .= ',' . intVal($id);
         }
     }
     $strMeetIds = trim($strMeetIds, ', ');
     if ($strMeetIds != '') {
         $strSql = "\n\t\t\tSELECT\n\t\t\t\tCA.*,\n\t\t\t\tU.LOGIN, U.NAME, U.LAST_NAME, U.SECOND_NAME, U.EMAIL, U.PERSONAL_PHOTO, U.WORK_POSITION,\n\t\t\t\tBUF.UF_DEPARTMENT\n\t\t\tFROM\n\t\t\t\tb_calendar_attendees CA\n\t\t\t\tLEFT JOIN b_user U ON (U.ID=CA.USER_ID)\n\t\t\t\tLEFT JOIN b_uts_user BUF ON (BUF.VALUE_ID = CA.USER_ID)\n\t\t\tWHERE\n\t\t\t\tU.ACTIVE = 'Y' AND\n\t\t\t\tCA.EVENT_ID in (" . $strMeetIds . ")";
         $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         while ($attendee = $res->Fetch()) {
             if (!isset($arAttendees[$attendee['EVENT_ID']])) {
                 $arAttendees[$attendee['EVENT_ID']] = array();
             }
             $attendee["STATUS"] = trim($attendee["STATUS"]);
             $attendee["DESCRIPTION"] = trim($attendee["DESCRIPTION"]);
             $attendee["COLOR"] = trim($attendee["COLOR"]);
             $attendee["TEXT_COLOR"] = trim($attendee["TEXT_COLOR"]);
             $attendee["ACCESSIBILITY"] = trim($attendee["ACCESSIBILITY"]);
             if (empty($attendee["ACCESSIBILITY"])) {
                 $attendee["ACCESSIBILITY"] = 'busy';
             }
             CCalendar::SetUserDepartment($attendee["USER_ID"], empty($attendee['UF_DEPARTMENT']) ? array() : unserialize($attendee['UF_DEPARTMENT']));
             $attendee['DISPLAY_NAME'] = CCalendar::GetUserName($attendee);
             $attendee['URL'] = CCalendar::GetUserUrl($attendee["USER_ID"]);
             $attendee['AVATAR'] = CCalendar::GetUserAvatarSrc($attendee);
             $arAttendees[$attendee['EVENT_ID']][] = $attendee;
         }
     }
     return $arAttendees;
 }
Exemple #3
0
}
$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', $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);
Exemple #4
0
 public static function GetOwnerName($type = '', $ownerId = '')
 {
     $type = strtolower($type);
     $key = $type . '_' . $ownerId;
     if (isset(self::$ownerNames[$key])) {
         return self::$ownerNames[$key];
     }
     $ownerName = '';
     if ($type == 'user') {
         $ownerName = CCalendar::GetUserName($ownerId);
     } elseif ($type == 'group') {
         // Get group name
         if (!CModule::IncludeModule("socialnetwork")) {
             return $ownerName;
         }
         if ($arGroup = CSocNetGroup::GetByID($ownerId)) {
             $ownerName = $arGroup["~NAME"];
         }
     } else {
         // Get type name
         $arTypes = CCalendarType::GetList(array("arFilter" => array("XML_ID" => $type)));
         $ownerName = $arTypes[0]['NAME'];
     }
     self::$ownerNames[$key] = $ownerName;
     $ownerName = trim($ownerName);
     return $ownerName;
 }
 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);
 }
 public static function GetSuperposedList($Params = array())
 {
     global $DB;
     $checkPermissions = $Params['checkPermissions'] !== false;
     $checkSocnetPermissions = $Params['checkSocnetPermissions'] !== false;
     $userId = isset($Params['userId']) ? intVal($Params['userId']) : self::$userId;
     $arResult = array();
     $arSectionIds = array();
     $sqlSearch = "";
     // Common types
     $strTypes = "";
     if (isset($Params['TYPES']) && is_array($Params['TYPES'])) {
         foreach ($Params['TYPES'] as $type) {
             $strTypes .= ",'" . CDatabase::ForSql($type) . "'";
         }
         $strTypes = trim($strTypes, ", ");
         if ($strTypes != "") {
             $sqlSearch .= "(CS.CAL_TYPE in (" . $strTypes . "))";
         }
     }
     // Group's calendars
     $strGroups = "0";
     if (is_array($Params['GROUPS']) && count($Params['GROUPS']) > 0) {
         foreach ($Params['GROUPS'] as $ownerId) {
             if (IntVal($ownerId) > 0) {
                 $strGroups .= "," . IntVal($ownerId);
             }
         }
         if ($strGroups != "0") {
             if ($sqlSearch != "") {
                 $sqlSearch .= " OR ";
             }
             $sqlSearch .= "(CS.OWNER_ID in (" . $strGroups . ") AND CS.CAL_TYPE='group')";
         }
     }
     if ($sqlSearch != "") {
         $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tCS.*,\n\t\t\t\t\tCT.NAME AS TYPE_NAME, CT.DESCRIPTION AS TYPE_DESC\n\t\t\t\tFROM\n\t\t\t\t\tb_calendar_section CS\n\t\t\t\t\tLEFT JOIN b_calendar_type CT ON (CS.CAL_TYPE=CT.XML_ID)\n\t\t\t\tWHERE\n\t\t\t\t\t(\n\t\t\t\t\t\tCT.ACTIVE='Y'\n\t\t\t\t\tAND\n\t\t\t\t\t\tCS.ACTIVE='Y'\n\t\t\t\t\tAND\n\t\t\t\t\t(\n\t\t\t\t\t\t{$sqlSearch}\n\t\t\t\t\t))";
         $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         while ($arRes = $res->Fetch()) {
             $arSectionIds[] = $arRes['ID'];
             $arResult[] = $arRes;
         }
     }
     // User's calendars
     $strUsers = "0";
     if (is_array($Params['USERS']) && count($Params['USERS']) > 0) {
         foreach ($Params['USERS'] as $ownerId) {
             if (IntVal($ownerId) > 0) {
                 $strUsers .= "," . IntVal($ownerId);
             }
         }
         if ($strUsers != "0") {
             $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tCS.*,\n\t\t\t\t\tU.LOGIN AS USER_LOGIN, U.NAME AS USER_NAME, U.LAST_NAME AS USER_LAST_NAME, U.SECOND_NAME AS USER_SECOND_NAME\n\t\t\t\tFROM\n\t\t\t\t\tb_calendar_section CS\n\t\t\t\t\tLEFT JOIN b_user U ON (CS.OWNER_ID=U.ID)\n\t\t\t\tWHERE\n\t\t\t\t\t(\n\t\t\t\t\t\tCS.ACTIVE='Y'\n\t\t\t\t\tAND\n\t\t\t\t\t\tCS.OWNER_ID in (" . $strUsers . ")\n\t\t\t\t\tAND\n\t\t\t\t\t\tCS.CAL_TYPE='user'\n\t\t\t\t\t)";
             $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         }
         while ($arRes = $res->Fetch()) {
             $arSectionIds[] = $arRes['ID'];
             $arResult[] = $arRes;
         }
     }
     if ($checkPermissions && count($arSectionIds) > 0) {
         if ($checkSocnetPermissions) {
             if (isset($Params['USERS']) && count($Params['USERS']) > 0) {
                 $arFeaturesU = CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $Params['USERS'], "calendar");
                 $arViewU = CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $Params['USERS'], "calendar", 'view');
                 $arWriteU = CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_GROUP, $Params['USERS'], "calendar", 'write');
             }
             if (isset($Params['GROUPS']) && count($Params['GROUPS']) > 0) {
                 $arFeaturesG = CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $Params['GROUPS'], "calendar");
                 $arViewG = CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_GROUP, $Params['GROUPS'], "calendar", 'view');
                 $arWriteG = CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_GROUP, $Params['GROUPS'], "calendar", 'write');
             }
         }
         CCalendarSect::GetArrayPermissions($arSectionIds);
         $res = array();
         $sectIds = array();
         foreach ($arResult as $sect) {
             $sectId = $sect['ID'];
             $ownerId = $sect['OWNER_ID'];
             if (self::CanDo('calendar_view_time', $sectId) && !in_array($sectId, $sectIds)) {
                 if ($checkSocnetPermissions) {
                     // Disabled in socialnetwork
                     if ($sect['CAL_TYPE'] == 'group' && (!$arFeaturesG[$ownerId] || !$arViewG[$ownerId]) || $sect['CAL_TYPE'] == 'user' && (!$arFeaturesU[$ownerId] || !$arViewU[$ownerId])) {
                         continue;
                     }
                 }
                 $sect['PERM'] = array('view_time' => self::CanDo('calendar_view_time', $sectId), 'view_title' => self::CanDo('calendar_view_title', $sectId), 'view_full' => self::CanDo('calendar_view_full', $sectId), 'add' => self::CanDo('calendar_add', $sectId), 'edit' => self::CanDo('calendar_edit', $sectId), 'edit_section' => self::CanDo('calendar_edit_section', $sectId), 'access' => self::CanDo('calendar_edit_access', $sectId));
                 if ($checkSocnetPermissions) {
                     if ($sect['CAL_TYPE'] == 'group' && !$arWriteG[$ownerId] || $sect['CAL_TYPE'] == 'user' && !$arWriteU[$ownerId]) {
                         $sect['PERM']['add'] = false;
                         $sect['PERM']['edit'] = false;
                         $sect['PERM']['edit_section'] = false;
                         $sect['PERM']['access'] = false;
                     }
                 }
                 if ($sect['CAL_TYPE'] == 'user') {
                     if (isset($sect['USER_NAME'], $sect['USER_LAST_NAME'])) {
                         $sect['OWNER_NAME'] = CCalendar::GetUserName(array("NAME" => $sect['USER_NAME'], "LAST_NAME" => $sect['USER_LAST_NAME'], "LOGIN" => $sect['USER_LOGIN'], "ID" => $ownerId, "SECOND_NAME" => $sect['USER_SECOND_NAME']));
                         unset($sect['USER_LOGIN']);
                         unset($sect['USER_LAST_NAME']);
                         unset($sect['USER_SECOND_NAME']);
                         unset($sect['USER_NAME']);
                     } else {
                         $sect['OWNER_NAME'] = CCalendar::GetUserName($ownerId);
                     }
                 } elseif ($sect['CAL_TYPE'] == 'group' && isset($Params['arGroups'])) {
                     $sect['OWNER_NAME'] = $Params['arGroups'][$ownerId]['NAME'];
                 }
                 $res[] = $sect;
                 $sectIds[] = $sectId;
             }
         }
         $arResult = $res;
     }
     return $arResult;
 }
 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);
         }
     }
 }
Exemple #8
0
        $newId = CCalendar::SaveEvent(array('arFields' => $arFields, 'autoDetectSection' => true, 'autoCreateSection' => true));
    } elseif ($_REQUEST['app_calendar_action'] == 'drop_event' && check_bitrix_sessid()) {
        $res = CCalendar::DeleteEvent(intVal($_POST['event_id']));
    }
    die;
}
$calType = 'user';
$ownerId = $userId;
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'];
 public static function EventUpdate($arParams = array(), $nav = null, $server = null)
 {
     $userId = CCalendar::GetCurUserId();
     $methodName = "calendar.event.update";
     $necessaryParams = array('id', 'ownerId', 'type');
     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)));
         }
     }
     $id = intVal($arParams['id']);
     $type = $arParams['type'];
     $ownerId = intval($arParams['ownerId']);
     $arFields = array("ID" => $id);
     if (isset($arParams['from_ts'])) {
         $arFields["DT_FROM_TS"] = intVal($arParams['from_ts']);
     }
     if (isset($arParams['to_ts'])) {
         $arFields["DT_TO_TS"] = intVal($arParams['to_ts']);
     }
     if (isset($arParams['skip_time'])) {
         $arFields["SKIP_TIME"] = $arParams['skip_time'] == 'Y';
     }
     if (isset($arParams['name'])) {
         $arFields["NAME"] = trim($arParams['name']);
     }
     if (isset($arParams['description'])) {
         $arFields["DESCRIPTION"] = trim($arParams['description']);
     }
     if (isset($arParams['section'])) {
         $sectionId = $arParams['section'];
         $arFields["SECTIONS"] = array($sectionId);
         $res = CCalendarSect::GetList(array('arFilter' => array('CAL_TYPE' => $type, 'OWNER_ID' => $ownerId, 'ID' => $arParams['section'])));
         if ($res && is_array($res) && isset($res[0])) {
             if (!$res[0]['PERM']['edit']) {
                 throw new Exception(GetMessage('CAL_REST_ACCESS_DENIED'));
             }
         } else {
             throw new Exception('CAL_REST_SECTION_ERROR');
         }
     }
     if (isset($arParams['color'])) {
         $color = CCalendar::Color($arParams['color']);
         if ($color) {
             $arFields["COLOR"] = $color;
         }
     }
     if (isset($arParams['text_color'])) {
         $color = CCalendar::Color($arParams['text_color']);
         if ($color) {
             $arFields["TEXT_COLOR"] = $color;
         }
     }
     if (isset($arParams['accessibility'])) {
         $arFields["ACCESSIBILITY"] = $arParams['accessibility'];
     }
     if (isset($arParams['importance'])) {
         $arFields["IMPORTANCE"] = $arParams['importance'];
     }
     if (isset($arParams['private_event'])) {
         $arFields["PRIVATE_EVENT"] = $arParams['private_event'] == "Y";
     }
     if (isset($arParams['rrule'])) {
         $arFields["RRULE"] = $arParams['rrule'];
     }
     if (isset($arParams['is_meeting'])) {
         $arFields["IS_MEETING"] = $arParams['is_meeting'] == "Y";
     }
     if (isset($arParams['location'])) {
         $arFields["LOCATION"] = $arParams['LOCATION'];
     }
     if (isset($arParams['remind'])) {
         $arFields["REMIND"] = $arParams['REMIND'];
     }
     if ($arFields['IS_MEETING']) {
         $arFields['ATTENDEES'] = isset($arParams['attendees']) ? $arParams['attendees'] : false;
         $meeting = isset($arParams['meeting']) ? $arParams['meeting'] : array();
         $arFields['MEETING_HOST'] = isset($arParams['host']) ? intVal($arParams['host']) : $userId;
         $arFields['MEETING'] = array('HOST_NAME' => CCalendar::GetUserName($arFields['MEETING_HOST']), 'TEXT' => $meeting['text'], 'OPEN' => (bool) $meeting['open'], 'NOTIFY' => (bool) $meeting['notify'], 'REINVITE' => (bool) $meeting['reinvite']);
     }
     $newId = CCalendar::SaveEvent(array('arFields' => $arFields));
     if (!$newId) {
         throw new Exception(GetMessage("CAL_REST_EVENT_UPDATE_ERROR"));
     }
     return $newId;
 }
    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 
    }
Exemple #11
0
 public static function AddEvent($MEETING_ID, $arFields, $arParams = array())
 {
     global $USER;
     $EventID = false;
     if (self::IsNewCalendar()) {
         $arEventFields = array('ID' => $arFields['EVENT_ID'], 'CAL_TYPE' => 'user', 'OWNER_ID' => $arFields['OWNER_ID'], 'DT_FROM' => $arFields['DATE_START'], 'DT_TO' => ConvertTimeStamp(MakeTimeStamp($arFields['DATE_START']) + $arFields['DURATION'], 'FULL'), 'NAME' => $arFields['TITLE'], 'DESCRIPTION' => CCalendar::ParseHTMLToBB($arFields['DESCRIPTION']), 'IS_MEETING' => true, 'MEETING_HOST' => $arFields['OWNER_ID'], 'MEETING' => array('HOST_NAME' => CCalendar::GetUserName($arFields['OWNER_ID'])), 'ATTENDEES' => array_keys($arFields['USERS']));
         if ($arFields['CURRENT_STATE'] == CMeeting::STATE_CLOSED) {
             $arEventFields['DT_TO'] = MakeTimeStamp($arFields['DATE_FINISH']) > MakeTimeStamp($arFields['DATE_START']) ? $arFields['DATE_FINISH'] : $arEventFields['DT_TO'];
         }
         $matches = array();
         if (preg_match('/^mr_([\\d]+)_([\\d]+)$/', $arFields["PLACE"], $matches)) {
             $arEventFields['LOCATION'] = 'ECMR_' . $matches[2];
             if ($arFields['EVENT_ID'] > 0) {
                 $arCurrentEvent = CCalendarEvent::GetById($arFields['EVENT_ID']);
                 if ($arCurrentEvent['LOCATION']) {
                     $res = CCalendar::ParseLocation($arCurrentEvent['LOCATION']);
                     if ($res['mrevid']) {
                         $arEventFields['LOCATION'] .= '_' . $res['mrevid'];
                     }
                 }
             }
         } else {
             $arEventFields['LOCATION'] = $arFields['PLACE'];
         }
         if (isset($arFields['REINVITE'])) {
             $arEventFields['MEETING']['REINVITE'] = $arFields['REINVITE'];
         } else {
             $arEventFields['MEETING']['REINVITE'] = false;
         }
         if (isset($arFields['NOTIFY'])) {
             $arEventFields['MEETING']['NOTIFY'] = $arFields['NOTIFY'];
         }
         $EventID = CCalendar::SaveEvent(array('arFields' => $arEventFields, 'userId' => $arFields['OWNER_ID'], 'autoDetectSection' => true, 'autoCreateSection' => true));
     } elseif (!$arFields['EVENT_ID']) {
         $iblockId = $arParams['CALENDAR_IBLOCK_ID'] ? $arParams['CALENDAR_IBLOCK_ID'] : COption::GetOptionInt('intranet', 'iblock_calendar', 0, SITE_ID);
         $obCalendar = new CEventCalendar();
         $obCalendar->Init(array('ownerType' => 'USER', 'ownerId' => $USER->GetID(), 'bOwner' => true, 'iblockId' => $iblockId, 'userIblockId' => $iblockId, 'bCache' => false, 'pathToUserCalendar' => '/company/personal/user/#user_id#/calendar/'));
         $guestCalendarId = false;
         $guestSection = $obCalendar->GetSectionIDByOwnerId($USER->GetID(), 'USER', $iblockId);
         $arGuestCalendars = array();
         if (!$guestSection) {
             $guestSection = $obCalendar->CreateSectionForOwner($USER->GetID(), "USER", $iblockId);
         }
         $arGuestCalendars = $obCalendar->GetCalendars(array('sectionId' => $guestSection, 'iblockId' => $iblockId, 'ownerType' => 'USER', 'ownerId' => $USER->GetID(), 'bOwner' => 1, 'forExport' => true, 'bOnlyID' => true));
         if (count($arGuestCalendars) > 0) {
             $arUserSet = $obCalendar->GetUserSettings(array('static' => false, 'userId' => $USER->GetID()));
             if ($arUserSet && isset($arUserSet['MeetCalId']) && in_array($arUserSet['MeetCalId'], $arGuestCalendars)) {
                 $guestCalendarId = intVal($arUserSet['MeetCalId']);
             } else {
                 $guestCalendarId = $arGuestCalendars[0];
             }
         }
         //$bGroup = $arParams['GROUP_ID'] > 0;
         $arPermissions = $obCalendar->GetPermissions(array('setProperties' => true));
         $arEventFields = array('iblockId' => $obCalendar->iblockId, 'ownerType' => $obCalendar->ownerType, 'ownerId' => $obCalendar->ownerId, 'RMiblockId' => self::__getRMIblockID(), 'allowResMeeting' => true, 'bNew' => true, 'fullUrl' => $obCalendar->fullUrl, 'userId' => $obCalendar->userId, 'pathToUserCalendar' => $obCalendar->pathToUserCalendar, 'pathToGroupCalendar' => $obCalendar->pathToGroupCalendar, 'userIblockId' => $obCalendar->iblockId, 'calendarId' => $guestCalendarId, 'sectionId' => $guestSection, 'dateFrom' => $arFields['DATE_START'], 'dateTo' => $arFields['DATE_FINISH'] ? $arFields['DATE_FINISH'] : ConvertTimeStamp(MakeTimeStamp($arFields['DATE_START']) + $arFields['DURATION'], 'FULL'), 'name' => $arFields['TITLE'], 'desc' => $arFields['DESCRIPTION'], 'prop' => array(), 'isMeeting' => true, 'guests' => array_keys($arFields['USERS']), 'notDisplayCalendar' => true);
         if ($EventID = $obCalendar->SaveEvent($arEventFields)) {
             CEventCalendar::ClearCache('/event_calendar/events/' . $arEventFields['iblockId'] . '/');
             CEventCalendar::ClearCache('/event_calendar/events/' . $arEventFields['userIblockId'] . '/');
         }
     }
     if ($EventID) {
         self::Update($MEETING_ID, array('EVENT_ID' => $EventID));
     }
     return $EventID;
 }