Ejemplo n.º 1
0
 public static function CreateDefault($Params = array())
 {
     if ($Params['type'] == 'user' || $Params['type'] == 'group') {
         $name = CCalendar::GetOwnerName($Params['type'], $Params['ownerId']);
     } else {
         $name = GetMessage('EC_DEF_SECT_GROUP_CAL');
     }
     // if ($Params['type'] == 'user')
     // $name = GetMessage('EC_DEF_SECT_USER_CAL');
     // else
     // $name = GetMessage('EC_DEF_SECT_GROUP_CAL');
     $arFields = array('CAL_TYPE' => $Params['type'], 'NAME' => $name, 'DESCRIPTION' => GetMessage('EC_DEF_SECT_DESC'), 'COLOR' => CCalendar::Color(), 'OWNER_ID' => $Params['ownerId'], 'IS_EXCHANGE' => 0, 'ACCESS' => CCalendarSect::GetDefaultAccess($Params['type'], $Params['ownerId']), 'PERM' => array('view_time' => true, 'view_title' => true, 'view_full' => true, 'add' => true, 'edit' => true, 'edit_section' => true, 'access' => true));
     $arFields['ID'] = self::Edit(array('arFields' => $arFields));
     if ($arFields['ID'] > 0) {
         return $arFields;
     }
     return false;
 }
Ejemplo n.º 2
0
 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);
         }
     }
 }
Ejemplo n.º 3
0
        return ShowError(GetMessage('EC_USER_ID_NOT_FOUND'));
    }
    if ($arParams['CALENDAR_TYPE'] == "group" || $arParams['CALENDAR_TYPE'] == "user") {
        $feature = "calendar";
        $arEntityActiveFeatures = CSocNetFeatures::GetActiveFeaturesNames($arParams['CALENDAR_TYPE'] == "group" ? SONET_ENTITY_GROUP : SONET_ENTITY_USER, $arParams['OWNER_ID']);
        $strFeatureTitle = array_key_exists($feature, $arEntityActiveFeatures) && StrLen($arEntityActiveFeatures[$feature]) > 0 ? $arEntityActiveFeatures[$feature] : GetMessage("EC_SONET_CALENDAR");
        $arParams["STR_TITLE"] = $strFeatureTitle;
    } else {
        $arParams["STR_TITLE"] = GetMessage("EC_SONET_CALENDAR");
    }
}
$bOwner = $arParams["CALENDAR_TYPE"] == 'user' || $arParams["CALENDAR_TYPE"] == 'group';
if ($arParams["SET_TITLE"] == "Y" || $bOwner && $arParams["SET_NAV_CHAIN"] == "Y") {
    $ownerName = '';
    if ($bOwner) {
        $ownerName = CCalendar::GetOwnerName($arParams["CALENDAR_TYPE"], $arParams["OWNER_ID"]);
    }
    if ($arParams["SET_TITLE"] == "Y") {
        $title_short = empty($arParams["STR_TITLE"]) ? GetMessage("WD_TITLE") : $arParams["STR_TITLE"];
        $title = ($ownerName ? $ownerName . ': ' : '') . $title_short;
        if ($arParams["HIDE_OWNER_IN_TITLE"] == "Y") {
            $APPLICATION->SetPageProperty("title", $title);
            $APPLICATION->SetTitle($title_short);
        } else {
            $APPLICATION->SetTitle($title);
        }
    }
    if ($bOwner && $arParams["SET_NAV_CHAIN"] == "Y") {
        $set = CCalendar::GetSettings();
        if ($arParams["CALENDAR_TYPE"] == 'group') {
            $APPLICATION->AddChainItem($ownerName, CComponentEngine::MakePathFromTemplate($set['path_to_group'], array("group_id" => $arParams["OWNER_ID"])));