mirror of https://github.com/nextcloud/calendar
save current work state
This commit is contained in:
parent
1d35efb94c
commit
824f1831bc
|
@ -19,7 +19,7 @@ $app->registerCron();
|
|||
$app->registerHooks();
|
||||
$app->registerProviders();
|
||||
|
||||
\OCA\Calendar\Sabre\VObject\Component\VCalendar::$valueMap['DATE-TIME'] = 'SabreProperty\DateTime';
|
||||
/*\OCA\Calendar\Sabre\VObject\Component\VCalendar::$valueMap['DATE-TIME'] = 'SabreProperty\DateTime';
|
||||
\OCA\Calendar\Sabre\VObject\Component\VCalendar::$valueMap['DATE'] = 'SabreProperty\DateTime';
|
||||
|
||||
\OCA\Calendar\Sabre\VObject\Component\VCalendar::$propertyMap['COMPLETED'] = 'SabreProperty\DateTime';
|
||||
|
@ -32,4 +32,4 @@ $app->registerProviders();
|
|||
\OCA\Calendar\Sabre\VObject\Component\VCalendar::$propertyMap['CREATED'] = 'SabreProperty\DateTime';
|
||||
\OCA\Calendar\Sabre\VObject\Component\VCalendar::$propertyMap['DTSTAMP'] = 'SabreProperty\DateTime';
|
||||
\OCA\Calendar\Sabre\VObject\Component\VCalendar::$propertyMap['LAST-MODIFIED'] = 'SabreProperty\DateTime';
|
||||
\OCA\Calendar\Sabre\VObject\Component\VCalendar::$propertyMap['ACKNOWLEDGED'] = 'SabreProperty\DateTime';
|
||||
\OCA\Calendar\Sabre\VObject\Component\VCalendar::$propertyMap['ACKNOWLEDGED'] = 'SabreProperty\DateTime';*/
|
|
@ -41,6 +41,7 @@ $routes = array(
|
|||
'event' => array('url' => '/v1/calendars/{calendarId}/events'),
|
||||
'journal' => array('url' => '/v1/calendars/{calendarId}/journals'),
|
||||
'todo' => array('url' => '/v1/calendars/{calendarId}/todos'),
|
||||
'timezone' => array('url' => '/v1/timezones'),
|
||||
)
|
||||
);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -32,8 +32,6 @@ use \DateTime;
|
|||
|
||||
class Sharing extends Backend {
|
||||
|
||||
private $backend;
|
||||
|
||||
private static $crudsMapper = array(
|
||||
\OCP\PERMISSION_CREATE => Permissions::CREATE,
|
||||
\OCP\PERMISSION_READ => Permissions::READ,
|
||||
|
@ -43,72 +41,88 @@ class Sharing extends Backend {
|
|||
\OCP\PERMISSION_ALL => Permissions::ALL,
|
||||
);
|
||||
|
||||
public function __construct($api, $parameters, &$backendBusinessLayer){
|
||||
|
||||
public function __construct(IAppContainer $api, $parameters){
|
||||
parent::__construct($api, 'sharing');
|
||||
$this->backend = $backendBusinessLayer;
|
||||
}
|
||||
|
||||
|
||||
public function cacheObjects($calendarURI, $userId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function canBeEnabled() {
|
||||
return \OCP\Share::isEnabled();
|
||||
}
|
||||
|
||||
|
||||
public function findCalendar($calendarURI, $userId) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function findCalendars($userId, $limit, $offset) {
|
||||
$sharedCalendars = OCP\Share::getItemsSharedWith('calendar', OC_Share_Backend_Calendar::FORMAT_CALENDAR);
|
||||
$singleSharedEvents = null;
|
||||
$sharedCalendars = \OCP\Share::getItemsSharedWith('calendar', OC_Share_Backend_Calendar::FORMAT_CALENDAR);
|
||||
$singleSharedEvents = \OCP\Share::getItemsSharedWith('calendar', OC_Share_Backend_Calendar::FORMAT_EVENT);
|
||||
}
|
||||
|
||||
|
||||
public function updateCalendar(Calendar $calendar, $calendarId, $userId) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function deleteCalendar(Calendar $calendar) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function mergeCalendar(Calendar $calendar, $calendarId=null, $userId=null) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function findObject($calendarURI, $objectURI, $userId) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function findObjects($calendarId, $userId, $limit, $offset) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function findObjectsInPeriod($calendarId, $start, $end, $userId, $limit, $offset){
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function findObjectsByType($calendarId, $type, $userId, $limit, $offset) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function findObjectsByTypeInPeriod($calendarId, $type, $start, $end, $userId, $limit, $offset) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function createObject(Object $object, $userId) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function updateObject(Object $object, $calendarId, $uri, $userId) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function deleteObject(Object $object){
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function searchByProperties($properties=array(), $calendarId=null, $userId=null) {
|
||||
|
||||
}
|
||||
|
|
|
@ -35,8 +35,6 @@ class ObjectController extends Controller {
|
|||
$userId = $this->api->getUserId();
|
||||
$calendarId = $this->params('calendarId');
|
||||
|
||||
$expand = $this->params('expand', false);
|
||||
|
||||
$nolimit = $this->params('nolimit', false);
|
||||
if($nolimit) {
|
||||
$limit = $offset = null;
|
||||
|
@ -50,8 +48,7 @@ class ObjectController extends Controller {
|
|||
return new Response(null, HTTP::STATUS_FORBIDDEN);
|
||||
}
|
||||
|
||||
$objectCollection = $this->objectBusinessLayer->findAll($calendar, $expand,
|
||||
$limit, $offset);
|
||||
$objectCollection = $this->objectBusinessLayer->findAll($calendar, $limit, $offset);
|
||||
|
||||
$serializer = new Serializer(Serializer::ObjectCollection, $objectCollection, $this->accept());
|
||||
|
||||
|
@ -81,7 +78,6 @@ class ObjectController extends Controller {
|
|||
$offset = $this->params('offset', 0);
|
||||
}
|
||||
|
||||
$expand = $this->params('expand', false);
|
||||
$start = $this->params('start', new DateTime(date('Y-m-01')));
|
||||
$end = $this->params('end', new DateTime(date('Y-m-t')));
|
||||
|
||||
|
@ -91,7 +87,7 @@ class ObjectController extends Controller {
|
|||
}
|
||||
|
||||
$objectCollection = $this->objectBusinessLayer->findAllInPeriod($calendar, $start, $end,
|
||||
$expand, $limit, $offset);
|
||||
$limit, $offset);
|
||||
|
||||
$serializer = new Serializer(Serializer::ObjectCollection, $objectCollection, $this->accept());
|
||||
|
||||
|
|
|
@ -76,7 +76,6 @@ abstract class ObjectTypeController extends ObjectController {
|
|||
$offset = $this->params('offset', 0);
|
||||
}
|
||||
|
||||
$expand = $this->params('expand', false);
|
||||
$start = $this->params('start');
|
||||
$end = $this->params('end');
|
||||
|
||||
|
@ -87,7 +86,7 @@ abstract class ObjectTypeController extends ObjectController {
|
|||
throw new ForbiddenExpcetion();
|
||||
}
|
||||
|
||||
$objectCollection = $this->objectBusinessLayer->findAllByType($calendar, $type, $expand,
|
||||
$objectCollection = $this->objectBusinessLayer->findAllByType($calendar, $type,
|
||||
$limit, $offset);
|
||||
|
||||
$serializer = new Serializer(Serializer::ObjectCollection, $objectCollection, $this->accept());
|
||||
|
@ -116,7 +115,6 @@ abstract class ObjectTypeController extends ObjectController {
|
|||
$offset = $this->params('offset', 0);
|
||||
}
|
||||
|
||||
$expand = $this->params('expand', false);
|
||||
$start = $this->params('start', new DateTime(date('Y-m-01')));
|
||||
$end = $this->params('end', new DateTime(date('Y-m-t')));
|
||||
|
||||
|
@ -128,7 +126,7 @@ abstract class ObjectTypeController extends ObjectController {
|
|||
}
|
||||
|
||||
$objectCollection = $this->objectBusinessLayer->findAllByTypeInPeriod($calendar, $type, $start, $end,
|
||||
$expand, $limit, $offset);
|
||||
$limit, $offset);
|
||||
|
||||
$serializer = new Serializer(Serializer::ObjectCollection, $objectCollection, $this->accept());
|
||||
|
||||
|
|
|
@ -12,6 +12,10 @@ use \OCP\AppFramework\Http;
|
|||
use \OCA\Calendar\Db\DoesNotExistException;
|
||||
use \OCA\Calendar\BusinessLayer\BusinessLayerException;
|
||||
|
||||
use \OCA\Calendar\Db\Subscription;
|
||||
use \OCA\Calendar\Db\SubscriptionCollection;
|
||||
use \OCA\Calendar\Db\SubscriptionMapper;
|
||||
|
||||
use \OCA\Calendar\Http\Response;
|
||||
|
||||
use \OCA\Calendar\Http\Reader;
|
||||
|
@ -22,32 +26,80 @@ use \OCA\Calendar\Http\SerializerException;
|
|||
class SubscriptionController extends Controller {
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* timezone mapper
|
||||
* @var \OCA\Calendar\Db\SubscriptionMapper
|
||||
*/
|
||||
public function index() {}
|
||||
private $subscriptionMapper;
|
||||
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param IAppContainer $app interface to the app
|
||||
* @param IRequest $request an instance of the request
|
||||
*/
|
||||
public function __construct(IAppContainer $app, IRequest $request,
|
||||
SubscriptionMapper $subscriptionMapper){
|
||||
parent::__construct($app, $request);
|
||||
|
||||
$this->subscriptionMapper = $subscriptionMapper;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function show() {}
|
||||
public function index() {
|
||||
$userId = $this->api->getUserId();
|
||||
$nolimit = $this->params('nolimit', false);
|
||||
if($nolimit) {
|
||||
$limit = $offset = null;
|
||||
} else {
|
||||
$limit = $this->params('limit', 25);
|
||||
$offset = $this->params('offset', 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function create() {}
|
||||
public function show() {
|
||||
try {
|
||||
$userId = $this->api->getUserId();
|
||||
|
||||
|
||||
return new Response($serializer);
|
||||
} catch (DoesNotExistException $ex) {
|
||||
return new Response(null, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function update() {}
|
||||
public function create() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function destroy() {}
|
||||
public function update() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function destroy() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2014 Georg Ehrke <oc.list@georgehrke.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
namespace OCA\Calendar\Controller;
|
||||
|
||||
use \OCP\AppFramework\Http;
|
||||
|
||||
use \OCP\AppFramework\IAppContainer;
|
||||
use \OCP\IRequest;
|
||||
|
||||
use \OCA\Calendar\Db\DoesNotExistException;
|
||||
|
||||
use \OCA\Calendar\Db\Timezone;
|
||||
use \OCA\Calendar\Db\TimezoneCollection;
|
||||
use \OCA\Calendar\Db\TimezoneMapper;
|
||||
|
||||
use \OCA\Calendar\Http\Response;
|
||||
|
||||
use \OCA\Calendar\Http\Reader;
|
||||
use \OCA\Calendar\Http\Serializer;
|
||||
use \OCA\Calendar\Http\ReaderExpcetion;
|
||||
use \OCA\Calendar\Http\SerializerException;
|
||||
|
||||
class TimezoneController extends Controller {
|
||||
|
||||
/**
|
||||
* timezone mapper
|
||||
* @var \OCA\Calendar\Db\TimezoneMapper
|
||||
*/
|
||||
private $timezoneMapper;
|
||||
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* @param IAppContainer $app interface to the app
|
||||
* @param IRequest $request an instance of the request
|
||||
*/
|
||||
public function __construct(IAppContainer $app, IRequest $request,
|
||||
TimezoneMapper $timezoneMapper){
|
||||
parent::__construct($app, $request);
|
||||
|
||||
$this->timezoneMapper = $timezoneMapper;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function index() {
|
||||
$nolimit = $this->params('nolimit', false);
|
||||
if($nolimit) {
|
||||
$limit = $offset = null;
|
||||
} else {
|
||||
$limit = $this->params('limit', 25);
|
||||
$offset = $this->params('offset', 0);
|
||||
}
|
||||
|
||||
$timezoneCollection = $this->timezoneMapper->findAll($limit, $offset);
|
||||
|
||||
$serializer = new Serializer(Serializer::TimezoneCollection, $timezoneCollection, $this->accept());
|
||||
return new Response($serializer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function show() {
|
||||
try {
|
||||
$tzId = str_replace('-', '/', $this->params('timezoneId'));
|
||||
|
||||
$timezone = $this->timezoneMapper->find($tzId);
|
||||
|
||||
$serializer = new Serializer(Serializer::Timezone, $timezone, $this->accept());
|
||||
return new Response($serializer);
|
||||
} catch (DoesNotExistException $ex) {
|
||||
return new Response(null, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function create() {
|
||||
return new Response(null, Http::STATUS_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function update() {
|
||||
return new Response(null, Http::STATUS_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function destroy() {
|
||||
return new Response(null, Http::STATUS_NOT_IMPLEMENTED);
|
||||
}
|
||||
}
|
|
@ -254,7 +254,7 @@ abstract class Collection {
|
|||
if($child instanceof VEvent ||
|
||||
$child instanceof VJournal ||
|
||||
$child instanceof VTodo ||
|
||||
$child instanceof VTimezone) {
|
||||
$child->name === 'VTIMEZONE') {
|
||||
$vObject->add($child);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2014 Georg Ehrke <oc.list@georgehrke.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
namespace OCA\Calendar\Db;
|
||||
|
||||
class CorruptDataException extends \Exception {}
|
|
@ -8,24 +8,30 @@
|
|||
namespace OCA\Calendar\Db;
|
||||
|
||||
use \OCA\Calendar\Sabre\VObject\Component\VCalendar;
|
||||
use \OCA\Calendar\Sabre\VObject\Reader;
|
||||
use \OCA\Calendar\Sabre\VObject\ParseException;
|
||||
use \OCA\Calendar\Sabre\VObject\EofException;
|
||||
|
||||
use \OCA\Calendar\Utility\Utility;
|
||||
|
||||
class Timezone extends Entity {
|
||||
|
||||
protected $timezone;
|
||||
public $tzId;
|
||||
public $vobject;
|
||||
|
||||
/**
|
||||
* @brief init Timezone object with timezone name
|
||||
* @param string $timezone
|
||||
*/
|
||||
public function __construct($timezone='UTC') {
|
||||
if(Utility::isTimezoneSupported($timezone)) {
|
||||
$this->timezone = new \DateTimeZone($timezone);
|
||||
} else {
|
||||
public function __construct($tzId, $tzData) {
|
||||
$this->addType('tzId', 'string');
|
||||
$this->addType('tzData', 'string');
|
||||
|
||||
$msg = '';
|
||||
throw new /* some */Exception($msg);
|
||||
if(!is_null($tzId)) {
|
||||
$this->setTzId($tzId);
|
||||
}
|
||||
if(!is_null($tzData)) {
|
||||
$this->setTzData($tzData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,9 +41,23 @@ class Timezone extends Entity {
|
|||
* @return boolean
|
||||
*/
|
||||
public function isValid() {
|
||||
return true;
|
||||
$strings = array('tzId', 'tzData');
|
||||
foreach($strings as $string) {
|
||||
if(is_null($this->$string)) {
|
||||
return false;
|
||||
}
|
||||
if($this->$string === '') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setTzData($data) {
|
||||
$tzData = "BEGIN:VCALENDAR\n";
|
||||
$tzData .= $data;
|
||||
$tzData .= "END:VCALENDAR";
|
||||
$this->vobject = Reader::read($tzData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief take data from VObject and put into this Timezone object
|
||||
|
@ -45,7 +65,14 @@ class Timezone extends Entity {
|
|||
* @return $this
|
||||
*/
|
||||
public function fromVObject(VCalendar $vcalendar) {
|
||||
//TODO implement
|
||||
if(!isset($vcalendar->{'VTIMEZONE'})) {
|
||||
throw new DoesNotExistException('no vtimezones found');
|
||||
}
|
||||
if(is_array($vcalendar->{'VTIMEZONE'})) {
|
||||
throw new MultipleObjectsReturnedException('multiple vtimezones found');
|
||||
}
|
||||
$this->vobject = $vcalendar;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,11 +81,11 @@ class Timezone extends Entity {
|
|||
* @return \Sabre\VObject\Component\VCalendar object
|
||||
*/
|
||||
public function getVObject() {
|
||||
//TODO implement
|
||||
return $this->vobject;
|
||||
}
|
||||
|
||||
|
||||
public function __toString() {
|
||||
return $this->timezone->getName();
|
||||
return $this->tzId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2014 Georg Ehrke <oc.list@georgehrke.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
namespace OCA\Calendar\Db;
|
||||
|
||||
use \OCP\AppFramework\IAppContainer;
|
||||
|
||||
use \OCA\Calendar\Db\Timezone;
|
||||
use \OCA\Calendar\Db\TimezoneCollection;
|
||||
|
||||
class TimezoneMapper extends Mapper {
|
||||
|
||||
private $folderName;
|
||||
private $fileBlacklist;
|
||||
|
||||
/**
|
||||
* @param API $api: Instance of the API abstraction layer
|
||||
* @param string $folderName
|
||||
*/
|
||||
public function __construct(IAppContainer $app, $folderName='/../timezones/'){
|
||||
$this->app = $app;
|
||||
$this->folderName = __DIR__ . $folderName;
|
||||
|
||||
$this->fileBlacklist = array('.', '..', 'INFO.md');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief find a timezone
|
||||
* @param string $tzId
|
||||
* @return \OCA\Calendar\Db\Timezone
|
||||
*/
|
||||
public function find($tzId) {
|
||||
$tzIdName = strtoupper(str_replace('/', '-', $tzId));
|
||||
$path = $this->folderName . $tzIdName . '.ics';
|
||||
|
||||
/**throw DoesNotExistException when:
|
||||
* - [x] $tzId is info.md (info.md shouldn't be packaged in the first place) or
|
||||
* - [x] $tzId is not a valid filename or
|
||||
* - [x] file inside /../timezones/ does not exist
|
||||
*/
|
||||
if(strtolower($tzId) === 'info.md' ||
|
||||
!\OCP\Util::isValidFileName($tzIdName) ||
|
||||
!file_exists($path)) {
|
||||
throw new DoesNotExistException();
|
||||
}
|
||||
|
||||
$data = file_get_contents($path);
|
||||
|
||||
return new Timezone($tzId, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief find all timezones
|
||||
* @param integer $limit
|
||||
* @param integer $offset
|
||||
* @return \OCA\Calendar\Db\TimezoneCollection
|
||||
*/
|
||||
public function findAll($limit, $offset) {
|
||||
$tzFiles = scandir($this->folderName);
|
||||
$files = array_values(array_diff($tzFiles, $this->fileBlacklist));
|
||||
|
||||
if(is_null($limit)) {
|
||||
$limit = (count($files) - 1);
|
||||
}
|
||||
if(is_null($offset)) {
|
||||
$offset = 0;
|
||||
}
|
||||
|
||||
$collection = new TimezoneCollection();
|
||||
for($i = $offset; $i < ($offset + $limit); $i++) {
|
||||
$tzId = str_replace('-', '/', str_replace('.ics', '', $files[$i]));
|
||||
$data = file_get_contents($this->folderName . $files[$i]);
|
||||
$timezone = new Timezone($tzId, $data);
|
||||
$collection->add($timezone);
|
||||
}
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
|
||||
public function delete(Entity $entity){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public function insert(Entity $entity){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public function update(Entity $entity){
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -30,11 +30,6 @@ class JSONObject extends JSON {
|
|||
*/
|
||||
public function serialize($convenience=true) {
|
||||
$vcalendar = $this->object->getVObject();
|
||||
|
||||
if($convenience === true) {
|
||||
JSONUtility::addConvenience($vcalendar);
|
||||
}
|
||||
|
||||
return $vcalendar->jsonSerialize();
|
||||
}
|
||||
}
|
|
@ -35,10 +35,6 @@ class JSONObjectCollection extends JSONCollection {
|
|||
|
||||
$vcalendar = $this->object->getVObject();
|
||||
|
||||
if($convenience === true) {
|
||||
//JSONUtility::addConvenience($vcalendar);
|
||||
}
|
||||
|
||||
return $vcalendar->jsonSerialize();
|
||||
}
|
||||
}
|
|
@ -7,4 +7,4 @@
|
|||
*/
|
||||
namespace OCA\Calendar\Http\JSON;
|
||||
|
||||
class JSONTimezoneCollection extends JSONTimezone {}
|
||||
class JSONTimezoneCollection extends JSONObjectCollection {}
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2014 Georg Ehrke <oc.list@georgehrke.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
namespace OCA\Calendar\Http\JSON;
|
||||
|
||||
use OCA\Calendar\Db\Object;
|
||||
use OCA\Calendar\Db\ObjectCollection;
|
||||
|
||||
class JSONTimezoneReader {
|
||||
|
||||
/**
|
||||
* @brief parse json object
|
||||
*/
|
||||
public function parse() {
|
||||
try {
|
||||
$data = $this->getData();
|
||||
|
||||
$vcalendar = Reader::readJson($data);
|
||||
$numberTimezones = SabreUtility::countTimezones($vcalendar);
|
||||
$isCollection = ($numberTimezones > 1);
|
||||
|
||||
if($isCollection) {
|
||||
$object = new TimezoneCollection($vcalendar);
|
||||
} else {
|
||||
$object = new Timezone($vcalendar);
|
||||
}
|
||||
|
||||
$this->setObject($object);
|
||||
|
||||
return $this;
|
||||
} catch(/* some */Exception $e) {
|
||||
throw new JSONObjectReaderException($ex->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -78,5 +78,4 @@ Reader::set(Reader::Timezone, 'OCA\\Calendar\\Http\\JSON\\JSONTimezoneReader', '
|
|||
Reader::set(Reader::Timezone, 'OCA\\Calendar\\Http\\JSON\\JSONTimezoneReader', 'application/calendar+json');
|
||||
|
||||
Reader::set(Reader::Calendar, 'OCA\\Calendar\\Http\\ICS\\ICSCalendarReader', 'text/calendar');
|
||||
Reader::set(Reader::Object, 'OCA\\Calendar\\Http\\ICS\\ICSObjectReader', 'text/calendar');
|
||||
Reader::set(Reader::Timezone, 'OCA\\Calendar\\Http\\ICS\\ICSTimezoneReader', 'text/calendar');
|
||||
Reader::set(Reader::Object, 'OCA\\Calendar\\Http\\ICS\\ICSObjectReader', 'text/calendar');
|
|
@ -102,7 +102,7 @@ class App extends \OCP\AppFramework\App {
|
|||
$req = $c->query('Request');
|
||||
$tmp = $c->query('TimezoneMapper');
|
||||
|
||||
return new ViewController($c, $req, $tmp);
|
||||
return new TimezoneController($c, $req, $tmp);
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
*/
|
||||
namespace OCA\Calendar\Utility;
|
||||
|
||||
use \OCA\Calendar\Db\Object;
|
||||
use \OCA\Calendar\Db\Timezone;
|
||||
use \OCA\Calendar\Db\TimezoneMapper;
|
||||
|
||||
class ObjectUtility extends Utility{
|
||||
|
||||
/**
|
||||
|
@ -21,4 +25,13 @@ class ObjectUtility extends Utility{
|
|||
return $substr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief add missing timezones to an object
|
||||
* @param \OCA\Calendar\Db\Object $object
|
||||
* @param \OCA\Calendar\Db\TimezoneMapper $tzMapper
|
||||
*/
|
||||
public static function addMissingVTimezones(Object &$object, TimezoneMapper &$tzMapper) {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue