public function __construct() { $timeNow = time(); //test $checkOffset = new \DateTime(date('d.m.Y', $timeNow), new \DateTimeZone(self::$tz)); $calcSumWin = $checkOffset->getOffset(); $this->nowTime = strtotime(date('d.m.Y H:i', $timeNow)) + $calcSumWin; if (\OC::$server->getSession()->get('public_link_token')) { $linkItem = \OCP\Share::getShareByToken(\OC::$server->getSession()->get('public_link_token', false)); if (is_array($linkItem) && isset($linkItem['uid_owner'])) { if ($linkItem['item_type'] === App::SHARECALENDAR) { $sPrefix = App::SHARECALENDARPREFIX; } if ($linkItem['item_type'] === App::SHAREEVENT) { $sPrefix = App::SHAREEVENTPREFIX; } if ($linkItem['item_type'] === App::SHARETODO) { $sPrefix = App::SHARETODOPREFIX; } $itemSource = App::validateItemSource($linkItem['item_source'], $sPrefix); $rootLinkItem = Calendar::find($itemSource); $this->aCalendars[] = $rootLinkItem; } } else { if (\OCP\User::isLoggedIn()) { $this->aCalendars = Calendar::allCalendars(\OCP\User::getUser()); $this->checkAlarm(); } } }
/** * Returns a list of ACE's for this node. * * Each ACE has the following properties: * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are * currently the only supported privileges * * 'principal', a url to the principal who owns the node * * 'protected' (optional), indicating that this ACE is not allowed to * be updated. * * @return array */ public function getACL() { $readprincipal = $this->getOwner(); $writeprincipal = $this->getOwner(); $uid = CalendarCalendar::extractUserID($this->getOwner()); $calendar = CalendarApp::getCalendar($this->calendarInfo['id'], false, false); if ($uid === \OCP\USER::getUser() && (bool) $calendar['issubscribe'] === true) { $readprincipal = 'principals/' . \OCP\USER::getUser(); $writeprincipal = ''; } if ($uid !== \OCP\USER::getUser()) { $sharedCalendar = \OCP\Share::getItemSharedWithBySource(CalendarApp::SHARECALENDAR, CalendarApp::SHARECALENDARPREFIX . $this->calendarInfo['id']); if ($sharedCalendar && $sharedCalendar['permissions'] & \OCP\PERMISSION_READ) { $readprincipal = 'principals/' . \OCP\USER::getUser(); $writeprincipal = ''; } if ($sharedCalendar && $sharedCalendar['permissions'] & \OCP\PERMISSION_UPDATE) { $readprincipal = 'principals/' . \OCP\USER::getUser(); $writeprincipal = 'principals/' . \OCP\USER::getUser(); } } $acl = array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => $writeprincipal . '/calendar-proxy-write', 'protected' => true), array('privilege' => '{DAV:}read', 'principal' => $readprincipal . '/calendar-proxy-read', 'protected' => true), array('privilege' => '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}read-free-busy', 'principal' => '{DAV:}authenticated', 'protected' => true)); if (empty($this->calendarInfo['{http://sabredav.org/ns}read-only'])) { $acl[] = ['privilege' => '{DAV:}write', 'principal' => $writeprincipal, 'protected' => true]; $acl[] = ['privilege' => '{DAV:}write', 'principal' => $writeprincipal . '/calendar-proxy-write', 'protected' => true]; } return $acl; }
public function formatItems($items, $format, $parameters = null) { $vtodos = array(); if ($format === self::FORMAT_TODO) { $user_timezone = CalendarApp::getTimezone(); foreach ($items as $item) { $item['item_source'] = CalendarApp::validateItemSource($item['item_source'], CalendarApp::SHARETODOPREFIX); if (!TasksApp::checkSharedTodo($item['item_source'])) { $event = TasksApp::getEventObject($item['item_source']); $vcalendar = VObject::parse($event['calendardata']); $vtodo = $vcalendar->VTODO; $accessclass = $vtodo->getAsString('CLASS'); if ($accessclass == '' || $accessclass == 'PUBLIC') { $permissions['permissions'] = $item['permissions']; $permissions['calendarcolor'] = '#cccccc'; $permissions['isOnlySharedTodo'] = true; $permissions['calendarowner'] = Object::getowner($item['item_source']); $permissions['displayname'] = $item['uid_owner']; //\OCP\Util::writeLog('calendar','Cal Owner :'.$permissions['calendarowner'].$vtodo -> getAsString('SUMMARY') ,\OCP\Util::DEBUG); $permissions['iscompleted'] = false; if ($vtodo->COMPLETED) { $permissions['iscompleted'] = true; $vtodos['done'][] = TasksApp::arrayForJSON($item['item_source'], $vtodo, $user_timezone, $permissions, $event); } else { $vtodos['open'][] = TasksApp::arrayForJSON($item['item_source'], $vtodo, $user_timezone, $permissions, $event); } } } //$vtodos[] = $vtodo; } } return $vtodos; }
public function formatItems($items, $format, $parameters = null) { $events = array(); if ($format == self::FORMAT_EVENT) { foreach ($items as $item) { $item['item_source'] = App::validateItemSource($item['item_source'], App::SHAREEVENTPREFIX); if (!Object::checkSharedEvent($item['item_source'])) { $event = Object::find($item['item_source']); $event['summary'] = $item['item_target']; $event['item_source'] = (int) $item['item_source']; $event['privat'] = false; $event['shared'] = false; $event['isalarm'] = $event['isalarm']; $event['permissions'] = $item['permissions']; //$event['userid'] = $event['userid']; $event['orgevent'] = false; $events[] = $event; } } } return $events; }
/** * @brief updates an VCalendar Object from the request data * @param array $request * @param object $vcalendar * @return object updated $vcalendar */ public static function updateVCalendarFromRequest($request, $vcalendar) { $accessclass = $request["accessclass"]; $title = $request["title"]; $location = $request["location"]; $categories = $request["categories"]; $allday = isset($request["allday"]); $link = $request["link"]; $from = $request["from"]; $to = $request["to"]; $checkDateFrom = strtotime($from); $checkWeekDay = date("D", $checkDateFrom); $weekDay = self::getWeeklyOptionsCheck($checkWeekDay); if (!$allday) { $fromtime = $request['fromtime']; $totime = $request['totime']; } $vevent = $vcalendar->VEVENT; /*REMINDER NEW*/ if ($request['reminder'] != 'none') { //$aTimeTransform=self::getReminderTimeParsingOptions(); if ($vevent->VALARM) { $valarm = $vevent->VALARM; } else { $valarm = new VObject('VALARM'); $vevent->add($valarm); } //sReminderRequest if ($request['reminder'] == 'OWNDEF' && ($request['reminderAdvanced'] == 'DISPLAY' || $request['reminderAdvanced'] == 'EMAIL')) { $valarm->setString('ATTENDEE', ''); if ($request['remindertimeselect'] !== 'ondate') { //$tTime=$aTimeTransform[$request['remindertimeselect']]['timehistory'].intval($request['remindertimeinput']).$aTimeTransform[$request['remindertimeselect']]['timedescr'] ; $valarm->setString('TRIGGER', $request['sReminderRequest']); } if ($request['remindertimeselect'] === 'ondate') { $temp = explode('TRIGGER;VALUE=DATE-TIME:', $request['sReminderRequest']); $datetime_element = new \Sabre\VObject\Property\ICalendar\DateTime(new \Sabre\VObject\Component\VCalendar(), 'TRIGGER'); $datetime_element->setDateTime(new \DateTime($temp[1]), false); $valarm->__set('TRIGGER', $datetime_element); $valarm->TRIGGER['VALUE'] = 'DATE-TIME'; } if ($request['reminderAdvanced'] == 'EMAIL') { //ATTENDEE:mailto:sebastian.doell@libasys.de $valarm->setString('ATTENDEE', 'mailto:' . $request['reminderemailinput']); } $valarm->setString('DESCRIPTION', 'owncloud'); $valarm->setString('ACTION', $request['reminderAdvanced']); } else { $valarm->setString('ATTENDEE', ''); $valarm->setString('TRIGGER', $request['reminder']); $valarm->setString('DESCRIPTION', 'owncloud'); $valarm->setString('ACTION', 'DISPLAY'); } } if ($request['reminder'] == 'none') { if ($vevent->VALARM) { $vevent->setString('VALARM', ''); } } /* $valarm = new VObject('VALARM'); $vevent->add($valarm); $valarm->addProperty('TRIGGER','-PT45M'); $valarm->addProperty('ACTION','DISPLAY'); $valarm->addProperty('DESCRIPTION','owncloud alarm');*/ //ORGANIZER;CN=email@email.com;EMAIL=email@email.com:MAILTO:email@email.com //$vevent->addProperty('ORGANIZER;CN='.$email.';EMAIL='.$email,'MAILTO:'.$email); //ATTENDEE;CN="Ryan Gr�nborg";CUTYPE=INDIVIDUAL;EMAIL="*****@*****.**";PARTSTAT=ACCEPTED:mailto:ryan@tv-glad.org //ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE; CN="Full Name":MAILTO:user@domain.com //ATTENDEE;CN="admin";CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:/oc50/remote.php/caldav/principals/admin/ //$vevent->addProperty('ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=admin','MAILTO:'.$email); //$vevent->addProperty('ATTENDEE;CN="admin";CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED','http://127.0.0.1/oc50/remote.php/caldav/principals/admin/'); //$vevent->addProperty('ATTENDEE;CN="sebastian";CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED','http://127.0.0.1/oc50/remote.php/caldav/principals/sebastian/'); $description = $request["description"]; $repeat = $request["repeat"]; $firstDayOfWeek = ';WKST=' . (\OCP\Config::getUserValue(\OCP\USER::getUser(), App::$appname, 'firstday', 'mo') == 'mo' ? 'MO' : 'SU'); if ($repeat != 'doesnotrepeat' && !array_key_exists('sRuleRequest', $request)) { $rrule = ''; $interval = $request['interval']; $end = $request['end']; $byoccurrences = $request['byoccurrences']; switch ($repeat) { case 'daily': $rrule .= 'FREQ=DAILY' . $firstDayOfWeek; break; case 'weekly': $rrule .= 'FREQ=WEEKLY' . $firstDayOfWeek; if (array_key_exists('rWeekday', $request)) { $rrule .= ';BYDAY=' . $request['rWeekday']; } break; case 'everymonth': $rrule .= 'FREQ=MONTHLY'; break; case 'everyyear': $rrule .= 'FREQ=YEARLY'; break; case 'everyweek': $rrule .= 'FREQ=WEEKLY'; break; case 'weekday': $rrule .= 'FREQ=WEEKLY' . $firstDayOfWeek; $rrule .= ';BYDAY=MO,TU,WE,TH,FR'; break; case 'biweekly': $rrule .= 'FREQ=WEEKLY' . $firstDayOfWeek; $interval = $interval * 2; break; case 'monthly': $rrule .= 'FREQ=MONTHLY' . $firstDayOfWeek; if ($request['advanced_month_select'] == 'monthday') { if (array_key_exists('rMonthday', $request)) { $rrule .= ';BYMONTHDAY=' . $request['rMonthday']; } } elseif ($request['advanced_month_select'] == 'weekday') { $rrule .= ';BYDAY=' . $request['rWeekday']; } break; case 'yearly': $rrule .= 'FREQ=YEARLY' . $firstDayOfWeek; if ($request['advanced_year_select'] == 'bydate') { } elseif ($request['advanced_year_select'] == 'byyearday') { list($_day, $_month, $_year) = explode('-', $from); $byyearday = date('z', mktime(0, 0, 0, $_month, $_day, $_year)) + 1; if (array_key_exists('byyearday', $request)) { foreach ($request['byyearday'] as $yearday) { $byyearday .= ',' . $yearday; } } $rrule .= ';BYYEARDAY=' . $byyearday; } elseif ($request['advanced_year_select'] == 'byweekno') { //Fix $days = array_flip(self::getWeeklyOptions(App::$l10n)); $byweekno = ''; foreach ($request['byweekno'] as $weekno) { if ($byweekno == '') { $byweekno = $weekno; } else { $byweekno .= ',' . $weekno; } } $rrule .= ';BYWEEKNO=' . $byweekno; $byday = ''; foreach ($request['weeklyoptions'] as $day) { if ($byday == '') { $byday .= $days[$day]; } else { $byday .= ',' . $days[$day]; } } $rrule .= ';BYDAY=' . $byday; } elseif ($request['advanced_year_select'] == 'bydaymonth') { //FIXED Removed Weekly Options if (array_key_exists('rMonth', $request)) { $rrule .= ';BYMONTH=' . $request['rMonth']; } if (array_key_exists('rMonthday', $request)) { $rrule .= ';BYMONTHDAY=' . $request['rMonthday']; } } break; default: break; } if ($interval != '') { $rrule .= ';INTERVAL=' . $interval; } if ($end == 'count') { $rrule .= ';COUNT=' . $byoccurrences; } if ($end == 'date') { list($bydate_day, $bydate_month, $bydate_year) = explode('-', $request['bydate']); $rrule .= ';UNTIL=' . $bydate_year . $bydate_month . $bydate_day; } $vevent->setString('RRULE', $rrule); $repeat = "true"; //\OCP\Util::writeLog('calendar','VTIMEZONE'.$vtimezone ->TZID, \OCP\Util::DEBUG); /**BEGIN:VTIMEZONE TZID:Europe/Berlin BEGIN:DAYLIGHT TZOFFSETFROM:+0100 RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU DTSTART:19810329T020000 TZNAME:MESZ TZOFFSETTO:+0200 END:DAYLIGHT BEGIN:STANDARD TZOFFSETFROM:+0200 RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU DTSTART:19961027T030000 TZNAME:MEZ TZOFFSETTO:+0100 END:STANDARD END:VTIMEZONE**/ } else { if (array_key_exists('sRuleRequest', $request)) { $end = $request['end']; $byoccurrences = $request['byoccurrences']; $rrule = $request['sRuleRequest']; if ($end == 'count') { $rrule .= ';COUNT=' . $byoccurrences; } if ($end == 'date') { list($bydate_day, $bydate_month, $bydate_year) = explode('-', $request['bydate']); $rrule .= ';UNTIL=' . $bydate_year . $bydate_month . $bydate_day; } $vevent->setString('RRULE', $rrule); $repeat = "true"; if (!$vcalendar->VTIMEZONE && $request['repeat'] != 'doesnotrepeat') { $tz = App::getTimezone(); $ex = explode('/', $tz, 2); $aTzTimes = App::getTzDaylightStandard(); if (isset($ex[1]) && array_key_exists($ex[0], $aTzTimes)) { $summerTime = $aTzTimes[$ex[0]]['daylight']; $winterTime = $aTzTimes[$ex[0]]['standard']; $dateOffsetSummer = new \DateTime($summerTime, new \DateTimeZone('UTC')); $dateOffsetSummer->setTimezone(new \DateTimeZone($tz)); $offsetSummer = $dateOffsetSummer->format('O'); $offsetSummerTZ = $dateOffsetSummer->format('T'); $dateOffsetWinter = new \DateTime($winterTime, new \DateTimeZone('UTC')); $dateOffsetWinter->setTimezone(new \DateTimeZone($tz)); $offsetWinter = $dateOffsetWinter->format('O'); $offsetWinterTZ = $dateOffsetWinter->format('T'); $vcalendar->add('VTIMEZONE', ['TZID' => $tz, 'DAYLIGHT' => ['TZOFFSETFROM' => $offsetWinter, 'RRULE' => 'FREQ=YEARLY;BYMONTH=' . $aTzTimes[$ex[0]]['daylightstart'] . ';BYDAY=-1SU', 'DTSTART' => $summerTime, 'TZNAME' => $offsetSummerTZ, 'TZOFFSETTO' => $offsetSummer], 'STANDARD' => ['TZOFFSETFROM' => $offsetSummer, 'RRULE' => 'FREQ=YEARLY;BYMONTH=' . $aTzTimes[$ex[0]]['daylightend'] . ';BYDAY=-1SU', 'DTSTART' => $winterTime, 'TZNAME' => $offsetWinterTZ, 'TZOFFSETTO' => $offsetWinter]]); } } } else { $repeat = "false"; } } if ($request["repeat"] == 'doesnotrepeat') { $vevent->setString('RRULE', ''); } $vevent->setDateTime('LAST-MODIFIED', 'now'); $vevent->setDateTime('DTSTAMP', 'now'); $vevent->setString('SUMMARY', $title); $oldStartTime = $vevent->DTSTART; // if($request["repeat"] == 'doesnotrepeat') { if ($allday) { $start = new \DateTime($from); $end = new \DateTime($to . ' +1 day'); $vevent->setDateTime('DTSTART', $start); $vevent->DTSTART['VALUE'] = 'DATE'; $vevent->setDateTime('DTEND', $end); $vevent->DTEND['VALUE'] = 'DATE'; } else { $timezone = App::getTimezone(); $timezone = new \DateTimeZone($timezone); $start = new \DateTime($from . ' ' . $fromtime, $timezone); $end = new \DateTime($to . ' ' . $totime, $timezone); $vevent->setDateTime('DTSTART', $start); $vevent->setDateTime('DTEND', $end); } //}else{ //} if ($vevent->EXDATE) { $calcStartOld = $oldStartTime->getDateTime()->format('U'); $calcStartNew = $start->format('U'); $timeDiff = $calcStartNew - $calcStartOld; if ($timeDiff != 0) { $delta = new \DateInterval('P0D'); $dMinutes = (int) ($timeDiff / 60); //$dTage=(int) ($dMinutes/(3600*24)); //$delta->d = $dTage; $delta->i = $dMinutes; \OCP\Util::writeLog(App::$appname, 'edit: ->' . $dMinutes, \OCP\Util::DEBUG); /* if ($allday) { $start_type = \Sabre\VObject\Property\DateTime::DATE; }else{ $start_type = \Sabre\VObject\Property\DateTime::LOCALTZ; } $calcStart=new \DateTime($oldStartTime); $aExt=$vevent->EXDATE; $vevent->setString('EXDATE',''); $timezone = App::getTimezone(); foreach($aExt as $param){ $dateTime = new \DateTime($param->getValue()); $datetime_element = new \Sabre\VObject\Property\DateTime('EXDATE'); $datetime_element -> setDateTime($dateTime->add($delta),$start_type); $vevent->addProperty('EXDATE;TZID='.$timezone,(string) $datetime_element); //$output.=$dateTime->format('Ymd\THis').':'.$datetime_element.'success'; }*/ } } unset($vevent->DURATION); $vevent->setString('CLASS', $accessclass); $vevent->setString('LOCATION', $location); $vevent->setString('DESCRIPTION', $description); $vevent->setString('CATEGORIES', $categories); $vevent->setString('URL', $link); /*if($repeat == "true") { $vevent->RRULE = $repeat; }*/ return $vcalendar; }
/** * @NoAdminRequired */ public function importEventsPerDrop() { $pCalid = $this->params('calid'); $pAddCal = $this->params('addCal'); $pAddCalCol = $this->params('addCalCol'); $data = $this->params('data'); $data = explode(',', $data); $data = end($data); $data = base64_decode($data); $import = new Import($data); $import->setUserID($this->userId); $import->setTimeZone(CalendarApp::$tz); $import->disableProgressCache(); if (!$import->isValid()) { $params = ['status' => 'error', 'error' => 'notvalid']; $response = new JSONResponse($params); return $response; } if ($pCalid == 'newCal' && $pAddCal != '') { $calendars = CalendarCalendar::allCalendars($this->userId); foreach ($calendars as $calendar) { if ($calendar['displayname'] == $pAddCal) { $id = $calendar['id']; $newcal = false; break; } $newcal = true; } if ($newcal) { $id = CalendarCalendar::addCalendar($this->userId, strip_tags($pAddCal), 'VEVENT,VTODO,VJOURNAL', null, 0, strip_tags($pAddCalCol)); CalendarCalendar::setCalendarActive($id, 1); } } else { $id = $pCalid; $calendar = CalendarApp::getCalendar($id); if ($calendar['userid'] != $this->userId) { $params = ['status' => 'error', 'error' => 'missingcalendarrights']; $response = new JSONResponse($params); return $response; } } $import->setOverwrite(false); $import->setCalendarID($id); $import->import(); $count = $import->getCount(); if ($count == 0) { CalendarCalendar::deleteCalendar($id); $params = ['status' => 'error', 'message' => $this->l10n->t('The file contained either no events or all events are already saved in your calendar.')]; $response = new JSONResponse($params); return $response; } else { $newcalendarname = strip_tags($pAddCal); if ($pAddCal != '') { $params = ['status' => 'success', 'message' => $count . ' ' . $this->l10n->t('events has been saved in the new calendar') . ' ' . $newcalendarname, 'eventSource' => CalendarCalendar::getEventSourceInfo(CalendarCalendar::find($id))]; $response = new JSONResponse($params); return $response; } else { $params = ['status' => 'success', 'message' => $count . ' ' . $this->l10n->t('events has been saved in the calendar') . ' ' . $calendar['displayname'], 'eventSource' => '']; $response = new JSONResponse($params); return $response; } } }
/** * * @param string $query * @return \OCP\Search\Result */ function search($query) { $today = date('Y-m-d', time()); $allowedCommands = array('#ra' => 1, '#dt' => 1); $calendars = Calendar::allCalendars(\OCP\USER::getUser(), true); $activeCalendars = ''; $config = \OC::$server->getConfig(); foreach ($calendars as $calendar) { $isAktiv = $calendar['active']; if ($config->getUserValue(\OCP\USER::getUser(), CalendarApp::$appname, 'calendar_' . $calendar['id']) != '') { $isAktiv = $config->getUserValue(\OCP\USER::getUser(), CalendarApp::$appname, 'calendar_' . $calendar['id']); } if (!array_key_exists('active', $calendar)) { $isAktiv = 1; } if ($isAktiv == 1 && (int) $calendar['issubscribe'] === 0) { $activeCalendars[] = $calendar; } } if (count($activeCalendars) == 0 || !\OCP\App::isEnabled(CalendarApp::$appname)) { //return false; } $results = array(); $searchquery = array(); if (substr_count($query, ' ') > 0) { $searchquery = explode(' ', $query); } else { $searchquery[] = $query; } $user_timezone = CalendarApp::getTimezone(); $l = \OC::$server->getL10N(TasksApp::$appname); $isDate = false; if (strlen($query) >= 5 && self::validateDate($query)) { $isDate = true; //\OCP\Util::writeLog('calendar','VALID DATE FOUND', \OCP\Util::DEBUG); } //foreach($calendars as $calendar) { $objects = TasksApp::all($activeCalendars); foreach ($objects as $object) { if ($object['objecttype'] != 'VTODO') { continue; } $searchAdvanced = false; if ($isDate == true && strlen($query) >= 5) { $tempQuery = strtotime($query); $checkDate = date('Y-m-d', $tempQuery); if (substr_count($object['startdate'], $checkDate) > 0 || substr_count($object['enddate'], $checkDate) > 0) { $searchAdvanced = true; } } if (array_key_exists($query, $allowedCommands) && $allowedCommands[$query]) { if ($query == '#dt') { $search = $object['startdate']; if (substr_count($search, $today) > 0) { $searchAdvanced = true; } } if ($query == '#ra') { if ($object['isalarm'] == 1) { $searchAdvanced = true; } } } if (substr_count(strtolower($object['summary']), strtolower($query)) > 0 || $searchAdvanced == true) { $calendardata = VObject::parse($object['calendardata']); $vtodo = $calendardata->VTODO; if (Object::getowner($object['id']) !== \OCP\USER::getUser()) { if (isset($vtodo->CLASS) && $vtodo->CLASS->getValue() === 'CONFIDENTIAL') { continue; } if (isset($vtodo->CLASS) && ($vtodo->CLASS->getValue() === 'PRIVATE' || $vtodo->CLASS->getValue() === '')) { continue; } } if ($vtodo->DUE) { $dtstart = $vtodo->DUE; $start_dt = $dtstart->getDateTime(); $start_dt->setTimezone(new \DateTimeZone($user_timezone)); if ($dtstart->getValueType() == 'DATE') { $info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y'); } else { $info = $l->t('Date') . ': ' . $start_dt->format('d.m.y H:i'); } } if ($vtodo->DTSTART) { $dtstart1 = $vtodo->DTSTART; $start_dt = $dtstart1->getDateTime(); $start_dt->setTimezone(new \DateTimeZone($user_timezone)); if ($dtstart1->getValueType() == 'DATE') { $info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y'); } else { $info = $l->t('Date') . ': ' . $start_dt->format('d.m.y H:i'); } } $link = \OC::$server->getURLGenerator()->linkToRoute(TasksApp::$appname . '.page.index') . '#' . urlencode($object['id']); $returnData['id'] = $object['id']; $returnData['description'] = $object['summary'] . ' ' . $info; $returnData['link'] = $link; $results[] = new Result($returnData); } } //} return $results; }
/** * @NoAdminRequired */ public function getUserSettingsCalendar() { $firstDayConfig = $this->configInfo->getUserValue($this->userId, $this->appName, 'firstday', 'mo'); $firstDay = $this->prepareFirstDay($firstDayConfig); $agendaTime = 'hh:mm tt { - hh:mm tt}'; $defaultTime = 'hh:mm tt'; $timeFormat = $this->configInfo->getUserValue($this->userId, $this->appName, 'timeformat', '24'); if ($timeFormat === '24') { $agendaTime = 'HH:mm { - HH:mm}'; $defaultTime = 'HH:mm { - HH:mm}'; } $dateFormat = $this->configInfo->getUserValue($this->userId, $this->appName, 'dateformat', 'd-m-Y'); $checkCat = CalendarApp::loadTags(); $checkCatTagsList = ''; $checkCatCategory = ''; foreach ($checkCat['categories'] as $category) { $checkCatCategory[] = $category; } foreach ($checkCat['tagslist'] as $tag) { $checkCatTagsList[$tag['name']] = array('id' => $tag['id'], 'name' => $tag['name'], 'color' => $tag['color'], 'bgcolor' => $tag['bgcolor']); } $eventSources = []; $calendars = CalendarCalendar::allCalendars($this->userId); $calendarInfo = []; $myCalendars = []; $myRefreshChecker = []; foreach ($calendars as $calendar) { $isAktiv = (int) $calendar['active']; if ($this->configInfo->getUserValue($this->userId, $this->appName, 'calendar_' . $calendar['id']) !== '') { $isAktiv = (int) $this->configInfo->getUserValue($this->userId, $this->appName, 'calendar_' . $calendar['id']); } if (!array_key_exists('active', $calendar)) { $isAktiv = 1; } if ($this->userId !== $calendar['userid']) { $calendar['uri'] = $calendar['uri'] . '_shared_by_' . $calendar['userid']; } $addClass = ''; if (isset($calendar['className'])) { $addClass = $calendar['className']; } $bgColor = ''; $textColor = ''; if (isset($calendar['calendarcolor'])) { $bgColor = $calendar['calendarcolor']; /*DEFAULT*/ $textColorDefault = CalendarCalendar::generateTextColor($bgColor); $textColor = $bgColor; } if (isset($calendar['textColor'])) { /*DEFAULT*/ $textColorDefault = $calendar['textColor']; $textColor = $bgColor; } $calendarInfo[$calendar['id']] = ['bgcolor' => $bgColor, 'color' => $textColorDefault, 'colorDefault' => $textColorDefault, 'name' => $calendar['displayname'], 'externuri' => $calendar['externuri'], 'uri' => $calendar['uri'], 'className' => $addClass]; if ((int) $isAktiv === 1) { $eventSources[] = CalendarCalendar::getEventSourceInfo($calendar); $myCalendars[$calendar['id']] = ['id' => $calendar['id'], 'name' => $calendar['displayname'], 'uri' => $calendar['uri'], 'issubscribe' => (int) $calendar['issubscribe'], 'permissions' => (int) $calendar['permissions']]; $myRefreshChecker[$calendar['id']] = $calendar['ctag']; } } $events_baseURL = \OC::$server->getURLGenerator()->linkToRoute($this->appName . '.event.getEvents'); $eventSources[] = array('url' => $events_baseURL . '?calendar_id=shared_events', 'className' => 'shared-events', 'editable' => 'false'); if ($this->configInfo->getUserValue($this->userId, $this->appName, 'userconfig')) { $userConfig = json_decode($this->configInfo->getUserValue($this->userId, $this->appName, 'userconfig')); } else { //Guest Config Public Page $userConfig = '{"agendaDay":"true","agendaThreeDays":"false","agendaWorkWeek":"false","agendaWeek":"true","month":"true","year":"false","list":"false"}'; $userConfig = json_decode($userConfig); } $leftNavAktiv = $this->configInfo->getUserValue($this->userId, $this->appName, 'calendarnav'); $rightNavAktiv = $this->configInfo->getUserValue($this->userId, $this->appName, 'tasknav'); $taskAppActive = \OC::$server->getAppManager()->isEnabledForUser('tasksplus'); $params = ['status' => 'success', 'defaultView' => $this->configInfo->getUserValue($this->userId, $this->appName, 'currentview', 'month'), 'agendatime' => $agendaTime, 'defaulttime' => $defaultTime, 'dateformat' => $dateFormat, 'timeformat' => $timeFormat, 'firstDay' => $firstDay, 'firstDayString' => $firstDayConfig, 'categories' => $checkCatCategory, 'tags' => $checkCatTagsList, 'eventSources' => $eventSources, 'calendarcolors' => $calendarInfo, 'mycalendars' => $myCalendars, 'myRefreshChecker' => $myRefreshChecker, 'choosenCalendar' => $this->configInfo->getUserValue($this->userId, $this->appName, 'choosencalendar'), 'userConfig' => $userConfig, 'sharetypeevent' => CalendarApp::SHAREEVENT, 'sharetypecalendar' => CalendarApp::SHARECALENDAR, 'leftnavAktiv' => $leftNavAktiv, 'rightnavAktiv' => $rightNavAktiv, 'taskAppActive' => $taskAppActive]; $response = new JSONResponse($params); return $response; }
* This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Affero General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ namespace OCA\CalendarPlus; use OCA\CalendarPlus\Calendar as CalendarCalendar; use OCA\CalendarPlus\Share\Backend\Event as ShareEvent; App::$appname = 'calendarplus'; App::$l10n = \OC::$server->getL10N('calendarplus'); App::$tz = App::getTimezone(); class App { const CALENDAR = 'calendar'; const EVENT = 'event'; const SHARECALENDAR = 'calpl'; const SHAREEVENT = 'calplevent'; const SHARECALENDARPREFIX = 'calendar-'; const SHAREEVENTPREFIX = 'event-'; const SHARETODO = 'calpltodo'; const SHARETODOPREFIX = 'todo-'; const CldObjectTable = '*PREFIX*clndrplus_objects'; const CldCalendarTable = '*PREFIX*clndrplus_calendars'; const CldRepeatTable = '*PREFIX*clndrplus_repeat'; /** * @brief language object for calendar app
public static function setComplete($vtodo, $percent_complete, $completed) { if (!empty($percent_complete)) { $vtodo->setString('PERCENT-COMPLETE', $percent_complete); } else { $vtodo->__unset('PERCENT-COMPLETE'); } if ($percent_complete === 100) { if (!$completed) { $completed = 'now'; } } else { $completed = null; } if ($completed) { $sTimezone = CalendarApp::getTimezone(); $timezone = new \DateTimeZone($sTimezone); $completed = new \DateTime($completed, $timezone); $vtodo->setDateTime('COMPLETED', $completed); \OCP\Util::emitHook('OC_Task', 'taskCompleted', $vtodo); } else { unset($vtodo->COMPLETED); } }
/** *@PublicPage * @NoCSRFRequired * @UseSession */ public function index($token) { if ($token) { $linkItem = Share::getShareByToken($token, false); if (is_array($linkItem) && isset($linkItem['uid_owner'])) { $type = $linkItem['item_type']; $itemSource = CalendarApp::validateItemSource($linkItem['item_source'], CalendarApp::SHARETODOPREFIX); $shareOwner = $linkItem['uid_owner']; $calendarName = $linkItem['item_target']; $rootLinkItem = \OCP\Share::resolveReShare($linkItem); // stupid copy and paste job if (isset($linkItem['share_with'])) { // Authenticate share_with $password = $this->params('password'); if (isset($password)) { if ($linkItem['share_type'] === \OCP\Share::SHARE_TYPE_LINK) { // Check Password $newHash = ''; if (\OC::$server->getHasher()->verify($password, $linkItem['share_with'], $newHash)) { $this->session->set('public_link_authenticated', $linkItem['id']); if (!empty($newHash)) { } } else { \OCP\Util::addStyle('files_sharing', 'authenticate'); $params = array('wrongpw' => true); return new TemplateResponse('files_sharing', 'authenticate', $params, 'guest'); } } else { \OCP\Util::writeLog('share', 'Unknown share type ' . $linkItem['share_type'] . ' for share id ' . $linkItem['id'], \OCP\Util::ERROR); return false; } } else { // Check if item id is set in session if (!$this->session->exists('public_link_authenticated') || $this->session->get('public_link_authenticated') !== $linkItem['id']) { // Prompt for password \OCP\Util::addStyle('files_sharing', 'authenticate'); $params = array(); return new TemplateResponse('files_sharing', 'authenticate', $params, 'guest'); } } } \OCP\Util::addStyle(CalendarApp::$appname, '3rdparty/fontello/css/animation'); \OCP\Util::addStyle(CalendarApp::$appname, '3rdparty/fontello/css/fontello'); \OCP\Util::addStyle($this->appName, 'style'); \OCP\Util::addStyle($this->appName, 'share'); \OCP\Util::addScript($this->appName, 'share'); $data = TasksApp::getEventObject($itemSource, false, false); $l = \OC::$server->getL10N($this->appName); $object = VObject::parse($data['calendardata']); $vTodo = $object->VTODO; $id = $data['id']; $object = Object::cleanByAccessClass($id, $object); $accessclass = $vTodo->getAsString('CLASS'); $permissions = TasksApp::getPermissions($id, TasksApp::TODO, $accessclass); if ($accessclass === 'PRIVATE') { header('HTTP/1.0 404 Not Found'); $response = new TemplateResponse('core', '404', '', 'guest'); return $response; } $categories = $vTodo->getAsArray('CATEGORIES'); $summary = strtr($vTodo->getAsString('SUMMARY'), array('\\,' => ',', '\\;' => ';')); $location = strtr($vTodo->getAsString('LOCATION'), array('\\,' => ',', '\\;' => ';')); $description = strtr($vTodo->getAsString('DESCRIPTION'), array('\\,' => ',', '\\;' => ';')); $priorityOptionsArray = TasksApp::getPriorityOptionsFilterd(); //$priorityOptions=$priorityOptionsArray[(string)$vTodo->priority]; $priorityOptions = 0; $link = strtr($vTodo->getAsString('URL'), array('\\,' => ',', '\\;' => ';')); $TaskDate = ''; $TaskTime = ''; if ($vTodo->DUE) { $dateDueType = $vTodo->DUE->getValueType(); if ($dateDueType == 'DATE') { $TaskDate = $vTodo->DUE->getDateTime()->format('d.m.Y'); $TaskTime = ''; } if ($dateDueType == 'DATE-TIME') { $TaskDate = $vTodo->DUE->getDateTime()->format('d.m.Y'); $TaskTime = $vTodo->DUE->getDateTime()->format('H:i'); } } $TaskStartTime = ''; $TaskStartDate = ''; if ($vTodo->DTSTART) { $dateStartType = $vTodo->DTSTART->getValueType(); if ($dateStartType === 'DATE') { $TaskStartDate = $vTodo->DTSTART->getDateTime()->format('d.m.Y'); $TaskStartTime = ''; } if ($dateStartType === 'DATE-TIME') { $TaskStartDate = $vTodo->DTSTART->getDateTime()->format('d.m.Y'); $TaskStartTime = $vTodo->DTSTART->getDateTime()->format('H:i'); } } //PERCENT-COMPLETE $cptlStatus = (string) $this->l10n->t('needs action'); $percentComplete = 0; if ($vTodo->{'PERCENT-COMPLETE'}) { $percentComplete = $vTodo->{'PERCENT-COMPLETE'}; //$cptlStatus = (string)$this->l10n->t('in procress'); if ($percentComplete === '0') { $cptlStatus = (string) $this->l10n->t('needs action'); } if ($percentComplete > '0' && $percentComplete < '100') { $cptlStatus = (string) $this->l10n->t('in procress'); } } if ($vTodo->{'COMPLETED'}) { $cptlStatus = (string) $this->l10n->t('completed'); } $timezone = \OC::$server->getSession()->get('public_link_timezone'); $sCat = ''; if (is_array($categories) && count($categories) > 0) { $sCat = $categories; } $params = ['eventid' => $itemSource, 'permissions' => $permissions, 'priorityOptions' => $priorityOptions, 'percentComplete' => $percentComplete, 'cptlStatus' => $cptlStatus, 'TaskDate' => isset($TaskDate) ? $TaskDate : '', 'TaskTime' => isset($TaskTime) ? $TaskTime : '', 'TaskStartDate' => isset($TaskStartDate) ? $TaskStartDate : '', 'TaskStartTime' => isset($TaskStartTime) ? $TaskStartTime : '', 'title' => $summary, 'accessclass' => $accessclass, 'location' => $location, 'categories' => $sCat, 'calendar' => $data['calendarid'], 'aCalendar' => CalendarApp::getCalendar($data['calendarid'], false, false), 'calAppName' => CalendarApp::$appname, 'description' => $description, 'repeat_rules' => '', 'link' => $link, 'timezone' => $timezone, 'uidOwner' => $shareOwner, 'displayName' => \OCP\User::getDisplayName($shareOwner), 'sharingToken' => $token, 'token' => $token]; $response = new TemplateResponse($this->appName, 'publicevent', $params, 'base'); return $response; } //end isset } //end token $tmpl = new \OCP\Template('', '404', 'guest'); $tmpl->printPage(); }
/** * @NoAdminRequired */ public function getDefaultValuesTasks() { $calendars = CalendarCalendar::allCalendars($this->userId); $myCalendars = array(); foreach ($calendars as $calendar) { if (!array_key_exists('active', $calendar)) { $calendar['active'] = 1; } if ($calendar['active'] == 1) { //$calendarInfo[$calendar['id']]=array('bgcolor'=>$calendar['calendarcolor'],'color'=>OCA\CalendarPlus\Calendar::generateTextColor($calendar['calendarcolor'])); $myCalendars[$calendar['id']] = array('id' => $calendar['id'], 'name' => $calendar['displayname'], 'uri' => $calendar['uri']); } } $checkCat = CalendarApp::loadTags(); $checkCatTagsList = ''; $checkCatCategory = ''; foreach ($checkCat['categories'] as $category) { $checkCatCategory[] = $category; } foreach ($checkCat['tagslist'] as $tag) { $checkCatTagsList[$tag['name']] = array('id' => $tag['id'], 'name' => $tag['name'], 'color' => $tag['color'], 'bgcolor' => $tag['bgcolor']); } $params = ['mycalendars' => $myCalendars, 'categories' => $checkCatCategory, 'tags' => $checkCatTagsList]; $response = new JSONResponse(); $response->setData($params); return $response; }
/** * @NoAdminRequired */ public function setCompletedTask() { $id = $this->params('id'); $checked = $this->params('checked'); $vcalendar = CalendarApp::getVCalendar($id); $vtodo = $vcalendar->VTODO; TasksApp::setComplete($vtodo, $checked ? 100 : 0, null); Object::edit($id, $vcalendar->serialize()); $user_timezone = CalendarApp::getTimezone(); $aTask = TasksApp::getEventObject($id, true, true); $aCalendar = CalendarCalendar::find($aTask['calendarid']); $task_info[] = TasksApp::arrayForJSON($id, $vtodo, $user_timezone, $aCalendar, $aTask); $subTaskIds = ''; if ($aTask['relatedto'] === '') { $subTaskIds = TasksApp::getSubTasks($aTask['eventuid']); if ($subTaskIds !== '') { $tempIds = explode(',', $subTaskIds); foreach ($tempIds as $subIds) { $vcalendar = TasksApp::getVCalendar($subIds, true, true); $vtodo = $vcalendar->VTODO; TasksApp::setComplete($vtodo, $checked ? 100 : 0, null); TasksApp::edit($subIds, $vcalendar->serialize()); $task_info[] = TasksApp::arrayForJSON($subIds, $vtodo, $user_timezone, $aCalendar, $aTask); } } } $params = ['status' => 'success', 'data' => $task_info]; $response = new JSONResponse($params); return $response; }
/** * @brief Converts the shared item sources back into the item in the specified format * @param array Shared items * @param int Format * @return ? * * The items array is a 3-dimensional array with the item_source as the first key and the share id as the second key to an array with the share info. * The key/value pairs included in the share info depend on the function originally called: * If called by getItem(s)Shared: id, item_type, item, item_source, share_type, share_with, permissions, stime, file_source * If called by getItem(s)SharedWith: id, item_type, item, item_source, item_target, share_type, share_with, permissions, stime, file_source, file_target * This function allows the backend to control the output of shared items with custom formats. * It is only called through calls to the public getItem(s)Shared(With) functions. */ public function formatItems($items, $format, $parameters = null) { $calendars = array(); if ($format == self::FORMAT_CALENDAR) { foreach ($items as $item) { $item['item_source'] = App::validateItemSource($item['item_source'], App::SHARECALENDARPREFIX); $calendar = App::getCalendar($item['item_source'], false); if (!$calendar) { continue; } // TODO: really check $parameters['permissions'] == 'rw'/'r' if ($parameters['permissions'] == 'rw') { continue; // TODO } $calendar['displayname'] = $item['item_target']; $calendar['permissions'] = $item['permissions']; $calendar['calendarid'] = $calendar['id']; $calendar['owner'] = $calendar['userid']; $calendar['active'] = (int) $calendar['active']; $calendars[] = $calendar; } } return $calendars; }
/** * @NoAdminRequired */ public function getUserSettingsCalendar() { $firstDayConfig = $this->configInfo->getUserValue($this->userId, $this->appName, 'firstday', 'mo'); $firstDay = $this->prepareFirstDay($firstDayConfig); $agendaTime = 'hh:mm tt { - hh:mm tt}'; $defaultTime = 'hh:mm tt'; if ($this->configInfo->getUserValue($this->userId, $this->appName, 'timeformat', '24') === '24') { $agendaTime = 'HH:mm { - HH:mm}'; $defaultTime = 'HH:mm'; } $checkCat = CalendarApp::loadTags(); $checkCatTagsList = ''; $checkCatCategory = ''; foreach ($checkCat['categories'] as $category) { $checkCatCategory[] = $category; } foreach ($checkCat['tagslist'] as $tag) { $checkCatTagsList[$tag['name']] = array('name' => $tag['name'], 'color' => $tag['color'], 'bgcolor' => $tag['bgcolor']); } $eventSources = []; $calendars = CalendarCalendar::allCalendars($this->userId); $calendarInfo = []; $myCalendars = []; $myRefreshChecker = []; foreach ($calendars as $calendar) { $isAktiv = $calendar['active']; if ($this->configInfo->getUserValue($this->userId, $this->appName, 'calendar_' . $calendar['id']) !== '') { $isAktiv = (int) $this->configInfo->getUserValue($this->userId, $this->appName, 'calendar_' . $calendar['id']); } if (!array_key_exists('active', $calendar)) { $isAktiv = 1; } if ((int) $isAktiv === 1) { $eventSources[] = CalendarCalendar::getEventSourceInfo($calendar); $calendarInfo[$calendar['id']] = ['bgcolor' => $calendar['calendarcolor'], 'color' => CalendarCalendar::generateTextColor($calendar['calendarcolor'])]; $myCalendars[$calendar['id']] = ['id' => $calendar['id'], 'name' => $calendar['displayname'], 'issubscribe' => (int) $calendar['issubscribe'], 'permissions' => (int) $calendar['permissions']]; $myRefreshChecker[$calendar['id']] = $calendar['ctag']; } } $events_baseURL = \OC::$server->getURLGenerator()->linkToRoute($this->appName . '.event.getEvents'); $eventSources[] = array('url' => $events_baseURL . '?calendar_id=shared_events', 'backgroundColor' => '#1D2D44', 'borderColor' => '#888', 'textColor' => 'white', 'editable' => 'false'); if ($this->configInfo->getUserValue($this->userId, $this->appName, 'userconfig')) { $userConfig = json_decode($this->configInfo->getUserValue($this->userId, $this->appName, 'userconfig')); } else { //Guest Config Public Page $userConfig = '{"agendaDay":"true","agendaThreeDays":"false","agendaWorkWeek":"false","agendaWeek":"true","month":"true","year":"false","list":"false"}'; $userConfig = json_decode($userConfig); } $params = ['status' => 'success', 'defaultView' => $this->configInfo->getUserValue($this->userId, $this->appName, 'currentview', 'month'), 'agendatime' => $agendaTime, 'defaulttime' => $defaultTime, 'firstDay' => $firstDay, 'categories' => $checkCatCategory, 'tags' => $checkCatTagsList, 'eventSources' => $eventSources, 'calendarcolors' => $calendarInfo, 'mycalendars' => $myCalendars, 'myRefreshChecker' => $myRefreshChecker, 'choosenCalendar' => $this->configInfo->getUserValue($this->userId, $this->appName, 'choosencalendar'), 'userConfig' => $userConfig, 'sharetypeevent' => CalendarApp::SHAREEVENT, 'sharetypecalendar' => CalendarApp::SHARECALENDAR]; $response = new JSONResponse($params); return $response; }
private function getPublicEvent($itemSource, $shareOwner, $token) { $itemSource = CalendarApp::validateItemSource($itemSource, CalendarApp::SHAREEVENTPREFIX); $data = CalendarApp::getEventObject($itemSource, false, false); $object = VObject::parse($data['calendardata']); $vevent = $object->VEVENT; $object = Object::cleanByAccessClass($itemSource, $object); $accessclass = $vevent->getAsString('CLASS'); if ($accessclass == 'PRIVATE') { header('HTTP/1.0 404 Not Found'); $response = new TemplateResponse('core', '404', '', 'guest'); return $response; } $permissions = CalendarApp::getPermissions($itemSource, CalendarApp::EVENT, $accessclass); $dtstart = $vevent->DTSTART; $dtend = Object::getDTEndFromVEvent($vevent); $dtstartType = $vevent->DTSTART->getValueType(); if ($dtstartType == 'DATE') { $startdate = $dtstart->getDateTime()->format('d-m-Y'); $starttime = ''; $enddate = $dtend->getDateTime()->modify('-1 day')->format('d-m-Y'); $endtime = ''; $choosenDate = $choosenDate + 3600 * 24; $allday = true; } if ($dtstartType == 'DATE-TIME') { $startdate = $dtstart->getDateTime()->format('d-m-Y'); $starttime = $dtstart->getDateTime()->format('H:i'); $enddate = $dtend->getDateTime()->format('d-m-Y'); $endtime = $dtend->getDateTime()->format('H:i'); $allday = false; } $summary = strtr($vevent->getAsString('SUMMARY'), array('\\,' => ',', '\\;' => ';')); $location = strtr($vevent->getAsString('LOCATION'), array('\\,' => ',', '\\;' => ';')); $categories = $vevent->getAsArray('CATEGORIES'); $description = strtr($vevent->getAsString('DESCRIPTION'), array('\\,' => ',', '\\;' => ';')); $link = strtr($vevent->getAsString('URL'), array('\\,' => ',', '\\;' => ';')); $last_modified = $vevent->__get('LAST-MODIFIED'); if ($last_modified) { $lastmodified = $last_modified->getDateTime()->format('U'); } else { $lastmodified = 0; } $repeatInfo = array(); $repeat['repeat'] = ''; if ($data['repeating'] == 1) { $rrule = explode(';', $vevent->getAsString('RRULE')); $rrulearr = array(); $repeat['repeat_rules'] = ''; foreach ($rrule as $rule) { list($attr, $val) = explode('=', $rule); if ($attr != 'COUNT' && $attr !== 'UNTIL') { if ($repeat['repeat_rules'] === '') { $repeat['repeat_rules'] = $attr . '=' . $val; } else { $repeat['repeat_rules'] .= ';' . $attr . '=' . $val; } } if ($attr === 'COUNT' || $attr !== 'UNTIL') { $rrulearr[$attr] = $val; } } if (array_key_exists('COUNT', $rrulearr)) { $repeat['end'] = 'count'; $repeat['count'] = $rrulearr['COUNT']; } elseif (array_key_exists('UNTIL', $rrulearr)) { $repeat['end'] = 'date'; $endbydate_day = substr($rrulearr['UNTIL'], 6, 2); $endbydate_month = substr($rrulearr['UNTIL'], 4, 2); $endbydate_year = substr($rrulearr['UNTIL'], 0, 4); $repeat['date'] = $endbydate_day . '-' . $endbydate_month . '-' . $endbydate_year; } else { $repeat['end'] = 'never'; } $repeat_end_options = CalendarApp::getEndOptions(); if ($repeat['end'] === 'count') { $repeatInfo['end'] = $this->l10n->t('after') . ' ' . $repeat['count'] . ' ' . $this->l10n->t('Events'); } if ($repeat['end'] === 'date') { $repeatInfo['end'] = $repeat['date']; } if ($repeat['end'] === 'never') { $repeatInfo['end'] = $repeat_end_options[$repeat['end']]; } } else { $repeat['repeat'] = 'doesnotrepeat'; } $calendar_options[0]['id'] = $data['calendarid']; $access_class_options = CalendarApp::getAccessClassOptions(); $aOExdate = ''; if ($vevent->EXDATE) { $timezone = CalendarApp::getTimezone(); foreach ($vevent->EXDATE as $param) { $param = new \DateTime($param); $aOExdate[$param->format('U')] = $param->format('d-m-Y'); } } $timezone = \OC::$server->getSession()->get('public_link_timezone'); $sCat = ''; if (is_array($categories) && count($categories) > 0) { $sCat = $categories; } $params = ['eventid' => $itemSource, 'appname' => $this->appName, 'permissions' => $permissions, 'lastmodified' => $lastmodified, 'exDate' => $aOExdate, 'sharingToken' => $token, 'token' => $token, 'calendar_options' => $calendar_options, 'access_class_options' => $access_class_options, 'title' => $summary, 'accessclass' => $accessclass, 'location' => $location, 'calendar' => $data['calendarid'], 'timezone' => $timezone, 'uidOwner' => $shareOwner, 'displayName' => \OCP\User::getDisplayName($shareOwner), 'allday' => $allday, 'startdate' => $startdate, 'starttime' => $starttime, 'enddate' => $enddate, 'endtime' => $endtime, 'description' => $description, 'link' => $link, 'repeat_rules' => isset($repeat['repeat_rules']) ? $repeat['repeat_rules'] : '', 'repeat' => $repeat['repeat'], 'repeatInfo' => $repeat['repeat'] != 'doesnotrepeat' ? $repeatInfo : '', 'categories' => $sCat]; $response = new TemplateResponse($this->appName, 'publicevent', $params, 'base'); return $response; }
/** *@PublicPage * @NoCSRFRequired * */ public function exportEvents() { $token = $this->params('t'); $calid = null; $eventid = null; if (isset($token)) { $linkItem = \OCP\Share::getShareByToken($token, false); if (is_array($linkItem) && isset($linkItem['uid_owner'])) { $rootLinkItem = \OCP\Share::resolveReShare($linkItem); if (isset($rootLinkItem['uid_owner'])) { \OCP\JSON::checkUserExists($rootLinkItem['uid_owner']); if ($linkItem['item_type'] === CalendarApp::SHARECALENDAR) { $sPrefix = CalendarApp::SHARECALENDARPREFIX; } if ($linkItem['item_type'] === CalendarApp::SHAREEVENT) { $sPrefix = CalendarApp::SHAREEVENTPREFIX; } if ($linkItem['item_type'] === CalendarApp::SHARETODO) { $sPrefix = CalendarApp::SHARETODOPREFIX; } $itemSource = CalendarApp::validateItemSource($linkItem['item_source'], $sPrefix); if ($linkItem['item_type'] === CalendarApp::SHARECALENDAR) { $calid = $itemSource; } if ($linkItem['item_type'] === CalendarApp::SHAREEVENT || $linkItem['item_type'] === CalendarApp::SHARETODO) { $eventid = $itemSource; } } } } else { if (\OCP\User::isLoggedIn()) { $calid = $this->params('calid'); $eventid = $this->params('eventid'); } } if (!is_null($calid)) { //check shared calendar also $calendar = CalendarApp::getCalendar($calid, true, true); if (!$calendar) { $params = ['status' => 'error']; $response = new JSONResponse($params); return $response; } $name = str_replace(' ', '_', $calendar['displayname']) . '.ics'; $calendarEvents = Export::export($calid, Export::CALENDAR); $response = new DataDownloadResponse($calendarEvents, $name, 'text/calendar'); return $response; } if (!is_null($eventid)) { $data = CalendarApp::getEventObject($eventid, false); if (!$data) { $params = ['status' => 'error']; $response = new JSONResponse($params); return $response; } $name = str_replace(' ', '_', $data['summary']) . '.ics'; $singleEvent = Export::export($eventid, Export::EVENT); $response = new DataDownloadResponse($singleEvent, $name, 'text/calendar'); return $response; } }
private function getVobjectData($id, $choosenDate, $data) { $result = []; if (!$data) { return false; } $sDateFormat = $this->configInfo->getUserValue($this->userId, $this->appName, 'dateformat', 'd-m-Y'); $object = VObject::parse($data['calendardata']); $vevent = $object->VEVENT; $object = Object::cleanByAccessClass($id, $object); $result['accessclass'] = $vevent->getAsString('CLASS'); $result['permissions'] = CalendarApp::getPermissions($id, CalendarApp::EVENT, $result['accessclass']); $dtstart = $vevent->DTSTART; $result['dtstart'] = $dtstart; $dtend = Object::getDTEndFromVEvent($vevent); $dateStartType = (string) $vevent->DTSTART->getValueType(); if ($dateStartType === 'DATE') { $result['startdate'] = $dtstart->getDateTime()->format($sDateFormat); $result['starttime'] = ''; $result['enddate'] = $dtend->getDateTime()->modify('-1 day')->format($sDateFormat); $result['endtime'] = ''; $result['choosenDate'] = $choosenDate + 3600 * 24; $result['allday'] = true; } if ($dateStartType === 'DATE-TIME') { $tz = CalendarApp::getTimezone(); $start_dt = new \DateTime($data['startdate'], new \DateTimeZone('UTC')); $end_dt = new \DateTime($data['enddate'], new \DateTimeZone('UTC')); $start_dt->setTimezone(new \DateTimeZone($tz)); $end_dt->setTimezone(new \DateTimeZone($tz)); $result['startdate'] = $start_dt->format($sDateFormat); $result['starttime'] = $start_dt->format('H:i'); $result['enddate'] = $end_dt->format($sDateFormat); $result['endtime'] = $end_dt->format('H:i'); $result['allday'] = false; $result['choosenDate'] = $choosenDate; } $result['summary'] = strtr($vevent->getAsString('SUMMARY'), array('\\,' => ',', '\\;' => ';')); $result['location'] = strtr($vevent->getAsString('LOCATION'), array('\\,' => ',', '\\;' => ';')); $result['categories'] = $vevent->getAsString('CATEGORIES'); $result['description'] = strtr($vevent->getAsString('DESCRIPTION'), array('\\,' => ',', '\\;' => ';')); $result['link'] = strtr($vevent->getAsString('URL'), array('\\,' => ',', '\\;' => ';')); $last_modified = $vevent->__get('LAST-MODIFIED'); if ($last_modified) { $result['lastmodified'] = $last_modified->getDateTime()->format('U'); } else { $result['lastmodified'] = 0; } $result['addSingleDeleteButton'] = false; if ((int) $data['repeating'] === 1) { $result['addSingleDeleteButton'] = true; $rrule = explode(';', $vevent->getAsString('RRULE')); $result['rrule'] = $this->parseRrules($rrule); } else { $result['rrule']['repeat'] = 'doesnotrepeat'; } //NEW Reminder $result['reminder_options'] = CalendarApp::getReminderOptions(); $result['alarm'] = $this->parseValarm($vevent, $result['reminder_options']); return $result; }
/** * @NoAdminRequired */ public function touchCalendar() { $id = (int) $this->params('eventid'); $data = CalendarApp::getEventObject($id, false, false); $vcalendar = VObject::parse($data['calendardata']); $vevent = $vcalendar->VEVENT; $vevent->setDateTime('LAST-MODIFIED', 'now'); $vevent->setDateTime('DTSTAMP', 'now'); Object::edit($id, $vcalendar->serialize()); $params = ['status' => 'success']; $response = new JSONResponse($params); return $response; }
public function generateAddonCalendarTodo() { $today = strtotime($this->getToday()); $tomorrow = strtotime($this->getTommorow()); $beginnWeek = strtotime($this->getStartofTheWeek()); $endWeek = strtotime($this->getEndofTheWeek()); $taskOutput = ''; // foreach( $this->aCalendar as $cal ) { $calendar_tasks = App::all($this->aCalendar, true); $checkCat = CalendarApp::loadTags(); $checkCatCache = ''; foreach ($checkCat['tagslist'] as $catInfo) { // foreach($catInfo as $cat){ $checkCatCache[$catInfo['name']] = $catInfo['bgcolor']; // } } foreach ($calendar_tasks as $taskInfo) { $taskOutput = ''; if ($taskInfo['objecttype'] != 'VTODO') { continue; } $calId = (string) $taskInfo['calendarid']; $object = VObject::parse($taskInfo['calendardata']); $vtodo = $object->VTODO; $completed = $vtodo->COMPLETED; $accessclass = $vtodo->getAsString('CLASS'); $categories = $vtodo->getAsArray('CATEGORIES'); if ($this->aCalendar[$calId]['userid'] !== \OCP\USER::getUser()) { if ($accessclass != '' && $accessclass != 'PUBLIC') { continue; } } if (!$completed) { $due = $vtodo->DUE; $dtstart = $vtodo->DTSTART; $Summary = '<span class="description"><a href="' . \OC::$server->getURLGenerator()->linkToRoute(App::$appname . '.page.index') . '#' . $taskInfo['id'] . '">' . $vtodo->getAsString('SUMMARY') . '</a></span>'; $addPrivateImg = ' '; if ($accessclass != '' && $accessclass === 'PRIVATE') { $addPrivateImg = '<i class="ioc ioc-lock" title="private"></i>'; } if ($accessclass != '' && $accessclass === 'CONFIDENTIAL') { $addPrivateImg = '<i class="ioc ioc-eye" title="confidential"></i>'; } $prioOutput = ''; if (isset($vtodo->PRIORITY)) { $prio = $vtodo->getAsString('PRIORITY'); if ($prio >= 1 && $prio < 5) { $prioOutput = '<i class="ioc ioc-info-circled priority-' . ($prio ? $prio : 'n') . '" title="' . (string) self::$l10n->t('priority %s ', array((string) self::$l10n->t('high'))) . '"></i>'; } elseif ($prio == 5) { $prioOutput = '<i class="ioc ioc-info-circled priority-' . ($prio ? $prio : 'n') . '" title="' . (string) self::$l10n->t('priority %s ', array((string) self::$l10n->t('medium'))) . '"></i>'; } elseif ($prio >= 6 && $prio <= 9) { $prioOutput = '<i class="ioc ioc-info-circled priority-' . ($prio ? $prio : 'n') . '" title="' . (string) self::$l10n->t('priority %s ', array((string) self::$l10n->t('low'))) . '"></i>'; } } $addShareImg = ''; if ($taskInfo['shared']) { $addShareImg = '<i class="ioc ioc-share" title="shared"></i>'; } $addAlarmImg = ''; if ($taskInfo['isalarm']) { $addAlarmImg = '<i class="ioc ioc-clock" title="reminder"></i>'; } $addCats = ''; if (is_array($categories)) { foreach ($categories as $catInfo) { $bgColor = '#ccc'; if (array_key_exists(trim($catInfo), $checkCatCache)) { $bgColor = $checkCatCache[trim($catInfo)]; } $addCats .= '<span class="catColPrev" style="float:right;padding:0;margin:0;margin-right:1px;margin-top:4px;line-height:12px;font-size:8px;width:12px;height:12px;background-color:' . $bgColor . '" title="' . $catInfo . '">' . substr(trim($catInfo), 0, 1) . '</span>'; } } $dateTask = '<span class="addImagesNoDate">' . $prioOutput . $addPrivateImg . $addAlarmImg . $addShareImg . '</span>' . $addCats . $Summary; if ($due != '') { $dateTask = $due->getDateTime()->format('d.m.Y H:i') . $addCats . '<br /><span class="addImages">' . $prioOutput . $addPrivateImg . $addAlarmImg . $addShareImg . '</span>' . $Summary; } if ($dtstart != '') { $dateTask = $dtstart->getDateTime()->format('d.m.Y H:i') . $addCats . '<br /><span class="addImages">' . $prioOutput . $addPrivateImg . $addAlarmImg . $addShareImg . '</span>' . $Summary; } //categories $taskOutput .= '<li class="taskListRow" data-taskid="' . $taskInfo['id'] . '"> <span class="colorCal" style="margin-top:6px;background-color:' . $this->aCalendar[$taskInfo['calendarid']]['calendarcolor'] . ';"> </span> <input class="inputTasksRow regular-checkbox" type="checkbox" id="task-val-' . $taskInfo['id'] . '" /><label style="float:left;margin-right:5px;" for="task-val-' . $taskInfo['id'] . '"></label> ' . $dateTask . ' </li>'; $bToday = false; $bTommorow = false; $bActWeek = false; $bMissed = false; $bCommingSoon = false; if ($dtstart) { $dtstartTmp = $dtstart->getDateTime()->format('d.m.Y'); $dtstart = strtotime($dtstartTmp); if ($dtstart == $today) { $this->taskOutPutbyTime['today'] .= $taskOutput; $bToday = true; } if ($dtstart == $tomorrow) { $this->taskOutPutbyTime['tomorrow'] .= $taskOutput; $bTommorow = true; } $bActWeek = false; if ($dtstart >= $beginnWeek && $dtstart <= $endWeek && !$bToday) { $this->taskOutPutbyTime['week'] .= $taskOutput; $bActWeek = true; } $bMissed = false; if ($dtstart < $today) { $this->taskOutPutbyTime['missed'] .= $taskOutput; $bMissed = true; } $bCommingSoon = false; if ($dtstart > $endWeek) { $this->taskOutPutbyTime['commingsoon'] .= $taskOutput; $bCommingSoon = true; } } if ($due) { $dueTmp = $due->getDateTime()->format('d.m.Y'); $due = strtotime($dueTmp); $bCheck = false; if ($due == $today && !$bToday) { $this->taskOutPutbyTime['today'] .= $taskOutput; $bCheck = true; } if ($due == $tomorrow && !$bTommorow) { $this->taskOutPutbyTime['tomorrow'] .= $taskOutput; $bCheck = true; } if ($due >= $beginnWeek && $due <= $endWeek && !$bCheck && !$bActWeek) { $this->taskOutPutbyTime['week'] .= $taskOutput; } if ($due < $today && !$bMissed) { $this->taskOutPutbyTime['missed'] .= $taskOutput; } if ($due > $endWeek && !$bCommingSoon) { $this->taskOutPutbyTime['commingsoon'] .= $taskOutput; } } if (!$dtstart && !$due) { //OhneTermin $this->taskOutPutbyTime['notermin'] .= $taskOutput; } } } //} return $this->taskOutPutbyTime; }