/** * 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; }
/** * @NoAdminRequired *@param integer $calendarid */ public function refreshSubscribedCalendar($calendarid) { $calendar = CalendarApp::getCalendar($calendarid, false, false); if (!$calendar) { $params = ['status' => 'error', 'message' => 'permission denied']; $response = new JSONResponse($params); return $response; } if ($calendar['uri'] !== 'bdaycpltocal_' . $calendar['userid']) { $getProtocol = explode('://', $calendar['externuri']); $protocol = $getProtocol[0]; $opts = array($protocol => array('method' => 'POST', 'header' => "Content-Type: text/calendar\r\n", 'timeout' => 60)); $aMeta = $this->stream_last_modified(trim($calendar['externuri'])); if ($aMeta['fileaccess'] === true) { $context = stream_context_create($opts); $file = file_get_contents($calendar['externuri'], false, $context); $file = \Sabre\VObject\StringUtil::convertToUTF8($file); $import = new Import($file); $import->setUserID($this->userId); $import->setTimeZone(CalendarApp::$tz); $import->setOverwrite(true); //$import -> setCheckModifiedDate(true); $import->setImportFromUri(true); $import->setCalendarID($calendarid); try { $import->import(); $importCount = $import->getCountImport(); $params = ['status' => 'success', 'refresh' => $calendarid, 'count' => $importCount]; $response = new JSONResponse($params); return $response; } catch (Exception $e) { $params = ['status' => 'error', 'message' => (string) $this->l10n->t('Import failed')]; $response = new JSONResponse($params); return $response; } } else { $params = ['status' => 'error', 'message' => (string) $this->l10n->t('Import failed')]; $response = new JSONResponse($params); return $response; } } else { $this->addBirthdays($this->userId, (int) $calendarid); $params = ['status' => 'success', 'refresh' => $calendarid]; $response = new JSONResponse($params); return $response; } }
/** * @NoAdminRequired */ public function refreshSubscribedCalendar() { $calendarid = (int) $this->params('calendarid'); $calendar = CalendarApp::getCalendar($calendarid, false, false); if (!$calendar) { $params = ['status' => 'error', 'message' => 'permission denied']; $response = new JSONResponse($params); return $response; } $getProtocol = explode('://', $calendar['externuri']); $protocol = $getProtocol[0]; $opts = array($protocol => array('method' => 'POST', 'header' => "Content-Type: text/calendar\r\n", 'timeout' => 60)); $last_modified = $this->stream_last_modified(trim($calendar['externuri'])); if (!is_null($last_modified)) { $context = stream_context_create($opts); $file = file_get_contents($calendar['externuri'], false, $context); $file = \Sabre\VObject\StringUtil::convertToUTF8($file); $import = new Import($file); $import->setUserID($this->userId); $import->setTimeZone(CalendarApp::$tz); $import->setOverwrite(true); $import->setCalendarID($calendarid); try { $import->import(); } catch (Exception $e) { $params = ['status' => 'error', 'message' => $this->l10n->t('Import failed')]; $response = new JSONResponse($params); return $response; } } $params = ['status' => 'success', 'refresh' => $calendarid]; $response = new JSONResponse($params); 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; } }
/** * @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; } } }
/** * @PublicPage * @NoCSRFRequired */ public function getShowEvent() { $id = $this->params('id'); $choosenDate = $this->params('choosendate'); if (\OCP\User::isLoggedIn()) { $sDateFormat = $this->configInfo->getUserValue($this->userId, $this->appName, 'dateformat', 'd-m-Y'); $sTimeFormat = $this->configInfo->getUserValue($this->userId, $this->appName, 'timeformat', '24'); if ($sTimeFormat == 24) { $sTimeFormatRead = 'H:i'; } else { $sTimeFormatRead = 'g:i a'; } if ($sDateFormat === 'd-m-Y') { $sDateFormat = 'd.m.Y'; } } else { if ($this->session->get('public_dateformat') != '') { $sDateFormat = $this->session->get('public_dateformat'); } else { $sDateFormat = 'd.m.Y'; } if ($this->session->get('public_timeformat') != '') { $sTimeFormatRead = $this->session->get('public_timeformat'); } else { $sTimeFormatRead = 'H:i'; } } $data = CalendarApp::getEventObject($id, false, false); if (!$data) { exit; } $object = VObject::parse($data['calendardata']); //FIXME Working with objectparser $vevent = $object->VEVENT; $object = Object::cleanByAccessClass($id, $object); $accessclass = $vevent->getAsString('CLASS'); $permissions = CalendarApp::getPermissions($id, CalendarApp::EVENT, $accessclass); $dtstart = $vevent->DTSTART; if (isset($choosenDate) && $choosenDate !== '') { $choosenDate = $choosenDate; } else { $choosenDate = $dtstart->getDateTime()->format('Ymd'); } $showdate = $dtstart->getDateTime()->format('Y-m-d H:i:s'); $organzier = ''; if ($vevent->ORGANIZER) { $organizerVal = $vevent->getAsString('ORGANIZER'); $temp = explode('mailto:', $organizerVal); $organzier = $temp[1]; } $attendees = ''; if ($vevent->ATTENDEE) { $attendees = array(); foreach ($vevent->ATTENDEE as $key => $param) { $temp1 = explode('mailto:', $param); $attendees[$key] = $temp1[1]; } } $dtend = Object::getDTEndFromVEvent($vevent); $dtstartType = (string) $vevent->DTSTART->getValueType(); $datetimedescr = ''; 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 ($startdate === $enddate) { $datetimedescr = (string) $this->l10n->t('On') . ' ' . $dtstart->getDateTime()->format($sDateFormat); } else { $datetimedescr = (string) $this->l10n->t('From') . ' ' . $dtstart->getDateTime()->format($sDateFormat) . ' ' . (string) $this->l10n->t('To') . ' ' . $dtend->getDateTime()->modify('-1 day')->format($sDateFormat); } } if ($dtstartType === '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)); $startdate = $start_dt->format('d-m-Y'); $starttime = $start_dt->format($sTimeFormatRead); $enddate = $end_dt->format('d-m-Y'); $endtime = $end_dt->format($sTimeFormatRead); if ($startdate === $enddate) { $datetimedescr = (string) $this->l10n->t('On') . ' ' . $start_dt->format($sDateFormat) . ' ' . (string) $this->l10n->t('From') . ' ' . $starttime . ' ' . (string) $this->l10n->t('To') . ' ' . $endtime; } else { $datetimedescr = (string) $this->l10n->t('From') . ' ' . $start_dt->format($sDateFormat) . ' ' . $starttime . ' ' . (string) $this->l10n->t('To') . ' ' . $end_dt->format($sDateFormat) . ' ' . $endtime; } $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('\\,' => ',', '\\;' => ';')); $categoriesOut = ''; if (is_array($categories)) { foreach ($categories as $category) { $bgColor = CalendarApp::genColorCodeFromText(trim($category), 80); $categoriesOut[] = array('name' => $category, 'bgcolor' => $bgColor, 'color' => CalendarApp::generateTextColor($bgColor)); } } $last_modified = $vevent->__get('LAST-MODIFIED'); if ($last_modified) { $lastmodified = $last_modified->getDateTime()->format('U'); } else { $lastmodified = 0; } $addSingleDeleteButton = false; $repeatInfo = array(); $repeat['repeat'] = ''; if ((int) $data['repeating'] === 1) { $addSingleDeleteButton = true; $rrule = explode(';', $vevent->getAsString('RRULE')); $rrulearr = array(); $repeat['repeat_rules'] = ''; foreach ($rrule as $rule) { list($attr, $val) = explode('=', $rule); if ((string) $attr !== 'COUNT' && (string) $attr !== 'UNTIL') { if ($repeat['repeat_rules'] === '') { $repeat['repeat_rules'] = $attr . '=' . $val; } else { $repeat['repeat_rules'] .= ';' . $attr . '=' . $val; } } if ((string) $attr === 'COUNT' || (string) $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); $rEnd_dt = new \DateTime($endbydate_day . '-' . $endbydate_month . '-' . $endbydate_year, new \DateTimeZone('UTC')); $repeat['date'] = $rEnd_dt->format($sDateFormat); //Switch it } 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'; } if ($permissions !== $this->shareConnector->getAllAccess()) { $calendar_options[0]['id'] = $data['calendarid']; } else { $calendar_options = CalendarCalendar::allCalendars($this->userId); } $checkCatCache = ''; if (\OCP\User::isLoggedIn()) { $category_options = CalendarApp::loadTags(); foreach ($category_options['tagslist'] as $catInfo) { $checkCatCache[$catInfo['name']] = $catInfo['bgcolor']; } } $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($sDateFormat); } } //NEW Reminder $reminder_options = CalendarApp::getReminderOptions(); $reminder_time_options = CalendarApp::getReminderTimeOptions(); //reminder $sAlarm = ''; $count = ''; if ($vevent->VALARM) { $valarm = ''; $sAlarm = ''; $counter = 0; foreach ($vevent->getComponents() as $param) { if ($param->name === 'VALARM') { $attr = $param->children(); foreach ($attr as $attrInfo) { $valarm[$counter][$attrInfo->name] = $attrInfo->getValue(); } $counter++; } } foreach ($valarm as $vInfo) { if ($vInfo['ACTION'] === 'DISPLAY' && strstr($vInfo['TRIGGER'], 'P')) { if (substr_count($vInfo['TRIGGER'], 'PT') === 1 && !stristr($vInfo['TRIGGER'], 'TRIGGER')) { $sAlarm[] = 'TRIGGER:' . $vInfo['TRIGGER']; } if (substr_count($vInfo['TRIGGER'], 'PT') === 1 && stristr($vInfo['TRIGGER'], 'TRIGGER')) { $sAlarm[] = $vInfo['TRIGGER']; } if (substr_count($vInfo['TRIGGER'], '-P') === 1 && substr_count($vInfo['TRIGGER'], 'PT') === 0) { $temp = explode('-P', (string) $vInfo['TRIGGER']); $sAlarm[] = 'TRIGGER:-PT' . $temp[1]; } if (substr_count($vInfo['TRIGGER'], '+P') === 1 && substr_count($vInfo['TRIGGER'], 'PT') === 0) { $temp = explode('+P', $vInfo['TRIGGER']); $sAlarm[] = 'TRIGGER:+PT' . $temp[1]; } } if ($vInfo['ACTION'] === 'DISPLAY' && !strstr($vInfo['TRIGGER'], 'P')) { if (!strstr($vInfo['TRIGGER'], 'DATE-TIME')) { $sAlarm[] = 'TRIGGER;VALUE=DATE-TIME:' . $vInfo['TRIGGER']; } else { $sAlarm[] = $vInfo['TRIGGER']; } } } } if ($permissions & $this->shareConnector->getReadAccess()) { $bShareOnlyEvent = 0; if (Object::checkShareEventMode($id)) { $bShareOnlyEvent = 1; } $pCategoriesCol = ''; $pCategories = ''; if (is_array($categoriesOut) && count($categoriesOut) > 0) { $pCategoriesCol = $checkCatCache; $pCategories = $categoriesOut; } $pRepeatInfo = ''; if ($repeat['repeat'] !== 'doesnotrepeat') { $pRepeatInfo = $repeatInfo; } $aCalendar = CalendarApp::getCalendar($data['calendarid'], false, false); $isBirthday = false; if ($aCalendar['uri'] === 'bdaycpltocal_' . $aCalendar['userid']) { $isBirthday = true; } $params = ['bShareOnlyEvent' => $bShareOnlyEvent, 'eventid' => $id, 'appname' => $this->appName, 'permissions' => $permissions, 'lastmodified' => $lastmodified, 'exDate' => $aOExdate, 'isBirthday' => $isBirthday, 'calendar_options' => $calendar_options, 'access_class_options' => $access_class_options, 'sReminderTrigger' => $sAlarm, 'cValarm' => $count, 'isShareApi' => $this->appConfig->getValue('core', 'shareapi_enabled', 'yes'), 'mailNotificationEnabled' => $this->appConfig->getValue('core', 'shareapi_allow_mail_notification', 'yes'), 'allowShareWithLink' => $this->appConfig->getValue('core', 'shareapi_allow_links', 'yes'), 'mailPublicNotificationEnabled' => $this->appConfig->getValue('core', 'shareapi_allow_public_notification', 'no'), 'title' => $summary, 'accessclass' => $accessclass, 'location' => $location, 'categoriesCol' => $pCategoriesCol, 'categories' => $pCategories, 'aCalendar' => $aCalendar, 'allday' => $allday, 'startdate' => $startdate, 'starttime' => $starttime, 'enddate' => $enddate, 'endtime' => $endtime, 'datetimedescr' => $datetimedescr, 'description' => $description, 'link' => $link, 'organzier' => $organzier, 'attendees' => $attendees, 'addSingleDeleteButton' => $addSingleDeleteButton, 'choosendate' => $choosenDate, 'showdate' => $showdate, 'repeat' => $repeat['repeat'], 'repeat_rules' => isset($repeat['repeat_rules']) ? $repeat['repeat_rules'] : '', 'repeatInfo' => $pRepeatInfo, 'sharetypeevent' => $this->shareConnector->getConstShareEvent(), 'sharetypeeventprefix' => $this->shareConnector->getConstSharePrefixEvent()]; $response = new TemplateResponse($this->appName, 'part.showevent', $params, ''); return $response; } }
/** *@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(); }
/** * @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; }
/** * @PublicPage * @NoCSRFRequired */ public function getEventsPublic() { $token = $this->params('t'); $pStart = $this->params('start'); $pEnd = $this->params('end'); $calendar_id = null; \OC::$server->getSession()->close(); if (isset($token)) { $linkItem = $this->shareConnector->getShareByToken($token); if (is_array($linkItem) && isset($linkItem['uid_owner'])) { $rootLinkItem = $this->shareConnector->resolveReShare($linkItem); if (isset($rootLinkItem['uid_owner'])) { \OCP\JSON::checkUserExists($rootLinkItem['uid_owner']); $calendar_id = $this->shareConnector->validateItemSource($linkItem['item_source'], $this->shareConnector->getConstSharePrefixCalendar()); } } } $start = new \DateTime('@' . $pStart); $end = new \DateTime('@' . $pEnd); $aCalendar = CalendarApp::getCalendar($calendar_id, false, false); $isBirthday = false; if ($aCalendar['uri'] === 'bdaycpltocal_' . $aCalendar['userid']) { $isBirthday = true; } $events = CalendarApp::getrequestedEvents($calendar_id, $start, $end); $output = array(); foreach ($events as $event) { $event['bday'] = 0; if ($isBirthday === true) { $event['bday'] = 1; } $eventArray = $this->eventController->generateEventOutput($event, $start, $end); if (is_array($eventArray)) { $output = array_merge($output, $eventArray); } } $response = new JSONResponse(); $response->setData($output); return $response; }