add space between if and {

This commit is contained in:
Georg Ehrke 2014-04-24 17:12:03 +02:00
parent 590b937e3d
commit 206fe691d2
43 changed files with 365 additions and 365 deletions

View File

@ -71,7 +71,7 @@ abstract class Backend implements IBackend {
public function __construct(IAppContainer $app, $backend=null){
$this->app = $app;
if($backend === null) {
if ($backend === null) {
$backend = get_class($this);
}
@ -88,7 +88,7 @@ abstract class Backend implements IBackend {
public function getSupportedActions() {
$actions = 0;
foreach($this->possibleActions as $action => $methodName) {
if(method_exists($this, $methodName)) {
if (method_exists($this, $methodName)) {
$actions |= $action;
}
}

View File

@ -77,7 +77,7 @@ class Contact extends Backend {
* @throws DoesNotExistException if uri does not exist
*/
public function findCalendar($calendarURI, $userId) {
if(!$this->doesCalendarExist($calendarURI, $userId)) {
if (!$this->doesCalendarExist($calendarURI, $userId)) {
$msg = 'Backend\Contact::findCalendar(): ';
$msg .= '"' . $calendarURI . '" doesn\'t exist';
throw new DoesNotExistException($msg);
@ -96,9 +96,9 @@ class Contact extends Backend {
$calendar->setOrder(0);
$calendar->setEnabled(true);
if($calendarURI === 'anniversary') {
if ($calendarURI === 'anniversary') {
$calendar->setDisplayname('Anniversary'); //TODO - use translation
} elseif($calendarURI === 'birthday') {
} elseif ($calendarURI === 'birthday') {
$calendar->setDisplayname('Birthday'); //TODO - use translation
}
@ -140,7 +140,7 @@ class Contact extends Backend {
* @returns boolean
*/
public function doesCalendarExist($calendarURI, $userId) {
if(in_array($calendarURI, $this->calendarURIs)) {
if (in_array($calendarURI, $this->calendarURIs)) {
return true;
} else {
return false;

View File

@ -107,14 +107,14 @@ class Local extends Backend {
));
$row = $result->fetchRow();
if($row === false || $row === null){
if ($row === false || $row === null){
$msg = 'Backend\Local::findCalendar(): Internal Error: ';
$msg .= 'No matching entry found';
throw new CacheOutDatedException($msg);
}
$row2 = $result->fetchRow();
if(($row2 === false || $row2 === null ) === false) {
if (($row2 === false || $row2 === null ) === false) {
$msg = 'Backend\Local::findCalendar(): Internal Error: ';
$msg .= 'More than one result';
throw new MultipleObjectsReturnedException($msg);
@ -176,7 +176,7 @@ class Local extends Backend {
));
$count = $result->fetchOne();
if(gettype($count) !== 'integer') {
if (gettype($count) !== 'integer') {
$count = intval($count);
}
@ -202,11 +202,11 @@ class Local extends Backend {
));
$count = $result->fetchOne();
if(gettype($count) !== 'integer') {
if (gettype($count) !== 'integer') {
$count = intval($count);
}
if($count === 0) {
if ($count === 0) {
return false;
} else {
return true;
@ -232,7 +232,7 @@ class Local extends Backend {
));
$ctag = $result->fetchOne();
if(gettype($ctag) !== 'integer') {
if (gettype($ctag) !== 'integer') {
$ctag = intval($ctag);
}
@ -249,7 +249,7 @@ class Local extends Backend {
$calendarURI = $calendar->getUri();
$userId = $calendar->getUserId();
if($this->doesCalendarExist($calendarURI, $userId) === true) {
if ($this->doesCalendarExist($calendarURI, $userId) === true) {
$msg = 'Backend\Local::createCalendar(): Internal Error: ';
$msg .= 'Calendar with uri and userid combination already exists!';
throw new CacheOutDatedException($msg);
@ -285,7 +285,7 @@ class Local extends Backend {
* @return Calendar
*/
public function updateCalendar(Calendar &$calendar) {
if($this->doesCalendarExist($oldCalendarURI, $oldUserId) === false) {
if ($this->doesCalendarExist($oldCalendarURI, $oldUserId) === false) {
$msg = 'Backend\Local::updateCalendar(): Internal Error: ';
$msg .= 'Calendar with uri and userid combination not found!';
throw new CacheOutDatedException($msg);
@ -396,14 +396,14 @@ class Local extends Backend {
));
$row = $result->fetchRow();
if($row === false || $row === null){
if ($row === false || $row === null){
$msg = 'Backend\Local::findObject(): Internal Error: ';
$msg .= 'No matching entry found';
throw new CacheOutDatedException($msg);
}
$row2 = $result->fetchRow();
if(($row2 === false || $row2 === null ) === false) {
if (($row2 === false || $row2 === null ) === false) {
$msg = 'Backend\Local::findObject(): Internal Error: ';
$msg .= 'More than one result';
throw new MultipleObjectsReturnedException($msg);
@ -627,7 +627,7 @@ class Local extends Backend {
));
$count = $result->fetchOne();
if(gettype($count) !== 'integer') {
if (gettype($count) !== 'integer') {
$count = intval($count);
}
@ -660,11 +660,11 @@ class Local extends Backend {
));
$count = $result->fetchOne();
if(gettype($count) !== 'integer') {
if (gettype($count) !== 'integer') {
$count = intval($count);
}
if($count === 0) {
if ($count === 0) {
return false;
} else {
return true;
@ -694,12 +694,12 @@ class Local extends Backend {
$calendarURI = $object->getCalendar()->getUri();
$userId = $object->getCalendar()->getUserId();
if(!$this->doesCalendarExist($calendarURI, $userId)) {
if (!$this->doesCalendarExist($calendarURI, $userId)) {
$msg = 'Backend\Local::createObject(): Internal Error: ';
$msg .= 'Calendar not found!';
throw new CacheOutDatedException($msg);
}
/*if($this->doesObjectExist($calendarURI, $userId)) {
/*if ($this->doesObjectExist($calendarURI, $userId)) {
$msg = 'Backend\Local::createObject(): User Error: ';
$msg .= 'Object already exists';
throw new BackendException($msg);
@ -741,12 +741,12 @@ class Local extends Backend {
$calendarURI = $object->getCalendar()->getUri();
$userId = $object->getCalendar()->getUserId();
if(!$this->doesCalendarExist($calendarURI, $userId)) {
if (!$this->doesCalendarExist($calendarURI, $userId)) {
$msg = 'Backend\Local::createObject(): Internal Error: ';
$msg .= 'Calendar not fouund!';
throw new CacheOutDatedException($msg);
}
/*if(!$this->doesObjectExist($calendarURI, $userId)) {
/*if (!$this->doesObjectExist($calendarURI, $userId)) {
$msg = 'Backend\Local::createObject(): User Error: ';
$msg .= 'Object already exists';
throw new BackendException($msg);
@ -788,7 +788,7 @@ class Local extends Backend {
$objectURI = $object->getObjectURI();
$userId = $object->getCalendar()->getUserId();
if(!$this->doesCalendarExist($calendarURI, $userId)) {
if (!$this->doesCalendarExist($calendarURI, $userId)) {
$msg = 'Backend\Local::createObject(): Internal Error: ';
$msg .= 'Calendar not fouund!';
throw new CacheOutDatedException($msg);
@ -816,13 +816,13 @@ class Local extends Backend {
* @return ObjectCollection
*/
public function searchByProperties(Calendar $calendar, array $properties=array(), $limit, $offset) {
if(!$this->doesCalendarExist($calendarURI, $userId)) {
if (!$this->doesCalendarExist($calendarURI, $userId)) {
$msg = 'Backend\Local::createObject(): Internal Error: ';
$msg .= 'Calendar not fouund!';
throw new CacheOutDatedException($msg);
}
if(empty($properties)) {
if (empty($properties)) {
return $this->findObjects($calendarId, $userId);
}
@ -944,7 +944,7 @@ class Local extends Backend {
* @param mixed (integer|string)
*/
public function getType($type) {
if(is_int($type)) {
if (is_int($type)) {
return ObjectType::getAsString($type);
} else {
return ObjectType::getTypeByString($type);
@ -958,7 +958,7 @@ class Local extends Backend {
* @param mixed (integer|string)
*/
public function getTypes($type) {
if(is_int($type)) {
if (is_int($type)) {
return ObjectType::getAsString($type);
} else {
return ObjectType::getTypesByString($type);

View File

@ -73,7 +73,7 @@ abstract class BusinessLayer {
final protected function splitCalendarURI($calendarId) {
$split = CalendarUtility::splitURI($calendarId);
if($split[0] === false || $split[1] === false) {
if ($split[0] === false || $split[1] === false) {
$msg = 'BusinessLayer::splitCalendarURI(): User Error: ';
$msg .= 'Given calendarId is not valid!';
throw new BusinessLayerException($msg);
@ -182,7 +182,7 @@ abstract class BusinessLayer {
* @param Backend $backend
*/
final protected function createBackend(Backend $backend) {
if($this->bmp->doesExist($backend)) {
if ($this->bmp->doesExist($backend)) {
$msg = 'BusinessLayer::allowNoBackendTwice(): ';
$msg .= 'Backend already exists';
throw new BusinessLayerException($msg, BusinessLayerException::CONFLICT);
@ -242,7 +242,7 @@ abstract class BusinessLayer {
$className = $backend->getClassname();
$args = is_array($backend->getArguments()) ? $backend->getArguments() : array();
if(class_exists($className) === false){
if (class_exists($className) === false){
$msg = 'BusinessLayer::setupBackends(): ';
$msg .= '"' . $className . '" not found';
\OCP\Util::writeLog('calendar', $msg, \OCP\Util::DEBUG);
@ -250,7 +250,7 @@ abstract class BusinessLayer {
return false;
}
if($backendCollection->search('backend', $backend->getBackend())->count() > 0) {
if ($backendCollection->search('backend', $backend->getBackend())->count() > 0) {
$msg = 'BusinessLayer::setupBackends(): ';
$msg .= '"' . $className . '" already initialized. ';
$msg .= 'Please check for double entries';
@ -263,12 +263,12 @@ abstract class BusinessLayer {
$backend->registerAPI($api);
//check if a backend can enabled
if($backend->api->canBeEnabled()) {
if ($backend->api->canBeEnabled()) {
$backendCollection->add($backend);
}
});
if($backendCollection->count() === 0){
if ($backendCollection->count() === 0){
$msg = 'BusinessLayer::setupBackends(): ';
$msg .= 'No backend was setup successfully';
throw new BusinessLayerException($msg);

View File

@ -18,7 +18,7 @@ class BusinessLayerException extends \Exception {
* @param Exception $previous
*/
public function __construct($message=null, $code=null, \Exception $previous=null) {
if($code === null) {
if ($code === null) {
$code = Http::STATUS_BAD_REQUEST;
}

View File

@ -73,13 +73,13 @@ class CalendarBusinessLayer extends BusinessLayer {
public function findAll($userId, $limit=null, $offset=null, $filterBackends=true) {
try {
$calendars = $this->cmp->findAll($userId, $limit, $offset);
if(!($calendars instanceof CalendarCollection)) {
if (!($calendars instanceof CalendarCollection)) {
$msg = 'CalendarBusinessLayer::findAll(): Internal Error: ';
$msg .= 'CalendarCache returned unrecognised format!';
throw new BusinessLayerException($msg);
}
if($filterBackends) {
if ($filterBackends) {
$backends = $this->backends->enabled();
$calendars = $calendars->filterByBackends($backends);
}
@ -100,9 +100,9 @@ class CalendarBusinessLayer extends BusinessLayer {
*/
public function numberOfCalendars($userId, $filterBackends=true) {
try {
if(!$filterBackends) {
if (!$filterBackends) {
$number = $this->cmp->count($userId);
if(gettype($number) !== 'integer') {
if (gettype($number) !== 'integer') {
$msg = 'CalendarBusinessLayer::numberOfAllCalendars(): Internal Error: ';
$msg .= 'CalendarCache returned unrecognised format!';
throw new BusinessLayerException($msg);
@ -130,7 +130,7 @@ class CalendarBusinessLayer extends BusinessLayer {
public function findAllOnBackend($backend, $userId, $limit=null, $offset=null) {
try {
$calendars = $this->cmp->findAllOnBackend($backend, $userId, $limit, $offset);
if(!($calendars instanceof CalendarCollection)) {
if (!($calendars instanceof CalendarCollection)) {
$msg = 'CalendarBusinessLayer::findAllOnBackend(): Internal Error: ';
$msg .= 'CalendarCache returned unrecognised format!';
throw new BusinessLayerException($msg);
@ -155,7 +155,7 @@ class CalendarBusinessLayer extends BusinessLayer {
public function numberOfCalendarsOnBackend($backend, $userId) {
try {
$number = $this->cmp->countOnBackend($backend, $userId);
if(gettype($number) !== 'integer') {
if (gettype($number) !== 'integer') {
$msg = 'CalendarBusinessLayer::numberOfAllCalendarsOnBackend(): Internal Error: ';
$msg .= 'CalendarCache returned unrecognised format!';
throw new BusinessLayerException($msg);
@ -181,14 +181,14 @@ class CalendarBusinessLayer extends BusinessLayer {
list($backend, $calendarURI) = (is_array($calendarId)) ? $calendarId :
$this->splitCalendarURI($calendarId);
if(!$this->isBackendEnabled($backend)) {
if (!$this->isBackendEnabled($backend)) {
$msg = 'CalendarBusinessLayer::find(): User Error: ';
$msg .= 'Backend found but not enabled';
throw new BusinessLayerException($msg, Http::STATUS_FORBIDDEN);
}
$calendar = $this->cmp->find($backend, $calendarURI, $userId);
if(!($calendar instanceof Calendar)) {
if (!($calendar instanceof Calendar)) {
$msg = 'CalendarBusinessLayer::find(): Internal Error: ';
$msg .= 'CalendarCache returned unrecognised format!';
throw new BusinessLayerException($msg);
@ -222,13 +222,13 @@ class CalendarBusinessLayer extends BusinessLayer {
$this->splitCalendarURI($calendarId);
$doesExistCached = $this->cmp->doesExist($backend, $calendarURI, $userId);
if(!$checkRemote) {
if (!$checkRemote) {
return $doesExistCached;
}
$doesExistRemote = $this->backends->find($backend)->api->doesCalendarExist($calendarURI, $userId);
//TODO - rethink: should the cache be updated here?
if($doesExistCached !== $doesExistRemote) {
if ($doesExistCached !== $doesExistRemote) {
$this->updateCacheForCalendarFromRemote(array($backend, $calendarURI), $userId);
}
@ -298,23 +298,23 @@ class CalendarBusinessLayer extends BusinessLayer {
$calendarURI = $calendar->getUri();
$userId = $calendar->getUserId();
if(!$calendar->isValid()) {
if (!$calendar->isValid()) {
$msg = 'CalendarBusinessLayer::create(): User Error: ';
$msg .= 'Given calendar data is not valid!';
throw new BusinessLayerException($msg, Http::STATUS_UNPROCESSABLE_ENTITY);
}
if(!$this->isBackendEnabled($backend)) {
if (!$this->isBackendEnabled($backend)) {
$msg = 'CalendarBusinessLayer::create(): User Error: ';
$msg .= 'Backend found but not enabled!';
throw new BusinessLayerException($msg, Http::STATUS_UNPROCESSABLE_ENTITY);
}
if($this->doesExist(array($backend, $calendarURI), $userId)) {
if ($this->doesExist(array($backend, $calendarURI), $userId)) {
$msg = 'CalendarBusinessLayer::create(): User Error: ';
$msg .= 'Calendar already exists!';
throw new BusinessLayerException($msg, Http::STATUS_CONFLICT);
}
if(!$this->doesBackendSupport($backend, \OCA\Calendar\Backend\CREATE_CALENDAR)) {
if (!$this->doesBackendSupport($backend, \OCA\Calendar\Backend\CREATE_CALENDAR)) {
$msg = 'CalendarBusinessLayer::create(): User Error: ';
$msg .= 'Backend does not support creating calendars!';
throw new BusinessLayerException($msg, Http::STATUS_UNPROCESSABLE_ENTITY);
@ -342,23 +342,23 @@ class CalendarBusinessLayer extends BusinessLayer {
*/
public function createFromRequest(Calendar $calendar) {
$userId = $this->api->getUserId();
if($calendar->getUserId() === null) {
if ($calendar->getUserId() === null) {
$calendar->setUserId($userId);
}
if($calendar->getOwnerId() === null) {
if ($calendar->getOwnerId() === null) {
$calendar->setOwnerId($userId);
}
if($calendar->getBackend() === null) {
if ($calendar->getBackend() === null) {
$defaultBackend = $this->app->query('defaultBackend');
$calendar->setBackend($defaultBackend);
}
if($calendar->getDisplayname() === null) {
if ($calendar->getDisplayname() === null) {
$calendar->setDisplayname('Untitled');
}
if($calendar->getUri() === null && $calendar->getDisplayname() !== '') {
if ($calendar->getUri() === null && $calendar->getDisplayname() !== '') {
$displayname = $calendar->getDisplayname();
$suggestedURI = strtolower($displayname);
@ -372,7 +372,7 @@ class CalendarBusinessLayer extends BusinessLayer {
* check if new uri equals old uri, if it does, this will
* prevent an endless loop, but the request will fail
*/
if($newSuggestedURI === $suggestedURI) {
if ($newSuggestedURI === $suggestedURI) {
break;
}
$suggestedURI = $newSuggestedURI;
@ -381,11 +381,11 @@ class CalendarBusinessLayer extends BusinessLayer {
$calendar->setUri($suggestedURI);
}
if($calendar->getCruds() === null) {
if ($calendar->getCruds() === null) {
$calendar->setCruds(Permissions::ALL);
}
if($calendar->getCtag() === null) {
if ($calendar->getCtag() === null) {
$calendar->setCtag(0);
}
@ -454,37 +454,37 @@ class CalendarBusinessLayer extends BusinessLayer {
$newCalendarURI = $calendar->getUri();
$newUserId = $calendar->getUserId();
if($oldUserId === $newUserId) {
if ($oldUserId === $newUserId) {
$msg = 'CalendarBusinessLayer::update(): Not supported: ';
$msg .= 'Transferring a calendar to another user is not supported yet.';
throw new BusinessLayerException($msg, Http::STATUS_UNPROCESSABLE_ENTITY);
}
if(!$this->isBackendEnabled($oldBackend)) {
if (!$this->isBackendEnabled($oldBackend)) {
$msg = 'CalendarBusinessLayer::update(): User Error: ';
$msg .= 'Old backend found but not enabled!';
throw new BusinessLayerException($msg, Http::STATUS_UNPROCESSABLE_ENTITY);
}
if($newBackend !== $oldBackend && !$this->isBackendEnabled($newBackend)) {
if ($newBackend !== $oldBackend && !$this->isBackendEnabled($newBackend)) {
$msg = 'CalendarBusinessLayer::update(): User Error: ';
$msg .= 'New backend found but not enabled!';
throw new BusinessLayerException($msg, Http::STATUS_UNPROCESSABLE_ENTITY);
}
if(!$calendar->isValid()) {
if (!$calendar->isValid()) {
$msg = 'CalendarBusinessLayer::update(): User Error: ';
$msg .= 'Given calendar data is not valid!';
throw new BusinessLayerException($msg, Http::STATUS_UNPROCESSABLE_ENTITY);
}
if($oldUserId !== $newUserId) {
if ($oldUserId !== $newUserId) {
return $this->transfer($calendar, array($oldBackend, $oldCalendarURI), $oldUserId);
} else if(!$this->doesCalendarExist(array($newBackend, $newCalendarURI), $newUserId)) {
} else if (!$this->doesCalendarExist(array($newBackend, $newCalendarURI), $newUserId)) {
/** Move a calendar when
* [x] uri and/or backend changed
* [x] new calendar does not exist
*/
return $this->move($calendar, array($oldBackend, $oldCalendarURI), $oldUserId);
} else if(($newBackend !== $oldBackend || $newCalendarURI !== $oldCalendarURI) &&
} else if (($newBackend !== $oldBackend || $newCalendarURI !== $oldCalendarURI) &&
$this->doesCalendarExist(array($newBackend, $newCalendarURI), $newUserId)) {
/** Merge a calendar when
* [x] uri and/or backend changed
@ -492,7 +492,7 @@ class CalendarBusinessLayer extends BusinessLayer {
*/
return $this->merge($calendar, array($oldBackend, $oldCalendarURI), $oldUserId);
} else {
if($this->doesBackendSupport($oldBackend, \OCA\Calendar\Backend\UPDATE_CALENDAR) === true) {
if ($this->doesBackendSupport($oldBackend, \OCA\Calendar\Backend\UPDATE_CALENDAR) === true) {
$api = &$this->backends->find($oldBackend)->api;
$api->updateCalendar($calendar, $oldCalendarURI);
$this->cmp->update($calendar);
@ -533,14 +533,14 @@ class CalendarBusinessLayer extends BusinessLayer {
$oldCalendarObject = $this->find(array($oldBackend, $oldCalendarURI), $oldUserId);
if($oldCtag !== null) {
if($oldCtag < $oldCalendarObject->getCtag()) {
if ($oldCtag !== null) {
if ($oldCtag < $oldCalendarObject->getCtag()) {
$msg = 'CalendarBusinessLayer::updateFromRequest(): User Error: ';
$msg .= 'Send If-Match ctag is outdated!';
throw new BusinessLayerException($msg, Http::STATUS_PRECONDITION_FAILED);
}
}
if($calendar->doesContainNullValues()) {
if ($calendar->doesContainNullValues()) {
$calendar = $oldCalendarObject->overwriteWith($calendar);
}
@ -567,10 +567,10 @@ class CalendarBusinessLayer extends BusinessLayer {
$oldBackendsAPI = &$this->backends->find($oldBackend)->api;
$newBackendsAPI = &$this->backends->find($newBackend)->api;
if($newBackend === $oldBackend && $this->doesBackendSupport($oldBackend, \OCA\Calendar\Backend\MERGE_CALENDAR)) {
if ($newBackend === $oldBackend && $this->doesBackendSupport($oldBackend, \OCA\Calendar\Backend\MERGE_CALENDAR)) {
$newBackendsAPI->mergeCalendar($calendar, $oldCalendarURI, $oldUserId);
} else {
if(!$this->doesBackendSupport($oldBackend, \OCA\Calendar\Backend\DELETE_CALENDAR)) {
if (!$this->doesBackendSupport($oldBackend, \OCA\Calendar\Backend\DELETE_CALENDAR)) {
$msg = 'CalendarBusinessLayer::merge(): User Error: ';
$msg .= 'Backend does not support deleting calendars!';
throw new BusinessLayerException($msg);
@ -613,15 +613,15 @@ class CalendarBusinessLayer extends BusinessLayer {
$oldBackendsAPI = &$this->backends->find($oldBackend)->api;
$newBackendsAPI = &$this->backends->find($newBackend)->api;
if($newBackend === $oldBackend && $this->doesBackendSupport($oldBackend, \OCA\Calendar\Backend\MOVE_CALENDAR)) {
if ($newBackend === $oldBackend && $this->doesBackendSupport($oldBackend, \OCA\Calendar\Backend\MOVE_CALENDAR)) {
$newBackendsAPI->moveCalendar($calendar, $oldCalendarURI, $oldUserId);
} else {
if(!$this->doesBackendSupport($oldBackend, \OCA\Calendar\Backend\DELETE_CALENDAR)) {
if (!$this->doesBackendSupport($oldBackend, \OCA\Calendar\Backend\DELETE_CALENDAR)) {
$msg = 'CalendarBusinessLayer::move(): User Error: ';
$msg .= 'Old backend does not support deleting calendars!';
throw new BusinessLayerException($msg);
}
if(!$this->doesBackendSupport($newBackend, \OCA\Calendar\Backend\CREATE_CALENDAR)) {
if (!$this->doesBackendSupport($newBackend, \OCA\Calendar\Backend\CREATE_CALENDAR)) {
$msg = 'CalendarBusinessLayer::move(): User Error: ';
$msg .= 'New backend does not support creating calendars!';
throw new BusinessLayerException($msg);
@ -715,12 +715,12 @@ class CalendarBusinessLayer extends BusinessLayer {
$calendar = $this->find(array($backend, $calendarURI), $userId);
if(!$this->isBackendEnabled($backend)) {
if (!$this->isBackendEnabled($backend)) {
$msg = 'CalendarBusinessLayer::delete(): User Error: ';
$msg .= 'Backend found but not enabled!';
throw new BusinessLayerException($msg);
}
if(!$this->doesBackendSupport($backend, \OCA\Calendar\Backend\DELETE_CALENDAR)) {
if (!$this->doesBackendSupport($backend, \OCA\Calendar\Backend\DELETE_CALENDAR)) {
$msg = 'CalendarBusinessLayer::delete(): User Error: ';
$msg .= 'Backend does not support deleting calendars!';
throw new BusinessLayerException($msg);
@ -759,13 +759,13 @@ class CalendarBusinessLayer extends BusinessLayer {
return true;
}
if($cctag === $rctag) {
if ($cctag === $rctag) {
return false;
}
if($cctag < $rctag) {
if ($cctag < $rctag) {
return true;
}
if($cctag > $rctag) {
if ($cctag > $rctag) {
//TODO - how to handle this case appropriately?
//could lead to endless updates if backend is sending broken ctag
//setting cached ctag to remote ctag will break client sync
@ -834,28 +834,28 @@ class CalendarBusinessLayer extends BusinessLayer {
$doesCalendarExistCached = $this->doesExist(array($backend, $calendarURI), $userId, false);
$doesCalendarExistRemote = $api->doesCalendarExist($calendarURI, $userId);
if(!$doesCalendarExistCached && !$doesCalendarExistRemote) {
if (!$doesCalendarExistCached && !$doesCalendarExistRemote) {
$msg = 'CalendarBusinessLayer::updateCacheForCalendarFromRemote(): ';
$msg .= '"b:' . $backend . ';u:' . $calendarURI . '" doesn\'t exist';
$msg .= 'Neither cached nor remote!';
throw new DoesNotExistException($msg);
}
if($doesCalendarExistCached) {
if ($doesCalendarExistCached) {
$cachedCalendar = $this->find(array($backend, $calendarURI), $userId);;
}
if($doesCalendarExistRemote) {
if ($doesCalendarExistRemote) {
$remoteCalendar = $api->findCalendar($calendarURI, $userId);
}
if(!$doesCalendarExistRemote) {
if (!$doesCalendarExistRemote) {
$this->obl->deleteAll(array($backend, $calendarURI), $userId);
$this->cmp->delete($cachedCalendar);
return true;
}
if(!$doesCalendarExistCached) {
if($remoteCalendar->isValid() !== true) {
if (!$doesCalendarExistCached) {
if ($remoteCalendar->isValid() !== true) {
$msg = 'CalendarBusinessLayer::updateCacheForCalendarFromRemote(): Backend Error: ';
$msg .= 'Given calendar data is not valid! (b:"' . $backend . '";c:"' . $calendarURI . '")';
throw new BusinessLayerException($msg);
@ -866,23 +866,23 @@ class CalendarBusinessLayer extends BusinessLayer {
return true;
}
if($cachedCalendar == $remoteCalendar) {
if ($cachedCalendar == $remoteCalendar) {
return true;
}
if($api->cacheObjects() && $cachedCalendar->getCtag() < $remoteCalendar->getCtag()) {
if ($api->cacheObjects() && $cachedCalendar->getCtag() < $remoteCalendar->getCtag()) {
$this->obl->updateCacheForCalendarFromRemote(array($backend, $calendarURI), $userId);
}
$this->resetValuesNotSupportedByAPI($remoteCalendar, $remoteAPI);
if($cachedCalendar == $remoteCalendar) {
if ($cachedCalendar == $remoteCalendar) {
return true;
}
$cachedCalendar->overwriteWith($remoteCalendar);
if($cachedCalendar->isValid() !== true) {
if ($cachedCalendar->isValid() !== true) {
$msg = 'CalendarBusinessLayer::updateCacheForCalendarFromRemote(): Backend Error: ';
$msg .= 'Given calendar data is not valid! (b:"' . $backend . '";c:"' . $calendarURI . '")';
throw new BusinessLayerException($msg);
@ -901,19 +901,19 @@ class CalendarBusinessLayer extends BusinessLayer {
* @param \OCA\Calendar\Backend\IBackend $api
*/
private function resetValuesNotSupportedByAPI(Calendar &$calendar, &$api) {
if($api->canStoreColor() === false) {
if ($api->canStoreColor() === false) {
$calendar->setColor(null);
}
if($api->canStoreComponents() === false) {
if ($api->canStoreComponents() === false) {
$calendar->setComponents(null);
}
if($api->canStoreDisplayname() === false) {
if ($api->canStoreDisplayname() === false) {
$calendar->setDisplayname(null);
}
if($api->canStoreEnabled() === false) {
if ($api->canStoreEnabled() === false) {
$calendar->setEnabled(null);
}
if($api->canStoreOrder() === false) {
if ($api->canStoreOrder() === false) {
$calendar->setOrder(null);
}
}

View File

@ -63,7 +63,7 @@ class ObjectBusinessLayer extends BusinessLayer {
$calendarURI = $calendar->getUri();
$userId = $calendar->getUserId();
if($this->isBackendEnabled($backend) !== true) {
if ($this->isBackendEnabled($backend) !== true) {
$msg = 'ObjectBusinessLayer::findAll(): User Error: ';
$msg .= 'Backend found but not enabled!';
throw new BusinessLayerException($msg, BusinessLayerException::INTERNAL);
@ -72,14 +72,14 @@ class ObjectBusinessLayer extends BusinessLayer {
$api = &$this->backends->find($backend)->api;
$cacheObjects = $api->cacheObjects($calendarURI, $userId);
if($cacheObjects === true) {
if ($cacheObjects === true) {
$objects = $this->omp->findAll($calendar, $limit, $offset);
} else {
$objects = $api->findObjects($calendar, $limit, $offset);
}
//check if $calendars is a CalendarCollection, if not throw an exception
if(($objects instanceof ObjectCollection) === false) {
if (($objects instanceof ObjectCollection) === false) {
$msg = 'ObjectBusinessLayer::findAll(): Internal Error: ';
$msg .= ($cacheObjects ? 'ObjectCache' : 'Backend') . ' returned unrecognised format!';
throw new BusinessLayerException($msg, BusinessLayerException::INTERNAL);
@ -106,7 +106,7 @@ class ObjectBusinessLayer extends BusinessLayer {
$calendarURI = $calendar->getUri();
$userId = $calendar->getUserId();
if($this->isBackendEnabled($backend) !== true) {
if ($this->isBackendEnabled($backend) !== true) {
$msg = 'ObjectBusinessLayer::findAll(): User Error: ';
$msg .= 'Backend found but not enabled!';
throw new BusinessLayerException($msg);
@ -116,14 +116,14 @@ class ObjectBusinessLayer extends BusinessLayer {
$cacheObjects = $api->cacheObjects($calendarURI, $userId);
//TODO implement
if($cacheObjects === true) {
if ($cacheObjects === true) {
$number = 0;
} else {
$number = 0;
}
//check if number is an integer, if not throw an exception
if(gettype($number) !== 'integer') {
if (gettype($number) !== 'integer') {
$msg = 'CalendarBusinessLayer::numberOfObjects(): Internal Error: ';
$msg .= ($cacheObjects ? 'ObjectCache' : 'Backend') . ' returned unrecognised format!';
throw new BusinessLayerException($msg);
@ -148,7 +148,7 @@ class ObjectBusinessLayer extends BusinessLayer {
$calendarURI = $calendar->getUri();
$userId = $calendar->getUserId();
if($this->isBackendEnabled($backend) !== true) {
if ($this->isBackendEnabled($backend) !== true) {
$msg = 'ObjectBusinessLayer::find(): User Error: ';
$msg .= 'Backend found but not enabled!';
throw new BusinessLayerException($msg);
@ -157,13 +157,13 @@ class ObjectBusinessLayer extends BusinessLayer {
$api = &$this->backends->find($backend)->api;
$cacheObjects = $api->cacheObjects($calendarURI, $userId);
if($cacheObjects === true) {
if ($cacheObjects === true) {
$object = $this->omp->find($calendar, $objectURI);
} else {
$object = $api->findObject($calendar, $objectURI);
}
if(($object instanceof Object) === false) {
if (($object instanceof Object) === false) {
$msg = 'ObjectBusinessLayer::find(): Internal Error: ';
$msg .= ($cacheObjects ? 'ObjectCache' : 'Backend') . ' returned unrecognised format!';
throw new BusinessLayerException($msg);
@ -192,7 +192,7 @@ class ObjectBusinessLayer extends BusinessLayer {
try {
$object = $this->find($calendar, $objectURI);
if($object->getType() !== $type) {
if ($object->getType() !== $type) {
$msg = 'ObjectBusinessLayer::find(): User Error: ';
$msg .= 'Requested object exists but is of different type!';
throw new BusinessLayerException($msg);
@ -224,7 +224,7 @@ class ObjectBusinessLayer extends BusinessLayer {
$calendarURI = $calendar->getUri();
$userId = $calendar->getUserId();
if($this->isBackendEnabled($backend) !== true) {
if ($this->isBackendEnabled($backend) !== true) {
$msg = 'ObjectBusinessLayer::findAllByType(): User Error: ';
$msg .= 'Backend found but not enabled!';
throw new BusinessLayerException($msg);
@ -233,26 +233,26 @@ class ObjectBusinessLayer extends BusinessLayer {
$api = &$this->backends->find($backend)->api;
$cacheObjects = $api->cacheObjects($calendarURI, $userId);
if($cacheObjects === true) {
if ($cacheObjects === true) {
$objects = $this->omp->findAllByType($calendar, $type, $limit, $offset);
} else {
$api = &$this->backends->find($backend)->api;
$doesBackendSupport = $this->doesBackendSupport($backend, \OCA\Calendar\Backend\FIND_OBJECTS_BY_TYPE);
if($doesBackendSupport === true) {
if ($doesBackendSupport === true) {
$objects = $api->findObjectsByType($calendar, $type, $limit, $offset);
} else {
//TODO - don't query for all
//query for subsets until we've got what we want
$objects = $api->findObjects($calendar);
if($objects instanceof ObjectCollection) {
if ($objects instanceof ObjectCollection) {
$objects = $objects->byType($type)->subset($limit, $offset);
}
}
}
//check if $objects is a ObjectCollection, if not throw an exception
if(($objects instanceof ObjectCollection) === false) {
if (($objects instanceof ObjectCollection) === false) {
$msg = 'ObjectBusinessLayer::findAllByType(): Internal Error: ';
$msg .= ($cacheObjects ? 'ObjectCache' : 'Backend') . ' returned unrecognised format!';
throw new BusinessLayerException($msg);
@ -283,18 +283,18 @@ class ObjectBusinessLayer extends BusinessLayer {
$calendarURI = $calendar->getUri();
$userId = $calendar->getUserId();
if($this->isBackendEnabled($backend) !== true) {
if ($this->isBackendEnabled($backend) !== true) {
$msg = 'ObjectBusinessLayer::findAllInPeriod(): User Error: ';
$msg .= 'Backend found but not enabled!';
throw new BusinessLayerException($msg);
}
$cacheObjects = $api->cacheObjects($calendarURI, $userId);
if($cacheObjects === true) {
if ($cacheObjects === true) {
$objects = $this->omp->findAllInPeriod($calendar, $start, $end, $limit, $offset);
//check if $objects is a ObjectCollection, if not throw an exception
if(($objects instanceof ObjectCollection) === false) {
if (($objects instanceof ObjectCollection) === false) {
$msg = 'ObjectBusinessLayer::findAllInPeriod(): Internal Error: ';
$msg .= 'ObjectCache returned unrecognised format!';
throw new BusinessLayerException($msg);
@ -303,20 +303,20 @@ class ObjectBusinessLayer extends BusinessLayer {
$api = &$this->backends->find($backend)->api;
$doesBackendSupport = $this->doesBackendSupport($backend, \OCA\Calendar\Backend\FIND_IN_PERIOD);
if($doesBackendSupport === true) {
if ($doesBackendSupport === true) {
$objects = $api->findObjectsInPeriod($calendar, $type, $limit, $offset);
} else {
$objects = $api->findObjects($calendar);
}
//check if $objects is a ObjectCollection, if not throw an exception
if(($objects instanceof ObjectCollection) === false) {
if (($objects instanceof ObjectCollection) === false) {
$msg = 'ObjectBusinessLayer::findAllByType(): Internal Error: ';
$msg .= 'Backend returned unrecognised format!';
throw new BusinessLayerException($msg);
}
if($doesBackendSupport === false) {
if ($doesBackendSupport === false) {
$objects = $objects->inPeriod($start, $end)->subset($limit, $offset);
}
}
@ -350,18 +350,18 @@ class ObjectBusinessLayer extends BusinessLayer {
$calendarURI = $calendar->getUri();
$userId = $calendar->getUserId();
if($this->isBackendEnabled($backend) !== true) {
if ($this->isBackendEnabled($backend) !== true) {
$msg = 'ObjectBusinessLayer::findAllInPeriod(): User Error: ';
$msg .= 'Backend found but not enabled!';
throw new BusinessLayerException($msg);
}
$cacheObjects = $api->cacheObjects($calendarURI, $userId);
if($cacheObjects === true) {
if ($cacheObjects === true) {
$objects = $this->omp->findAllByTypeInPeriod($calendar, $start, $end, $type);
//check if $objects is a ObjectCollection, if not throw an exception
if(($objects instanceof ObjectCollection) === false) {
if (($objects instanceof ObjectCollection) === false) {
$msg = 'ObjectBusinessLayer::findAllByTypeInPeriod(): Internal Error: ';
$msg .= 'ObjectCache returned unrecognised format!';
throw new BusinessLayerException($msg);
@ -370,20 +370,20 @@ class ObjectBusinessLayer extends BusinessLayer {
$api = &$this->backends->find($backend)->api;
$doesBackendSupport = $this->doesBackendSupport($backend, \OCA\Calendar\Backend\FIND_IN_PERIOD_BY_TYPE);
if($doesBackendSupport === true) {
if ($doesBackendSupport === true) {
$objects = $api->findObjectsByTypeInPeriod($calendar, $start, $end, $type);
} else {
$objects = $api->findObjects($calendar);
}
//check if $objects is a ObjectCollection, if not throw an exception
if(($objects instanceof ObjectCollection) === false) {
if (($objects instanceof ObjectCollection) === false) {
$msg = 'ObjectBusinessLayer::findAllByType(): Internal Error: ';
$msg .= 'Backend returned unrecognised format!';
throw new BusinessLayerException($msg);
}
if($doesBackendSupport === false) {
if ($doesBackendSupport === false) {
$objects = $objects->byType($type)->inPeriod($start, $end)->subset($limit, $offset);
}
}
@ -408,29 +408,29 @@ class ObjectBusinessLayer extends BusinessLayer {
$calendarURI = $object->calendar->getUri();
$objectURI = $object->getObjectURI();
if($this->isBackendEnabled($backend) !== true) {
if ($this->isBackendEnabled($backend) !== true) {
$msg = 'ObjectBusinessLayer::create(): User Error: ';
$msg .= 'Backend found but not enabled!';
throw new BusinessLayerException($msg);
}
//validate that calendar exists
if($this->doesObjectExist($calendarId, $objectURI, $userId) !== false) {
if ($this->doesObjectExist($calendarId, $objectURI, $userId) !== false) {
$msg = 'ObjectBusinessLayer::create(): User Error: ';
$msg .= 'Object already exists!';
throw new BusinessLayerException($msg);
}
if($this->doesBackendSupport($backend, \OCA\Calendar\Backend\CREATE_OBJECT) !== true) {
if ($this->doesBackendSupport($backend, \OCA\Calendar\Backend\CREATE_OBJECT) !== true) {
$msg = 'ObjectBusinessLayer::create(): User Error: ';
$msg .= 'Backend does not support creating objects!';
throw new BusinessLayerException($msg);
}
if($object->isValid() !== true) {
if ($object->isValid() !== true) {
//try to fix the object
$object->fix();
//check again
if($object->isValid() !== true) {
if ($object->isValid() !== true) {
$msg = 'ObjectBusinessLayer::create(): User Error: ';
$msg .= 'Given object data is not valid and not fixable';
throw new BusinessLayerException($msg);
@ -440,7 +440,7 @@ class ObjectBusinessLayer extends BusinessLayer {
$api->createObject($object, $calendarURI, $objectURI, $userId);
$cacheObjects = $api->cacheObjects($calendarURI, $userId);
if($cacheObjects === true) {
if ($cacheObjects === true) {
$this->omp->insert($object, $calendarURI, $objectURI, $userId);
}
@ -469,20 +469,20 @@ class ObjectBusinessLayer extends BusinessLayer {
*/
public function update(Object &$object, Calendar &$calendar, $objectURI) {
try {
if(is_array($calendarId)) {
if (is_array($calendarId)) {
$backend = $calendarId[0];
$calendarURI = $calendarId[1];
} else {
list($backend, $calendarURI) = $this->splitCalendarURI($calendarId);
}
if($this->isBackendEnabled($backend) !== true) {
if ($this->isBackendEnabled($backend) !== true) {
$msg = 'ObjectBusinessLayer::findAllByType(): User Error: ';
$msg .= 'Backend found but not enabled!';
throw new BusinessLayerException($msg);
}
if($object->getBackend() !== $backend || $object->getUri() !== $calendarURI) {
if ($object->getBackend() !== $backend || $object->getUri() !== $calendarURI) {
return $this->move($object, $calendarId, $objectURI, $userId);
}
@ -490,13 +490,13 @@ class ObjectBusinessLayer extends BusinessLayer {
$api = &$this->backends->find($backend)->api;
if($object->isValid() === false) {
if ($object->isValid() === false) {
$object->fix();
}
$object = $api->updateObject($object, $calendarURI, $objectURI, $userId);
$cacheObjects = $api->cacheObjects($calendarURI, $userId);
if($cacheObjects) {
if ($cacheObjects) {
$this->omp->update($object, $calendarURI, $objectURI, $userId);
}
@ -514,7 +514,7 @@ class ObjectBusinessLayer extends BusinessLayer {
public function updateFromRequest(Object $object, Calendar &$calendar, $objectURI, $etag) {
$oldObject = $this->find($calendar, $objectURI);
if($oldObject->getEtag() !== $etag) {
if ($oldObject->getEtag() !== $etag) {
$msg = 'ObjectBusinessLayer::updateFromRequest(): User Error: ';
$msg .= 'If-Match failed; etags are not equal!';
throw new BusinessLayerException($msg, Http::STATUS_PRECONDITION_FAILED);
@ -533,7 +533,7 @@ class ObjectBusinessLayer extends BusinessLayer {
*/
public function delete(Calendar $calendar, $objectURI, $userId) {
try {
if(is_array($calendarId)) {
if (is_array($calendarId)) {
$backend = $calendarId[0];
$calendarURI = $calendarId[1];
} else {
@ -548,7 +548,7 @@ class ObjectBusinessLayer extends BusinessLayer {
$api = &$this->backends->find($backend)->api;
$api->deleteObject($calendarURI, $objectURI, $userId);
if($api->cacheObjects($calendarURI, $userId)) {
if ($api->cacheObjects($calendarURI, $userId)) {
$this->omp->delete($calendar);
}
@ -573,7 +573,7 @@ class ObjectBusinessLayer extends BusinessLayer {
*/
public function move($object, Calendar $calendar, $objectURI, $userId) {
try {
if(is_array($calendarId)) {
if (is_array($calendarId)) {
$backend = $calendarId[0];
$calendarURI = $calendarId[1];
} else {
@ -599,14 +599,14 @@ class ObjectBusinessLayer extends BusinessLayer {
$doesBackendSupportMovingEvents = $oldBackendsAPI->implementsActions(\OCA\Calendar\Backend\MOVE_OBJECT);
if($oldBackend == $newBackend && $doesBackendSupportMovingEvents === true) {
if ($oldBackend == $newBackend && $doesBackendSupportMovingEvents === true) {
$object = $newBackendsAPI->moveObject($object, $calendarURI, $objectURI, $userId);
} else {
$this->checkBackendSupports($oldBackend, \OCA\Calendar\Backend\DELETE_OBJECT);
$this->checkBackendSupports($newBackend, \OCA\Calendar\Backend\CREATE_OBJECT);
$status = $newBackendsAPI->createObject($object);
if($status === true) {
if ($status === true) {
$object = $this->backends->find($object->getBackend())->api->createObject();
} else {
throw new BusinessLayerException('Could not move object to another calendar.');
@ -614,13 +614,13 @@ class ObjectBusinessLayer extends BusinessLayer {
}
$cacheObjectsInOldBackend = $oldBackendsAPI->cacheObjects($calendarURI, $userId);
if($cacheObjectsInOldBackend === true) {
if ($cacheObjectsInOldBackend === true) {
//dafuq
$this->omp->delete($object, $calendarURI, $objectURI, $userId);
}
$cacheObjectsInNewBackend = $newBackendsAPI->cacheObjects($calendarURI, $userId);
if($cacheObjectsInNewBackend === true) {
if ($cacheObjectsInNewBackend === true) {
//dafuq
$this->omp->create($object, $object->getCalendarUri(), $object->getObjectUri(), $userId);
}
@ -637,12 +637,12 @@ class ObjectBusinessLayer extends BusinessLayer {
}
public function moveAll() {
/*if($this->doesBackendSupport($oldBackend, \OCA\Calendar\Backend\DELETE_OBJECT) !== true) {
/*if ($this->doesBackendSupport($oldBackend, \OCA\Calendar\Backend\DELETE_OBJECT) !== true) {
$msg = 'CalendarBusinessLayer::update(): User Error: ';
$msg .= 'Backend does not support deleting objects!';
throw new BusinessLayerException($msg);
}
if($this->doesBackendSupport($newBackend, \OCA\Calendar\Backend\CREATE_OBJECT) !== true) {
if ($this->doesBackendSupport($newBackend, \OCA\Calendar\Backend\CREATE_OBJECT) !== true) {
$msg = 'CalendarBusinessLayer::update(): User Error: ';
$msg .= 'Backend does not support creating objects!';
throw new BusinessLayerException($msg);
@ -663,7 +663,7 @@ class ObjectBusinessLayer extends BusinessLayer {
*/
public function touch(Calendar $calendar, $objectURI, $userId) {
try {
if(is_array($calendarId)) {
if (is_array($calendarId)) {
$backend = $calendarId[0];
$calendarURI = $calendarId[1];
} else {
@ -692,7 +692,7 @@ class ObjectBusinessLayer extends BusinessLayer {
* @throws BusinessLayerException if uri is already taken
*/
private function allowNoObjectURITwice($backend, $calendarURI, $objectURI, $userId){
if($this->isObjectURIAvailable($backend, $calendarURI, $objectURI, $userId, true) === false) {
if ($this->isObjectURIAvailable($backend, $calendarURI, $objectURI, $userId, true) === false) {
throw new BusinessLayerException('Can not add object: UID already exists');
}
}
@ -707,13 +707,13 @@ class ObjectBusinessLayer extends BusinessLayer {
*/
private function isObjectURIAvailable($backend, $calendarURI, $objectURI, $userId, $checkRemote=false) {
$existingObjects = $this->omp->find($backend, $calendarURI, $objectURI, $userId);
if(count($existingObjects) !== 0) {
if (count($existingObjects) !== 0) {
return false;
}
if($checkRemote === true) {
if ($checkRemote === true) {
$existingRemoteObjects = $this->backends->find($backend)->api->findObject($calendarURI, $objectURI, $userId);
if(count($existingRemoteObjects) !== 0) {
if (count($existingRemoteObjects) !== 0) {
return false;
}
}
@ -728,7 +728,7 @@ class ObjectBusinessLayer extends BusinessLayer {
*/
public function updateCacheForCalendarFromRemote($calendarId, $userId=null) {
try{
if(is_array($calendarId)) {
if (is_array($calendarId)) {
$backend = $calendarId[0];
$calendarURI = $calendarId[1];
} else {
@ -750,7 +750,7 @@ class ObjectBusinessLayer extends BusinessLayer {
*/
public function updateCacheForObjectFromRemote($calendarId, $objectURI, $userId) {
try{
if(is_array($calendarId)) {
if (is_array($calendarId)) {
$backend = $calendarId[0];
$calendarURI = $calendarId[1];
} else {
@ -762,14 +762,14 @@ class ObjectBusinessLayer extends BusinessLayer {
$doesObjectExistCached = $this->doesExist(array($backend, $calendarURI), $objectURI, $userId, false);
$doesObjectExistRemote = $remoteAPI->doesObjectExist($calendarURI, $objectURI, $userId);
if($doesObjectExistCached === false && $doesObjectExistRemote === false) {
if ($doesObjectExistCached === false && $doesObjectExistRemote === false) {
$msg = 'ObjectBusinessLayer::updateCacheForObjectFromRemote(): ';
$msg .= '"b:' . $backend . ';cu:' . $calendarURI . ';ou:' . $objectURI . '" doesn\'t exist';
$msg .= 'Neither cached nor remote!';
throw new DoesNotExistException($msg);
}
if($doesObjectExistRemote === false) {
if ($doesObjectExistRemote === false) {
$msg = 'ObjectBusinessLayer::updateCacheForObjectFromRemote(): ';
$msg .= 'Object vanished from remote - removing object from cache!';
//TODO - log debug message
@ -782,7 +782,7 @@ class ObjectBusinessLayer extends BusinessLayer {
$remoteObject = $remoteAPI->findObject($calendarURI, $objectURI, $userId);
if($doesCalendarExistCached === false) {
if ($doesCalendarExistCached === false) {
$msg = 'ObjectBusinessLayer::updateCacheForObjectFromRemote(): ';
$msg .= 'Object not cached - creating object from remote!';
//TODO - log debug message
@ -791,11 +791,11 @@ class ObjectBusinessLayer extends BusinessLayer {
return true;
}
if($cachedObject === null) {
if ($cachedObject === null) {
$cachedObject = $this->find(array($backend, $calendarURI), $objectURI, $userId);
}
if($cachedObject->getEtag() === $remoteObject->getEtag()) {
if ($cachedObject->getEtag() === $remoteObject->getEtag()) {
return true;
}

View File

@ -36,7 +36,7 @@ class CalendarController extends Controller {
$userId = $this->api->getUserId();
$nolimit = $this->params('nolimit', false);
if($nolimit) {
if ($nolimit) {
$limit = $offset = null;
} else {
$limit = $this->params('limit', 25);
@ -87,10 +87,10 @@ class CalendarController extends Controller {
$calendar = $reader->sanitize()->getObject();
if($calendar instanceof Calendar) {
if ($calendar instanceof Calendar) {
$calendar = $this->calendarBusinessLayer->createFromRequest($calendar);
$serializer = new Serializer(Serializer::Calendar, $calendar, $this->accept());
} elseif($calendar instanceof CalendarCollection) {
} elseif ($calendar instanceof CalendarCollection) {
$calendar = $this->calendarBusinessLayer->createCollectionFromRequest($calendar);
$serializer = new serializer(Serializer::CalendarCollection, $calendar, $this->accept());
} else {
@ -122,9 +122,9 @@ class CalendarController extends Controller {
$reader = new Reader(Reader::Calendar, $data, $this->contentType());
$calendar = $reader->sanitize()->getObject();
if($calendar instanceof Calendar) {
if ($calendar instanceof Calendar) {
$calendar = $this->calendarBusinessLayer->updateFromRequest($calendar, $calendarId, $userId, $ctag);
} elseif($calendar instanceof CalendarCollection) {
} elseif ($calendar instanceof CalendarCollection) {
throw new ReaderException('Updates can only be applied to a single resource.', Http::STATUS_BAD_REQUEST);
} else {
throw new ReaderException('Reader returned unrecognised format.');

View File

@ -52,10 +52,10 @@ abstract class Controller extends \OCP\AppFramework\Controller {
$this->app = $app;
$this->api = $app->getCoreApi();
if($calendarBusinessLayer instanceof CalendarBusinessLayer) {
if ($calendarBusinessLayer instanceof CalendarBusinessLayer) {
$this->calendarBusinessLayer = $calendarBusinessLayer;
}
if($objectBusinessLayer instanceof ObjectBusinessLayer) {
if ($objectBusinessLayer instanceof ObjectBusinessLayer) {
$this->objectBusinessLayer = $objectBusinessLayer;
}
}
@ -69,7 +69,7 @@ abstract class Controller extends \OCP\AppFramework\Controller {
*/
public function params($key, $default=null){
$value = parent::params($key, $default);
if($default !== null) {
if ($default !== null) {
settype($value, gettype($default));
}
return $value;
@ -87,11 +87,11 @@ abstract class Controller extends \OCP\AppFramework\Controller {
$key = str_replace('-', '_', $key);
if(isset($this->request->server[$key]) === false) {
if (isset($this->request->server[$key]) === false) {
return $default;
} else {
$value = $this->request->server[$key];
if(strtolower($type) === 'datetime') {
if (strtolower($type) === 'datetime') {
$value = \DateTime::createFromFormat(\DateTime::ISO8601);
} else {
settype($value, $type);
@ -104,10 +104,10 @@ abstract class Controller extends \OCP\AppFramework\Controller {
protected function accept() {
$accept = $this->header('accept');
if(substr_count($accept, ',')) {
if (substr_count($accept, ',')) {
list($accept) = explode(',', $accept);
}
if(substr_count($accept, ';')) {
if (substr_count($accept, ';')) {
list($accept) = explode(';', $accept);
}
@ -118,7 +118,7 @@ abstract class Controller extends \OCP\AppFramework\Controller {
protected function contentType() {
$contentType = $this->header('content-type');
if(substr_count($contentType, ';')) {
if (substr_count($contentType, ';')) {
list($contentType) = explode(';', $contentType);
}

View File

@ -36,7 +36,7 @@ class ObjectController extends Controller {
$calendarId = $this->params('calendarId');
$nolimit = $this->params('nolimit', false);
if($nolimit) {
if ($nolimit) {
$limit = $offset = null;
} else {
$limit = $this->params('limit', 25);
@ -44,7 +44,7 @@ class ObjectController extends Controller {
}
$calendar = $this->calendarBusinessLayer->find($calendarId, $userId);
if(!$calendar->doesAllow(Permissions::READ)) {
if (!$calendar->doesAllow(Permissions::READ)) {
return new Response(null, HTTP::STATUS_FORBIDDEN);
}
@ -71,7 +71,7 @@ class ObjectController extends Controller {
$calendarId = $this->params('calendarId');
$nolimit = $this->params('nolimit', false);
if($nolimit) {
if ($nolimit) {
$limit = $offset = null;
} else {
$limit = $this->params('limit', 25);
@ -82,7 +82,7 @@ class ObjectController extends Controller {
$end = $this->params('end', new DateTime(date('Y-m-t')));
$calendar = $this->calendarBusinessLayer->find($calendarId, $userId);
if(!$calendar->doesAllow(Permissions::READ)) {
if (!$calendar->doesAllow(Permissions::READ)) {
return new Response(null, HTTP::STATUS_FORBIDDEN);
}
@ -111,7 +111,7 @@ class ObjectController extends Controller {
$objectURI = $this->params('objectId');
$calendar = $this->calendarBusinessLayer->find($calendarId, $userId);
if(!$calendar->doesAllow(Permissions::READ)) {
if (!$calendar->doesAllow(Permissions::READ)) {
return new Response(null, HTTP::STATUS_FORBIDDEN);
}
@ -139,24 +139,24 @@ class ObjectController extends Controller {
$data = $this->request->params;
$calendar = $this->calendarBusinessLayer->find($calendarId, $userId);
if(!$calendar->doesAllow(Permissions::CREATE)) {
if (!$calendar->doesAllow(Permissions::CREATE)) {
return new Response(null, HTTP::STATUS_FORBIDDEN);
}
$reader = new Reader(Reader::Object, $data, $this->contentType());
$object = $reader->sanitize()->getObject()->setCalendar($calendar);
if($object instanceof Object) {
if ($object instanceof Object) {
$object = $this->objectBusinessLayer->createFromRequest($object);
$serializer = new Serializer(Serializer::$object, $object, $this->accept());
} elseif($object instanceof ObjectCollection) {
} elseif ($object instanceof ObjectCollection) {
$object = $this->objectBusinessLayer->createCollectionFromRequest($object);
$serializer = new serializer(Serializer::ObjectCollection, $object, $this->accept());
} else {
throw new ReaderException('Reader returned unrecognised format.');
}
if(!$calendar->doesAllow(Permissions::READ)) {
if (!$calendar->doesAllow(Permissions::READ)) {
return new Response(null, HTTP::STATUS_NO_CONTENT);
}
@ -181,22 +181,22 @@ class ObjectController extends Controller {
$data = $this->request->params;
$calendar = $this->calendarBusinessLayer->find($calendarId, $userId);
if(!$calendar->doesAllow(Permissions::UPDATE)) {
if (!$calendar->doesAllow(Permissions::UPDATE)) {
return new Response(null, HTTP::STATUS_FORBIDDEN);
}
$reader = new Reader(Reader::Object, $data, $this->contentType());
$object = $reader->sanitize()->getObject()->setCalendar($calendar);
if($object instanceof Object) {
if ($object instanceof Object) {
$object = $this->objectBusinessLayer->updateFromRequest($object, $calendar, $objectURI, $etag);
} elseif($object instanceof ObjectCollection) {
} elseif ($object instanceof ObjectCollection) {
throw new ReaderException('Updates can only be applied to a single resource.', Http::STATUS_BAD_REQUEST);
} else {
throw new ReaderException('Reader returned unrecognised format.');
}
if(!$calendar->doesAllow(Permissions::READ)) {
if (!$calendar->doesAllow(Permissions::READ)) {
return new Response(null, HTTP::STATUS_NO_CONTENT);
}
@ -220,7 +220,7 @@ class ObjectController extends Controller {
$objectURI = $this->params('objectId');
$calendar = $this->calendarBusinessLayer->find($calendarId, $userId);
if(!$calendar->doesAllow(Permissions::DELETE)) {
if (!$calendar->doesAllow(Permissions::DELETE)) {
return new Response(null, HTTP::STATUS_FORBIDDEN);
}

View File

@ -69,7 +69,7 @@ abstract class ObjectTypeController extends ObjectController {
$calendarId = $this->params('calendarId');
$nolimit = $this->params('nolimit', false);
if($nolimit) {
if ($nolimit) {
$limit = $offset = null;
} else {
$limit = $this->params('limit', 25);
@ -82,7 +82,7 @@ abstract class ObjectTypeController extends ObjectController {
$type = $this->objectType;
$calendar = $this->calendarBusinessLayer->find($calendarId, $userId);
if($calendar->doesAllow(Permissions::READ) === false) {
if ($calendar->doesAllow(Permissions::READ) === false) {
throw new ForbiddenExpcetion();
}
@ -108,7 +108,7 @@ abstract class ObjectTypeController extends ObjectController {
$calendarId = $this->params('calendarId');
$nolimit = $this->params('nolimit', false);
if($nolimit) {
if ($nolimit) {
$limit = $offset = null;
} else {
$limit = $this->params('limit', 25);
@ -121,7 +121,7 @@ abstract class ObjectTypeController extends ObjectController {
$type = $this->objectType;
$calendar = $this->calendarBusinessLayer->find($calendarId, $userId);
if(!$calendar->doesAllow(Permissions::READ)) {
if (!$calendar->doesAllow(Permissions::READ)) {
return new Response(null, HTTP::STATUS_FORBIDDEN);
}
@ -152,7 +152,7 @@ abstract class ObjectTypeController extends ObjectController {
$type = $this->objectType;
$calendar = $this->calendarBusinessLayer->find($calendarId, $userId);
if(!$calendar->doesAllow(Permissions::READ)) {
if (!$calendar->doesAllow(Permissions::READ)) {
return new Response(null, HTTP::STATUS_FORBIDDEN);
}

View File

@ -52,7 +52,7 @@ class SubscriptionController extends Controller {
public function index() {
$userId = $this->api->getUserId();
$nolimit = $this->params('nolimit', false);
if($nolimit) {
if ($nolimit) {
$limit = $offset = null;
} else {
$limit = $this->params('limit', 25);

View File

@ -53,7 +53,7 @@ class TimezoneController extends Controller {
*/
public function index() {
$nolimit = $this->params('nolimit', false);
if($nolimit) {
if ($nolimit) {
$limit = $offset = null;
} else {
$limit = $this->params('limit', 25);

View File

@ -25,7 +25,7 @@ class Backend extends Entity {
* @param array $fromRow
*/
public function __construct($fromRow=null){
if(is_array($fromRow)){
if (is_array($fromRow)){
$this->fromRow($fromRow);
}
@ -83,29 +83,29 @@ class Backend extends Entity {
* @return boolean
*/
public function isValid() {
if(is_string($this->backend) === false) {
if (is_string($this->backend) === false) {
return false;
}
if(trim($this->backend) === '') {
if (trim($this->backend) === '') {
return false;
}
if(is_string($this->classname) === false) {
if (is_string($this->classname) === false) {
return false;
}
if(class_exists($this->classname) === false) {
if (class_exists($this->classname) === false) {
return false;
}
if(is_array($this->arguments) === false && $this->arguments !== null) {
if (is_array($this->arguments) === false && $this->arguments !== null) {
return false;
}
if(is_bool($this->enabled) === false) {
if (is_bool($this->enabled) === false) {
return false;
}
if(($this->api instanceof IBackend) === false && $this->api !== null) {
if (($this->api instanceof IBackend) === false && $this->api !== null) {
return false;
}

View File

@ -29,7 +29,7 @@ class BackendMapper extends Mapper {
$this->configName = $configName;
$backends = \OCP\Config::getSystemValue($configName);
if($backends === null) {
if ($backends === null) {
$backends = $api->query('fallbackBackendConfig');
}
@ -50,7 +50,7 @@ class BackendMapper extends Mapper {
* @param API $api: Instance of the API abstraction layer
*/
public function __destruct() {
if($this->didChange === true) {
if ($this->didChange === true) {
$newConfig = $this->backendCollection->getObjects();
//\OCP\Config::setSystemValue($this->configName, $newConfig);
}

View File

@ -53,12 +53,12 @@ class Calendar extends Entity {
$this->setEnabled(true);
//create from array
if(is_array($createFrom)){
if (is_array($createFrom)){
$this->fromRow($createFrom);
}
//create from VCalendar
if($createFrom instanceof VCalendar) {
if ($createFrom instanceof VCalendar) {
$this->fromVObject($createFrom);
}
}
@ -70,17 +70,17 @@ class Calendar extends Entity {
* @return $this
*/
public function fromVObject(VCalendar $vcalendar) {
if(isset($vcalendar->{'X-WR-CALNAME'})) {
if (isset($vcalendar->{'X-WR-CALNAME'})) {
$this->setDisplayname($vcalendar->{'X-WR-CALNAME'});
}
if(isset($vcalendar->{'X-WR-TIMEZONE'})) {
if (isset($vcalendar->{'X-WR-TIMEZONE'})) {
try {
$this->setTimezone(new Timezone($vcalendar->{'X-WR-TIMEZONE'}));
} catch(\Exception $ex) {}
}
if(isset($calendar->{'X-APPLE-CALENDAR-COLOR'})) {
if (isset($calendar->{'X-APPLE-CALENDAR-COLOR'})) {
$this->setColor($vcalendar->{'X-APPLE-CALENDAR-COLOR'});
}
@ -129,7 +129,7 @@ class Calendar extends Entity {
* @brief set uri property
*/
public function setURI($uri) {
if(is_string($uri) === false || trim($uri) === '') {
if (is_string($uri) === false || trim($uri) === '') {
return null;
}
@ -152,7 +152,7 @@ class Calendar extends Entity {
* @return string
*/
public function getCalendarId(){
if(!property_exists($this, 'backend') || !property_exists($this, 'uri')) {
if (!property_exists($this, 'backend') || !property_exists($this, 'uri')) {
$msg = 'getCalendarId is not applicable to this kind of object';
throw new \BadFunctionCallException($msg);
}
@ -174,14 +174,14 @@ class Calendar extends Entity {
* false if calendarId could not be set
*/
public function setCalendarId($calendarId) {
if(!property_exists($this, 'backend') || !property_exists($this, 'uri')) {
if (!property_exists($this, 'backend') || !property_exists($this, 'uri')) {
$msg = 'setCalendarId is not applicable to this kind of object';
throw new \BadFunctionCallException($msg);
}
list($backend, $calendarURI) = CalendarUtility::splitURI($calendarId);
if($backend !== false && $calendarURI !== false) {
if ($backend !== false && $calendarURI !== false) {
$this->backend = $backend;
$this->uri = $calendarURI;
@ -206,10 +206,10 @@ class Calendar extends Entity {
);
foreach($strings as $string) {
if(is_string($string) === false) {
if (is_string($string) === false) {
return false;
}
if(trim($string) === '') {
if (trim($string) === '') {
return false;
}
}
@ -222,10 +222,10 @@ class Calendar extends Entity {
);
foreach($uInts as $integer) {
if(is_int($integer) === false) {
if (is_int($integer) === false) {
return false;
}
if($integer < 0) {
if ($integer < 0) {
return false;
}
}
@ -235,28 +235,28 @@ class Calendar extends Entity {
);
foreach($booleans as $boolean) {
if(is_bool($boolean) === false) {
if (is_bool($boolean) === false) {
return false;
}
}
if(preg_match('/[A-Za-z0-9]+/', $this->uri) !== 1) {
if (preg_match('/[A-Za-z0-9]+/', $this->uri) !== 1) {
return false;
}
if(preg_match('/#((?:[0-9a-fA-F]{2}){3}|(?:[0-9a-fA-F]{1}){3}|(?:[0-9a-fA-F]{1}){4}|(?:[0-9a-fA-F]{2}){4})$/', $this->color) !== 1) {
if (preg_match('/#((?:[0-9a-fA-F]{2}){3}|(?:[0-9a-fA-F]{1}){3}|(?:[0-9a-fA-F]{1}){4}|(?:[0-9a-fA-F]{2}){4})$/', $this->color) !== 1) {
return false;
}
if($this->components > ObjectType::ALL) {
if ($this->components > ObjectType::ALL) {
return false;
}
if($this->cruds > Permissions::ALL) {
if ($this->cruds > Permissions::ALL) {
return false;
}
if($this->timezone instanceof Timezone && $this->timezone->isValid() === false) {
if ($this->timezone instanceof Timezone && $this->timezone->isValid() === false) {
return false;
}

View File

@ -45,7 +45,7 @@ class CalendarCollection extends Collection {
$newCollection = new CalendarCollection();
$this->iterate(function($object) use (&$newCollection, $component) {
if($object->getComponents() & $component) {
if ($object->getComponents() & $component) {
$newCollection->add(clone $object);
}
});
@ -62,7 +62,7 @@ class CalendarCollection extends Collection {
$newCollection = new CalendarCollection();
$this->iterate(function($object) use (&$newCollection, $cruds) {
if($object->getCruds() & $cruds) {
if ($object->getCruds() & $cruds) {
$newCollection->add(clone $object);
}
});
@ -76,7 +76,7 @@ class CalendarCollection extends Collection {
$this->iterate(function($object) use (&$filteredCalendars, $objects) {
foreach($objects as $backend) {
if($object->getBackend() === $backend->getBackend()) {
if ($object->getBackend() === $backend->getBackend()) {
$filteredCalendars->add(clone $object);
}
}

View File

@ -113,7 +113,7 @@ class CalendarMapper extends Mapper {
$row = $this->findOneQuery($sql, array($backend, $calendarURI, $userId));
$count = intval($row['count']);
if($count === 0) {
if ($count === 0) {
return false;
} else {
return true;
@ -136,7 +136,7 @@ class CalendarMapper extends Mapper {
$row = $this->findOneQuery($sql, array($cruds, $backend, $calendarURI, $userId));
$count = intval($row['count']);
if($count === 0) {
if ($count === 0) {
return false;
} else {
return true;
@ -159,7 +159,7 @@ class CalendarMapper extends Mapper {
$row = $this->findOneQuery($sql, array($component, $backend, $calendarURI, $userId));
$count = intval($row['count']);
if($count === 0) {
if ($count === 0) {
return false;
} else {
return true;

View File

@ -26,13 +26,13 @@ abstract class Collection {
public function __construct($objects=null) {
$this->objects = array();
if($objects !== null) {
if ($objects !== null) {
if(is_array($objects) === true) {
if (is_array($objects) === true) {
$this->objects = $objects;
} else if($objects instanceof Entity) {
} else if ($objects instanceof Entity) {
$this->add($objects);
} else if($objects instanceof Collection) {
} else if ($objects instanceof Collection) {
$this->addCollection($objects);
}
@ -46,7 +46,7 @@ abstract class Collection {
* @return integer
*/
public function add(Entity $object, $nth=null) {
if($nth === null) {
if ($nth === null) {
$nth = $this->count();
}
for($i = $this->count(); $i > $nth; $i--) {
@ -63,7 +63,7 @@ abstract class Collection {
* @return integer
*/
public function addCollection(Collection $objects, $nth=null) {
if($nth === null) {
if ($nth === null) {
$nth = $this->count();
}
$numberOfNewEntities = $objects->count();
@ -83,7 +83,7 @@ abstract class Collection {
* @return
*/
public function remove($nth=null) {
if($nth === null){
if ($nth === null){
$nth = $this->key();
}
unset($this->objects[$nth]);
@ -99,7 +99,7 @@ abstract class Collection {
for($i = 0; $i < $this->count(); $i++) {
//use of (==) instead of (===) is intended!
//see http://php.net/manual/en/language.oop5.object-comparison.php
if($this->objects[$i] == $entity) {
if ($this->objects[$i] == $entity) {
unset($this->objects[($i--)]);
}
}
@ -117,7 +117,7 @@ abstract class Collection {
$propertyGetter = 'get' . ucfirst($key);
for($i = 0; $i < $this->count(); $i++) {
if(is_callable(array($this->objects[$i], $propertyGetter)) && $object->{$propertyGetter}() === $value) {
if (is_callable(array($this->objects[$i], $propertyGetter)) && $object->{$propertyGetter}() === $value) {
unset($this->objects[($i--)]);
}
}
@ -187,7 +187,7 @@ abstract class Collection {
* @return mixed (single Entity) or null
*/
public function get($nth) {
if(array_key_exists($nth, $this->objects)) {
if (array_key_exists($nth, $this->objects)) {
return $this->objects[$nth];
} else {
return null;
@ -211,17 +211,17 @@ abstract class Collection {
public function subset($limit=null, $offset=null) {
$class = get_class($this);
if($offset === null) {
if ($offset === null) {
$offset = 0;
}
if($limit === null) {
if ($limit === null) {
return $this;
} else {
$subset = new $class();
for($i = $offset; $i < ($offset + $limit); $i++) {
if(array_key_exists($i, $this->objects)) {
if (array_key_exists($i, $this->objects)) {
$subset->add($this->objects[$i]);
}
}
@ -253,7 +253,7 @@ abstract class Collection {
$vElement = $object->getVObject();
$children = $vElement->children();
foreach($children as $child) {
if($child instanceof VEvent ||
if ($child instanceof VEvent ||
$child instanceof VJournal ||
$child instanceof VTodo ||
$child->name === 'VTIMEZONE') {
@ -293,7 +293,7 @@ abstract class Collection {
$propertyGetter = 'get' . ucfirst($key);
foreach($this->objects as &$object) {
if(is_callable(array($object, $propertyGetter)) && $object->{$propertyGetter}() === $value) {
if (is_callable(array($object, $propertyGetter)) && $object->{$propertyGetter}() === $value) {
$matchingObjects->add($object);
}
}
@ -315,7 +315,7 @@ abstract class Collection {
$dataGetter = 'get' . ucfirst($dataProperty);
foreach($this->objects as &$object) {
if(is_callable(array($object, $propertyGetter)) && preg_match($regex, $object->{$dataGetter}()) === 1) {
if (is_callable(array($object, $propertyGetter)) && preg_match($regex, $object->{$dataGetter}()) === 1) {
$matchingObjects->add($object);
}
}
@ -333,7 +333,7 @@ abstract class Collection {
$propertySetter = 'set' . ucfirst($key);
foreach($this->objects as &$object) {
if(is_callable(array($object, $propertySetter))) {
if (is_callable(array($object, $propertySetter))) {
$object->{$propertySetter}($value);
}
}
@ -348,7 +348,7 @@ abstract class Collection {
*/
public function isValid() {
foreach($this->objects as &$object) {
if($object->isValid() === false) {
if ($object->isValid() === false) {
return false;
}
}

View File

@ -43,7 +43,7 @@ abstract class Entity {
public function fromRow(array $row){
foreach($row as $key => $value){
$prop = $this->columnToProperty($key);
if($value !== null && array_key_exists($prop, $this->fieldTypes)){
if ($value !== null && array_key_exists($prop, $this->fieldTypes)){
settype($value, $this->fieldTypes[$prop]);
}
$this->$prop = $value;
@ -71,7 +71,7 @@ abstract class Entity {
$setter = 'set' . ucfirst($key);
$newValue = $object->$getter();
if($newValue !== null && $newValue !== $value) {
if ($newValue !== null && $newValue !== $value) {
$this->$setter($newValue);
}
}
@ -90,7 +90,7 @@ abstract class Entity {
foreach($properties as $property) {
$method = 'get' . ucfirst($property);
if($this->$method() === null) {
if ($this->$method() === null) {
return true;
}
}
@ -107,11 +107,11 @@ abstract class Entity {
protected function setter($name, $args) {
// setters should only work for existing attributes
if(property_exists($this, $name)){
if (property_exists($this, $name)){
$this->markFieldUpdated($name);
// if type definition exists, cast to correct type
if($args[0] !== null && array_key_exists($name, $this->fieldTypes)) {
if ($args[0] !== null && array_key_exists($name, $this->fieldTypes)) {
settype($args[0], $this->fieldTypes[$name]);
}
$this->$name = $args[0];
@ -125,7 +125,7 @@ abstract class Entity {
protected function getter($name) {
// getters should only work for existing attributes
if(property_exists($this, $name)){
if (property_exists($this, $name)){
return $this->$name;
} else {
throw new \BadFunctionCallException($name .
@ -143,9 +143,9 @@ abstract class Entity {
public function __call($methodName, $args){
$attr = lcfirst( substr($methodName, 3) );
if(strpos($methodName, 'set') === 0){
if (strpos($methodName, 'set') === 0){
$this->setter($attr, $args);
} elseif(strpos($methodName, 'get') === 0) {
} elseif (strpos($methodName, 'get') === 0) {
return $this->getter($attr);
} else {
throw new \BadFunctionCallException($methodName .
@ -174,7 +174,7 @@ abstract class Entity {
$property = null;
foreach($parts as $part){
if($property === null){
if ($property === null){
$property = $part;
} else {
$property .= ucfirst($part);
@ -195,7 +195,7 @@ abstract class Entity {
$column = null;
foreach($parts as $part){
if($column === null){
if ($column === null){
$column = $part;
} else {
$column .= '_' . lcfirst($part);
@ -233,7 +233,7 @@ abstract class Entity {
*/
public function slugify($attributeName){
// toSlug should only work for existing attributes
if(property_exists($this, $attributeName)){
if (property_exists($this, $attributeName)){
$value = $this->$attributeName;
// replace everything except alphanumeric with a single '-'
$value = preg_replace('/[^A-Za-z0-9]+/', '-', $value);

View File

@ -71,7 +71,7 @@ abstract class Mapper {
$values .= '?';
// only append colon if there are more entries
if($i < count($properties)-1){
if ($i < count($properties)-1){
$columns .= ',';
$values .= ',';
}
@ -100,7 +100,7 @@ abstract class Mapper {
public function update(Entity $entity){
// entity needs an id
$id = $entity->getId();
if($id === null){
if ($id === null){
throw new \InvalidArgumentException(
'Entity which should be updated has no id');
}
@ -112,7 +112,7 @@ abstract class Mapper {
// dont update the id field
unset($properties['id']);
if(count($properties) === 0) {
if (count($properties) === 0) {
return;
}
@ -129,7 +129,7 @@ abstract class Mapper {
$columns .= '`' . $column . '` = ?';
// only append colon if there are more entries
if($i < count($properties)-1){
if ($i < count($properties)-1){
$columns .= ',';
}
@ -159,12 +159,12 @@ abstract class Mapper {
$result = $this->execute($sql, $params);
$row = $result->fetchRow();
if($row === false || $row === null){
if ($row === false || $row === null){
throw new DoesNotExistException('No matching entry found');
}
$row2 = $result->fetchRow();
//MDB2 returns null, PDO and doctrine false when no row is available
if( ! ($row2 === false || $row2 === null )) {
if ( ! ($row2 === false || $row2 === null )) {
throw new MultipleObjectsReturnedException('More than one result');
} else {
return $row;
@ -233,12 +233,12 @@ abstract class Mapper {
$result = $this->execute($sql, $params);
$row = $result->fetchRow();
if($row === false){
if ($row === false){
throw new DoesNotExistException('No matching entry found');
}
$row2 = $result->fetchRow();
//MDB2 returns null, PDO and doctrine false when no row is available
if( ! ($row2 === false || $row2 === null )) {
if ( ! ($row2 === false || $row2 === null )) {
throw new MultipleObjectsReturnedException('More than one result');
} else {
return $this->mapRowToEntity($row);

View File

@ -48,10 +48,10 @@ class Object extends Entity {
$this->addType('etag', 'string');
$this->addType('ruds', 'integer');
if(is_array($fromRow)) {
if (is_array($fromRow)) {
$this->fromRow($fromRow);
}
if($fromRow instanceof VCalendar) {
if ($fromRow instanceof VCalendar) {
$this->fromVObject($fromRow);
}
}
@ -63,8 +63,8 @@ class Object extends Entity {
public function fromRow(array $row) {
foreach($row as $key => $value) {
$prop = $this->columnToProperty($key);
if(property_exists($this, $prop)) {
if($value !== null && array_key_exists($prop, $this->fieldTypes)){
if (property_exists($this, $prop)) {
if ($value !== null && array_key_exists($prop, $this->fieldTypes)){
settype($value, $this->fieldTypes[$prop]);
}
@ -72,7 +72,7 @@ class Object extends Entity {
}
}
if(array_key_exists('calendarData', $row) && trim($row['calendarData'] !== '')) {
if (array_key_exists('calendarData', $row) && trim($row['calendarData'] !== '')) {
$this->setCalendarData($row['calendarData']);
}
@ -125,7 +125,7 @@ class Object extends Entity {
public function fromVObject(VCalendar $vcalendar) {
$count = SabreUtility::countUniqueUIDs($vcalendar);
if($count !== 1) {
if ($count !== 1) {
$msg = 'Db\Object::fromVObject(): ';
$msg .= 'Multiple objects can\'t be stored in one resource.';
throw new MultipleObjectsReturnedException($msg);
@ -142,18 +142,18 @@ class Object extends Entity {
*/
public function getVObject() {
$objectName = $this->objectName;
if(!isset($this->vobject->{$objectName}->{'X-OC-URI'})) {
if (!isset($this->vobject->{$objectName}->{'X-OC-URI'})) {
$uri = new TextProperty($this->vobject, 'X-OC-URI', $this->objectURI);
$this->vobject->{$objectName}->add($uri);
}
if(!isset($this->vobject->{$objectName}->{'X-OC-ETAG'})) {
if($this->etag === null) {
if (!isset($this->vobject->{$objectName}->{'X-OC-ETAG'})) {
if ($this->etag === null) {
$this->generateEtag();
}
$etag = new TextProperty($this->vobject, 'X-OC-ETAG', $this->etag);
$this->vobject->{$objectName}->add($etag);
}
if(!isset($this->vobject->{$objectName}->{'X-OC-RUDS'})) {
if (!isset($this->vobject->{$objectName}->{'X-OC-RUDS'})) {
$ruds = new IntegerProperty($this->vobject, 'X-OC-RUDS', $this->ruds);
$this->vobject->{$objectName}->add($ruds);
}
@ -229,7 +229,7 @@ class Object extends Entity {
public function getRepeating() {
$objectName = $this->objectName;
if(isset($this->vobject->{$objectName}->{'RRULE'}) ||
if (isset($this->vobject->{$objectName}->{'RRULE'}) ||
isset($this->vobject->{$objectName}->{'RDATE'}) ||
isset($this->vobject->{$objectName}->{'RECURRENCE-ID'})) {
return true;
@ -243,7 +243,7 @@ class Object extends Entity {
* @return mixed DateTime/null
*/
public function getLastOccurence() {
if($this->isRepeating() === false) {
if ($this->isRepeating() === false) {
return null;
}
@ -251,16 +251,16 @@ class Object extends Entity {
$lastOccurences = array();
if(isset($this->vobject->{$objectName}->{'RRULE'})) {
if (isset($this->vobject->{$objectName}->{'RRULE'})) {
$rrule = $this->vobject->{$objectName}->{'RRULE'};
//https://github.com/fruux/sabre-vobject/wiki/Sabre-VObject-Property-Recur
$parts = $rrule->getParts();
if(!array_key_exists('COUNT', $parts) && array_key_exists('UNTIL', $parts)) {
if (!array_key_exists('COUNT', $parts) && array_key_exists('UNTIL', $parts)) {
return null;
}
//$lastOccurences[] = DateTime of last occurence
}
if(isset($this->vobject->{$objectName}->{'RDATE'})) {
if (isset($this->vobject->{$objectName}->{'RDATE'})) {
//$lastOccurences[] = DateTime of last occurence
}
}
@ -272,7 +272,7 @@ class Object extends Entity {
public function getSummary() {
$objectName = $this->objectName;
if(isset($this->vobject->{$objectName}->{'SUMMARY'})) {
if (isset($this->vobject->{$objectName}->{'SUMMARY'})) {
return $this->vobject->{$objectName}->{'SUMMARY'}->getValue();
}
@ -293,12 +293,12 @@ class Object extends Entity {
}
public function getRuds($force=false) {
if($this->ruds !== null) {
if ($this->ruds !== null) {
return $this->ruds;
} else {
if($this->calendar instanceof Calendar) {
if ($this->calendar instanceof Calendar) {
$cruds = $this->calendar->getCruds();
if($cruds & Permissions::CREATE) {
if ($cruds & Permissions::CREATE) {
$cruds -= Permissions::CREATE;
}
return $cruds;
@ -308,7 +308,7 @@ class Object extends Entity {
}
public function setRuds($ruds) {
if($ruds & Permissions::CREATE) {
if ($ruds & Permissions::CREATE) {
$ruds -= Permissions::CREATE;
}
@ -322,7 +322,7 @@ class Object extends Entity {
public function getLastModified() {
$objectName = $this->objectName;
if(isset($this->vobject->{$objectName}->{'LAST-MODIFIED'})) {
if (isset($this->vobject->{$objectName}->{'LAST-MODIFIED'})) {
return $this->vobject->{$objectName}->{'LAST-MODIFIED'}->getDateTime();
}
@ -340,15 +340,15 @@ class Object extends Entity {
);
foreach($strings as $string) {
if(is_string($string) === false) {
if (is_string($string) === false) {
return false;
}
if(trim($string) === '') {
if (trim($string) === '') {
return false;
}
}
if(!($this->calendar instanceof Calendar)) {
if (!($this->calendar instanceof Calendar)) {
return false;
}

View File

@ -21,7 +21,7 @@ class ObjectCollection extends Collection {
$objectsInPeriod = new ObjectCollection();
$this->iterate(function($object) use (&$objectsInPeriod) {
if($object->isRepeating() === true) {
if ($object->isRepeating() === true) {
$objectsInPeriod->add(clone $object);
} else {
@ -43,7 +43,7 @@ class ObjectCollection extends Collection {
$expandedObjects = new ObjectCollection();
$this->iterate(function($object) use (&$expandedObjects) {
if($object->isRepeating() === true) {
if ($object->isRepeating() === true) {
@ -72,7 +72,7 @@ class ObjectCollection extends Collection {
$objectsOfType = new ObjectCollection();
$this->iterate(function($object) use (&$objectsOfType, $type) {
if($object->getType() & $type) {
if ($object->getType() & $type) {
$collection->add(clone $object);
}
});

View File

@ -16,13 +16,13 @@ class ObjectType {
public static function getAsString($type) {
$types = array();
if($type & self::EVENT) {
if ($type & self::EVENT) {
$types[] = 'VEVENT';
}
if($type & self::JOURNAL) {
if ($type & self::JOURNAL) {
$types[] = 'VJOURNAL';
}
if($type & self::TODO) {
if ($type & self::TODO) {
$types[] = 'VTODO';
}
@ -33,13 +33,13 @@ class ObjectType {
public static function getAsReadableString($type) {
$types = array();
if($type & self::EVENT) {
if ($type & self::EVENT) {
$types[] = 'events';
}
if($type & self::JOURNAL) {
if ($type & self::JOURNAL) {
$types[] = 'journals';
}
if($type & self::TODO) {
if ($type & self::TODO) {
$types[] = 'todos';
}
@ -74,13 +74,13 @@ class ObjectType {
$types = 0;
$string = strtoupper($string);
if(substr_count($string, 'VEVENT')) {
if (substr_count($string, 'VEVENT')) {
$types += self::EVENT;
}
if(substr_count($string, 'VJOURNAL')) {
if (substr_count($string, 'VJOURNAL')) {
$types += self::JOURNAL;
}
if(substr_count($string, 'VTODO')) {
if (substr_count($string, 'VTODO')) {
$types += self::TODO;
}
}
@ -88,7 +88,7 @@ class ObjectType {
public static function getTypeBySabreClass($class) {
$type = 0;
if(is_string($class)) {
if (is_string($class)) {
$class = get_class($class);
}

View File

@ -30,10 +30,10 @@ class Timezone extends Entity {
$this->addType('tzId', 'string');
$this->addType('tzData', 'string');
if(!is_null($tzId)) {
if (!is_null($tzId)) {
$this->setTzId($tzId);
}
if(!is_null($tzData)) {
if (!is_null($tzData)) {
$this->setTzData($tzData);
}
}
@ -54,7 +54,7 @@ class Timezone extends Entity {
* @param string $data
*/
public function setTzData($data) {
if(substr_count($data, 'BEGIN:VCALENDAR') === 0) {
if (substr_count($data, 'BEGIN:VCALENDAR') === 0) {
$data = 'BEGIN:VCALENDAR' . "\n" . $data . "\n" . 'END:VCALENDAR';
}
@ -68,10 +68,10 @@ class Timezone extends Entity {
* @return $this
*/
public function fromVObject(VCalendar $vcalendar) {
if(!isset($vcalendar->{'VTIMEZONE'})) {
if (!isset($vcalendar->{'VTIMEZONE'})) {
throw new DoesNotExistException('no vtimezones found');
}
if(is_array($vcalendar->{'VTIMEZONE'})) {
if (is_array($vcalendar->{'VTIMEZONE'})) {
throw new MultipleObjectsReturnedException('multiple vtimezones found');
}
$this->vobject = $vcalendar;

View File

@ -43,7 +43,7 @@ class TimezoneMapper extends Mapper {
* - [x] $tzId is not a valid filename or
* - [x] file inside /../timezones/ does not exist
*/
if(strtolower($tzId) === 'info.md' ||
if (strtolower($tzId) === 'info.md' ||
!\OCP\Util::isValidFileName($tzIdName) ||
!file_exists($path)) {
throw new DoesNotExistException();
@ -64,10 +64,10 @@ class TimezoneMapper extends Mapper {
$tzFiles = scandir($this->folderName);
$files = array_values(array_diff($tzFiles, $this->fileBlacklist));
if(is_null($limit)) {
if (is_null($limit)) {
$limit = (count($files) - 1);
}
if(is_null($offset)) {
if (is_null($offset)) {
$offset = 0;
}

View File

@ -22,7 +22,7 @@ class ICSObject extends ICS {
public function serialize($convenience=true) {
$vcalendar = $this->object->getVObject();
if($convenience === true) {
if ($convenience === true) {
JSONUtility::addConvenience($vcalendar);
}

View File

@ -15,7 +15,7 @@ class ICSObjectCollection extends ICSCollection {
public function serialize($convenience=true) {
$vcalendar = $this->collection->getVObject();
if($convenience === true) {
if ($convenience === true) {
JSONUtility::addConvenience($vcalendar);
}

View File

@ -30,7 +30,7 @@ class ICSObjectReader extends ICSReader {
$objectCollection->add($object);
}
if($objectCollection->count() === 1) {
if ($objectCollection->count() === 1) {
$this->setObject($objectCollection->reset()->current());
} else {
$this->setObject($objectCollection);

View File

@ -33,12 +33,12 @@ class JSONCalendarCollection extends JSONCollection {
$this->object->iterate(function(&$object) use (&$jsonArray, $convenience) {
try {
if($object instanceof Calendar) {
if ($object instanceof Calendar) {
$jsonCalendar = new JSONCalendar();
$jsonCalendar->setObject($object);
$jsonArray[] = $jsonCalendar->serialize($convenience);
}
if($object instanceof JSONCalendar) {
if ($object instanceof JSONCalendar) {
$jsonArray[] = $object->serialize($convenience);
}
} catch (JSONException $ex) {

View File

@ -23,7 +23,7 @@ class JSONCalendarReader extends JSONReader{
$data = $this->getData();
$isCollection = $this->isDataACollection();
if($isCollection) {
if ($isCollection) {
$collection = new CalendarCollection();
foreach($data as $singleEntity) {
@ -53,7 +53,7 @@ class JSONCalendarReader extends JSONReader{
* @brief overwrite values that should not be set by user with null
*/
public function sanitize() {
if($this->object === null) {
if ($this->object === null) {
$this->parse();
}
@ -75,7 +75,7 @@ class JSONCalendarReader extends JSONReader{
private function isDataACollection() {
$data = $this->data;
if(array_key_exists(0, $data) && is_array($data[0])) {
if (array_key_exists(0, $data) && is_array($data[0])) {
return true;
}
return false;

View File

@ -28,7 +28,7 @@ abstract class JSON implements ISerializer {
* @param Entity $object
*/
public function setObject($object) {
if($object instanceof Entity) {
if ($object instanceof Entity) {
$this->object = $object;
return $this;
}

View File

@ -17,7 +17,7 @@ abstract class JSONCollection extends JSON {
* @param Collection $object
*/
public function setObject($object) {
if($object instanceof Collection) {
if ($object instanceof Collection) {
$this->object = $object;
return $this;
}

View File

@ -21,7 +21,7 @@ abstract class JSONReader implements IReader {
* @brief Constructor
*/
public function __construct($json=null) {
if($json !== null) {
if ($json !== null) {
$this->setData($json);
}
}
@ -41,20 +41,20 @@ abstract class JSONReader implements IReader {
//reset object
$this->object = null;
if(is_array($json)) {
if (is_array($json)) {
$this->data = $json;
return $this;
}
if(is_string($json)) {
if(trim($json) === '') {
if (is_string($json)) {
if (trim($json) === '') {
$msg = 'JSONReader::setData(): User Error: ';
$msg .= 'Given string is empty';
throw new JSONReaderException($msg);
}
$data = json_decode($json, true);
if(!is_string($data)) {
if (!is_string($data)) {
$msg = 'JSONReader::setData(): User Error: ';
$msg .= 'Could not parse given (json) string!';
throw new JSONReaderException($msg);
@ -73,13 +73,13 @@ abstract class JSONReader implements IReader {
* @brief get object created from reader
*/
public function getObject() {
if($this->getData() === null) {
if ($this->getData() === null) {
$msg = 'JSONReader::getObject(): Internal Error: ';
$msg .= 'getObject may not be called before any data was set!';
throw new JSONReaderException($msg);
}
if($this->object === null) {
if ($this->object === null) {
$this->parse();
}
@ -90,7 +90,7 @@ abstract class JSONReader implements IReader {
* @brief set object
*/
protected function setObject($object) {
if(($object instanceof Entity) ||
if (($object instanceof Entity) ||
($object instanceof Collection)) {
$this->object = $object;
return $this;
@ -103,7 +103,7 @@ abstract class JSONReader implements IReader {
* @brief get if reader will return collection
*/
public function isCollection() {
if($this->object === null) {
if ($this->object === null) {
$this->parse();
}
@ -119,7 +119,7 @@ abstract class JSONReader implements IReader {
$isCollection = $this->isCollection();
foreach($properties as $property) {
if($isCollection) {
if ($isCollection) {
$this->object->setProperty($property, null);
} else {
$setter = 'set' . ucfirst($property);

View File

@ -29,7 +29,7 @@ class JSONObjectCollection extends JSONCollection {
public function serialize($convenience=true) {
//if the collection does not contain any object,
//return the http 204 no content status code
if($this->object->count() === 0) {
if ($this->object->count() === 0) {
return null;
}

View File

@ -25,7 +25,7 @@ class JSONObjectReader {
$uniqueUIDs = SabreUtility::countUniqueUIDs($vcalendar);
$isCollection = ($uniqueUIDs !== 1);
if($isCollection) {
if ($isCollection) {
$singleObjects = SabreUtility::splitByUID($vcalendar);
$collection = new ObjectCollection($singleObjects);
$this->setObject($collection);

View File

@ -19,10 +19,10 @@ abstract class Manager {
* @return mixed (boolean|string)
*/
public static function get($type, $requestedMimeType) {
if(!array_key_exists($type, self::$all)) {
if (!array_key_exists($type, self::$all)) {
return false;
}
if(!array_key_exists($requestedMimeType, self::$all[$type])) {
if (!array_key_exists($requestedMimeType, self::$all[$type])) {
return false;
}
return self::$all[$type][$requestedMimeType];
@ -37,7 +37,7 @@ abstract class Manager {
* @return boolean
*/
public static function set($type, $class, $requestedMimeType, $overwrite=false) {
if($overwrite === false && self::get($type, $requestedMimeType) !== false) {
if ($overwrite === false && self::get($type, $requestedMimeType) !== false) {
return false;
}
@ -51,7 +51,7 @@ abstract class Manager {
* @return mixed (boolean|string)
*/
public static function getFallback($type) {
if(!array_key_exists($type, self::$fallback)) {
if (!array_key_exists($type, self::$fallback)) {
return false;
}
return self::$fallback[$type];

View File

@ -23,7 +23,7 @@ class Reader extends Manager implements IReader {
*/
public function __construct($type, $data, $requestedMimeType) {
$class = self::get($type, $requestedMimeType);
if(!$class) {
if (!$class) {
throw new \Exception('No reader found.');
}

View File

@ -22,8 +22,8 @@ class Response extends CoreResponse {
public function __construct($data=null, $statusCode=null) {
$this->data = $data;
if($statusCode === null) {
if($data === null) {
if ($statusCode === null) {
if ($data === null) {
$statusCode = Http::STATUS_NO_CONTENT;
} else {
$statusCode = Http::STATUS_OK;
@ -31,7 +31,7 @@ class Response extends CoreResponse {
}
$this->setStatus($statusCode);
if($data instanceof ISerializer) {
if ($data instanceof ISerializer) {
$headers = $data->getHeaders();
foreach($headers as $key => $value) {
$this->addHeader($key, $value);
@ -44,17 +44,17 @@ class Response extends CoreResponse {
* @return string the rendered data
*/
public function render(){
if(is_string($this->data)) {
if (is_string($this->data)) {
return $this->data;
} elseif(is_array($this->data)) {
} elseif (is_array($this->data)) {
return json_encode($this->data);
} elseif($this->data instanceof ISerializer) {
} elseif ($this->data instanceof ISerializer) {
$data = $this->data->serialize();
if(is_null($data)) {
if (is_null($data)) {
$this->setStatus(Http::STATUS_NO_CONTENT);
return '';
}else if(is_array($data)) {
}else if (is_array($data)) {
return json_encode($data);
} else {
return $data;

View File

@ -20,10 +20,10 @@ class Serializer extends Manager implements ISerializer {
public function __construct($type, $data, $requestedMimeType) {
$class = self::get($type, $requestedMimeType);
if(!$class) {
if (!$class) {
$class = self::getFallback($type);
}
if(!$class) {
if (!$class) {
throw new Exception('No serializer found.');
}

View File

@ -22,14 +22,14 @@ class CalendarUtility extends Utility{
* @return string $calendarURI
*/
public static function suggestURI($calendarURI) {
if(substr_count($calendarURI, '-') === 0) {
if (substr_count($calendarURI, '-') === 0) {
$calendarURI .= '-1';
} else {
$positionLastDash = strrpos($calendarURI, '-');
$firstPart = substr($calendarURI, 0, $positionLastDash);
$lastPart = substr($calendarURI, $positionLastDash + 1);
$pattern = '/^\d+$/';
if(preg_match($pattern, $lastPart)) {
if (preg_match($pattern, $lastPart)) {
$lastPart = (int) $lastPart;
$lastPart++;
$calendarURI = $firstPart . '-' . $lastPart;

View File

@ -20,7 +20,7 @@ class JSONUtility extends Utility{
* @return array
*/
public static function getUserInformation($userId) {
if($userId === null) {
if ($userId === null) {
$userId = \OCP\User::getUser();
}
@ -37,11 +37,11 @@ class JSONUtility extends Utility{
* @return string $userId
*/
public static function parseUserInformation($value) {
if(is_array($value) === false) {
if (is_array($value) === false) {
return null;
}
if(array_key_exists('userid', $value) === false) {
if (array_key_exists('userid', $value) === false) {
return null;
} else {
return $value['userid'];
@ -71,13 +71,13 @@ class JSONUtility extends Utility{
public static function parseComponents($value) {
$components = 0;
if(array_key_exists('vevent', $value) && $value['vevent'] === true) {
if (array_key_exists('vevent', $value) && $value['vevent'] === true) {
$components += ObjectType::EVENT;
}
if(array_key_exists('vjournal', $value) && $value['vjournal'] === true) {
if (array_key_exists('vjournal', $value) && $value['vjournal'] === true) {
$components += ObjectType::JOURNAL;
}
if(array_key_exists('vtodo', $value) && $value['vtodo'] === true) {
if (array_key_exists('vtodo', $value) && $value['vtodo'] === true) {
$components += ObjectType::TODO;
}
@ -111,22 +111,22 @@ class JSONUtility extends Utility{
$cruds = 0;
//use code if given
if(array_key_exists('code', $value) && (int) $value['code'] >= 0 && (int) $value['code'] <= 31) {
if (array_key_exists('code', $value) && (int) $value['code'] >= 0 && (int) $value['code'] <= 31) {
$cruds = (int) $value['code'];
} else {
if(array_key_exists('create', $value) && $value['create'] === true) {
if (array_key_exists('create', $value) && $value['create'] === true) {
$cruds += Permissions::CREATE;
}
if(array_key_exists('update', $value) && $value['update'] === true) {
if (array_key_exists('update', $value) && $value['update'] === true) {
$cruds += Permissions::UPDATE;
}
if(array_key_exists('delete', $value) && $value['delete'] === true) {
if (array_key_exists('delete', $value) && $value['delete'] === true) {
$cruds += Permissions::DELETE;
}
if(array_key_exists('read', $value) && $value['read'] === true) {
if (array_key_exists('read', $value) && $value['read'] === true) {
$cruds += Permissions::READ;
}
if(array_key_exists('share', $value) && $value['share'] === true) {
if (array_key_exists('share', $value) && $value['share'] === true) {
$cruds += Permissions::SHARE;
}
}

View File

@ -25,7 +25,7 @@ class SabreUtility extends Utility {
*/
public static function getObjectName($vcalendar) {
foreach($vcalendar->children() as $child) {
if($child instanceof VEvent ||
if ($child instanceof VEvent ||
$child instanceof VJournal ||
$child instanceof VTodo ||
$child instanceof VFreeBusy) {
@ -75,11 +75,11 @@ class SabreUtility extends Utility {
$count = 0;
foreach($properties as $property) {
if(isset($vcalendar->$property)) {
if(is_array($vcalendar->$object)) {
if (isset($vcalendar->$property)) {
if (is_array($vcalendar->$object)) {
$count += count($vcalendar->$object);
}
if($vcalendar->$object instanceof Component) {
if ($vcalendar->$object instanceof Component) {
$count++;
}
}
@ -98,7 +98,7 @@ class SabreUtility extends Utility {
$uids = array();
foreach($vcalendar->children() as $child) {
if($child instanceof VEvent ||
if ($child instanceof VEvent ||
$child instanceof VJournal ||
$child instanceof VTodo ||
$child instanceof VFreeBusy) {
@ -119,14 +119,14 @@ class SabreUtility extends Utility {
* @return \OCA\Calendar\Sabre\VObject\Property\DateTime $dstart
*/
public static function getDTStart(Component $vobject) {
if(!isset($vobject->{'DTSTART'})) {
if (!isset($vobject->{'DTSTART'})) {
return null;
}
//If recurrenceId is set, that's the actual start
//DTSTART has the value of the first object of recurring events
//This doesn't make any sense, but that's how it is in the standard
if(isset($vobject->{'RECURRENCE-ID'})) {
if (isset($vobject->{'RECURRENCE-ID'})) {
return $vobject->{'RECURRENCE-ID'};
}
@ -140,17 +140,17 @@ class SabreUtility extends Utility {
* @return \OCA\Calendar\Sabre\VObject\Property\DateTime $dtend
*/
public static function getDTEnd(Component $vobject) {
if(isset($vobject->{'DTEND'})) {
if (isset($vobject->{'DTEND'})) {
return $vobject->{'DTEND'};
}
if(!isset($vobject->{'DTSTART'})) {
if (!isset($vobject->{'DTSTART'})) {
return null;
}
$dtend = self::getDTStart($vobject);
if(!isset($vobject->{'DURATION'})) {
if (!isset($vobject->{'DURATION'})) {
return $dtend;
}