Esempio n. 1
0
 public static function CheckEndUpdateAttendeesCodes($event)
 {
     if ($event['ID'] > 0 && $event['IS_MEETING'] && empty($event['ATTENDEES_CODES']) && is_array($event['~ATTENDEES'])) {
         $event['ATTENDEES_CODES'] = array();
         foreach ($event['~ATTENDEES'] as $attendee) {
             if (intval($attendee['USER_ID']) > 0) {
                 $event['ATTENDEES_CODES'][] = 'U' . IntVal($attendee['USER_ID']);
             }
         }
         $event['ATTENDEES_CODES'] = array_unique($event['ATTENDEES_CODES']);
         global $DB;
         $strSql = "UPDATE b_calendar_event SET " . "ATTENDEES_CODES='" . implode(',', $event['ATTENDEES_CODES']) . "'" . " WHERE ID=" . IntVal($event['ID']);
         $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
         CCalendar::ClearCache(array('event_list'));
     }
     return $event['ATTENDEES_CODES'];
 }
Esempio n. 2
0
 public static function SaveSection($Params)
 {
     $type = isset($Params['arFields']['CAL_TYPE']) ? $Params['arFields']['CAL_TYPE'] : self::$type;
     // Exchange
     if ($Params['bAffectToDav'] !== false && CCalendar::IsExchangeEnabled(self::$ownerId) && $type == 'user') {
         $exchRes = true;
         $ownerId = isset($Params['arFields']['OWNER_ID']) ? $Params['arFields']['OWNER_ID'] : self::$ownerId;
         if (isset($Params['arFields']['ID']) && $Params['arFields']['ID'] > 0) {
             // Fetch section
             $oSect = CCalendarSect::GetById($Params['arFields']['ID']);
             // For exchange we change only calendar name
             if ($oSect && $oSect['IS_EXCHANGE'] && $oSect['DAV_EXCH_CAL'] && $oSect["NAME"] != $Params['arFields']['NAME']) {
                 $exchRes = CDavExchangeCalendar::DoUpdateCalendar($ownerId, $oSect['DAV_EXCH_CAL'], $oSect['DAV_EXCH_MOD'], $Params['arFields']);
             }
         } elseif ($Params['arFields']['IS_EXCHANGE']) {
             $exchRes = CDavExchangeCalendar::DoAddCalendar($ownerId, $Params['arFields']);
         }
         if ($exchRes !== true) {
             if (!is_array($exchRes) || !array_key_exists("XML_ID", $exchRes)) {
                 return CCalendar::ThrowError(CCalendar::CollectExchangeErrors($exchRes));
             }
             // // It's ok, we successfuly save event to exchange calendar - and save it to DB
             $Params['arFields']['DAV_EXCH_CAL'] = $exchRes['XML_ID'];
             $Params['arFields']['DAV_EXCH_MOD'] = $exchRes['MODIFICATION_LABEL'];
         }
     }
     // Save here
     $ID = CCalendarSect::Edit($Params);
     CCalendar::ClearCache(array('section_list', 'event_list'));
     return $ID;
 }
Esempio n. 3
0
	function InstallEvents()
	{
		global $DB;

		$arCurPhpVer = Explode(".", PhpVersion());
		if (IntVal($arCurPhpVer[0]) < 5)
			return true;

		$sIn = "'CALENDAR_INVITATION'";
		$rs = $DB->Query("SELECT count(*) C FROM b_event_type WHERE EVENT_NAME IN (".$sIn.") ", false, "File: ".__FILE__."<br>Line: ".__LINE__);
		$ar = $rs->Fetch();

		if($ar["C"] <= 0)
			include($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/calendar/install/events.php");

		if (!IsModuleInstalled('intranet'))
		{
			COption::SetOptionString("intranet", "calendar_2", "Y");
			CModule::IncludeModule('calendar');
			CCalendar::ClearCache();
			CCalendar::CacheTime(0);

			$arTypes = CCalendarType::GetList();
			if (!$arTypes || !count($arTypes))
			{
				CCalendarType::Edit(array(
					'NEW' => true,
					'arFields' => array(
						'XML_ID' => 'events',
						'NAME' => GetMessage('CAL_DEFAULT_TYPE'),
						'ACCESS' => array(
							'G2' => CCalendar::GetAccessTasksByName('calendar_type', 'calendar_type_view')
						)
					)
				));
			}
		}

		return true;
	}
 public static function Delete($ID)
 {
     global $DB;
     if (!CCalendarSect::CanDo('calendar_edit_section', $ID)) {
         return CCalendar::ThrowError('EC_ACCESS_DENIED');
     }
     // Del link from table
     $strSql = "DELETE FROM b_calendar_event_sect WHERE SECT_ID=" . IntVal($ID);
     $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     // Del from
     $strSql = "DELETE FROM b_calendar_section WHERE ID=" . IntVal($ID);
     $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     CCalendarEvent::DeleteEmpty();
     CCalendar::ClearCache(array('section_list', 'event_list'));
     return true;
 }
Esempio n. 5
0
}
if (CModule::IncludeModule("intranet") && CModule::IncludeModule("calendar")) {
    CModule::IncludeModule("socialnetwork");
    $RES = NULL;
    // 1. Fetch options
    if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["convert"]) && $_POST["convert"] == 'Y' && check_bitrix_sessid()) {
        // Remember all settings
        $SET = array('work_time_start' => $_REQUEST['work_time_start'], 'work_time_end' => $_REQUEST['work_time_end'], 'year_holidays' => $_REQUEST['year_holidays'], 'week_holidays' => implode('|', $_REQUEST['week_holidays']), 'path_to_user' => $_REQUEST['path_to_user'], 'path_to_user_calendar' => $_REQUEST['path_to_user_calendar'], 'path_to_group' => $_REQUEST['path_to_group'], 'path_to_group_calendar' => $_REQUEST['path_to_group_calendar'], 'path_to_vr' => $_REQUEST['path_to_vr'], 'path_to_rm' => $_REQUEST['path_to_rm'], 'rm_iblock_type' => $_REQUEST['rm_iblock_type'], 'rm_iblock_id' => $_REQUEST['rm_iblock_id'], 'vr_iblock_id' => $_REQUEST['vr_iblock_id']);
        $CUR_SET = CCalendar::GetSettings();
        foreach ($CUR_SET as $key => $value) {
            if (!isset($SET[$key]) && isset($value)) {
                $SET[$key] = $value;
            }
        }
        CCalendar::SetSettings($SET);
        CCalendar::ClearCache(array('access_tasks', 'type_list', 'type_list', 'section_list'));
        // Remember iblocks
        // Create types
        if (isset($_POST["set_params"]) && $_POST["set_params"] == 'Y') {
            $types = array();
            foreach ($_POST['types'] as $type) {
                if (isset($type['allow']) && $type['allow'] == "Y") {
                    $types[$type['key']] = array('iblockType' => $type['iblock_type'], 'iblockId' => $type['iblock_id'], 'name' => $type['title'], 'desc' => $type['desc']);
                    $typeAccess = array('G2' => CCalendar::GetAccessTasksByName('calendar_type', 'calendar_type_edit'));
                    if ($type['key'] != 'user' && $type['key'] != 'group') {
                        $arGroupPerm = CIBlock::GetGroupPermissions($type['iblock_id']);
                        $taskByLetter = array('D' => CCalendar::GetAccessTasksByName('calendar_type', 'calendar_type_denied'), 'R' => CCalendar::GetAccessTasksByName('calendar_type', 'calendar_type_view'), 'W' => CCalendar::GetAccessTasksByName('calendar_type', 'calendar_type_edit'), 'X' => CCalendar::GetAccessTasksByName('calendar_type', 'calendar_type_access'));
                        foreach ($arGroupPerm as $groupId => $letter) {
                            $typeAccess['G' . $groupId] = $taskByLetter[$letter];
                        }
                    }
Esempio n. 6
0
 public static function Delete($id, $checkPermissions = true)
 {
     global $DB;
     if ($checkPermissions !== false && !CCalendarSect::CanDo('calendar_edit_section', $id)) {
         return CCalendar::ThrowError('EC_ACCESS_DENIED');
     }
     $arEvents = CCalendarEvent::GetList(array('arFilter' => array("SECTION" => array(IntVal($id))), 'setDefaultLimit' => false, 'parseRecursion' => false, 'checkPermissions' => false));
     $meetingIds = array();
     foreach ($arEvents as $event) {
         if ($event['IS_MEETING'] && $event['PARENT_ID'] === $event['ID']) {
             $meetingIds[] = intval($event['PARENT_ID']);
             CCalendarLiveFeed::OnDeleteCalendarEventEntry($event['PARENT_ID'], $event);
         }
     }
     if (count($meetingIds) > 0) {
         $meetingIds = implode(',', $meetingIds);
         $DB->Query("DELETE from b_calendar_event WHERE PARENT_ID in (" . $meetingIds . ")", false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     // Del link from table
     $strSql = "DELETE FROM b_calendar_event_sect WHERE SECT_ID=" . IntVal($id);
     $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     // Del from
     $strSql = "DELETE FROM b_calendar_section WHERE ID=" . IntVal($id);
     $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     CCalendarEvent::DeleteEmpty();
     CCalendar::ClearCache(array('section_list', 'event_list'));
     return true;
 }
Esempio n. 7
0
 public static function Delete($XML_ID)
 {
     global $DB;
     // Del types
     $strSql = "DELETE FROM b_calendar_type WHERE XML_ID='" . $DB->ForSql($XML_ID) . "'";
     $z = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     // Del access for types
     $strSql = "DELETE FROM b_calendar_access WHERE SECT_ID='" . $DB->ForSql($XML_ID) . "'";
     $z = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     // Del sections
     $strSql = "DELETE FROM b_calendar_section WHERE CAL_TYPE='" . $DB->ForSql($XML_ID) . "'";
     $z = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     // Del events
     $strSql = "DELETE FROM b_calendar_event WHERE CAL_TYPE='" . $DB->ForSql($XML_ID) . "'";
     $z = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
     CCalendar::ClearCache(array('type_list', 'section_list', 'event_list'));
     return true;
 }
    public static function DeleteEmpty()
    {
        global $DB;
        $strSql = 'SELECT CE.ID, CE.LOCATION
			FROM b_calendar_event CE
			LEFT JOIN b_calendar_event_sect CES ON (CE.ID=CES.EVENT_ID)
			WHERE CES.SECT_ID is null';
        $res = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
        $strItems = "0";
        while ($arRes = $res->Fetch()) {
            $loc = $arRes['LOCATION'];
            if ($loc && strlen($loc) > 5 && substr($loc, 0, 5) == 'ECMR_') {
                $loc = CCalendar::ParseLocation($loc);
                if ($loc['mrid'] !== false && $loc['mrevid'] !== false) {
                    // Release MR
                    CCalendar::ReleaseLocation($loc);
                }
            }
            $strItems .= "," . IntVal($arRes['ID']);
        }
        // Clean from 'b_calendar_event'
        if ($strItems != "0") {
            $DB->Query("DELETE FROM b_calendar_event WHERE ID in (" . $strItems . ")", false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
        }
        CCalendar::ClearCache(array('section_list', 'event_list'));
    }