Пример #1
0
    function CreateDefault($arParams = array(), $bDisplay = true, &$newSectionId = 'none')
    {
        $iblockId = $arParams['iblockId'];
        $ownerId = $arParams['ownerId'];
        $ownerType = $arParams['ownerType'];
        $sectionId = $arParams['sectionId'];
        if ($ownerType == 'USER') {
            $name = GetMessage('EC_DEF_SECT_USER_CAL');
        } else {
            $name = GetMessage('EC_DEF_SECT_GROUP_CAL');
        }
        $arFields = array('ID' => 0, 'NAME' => $name, 'DESCRIPTION' => '', "COLOR" => "#CEE669", "EXPORT" => true, "EXPORT_SET" => 'all');
        $arParams['arFields'] = $arFields;
        $ID = CECCalendar::Edit($arParams, $newSectionId, $bDisplay);
        if ($ID > 0 && $bDisplay) {
            $arEx = CECCalendar::GetExportParams($iblockId, $ID, $ownerType, $ownerId);
            $outlookJs = CECCalendar::GetOutlookLink(array('ID' => intVal($ID), 'PREFIX' => CEventCalendar::GetOwnerName(array('iblockId' => $iblockId, 'ownerType' => $ownerType, 'ownerId' => $ownerId))));
            ?>
<script>window._bx_def_calendar = {
	ID: <?php 
            echo intVal($ID);
            ?>
,
	NAME: '<?php 
            echo $arFields['NAME'];
            ?>
',
	COLOR: '<?php 
            echo $arFields['COLOR'];
            ?>
',
	EXPORT: <?php 
            echo $arEx['ALLOW'] ? 'true' : 'false';
            ?>
,
	EXPORT_SET: '<?php 
            echo $arEx['SET'];
            ?>
',
	EXPORT_LINK: '<?php 
            echo $arEx['LINK'];
            ?>
',
	PRIVATE_STATUS: 'full',
	bNew: true,
	OUTLOOK_JS: '<?php 
            echo addslashes(htmlspecialcharsex($outlookJs));
            ?>
'
};</script>
			<?php 
        }
        // Clear cache
        CEventCalendar::ClearCache("event_calendar/" . $iblockId . "/calendars/" . ($ownerId > 0 ? $ownerId : 0) . "/");
        if ($ownerType == 'GROUP') {
            CEventCalendar::ClearCache('event_calendar/sp_groups/');
        } elseif ($ownerType == 'USER') {
            CEventCalendar::ClearCache('event_calendar/sp_user/');
        } else {
            CEventCalendar::ClearCache('event_calendar/sp_common/');
        }
        return $ID;
    }