mirror of https://github.com/nextcloud/calendar
some fixes
This commit is contained in:
parent
518aade8bb
commit
0142da039b
|
@ -7,8 +7,6 @@
|
|||
*/
|
||||
namespace OCA\Calendar;
|
||||
|
||||
require_once(__DIR__ . '/../3rdparty/VObject/includes.php');
|
||||
|
||||
define('OCA\Calendar\JSON_API_VERSION', '1.0');
|
||||
define('OCA\Calendar\PHP_API_VERSION', '1.0');
|
||||
|
||||
|
@ -17,19 +15,4 @@ $app->registerNavigation();
|
|||
|
||||
$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'] = 'SabreProperty\DateTime';
|
||||
|
||||
\OCA\Calendar\Sabre\VObject\Component\VCalendar::$propertyMap['COMPLETED'] = 'SabreProperty\DateTime';
|
||||
\OCA\Calendar\Sabre\VObject\Component\VCalendar::$propertyMap['DTEND'] = 'SabreProperty\DateTime';
|
||||
\OCA\Calendar\Sabre\VObject\Component\VCalendar::$propertyMap['DUE'] = 'SabreProperty\DateTime';
|
||||
\OCA\Calendar\Sabre\VObject\Component\VCalendar::$propertyMap['DTSTART'] = 'SabreProperty\DateTime';
|
||||
|
||||
\OCA\Calendar\Sabre\VObject\Component\VCalendar::$propertyMap['RECURRENCE-ID'] = 'SabreProperty\DateTime';
|
||||
|
||||
\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';*/
|
||||
$app->registerProviders();
|
|
@ -7,10 +7,115 @@
|
|||
*/
|
||||
namespace OCA\Calendar\Backend;
|
||||
|
||||
use \OCA\Calendar\Db\Calendar;
|
||||
use \OCA\Calendar\Db\Object;
|
||||
use \OCA\Calendar\Db\ObjectType;
|
||||
use \OCP\AppFramework\IAppContainer;
|
||||
|
||||
use \OCA\Calendar\Db\DoesNotExistException;
|
||||
use \OCA\Calendar\Db\MultipleObjectsReturnedException;
|
||||
use \OCA\Calendar\Db\CorruptDataException;
|
||||
|
||||
use \OCA\Calendar\Db\Calendar;
|
||||
use \OCA\Calendar\Db\CalendarCollection;
|
||||
|
||||
use \OCA\Calendar\Db\Object;
|
||||
use \OCA\Calendar\Db\ObjectCollection;
|
||||
|
||||
use \OCA\Calendar\Db\Timezone;
|
||||
use \OCA\Calendar\Db\TimezoneCollection;
|
||||
|
||||
use \OCA\Calendar\Db\ObjectType;
|
||||
use \OCA\Calendar\Db\Permissions;
|
||||
|
||||
class CalDAV extends Backend {}
|
||||
use \OCA\Calendar\Utility\ObjectUtility;
|
||||
|
||||
use \DateTime;
|
||||
|
||||
class CalDAV extends Backend {
|
||||
|
||||
/**
|
||||
* subscription mapper
|
||||
* @var \OCA\Calendar\Db\SubscriptionMapper
|
||||
*/
|
||||
protected $subscriptionMapper;
|
||||
|
||||
|
||||
/**
|
||||
* @brief constructor
|
||||
* @param IAppContainer $app
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function __construct(IAppContainer $app, array $parameters){
|
||||
parent::__construct($app, 'CalDAV');
|
||||
|
||||
$this->subscriptionMapper = $app->query('SubscriptionMapper');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns information about calendar $calendarURI of the user $userId
|
||||
* @param string $calendarURI
|
||||
* @param string $userId
|
||||
* @returns array with \OCA\Calendar\Db\Calendar object
|
||||
* @throws DoesNotExistException if uri does not exist
|
||||
*/
|
||||
public function findCalendar($calendarURI, $userId) {
|
||||
return new Calendar();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns all calendars of the user $userId
|
||||
* @param string $userId
|
||||
* @returns \OCA\Calendar\Db\CalendarCollection
|
||||
* @throws DoesNotExistException if uri does not exist
|
||||
*/
|
||||
public function findCalendars($userId, $limit=null, $offset=null) {
|
||||
return new CalendarCollection();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns number of calendar
|
||||
* @param string $userid
|
||||
* @returns integer
|
||||
*/
|
||||
public function countCalendars($userId) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns whether or not a calendar exists
|
||||
* @param string $calendarURI
|
||||
* @param string $userid
|
||||
* @returns boolean
|
||||
*/
|
||||
public function doesCalendarExist($calendarURI, $userId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns information about the object (event/journal/todo) with the uid $objectURI in the calendar $calendarURI of the user $userId
|
||||
* @param string $calendarURI
|
||||
* @param string $objectURI
|
||||
* @param string $userid
|
||||
* @returns \OCA\Calendar\Db\Object object
|
||||
* @throws DoesNotExistException if calendar does not exist
|
||||
* @throws DoesNotExistException if object does not exist
|
||||
*/
|
||||
public function findObject(Calendar &$calendar, $objectURI) {
|
||||
throw new DoesNotExistException();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns all objects in the calendar $calendarURI of the user $userId
|
||||
* @param string $calendarURI
|
||||
* @param string $userId
|
||||
* @returns \OCA\Calendar\Db\ObjectCollection
|
||||
* @throws DoesNotExistException if calendar does not exist
|
||||
*/
|
||||
public function findObjects(Calendar &$calendar, $limit, $offset) {
|
||||
return new ObjectCollection();
|
||||
}
|
||||
}
|
|
@ -8,24 +8,39 @@
|
|||
*/
|
||||
namespace OCA\Calendar\Backend;
|
||||
|
||||
use \OCP\AppFramework\IAppContainer;
|
||||
|
||||
use \OCA\Calendar\Db\DoesNotExistException;
|
||||
use \OCA\Calendar\Db\MultipleObjectsReturnedException;
|
||||
use \OCA\Calendar\Db\CorruptDataException;
|
||||
|
||||
use \OCA\Calendar\Db\Calendar;
|
||||
use \OCA\Calendar\Db\CalendarCollection;
|
||||
|
||||
use \OCA\Calendar\Db\Object;
|
||||
use \OCA\Calendar\Db\ObjectCollection;
|
||||
|
||||
use \OCA\Calendar\Db\TimeZone;
|
||||
use \OCA\Calendar\Db\TimeZoneCollection;
|
||||
use \OCA\Calendar\Db\Timezone;
|
||||
use \OCA\Calendar\Db\TimezoneCollection;
|
||||
|
||||
use \OCA\Calendar\Db\ObjectType;
|
||||
use \OCA\Calendar\Db\Permissions;
|
||||
|
||||
use \OCA\Calendar\Utility\ObjectUtility;
|
||||
|
||||
use \DateTime;
|
||||
|
||||
class Contact extends Backend {
|
||||
|
||||
public $calendarURIs;
|
||||
|
||||
public function __construct($api, $parameters){
|
||||
parent::__construct($api, 'Contact');
|
||||
/**
|
||||
* @brief constructor
|
||||
* @param IAppContainer $app
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function __construct(IAppContainer $app, array $parameters){
|
||||
parent::__construct($app, 'Contact');
|
||||
|
||||
$this->calendarURIs = array(
|
||||
'anniversary',
|
||||
|
@ -33,39 +48,33 @@ class Contact extends Backend {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns whether or not a backend can be enabled
|
||||
* @returns boolean
|
||||
*
|
||||
* This method returns a boolean.
|
||||
* This method is mandatory!
|
||||
*/
|
||||
public function canBeEnabled() {
|
||||
return true;//return \OCP\App::isEnabled('contacts');
|
||||
return \OCP\App::isEnabled('contacts');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns whether or not calendar objects should be cached
|
||||
* @param string $calendarURI
|
||||
* @param string $userId
|
||||
* @returns boolean
|
||||
*
|
||||
* This method returns a boolen.
|
||||
* This method is mandatory!
|
||||
*/
|
||||
public function cacheObjects($uri, $userId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns information about calendar $calendarURI of the user $userId
|
||||
* @param string $calendarURI
|
||||
* @param string $userId
|
||||
* @returns array with \OCA\Calendar\Db\Calendar object
|
||||
* @throws DoesNotExistException if uri does not exist
|
||||
*
|
||||
* This method returns an \OCA\Calendar\Db\Calendar object.
|
||||
* This method is mandatory!
|
||||
*/
|
||||
public function findCalendar($calendarURI, $userId) {
|
||||
if(!$this->doesCalendarExist($calendarURI, $userId)) {
|
||||
|
@ -96,14 +105,12 @@ class Contact extends Backend {
|
|||
return $calendar;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns all calendars of the user $userId
|
||||
* @param string $userId
|
||||
* @returns \OCA\Calendar\Db\CalendarCollection
|
||||
* @throws DoesNotExistException if uri does not exist
|
||||
*
|
||||
* This method returns an \OCA\Calendar\Db\CalendarCollection object.
|
||||
* This method is mandatory!
|
||||
*/
|
||||
public function findCalendars($userId, $limit=null, $offset=null) {
|
||||
$calendars = new CalendarCollection();
|
||||
|
@ -115,26 +122,22 @@ class Contact extends Backend {
|
|||
return $calendars;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns number of calendar
|
||||
* @param string $userid
|
||||
* @returns integer
|
||||
*
|
||||
* This method returns an integer
|
||||
* This method is mandatory!
|
||||
*/
|
||||
public function countCalendars($userId) {
|
||||
return 1;
|
||||
return count($this->calendarURIs);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns whether or not a calendar exists
|
||||
* @param string $calendarURI
|
||||
* @param string $userid
|
||||
* @returns boolean
|
||||
*
|
||||
* This method returns a boolean
|
||||
* This method is mandatory!
|
||||
*/
|
||||
public function doesCalendarExist($calendarURI, $userId) {
|
||||
if(in_array($calendarURI, $this->calendarURIs)) {
|
||||
|
@ -144,6 +147,7 @@ class Contact extends Backend {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns information about the object (event/journal/todo) with the uid $objectURI in the calendar $calendarURI of the user $userId
|
||||
* @param string $calendarURI
|
||||
|
@ -152,24 +156,19 @@ class Contact extends Backend {
|
|||
* @returns \OCA\Calendar\Db\Object object
|
||||
* @throws DoesNotExistException if calendar does not exist
|
||||
* @throws DoesNotExistException if object does not exist
|
||||
*
|
||||
* This method returns an \OCA\Calendar\Db\Object object.
|
||||
* This method is mandatory!
|
||||
*/
|
||||
public function findObject(Calendar &$calendar, $objectURI) {
|
||||
//TODO implement
|
||||
throw new DoesNotExistException();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns all objects in the calendar $calendarURI of the user $userId
|
||||
* @param string $calendarURI
|
||||
* @param string $userId
|
||||
* @returns \OCA\Calendar\Db\ObjectCollection
|
||||
* @throws DoesNotExistException if calendar does not exist
|
||||
*
|
||||
* This method returns an \OCA\Calendar\Db\ObjectCollection object.
|
||||
* This method is mandatory!
|
||||
*/
|
||||
public function findObjects(Calendar &$calendar, $limit, $offset) {
|
||||
//TODO implement
|
||||
|
|
|
@ -261,6 +261,7 @@ class Local extends Backend {
|
|||
$sql .= '(`userid`, `displayname`, `uri`, `active`, `ctag`, `calendarorder`, ';
|
||||
$sql .= '`calendarcolor`, `timezone`, `components`) ';
|
||||
$sql .= 'VALUES(?,?,?,?,?,?,?,?,?)';
|
||||
|
||||
$result = \OCP\DB::prepare($sql)->execute(array(
|
||||
$calendar->getUserId(),
|
||||
$calendar->getDisplayname(),
|
||||
|
@ -293,9 +294,11 @@ class Local extends Backend {
|
|||
$caltbl = $this->calTableName;
|
||||
|
||||
$sql = 'UPDATE `' . $caltbl . '` SET ';
|
||||
$sql .= '`userid` = ?, `displayname` = ?, `uri` = ?, `active` = ?, `ctag` = ?, ';
|
||||
$sql .= '`calendarorder` = ?, `calendarcolor` = ?, `timezone` = ?, `components` = ? ';
|
||||
$sql .= '`userid` = ?, `displayname` = ?, `uri` = ?, `active` = ?, ';
|
||||
$sql .= '`ctag` = ?, `calendarorder` = ?, `calendarcolor` = ?, ';
|
||||
$sql .= '`timezone` = ?, `components` = ? ';
|
||||
$sql .= 'WHERE `userid` = ? AND `uri` = ?';
|
||||
|
||||
$result = \OCP\DB::prepare($sql)->execute(array(
|
||||
$calendar->getUserId(),
|
||||
$calendar->getDisplayname(),
|
||||
|
@ -321,10 +324,12 @@ class Local extends Backend {
|
|||
public function deleteCalendar($calendarURI, $userId) {
|
||||
$caltbl = $this->calTableName;
|
||||
|
||||
$sql = 'DELETE FROM `' . $caltbl . '` ';
|
||||
//TODO - delete objects
|
||||
|
||||
$sql = 'DELETE FROM `' . $caltbl . '` WHERE ';
|
||||
$sql .= '`uri` = ? AND `userid` = ?';
|
||||
|
||||
$result = \OCP\DB::prepare($sql)->execute(array(
|
||||
$this->calTableName,
|
||||
$calendarURI,
|
||||
$userId
|
||||
));
|
||||
|
@ -928,10 +933,6 @@ class Local extends Backend {
|
|||
$object->setCalendar($calendar);
|
||||
$object->setObjectURI(strval($row['uri']));
|
||||
$object->setCalendarData(strval($row['calendardata']));
|
||||
ObjectUtility::addMissingVTimezones(
|
||||
$object,
|
||||
$this->app->query('TimezoneMapper')
|
||||
);
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
|
|
@ -7,10 +7,106 @@
|
|||
*/
|
||||
namespace OCA\Calendar\Backend;
|
||||
|
||||
use \OCA\Calendar\Db\Calendar;
|
||||
use \OCA\Calendar\Db\Object;
|
||||
use \OCA\Calendar\Db\ObjectType;
|
||||
use \OCP\AppFramework\IAppContainer;
|
||||
|
||||
use \OCA\Calendar\Db\DoesNotExistException;
|
||||
use \OCA\Calendar\Db\MultipleObjectsReturnedException;
|
||||
use \OCA\Calendar\Db\CorruptDataException;
|
||||
|
||||
use \OCA\Calendar\Db\Calendar;
|
||||
use \OCA\Calendar\Db\CalendarCollection;
|
||||
|
||||
use \OCA\Calendar\Db\Object;
|
||||
use \OCA\Calendar\Db\ObjectCollection;
|
||||
|
||||
use \OCA\Calendar\Db\Timezone;
|
||||
use \OCA\Calendar\Db\TimezoneCollection;
|
||||
|
||||
use \OCA\Calendar\Db\ObjectType;
|
||||
use \OCA\Calendar\Db\Permissions;
|
||||
|
||||
class LocalStorage extends Backend {}
|
||||
use \OCA\Calendar\Utility\ObjectUtility;
|
||||
|
||||
use \DateTime;
|
||||
|
||||
class LocalStorage extends Backend {
|
||||
|
||||
/**
|
||||
* @brief constructor
|
||||
* @param IAppContainer $app
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function __construct(IAppContainer $app, array $parameters){
|
||||
parent::__construct($app, 'LocalStorage');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns information about calendar $calendarURI of the user $userId
|
||||
* @param string $calendarURI
|
||||
* @param string $userId
|
||||
* @returns array with \OCA\Calendar\Db\Calendar object
|
||||
* @throws DoesNotExistException if uri does not exist
|
||||
*/
|
||||
public function findCalendar($calendarURI, $userId) {
|
||||
return new Calendar();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns all calendars of the user $userId
|
||||
* @param string $userId
|
||||
* @returns \OCA\Calendar\Db\CalendarCollection
|
||||
* @throws DoesNotExistException if uri does not exist
|
||||
*/
|
||||
public function findCalendars($userId, $limit=null, $offset=null) {
|
||||
return new CalendarCollection();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns number of calendar
|
||||
* @param string $userid
|
||||
* @returns integer
|
||||
*/
|
||||
public function countCalendars($userId) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns whether or not a calendar exists
|
||||
* @param string $calendarURI
|
||||
* @param string $userid
|
||||
* @returns boolean
|
||||
*/
|
||||
public function doesCalendarExist($calendarURI, $userId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns information about the object (event/journal/todo) with the uid $objectURI in the calendar $calendarURI of the user $userId
|
||||
* @param string $calendarURI
|
||||
* @param string $objectURI
|
||||
* @param string $userid
|
||||
* @returns \OCA\Calendar\Db\Object object
|
||||
* @throws DoesNotExistException if calendar does not exist
|
||||
* @throws DoesNotExistException if object does not exist
|
||||
*/
|
||||
public function findObject(Calendar &$calendar, $objectURI) {
|
||||
throw new DoesNotExistException();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns all objects in the calendar $calendarURI of the user $userId
|
||||
* @param string $calendarURI
|
||||
* @param string $userId
|
||||
* @returns \OCA\Calendar\Db\ObjectCollection
|
||||
* @throws DoesNotExistException if calendar does not exist
|
||||
*/
|
||||
public function findObjects(Calendar &$calendar, $limit, $offset) {
|
||||
return new ObjectCollection();
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@ use \OCP\AppFramework\IAppContainer;
|
|||
|
||||
use \OCA\Calendar\Db\DoesNotExistException;
|
||||
use \OCA\Calendar\Db\MultipleObjectsReturnedException;
|
||||
use \OCA\Calendar\Db\CorruptDataException;
|
||||
|
||||
use \OCA\Calendar\Db\Calendar;
|
||||
use \OCA\Calendar\Db\CalendarCollection;
|
||||
|
@ -28,6 +29,8 @@ use \OCA\Calendar\Db\TimezoneCollection;
|
|||
use \OCA\Calendar\Db\ObjectType;
|
||||
use \OCA\Calendar\Db\Permissions;
|
||||
|
||||
use \OCA\Calendar\Utility\ObjectUtility;
|
||||
|
||||
use \DateTime;
|
||||
|
||||
class Sharing extends Backend {
|
||||
|
@ -42,8 +45,13 @@ class Sharing extends Backend {
|
|||
);
|
||||
|
||||
|
||||
public function __construct(IAppContainer $api, $parameters){
|
||||
parent::__construct($api, 'sharing');
|
||||
/**
|
||||
* @brief constructor
|
||||
* @param IAppContainer $app
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function __construct(IAppContainer $app, array $parameters){
|
||||
parent::__construct($app, 'Sharing');
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7,21 +7,115 @@
|
|||
*/
|
||||
namespace OCA\Calendar\Backend;
|
||||
|
||||
use \OCA\Calendar\AppFramework\Core\API;
|
||||
use \OCA\Calendar\AppFramework\Db\Mapper;
|
||||
use \OCA\Calendar\AppFramework\Db\DoesNotExistException;
|
||||
use \OCA\Calendar\AppFramework\Db\MultipleObjectsReturnedException;
|
||||
use \OCP\AppFramework\IAppContainer;
|
||||
|
||||
use \OCA\Calendar\Db\DoesNotExistException;
|
||||
use \OCA\Calendar\Db\MultipleObjectsReturnedException;
|
||||
use \OCA\Calendar\Db\CorruptDataException;
|
||||
|
||||
use \OCA\Calendar\Db\Calendar;
|
||||
use \OCA\Calendar\Db\Object;
|
||||
use \OCA\Calendar\Db\ObjectType;
|
||||
use \OCA\Calendar\Db\CalendarCollection;
|
||||
|
||||
use \OCA\Calendar\Db\Object;
|
||||
use \OCA\Calendar\Db\ObjectCollection;
|
||||
|
||||
use \OCA\Calendar\Db\Timezone;
|
||||
use \OCA\Calendar\Db\TimezoneCollection;
|
||||
|
||||
use \OCA\Calendar\Db\ObjectType;
|
||||
use \OCA\Calendar\Db\Permissions;
|
||||
|
||||
use \OCA\Calendar\Utility\ObjectUtility;
|
||||
|
||||
use \DateTime;
|
||||
|
||||
class WebCal extends Backend {
|
||||
|
||||
public function cacheObjects($calendarURI, $userId) {
|
||||
return true;
|
||||
/**
|
||||
* subscription mapper
|
||||
* @var \OCA\Calendar\Db\SubscriptionMapper
|
||||
*/
|
||||
protected $subscriptionMapper;
|
||||
|
||||
|
||||
/**
|
||||
* @brief constructor
|
||||
* @param IAppContainer $app
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function __construct(IAppContainer $app, array $parameters){
|
||||
parent::__construct($app, 'WebCAL');
|
||||
|
||||
$this->subscriptionMapper = $app->query('SubscriptionMapper');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns information about calendar $calendarURI of the user $userId
|
||||
* @param string $calendarURI
|
||||
* @param string $userId
|
||||
* @returns array with \OCA\Calendar\Db\Calendar object
|
||||
* @throws DoesNotExistException if uri does not exist
|
||||
*/
|
||||
public function findCalendar($calendarURI, $userId) {
|
||||
return new Calendar();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns all calendars of the user $userId
|
||||
* @param string $userId
|
||||
* @returns \OCA\Calendar\Db\CalendarCollection
|
||||
* @throws DoesNotExistException if uri does not exist
|
||||
*/
|
||||
public function findCalendars($userId, $limit=null, $offset=null) {
|
||||
return new CalendarCollection();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns number of calendar
|
||||
* @param string $userid
|
||||
* @returns integer
|
||||
*/
|
||||
public function countCalendars($userId) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns whether or not a calendar exists
|
||||
* @param string $calendarURI
|
||||
* @param string $userid
|
||||
* @returns boolean
|
||||
*/
|
||||
public function doesCalendarExist($calendarURI, $userId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns information about the object (event/journal/todo) with the uid $objectURI in the calendar $calendarURI of the user $userId
|
||||
* @param string $calendarURI
|
||||
* @param string $objectURI
|
||||
* @param string $userid
|
||||
* @returns \OCA\Calendar\Db\Object object
|
||||
* @throws DoesNotExistException if calendar does not exist
|
||||
* @throws DoesNotExistException if object does not exist
|
||||
*/
|
||||
public function findObject(Calendar &$calendar, $objectURI) {
|
||||
throw new DoesNotExistException();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns all objects in the calendar $calendarURI of the user $userId
|
||||
* @param string $calendarURI
|
||||
* @param string $userId
|
||||
* @returns \OCA\Calendar\Db\ObjectCollection
|
||||
* @throws DoesNotExistException if calendar does not exist
|
||||
*/
|
||||
public function findObjects(Calendar &$calendar, $limit, $offset) {
|
||||
return new ObjectCollection();
|
||||
}
|
||||
}
|
|
@ -27,20 +27,28 @@ abstract class BusinessLayer {
|
|||
*/
|
||||
protected $app;
|
||||
|
||||
|
||||
/**
|
||||
* ownCloud's core api
|
||||
* @var \OCP\AppFramework\IApi
|
||||
*/
|
||||
protected $api;
|
||||
|
||||
|
||||
/**
|
||||
* app container for dependency injection
|
||||
* @var \OCA\Calendar\BusinessLayer\BackendBusinessLayer
|
||||
*/
|
||||
private $bmp;
|
||||
|
||||
|
||||
/**
|
||||
* Backend Collection
|
||||
* @var \OCA\Calendar\Db\BackendCollection
|
||||
*/
|
||||
protected $backends;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param IAppContainer $app interface to the app
|
||||
|
@ -48,18 +56,17 @@ abstract class BusinessLayer {
|
|||
*/
|
||||
public function __construct(IAppContainer $app, BackendMapper $backendMapper){
|
||||
$this->app = $app;
|
||||
$this->api = $app->getCoreApi();
|
||||
$this->bmp = $backendMapper;
|
||||
$this->api = $app->getCoreApi();
|
||||
|
||||
$this->setupBackends();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get backend and uri from public uri
|
||||
* public uri: backend-uri; e.g. local-work
|
||||
* backend: backend; e.g. local for standard database backend
|
||||
* real uri: uri; e.g. work
|
||||
* @param string $uri public uri
|
||||
* @brief split up calendarURI
|
||||
* @param string $calendarId e.g. local::personal
|
||||
* @return array [$backend, $calendarURI]
|
||||
* @throws BusinessLayerException if uri is empty
|
||||
* @throws BusinessLayerException if uri is not valid
|
||||
*/
|
||||
|
@ -67,50 +74,30 @@ abstract class BusinessLayer {
|
|||
$split = CalendarUtility::splitURI($calendarId);
|
||||
|
||||
if($split[0] === false || $split[1] === false) {
|
||||
throw new BusinessLayerException('calendar uri is not valid');
|
||||
$msg = 'BusinessLayer::splitCalendarURI(): User Error: ';
|
||||
$msg .= 'Given calendarId is not valid!';
|
||||
throw new BusinessLayerException($msg);
|
||||
}
|
||||
|
||||
return $split;
|
||||
}
|
||||
|
||||
/**
|
||||
* get backend and real calendar uri and real object uri from public uri
|
||||
* public uri: backend-uri; e.g. local-work
|
||||
* backend: backend; e.g. local for standard database backend
|
||||
* real uri: uri; e.g. work
|
||||
* @param string $uri public uri
|
||||
* @throws BusinessLayerException if uri is empty
|
||||
* @throws BusinessLayerException if uri is not valid
|
||||
* @throws DoesNotImplementException if backend does not implement searched implementation
|
||||
*/
|
||||
final protected function splitObjectURI($objectURI=null) {
|
||||
$split = ObjectUtility::splitURI($objectURI);
|
||||
|
||||
if($split[0] === false || $split[1] === false || $split[2] === false) {
|
||||
throw new BusinessLayerException('object uri is not valid');
|
||||
}
|
||||
|
||||
return $split;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if a backend does support a certian action
|
||||
* @brief check if a backend does support a certian action
|
||||
* @param string $backend
|
||||
* @param action
|
||||
* @param integer $action
|
||||
* @return boolean
|
||||
*/
|
||||
final protected function doesBackendSupport($backend, $action) {
|
||||
try {
|
||||
return $this->backends->search('backend', $backend)->current()->api->implementsActions($action);
|
||||
} catch(DoesNotExistException $ex){
|
||||
throw new BusinessLayerException($ex->getMessage());
|
||||
} catch(MultipleObjectsReturnedException $ex){
|
||||
throw new BusinessLayerException($ex->getMessage());
|
||||
}
|
||||
return $this->backends->search('backend', $backend)->current()->api->implementsActions($action);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* check if a backend is enabled
|
||||
* @brief check if a backend is enabled
|
||||
* @param string $backend
|
||||
* @return boolean
|
||||
*/
|
||||
final protected function isBackendEnabled($backend) {
|
||||
try {
|
||||
|
@ -122,24 +109,29 @@ abstract class BusinessLayer {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get the default backend
|
||||
* @brief get the default backend
|
||||
* @return string
|
||||
*/
|
||||
final protected function getDefaultBackend(){
|
||||
return $this->bmp->getDefault();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set the default backend
|
||||
* @brief set the default backend
|
||||
* @param string $backend
|
||||
*/
|
||||
final protected function setDefaultBackend($backend){
|
||||
return $this->bmp->setDefault($backend);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* find a backend
|
||||
* @brief find a backend
|
||||
* @param string $backend
|
||||
* @return \OCA\Calendar\Db\Backend
|
||||
*/
|
||||
final protected function findBackend($backendId) {
|
||||
try {
|
||||
|
@ -151,35 +143,42 @@ abstract class BusinessLayer {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* find all backend
|
||||
* @brief find all backend
|
||||
* @param integer $limit
|
||||
* @param integer $offset
|
||||
* @return \OCA\Calendar\Db\BackendCollection
|
||||
*/
|
||||
final protected function findAllBackends($limit=null, $offset=null) {
|
||||
return $this->bmp->findAll($limit, $offset);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* find all disabled backend
|
||||
* @brief find all disabled backend
|
||||
* @param integer $limit
|
||||
* @param integer $offset
|
||||
* @return \OCA\Calendar\Db\BackendCollection
|
||||
*/
|
||||
final protected function findAllDisabledBackeds($limit=null, $offset=null) {
|
||||
return $this->bmp->findWhereEnabledIs(false, $limit, $offset);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* find all enabled backend
|
||||
* @brief find all enabled backend
|
||||
* @param integer $limit
|
||||
* @param integer $offset
|
||||
* @return \OCA\Calendar\Db\BackendCollection
|
||||
*/
|
||||
final protected function findAllEnabledBackends($limit=null, $offset=null) {
|
||||
return $this->bmp->findWhereEnabledIs(true, $limit, $offset);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* create a backend
|
||||
* @brief create a backend
|
||||
* @param Backend $backend
|
||||
*/
|
||||
final protected function createBackend(Backend $backend) {
|
||||
|
@ -192,16 +191,18 @@ abstract class BusinessLayer {
|
|||
return $this->bmp->create($create);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* update a backend
|
||||
* @brief update a backend
|
||||
* @param Backend $backend
|
||||
*/
|
||||
final protected function updateBackend(Backend $backend) {
|
||||
return $this->bmp->update($backend);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* enable a backend
|
||||
* @brief enable a backend
|
||||
* @param string $backend
|
||||
*/
|
||||
final protected function enableBackend($backendId){
|
||||
|
@ -209,8 +210,9 @@ abstract class BusinessLayer {
|
|||
return $this->bmp->update($backend);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* disable a backend
|
||||
* @brief disable a backend
|
||||
* @param string $backend
|
||||
*/
|
||||
final protected function disableBackend($backendId){
|
||||
|
@ -218,16 +220,18 @@ abstract class BusinessLayer {
|
|||
return $this->bmp->update($backend);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* delete a backend
|
||||
* @brief delete a backend
|
||||
* @param Backend $backend
|
||||
*/
|
||||
final protected function deleteBackend(Backend $backend) {
|
||||
return $this->bmp->delete($backend);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* setup backends
|
||||
* @brief setup backends
|
||||
* @throws BusinessLayerException if no backends could be setup
|
||||
*/
|
||||
private function setupBackends() {
|
||||
|
|
|
@ -11,6 +11,12 @@ use \OCP\AppFramework\Http;
|
|||
|
||||
class BusinessLayerException extends \Exception {
|
||||
|
||||
/**
|
||||
* @brief Constructor
|
||||
* @param string $message
|
||||
* @param integer $code
|
||||
* @param Exception $previous
|
||||
*/
|
||||
public function __construct($message=null, $code=null, \Exception $previous=null) {
|
||||
if($code === null) {
|
||||
$code = Http::STATUS_BAD_REQUEST;
|
||||
|
@ -18,5 +24,4 @@ class BusinessLayerException extends \Exception {
|
|||
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
}
|
|
@ -515,6 +515,7 @@ class CalendarBusinessLayer extends BusinessLayer {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* update a new calendar from request
|
||||
* @param Calendar $calendar
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
*/
|
||||
namespace OCA\Calendar\Db;
|
||||
|
||||
require_once(__DIR__ . '/../3rdparty/VObject/includes.php');
|
||||
|
||||
use \OCA\Calendar\Sabre\VObject\Component\VCalendar;
|
||||
use \OCA\Calendar\Sabre\VObject\Reader;
|
||||
use \OCA\Calendar\Sabre\VObject\ParseException;
|
||||
|
|
|
@ -24,7 +24,7 @@ abstract class Mapper {
|
|||
* @param string $tableName the name of the table. set this to allow entity
|
||||
* queries without using sql
|
||||
*/
|
||||
public function __construct(IAppContainer $api, $tableName){
|
||||
public function __construct(IAppContainer $app, $tableName){
|
||||
$this->app = $app;
|
||||
$this->tableName = '*PREFIX*' . $tableName;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
*/
|
||||
namespace OCA\Calendar\Db;
|
||||
|
||||
require_once(__DIR__ . '/../3rdparty/VObject/includes.php');
|
||||
|
||||
use \BadFunctionCallException;
|
||||
use \DateTime;
|
||||
use \OCA\Calendar\Sabre\VObject\Component\VCalendar;
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
*/
|
||||
namespace OCA\Calendar\Db;
|
||||
|
||||
require_once(__DIR__ . '/../3rdparty/VObject/includes.php');
|
||||
|
||||
use \OCA\Calendar\Sabre\VObject\Component\VCalendar;
|
||||
use \OCA\Calendar\Sabre\VObject\Reader;
|
||||
use \OCA\Calendar\Sabre\VObject\ParseException;
|
||||
|
@ -19,11 +21,12 @@ class Timezone extends Entity {
|
|||
public $tzId;
|
||||
public $vobject;
|
||||
|
||||
|
||||
/**
|
||||
* @brief init Timezone object with timezone name
|
||||
* @param string $timezone
|
||||
*/
|
||||
public function __construct($tzId, $tzData) {
|
||||
public function __construct($tzId=null, $tzData=null) {
|
||||
$this->addType('tzId', 'string');
|
||||
$this->addType('tzData', 'string');
|
||||
|
||||
|
@ -41,24 +44,24 @@ class Timezone extends Entity {
|
|||
* @return boolean
|
||||
*/
|
||||
public function isValid() {
|
||||
$strings = array('tzId', 'tzData');
|
||||
foreach($strings as $string) {
|
||||
if(is_null($this->$string)) {
|
||||
return false;
|
||||
}
|
||||
if($this->$string === '') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
//TODO fix me
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief set timezone data
|
||||
* @param string $data
|
||||
*/
|
||||
public function setTzData($data) {
|
||||
$tzData = "BEGIN:VCALENDAR\n";
|
||||
$tzData .= $data;
|
||||
$tzData .= "END:VCALENDAR";
|
||||
$this->vobject = Reader::read($tzData);
|
||||
if(substr_count($data, 'BEGIN:VCALENDAR') === 0) {
|
||||
$data = 'BEGIN:VCALENDAR' . "\n" . $data . "\n" . 'END:VCALENDAR';
|
||||
}
|
||||
|
||||
$this->vobject = Reader::read($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief take data from VObject and put into this Timezone object
|
||||
* @param \Sabre\VObject\Component\VCalendar $vcalendar
|
||||
|
|
|
@ -108,7 +108,7 @@ class JSONCalendar extends JSON {
|
|||
private function setCalDAVURL() {
|
||||
$calendarURI = CalendarUtility::getURI($this->object->getBackend(), $this->object->getUri());
|
||||
|
||||
$calDAVURL = JSONUtility::getCalDAV($calendarURI);
|
||||
$calDAVURL = JSONUtility::getCalDAV($calendarURI, $this->object->getUserId());
|
||||
$this->jsonArray['caldav'] = $calDAVURL;
|
||||
}
|
||||
}
|
|
@ -30,6 +30,12 @@ class JSONObject extends JSON {
|
|||
*/
|
||||
public function serialize($convenience=true) {
|
||||
$vcalendar = $this->object->getVObject();
|
||||
|
||||
/*ObjectUtility::addMissingVTimezones(
|
||||
$vcalendar,
|
||||
$this->app->query('TimezoneMapper')
|
||||
);*/
|
||||
|
||||
return $vcalendar->jsonSerialize();
|
||||
}
|
||||
}
|
|
@ -35,6 +35,11 @@ class JSONObjectCollection extends JSONCollection {
|
|||
|
||||
$vcalendar = $this->object->getVObject();
|
||||
|
||||
/*ObjectUtility::addMissingVTimezones(
|
||||
$vcalendar,
|
||||
$this->app->query('TimezoneMapper')
|
||||
);*/
|
||||
|
||||
return $vcalendar->jsonSerialize();
|
||||
}
|
||||
}
|
|
@ -16,9 +16,9 @@ class CalendarUtility extends Utility{
|
|||
$calendarURI .= '-1';
|
||||
} else {
|
||||
$positionLastDash = strrpos($calendarURI, '-');
|
||||
$firstPart = substr($calendarURI, 0, strlen($calendarURI) - $positionLastDash);
|
||||
$firstPart = substr($calendarURI, 0, $positionLastDash);
|
||||
$lastPart = substr($calendarURI, $positionLastDash + 1);
|
||||
$pattern = "^\d$";
|
||||
$pattern = '/^\d+$/';
|
||||
if(preg_match($pattern, $lastPart)) {
|
||||
$lastPart = (int) $lastPart;
|
||||
$lastPart++;
|
||||
|
|
Loading…
Reference in New Issue