本文整理汇总了PHP中CCalendar::RemoveAgent方法的典型用法代码示例。如果您正苦于以下问题:PHP CCalendar::RemoveAgent方法的具体用法?PHP CCalendar::RemoveAgent怎么用?PHP CCalendar::RemoveAgent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCalendar
的用法示例。
在下文中一共展示了CCalendar::RemoveAgent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ReminderAgent
public static function ReminderAgent($eventId = 0, $userId = 0, $viewPath = '', $calendarType = '', $ownerId = 0)
{
if ($eventId > 0 && $userId > 0 && $calendarType != '') {
if (!CModule::IncludeModule("im")) {
return false;
}
$skipReminding = false;
global $USER;
// Create tmp user
if ($bTmpUser = !$USER || !is_object($USER)) {
$USER = new CUser();
}
// We have to use this to set timezone offset to local user's timezone
self::SetOffset(false, self::GetOffset($userId));
$arEvents = CCalendarEvent::GetList(array('arFilter' => array("ID" => $eventId, "DELETED" => "N", "FROM_LIMIT" => CCalendar::Date(time() - 3600, false), "TO_LIMIT" => CCalendar::Date(CCalendar::GetMaxTimestamp(), false)), 'parseRecursion' => true, 'maxInstanceCount' => 2, 'preciseLimits' => true, 'fetchAttendees' => true, 'checkPermissions' => false, 'setDefaultLimit' => false));
if ($arEvents && is_array($arEvents[0])) {
$Event = $arEvents[0];
}
if ($Event && $Event['IS_MEETING'] && is_array($Event['~ATTENDEES'])) {
foreach ($Event['~ATTENDEES'] as $attendee) {
// If current user is an attendee but his status is 'N' we don't take care about reminding
if ($attendee['USER_ID'] == $userId && $attendee['STATUS'] == 'N') {
$skipReminding = true;
break;
}
}
}
if ($Event && $Event['DELETED'] != 'Y' && !$skipReminding) {
// Get Calendar Info
$Section = CCalendarSect::GetById($Event['SECT_ID'], false);
if ($Section) {
$arNotifyFields = array('FROM_USER_ID' => $userId, 'TO_USER_ID' => $userId, 'NOTIFY_TYPE' => IM_NOTIFY_SYSTEM, 'NOTIFY_MODULE' => "calendar", 'NOTIFY_EVENT' => "reminder", 'NOTIFY_TAG' => "CALENDAR|INVITE|" . $eventId . "|" . $userId . "|REMINDER", 'NOTIFY_SUB_TAG' => "CALENDAR|INVITE|" . $eventId);
$arNotifyFields['MESSAGE'] = GetMessage('EC_EVENT_REMINDER', array('#EVENT_NAME#' => $Event["NAME"], '#DATE_FROM#' => CCalendar::CutZeroTime($Event["DT_FROM"])));
$sectionName = $Section['NAME'];
$ownerName = CCalendar::GetOwnerName($calendarType, $ownerId);
if ($calendarType == 'user' && $ownerId == $userId) {
$arNotifyFields['MESSAGE'] .= ' ' . GetMessage('EC_EVENT_REMINDER_IN_PERSONAL', array('#CALENDAR_NAME#' => $sectionName));
} else {
if ($calendarType == 'user') {
$arNotifyFields['MESSAGE'] .= ' ' . GetMessage('EC_EVENT_REMINDER_IN_USER', array('#CALENDAR_NAME#' => $sectionName, '#USER_NAME#' => $ownerName));
} else {
if ($calendarType == 'group') {
$arNotifyFields['MESSAGE'] .= ' ' . GetMessage('EC_EVENT_REMINDER_IN_GROUP', array('#CALENDAR_NAME#' => $sectionName, '#GROUP_NAME#' => $ownerName));
} else {
$arNotifyFields['MESSAGE'] .= ' ' . GetMessage('EC_EVENT_REMINDER_IN_COMMON', array('#CALENDAR_NAME#' => $sectionName, '#IBLOCK_NAME#' => $ownerName));
}
}
}
if ($viewPath != '') {
$arNotifyFields['MESSAGE'] .= "\n" . GetMessage('EC_EVENT_REMINDER_DETAIL', array('#URL_VIEW#' => $viewPath));
}
CIMNotify::Add($arNotifyFields);
foreach (GetModuleEvents("calendar", "OnRemindEvent", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(array('eventId' => $eventId, 'userId' => $userId, 'viewPath' => $viewPath, 'calType' => $calendarType, 'ownerId' => $ownerId)));
}
if (CCalendarEvent::CheckRecurcion($Event) && ($nextEvent = $arEvents[1])) {
$remAgentParams = array('eventId' => $eventId, 'userId' => $userId, 'viewPath' => $viewPath, 'calendarType' => $calendarType, 'ownerId' => $ownerId);
// 1. clean reminders
CCalendar::RemoveAgent($remAgentParams);
// 2. Set new reminders
$startTs = $nextEvent['DT_FROM_TS'];
$reminder = $nextEvent['REMIND'][0];
if ($reminder) {
$delta = intVal($reminder['count']) * 60;
//Minute
if ($reminder['type'] == 'hour') {
$delta = $delta * 60;
} elseif ($reminder['type'] == 'day') {
$delta = $delta * 60 * 24;
}
//Day
if ($startTs - $delta >= time() - 60 * 10) {
// Inaccuracy - 10 min
CCalendar::AddAgent(CCalendar::Date($startTs - $delta), $remAgentParams);
}
}
}
}
}
self::$offset = null;
if (isset($bTmpUser) && $bTmpUser) {
unset($USER);
}
}
}
示例2: SetMeetingParams
public static function SetMeetingParams($userId, $eventId, $arFields)
{
global $DB;
$eventId = intVal($eventId);
$userId = intVal($userId);
// Check $arFields
if (!in_array($arFields['ACCESSIBILITY'], array('busy', 'quest', 'free', 'absent'))) {
$arFields['ACCESSIBILITY'] = 'busy';
}
$arReminders = array();
if ($arFields['REMIND'] && is_array($arFields['REMIND'])) {
foreach ($arFields['REMIND'] as $remind) {
if (in_array($remind['type'], array('min', 'hour', 'day'))) {
$arReminders[] = array('type' => $remind['type'], 'count' => floatVal($remind['count']));
}
}
}
$arFields['REMIND'] = count($arReminders) > 0 ? serialize($arReminders) : '';
// Reminding options
$Event = CCalendarEvent::GetById($eventId);
if (!$Event) {
return false;
}
$path = CCalendar::GetPath($arFields['CAL_TYPE']);
$path = CHTTP::urlDeleteParams($path, array("action", "sessid", "bx_event_calendar_request", "EVENT_ID"));
$viewPath = CHTTP::urlAddParams($path, array('EVENT_ID' => $eventId));
$remAgentParams = array('eventId' => $eventId, 'userId' => $userId, 'viewPath' => $viewPath, 'calendarType' => $Event["CAL_TYPE"], 'ownerId' => $Event["OWNER_ID"]);
// 1. clean reminders
CCalendar::RemoveAgent($remAgentParams);
// 2. Set new reminders
foreach ($arReminders as $reminder) {
$delta = intVal($reminder['count']) * 60;
//Minute
if ($reminder['type'] == 'hour') {
$delta = $delta * 60;
} elseif ($reminder['type'] == 'day') {
$delta = $delta * 60 * 24;
}
//Day
if ($Event['DT_FROM_TS'] - $delta >= time() - 60 * 5) {
// Inaccuracy - 5 min
CCalendar::AddAgent(CCalendar::Date($Event['DT_FROM_TS'] - $delta), $remAgentParams);
}
}
// Select meeting info about event
$res = CCalendarEvent::GetList(array('arFilter' => array("ID" => $eventId, "DELETED" => "N"), 'parseRecursion' => false));
if ($Event = $res[0]) {
if ($Event['IS_MEETING']) {
// Try to find this user into attendees for this event
$strSql = "SELECT * FROM b_calendar_attendees WHERE USER_KEY={$userId} AND EVENT_ID={$eventId}";
$dbAtt = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($att = $dbAtt->Fetch()) {
//Set params
$strSql = "UPDATE b_calendar_attendees SET " . $DB->PrepareUpdate("b_calendar_attendees", $arFields) . " WHERE EVENT_ID=" . $eventId . " AND USER_KEY=" . $userId;
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
}
}
CCalendar::ClearCache('attendees_list');
return true;
}
示例3: UpdateReminders
function UpdateReminders($Params = array())
{
$eventId = intVal($Params['id']);
$reminders = $Params['reminders'];
$arFields = $Params['arFields'];
$userId = $Params['userId'];
$bNew = $Params['bNew'];
$path = $Params['path'];
$path = CHTTP::urlDeleteParams($path, array("action", "sessid", "bx_event_calendar_request", "EVENT_ID"));
$viewPath = CHTTP::urlAddParams($path, array('EVENT_ID' => $eventId));
$remAgentParams = array('eventId' => $eventId, 'userId' => $arFields["CREATED_BY"], 'viewPath' => $viewPath, 'calendarType' => $arFields["CAL_TYPE"], 'ownerId' => $arFields["OWNER_ID"]);
// 1. clean reminders
if (!$bNew) {
// if we edit event here can be "old" reminders
CCalendar::RemoveAgent($remAgentParams);
}
// 2. Set new reminders
$startTs = $arFields['DATE_FROM_TS_UTC'];
// Start of the event in UTC
$agentTime = 0;
foreach ($reminders as $reminder) {
$delta = intVal($reminder['count']) * 60;
//Minute
if ($reminder['type'] == 'hour') {
$delta = $delta * 60;
} elseif ($reminder['type'] == 'day') {
$delta = $delta * 60 * 24;
}
//Day
// $startTs - UTC timestamp; date('Z', $startTs) - offset of the server
$agentTime = $startTs + date('Z', $startTs);
if ($agentTime - $delta >= time() - 60 * 5) {
CCalendar::AddAgent(CCalendar::Date($agentTime - $delta), $remAgentParams);
} elseif ($arFields['RRULE'] != '') {
$arEvents = CCalendarEvent::GetList(array('arFilter' => array("ID" => $eventId, "DELETED" => "N", "FROM_LIMIT" => CCalendar::Date(time() - 3600, false), "TO_LIMIT" => CCalendar::GetMaxDate()), 'userId' => $userId, 'parseRecursion' => true, 'maxInstanceCount' => 2, 'preciseLimits' => true, 'fetchAttendees' => true, 'checkPermissions' => false, 'setDefaultLimit' => false));
if ($arEvents && is_array($arEvents[0])) {
$nextEvent = $arEvents[0];
$startTs = CCalendar::Timestamp($nextEvent['DATE_FROM'], false, $arEvents[0]["DT_SKIP_TIME"] !== 'Y');
if ($nextEvent["DT_SKIP_TIME"] == 'N' && $nextEvent["TZ_FROM"]) {
$startTs = $startTs - CCalendar::GetTimezoneOffset($nextEvent["TZ_FROM"], $startTs);
// UTC timestamp
}
if ($startTs + date("Z", $startTs) < time() - 60 * 5 && $arEvents[1]) {
$nextEvent = $arEvents[1];
}
$startTs = CCalendar::Timestamp($nextEvent['DATE_FROM'], false, $arEvents[0]["DT_SKIP_TIME"] !== 'Y');
if ($nextEvent["DT_SKIP_TIME"] == 'N' && $nextEvent["TZ_FROM"]) {
$startTs = $startTs - CCalendar::GetTimezoneOffset($nextEvent["TZ_FROM"], $startTs);
// UTC timestamp
}
$reminder = $nextEvent['REMIND'][0];
if ($reminder) {
$delta = intVal($reminder['count']) * 60;
//Minute
if ($reminder['type'] == 'hour') {
$delta = $delta * 60;
} elseif ($reminder['type'] == 'day') {
$delta = $delta * 60 * 24;
}
//Day
// $startTs - UTC timestamp; date("Z", $startTs) - offset of the server
$agentTime = $startTs + date("Z", $startTs);
if ($agentTime - $delta >= time() - 60 * 5) {
// Inaccuracy - 5 min
CCalendar::AddAgent(CCalendar::Date($agentTime - $delta), $remAgentParams);
}
}
}
}
}
}