本文整理汇总了PHP中CCalendar::ThrowError方法的典型用法代码示例。如果您正苦于以下问题:PHP CCalendar::ThrowError方法的具体用法?PHP CCalendar::ThrowError怎么用?PHP CCalendar::ThrowError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCalendar
的用法示例。
在下文中一共展示了CCalendar::ThrowError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ReturnICal
public static function ReturnICal($Params)
{
$sectId = $Params['sectId'];
$userId = intVal($Params['userId']);
$sign = $Params['sign'];
$type = strtolower($Params['type']);
$ownerId = intVal($Params['ownerId']);
$bCache = false;
$GLOBALS['APPLICATION']->RestartBuffer();
if (!self::CheckSign($sign, $userId, $sectId)) {
return CCalendar::ThrowError(GetMessage('EC_ACCESS_DENIED'));
}
$arSections = CCalendarSect::GetList(array('arFilter' => array('ID' => $sectId), 'checkPermissions' => false));
if ($arSections && $arSections[0] && $arSections[0]['EXPORT'] && $arSections[0]['EXPORT']['ALLOW']) {
$arSection = $arSections[0];
$arEvents = CCalendarEvent::GetList(array('arFilter' => array('SECTION' => $arSection['ID']), 'getUserfields' => false, 'parseRecursion' => false, 'fetchAttendees' => false, 'fetchMeetings' => true, 'userId' => $userId));
$iCalEvents = self::FormatICal($arSection, $arEvents);
} else {
return CCalendar::ThrowError(GetMessage('EC_ACCESS_DENIED'));
}
self::ShowICalHeaders();
echo $iCalEvents;
exit;
}
示例2: DoSaveToDav
public static function DoSaveToDav($Params = array(), &$arFields, $oCurEvent = false)
{
$sectionId = $Params['sectionId'];
$bExchange = $Params['bExchange'];
$bCalDav = $Params['bCalDav'];
if (isset($oCurEvent['DAV_XML_ID'])) {
$arFields['DAV_XML_ID'] = $oCurEvent['DAV_XML_ID'];
}
if (isset($oCurEvent['DAV_EXCH_LABEL'])) {
$arFields['DAV_EXCH_LABEL'] = $oCurEvent['DAV_EXCH_LABEL'];
}
if (isset($oCurEvent['CAL_DAV_LABEL'])) {
$arFields['CAL_DAV_LABEL'] = $oCurEvent['CAL_DAV_LABEL'];
}
$oSect = CCalendarSect::GetById($sectionId);
if ($oCurEvent) {
if ($oCurEvent['SECT_ID'] != $sectionId) {
$bCalDav = CCalendar::IsCalDAVEnabled() && $oCurEvent['CAL_TYPE'] == 'user' && strlen($oCurEvent['CAL_DAV_LABEL']) > 0;
$bExchangeEnabled = CCalendar::IsExchangeEnabled() && $oCurEvent['CAL_TYPE'] == 'user';
if ($bExchangeEnabled || $bCalDav) {
$res = CCalendar::DoDeleteToDav(array('bCalDav' => $bCalDav, 'bExchangeEnabled' => $bExchangeEnabled, 'sectionId' => $oCurEvent['SECT_ID']), $oCurEvent);
if ($res !== true) {
return CCalendar::ThrowError($res);
}
}
}
}
$fromTs = CCalendar::Timestamp($arFields['DT_FROM']);
$toTs = CCalendar::Timestamp($arFields['DT_TO']);
if (!isset($arFields['DT_FROM_TS'])) {
$arFields['DT_FROM_TS'] = $fromTs;
}
if (!isset($arFields['DT_TO_TS'])) {
$arFields['DT_TO_TS'] = $toTs;
}
$arDavFields = $arFields;
CCalendarEvent::CheckFields($arDavFields);
if ($arDavFields['RRULE'] != '') {
$arDavFields['RRULE'] = $arFields['RRULE'];
}
$arDavFields['DETAIL_TEXT'] = $arDavFields['DESCRIPTION'];
$arDavFields['DETAIL_TEXT_TYPE'] = 'text';
$arDavFields['ACTIVE_FROM'] = $arDavFields['DT_FROM'];
$arDavFields['ACTIVE_TO'] = $arDavFields['DT_TO'];
$arDavFields['PROPERTY_LOCATION'] = $arDavFields['LOCATION']['NEW'];
if ($arDavFields['PROPERTY_LOCATION'] !== '') {
$arDavFields['PROPERTY_LOCATION'] = CCalendar::GetTextLocation($arDavFields['PROPERTY_LOCATION']);
}
$arDavFields['PROPERTY_IMPORTANCE'] = $arDavFields['IMPORTANCE'];
$arDavFields['REMIND_SETTINGS'] = '';
if ($arFields['REMIND'] && is_array($arFields['REMIND']) && is_array($arFields['REMIND'][0])) {
$arDavFields['REMIND_SETTINGS'] = floatVal($arFields['REMIND'][0]['count']) . '_' . $arFields['REMIND'][0]['type'];
}
// RRULE
$arDavFields['PROPERTY_PERIOD_TYPE'] = 'NONE';
if (is_array($arFields['RRULE']) && isset($arFields['RRULE']['FREQ']) && in_array($arFields['RRULE']['FREQ'], array('HOURLY', 'DAILY', 'MONTHLY', 'YEARLY', 'WEEKLY'))) {
$arDavFields['PROPERTY_PERIOD_TYPE'] = $arFields['RRULE']['FREQ'];
// Interval
$arDavFields['PROPERTY_PERIOD_COUNT'] = isset($arFields['RRULE']['INTERVAL']) && intVal($arFields['RRULE']['INTERVAL']) > 1 ? intVal($arFields['RRULE']['INTERVAL']) : 1;
if ($arFields['RRULE']['FREQ'] == 'WEEKLY' && isset($arFields['RRULE']['BYDAY'])) {
//PROPERTY_PERIOD_ADDITIONAL
$BYDAYS = array();
$days = array('SU' => 0, 'MO' => 1, 'TU' => 2, 'WE' => 3, 'TH' => 4, 'FR' => 5, 'SA' => 6);
$bydays = explode(',', $arFields['RRULE']['BYDAY']);
foreach ($bydays as $day) {
$BYDAYS[] = $days[$day];
}
$arDavFields['PROPERTY_PERIOD_ADDITIONAL'] = implode(',', $BYDAYS);
}
$h24 = 60 * 60 * 24;
if ($fromTs == $toTs) {
$arDavFields['PROPERTY_EVENT_LENGTH'] = $h24;
} else {
$arDavFields['PROPERTY_EVENT_LENGTH'] = intVal($toTs - $fromTs);
if ($arDavFields['PROPERTY_EVENT_LENGTH'] % $h24 == 0) {
// We have dates without times
$arDavFields['PROPERTY_EVENT_LENGTH'] += $h24;
}
}
// Until date
if (isset($arFields['RRULE']['UNTIL'])) {
$periodTs = $arFields['RRULE']['UNTIL'];
} else {
$periodTs = CCalendar::GetMaxTimestamp();
}
$arDavFields['ACTIVE_TO'] = CCalendar::Date($periodTs);
}
// **** Synchronize with CalDav ****
if ($bCalDav && $oSect['CAL_DAV_CON'] > 0) {
// New event or move existent event to DAV calendar
if ($arFields['ID'] <= 0 || $oCurEvent && !$oCurEvent['CAL_DAV_LABEL']) {
$DAVRes = CDavGroupdavClientCalendar::DoAddItem($oSect['CAL_DAV_CON'], $oSect['CAL_DAV_CAL'], $arDavFields);
} else {
// Edit existent event
$DAVRes = CDavGroupdavClientCalendar::DoUpdateItem($oSect['CAL_DAV_CON'], $oSect['CAL_DAV_CAL'], $oCurEvent['DAV_XML_ID'], $oCurEvent['CAL_DAV_LABEL'], $arDavFields);
}
if (!is_array($DAVRes) || !array_key_exists("XML_ID", $DAVRes)) {
return CCalendar::CollectCalDAVErros($DAVRes);
}
// // It's ok, we successfuly save event to caldav calendar - and save it to DB
//.........这里部分代码省略.........
示例3: DoSaveToDav
public static function DoSaveToDav($Params = array(), &$arFields, $oCurEvent = false)
{
$sectionId = $Params['sectionId'];
$bExchange = $Params['bExchange'];
$bCalDav = $Params['bCalDav'];
if (isset($oCurEvent['DAV_XML_ID'])) {
$arFields['DAV_XML_ID'] = $oCurEvent['DAV_XML_ID'];
}
if (isset($oCurEvent['DAV_EXCH_LABEL'])) {
$arFields['DAV_EXCH_LABEL'] = $oCurEvent['DAV_EXCH_LABEL'];
}
if (isset($oCurEvent['CAL_DAV_LABEL'])) {
$arFields['CAL_DAV_LABEL'] = $oCurEvent['CAL_DAV_LABEL'];
}
$oSect = CCalendarSect::GetById($sectionId);
if ($oCurEvent) {
if ($oCurEvent['SECT_ID'] != $sectionId) {
$bCalDavCur = CCalendar::IsCalDAVEnabled() && $oCurEvent['CAL_TYPE'] == 'user' && strlen($oCurEvent['CAL_DAV_LABEL']) > 0;
$bExchangeEnabledCur = CCalendar::IsExchangeEnabled() && $oCurEvent['CAL_TYPE'] == 'user';
if ($bExchangeEnabledCur || $bCalDavCur) {
$res = CCalendar::DoDeleteToDav(array('bCalDav' => $bCalDavCur, 'bExchangeEnabled' => $bExchangeEnabledCur, 'sectionId' => $oCurEvent['SECT_ID']), $oCurEvent);
if ($oCurEvent['DAV_EXCH_LABEL']) {
$oCurEvent['DAV_EXCH_LABEL'] = '';
}
if ($res !== true) {
return CCalendar::ThrowError($res);
}
}
}
}
$arDavFields = $arFields;
CCalendarEvent::CheckFields($arDavFields);
if ($arDavFields['RRULE'] != '') {
$arDavFields['RRULE'] = $arFields['RRULE'];
}
$arDavFields['PROPERTY_LOCATION'] = $arDavFields['LOCATION']['NEW'];
if ($arDavFields['PROPERTY_LOCATION'] !== '') {
$arDavFields['PROPERTY_LOCATION'] = CCalendar::GetTextLocation($arDavFields['PROPERTY_LOCATION']);
}
$arDavFields['PROPERTY_IMPORTANCE'] = $arDavFields['IMPORTANCE'];
$arDavFields['REMIND_SETTINGS'] = '';
if ($arFields['REMIND'] && is_array($arFields['REMIND']) && is_array($arFields['REMIND'][0])) {
$arDavFields['REMIND_SETTINGS'] = floatVal($arFields['REMIND'][0]['count']) . '_' . $arFields['REMIND'][0]['type'];
}
// **** Synchronize with CalDav ****
if ($bCalDav && $oSect['CAL_DAV_CON'] > 0) {
// New event or move existent event to DAV calendar
if ($arFields['ID'] <= 0 || $oCurEvent && !$oCurEvent['CAL_DAV_LABEL']) {
$DAVRes = CDavGroupdavClientCalendar::DoAddItem($oSect['CAL_DAV_CON'], $oSect['CAL_DAV_CAL'], $arDavFields);
} else {
// Edit existent event
$DAVRes = CDavGroupdavClientCalendar::DoUpdateItem($oSect['CAL_DAV_CON'], $oSect['CAL_DAV_CAL'], $oCurEvent['DAV_XML_ID'], $oCurEvent['CAL_DAV_LABEL'], $arDavFields);
}
if (!is_array($DAVRes) || !array_key_exists("XML_ID", $DAVRes)) {
return CCalendar::CollectCalDAVErros($DAVRes);
}
// // It's ok, we successfuly save event to caldav calendar - and save it to DB
$arFields['DAV_XML_ID'] = $DAVRes['XML_ID'];
$arFields['CAL_DAV_LABEL'] = $DAVRes['MODIFICATION_LABEL'];
} elseif ($bExchange && $oSect['IS_EXCHANGE'] && strlen($oSect['DAV_EXCH_CAL']) > 0 && $oSect['DAV_EXCH_CAL'] !== 0) {
$ownerId = $arFields['OWNER_ID'];
$fromTo = CCalendarEvent::GetEventFromToForUser($arDavFields, $ownerId);
$arDavFields["DATE_FROM"] = $fromTo['DATE_FROM'];
$arDavFields["DATE_TO"] = $fromTo['DATE_TO'];
// Convert BBcode to HTML for exchange
$arDavFields["DESCRIPTION"] = CCalendarEvent::ParseText($arDavFields['DESCRIPTION']);
// New event or move existent event to Exchange calendar
if ($arFields['ID'] <= 0 || $oCurEvent && !$oCurEvent['DAV_EXCH_LABEL']) {
$exchRes = CDavExchangeCalendar::DoAddItem($ownerId, $oSect['DAV_EXCH_CAL'], $arDavFields);
} else {
$exchRes = CDavExchangeCalendar::DoUpdateItem($ownerId, $oCurEvent['DAV_XML_ID'], $oCurEvent['DAV_EXCH_LABEL'], $arDavFields);
}
if (!is_array($exchRes) || !array_key_exists("XML_ID", $exchRes)) {
return CCalendar::CollectExchangeErrors($exchRes);
}
// It's ok, we successfuly save event to exchange calendar - and save it to DB
$arFields['DAV_XML_ID'] = $exchRes['XML_ID'];
$arFields['DAV_EXCH_LABEL'] = $exchRes['MODIFICATION_LABEL'];
}
return true;
}