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'));
    }
Exemple #2
0
<?php

define("PUBLIC_AJAX_MODE", true);
define("NO_KEEP_STATISTIC", "Y");
define("NO_AGENT_STATISTIC", "Y");
define("NO_AGENT_CHECK", true);
define("DisableEventsCheck", true);
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
if (check_bitrix_sessid() && CModule::IncludeModule("calendar")) {
    if (isset($_REQUEST['bx_event_calendar_check_meeting_room']) && $_REQUEST['bx_event_calendar_check_meeting_room'] === 'Y') {
        $check = false;
        $settings = CCalendar::GetSettings();
        $from = CCalendar::Date(CCalendar::Timestamp($_REQUEST['from']));
        $to = CCalendar::Date(CCalendar::Timestamp($_REQUEST['to']));
        $loc_new = CCalendar::ParseLocation(trim($_REQUEST['location']));
        $params = array('dateFrom' => $from, 'dateTo' => $to, 'regularity' => 'NONE', 'members' => false);
        if ($loc_new['mrid'] == $settings['vr_iblock_id']) {
            $params['VMiblockId'] = $settings['vr_iblock_id'];
            $check = CCalendar::CheckVideoRoom($params);
        } else {
            $params['RMiblockId'] = $settings['rm_iblock_id'];
            $params['mrid'] = $loc_new['mrid'];
            $params['mrevid_old'] = 0;
            $check = CCalendar::CheckMeetingRoom($params);
        }
        ?>
<script>top.BXCRES_Check = <?php 
        echo CUtil::PhpToJSObject($check);
        ?>
;</script><?php 
Exemple #3
0
 public static function SetLocation($old = '', $new = '', $Params = array())
 {
     // *** ADD MEETING ROOM ***
     $locOld = CCalendar::ParseLocation($old);
     $locNew = CCalendar::ParseLocation($new);
     $allowReserveMeeting = isset($Params['allowReserveMeeting']) ? $Params['allowReserveMeeting'] : self::$allowReserveMeeting;
     $allowVideoMeeting = isset($Params['allowVideoMeeting']) ? $Params['allowVideoMeeting'] : self::$allowVideoMeeting;
     $RMiblockId = isset($Params['RMiblockId']) ? $Params['RMiblockId'] : self::$settings['rm_iblock_id'];
     $VMiblockId = isset($Params['VMiblockId']) ? $Params['VMiblockId'] : self::$settings['vr_iblock_id'];
     // If not allowed
     if (!$allowReserveMeeting && !$allowVideoMeeting) {
         return $locNew['mrid'] ? $locNew['str'] : $new;
     }
     if ($locOld['mrid'] !== false && $locOld['mrevid'] !== false) {
         if ($allowVideoMeeting && $locOld['mrid'] == $VMiblockId) {
             CCalendar::ReleaseVideoRoom(array('mrevid' => $locOld['mrevid'], 'mrid' => $locOld['mrid'], 'VMiblockId' => $VMiblockId));
         } elseif ($allowReserveMeeting) {
             CCalendar::ReleaseMeetingRoom(array('mrevid' => $locOld['mrevid'], 'mrid' => $locOld['mrid'], 'RMiblockId' => $RMiblockId));
         }
     }
     if ($locNew['mrid'] !== false) {
         if ($Params['bRecreateReserveMeetings']) {
             // video meeting
             if ($allowVideoMeeting && $locNew['mrid'] == $VMiblockId) {
                 $mrevid = CCalendar::ReserveVideoRoom(array('mrid' => $locNew['mrid'], 'dateFrom' => $Params['dateFrom'], 'dateTo' => $Params['dateTo'], 'name' => $Params['name'], 'description' => GetMessage('EC_RESERVE_FOR_EVENT') . ': ' . $Params['name'], 'persons' => $Params['persons'], 'members' => $Params['attendees'], 'VMiblockId' => $VMiblockId));
             } elseif ($allowReserveMeeting) {
                 $mrevid = CCalendar::ReserveMeetingRoom(array('RMiblockId' => $RMiblockId, 'mrid' => $locNew['mrid'], 'dateFrom' => $Params['dateFrom'], 'dateTo' => $Params['dateTo'], 'name' => $Params['name'], 'description' => GetMessage('EC_RESERVE_FOR_EVENT') . ': ' . $Params['name'], 'persons' => $Params['persons'], 'members' => $Params['attendees']));
             }
         } elseif (is_array($locNew) && $locNew['mrevid'] !== false) {
             $mrevid = $locNew['mrevid'];
         }
         if ($mrevid && $mrevid != 'reserved' && $mrevid != 'expire' && $mrevid > 0) {
             $locNew = 'ECMR_' . $locNew['mrid'] . '_' . $mrevid;
         } else {
             $locNew = '';
         }
     } else {
         $locNew = $locNew['str'];
     }
     return $locNew;
 }
Exemple #4
0
 public static function GetEvent($eventId)
 {
     if (self::IsNewCalendar()) {
         $arEvent = CCalendarEvent::GetByID($eventId);
         if ($arEvent['LOCATION']) {
             $arEvent['LOCATION'] = CCalendar::ParseLocation($arEvent['LOCATION']);
         }
         return $arEvent;
     }
 }