Merge pull request #20422 from nextcloud/techdebt/format-control-structs-classes-methods
Format control structures, classes, methods and function
This commit is contained in:
commit
1762a409f9
|
@ -91,5 +91,4 @@ class AccessibilityProvider {
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,6 @@ class ConfigController extends OCSController {
|
||||||
*/
|
*/
|
||||||
public function setConfig(string $key, $value): DataResponse {
|
public function setConfig(string $key, $value): DataResponse {
|
||||||
if ($key === 'theme' || $key === 'font' || $key === 'highcontrast') {
|
if ($key === 'theme' || $key === 'font' || $key === 'highcontrast') {
|
||||||
|
|
||||||
if ($value === false || $value === '') {
|
if ($value === false || $value === '') {
|
||||||
throw new OCSBadRequestException('Invalid value: ' . $value);
|
throw new OCSBadRequestException('Invalid value: ' . $value);
|
||||||
}
|
}
|
||||||
|
@ -142,7 +141,6 @@ class ConfigController extends OCSController {
|
||||||
*/
|
*/
|
||||||
public function deleteConfig(string $key): DataResponse {
|
public function deleteConfig(string $key): DataResponse {
|
||||||
if ($key === 'theme' || $key === 'font' || $key === 'highcontrast') {
|
if ($key === 'theme' || $key === 'font' || $key === 'highcontrast') {
|
||||||
|
|
||||||
$this->config->deleteUserValue($this->userId, $this->appName, $key);
|
$this->config->deleteUserValue($this->userId, $this->appName, $key);
|
||||||
$userValues = $this->config->getUserKeys($this->userId, $this->appName);
|
$userValues = $this->config->getUserKeys($this->userId, $this->appName);
|
||||||
|
|
||||||
|
@ -156,5 +154,4 @@ class ConfigController extends OCSController {
|
||||||
|
|
||||||
throw new OCSBadRequestException('Invalid key: ' . $key);
|
throw new OCSBadRequestException('Invalid key: ' . $key);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,5 +86,4 @@ class RepairUserConfig implements IRepairStep {
|
||||||
});
|
});
|
||||||
$output->finishProgress();
|
$output->finishProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,8 +53,8 @@ class Action {
|
||||||
array $params,
|
array $params,
|
||||||
array $elements,
|
array $elements,
|
||||||
bool $obfuscateParameters = false) {
|
bool $obfuscateParameters = false) {
|
||||||
foreach($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
if(!isset($params[$element])) {
|
if (!isset($params[$element])) {
|
||||||
if ($obfuscateParameters) {
|
if ($obfuscateParameters) {
|
||||||
$this->logger->critical(
|
$this->logger->critical(
|
||||||
'$params["'.$element.'"] was missing.',
|
'$params["'.$element.'"] was missing.',
|
||||||
|
@ -74,8 +74,8 @@ class Action {
|
||||||
}
|
}
|
||||||
|
|
||||||
$replaceArray = [];
|
$replaceArray = [];
|
||||||
foreach($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
if($params[$element] instanceof \DateTime) {
|
if ($params[$element] instanceof \DateTime) {
|
||||||
$params[$element] = $params[$element]->format('Y-m-d H:i:s');
|
$params[$element] = $params[$element]->format('Y-m-d H:i:s');
|
||||||
}
|
}
|
||||||
$replaceArray[] = $params[$element];
|
$replaceArray[] = $params[$element];
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Sharing extends Action {
|
||||||
* @param array $params
|
* @param array $params
|
||||||
*/
|
*/
|
||||||
public function shared(array $params) {
|
public function shared(array $params) {
|
||||||
if($params['shareType'] === Share::SHARE_TYPE_LINK) {
|
if ($params['shareType'] === Share::SHARE_TYPE_LINK) {
|
||||||
$this->log(
|
$this->log(
|
||||||
'The %s "%s" with ID "%s" has been shared via link with permissions "%s" (Share ID: %s)',
|
'The %s "%s" with ID "%s" has been shared via link with permissions "%s" (Share ID: %s)',
|
||||||
$params,
|
$params,
|
||||||
|
@ -55,7 +55,7 @@ class Sharing extends Action {
|
||||||
'id',
|
'id',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} elseif($params['shareType'] === Share::SHARE_TYPE_USER) {
|
} elseif ($params['shareType'] === Share::SHARE_TYPE_USER) {
|
||||||
$this->log(
|
$this->log(
|
||||||
'The %s "%s" with ID "%s" has been shared to the user "%s" with permissions "%s" (Share ID: %s)',
|
'The %s "%s" with ID "%s" has been shared to the user "%s" with permissions "%s" (Share ID: %s)',
|
||||||
$params,
|
$params,
|
||||||
|
@ -68,7 +68,7 @@ class Sharing extends Action {
|
||||||
'id',
|
'id',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) {
|
} elseif ($params['shareType'] === Share::SHARE_TYPE_GROUP) {
|
||||||
$this->log(
|
$this->log(
|
||||||
'The %s "%s" with ID "%s" has been shared to the group "%s" with permissions "%s" (Share ID: %s)',
|
'The %s "%s" with ID "%s" has been shared to the group "%s" with permissions "%s" (Share ID: %s)',
|
||||||
$params,
|
$params,
|
||||||
|
@ -81,7 +81,7 @@ class Sharing extends Action {
|
||||||
'id',
|
'id',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} elseif($params['shareType'] === Share::SHARE_TYPE_ROOM) {
|
} elseif ($params['shareType'] === Share::SHARE_TYPE_ROOM) {
|
||||||
$this->log(
|
$this->log(
|
||||||
'The %s "%s" with ID "%s" has been shared to the room "%s" with permissions "%s" (Share ID: %s)',
|
'The %s "%s" with ID "%s" has been shared to the room "%s" with permissions "%s" (Share ID: %s)',
|
||||||
$params,
|
$params,
|
||||||
|
@ -94,7 +94,7 @@ class Sharing extends Action {
|
||||||
'id',
|
'id',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} elseif($params['shareType'] === Share::SHARE_TYPE_EMAIL) {
|
} elseif ($params['shareType'] === Share::SHARE_TYPE_EMAIL) {
|
||||||
$this->log(
|
$this->log(
|
||||||
'The %s "%s" with ID "%s" has been shared to the email recipient "%s" with permissions "%s" (Share ID: %s)',
|
'The %s "%s" with ID "%s" has been shared to the email recipient "%s" with permissions "%s" (Share ID: %s)',
|
||||||
$params,
|
$params,
|
||||||
|
@ -107,7 +107,7 @@ class Sharing extends Action {
|
||||||
'id',
|
'id',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} elseif($params['shareType'] === Share::SHARE_TYPE_CIRCLE) {
|
} elseif ($params['shareType'] === Share::SHARE_TYPE_CIRCLE) {
|
||||||
$this->log(
|
$this->log(
|
||||||
'The %s "%s" with ID "%s" has been shared to the circle "%s" with permissions "%s" (Share ID: %s)',
|
'The %s "%s" with ID "%s" has been shared to the circle "%s" with permissions "%s" (Share ID: %s)',
|
||||||
$params,
|
$params,
|
||||||
|
@ -120,7 +120,7 @@ class Sharing extends Action {
|
||||||
'id',
|
'id',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} elseif($params['shareType'] === Share::SHARE_TYPE_REMOTE) {
|
} elseif ($params['shareType'] === Share::SHARE_TYPE_REMOTE) {
|
||||||
$this->log(
|
$this->log(
|
||||||
'The %s "%s" with ID "%s" has been shared to the remote user "%s" with permissions "%s" (Share ID: %s)',
|
'The %s "%s" with ID "%s" has been shared to the remote user "%s" with permissions "%s" (Share ID: %s)',
|
||||||
$params,
|
$params,
|
||||||
|
@ -133,7 +133,7 @@ class Sharing extends Action {
|
||||||
'id',
|
'id',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} elseif($params['shareType'] === Share::SHARE_TYPE_REMOTE_GROUP) {
|
} elseif ($params['shareType'] === Share::SHARE_TYPE_REMOTE_GROUP) {
|
||||||
$this->log(
|
$this->log(
|
||||||
'The %s "%s" with ID "%s" has been shared to the remote group "%s" with permissions "%s" (Share ID: %s)',
|
'The %s "%s" with ID "%s" has been shared to the remote group "%s" with permissions "%s" (Share ID: %s)',
|
||||||
$params,
|
$params,
|
||||||
|
@ -155,7 +155,7 @@ class Sharing extends Action {
|
||||||
* @param array $params
|
* @param array $params
|
||||||
*/
|
*/
|
||||||
public function unshare(array $params) {
|
public function unshare(array $params) {
|
||||||
if($params['shareType'] === Share::SHARE_TYPE_LINK) {
|
if ($params['shareType'] === Share::SHARE_TYPE_LINK) {
|
||||||
$this->log(
|
$this->log(
|
||||||
'The %s "%s" with ID "%s" has been unshared (Share ID: %s)',
|
'The %s "%s" with ID "%s" has been unshared (Share ID: %s)',
|
||||||
$params,
|
$params,
|
||||||
|
@ -166,7 +166,7 @@ class Sharing extends Action {
|
||||||
'id',
|
'id',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} elseif($params['shareType'] === Share::SHARE_TYPE_USER) {
|
} elseif ($params['shareType'] === Share::SHARE_TYPE_USER) {
|
||||||
$this->log(
|
$this->log(
|
||||||
'The %s "%s" with ID "%s" has been unshared from the user "%s" (Share ID: %s)',
|
'The %s "%s" with ID "%s" has been unshared from the user "%s" (Share ID: %s)',
|
||||||
$params,
|
$params,
|
||||||
|
@ -178,7 +178,7 @@ class Sharing extends Action {
|
||||||
'id',
|
'id',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) {
|
} elseif ($params['shareType'] === Share::SHARE_TYPE_GROUP) {
|
||||||
$this->log(
|
$this->log(
|
||||||
'The %s "%s" with ID "%s" has been unshared from the group "%s" (Share ID: %s)',
|
'The %s "%s" with ID "%s" has been unshared from the group "%s" (Share ID: %s)',
|
||||||
$params,
|
$params,
|
||||||
|
@ -190,7 +190,7 @@ class Sharing extends Action {
|
||||||
'id',
|
'id',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} elseif($params['shareType'] === Share::SHARE_TYPE_ROOM) {
|
} elseif ($params['shareType'] === Share::SHARE_TYPE_ROOM) {
|
||||||
$this->log(
|
$this->log(
|
||||||
'The %s "%s" with ID "%s" has been unshared from the room "%s" (Share ID: %s)',
|
'The %s "%s" with ID "%s" has been unshared from the room "%s" (Share ID: %s)',
|
||||||
$params,
|
$params,
|
||||||
|
@ -202,7 +202,7 @@ class Sharing extends Action {
|
||||||
'id',
|
'id',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} elseif($params['shareType'] === Share::SHARE_TYPE_EMAIL) {
|
} elseif ($params['shareType'] === Share::SHARE_TYPE_EMAIL) {
|
||||||
$this->log(
|
$this->log(
|
||||||
'The %s "%s" with ID "%s" has been unshared from the email recipient "%s" (Share ID: %s)',
|
'The %s "%s" with ID "%s" has been unshared from the email recipient "%s" (Share ID: %s)',
|
||||||
$params,
|
$params,
|
||||||
|
@ -214,7 +214,7 @@ class Sharing extends Action {
|
||||||
'id',
|
'id',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} elseif($params['shareType'] === Share::SHARE_TYPE_CIRCLE) {
|
} elseif ($params['shareType'] === Share::SHARE_TYPE_CIRCLE) {
|
||||||
$this->log(
|
$this->log(
|
||||||
'The %s "%s" with ID "%s" has been unshared from the circle "%s" (Share ID: %s)',
|
'The %s "%s" with ID "%s" has been unshared from the circle "%s" (Share ID: %s)',
|
||||||
$params,
|
$params,
|
||||||
|
@ -226,7 +226,7 @@ class Sharing extends Action {
|
||||||
'id',
|
'id',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} elseif($params['shareType'] === Share::SHARE_TYPE_REMOTE) {
|
} elseif ($params['shareType'] === Share::SHARE_TYPE_REMOTE) {
|
||||||
$this->log(
|
$this->log(
|
||||||
'The %s "%s" with ID "%s" has been unshared from the remote user "%s" (Share ID: %s)',
|
'The %s "%s" with ID "%s" has been unshared from the remote user "%s" (Share ID: %s)',
|
||||||
$params,
|
$params,
|
||||||
|
@ -238,7 +238,7 @@ class Sharing extends Action {
|
||||||
'id',
|
'id',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} elseif($params['shareType'] === Share::SHARE_TYPE_REMOTE_GROUP) {
|
} elseif ($params['shareType'] === Share::SHARE_TYPE_REMOTE_GROUP) {
|
||||||
$this->log(
|
$this->log(
|
||||||
'The %s "%s" with ID "%s" has been unshared from the remote group "%s" (Share ID: %s)',
|
'The %s "%s" with ID "%s" has been unshared from the remote group "%s" (Share ID: %s)',
|
||||||
$params,
|
$params,
|
||||||
|
|
|
@ -29,7 +29,6 @@ declare(strict_types=1);
|
||||||
namespace OCA\AdminAudit\Actions;
|
namespace OCA\AdminAudit\Actions;
|
||||||
|
|
||||||
class Trashbin extends Action {
|
class Trashbin extends Action {
|
||||||
|
|
||||||
public function delete(array $params) {
|
public function delete(array $params) {
|
||||||
$this->log('File "%s" deleted from trash bin.',
|
$this->log('File "%s" deleted from trash bin.',
|
||||||
['path' => $params['path']], ['path']
|
['path' => $params['path']], ['path']
|
||||||
|
@ -41,5 +40,4 @@ class Trashbin extends Action {
|
||||||
['path' => $params['filePath']], ['path']
|
['path' => $params['filePath']], ['path']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ class UserManagement extends Action {
|
||||||
* @param array $params
|
* @param array $params
|
||||||
*/
|
*/
|
||||||
public function change(array $params) {
|
public function change(array $params) {
|
||||||
switch($params['feature']) {
|
switch ($params['feature']) {
|
||||||
case 'enabled':
|
case 'enabled':
|
||||||
$this->log(
|
$this->log(
|
||||||
$params['value'] === true
|
$params['value'] === true
|
||||||
|
@ -130,7 +130,7 @@ class UserManagement extends Action {
|
||||||
* @param IUser $user
|
* @param IUser $user
|
||||||
*/
|
*/
|
||||||
public function setPassword(IUser $user) {
|
public function setPassword(IUser $user) {
|
||||||
if($user->getBackendClassName() === 'Database') {
|
if ($user->getBackendClassName() === 'Database') {
|
||||||
$this->log(
|
$this->log(
|
||||||
'Password of user "%s" has been changed',
|
'Password of user "%s" has been changed',
|
||||||
[
|
[
|
||||||
|
|
|
@ -29,7 +29,6 @@ declare(strict_types=1);
|
||||||
namespace OCA\AdminAudit\Actions;
|
namespace OCA\AdminAudit\Actions;
|
||||||
|
|
||||||
class Versions extends Action {
|
class Versions extends Action {
|
||||||
|
|
||||||
public function rollback(array $params) {
|
public function rollback(array $params) {
|
||||||
$this->log('Version "%s" of "%s" was restored.',
|
$this->log('Version "%s" of "%s" was restored.',
|
||||||
[
|
[
|
||||||
|
@ -46,5 +45,4 @@ class Versions extends Action {
|
||||||
['path']
|
['path']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,12 +74,11 @@ class Application extends App {
|
||||||
|
|
||||||
$default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log';
|
$default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log';
|
||||||
$logFile = $config->getAppValue('admin_audit', 'logfile', $default);
|
$logFile = $config->getAppValue('admin_audit', 'logfile', $default);
|
||||||
if($logFile === null) {
|
if ($logFile === null) {
|
||||||
$this->logger = $c->getLogger();
|
$this->logger = $c->getLogger();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->logger = $c->getLogFactory()->getCustomLogger($logFile);
|
$this->logger = $c->getLogFactory()->getCustomLogger($logFile);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function register() {
|
public function register() {
|
||||||
|
@ -152,7 +151,6 @@ class Application extends App {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function appHooks() {
|
protected function appHooks() {
|
||||||
|
|
||||||
$eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher();
|
$eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher();
|
||||||
$eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE, function (ManagerEvent $event) {
|
$eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE, function (ManagerEvent $event) {
|
||||||
$appActions = new AppManagement($this->logger);
|
$appActions = new AppManagement($this->logger);
|
||||||
|
@ -166,7 +164,6 @@ class Application extends App {
|
||||||
$appActions = new AppManagement($this->logger);
|
$appActions = new AppManagement($this->logger);
|
||||||
$appActions->disableApp($event->getAppID());
|
$appActions->disableApp($event->getAppID());
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function consoleHooks() {
|
protected function consoleHooks() {
|
||||||
|
|
|
@ -38,14 +38,14 @@ class Rotate extends TimedJob {
|
||||||
$default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log';
|
$default = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/audit.log';
|
||||||
$this->filePath = $config->getAppValue('admin_audit', 'logfile', $default);
|
$this->filePath = $config->getAppValue('admin_audit', 'logfile', $default);
|
||||||
|
|
||||||
if($this->filePath === '') {
|
if ($this->filePath === '') {
|
||||||
// default log file, nothing to do
|
// default log file, nothing to do
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->maxSize = $config->getSystemValue('log_rotate_size', 100 * 1024 * 1024);
|
$this->maxSize = $config->getSystemValue('log_rotate_size', 100 * 1024 * 1024);
|
||||||
|
|
||||||
if($this->shouldRotateBySize()) {
|
if ($this->shouldRotateBySize()) {
|
||||||
$this->rotate();
|
$this->rotate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,5 +73,4 @@ class SecurityTest extends TestCase {
|
||||||
|
|
||||||
$this->security->twofactorSuccess($this->user, ['provider' => 'myprovider']);
|
$this->security->twofactorSuccess($this->user, ['provider' => 'myprovider']);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ use OCA\CloudFederationAPI\Capabilities;
|
||||||
use OCP\AppFramework\App;
|
use OCP\AppFramework\App;
|
||||||
|
|
||||||
class Application extends App {
|
class Application extends App {
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct('cloud_federation_api');
|
parent::__construct('cloud_federation_api');
|
||||||
|
|
||||||
|
|
|
@ -55,5 +55,4 @@ class Config {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ class RequestHandlerController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($shareType === 'group') {
|
if ($shareType === 'group') {
|
||||||
if(!$this->groupManager->groupExists($shareWith)) {
|
if (!$this->groupManager->groupExists($shareWith)) {
|
||||||
return new JSONResponse(
|
return new JSONResponse(
|
||||||
['message' => 'Group "' . $shareWith . '" does not exists at ' . $this->urlGenerator->getBaseUrl()],
|
['message' => 'Group "' . $shareWith . '" does not exists at ' . $this->urlGenerator->getBaseUrl()],
|
||||||
Http::STATUS_BAD_REQUEST
|
Http::STATUS_BAD_REQUEST
|
||||||
|
@ -208,14 +208,13 @@ class RequestHandlerController extends Controller {
|
||||||
|
|
||||||
$user = $this->userManager->get($shareWith);
|
$user = $this->userManager->get($shareWith);
|
||||||
$recipientDisplayName = '';
|
$recipientDisplayName = '';
|
||||||
if($user) {
|
if ($user) {
|
||||||
$recipientDisplayName = $user->getDisplayName();
|
$recipientDisplayName = $user->getDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new JSONResponse(
|
return new JSONResponse(
|
||||||
['recipientDisplayName' => $recipientDisplayName],
|
['recipientDisplayName' => $recipientDisplayName],
|
||||||
Http::STATUS_CREATED);
|
Http::STATUS_CREATED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -267,8 +266,7 @@ class RequestHandlerController extends Controller {
|
||||||
return new JSONResponse($e->getReturnMessage(), Http::STATUS_BAD_REQUEST);
|
return new JSONResponse($e->getReturnMessage(), Http::STATUS_BAD_REQUEST);
|
||||||
} catch (AuthenticationFailedException $e) {
|
} catch (AuthenticationFailedException $e) {
|
||||||
return new JSONResponse(["message" => "RESOURCE_NOT_FOUND"], Http::STATUS_FORBIDDEN);
|
return new JSONResponse(["message" => "RESOURCE_NOT_FOUND"], Http::STATUS_FORBIDDEN);
|
||||||
}
|
} catch (\Exception $e) {
|
||||||
catch (\Exception $e) {
|
|
||||||
return new JSONResponse(
|
return new JSONResponse(
|
||||||
['message' => 'Internal error at ' . $this->urlGenerator->getBaseUrl()],
|
['message' => 'Internal error at ' . $this->urlGenerator->getBaseUrl()],
|
||||||
Http::STATUS_BAD_REQUEST
|
Http::STATUS_BAD_REQUEST
|
||||||
|
@ -276,7 +274,6 @@ class RequestHandlerController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
return new JSONResponse($result,Http::STATUS_CREATED);
|
return new JSONResponse($result,Http::STATUS_CREATED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -297,5 +294,4 @@ class RequestHandlerController extends Controller {
|
||||||
|
|
||||||
return $uid;
|
return $uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,6 @@ use OCP\EventDispatcher\IEventDispatcher;
|
||||||
use OCP\Util;
|
use OCP\Util;
|
||||||
|
|
||||||
class Application extends App {
|
class Application extends App {
|
||||||
|
|
||||||
const APP_ID = 'comments';
|
const APP_ID = 'comments';
|
||||||
|
|
||||||
public function __construct(array $urlParams = []) {
|
public function __construct(array $urlParams = []) {
|
||||||
|
|
|
@ -48,12 +48,12 @@ class CommentersSorter implements ISorter {
|
||||||
*/
|
*/
|
||||||
public function sort(array &$sortArray, array $context) {
|
public function sort(array &$sortArray, array $context) {
|
||||||
$commenters = $this->retrieveCommentsInformation($context['itemType'], $context['itemId']);
|
$commenters = $this->retrieveCommentsInformation($context['itemType'], $context['itemId']);
|
||||||
if(count($commenters) === 0) {
|
if (count($commenters) === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($sortArray as $type => &$byType) {
|
foreach ($sortArray as $type => &$byType) {
|
||||||
if(!isset($commenters[$type])) {
|
if (!isset($commenters[$type])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ class CommentersSorter implements ISorter {
|
||||||
|
|
||||||
usort($workArray, function ($a, $b) use ($commenters, $type) {
|
usort($workArray, function ($a, $b) use ($commenters, $type) {
|
||||||
$r = $this->compare($a[1], $b[1], $commenters[$type]);
|
$r = $this->compare($a[1], $b[1], $commenters[$type]);
|
||||||
if($r === 0) {
|
if ($r === 0) {
|
||||||
$r = $a[0] - $b[0];
|
$r = $a[0] - $b[0];
|
||||||
}
|
}
|
||||||
return $r;
|
return $r;
|
||||||
|
@ -84,16 +84,16 @@ class CommentersSorter implements ISorter {
|
||||||
*/
|
*/
|
||||||
protected function retrieveCommentsInformation($type, $id) {
|
protected function retrieveCommentsInformation($type, $id) {
|
||||||
$comments = $this->commentsManager->getForObject($type, $id);
|
$comments = $this->commentsManager->getForObject($type, $id);
|
||||||
if(count($comments) === 0) {
|
if (count($comments) === 0) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$actors = [];
|
$actors = [];
|
||||||
foreach ($comments as $comment) {
|
foreach ($comments as $comment) {
|
||||||
if(!isset($actors[$comment->getActorType()])) {
|
if (!isset($actors[$comment->getActorType()])) {
|
||||||
$actors[$comment->getActorType()] = [];
|
$actors[$comment->getActorType()] = [];
|
||||||
}
|
}
|
||||||
if(!isset($actors[$comment->getActorType()][$comment->getActorId()])) {
|
if (!isset($actors[$comment->getActorType()][$comment->getActorId()])) {
|
||||||
$actors[$comment->getActorType()][$comment->getActorId()] = 1;
|
$actors[$comment->getActorType()][$comment->getActorId()] = 1;
|
||||||
} else {
|
} else {
|
||||||
$actors[$comment->getActorType()][$comment->getActorId()]++;
|
$actors[$comment->getActorType()][$comment->getActorId()]++;
|
||||||
|
|
|
@ -108,7 +108,7 @@ class Notifications extends Controller {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$comment = $this->commentsManager->get($id);
|
$comment = $this->commentsManager->get($id);
|
||||||
if($comment->getObjectType() !== 'files') {
|
if ($comment->getObjectType() !== 'files') {
|
||||||
return new NotFoundResponse();
|
return new NotFoundResponse();
|
||||||
}
|
}
|
||||||
$userFolder = $this->rootFolder->getUserFolder($currentUser->getUID());
|
$userFolder = $this->rootFolder->getUserFolder($currentUser->getUID());
|
||||||
|
|
|
@ -49,13 +49,13 @@ class EventHandler implements ICommentsEventHandler {
|
||||||
* @param CommentsEvent $event
|
* @param CommentsEvent $event
|
||||||
*/
|
*/
|
||||||
public function handle(CommentsEvent $event) {
|
public function handle(CommentsEvent $event) {
|
||||||
if($event->getComment()->getObjectType() !== 'files') {
|
if ($event->getComment()->getObjectType() !== 'files') {
|
||||||
// this is a 'files'-specific Handler
|
// this is a 'files'-specific Handler
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$eventType = $event->getEvent();
|
$eventType = $event->getEvent();
|
||||||
if($eventType === CommentsEvent::EVENT_ADD
|
if ($eventType === CommentsEvent::EVENT_ADD
|
||||||
) {
|
) {
|
||||||
$this->notificationHandler($event);
|
$this->notificationHandler($event);
|
||||||
$this->activityHandler($event);
|
$this->activityHandler($event);
|
||||||
|
@ -67,7 +67,7 @@ class EventHandler implements ICommentsEventHandler {
|
||||||
CommentsEvent::EVENT_UPDATE,
|
CommentsEvent::EVENT_UPDATE,
|
||||||
CommentsEvent::EVENT_DELETE,
|
CommentsEvent::EVENT_DELETE,
|
||||||
];
|
];
|
||||||
if(in_array($eventType, $applicableEvents)) {
|
if (in_array($eventType, $applicableEvents)) {
|
||||||
$this->notificationHandler($event);
|
$this->notificationHandler($event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,5 +43,4 @@ class LoadAdditionalScripts implements IEventListener {
|
||||||
// we properly split it between files list and sidebar
|
// we properly split it between files list and sidebar
|
||||||
Util::addScript(Application::APP_ID, 'comments');
|
Util::addScript(Application::APP_ID, 'comments');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,5 +42,4 @@ class LoadSidebarScripts implements IEventListener {
|
||||||
// we properly split it between files list and sidebar
|
// we properly split it between files list and sidebar
|
||||||
Util::addScript(Application::APP_ID, 'comments');
|
Util::addScript(Application::APP_ID, 'comments');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,6 @@ class Listener {
|
||||||
IManager $notificationManager,
|
IManager $notificationManager,
|
||||||
IUserManager $userManager
|
IUserManager $userManager
|
||||||
) {
|
) {
|
||||||
|
|
||||||
$this->notificationManager = $notificationManager;
|
$this->notificationManager = $notificationManager;
|
||||||
$this->userManager = $userManager;
|
$this->userManager = $userManager;
|
||||||
}
|
}
|
||||||
|
@ -57,15 +56,15 @@ class Listener {
|
||||||
$comment = $event->getComment();
|
$comment = $event->getComment();
|
||||||
|
|
||||||
$mentions = $this->extractMentions($comment->getMentions());
|
$mentions = $this->extractMentions($comment->getMentions());
|
||||||
if(empty($mentions)) {
|
if (empty($mentions)) {
|
||||||
// no one to notify
|
// no one to notify
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$notification = $this->instantiateNotification($comment);
|
$notification = $this->instantiateNotification($comment);
|
||||||
|
|
||||||
foreach($mentions as $uid) {
|
foreach ($mentions as $uid) {
|
||||||
if(($comment->getActorType() === 'users' && $uid === $comment->getActorId())
|
if (($comment->getActorType() === 'users' && $uid === $comment->getActorId())
|
||||||
|| !$this->userManager->userExists($uid)
|
|| !$this->userManager->userExists($uid)
|
||||||
) {
|
) {
|
||||||
// do not notify unknown users or yourself
|
// do not notify unknown users or yourself
|
||||||
|
@ -73,9 +72,8 @@ class Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
$notification->setUser($uid);
|
$notification->setUser($uid);
|
||||||
if($event->getEvent() === CommentsEvent::EVENT_DELETE
|
if ($event->getEvent() === CommentsEvent::EVENT_DELETE
|
||||||
|| $event->getEvent() === CommentsEvent::EVENT_PRE_UPDATE)
|
|| $event->getEvent() === CommentsEvent::EVENT_PRE_UPDATE) {
|
||||||
{
|
|
||||||
$this->notificationManager->markProcessed($notification);
|
$this->notificationManager->markProcessed($notification);
|
||||||
} else {
|
} else {
|
||||||
$this->notificationManager->notify($notification);
|
$this->notificationManager->notify($notification);
|
||||||
|
@ -107,12 +105,12 @@ class Listener {
|
||||||
* @return string[] containing the mentions, e.g. ['alice', 'bob']
|
* @return string[] containing the mentions, e.g. ['alice', 'bob']
|
||||||
*/
|
*/
|
||||||
public function extractMentions(array $mentions) {
|
public function extractMentions(array $mentions) {
|
||||||
if(empty($mentions)) {
|
if (empty($mentions)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
$uids = [];
|
$uids = [];
|
||||||
foreach($mentions as $mention) {
|
foreach ($mentions as $mention) {
|
||||||
if($mention['type'] === 'user') {
|
if ($mention['type'] === 'user') {
|
||||||
$uids[] = $mention['id'];
|
$uids[] = $mention['id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,12 +96,12 @@ class Notifier implements INotifier {
|
||||||
* @since 9.0.0
|
* @since 9.0.0
|
||||||
*/
|
*/
|
||||||
public function prepare(INotification $notification, string $languageCode): INotification {
|
public function prepare(INotification $notification, string $languageCode): INotification {
|
||||||
if($notification->getApp() !== 'comments') {
|
if ($notification->getApp() !== 'comments') {
|
||||||
throw new \InvalidArgumentException();
|
throw new \InvalidArgumentException();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$comment = $this->commentsManager->get($notification->getObjectId());
|
$comment = $this->commentsManager->get($notification->getObjectId());
|
||||||
} catch(NotFoundException $e) {
|
} catch (NotFoundException $e) {
|
||||||
// needs to be converted to InvalidArgumentException, otherwise none Notifications will be shown at all
|
// needs to be converted to InvalidArgumentException, otherwise none Notifications will be shown at all
|
||||||
throw new \InvalidArgumentException('Comment not found', 0, $e);
|
throw new \InvalidArgumentException('Comment not found', 0, $e);
|
||||||
}
|
}
|
||||||
|
@ -118,12 +118,12 @@ class Notifier implements INotifier {
|
||||||
switch ($notification->getSubject()) {
|
switch ($notification->getSubject()) {
|
||||||
case 'mention':
|
case 'mention':
|
||||||
$parameters = $notification->getSubjectParameters();
|
$parameters = $notification->getSubjectParameters();
|
||||||
if($parameters[0] !== 'files') {
|
if ($parameters[0] !== 'files') {
|
||||||
throw new \InvalidArgumentException('Unsupported comment object');
|
throw new \InvalidArgumentException('Unsupported comment object');
|
||||||
}
|
}
|
||||||
$userFolder = $this->rootFolder->getUserFolder($notification->getUser());
|
$userFolder = $this->rootFolder->getUserFolder($notification->getUser());
|
||||||
$nodes = $userFolder->getById((int)$parameters[1]);
|
$nodes = $userFolder->getById((int)$parameters[1]);
|
||||||
if(empty($nodes)) {
|
if (empty($nodes)) {
|
||||||
throw new AlreadyProcessedException();
|
throw new AlreadyProcessedException();
|
||||||
}
|
}
|
||||||
$node = $nodes[0];
|
$node = $nodes[0];
|
||||||
|
|
|
@ -29,7 +29,6 @@ use OCP\Files\NotFoundException;
|
||||||
use OCP\Search\Result as BaseResult;
|
use OCP\Search\Result as BaseResult;
|
||||||
|
|
||||||
class Result extends BaseResult {
|
class Result extends BaseResult {
|
||||||
|
|
||||||
public $type = 'comment';
|
public $type = 'comment';
|
||||||
public $comment;
|
public $comment;
|
||||||
public $authorId;
|
public $authorId;
|
||||||
|
@ -108,5 +107,4 @@ class Result extends BaseResult {
|
||||||
|
|
||||||
return $prefix . mb_substr($message, $start, $end - $start) . $suffix;
|
return $prefix . mb_substr($message, $start, $end - $start) . $suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ class ApplicationTest extends TestCase {
|
||||||
Notifier::class,
|
Notifier::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach($services as $service) {
|
foreach ($services as $service) {
|
||||||
$s = $c->query($service);
|
$s = $c->query($service);
|
||||||
$this->assertInstanceOf($service, $s);
|
$this->assertInstanceOf($service, $s);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,9 +49,9 @@ class CommentersSorterTest extends TestCase {
|
||||||
*/
|
*/
|
||||||
public function testSort($data) {
|
public function testSort($data) {
|
||||||
$commentMocks = [];
|
$commentMocks = [];
|
||||||
foreach($data['actors'] as $actorType => $actors) {
|
foreach ($data['actors'] as $actorType => $actors) {
|
||||||
foreach ($actors as $actorId => $noOfComments) {
|
foreach ($actors as $actorId => $noOfComments) {
|
||||||
for($i=0;$i<$noOfComments;$i++) {
|
for ($i=0;$i<$noOfComments;$i++) {
|
||||||
$mock = $this->createMock(IComment::class);
|
$mock = $this->createMock(IComment::class);
|
||||||
$mock->expects($this->atLeastOnce())
|
$mock->expects($this->atLeastOnce())
|
||||||
->method('getActorType')
|
->method('getActorType')
|
||||||
|
|
|
@ -116,5 +116,4 @@ class EventHandlerTest extends TestCase {
|
||||||
|
|
||||||
$this->eventHandler->handle($event);
|
$this->eventHandler->handle($event);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -616,5 +616,4 @@ class NotifierTest extends TestCase {
|
||||||
|
|
||||||
$this->notifier->prepare($this->notification, $this->lc);
|
$this->notifier->prepare($this->notification, $this->lc);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,6 @@ use Sabre\DAVACL\ACLTrait;
|
||||||
use Sabre\DAVACL\IACL;
|
use Sabre\DAVACL\IACL;
|
||||||
|
|
||||||
class AddressBook extends ExternalAddressBook implements IACL {
|
class AddressBook extends ExternalAddressBook implements IACL {
|
||||||
|
|
||||||
public const URI = 'recent';
|
public const URI = 'recent';
|
||||||
|
|
||||||
use ACLTrait;
|
use ACLTrait;
|
||||||
|
@ -174,5 +173,4 @@ class AddressBook extends ExternalAddressBook implements IACL {
|
||||||
list(, $uid) = \Sabre\Uri\split($this->principalUri);
|
list(, $uid) = \Sabre\Uri\split($this->principalUri);
|
||||||
return $uid;
|
return $uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,5 +77,4 @@ class AddressBookProvider implements IAddressBookProvider {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ use OCP\Contacts\Events\ContactInteractedWithEvent;
|
||||||
use OCP\EventDispatcher\IEventDispatcher;
|
use OCP\EventDispatcher\IEventDispatcher;
|
||||||
|
|
||||||
class Application extends App {
|
class Application extends App {
|
||||||
|
|
||||||
public const APP_ID = 'contactsinteraction';
|
public const APP_ID = 'contactsinteraction';
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
|
@ -43,5 +42,4 @@ class Application extends App {
|
||||||
private function registerListeners(IEventDispatcher $dispatcher): void {
|
private function registerListeners(IEventDispatcher $dispatcher): void {
|
||||||
$dispatcher->addServiceListener(ContactInteractedWithEvent::class, ContactInteractionListener::class);
|
$dispatcher->addServiceListener(ContactInteractedWithEvent::class, ContactInteractionListener::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,5 +48,4 @@ class CleanupJob extends TimedJob {
|
||||||
$time->modify('-7days');
|
$time->modify('-7days');
|
||||||
$this->mapper->cleanUp($time->getTimestamp());
|
$this->mapper->cleanUp($time->getTimestamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ use Sabre\DAVACL\ACLTrait;
|
||||||
use Sabre\DAVACL\IACL;
|
use Sabre\DAVACL\IACL;
|
||||||
|
|
||||||
class Card implements ICard, IACL {
|
class Card implements ICard, IACL {
|
||||||
|
|
||||||
use ACLTrait;
|
use ACLTrait;
|
||||||
|
|
||||||
/** @var RecentContact */
|
/** @var RecentContact */
|
||||||
|
@ -133,5 +132,4 @@ class Card implements ICard, IACL {
|
||||||
function getLastModified(): ?int {
|
function getLastModified(): ?int {
|
||||||
return $this->contact->getLastContact();
|
return $this->contact->getLastContact();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,5 +88,4 @@ class CardSearchDao {
|
||||||
|
|
||||||
return $card;
|
return $card;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,5 +69,4 @@ class RecentContact extends Entity {
|
||||||
$this->addType('card', 'string');
|
$this->addType('card', 'string');
|
||||||
$this->addType('lastContact', 'int');
|
$this->addType('lastContact', 'int');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ use OCP\IDBConnection;
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
|
|
||||||
class RecentContactMapper extends QBMapper {
|
class RecentContactMapper extends QBMapper {
|
||||||
|
|
||||||
public const TABLE_NAME = 'recent_contact';
|
public const TABLE_NAME = 'recent_contact';
|
||||||
|
|
||||||
public function __construct(IDBConnection $db) {
|
public function __construct(IDBConnection $db) {
|
||||||
|
@ -114,5 +113,4 @@ class RecentContactMapper extends QBMapper {
|
||||||
|
|
||||||
$delete->execute();
|
$delete->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,5 +167,4 @@ class ContactInteractionListener implements IEventListener {
|
||||||
|
|
||||||
return (new VCard($props))->serialize();
|
return (new VCard($props))->serialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,5 +89,4 @@ class Version010000Date20200304152605 extends SimpleMigrationStep {
|
||||||
|
|
||||||
return $schema;
|
return $schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ $eventHandler = function () use ($app) {
|
||||||
$job = $app->getContainer()->query(\OCA\DAV\BackgroundJob\UpdateCalendarResourcesRoomsBackgroundJob::class);
|
$job = $app->getContainer()->query(\OCA\DAV\BackgroundJob\UpdateCalendarResourcesRoomsBackgroundJob::class);
|
||||||
$job->run([]);
|
$job->run([]);
|
||||||
$app->getContainer()->getServer()->getJobList()->setLastRun($job);
|
$app->getContainer()->getServer()->getJobList()->setLastRun($job);
|
||||||
} catch(\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
$app->getContainer()->getServer()->getLogger()->logException($ex);
|
$app->getContainer()->getServer()->getLogger()->logException($ex);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -65,7 +65,7 @@ $size = filesize($file);
|
||||||
$stream = fopen($file, 'r');
|
$stream = fopen($file, 'r');
|
||||||
|
|
||||||
$index = 0;
|
$index = 0;
|
||||||
while(!feof($stream)) {
|
while (!feof($stream)) {
|
||||||
request($client, 'PUT', "$uploadUrl/$index", fread($stream, $chunkSize));
|
request($client, 'PUT', "$uploadUrl/$index", fread($stream, $chunkSize));
|
||||||
$index++;
|
$index++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,6 @@ use OCP\IUser;
|
||||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||||
|
|
||||||
class Application extends App {
|
class Application extends App {
|
||||||
|
|
||||||
const APP_ID = 'dav';
|
const APP_ID = 'dav';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -265,9 +264,8 @@ class Application extends App {
|
||||||
$notificationProviderManager->registerProvider(AudioProvider::class);
|
$notificationProviderManager->registerProvider(AudioProvider::class);
|
||||||
$notificationProviderManager->registerProvider(EmailProvider::class);
|
$notificationProviderManager->registerProvider(EmailProvider::class);
|
||||||
$notificationProviderManager->registerProvider(PushProvider::class);
|
$notificationProviderManager->registerProvider(PushProvider::class);
|
||||||
} catch(\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
$this->getContainer()->getServer()->getLogger()->logException($ex);
|
$this->getContainer()->getServer()->getLogger()->logException($ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -303,5 +303,4 @@ class PluginManager {
|
||||||
$this->calendarPlugins[] = $instantiatedCalendarPlugin;
|
$this->calendarPlugins[] = $instantiatedCalendarPlugin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ class AvatarHome implements ICollection {
|
||||||
return [
|
return [
|
||||||
$this->getChild('96.jpeg')
|
$this->getChild('96.jpeg')
|
||||||
];
|
];
|
||||||
} catch(NotFound $exception) {
|
} catch (NotFound $exception) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,6 +116,4 @@ class AvatarHome implements ICollection {
|
||||||
public function getLastModified() {
|
public function getLastModified() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,5 @@ class AvatarNode extends File {
|
||||||
return (int)$timestamp;
|
return (int)$timestamp;
|
||||||
}
|
}
|
||||||
return $timestamp;
|
return $timestamp;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,5 +47,4 @@ class RootCollection extends AbstractPrincipalCollection {
|
||||||
public function getName() {
|
public function getName() {
|
||||||
return 'avatars';
|
return 'avatars';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ class BuildReminderIndexBackgroundJob extends QueuedJob {
|
||||||
->orderBy('id', 'ASC');
|
->orderBy('id', 'ASC');
|
||||||
|
|
||||||
$stmt = $query->execute();
|
$stmt = $query->execute();
|
||||||
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
$offset = $row['id'];
|
$offset = $row['id'];
|
||||||
if (is_resource($row['calendardata'])) {
|
if (is_resource($row['calendardata'])) {
|
||||||
$row['calendardata'] = stream_get_contents($row['calendardata']);
|
$row['calendardata'] = stream_get_contents($row['calendardata']);
|
||||||
|
@ -126,7 +126,7 @@ class BuildReminderIndexBackgroundJob extends QueuedJob {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->reminderService->onTouchCalendarObject('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', $row);
|
$this->reminderService->onTouchCalendarObject('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', $row);
|
||||||
} catch(\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
$this->logger->logException($ex);
|
$this->logger->logException($ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,5 +48,4 @@ class CleanupDirectLinksJob extends TimedJob {
|
||||||
// Delete all shares expired 24 hours ago
|
// Delete all shares expired 24 hours ago
|
||||||
$this->mapper->deleteExpired($this->timeFactory->getTime() - 60*60*24);
|
$this->mapper->deleteExpired($this->timeFactory->getTime() - 60*60*24);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ class RefreshWebcalJob extends Job {
|
||||||
try {
|
try {
|
||||||
/** @var DateInterval $dateInterval */
|
/** @var DateInterval $dateInterval */
|
||||||
$dateInterval = DateTimeParser::parseDuration($refreshRate);
|
$dateInterval = DateTimeParser::parseDuration($refreshRate);
|
||||||
} catch(InvalidDataException $ex) {
|
} catch (InvalidDataException $ex) {
|
||||||
$this->logger->logException($ex);
|
$this->logger->logException($ex);
|
||||||
$this->logger->warning("Subscription $subscriptionId could not be refreshed, refreshrate in database is invalid");
|
$this->logger->warning("Subscription $subscriptionId could not be refreshed, refreshrate in database is invalid");
|
||||||
return;
|
return;
|
||||||
|
@ -142,7 +142,7 @@ class RefreshWebcalJob extends Job {
|
||||||
RefreshWebcalService::STRIP_TODOS,
|
RefreshWebcalService::STRIP_TODOS,
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach($forceInt as $column) {
|
foreach ($forceInt as $column) {
|
||||||
if (isset($row[$column])) {
|
if (isset($row[$column])) {
|
||||||
$row[$column] = (int) $row[$column];
|
$row[$column] = (int) $row[$column];
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,5 +64,4 @@ class RegisterRegenerateBirthdayCalendars extends QueuedJob {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
||||||
string $principalPrefix):void {
|
string $principalPrefix):void {
|
||||||
$backends = $backendManager->getBackends();
|
$backends = $backendManager->getBackends();
|
||||||
|
|
||||||
foreach($backends as $backend) {
|
foreach ($backends as $backend) {
|
||||||
$backendId = $backend->getBackendIdentifier();
|
$backendId = $backend->getBackendIdentifier();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -115,7 +115,7 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
||||||
} else {
|
} else {
|
||||||
$list = $backend->listAllRooms();
|
$list = $backend->listAllRooms();
|
||||||
}
|
}
|
||||||
} catch(BackendTemporarilyUnavailableException $ex) {
|
} catch (BackendTemporarilyUnavailableException $ex) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
||||||
$deletedIds = array_diff($cachedList, $list);
|
$deletedIds = array_diff($cachedList, $list);
|
||||||
$editedIds = array_intersect($list, $cachedList);
|
$editedIds = array_intersect($list, $cachedList);
|
||||||
|
|
||||||
foreach($newIds as $newId) {
|
foreach ($newIds as $newId) {
|
||||||
try {
|
try {
|
||||||
if ($backend instanceof IResourceBackend) {
|
if ($backend instanceof IResourceBackend) {
|
||||||
$resource = $backend->getResource($newId);
|
$resource = $backend->getResource($newId);
|
||||||
|
@ -136,7 +136,7 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
||||||
if ($resource instanceof IMetadataProvider) {
|
if ($resource instanceof IMetadataProvider) {
|
||||||
$metadata = $this->getAllMetadataOfBackend($resource);
|
$metadata = $this->getAllMetadataOfBackend($resource);
|
||||||
}
|
}
|
||||||
} catch(BackendTemporarilyUnavailableException $ex) {
|
} catch (BackendTemporarilyUnavailableException $ex) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
||||||
// when an event is actually scheduled with this resource / room
|
// when an event is actually scheduled with this resource / room
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($deletedIds as $deletedId) {
|
foreach ($deletedIds as $deletedId) {
|
||||||
$id = $this->getIdForBackendAndResource($dbTable, $backendId, $deletedId);
|
$id = $this->getIdForBackendAndResource($dbTable, $backendId, $deletedId);
|
||||||
$this->deleteFromCache($dbTable, $id);
|
$this->deleteFromCache($dbTable, $id);
|
||||||
$this->deleteMetadataFromCache($dbTableMetadata, $foreignKey, $id);
|
$this->deleteMetadataFromCache($dbTableMetadata, $foreignKey, $id);
|
||||||
|
@ -155,7 +155,7 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
||||||
$this->deleteCalendarDataForResource($principalPrefix, $principalName);
|
$this->deleteCalendarDataForResource($principalPrefix, $principalName);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($editedIds as $editedId) {
|
foreach ($editedIds as $editedId) {
|
||||||
$id = $this->getIdForBackendAndResource($dbTable, $backendId, $editedId);
|
$id = $this->getIdForBackendAndResource($dbTable, $backendId, $editedId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -169,7 +169,7 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
||||||
if ($resource instanceof IMetadataProvider) {
|
if ($resource instanceof IMetadataProvider) {
|
||||||
$metadata = $this->getAllMetadataOfBackend($resource);
|
$metadata = $this->getAllMetadataOfBackend($resource);
|
||||||
}
|
}
|
||||||
} catch(BackendTemporarilyUnavailableException $ex) {
|
} catch (BackendTemporarilyUnavailableException $ex) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
||||||
string $foreignKey,
|
string $foreignKey,
|
||||||
int $foreignId,
|
int $foreignId,
|
||||||
array $metadata):void {
|
array $metadata):void {
|
||||||
foreach($metadata as $key => $value) {
|
foreach ($metadata as $key => $value) {
|
||||||
$query = $this->dbConnection->getQueryBuilder();
|
$query = $this->dbConnection->getQueryBuilder();
|
||||||
$query->insert($table)
|
$query->insert($table)
|
||||||
->values([
|
->values([
|
||||||
|
@ -308,7 +308,7 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
||||||
->execute();
|
->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($deletedMetadata as $key => $value) {
|
foreach ($deletedMetadata as $key => $value) {
|
||||||
$query = $this->dbConnection->getQueryBuilder();
|
$query = $this->dbConnection->getQueryBuilder();
|
||||||
$query->delete($dbTable)
|
$query->delete($dbTable)
|
||||||
->where($query->expr()->eq($foreignKey, $query->createNamedParameter($id)))
|
->where($query->expr()->eq($foreignKey, $query->createNamedParameter($id)))
|
||||||
|
@ -317,7 +317,7 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
||||||
}
|
}
|
||||||
|
|
||||||
$existingKeys = array_keys(array_intersect_key($metadata, $cachedMetadata));
|
$existingKeys = array_keys(array_intersect_key($metadata, $cachedMetadata));
|
||||||
foreach($existingKeys as $existingKey) {
|
foreach ($existingKeys as $existingKey) {
|
||||||
if ($metadata[$existingKey] !== $cachedMetadata[$existingKey]) {
|
if ($metadata[$existingKey] !== $cachedMetadata[$existingKey]) {
|
||||||
$query = $this->dbConnection->getQueryBuilder();
|
$query = $this->dbConnection->getQueryBuilder();
|
||||||
$query->update($dbTable)
|
$query->update($dbTable)
|
||||||
|
@ -352,7 +352,7 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
||||||
|
|
||||||
$keys = $resource->getAllAvailableMetadataKeys();
|
$keys = $resource->getAllAvailableMetadataKeys();
|
||||||
$metadata = [];
|
$metadata = [];
|
||||||
foreach($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
$metadata[$key] = $resource->getMetadataForKey($key);
|
$metadata[$key] = $resource->getMetadataForKey($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,7 +376,7 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
|
||||||
$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
$metadata = [];
|
$metadata = [];
|
||||||
foreach($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
$metadata[$row['key']] = $row['value'];
|
$metadata[$row['key']] = $row['value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,5 +86,4 @@ class UploadCleanup extends TimedJob {
|
||||||
$this->jobList->remove(self::class, $argument);
|
$this->jobList->remove(self::class, $argument);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -469,7 +469,7 @@ class Backend {
|
||||||
protected function getObjectNameAndType(array $objectData) {
|
protected function getObjectNameAndType(array $objectData) {
|
||||||
$vObject = Reader::read($objectData['calendardata']);
|
$vObject = Reader::read($objectData['calendardata']);
|
||||||
$component = $componentType = null;
|
$component = $componentType = null;
|
||||||
foreach($vObject->getComponents() as $component) {
|
foreach ($vObject->getComponents() as $component) {
|
||||||
if (in_array($component->name, ['VEVENT', 'VTODO'])) {
|
if (in_array($component->name, ['VEVENT', 'VTODO'])) {
|
||||||
$componentType = $component->name;
|
$componentType = $component->name;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -36,7 +36,6 @@ use OCP\IUserManager;
|
||||||
use OCP\L10N\IFactory;
|
use OCP\L10N\IFactory;
|
||||||
|
|
||||||
class Calendar extends Base {
|
class Calendar extends Base {
|
||||||
|
|
||||||
const SUBJECT_ADD = 'calendar_add';
|
const SUBJECT_ADD = 'calendar_add';
|
||||||
const SUBJECT_UPDATE = 'calendar_update';
|
const SUBJECT_UPDATE = 'calendar_update';
|
||||||
const SUBJECT_DELETE = 'calendar_delete';
|
const SUBJECT_DELETE = 'calendar_delete';
|
||||||
|
@ -111,12 +110,10 @@ class Calendar extends Base {
|
||||||
$subject = $this->l->t('{actor} updated calendar {calendar}');
|
$subject = $this->l->t('{actor} updated calendar {calendar}');
|
||||||
} elseif ($event->getSubject() === self::SUBJECT_UPDATE . '_self') {
|
} elseif ($event->getSubject() === self::SUBJECT_UPDATE . '_self') {
|
||||||
$subject = $this->l->t('You updated calendar {calendar}');
|
$subject = $this->l->t('You updated calendar {calendar}');
|
||||||
|
|
||||||
} elseif ($event->getSubject() === self::SUBJECT_PUBLISH . '_self') {
|
} elseif ($event->getSubject() === self::SUBJECT_PUBLISH . '_self') {
|
||||||
$subject = $this->l->t('You shared calendar {calendar} as public link');
|
$subject = $this->l->t('You shared calendar {calendar} as public link');
|
||||||
} elseif ($event->getSubject() === self::SUBJECT_UNPUBLISH . '_self') {
|
} elseif ($event->getSubject() === self::SUBJECT_UNPUBLISH . '_self') {
|
||||||
$subject = $this->l->t('You removed public link for calendar {calendar}');
|
$subject = $this->l->t('You removed public link for calendar {calendar}');
|
||||||
|
|
||||||
} elseif ($event->getSubject() === self::SUBJECT_SHARE_USER) {
|
} elseif ($event->getSubject() === self::SUBJECT_SHARE_USER) {
|
||||||
$subject = $this->l->t('{actor} shared calendar {calendar} with you');
|
$subject = $this->l->t('{actor} shared calendar {calendar} with you');
|
||||||
} elseif ($event->getSubject() === self::SUBJECT_SHARE_USER . '_you') {
|
} elseif ($event->getSubject() === self::SUBJECT_SHARE_USER . '_you') {
|
||||||
|
@ -131,7 +128,6 @@ class Calendar extends Base {
|
||||||
$subject = $this->l->t('{actor} unshared calendar {calendar} from {user}');
|
$subject = $this->l->t('{actor} unshared calendar {calendar} from {user}');
|
||||||
} elseif ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_self') {
|
} elseif ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_self') {
|
||||||
$subject = $this->l->t('{actor} unshared calendar {calendar} from themselves');
|
$subject = $this->l->t('{actor} unshared calendar {calendar} from themselves');
|
||||||
|
|
||||||
} elseif ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_you') {
|
} elseif ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_you') {
|
||||||
$subject = $this->l->t('You shared calendar {calendar} with group {group}');
|
$subject = $this->l->t('You shared calendar {calendar} with group {group}');
|
||||||
} elseif ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_by') {
|
} elseif ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_by') {
|
||||||
|
|
|
@ -34,7 +34,6 @@ use OCP\IUserManager;
|
||||||
use OCP\L10N\IFactory;
|
use OCP\L10N\IFactory;
|
||||||
|
|
||||||
class Event extends Base {
|
class Event extends Base {
|
||||||
|
|
||||||
const SUBJECT_OBJECT_ADD = 'object_add';
|
const SUBJECT_OBJECT_ADD = 'object_add';
|
||||||
const SUBJECT_OBJECT_UPDATE = 'object_update';
|
const SUBJECT_OBJECT_UPDATE = 'object_update';
|
||||||
const SUBJECT_OBJECT_DELETE = 'object_delete';
|
const SUBJECT_OBJECT_DELETE = 'object_delete';
|
||||||
|
|
|
@ -60,7 +60,6 @@ class Todo extends Event {
|
||||||
$subject = $this->l->t('{actor} updated todo {todo} in list {calendar}');
|
$subject = $this->l->t('{actor} updated todo {todo} in list {calendar}');
|
||||||
} elseif ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_self') {
|
} elseif ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_self') {
|
||||||
$subject = $this->l->t('You updated todo {todo} in list {calendar}');
|
$subject = $this->l->t('You updated todo {todo} in list {calendar}');
|
||||||
|
|
||||||
} elseif ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_completed') {
|
} elseif ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_completed') {
|
||||||
$subject = $this->l->t('{actor} solved todo {todo} in list {calendar}');
|
$subject = $this->l->t('{actor} solved todo {todo} in list {calendar}');
|
||||||
} elseif ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_completed_self') {
|
} elseif ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_completed_self') {
|
||||||
|
|
|
@ -49,7 +49,6 @@ use Sabre\VObject\Reader;
|
||||||
* @package OCA\DAV\CalDAV
|
* @package OCA\DAV\CalDAV
|
||||||
*/
|
*/
|
||||||
class BirthdayService {
|
class BirthdayService {
|
||||||
|
|
||||||
const BIRTHDAY_CALENDAR_URI = 'contact_birthdays';
|
const BIRTHDAY_CALENDAR_URI = 'contact_birthdays';
|
||||||
|
|
||||||
/** @var GroupPrincipalBackend */
|
/** @var GroupPrincipalBackend */
|
||||||
|
@ -298,7 +297,7 @@ class BirthdayService {
|
||||||
$calendar = $this->calDavBackEnd->getCalendarByUri($principal, self::BIRTHDAY_CALENDAR_URI);
|
$calendar = $this->calDavBackEnd->getCalendarByUri($principal, self::BIRTHDAY_CALENDAR_URI);
|
||||||
$calendarObjects = $this->calDavBackEnd->getCalendarObjects($calendar['id'], CalDavBackend::CALENDAR_TYPE_CALENDAR);
|
$calendarObjects = $this->calDavBackEnd->getCalendarObjects($calendar['id'], CalDavBackend::CALENDAR_TYPE_CALENDAR);
|
||||||
|
|
||||||
foreach($calendarObjects as $calendarObject) {
|
foreach ($calendarObjects as $calendarObject) {
|
||||||
$this->calDavBackEnd->deleteCalendarObject($calendar['id'], $calendarObject['uri'], CalDavBackend::CALENDAR_TYPE_CALENDAR);
|
$this->calDavBackEnd->deleteCalendarObject($calendar['id'], $calendarObject['uri'], CalDavBackend::CALENDAR_TYPE_CALENDAR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -311,9 +310,9 @@ class BirthdayService {
|
||||||
$principal = 'principals/users/'.$user;
|
$principal = 'principals/users/'.$user;
|
||||||
$this->ensureCalendarExists($principal);
|
$this->ensureCalendarExists($principal);
|
||||||
$books = $this->cardDavBackEnd->getAddressBooksForUser($principal);
|
$books = $this->cardDavBackEnd->getAddressBooksForUser($principal);
|
||||||
foreach($books as $book) {
|
foreach ($books as $book) {
|
||||||
$cards = $this->cardDavBackEnd->getCards($book['id']);
|
$cards = $this->cardDavBackEnd->getCards($book['id']);
|
||||||
foreach($cards as $card) {
|
foreach ($cards as $card) {
|
||||||
$this->onCardChanged((int) $book['id'], $card['uri'], $card['carddata']);
|
$this->onCardChanged((int) $book['id'], $card['uri'], $card['carddata']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -455,7 +454,7 @@ class BirthdayService {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch($field) {
|
switch ($field) {
|
||||||
case 'BDAY':
|
case 'BDAY':
|
||||||
return implode('', [
|
return implode('', [
|
||||||
$name,
|
$name,
|
||||||
|
|
|
@ -136,7 +136,6 @@ class CachedSubscription extends \Sabre\CalDAV\Calendar {
|
||||||
|
|
||||||
$obj['acl'] = $this->getChildACL();
|
$obj['acl'] = $this->getChildACL();
|
||||||
return new CachedSubscriptionObject($this->caldavBackend, $this->calendarInfo, $obj);
|
return new CachedSubscriptionObject($this->caldavBackend, $this->calendarInfo, $obj);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -146,7 +145,7 @@ class CachedSubscription extends \Sabre\CalDAV\Calendar {
|
||||||
$objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id'], CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
|
$objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id'], CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
|
||||||
|
|
||||||
$children = [];
|
$children = [];
|
||||||
foreach($objs as $obj) {
|
foreach ($objs as $obj) {
|
||||||
$children[] = new CachedSubscriptionObject($this->caldavBackend, $this->calendarInfo, $obj);
|
$children[] = new CachedSubscriptionObject($this->caldavBackend, $this->calendarInfo, $obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +160,7 @@ class CachedSubscription extends \Sabre\CalDAV\Calendar {
|
||||||
$objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
|
$objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
|
||||||
|
|
||||||
$children = [];
|
$children = [];
|
||||||
foreach($objs as $obj) {
|
foreach ($objs as $obj) {
|
||||||
$children[] = new CachedSubscriptionObject($this->caldavBackend, $this->calendarInfo, $obj);
|
$children[] = new CachedSubscriptionObject($this->caldavBackend, $this->calendarInfo, $obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,6 @@ use Symfony\Component\EventDispatcher\GenericEvent;
|
||||||
* @package OCA\DAV\CalDAV
|
* @package OCA\DAV\CalDAV
|
||||||
*/
|
*/
|
||||||
class CalDavBackend extends AbstractBackend implements SyncSupport, SubscriptionSupport, SchedulingSupport {
|
class CalDavBackend extends AbstractBackend implements SyncSupport, SubscriptionSupport, SchedulingSupport {
|
||||||
|
|
||||||
const CALENDAR_TYPE_CALENDAR = 0;
|
const CALENDAR_TYPE_CALENDAR = 0;
|
||||||
const CALENDAR_TYPE_SUBSCRIPTION = 1;
|
const CALENDAR_TYPE_SUBSCRIPTION = 1;
|
||||||
|
|
||||||
|
@ -273,8 +272,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$stmt = $query->execute();
|
$stmt = $query->execute();
|
||||||
|
|
||||||
$calendars = [];
|
$calendars = [];
|
||||||
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
|
|
||||||
$components = [];
|
$components = [];
|
||||||
if ($row['components']) {
|
if ($row['components']) {
|
||||||
$components = explode(',',$row['components']);
|
$components = explode(',',$row['components']);
|
||||||
|
@ -291,7 +289,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint),
|
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint),
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach($this->propertyMap as $xmlName=>$dbName) {
|
foreach ($this->propertyMap as $xmlName=>$dbName) {
|
||||||
$calendar[$xmlName] = $row[$dbName];
|
$calendar[$xmlName] = $row[$dbName];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +330,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
|
$readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
|
||||||
while($row = $result->fetch()) {
|
while ($row = $result->fetch()) {
|
||||||
if ($row['principaluri'] === $principalUri) {
|
if ($row['principaluri'] === $principalUri) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -369,7 +367,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$readOnlyPropertyName => $readOnly,
|
$readOnlyPropertyName => $readOnly,
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach($this->propertyMap as $xmlName=>$dbName) {
|
foreach ($this->propertyMap as $xmlName=>$dbName) {
|
||||||
$calendar[$xmlName] = $row[$dbName];
|
$calendar[$xmlName] = $row[$dbName];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,7 +400,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
->orderBy('calendarorder', 'ASC');
|
->orderBy('calendarorder', 'ASC');
|
||||||
$stmt = $query->execute();
|
$stmt = $query->execute();
|
||||||
$calendars = [];
|
$calendars = [];
|
||||||
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
$components = [];
|
$components = [];
|
||||||
if ($row['components']) {
|
if ($row['components']) {
|
||||||
$components = explode(',',$row['components']);
|
$components = explode(',',$row['components']);
|
||||||
|
@ -416,7 +414,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
|
'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
|
||||||
'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
|
'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
|
||||||
];
|
];
|
||||||
foreach($this->propertyMap as $xmlName=>$dbName) {
|
foreach ($this->propertyMap as $xmlName=>$dbName) {
|
||||||
$calendar[$xmlName] = $row[$dbName];
|
$calendar[$xmlName] = $row[$dbName];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,7 +469,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
->andWhere($query->expr()->eq('s.type', $query->createNamedParameter('calendar')))
|
->andWhere($query->expr()->eq('s.type', $query->createNamedParameter('calendar')))
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
while($row = $result->fetch()) {
|
while ($row = $result->fetch()) {
|
||||||
list(, $name) = Uri\split($row['principaluri']);
|
list(, $name) = Uri\split($row['principaluri']);
|
||||||
$row['displayname'] = $row['displayname'] . "($name)";
|
$row['displayname'] = $row['displayname'] . "($name)";
|
||||||
$components = [];
|
$components = [];
|
||||||
|
@ -491,7 +489,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC,
|
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC,
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach($this->propertyMap as $xmlName=>$dbName) {
|
foreach ($this->propertyMap as $xmlName=>$dbName) {
|
||||||
$calendar[$xmlName] = $row[$dbName];
|
$calendar[$xmlName] = $row[$dbName];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,14 +555,13 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC,
|
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC,
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach($this->propertyMap as $xmlName=>$dbName) {
|
foreach ($this->propertyMap as $xmlName=>$dbName) {
|
||||||
$calendar[$xmlName] = $row[$dbName];
|
$calendar[$xmlName] = $row[$dbName];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addOwnerPrincipal($calendar);
|
$this->addOwnerPrincipal($calendar);
|
||||||
|
|
||||||
return $calendar;
|
return $calendar;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -610,7 +607,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
|
'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach($this->propertyMap as $xmlName=>$dbName) {
|
foreach ($this->propertyMap as $xmlName=>$dbName) {
|
||||||
$calendar[$xmlName] = $row[$dbName];
|
$calendar[$xmlName] = $row[$dbName];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,7 +657,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
|
'{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'),
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach($this->propertyMap as $xmlName=>$dbName) {
|
foreach ($this->propertyMap as $xmlName=>$dbName) {
|
||||||
$calendar[$xmlName] = $row[$dbName];
|
$calendar[$xmlName] = $row[$dbName];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -704,7 +701,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
|
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) {
|
foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) {
|
||||||
if (!is_null($row[$dbName])) {
|
if (!is_null($row[$dbName])) {
|
||||||
$subscription[$xmlName] = $row[$dbName];
|
$subscription[$xmlName] = $row[$dbName];
|
||||||
}
|
}
|
||||||
|
@ -753,7 +750,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$values['transparent'] = (int) ($properties[$transp]->getValue() === 'transparent');
|
$values['transparent'] = (int) ($properties[$transp]->getValue() === 'transparent');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($this->propertyMap as $xmlName=>$dbName) {
|
foreach ($this->propertyMap as $xmlName=>$dbName) {
|
||||||
if (isset($properties[$xmlName])) {
|
if (isset($properties[$xmlName])) {
|
||||||
$values[$dbName] = $properties[$xmlName];
|
$values[$dbName] = $properties[$xmlName];
|
||||||
}
|
}
|
||||||
|
@ -761,7 +758,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
|
|
||||||
$query = $this->db->getQueryBuilder();
|
$query = $this->db->getQueryBuilder();
|
||||||
$query->insert('calendars');
|
$query->insert('calendars');
|
||||||
foreach($values as $column => $value) {
|
foreach ($values as $column => $value) {
|
||||||
$query->setValue($column, $query->createNamedParameter($value));
|
$query->setValue($column, $query->createNamedParameter($value));
|
||||||
}
|
}
|
||||||
$query->execute();
|
$query->execute();
|
||||||
|
@ -803,7 +800,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$propPatch->handle($supportedProperties, function ($mutations) use ($calendarId) {
|
$propPatch->handle($supportedProperties, function ($mutations) use ($calendarId) {
|
||||||
$newValues = [];
|
$newValues = [];
|
||||||
foreach ($mutations as $propertyName => $propertyValue) {
|
foreach ($mutations as $propertyName => $propertyValue) {
|
||||||
|
|
||||||
switch ($propertyName) {
|
switch ($propertyName) {
|
||||||
case '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp':
|
case '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp':
|
||||||
$fieldName = 'transparent';
|
$fieldName = 'transparent';
|
||||||
|
@ -814,7 +810,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$newValues[$fieldName] = $propertyValue;
|
$newValues[$fieldName] = $propertyValue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$query = $this->db->getQueryBuilder();
|
$query = $this->db->getQueryBuilder();
|
||||||
$query->update('calendars');
|
$query->update('calendars');
|
||||||
|
@ -923,7 +918,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$stmt = $query->execute();
|
$stmt = $query->execute();
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
|
foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
|
||||||
$result[] = [
|
$result[] = [
|
||||||
'id' => $row['id'],
|
'id' => $row['id'],
|
||||||
'uri' => $row['uri'],
|
'uri' => $row['uri'],
|
||||||
|
@ -966,7 +961,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$stmt = $query->execute();
|
$stmt = $query->execute();
|
||||||
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
if(!$row) {
|
if (!$row) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1326,7 +1321,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$requirePostFilter = false;
|
$requirePostFilter = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$columns = ['uri'];
|
$columns = ['uri'];
|
||||||
if ($requirePostFilter) {
|
if ($requirePostFilter) {
|
||||||
|
@ -1352,13 +1346,13 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$stmt = $query->execute();
|
$stmt = $query->execute();
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
if ($requirePostFilter) {
|
if ($requirePostFilter) {
|
||||||
// validateFilterForObject will parse the calendar data
|
// validateFilterForObject will parse the calendar data
|
||||||
// catch parsing errors
|
// catch parsing errors
|
||||||
try {
|
try {
|
||||||
$matches = $this->validateFilterForObject($row, $filters);
|
$matches = $this->validateFilterForObject($row, $filters);
|
||||||
} catch(ParseException $ex) {
|
} catch (ParseException $ex) {
|
||||||
$this->logger->logException($ex, [
|
$this->logger->logException($ex, [
|
||||||
'app' => 'dav',
|
'app' => 'dav',
|
||||||
'message' => 'Caught parsing exception for calendar data. This usually indicates invalid calendar data. calendar-id:'.$id.' uri:'.$row['uri']
|
'message' => 'Caught parsing exception for calendar data. This usually indicates invalid calendar data. calendar-id:'.$id.' uri:'.$row['uri']
|
||||||
|
@ -1400,7 +1394,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
|
|
||||||
$uriMapper = [];
|
$uriMapper = [];
|
||||||
|
|
||||||
foreach($calendars as $calendar) {
|
foreach ($calendars as $calendar) {
|
||||||
if ($calendar['{http://owncloud.org/ns}owner-principal'] === $principalUri) {
|
if ($calendar['{http://owncloud.org/ns}owner-principal'] === $principalUri) {
|
||||||
$ownCalendars[] = $calendar['id'];
|
$ownCalendars[] = $calendar['id'];
|
||||||
} else {
|
} else {
|
||||||
|
@ -1415,14 +1409,14 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$query = $this->db->getQueryBuilder();
|
$query = $this->db->getQueryBuilder();
|
||||||
// Calendar id expressions
|
// Calendar id expressions
|
||||||
$calendarExpressions = [];
|
$calendarExpressions = [];
|
||||||
foreach($ownCalendars as $id) {
|
foreach ($ownCalendars as $id) {
|
||||||
$calendarExpressions[] = $query->expr()->andX(
|
$calendarExpressions[] = $query->expr()->andX(
|
||||||
$query->expr()->eq('c.calendarid',
|
$query->expr()->eq('c.calendarid',
|
||||||
$query->createNamedParameter($id)),
|
$query->createNamedParameter($id)),
|
||||||
$query->expr()->eq('c.calendartype',
|
$query->expr()->eq('c.calendartype',
|
||||||
$query->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)));
|
$query->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)));
|
||||||
}
|
}
|
||||||
foreach($sharedCalendars as $id) {
|
foreach ($sharedCalendars as $id) {
|
||||||
$calendarExpressions[] = $query->expr()->andX(
|
$calendarExpressions[] = $query->expr()->andX(
|
||||||
$query->expr()->eq('c.calendarid',
|
$query->expr()->eq('c.calendarid',
|
||||||
$query->createNamedParameter($id)),
|
$query->createNamedParameter($id)),
|
||||||
|
@ -1440,7 +1434,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
|
|
||||||
// Component expressions
|
// Component expressions
|
||||||
$compExpressions = [];
|
$compExpressions = [];
|
||||||
foreach($filters['comps'] as $comp) {
|
foreach ($filters['comps'] as $comp) {
|
||||||
$compExpressions[] = $query->expr()
|
$compExpressions[] = $query->expr()
|
||||||
->eq('c.componenttype', $query->createNamedParameter($comp));
|
->eq('c.componenttype', $query->createNamedParameter($comp));
|
||||||
}
|
}
|
||||||
|
@ -1459,13 +1453,13 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
}
|
}
|
||||||
|
|
||||||
$propParamExpressions = [];
|
$propParamExpressions = [];
|
||||||
foreach($filters['props'] as $prop) {
|
foreach ($filters['props'] as $prop) {
|
||||||
$propParamExpressions[] = $query->expr()->andX(
|
$propParamExpressions[] = $query->expr()->andX(
|
||||||
$query->expr()->eq('i.name', $query->createNamedParameter($prop)),
|
$query->expr()->eq('i.name', $query->createNamedParameter($prop)),
|
||||||
$query->expr()->isNull('i.parameter')
|
$query->expr()->isNull('i.parameter')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
foreach($filters['params'] as $param) {
|
foreach ($filters['params'] as $param) {
|
||||||
$propParamExpressions[] = $query->expr()->andX(
|
$propParamExpressions[] = $query->expr()->andX(
|
||||||
$query->expr()->eq('i.name', $query->createNamedParameter($param['property'])),
|
$query->expr()->eq('i.name', $query->createNamedParameter($param['property'])),
|
||||||
$query->expr()->eq('i.parameter', $query->createNamedParameter($param['parameter']))
|
$query->expr()->eq('i.parameter', $query->createNamedParameter($param['parameter']))
|
||||||
|
@ -1497,7 +1491,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$stmt = $query->execute();
|
$stmt = $query->execute();
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
$path = $uriMapper[$row['calendarid']] . '/' . $row['uri'];
|
$path = $uriMapper[$row['calendarid']] . '/' . $row['uri'];
|
||||||
if (!in_array($path, $result)) {
|
if (!in_array($path, $result)) {
|
||||||
$result[] = $path;
|
$result[] = $path;
|
||||||
|
@ -1538,7 +1532,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
}
|
}
|
||||||
|
|
||||||
$or = $innerQuery->expr()->orX();
|
$or = $innerQuery->expr()->orX();
|
||||||
foreach($searchProperties as $searchProperty) {
|
foreach ($searchProperties as $searchProperty) {
|
||||||
$or->add($innerQuery->expr()->eq('op.name',
|
$or->add($innerQuery->expr()->eq('op.name',
|
||||||
$outerQuery->createNamedParameter($searchProperty)));
|
$outerQuery->createNamedParameter($searchProperty)));
|
||||||
}
|
}
|
||||||
|
@ -1557,7 +1551,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
if (isset($options['timerange']['start']) && $options['timerange']['start'] instanceof DateTime) {
|
if (isset($options['timerange']['start']) && $options['timerange']['start'] instanceof DateTime) {
|
||||||
$outerQuery->andWhere($outerQuery->expr()->gt('lastoccurence',
|
$outerQuery->andWhere($outerQuery->expr()->gt('lastoccurence',
|
||||||
$outerQuery->createNamedParameter($options['timerange']['start']->getTimeStamp())));
|
$outerQuery->createNamedParameter($options['timerange']['start']->getTimeStamp())));
|
||||||
|
|
||||||
}
|
}
|
||||||
if (isset($options['timerange']['end']) && $options['timerange']['end'] instanceof DateTime) {
|
if (isset($options['timerange']['end']) && $options['timerange']['end'] instanceof DateTime) {
|
||||||
$outerQuery->andWhere($outerQuery->expr()->lt('firstoccurence',
|
$outerQuery->andWhere($outerQuery->expr()->lt('firstoccurence',
|
||||||
|
@ -1567,7 +1560,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
|
|
||||||
if (isset($options['types'])) {
|
if (isset($options['types'])) {
|
||||||
$or = $outerQuery->expr()->orX();
|
$or = $outerQuery->expr()->orX();
|
||||||
foreach($options['types'] as $type) {
|
foreach ($options['types'] as $type) {
|
||||||
$or->add($outerQuery->expr()->eq('componenttype',
|
$or->add($outerQuery->expr()->eq('componenttype',
|
||||||
$outerQuery->createNamedParameter($type)));
|
$outerQuery->createNamedParameter($type)));
|
||||||
}
|
}
|
||||||
|
@ -1592,7 +1585,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$comps = $calendarData->getComponents();
|
$comps = $calendarData->getComponents();
|
||||||
$objects = [];
|
$objects = [];
|
||||||
$timezones = [];
|
$timezones = [];
|
||||||
foreach($comps as $comp) {
|
foreach ($comps as $comp) {
|
||||||
if ($comp instanceof VTimeZone) {
|
if ($comp instanceof VTimeZone) {
|
||||||
$timezones[] = $comp;
|
$timezones[] = $comp;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1629,7 +1622,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
});
|
});
|
||||||
$validationRules = $comp->getValidationRules();
|
$validationRules = $comp->getValidationRules();
|
||||||
|
|
||||||
foreach($subComponents as $subComponent) {
|
foreach ($subComponents as $subComponent) {
|
||||||
$name = $subComponent->name;
|
$name = $subComponent->name;
|
||||||
if (!isset($data[$name])) {
|
if (!isset($data[$name])) {
|
||||||
$data[$name] = [];
|
$data[$name] = [];
|
||||||
|
@ -1637,7 +1630,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$data[$name][] = $this->transformSearchData($subComponent);
|
$data[$name][] = $this->transformSearchData($subComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($properties as $property) {
|
foreach ($properties as $property) {
|
||||||
$name = $property->name;
|
$name = $property->name;
|
||||||
if (!isset($validationRules[$name])) {
|
if (!isset($validationRules[$name])) {
|
||||||
$validationRules[$name] = '*';
|
$validationRules[$name] = '*';
|
||||||
|
@ -1696,7 +1689,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
function getCalendarObjectByUID($principalUri, $uid) {
|
function getCalendarObjectByUID($principalUri, $uid) {
|
||||||
|
|
||||||
$query = $this->db->getQueryBuilder();
|
$query = $this->db->getQueryBuilder();
|
||||||
$query->selectAlias('c.uri', 'calendaruri')->selectAlias('co.uri', 'objecturi')
|
$query->selectAlias('c.uri', 'calendaruri')->selectAlias('co.uri', 'objecturi')
|
||||||
->from('calendarobjects', 'co')
|
->from('calendarobjects', 'co')
|
||||||
|
@ -1789,7 +1781,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($syncToken) {
|
if ($syncToken) {
|
||||||
|
|
||||||
$query = "SELECT `uri`, `operation` FROM `*PREFIX*calendarchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `calendarid` = ? AND `calendartype` = ? ORDER BY `synctoken`";
|
$query = "SELECT `uri`, `operation` FROM `*PREFIX*calendarchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `calendarid` = ? AND `calendartype` = ? ORDER BY `synctoken`";
|
||||||
if ($limit>0) {
|
if ($limit>0) {
|
||||||
$query.= " LIMIT " . (int)$limit;
|
$query.= " LIMIT " . (int)$limit;
|
||||||
|
@ -1803,15 +1794,12 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
|
|
||||||
// This loop ensures that any duplicates are overwritten, only the
|
// This loop ensures that any duplicates are overwritten, only the
|
||||||
// last change on a node is relevant.
|
// last change on a node is relevant.
|
||||||
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
|
|
||||||
$changes[$row['uri']] = $row['operation'];
|
$changes[$row['uri']] = $row['operation'];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($changes as $uri => $operation) {
|
foreach ($changes as $uri => $operation) {
|
||||||
|
switch ($operation) {
|
||||||
switch($operation) {
|
|
||||||
case 1:
|
case 1:
|
||||||
$result['added'][] = $uri;
|
$result['added'][] = $uri;
|
||||||
break;
|
break;
|
||||||
|
@ -1822,7 +1810,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$result['deleted'][] = $uri;
|
$result['deleted'][] = $uri;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No synctoken supplied, this is the initial sync.
|
// No synctoken supplied, this is the initial sync.
|
||||||
|
@ -1833,7 +1820,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$result['added'] = $stmt->fetchAll(\PDO::FETCH_COLUMN);
|
$result['added'] = $stmt->fetchAll(\PDO::FETCH_COLUMN);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1885,8 +1871,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$stmt =$query->execute();
|
$stmt =$query->execute();
|
||||||
|
|
||||||
$subscriptions = [];
|
$subscriptions = [];
|
||||||
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
|
|
||||||
$subscription = [
|
$subscription = [
|
||||||
'id' => $row['id'],
|
'id' => $row['id'],
|
||||||
'uri' => $row['uri'],
|
'uri' => $row['uri'],
|
||||||
|
@ -1898,14 +1883,13 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
|
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) {
|
foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) {
|
||||||
if (!is_null($row[$dbName])) {
|
if (!is_null($row[$dbName])) {
|
||||||
$subscription[$xmlName] = $row[$dbName];
|
$subscription[$xmlName] = $row[$dbName];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$subscriptions[] = $subscription;
|
$subscriptions[] = $subscription;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $subscriptions;
|
return $subscriptions;
|
||||||
|
@ -1923,7 +1907,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function createSubscription($principalUri, $uri, array $properties) {
|
function createSubscription($principalUri, $uri, array $properties) {
|
||||||
|
|
||||||
if (!isset($properties['{http://calendarserver.org/ns/}source'])) {
|
if (!isset($properties['{http://calendarserver.org/ns/}source'])) {
|
||||||
throw new Forbidden('The {http://calendarserver.org/ns/}source property is required when creating subscriptions');
|
throw new Forbidden('The {http://calendarserver.org/ns/}source property is required when creating subscriptions');
|
||||||
}
|
}
|
||||||
|
@ -1937,11 +1920,11 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
|
|
||||||
$propertiesBoolean = ['striptodos', 'stripalarms', 'stripattachments'];
|
$propertiesBoolean = ['striptodos', 'stripalarms', 'stripattachments'];
|
||||||
|
|
||||||
foreach($this->subscriptionPropertyMap as $xmlName=>$dbName) {
|
foreach ($this->subscriptionPropertyMap as $xmlName=>$dbName) {
|
||||||
if (array_key_exists($xmlName, $properties)) {
|
if (array_key_exists($xmlName, $properties)) {
|
||||||
$values[$dbName] = $properties[$xmlName];
|
$values[$dbName] = $properties[$xmlName];
|
||||||
if (in_array($dbName, $propertiesBoolean)) {
|
if (in_array($dbName, $propertiesBoolean)) {
|
||||||
$values[$dbName] = true;
|
$values[$dbName] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1994,10 +1977,9 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
* @suppress SqlInjectionChecker
|
* @suppress SqlInjectionChecker
|
||||||
*/
|
*/
|
||||||
$propPatch->handle($supportedProperties, function ($mutations) use ($subscriptionId) {
|
$propPatch->handle($supportedProperties, function ($mutations) use ($subscriptionId) {
|
||||||
|
|
||||||
$newValues = [];
|
$newValues = [];
|
||||||
|
|
||||||
foreach($mutations as $propertyName=>$propertyValue) {
|
foreach ($mutations as $propertyName=>$propertyValue) {
|
||||||
if ($propertyName === '{http://calendarserver.org/ns/}source') {
|
if ($propertyName === '{http://calendarserver.org/ns/}source') {
|
||||||
$newValues['source'] = $propertyValue->getHref();
|
$newValues['source'] = $propertyValue->getHref();
|
||||||
} else {
|
} else {
|
||||||
|
@ -2009,7 +1991,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$query = $this->db->getQueryBuilder();
|
$query = $this->db->getQueryBuilder();
|
||||||
$query->update('calendarsubscriptions')
|
$query->update('calendarsubscriptions')
|
||||||
->set('lastmodified', $query->createNamedParameter(time()));
|
->set('lastmodified', $query->createNamedParameter(time()));
|
||||||
foreach($newValues as $fieldName=>$value) {
|
foreach ($newValues as $fieldName=>$value) {
|
||||||
$query->set($fieldName, $query->createNamedParameter($value));
|
$query->set($fieldName, $query->createNamedParameter($value));
|
||||||
}
|
}
|
||||||
$query->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId)))
|
$query->where($query->expr()->eq('id', $query->createNamedParameter($subscriptionId)))
|
||||||
|
@ -2024,7 +2006,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
]));
|
]));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2090,7 +2071,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
|
|
||||||
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
if(!$row) {
|
if (!$row) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2122,7 +2103,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
|
foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
|
||||||
$result[] = [
|
$result[] = [
|
||||||
'calendardata' => $row['calendardata'],
|
'calendardata' => $row['calendardata'],
|
||||||
'uri' => $row['uri'],
|
'uri' => $row['uri'],
|
||||||
|
@ -2205,7 +2186,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$stmt->execute([
|
$stmt->execute([
|
||||||
$calendarId
|
$calendarId
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2224,7 +2204,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getDenormalizedData($calendarData) {
|
public function getDenormalizedData($calendarData) {
|
||||||
|
|
||||||
$vObject = Reader::read($calendarData);
|
$vObject = Reader::read($calendarData);
|
||||||
$componentType = null;
|
$componentType = null;
|
||||||
$component = null;
|
$component = null;
|
||||||
|
@ -2232,7 +2211,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$lastOccurrence = null;
|
$lastOccurrence = null;
|
||||||
$uid = null;
|
$uid = null;
|
||||||
$classification = self::CLASSIFICATION_PUBLIC;
|
$classification = self::CLASSIFICATION_PUBLIC;
|
||||||
foreach($vObject->getComponents() as $component) {
|
foreach ($vObject->getComponents() as $component) {
|
||||||
if ($component->name!=='VTIMEZONE') {
|
if ($component->name!=='VTIMEZONE') {
|
||||||
$componentType = $component->name;
|
$componentType = $component->name;
|
||||||
$uid = (string)$component->UID;
|
$uid = (string)$component->UID;
|
||||||
|
@ -2266,14 +2245,12 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$lastOccurrence = $maxDate->getTimestamp();
|
$lastOccurrence = $maxDate->getTimestamp();
|
||||||
} else {
|
} else {
|
||||||
$end = $it->getDtEnd();
|
$end = $it->getDtEnd();
|
||||||
while($it->valid() && $end < $maxDate) {
|
while ($it->valid() && $end < $maxDate) {
|
||||||
$end = $it->getDtEnd();
|
$end = $it->getDtEnd();
|
||||||
$it->next();
|
$it->next();
|
||||||
|
|
||||||
}
|
}
|
||||||
$lastOccurrence = $end->getTimestamp();
|
$lastOccurrence = $end->getTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2297,7 +2274,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
'uid' => $uid,
|
'uid' => $uid,
|
||||||
'classification' => $classification
|
'classification' => $classification
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2346,7 +2322,6 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public function setPublishStatus($value, $calendar) {
|
public function setPublishStatus($value, $calendar) {
|
||||||
|
|
||||||
$calendarId = $calendar->getResourceId();
|
$calendarId = $calendar->getResourceId();
|
||||||
$this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::publishCalendar', new GenericEvent(
|
$this->dispatcher->dispatch('\OCA\DAV\CalDAV\CalDavBackend::publishCalendar', new GenericEvent(
|
||||||
'\OCA\DAV\CalDAV\CalDavBackend::updateShares',
|
'\OCA\DAV\CalDAV\CalDavBackend::updateShares',
|
||||||
|
@ -2490,7 +2465,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$ids = $result->fetchAll();
|
$ids = $result->fetchAll();
|
||||||
foreach($ids as $id) {
|
foreach ($ids as $id) {
|
||||||
$this->deleteCalendar($id['id']);
|
$this->deleteCalendar($id['id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2507,7 +2482,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
$stmt = $query->execute();
|
$stmt = $query->execute();
|
||||||
|
|
||||||
$uris = [];
|
$uris = [];
|
||||||
foreach($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
|
foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $row) {
|
||||||
$uris[] = $row['uri'];
|
$uris[] = $row['uri'];
|
||||||
}
|
}
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
@ -2528,7 +2503,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)))
|
->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)))
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
foreach($uris as $uri) {
|
foreach ($uris as $uri) {
|
||||||
$this->addChange($subscriptionId, $uri, 3, self::CALENDAR_TYPE_SUBSCRIPTION);
|
$this->addChange($subscriptionId, $uri, 3, self::CALENDAR_TYPE_SUBSCRIPTION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2540,8 +2515,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
||||||
* @param string $uriOrigin
|
* @param string $uriOrigin
|
||||||
* @param string $uriDestination
|
* @param string $uriDestination
|
||||||
*/
|
*/
|
||||||
public function moveCalendar($uriName, $uriOrigin, $uriDestination)
|
public function moveCalendar($uriName, $uriOrigin, $uriDestination) {
|
||||||
{
|
|
||||||
$query = $this->db->getQueryBuilder();
|
$query = $this->db->getQueryBuilder();
|
||||||
$query->update('calendars')
|
$query->update('calendars')
|
||||||
->set('principaluri', $query->createNamedParameter($uriDestination))
|
->set('principaluri', $query->createNamedParameter($uriDestination))
|
||||||
|
|
|
@ -280,7 +280,6 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getChild($name) {
|
public function getChild($name) {
|
||||||
|
|
||||||
$obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name);
|
$obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name);
|
||||||
|
|
||||||
if (!$obj) {
|
if (!$obj) {
|
||||||
|
@ -294,11 +293,9 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
|
||||||
$obj['acl'] = $this->getChildACL();
|
$obj['acl'] = $this->getChildACL();
|
||||||
|
|
||||||
return new CalendarObject($this->caldavBackend, $this->l10n, $this->calendarInfo, $obj);
|
return new CalendarObject($this->caldavBackend, $this->l10n, $this->calendarInfo, $obj);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getChildren() {
|
public function getChildren() {
|
||||||
|
|
||||||
$objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']);
|
$objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']);
|
||||||
$children = [];
|
$children = [];
|
||||||
foreach ($objs as $obj) {
|
foreach ($objs as $obj) {
|
||||||
|
@ -309,11 +306,9 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
|
||||||
$children[] = new CalendarObject($this->caldavBackend, $this->l10n, $this->calendarInfo, $obj);
|
$children[] = new CalendarObject($this->caldavBackend, $this->l10n, $this->calendarInfo, $obj);
|
||||||
}
|
}
|
||||||
return $children;
|
return $children;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMultipleChildren(array $paths) {
|
public function getMultipleChildren(array $paths) {
|
||||||
|
|
||||||
$objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths);
|
$objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths);
|
||||||
$children = [];
|
$children = [];
|
||||||
foreach ($objs as $obj) {
|
foreach ($objs as $obj) {
|
||||||
|
@ -324,7 +319,6 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
|
||||||
$children[] = new CalendarObject($this->caldavBackend, $this->l10n, $this->calendarInfo, $obj);
|
$children[] = new CalendarObject($this->caldavBackend, $this->l10n, $this->calendarInfo, $obj);
|
||||||
}
|
}
|
||||||
return $children;
|
return $children;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function childExists($name) {
|
public function childExists($name) {
|
||||||
|
@ -340,7 +334,6 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calendarQuery(array $filters) {
|
public function calendarQuery(array $filters) {
|
||||||
|
|
||||||
$uris = $this->caldavBackend->calendarQuery($this->calendarInfo['id'], $filters);
|
$uris = $this->caldavBackend->calendarQuery($this->calendarInfo['id'], $filters);
|
||||||
if ($this->isShared()) {
|
if ($this->isShared()) {
|
||||||
return array_filter($uris, function ($uri) {
|
return array_filter($uris, function ($uri) {
|
||||||
|
|
|
@ -101,7 +101,7 @@ class CalendarImpl implements ICalendar {
|
||||||
$permissions = $this->calendar->getACL();
|
$permissions = $this->calendar->getACL();
|
||||||
$result = 0;
|
$result = 0;
|
||||||
foreach ($permissions as $permission) {
|
foreach ($permissions as $permission) {
|
||||||
switch($permission['privilege']) {
|
switch ($permission['privilege']) {
|
||||||
case '{DAV:}read':
|
case '{DAV:}read':
|
||||||
$result |= Constants::PERMISSION_READ;
|
$result |= Constants::PERMISSION_READ;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -66,7 +66,7 @@ class CalendarManager {
|
||||||
* @param array $calendars
|
* @param array $calendars
|
||||||
*/
|
*/
|
||||||
private function register(IManager $cm, array $calendars) {
|
private function register(IManager $cm, array $calendars) {
|
||||||
foreach($calendars as $calendarInfo) {
|
foreach ($calendars as $calendarInfo) {
|
||||||
$calendar = new Calendar($this->backend, $calendarInfo, $this->l10n, $this->config);
|
$calendar = new Calendar($this->backend, $calendarInfo, $this->l10n, $this->config);
|
||||||
$cm->registerCalendar(new CalendarImpl(
|
$cm->registerCalendar(new CalendarImpl(
|
||||||
$calendar,
|
$calendar,
|
||||||
|
|
|
@ -96,19 +96,19 @@ class CalendarObject extends \Sabre\CalDAV\CalendarObject {
|
||||||
private function createConfidentialObject(Component\VCalendar $vObject) {
|
private function createConfidentialObject(Component\VCalendar $vObject) {
|
||||||
/** @var Component $vElement */
|
/** @var Component $vElement */
|
||||||
$vElement = null;
|
$vElement = null;
|
||||||
if(isset($vObject->VEVENT)) {
|
if (isset($vObject->VEVENT)) {
|
||||||
$vElement = $vObject->VEVENT;
|
$vElement = $vObject->VEVENT;
|
||||||
}
|
}
|
||||||
if(isset($vObject->VJOURNAL)) {
|
if (isset($vObject->VJOURNAL)) {
|
||||||
$vElement = $vObject->VJOURNAL;
|
$vElement = $vObject->VJOURNAL;
|
||||||
}
|
}
|
||||||
if(isset($vObject->VTODO)) {
|
if (isset($vObject->VTODO)) {
|
||||||
$vElement = $vObject->VTODO;
|
$vElement = $vObject->VTODO;
|
||||||
}
|
}
|
||||||
if(!is_null($vElement)) {
|
if (!is_null($vElement)) {
|
||||||
foreach ($vElement->children() as &$property) {
|
foreach ($vElement->children() as &$property) {
|
||||||
/** @var Property $property */
|
/** @var Property $property */
|
||||||
switch($property->name) {
|
switch ($property->name) {
|
||||||
case 'CREATED':
|
case 'CREATED':
|
||||||
case 'DTSTART':
|
case 'DTSTART':
|
||||||
case 'RRULE':
|
case 'RRULE':
|
||||||
|
@ -136,7 +136,7 @@ class CalendarObject extends \Sabre\CalDAV\CalendarObject {
|
||||||
private function removeVAlarms(Component\VCalendar $vObject) {
|
private function removeVAlarms(Component\VCalendar $vObject) {
|
||||||
$subcomponents = $vObject->getComponents();
|
$subcomponents = $vObject->getComponents();
|
||||||
|
|
||||||
foreach($subcomponents as $subcomponent) {
|
foreach ($subcomponents as $subcomponent) {
|
||||||
unset($subcomponent->VALARM);
|
unset($subcomponent->VALARM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
namespace OCA\DAV\CalDAV;
|
namespace OCA\DAV\CalDAV;
|
||||||
|
|
||||||
class CalendarRoot extends \Sabre\CalDAV\CalendarRoot {
|
class CalendarRoot extends \Sabre\CalDAV\CalendarRoot {
|
||||||
|
|
||||||
function getChildForPrincipal(array $principal) {
|
function getChildForPrincipal(array $principal) {
|
||||||
return new CalendarHome($this->caldavBackend, $principal);
|
return new CalendarHome($this->caldavBackend, $principal);
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,5 +93,4 @@ class ICSExportPlugin extends \Sabre\CalDAV\ICSExportPlugin {
|
||||||
|
|
||||||
return $vcalendar;
|
return $vcalendar;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,6 @@ abstract class ExternalCalendar implements CalDAV\ICalendar, DAV\IProperties {
|
||||||
*/
|
*/
|
||||||
final public function createDirectory($name) {
|
final public function createDirectory($name) {
|
||||||
throw new DAV\Exception\MethodNotAllowed('Creating collections in calendar objects is not allowed');
|
throw new DAV\Exception\MethodNotAllowed('Creating collections in calendar objects is not allowed');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -67,5 +67,4 @@ interface ICalendarProvider {
|
||||||
* @return ExternalCalendar|null Calendar if it exists, null otherwise
|
* @return ExternalCalendar|null Calendar if it exists, null otherwise
|
||||||
*/
|
*/
|
||||||
public function getCalendarInCalendarHome(string $principalUri, string $calendarUri): ?ExternalCalendar;
|
public function getCalendarInCalendarHome(string $principalUri, string $calendarUri): ?ExternalCalendar;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
namespace OCA\DAV\CalDAV;
|
namespace OCA\DAV\CalDAV;
|
||||||
|
|
||||||
class Plugin extends \Sabre\CalDAV\Plugin {
|
class Plugin extends \Sabre\CalDAV\Plugin {
|
||||||
|
|
||||||
const SYSTEM_CALENDAR_ROOT = 'system-calendars';
|
const SYSTEM_CALENDAR_ROOT = 'system-calendars';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,5 +51,4 @@ class Plugin extends \Sabre\CalDAV\Plugin {
|
||||||
return self::SYSTEM_CALENDAR_ROOT . '/calendar-rooms/' . $principalId;
|
return self::SYSTEM_CALENDAR_ROOT . '/calendar-rooms/' . $principalId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,5 +39,4 @@ class Collection extends \Sabre\CalDAV\Principal\Collection {
|
||||||
function getChildForPrincipal(array $principalInfo) {
|
function getChildForPrincipal(array $principalInfo) {
|
||||||
return new User($this->principalBackend, $principalInfo);
|
return new User($this->principalBackend, $principalInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,5 +51,4 @@ class User extends \Sabre\CalDAV\Principal\User {
|
||||||
];
|
];
|
||||||
return $acl;
|
return $acl;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,6 @@ use OCP\IDBConnection;
|
||||||
* @package OCA\DAV\CalDAV\Proxy
|
* @package OCA\DAV\CalDAV\Proxy
|
||||||
*/
|
*/
|
||||||
class ProxyMapper extends QBMapper {
|
class ProxyMapper extends QBMapper {
|
||||||
|
|
||||||
const PERMISSION_READ = 1;
|
const PERMISSION_READ = 1;
|
||||||
const PERMISSION_WRITE = 2;
|
const PERMISSION_WRITE = 2;
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,6 @@ class PublicCalendarRoot extends Collection {
|
||||||
$this->caldavBackend = $caldavBackend;
|
$this->caldavBackend = $caldavBackend;
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -44,7 +44,7 @@ use Sabre\VObject\Property;
|
||||||
*
|
*
|
||||||
* @package OCA\DAV\CalDAV\Reminder\NotificationProvider
|
* @package OCA\DAV\CalDAV\Reminder\NotificationProvider
|
||||||
*/
|
*/
|
||||||
abstract class AbstractProvider implements INotificationProvider {
|
abstract class AbstractProvider implements INotificationProvider {
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
public const NOTIFICATION_TYPE = '';
|
public const NOTIFICATION_TYPE = '';
|
||||||
|
|
|
@ -99,7 +99,7 @@ class EmailProvider extends AbstractProvider {
|
||||||
$sortedByLanguage = $this->sortEMailAddressesByLanguage($emailAddresses, $fallbackLanguage);
|
$sortedByLanguage = $this->sortEMailAddressesByLanguage($emailAddresses, $fallbackLanguage);
|
||||||
$organizer = $this->getOrganizerEMailAndNameFromEvent($vevent);
|
$organizer = $this->getOrganizerEMailAndNameFromEvent($vevent);
|
||||||
|
|
||||||
foreach($sortedByLanguage as $lang => $emailAddresses) {
|
foreach ($sortedByLanguage as $lang => $emailAddresses) {
|
||||||
if (!$this->hasL10NForLang($lang)) {
|
if (!$this->hasL10NForLang($lang)) {
|
||||||
$lang = $fallbackLanguage;
|
$lang = $fallbackLanguage;
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ class EmailProvider extends AbstractProvider {
|
||||||
string $defaultLanguage):array {
|
string $defaultLanguage):array {
|
||||||
$sortedByLanguage = [];
|
$sortedByLanguage = [];
|
||||||
|
|
||||||
foreach($emails as $emailAddress => $parameters) {
|
foreach ($emails as $emailAddress => $parameters) {
|
||||||
if (isset($parameters['LANG'])) {
|
if (isset($parameters['LANG'])) {
|
||||||
$lang = $parameters['LANG'];
|
$lang = $parameters['LANG'];
|
||||||
} else {
|
} else {
|
||||||
|
@ -260,7 +260,7 @@ class EmailProvider extends AbstractProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
$emailAddressesOfDelegates = $delegates->getParts();
|
$emailAddressesOfDelegates = $delegates->getParts();
|
||||||
foreach($emailAddressesOfDelegates as $addressesOfDelegate) {
|
foreach ($emailAddressesOfDelegates as $addressesOfDelegate) {
|
||||||
if (strcasecmp($addressesOfDelegate, 'mailto:') === 0) {
|
if (strcasecmp($addressesOfDelegate, 'mailto:') === 0) {
|
||||||
$emailAddresses[substr($addressesOfDelegate, 7)] = [];
|
$emailAddresses[substr($addressesOfDelegate, 7)] = [];
|
||||||
}
|
}
|
||||||
|
@ -345,7 +345,7 @@ class EmailProvider extends AbstractProvider {
|
||||||
private function getEMailAddressesOfAllUsersWithWriteAccessToCalendar(array $users):array {
|
private function getEMailAddressesOfAllUsersWithWriteAccessToCalendar(array $users):array {
|
||||||
$emailAddresses = [];
|
$emailAddresses = [];
|
||||||
|
|
||||||
foreach($users as $user) {
|
foreach ($users as $user) {
|
||||||
$emailAddress = $user->getEMailAddress();
|
$emailAddress = $user->getEMailAddress();
|
||||||
if ($emailAddress) {
|
if ($emailAddress) {
|
||||||
$lang = $this->getLangForUser($user);
|
$lang = $this->getLangForUser($user);
|
||||||
|
|
|
@ -39,5 +39,4 @@ class ProviderNotAvailableException extends \Exception {
|
||||||
public function __construct(string $type) {
|
public function __construct(string $type) {
|
||||||
parent::__construct("No notification provider for type $type available");
|
parent::__construct("No notification provider for type $type available");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ class PushProvider extends AbstractProvider {
|
||||||
// Empty Notification ObjectId will be catched by OC\Notification\Notification
|
// Empty Notification ObjectId will be catched by OC\Notification\Notification
|
||||||
$eventUUIDHash = $eventUUID ? hash('sha256', $eventUUID, false) : '';
|
$eventUUIDHash = $eventUUID ? hash('sha256', $eventUUID, false) : '';
|
||||||
|
|
||||||
foreach($users as $user) {
|
foreach ($users as $user) {
|
||||||
/** @var INotification $notification */
|
/** @var INotification $notification */
|
||||||
$notification = $this->manager->createNotification();
|
$notification = $this->manager->createNotification();
|
||||||
$notification->setApp(Application::APP_ID)
|
$notification->setApp(Application::APP_ID)
|
||||||
|
|
|
@ -38,5 +38,4 @@ class NotificationTypeDoesNotExistException extends \Exception {
|
||||||
public function __construct(string $type) {
|
public function __construct(string $type) {
|
||||||
parent::__construct("Type $type is not an accepted type of notification");
|
parent::__construct("Type $type is not an accepted type of notification");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ class Notifier implements INotifier {
|
||||||
$this->l10n = $this->l10nFactory->get('dav', $languageCode);
|
$this->l10n = $this->l10nFactory->get('dav', $languageCode);
|
||||||
|
|
||||||
// Handle notifier subjects
|
// Handle notifier subjects
|
||||||
switch($notification->getSubject()) {
|
switch ($notification->getSubject()) {
|
||||||
case 'calendar_reminder':
|
case 'calendar_reminder':
|
||||||
return $this->prepareReminderNotification($notification);
|
return $this->prepareReminderNotification($notification);
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ class ReminderService {
|
||||||
public function processReminders():void {
|
public function processReminders():void {
|
||||||
$reminders = $this->backend->getRemindersToProcess();
|
$reminders = $this->backend->getRemindersToProcess();
|
||||||
|
|
||||||
foreach($reminders as $reminder) {
|
foreach ($reminders as $reminder) {
|
||||||
$calendarData = is_resource($reminder['calendardata'])
|
$calendarData = is_resource($reminder['calendardata'])
|
||||||
? stream_get_contents($reminder['calendardata'])
|
? stream_get_contents($reminder['calendardata'])
|
||||||
: $reminder['calendardata'];
|
: $reminder['calendardata'];
|
||||||
|
@ -163,7 +163,7 @@ class ReminderService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($action) {
|
switch ($action) {
|
||||||
case '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject':
|
case '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject':
|
||||||
$this->onCalendarObjectCreate($objectData);
|
$this->onCalendarObjectCreate($objectData);
|
||||||
break;
|
break;
|
||||||
|
@ -206,14 +206,14 @@ class ReminderService {
|
||||||
$now = $this->timeFactory->getDateTime();
|
$now = $this->timeFactory->getDateTime();
|
||||||
$isRecurring = $masterItem ? $this->isRecurring($masterItem) : false;
|
$isRecurring = $masterItem ? $this->isRecurring($masterItem) : false;
|
||||||
|
|
||||||
foreach($recurrenceExceptions as $recurrenceException) {
|
foreach ($recurrenceExceptions as $recurrenceException) {
|
||||||
$eventHash = $this->getEventHash($recurrenceException);
|
$eventHash = $this->getEventHash($recurrenceException);
|
||||||
|
|
||||||
if (!isset($recurrenceException->VALARM)) {
|
if (!isset($recurrenceException->VALARM)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($recurrenceException->VALARM as $valarm) {
|
foreach ($recurrenceException->VALARM as $valarm) {
|
||||||
/** @var VAlarm $valarm */
|
/** @var VAlarm $valarm */
|
||||||
$alarmHash = $this->getAlarmHash($valarm);
|
$alarmHash = $this->getAlarmHash($valarm);
|
||||||
$triggerTime = $valarm->getEffectiveTriggerTime();
|
$triggerTime = $valarm->getEffectiveTriggerTime();
|
||||||
|
@ -237,7 +237,7 @@ class ReminderService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($masterItem->VALARM as $valarm) {
|
foreach ($masterItem->VALARM as $valarm) {
|
||||||
$masterAlarms[] = $this->getAlarmHash($valarm);
|
$masterAlarms[] = $this->getAlarmHash($valarm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ class ReminderService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while($iterator->valid() && count($processedAlarms) < count($masterAlarms)) {
|
while ($iterator->valid() && count($processedAlarms) < count($masterAlarms)) {
|
||||||
$event = $iterator->getEventObject();
|
$event = $iterator->getEventObject();
|
||||||
|
|
||||||
// Recurrence-exceptions are handled separately, so just ignore them here
|
// Recurrence-exceptions are handled separately, so just ignore them here
|
||||||
|
@ -259,7 +259,7 @@ class ReminderService {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($event->VALARM as $valarm) {
|
foreach ($event->VALARM as $valarm) {
|
||||||
/** @var VAlarm $valarm */
|
/** @var VAlarm $valarm */
|
||||||
$alarmHash = $this->getAlarmHash($valarm);
|
$alarmHash = $this->getAlarmHash($valarm);
|
||||||
if (\in_array($alarmHash, $processedAlarms, true)) {
|
if (\in_array($alarmHash, $processedAlarms, true)) {
|
||||||
|
@ -365,7 +365,7 @@ class ReminderService {
|
||||||
];
|
];
|
||||||
|
|
||||||
$repeat = isset($valarm->REPEAT) ? (int) $valarm->REPEAT->getValue() : 0;
|
$repeat = isset($valarm->REPEAT) ? (int) $valarm->REPEAT->getValue() : 0;
|
||||||
for($i = 0; $i < $repeat; $i++) {
|
for ($i = 0; $i < $repeat; $i++) {
|
||||||
if ($valarm->DURATION === null) {
|
if ($valarm->DURATION === null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -394,7 +394,7 @@ class ReminderService {
|
||||||
* @param array $reminders
|
* @param array $reminders
|
||||||
*/
|
*/
|
||||||
private function writeRemindersToDatabase(array $reminders): void {
|
private function writeRemindersToDatabase(array $reminders): void {
|
||||||
foreach($reminders as $reminder) {
|
foreach ($reminders as $reminder) {
|
||||||
$this->backend->insertReminder(
|
$this->backend->insertReminder(
|
||||||
(int) $reminder['calendar_id'],
|
(int) $reminder['calendar_id'],
|
||||||
(int) $reminder['object_id'],
|
(int) $reminder['object_id'],
|
||||||
|
@ -422,7 +422,6 @@ class ReminderService {
|
||||||
!$reminder['is_recurring'] ||
|
!$reminder['is_recurring'] ||
|
||||||
!$reminder['is_relative'] ||
|
!$reminder['is_relative'] ||
|
||||||
$reminder['is_recurrence_exception']) {
|
$reminder['is_recurrence_exception']) {
|
||||||
|
|
||||||
$this->backend->removeReminder($reminder['id']);
|
$this->backend->removeReminder($reminder['id']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -440,7 +439,7 @@ class ReminderService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while($iterator->valid()) {
|
while ($iterator->valid()) {
|
||||||
$event = $iterator->getEventObject();
|
$event = $iterator->getEventObject();
|
||||||
|
|
||||||
// Recurrence-exceptions are handled separately, so just ignore them here
|
// Recurrence-exceptions are handled separately, so just ignore them here
|
||||||
|
@ -455,7 +454,7 @@ class ReminderService {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($event->VALARM as $valarm) {
|
foreach ($event->VALARM as $valarm) {
|
||||||
/** @var VAlarm $valarm */
|
/** @var VAlarm $valarm */
|
||||||
$alarmHash = $this->getAlarmHash($valarm);
|
$alarmHash = $this->getAlarmHash($valarm);
|
||||||
if ($alarmHash !== $reminder['alarm_hash']) {
|
if ($alarmHash !== $reminder['alarm_hash']) {
|
||||||
|
@ -608,7 +607,7 @@ class ReminderService {
|
||||||
|
|
||||||
// Handle recurrence-exceptions first, because recurrence-expansion is expensive
|
// Handle recurrence-exceptions first, because recurrence-expansion is expensive
|
||||||
if ($isRecurrenceException) {
|
if ($isRecurrenceException) {
|
||||||
foreach($recurrenceExceptions as $recurrenceException) {
|
foreach ($recurrenceExceptions as $recurrenceException) {
|
||||||
if ($this->getEffectiveRecurrenceIdOfVEvent($recurrenceException) === $recurrenceId) {
|
if ($this->getEffectiveRecurrenceIdOfVEvent($recurrenceException) === $recurrenceId) {
|
||||||
return $recurrenceException;
|
return $recurrenceException;
|
||||||
}
|
}
|
||||||
|
@ -678,7 +677,7 @@ class ReminderService {
|
||||||
try {
|
try {
|
||||||
return VObject\Reader::read($calendarData,
|
return VObject\Reader::read($calendarData,
|
||||||
VObject\Reader::OPTION_FORGIVING);
|
VObject\Reader::OPTION_FORGIVING);
|
||||||
} catch(ParseException $ex) {
|
} catch (ParseException $ex) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -707,7 +706,7 @@ class ReminderService {
|
||||||
private function getAllVEventsFromVCalendar(VObject\Component\VCalendar $vcalendar):array {
|
private function getAllVEventsFromVCalendar(VObject\Component\VCalendar $vcalendar):array {
|
||||||
$vevents = [];
|
$vevents = [];
|
||||||
|
|
||||||
foreach($vcalendar->children() as $child) {
|
foreach ($vcalendar->children() as $child) {
|
||||||
if (!($child instanceof VObject\Component)) {
|
if (!($child instanceof VObject\Component)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
||||||
$metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC);
|
$metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
$metaDataById = [];
|
$metaDataById = [];
|
||||||
foreach($metaDataRows as $metaDataRow) {
|
foreach ($metaDataRows as $metaDataRow) {
|
||||||
if (!isset($metaDataById[$metaDataRow[$this->dbForeignKeyName]])) {
|
if (!isset($metaDataById[$metaDataRow[$this->dbForeignKeyName]])) {
|
||||||
$metaDataById[$metaDataRow[$this->dbForeignKeyName]] = [];
|
$metaDataById[$metaDataRow[$this->dbForeignKeyName]] = [];
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
||||||
$metaDataRow['value'];
|
$metaDataRow['value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
$id = $row['id'];
|
$id = $row['id'];
|
||||||
|
|
||||||
if (isset($metaDataById[$id])) {
|
if (isset($metaDataById[$id])) {
|
||||||
|
@ -142,7 +142,6 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
||||||
} else {
|
} else {
|
||||||
$principals[] = $this->rowToPrincipal($row);
|
$principals[] = $this->rowToPrincipal($row);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
@ -175,7 +174,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
||||||
$stmt = $query->execute();
|
$stmt = $query->execute();
|
||||||
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
if(!$row) {
|
if (!$row) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +186,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
||||||
$metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC);
|
$metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
$metadata = [];
|
$metadata = [];
|
||||||
|
|
||||||
foreach($metaDataRows as $metaDataRow) {
|
foreach ($metaDataRows as $metaDataRow) {
|
||||||
$metadata[$metaDataRow['key']] = $metaDataRow['value'];
|
$metadata[$metaDataRow['key']] = $metaDataRow['value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +205,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
||||||
$stmt = $query->execute();
|
$stmt = $query->execute();
|
||||||
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
if(!$row) {
|
if (!$row) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +217,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
||||||
$metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC);
|
$metaDataRows = $metaDataStmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||||
$metadata = [];
|
$metadata = [];
|
||||||
|
|
||||||
foreach($metaDataRows as $metaDataRow) {
|
foreach ($metaDataRows as $metaDataRow) {
|
||||||
$metadata[$metaDataRow['key']] = $metaDataRow['value'];
|
$metadata[$metaDataRow['key']] = $metaDataRow['value'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +264,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
||||||
|
|
||||||
$stmt = $query->execute();
|
$stmt = $query->execute();
|
||||||
$principals = [];
|
$principals = [];
|
||||||
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
if (!$this->isAllowedToAccessResource($row, $usersGroups)) {
|
if (!$this->isAllowedToAccessResource($row, $usersGroups)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -284,7 +283,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
||||||
|
|
||||||
$stmt = $query->execute();
|
$stmt = $query->execute();
|
||||||
$principals = [];
|
$principals = [];
|
||||||
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
if (!$this->isAllowedToAccessResource($row, $usersGroups)) {
|
if (!$this->isAllowedToAccessResource($row, $usersGroups)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -352,7 +351,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
||||||
$stmt = $query->execute();
|
$stmt = $query->execute();
|
||||||
|
|
||||||
$rows = [];
|
$rows = [];
|
||||||
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
$id = $row[$this->dbForeignKeyName];
|
$id = $row[$this->dbForeignKeyName];
|
||||||
|
|
||||||
$principalRow = $this->getPrincipalById($id);
|
$principalRow = $this->getPrincipalById($id);
|
||||||
|
@ -388,7 +387,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
||||||
$stmt = $query->execute();
|
$stmt = $query->execute();
|
||||||
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
if(!$row) {
|
if (!$row) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!$this->isAllowedToAccessResource($row, $usersGroups)) {
|
if (!$this->isAllowedToAccessResource($row, $usersGroups)) {
|
||||||
|
@ -415,7 +414,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface {
|
||||||
$stmt = $query->execute();
|
$stmt = $query->execute();
|
||||||
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
|
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
if(!$row) {
|
if (!$row) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!$this->isAllowedToAccessResource($row, $usersGroups)) {
|
if (!$this->isAllowedToAccessResource($row, $usersGroups)) {
|
||||||
|
|
|
@ -316,7 +316,7 @@ class IMipPlugin extends SabreIMipPlugin {
|
||||||
$this->logger->error('Unable to deliver message to {failed}', ['app' => 'dav', 'failed' => implode(', ', $failed)]);
|
$this->logger->error('Unable to deliver message to {failed}', ['app' => 'dav', 'failed' => implode(', ', $failed)]);
|
||||||
$iTipMessage->scheduleStatus = '5.0; EMail delivery failed';
|
$iTipMessage->scheduleStatus = '5.0; EMail delivery failed';
|
||||||
}
|
}
|
||||||
} catch(\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
$this->logger->logException($ex, ['app' => 'dav']);
|
$this->logger->logException($ex, ['app' => 'dav']);
|
||||||
$iTipMessage->scheduleStatus = '5.0; EMail delivery failed';
|
$iTipMessage->scheduleStatus = '5.0; EMail delivery failed';
|
||||||
}
|
}
|
||||||
|
@ -358,10 +358,9 @@ class IMipPlugin extends SabreIMipPlugin {
|
||||||
$lastOccurrence = $maxDate->getTimestamp();
|
$lastOccurrence = $maxDate->getTimestamp();
|
||||||
} else {
|
} else {
|
||||||
$end = $it->getDtEnd();
|
$end = $it->getDtEnd();
|
||||||
while($it->valid() && $end < $maxDate) {
|
while ($it->valid() && $end < $maxDate) {
|
||||||
$end = $it->getDtEnd();
|
$end = $it->getDtEnd();
|
||||||
$it->next();
|
$it->next();
|
||||||
|
|
||||||
}
|
}
|
||||||
$lastOccurrence = $end->getTimestamp();
|
$lastOccurrence = $end->getTimestamp();
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,6 @@ class SearchPlugin extends ServerPlugin {
|
||||||
// If we're dealing with the calendar home, the calendar home itself is
|
// If we're dealing with the calendar home, the calendar home itself is
|
||||||
// responsible for the calendar-query
|
// responsible for the calendar-query
|
||||||
if ($node instanceof CalendarHome && $depth === 2) {
|
if ($node instanceof CalendarHome && $depth === 2) {
|
||||||
|
|
||||||
$nodePaths = $node->calendarSearch($report->filters, $report->limit, $report->offset);
|
$nodePaths = $node->calendarSearch($report->filters, $report->limit, $report->offset);
|
||||||
|
|
||||||
foreach ($nodePaths as $path) {
|
foreach ($nodePaths as $path) {
|
||||||
|
|
|
@ -45,7 +45,6 @@ class ParamFilter implements XmlDeserializable {
|
||||||
|
|
||||||
if (!is_string($property)) {
|
if (!is_string($property)) {
|
||||||
throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid property attribute');
|
throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid property attribute');
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!is_string($parameter)) {
|
if (!is_string($parameter)) {
|
||||||
throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid parameter attribute');
|
throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid parameter attribute');
|
||||||
|
|
|
@ -111,7 +111,7 @@ class Plugin extends ServerPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
$calendarHome->enableCachedSubscriptionsForThisRequest();
|
$calendarHome->enableCachedSubscriptionsForThisRequest();
|
||||||
} catch(NotFound $ex) {
|
} catch (NotFound $ex) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,7 @@ class RefreshWebcalService {
|
||||||
$calendarData = $vObject->serialize();
|
$calendarData = $vObject->serialize();
|
||||||
try {
|
try {
|
||||||
$this->calDavBackend->createCalendarObject($subscription['id'], $uri, $calendarData, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
|
$this->calDavBackend->createCalendarObject($subscription['id'], $uri, $calendarData, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
|
||||||
} catch(BadRequest $ex) {
|
} catch (BadRequest $ex) {
|
||||||
$this->logger->logException($ex);
|
$this->logger->logException($ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ class RefreshWebcalService {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->updateSubscription($subscription, $mutations);
|
$this->updateSubscription($subscription, $mutations);
|
||||||
} catch(ParseException $ex) {
|
} catch (ParseException $ex) {
|
||||||
$subscriptionId = $subscription['id'];
|
$subscriptionId = $subscription['id'];
|
||||||
|
|
||||||
$this->logger->logException($ex);
|
$this->logger->logException($ex);
|
||||||
|
@ -274,11 +274,11 @@ class RefreshWebcalService {
|
||||||
|
|
||||||
$contentType = $response->getHeader('Content-Type');
|
$contentType = $response->getHeader('Content-Type');
|
||||||
$contentType = explode(';', $contentType, 2)[0];
|
$contentType = explode(';', $contentType, 2)[0];
|
||||||
switch($contentType) {
|
switch ($contentType) {
|
||||||
case 'application/calendar+json':
|
case 'application/calendar+json':
|
||||||
try {
|
try {
|
||||||
$jCalendar = Reader::readJson($body, Reader::OPTION_FORGIVING);
|
$jCalendar = Reader::readJson($body, Reader::OPTION_FORGIVING);
|
||||||
} catch(Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
// In case of a parsing error return null
|
// In case of a parsing error return null
|
||||||
$this->logger->debug("Subscription $subscriptionId could not be parsed");
|
$this->logger->debug("Subscription $subscriptionId could not be parsed");
|
||||||
return null;
|
return null;
|
||||||
|
@ -288,7 +288,7 @@ class RefreshWebcalService {
|
||||||
case 'application/calendar+xml':
|
case 'application/calendar+xml':
|
||||||
try {
|
try {
|
||||||
$xCalendar = Reader::readXML($body);
|
$xCalendar = Reader::readXML($body);
|
||||||
} catch(Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
// In case of a parsing error return null
|
// In case of a parsing error return null
|
||||||
$this->logger->debug("Subscription $subscriptionId could not be parsed");
|
$this->logger->debug("Subscription $subscriptionId could not be parsed");
|
||||||
return null;
|
return null;
|
||||||
|
@ -299,14 +299,14 @@ class RefreshWebcalService {
|
||||||
default:
|
default:
|
||||||
try {
|
try {
|
||||||
$vCalendar = Reader::read($body);
|
$vCalendar = Reader::read($body);
|
||||||
} catch(Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
// In case of a parsing error return null
|
// In case of a parsing error return null
|
||||||
$this->logger->debug("Subscription $subscriptionId could not be parsed");
|
$this->logger->debug("Subscription $subscriptionId could not be parsed");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return $vCalendar->serialize();
|
return $vCalendar->serialize();
|
||||||
}
|
}
|
||||||
} catch(Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
$this->logger->logException($ex);
|
$this->logger->logException($ex);
|
||||||
$this->logger->warning("Subscription $subscriptionId could not be refreshed due to a network error");
|
$this->logger->warning("Subscription $subscriptionId could not be refreshed due to a network error");
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ class RefreshWebcalService {
|
||||||
// check if new refresh rate is even valid
|
// check if new refresh rate is even valid
|
||||||
try {
|
try {
|
||||||
DateTimeParser::parseDuration($newRefreshRate);
|
DateTimeParser::parseDuration($newRefreshRate);
|
||||||
} catch(InvalidDataException $ex) {
|
} catch (InvalidDataException $ex) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ namespace OCA\DAV;
|
||||||
use OCP\Capabilities\ICapability;
|
use OCP\Capabilities\ICapability;
|
||||||
|
|
||||||
class Capabilities implements ICapability {
|
class Capabilities implements ICapability {
|
||||||
|
|
||||||
public function getCapabilities() {
|
public function getCapabilities() {
|
||||||
return [
|
return [
|
||||||
'dav' => [
|
'dav' => [
|
||||||
|
|
|
@ -155,14 +155,12 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getChild($name) {
|
public function getChild($name) {
|
||||||
|
|
||||||
$obj = $this->carddavBackend->getCard($this->addressBookInfo['id'], $name);
|
$obj = $this->carddavBackend->getCard($this->addressBookInfo['id'], $name);
|
||||||
if (!$obj) {
|
if (!$obj) {
|
||||||
throw new NotFound('Card not found');
|
throw new NotFound('Card not found');
|
||||||
}
|
}
|
||||||
$obj['acl'] = $this->getChildACL();
|
$obj['acl'] = $this->getChildACL();
|
||||||
return new Card($this->carddavBackend, $this->addressBookInfo, $obj);
|
return new Card($this->carddavBackend, $this->addressBookInfo, $obj);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -65,7 +65,6 @@ class AddressBookImpl implements IAddressBook {
|
||||||
array $addressBookInfo,
|
array $addressBookInfo,
|
||||||
CardDavBackend $backend,
|
CardDavBackend $backend,
|
||||||
IURLGenerator $urlGenerator) {
|
IURLGenerator $urlGenerator) {
|
||||||
|
|
||||||
$this->addressBook = $addressBook;
|
$this->addressBook = $addressBook;
|
||||||
$this->addressBookInfo = $addressBookInfo;
|
$this->addressBookInfo = $addressBookInfo;
|
||||||
$this->backend = $backend;
|
$this->backend = $backend;
|
||||||
|
@ -156,7 +155,6 @@ class AddressBookImpl implements IAddressBook {
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->vCard2Array($uri, $vCard);
|
return $this->vCard2Array($uri, $vCard);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -167,7 +165,7 @@ class AddressBookImpl implements IAddressBook {
|
||||||
$permissions = $this->addressBook->getACL();
|
$permissions = $this->addressBook->getACL();
|
||||||
$result = 0;
|
$result = 0;
|
||||||
foreach ($permissions as $permission) {
|
foreach ($permissions as $permission) {
|
||||||
switch($permission['privilege']) {
|
switch ($permission['privilege']) {
|
||||||
case '{DAV:}read':
|
case '{DAV:}read':
|
||||||
$result |= Constants::PERMISSION_READ;
|
$result |= Constants::PERMISSION_READ;
|
||||||
break;
|
break;
|
||||||
|
@ -261,7 +259,6 @@ class AddressBookImpl implements IAddressBook {
|
||||||
]) . '?photo';
|
]) . '?photo';
|
||||||
|
|
||||||
$result['PHOTO'] = 'VALUE=uri:' . $url;
|
$result['PHOTO'] = 'VALUE=uri:' . $url;
|
||||||
|
|
||||||
} elseif ($property->name === 'X-SOCIALPROFILE') {
|
} elseif ($property->name === 'X-SOCIALPROFILE') {
|
||||||
$type = $this->getTypeFromProperty($property);
|
$type = $this->getTypeFromProperty($property);
|
||||||
|
|
||||||
|
@ -273,7 +270,7 @@ class AddressBookImpl implements IAddressBook {
|
||||||
$result[$property->name][$type] = $property->getValue();
|
$result[$property->name][$type] = $property->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
// The following properties can be set multiple times
|
// The following properties can be set multiple times
|
||||||
} elseif (in_array($property->name, ['CLOUD', 'EMAIL', 'IMPP', 'TEL', 'URL', 'X-ADDRESSBOOKSERVER-MEMBER'])) {
|
} elseif (in_array($property->name, ['CLOUD', 'EMAIL', 'IMPP', 'TEL', 'URL', 'X-ADDRESSBOOKSERVER-MEMBER'])) {
|
||||||
if (!isset($result[$property->name])) {
|
if (!isset($result[$property->name])) {
|
||||||
$result[$property->name] = [];
|
$result[$property->name] = [];
|
||||||
|
@ -288,8 +285,6 @@ class AddressBookImpl implements IAddressBook {
|
||||||
} else {
|
} else {
|
||||||
$result[$property->name][] = $property->getValue();
|
$result[$property->name][] = $property->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$result[$property->name] = $property->getValue();
|
$result[$property->name] = $property->getValue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,6 @@ class AddressBookRoot extends \Sabre\CardDAV\AddressBookRoot {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getName() {
|
function getName() {
|
||||||
|
|
||||||
if ($this->principalPrefix === 'principals') {
|
if ($this->principalPrefix === 'principals') {
|
||||||
return parent::getName();
|
return parent::getName();
|
||||||
}
|
}
|
||||||
|
@ -70,7 +69,5 @@ class AddressBookRoot extends \Sabre\CardDAV\AddressBookRoot {
|
||||||
|
|
||||||
// We are only interested in the second part.
|
// We are only interested in the second part.
|
||||||
return $parts[1];
|
return $parts[1];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||||
|
|
||||||
class CardDavBackend implements BackendInterface, SyncSupport {
|
class CardDavBackend implements BackendInterface, SyncSupport {
|
||||||
|
|
||||||
const PERSONAL_ADDRESSBOOK_URI = 'contacts';
|
const PERSONAL_ADDRESSBOOK_URI = 'contacts';
|
||||||
const PERSONAL_ADDRESSBOOK_NAME = 'Contacts';
|
const PERSONAL_ADDRESSBOOK_NAME = 'Contacts';
|
||||||
|
|
||||||
|
@ -155,7 +154,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
||||||
$addressBooks = [];
|
$addressBooks = [];
|
||||||
|
|
||||||
$result = $query->execute();
|
$result = $query->execute();
|
||||||
while($row = $result->fetch()) {
|
while ($row = $result->fetch()) {
|
||||||
$addressBooks[$row['id']] = [
|
$addressBooks[$row['id']] = [
|
||||||
'id' => $row['id'],
|
'id' => $row['id'],
|
||||||
'uri' => $row['uri'],
|
'uri' => $row['uri'],
|
||||||
|
@ -190,7 +189,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
|
$readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
|
||||||
while($row = $result->fetch()) {
|
while ($row = $result->fetch()) {
|
||||||
if ($row['principaluri'] === $principalUri) {
|
if ($row['principaluri'] === $principalUri) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -241,7 +240,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
||||||
$addressBooks = [];
|
$addressBooks = [];
|
||||||
|
|
||||||
$result = $query->execute();
|
$result = $query->execute();
|
||||||
while($row = $result->fetch()) {
|
while ($row = $result->fetch()) {
|
||||||
$addressBooks[$row['id']] = [
|
$addressBooks[$row['id']] = [
|
||||||
'id' => $row['id'],
|
'id' => $row['id'],
|
||||||
'uri' => $row['uri'],
|
'uri' => $row['uri'],
|
||||||
|
@ -364,11 +363,9 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
||||||
* @suppress SqlInjectionChecker
|
* @suppress SqlInjectionChecker
|
||||||
*/
|
*/
|
||||||
$propPatch->handle($supportedProperties, function ($mutations) use ($addressBookId) {
|
$propPatch->handle($supportedProperties, function ($mutations) use ($addressBookId) {
|
||||||
|
|
||||||
$updates = [];
|
$updates = [];
|
||||||
foreach($mutations as $property=>$newValue) {
|
foreach ($mutations as $property=>$newValue) {
|
||||||
|
switch ($property) {
|
||||||
switch($property) {
|
|
||||||
case '{DAV:}displayname':
|
case '{DAV:}displayname':
|
||||||
$updates['displayname'] = $newValue;
|
$updates['displayname'] = $newValue;
|
||||||
break;
|
break;
|
||||||
|
@ -380,7 +377,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
||||||
$query = $this->db->getQueryBuilder();
|
$query = $this->db->getQueryBuilder();
|
||||||
$query->update('addressbooks');
|
$query->update('addressbooks');
|
||||||
|
|
||||||
foreach($updates as $key=>$value) {
|
foreach ($updates as $key=>$value) {
|
||||||
$query->set($key, $query->createNamedParameter($value));
|
$query->set($key, $query->createNamedParameter($value));
|
||||||
}
|
}
|
||||||
$query->where($query->expr()->eq('id', $query->createNamedParameter($addressBookId)))
|
$query->where($query->expr()->eq('id', $query->createNamedParameter($addressBookId)))
|
||||||
|
@ -389,7 +386,6 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
||||||
$this->addChange($addressBookId, "", 2);
|
$this->addChange($addressBookId, "", 2);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,9 +407,8 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
||||||
'synctoken' => 1
|
'synctoken' => 1
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach($properties as $property=>$newValue) {
|
foreach ($properties as $property=>$newValue) {
|
||||||
|
switch ($property) {
|
||||||
switch($property) {
|
|
||||||
case '{DAV:}displayname':
|
case '{DAV:}displayname':
|
||||||
$values['displayname'] = $newValue;
|
$values['displayname'] = $newValue;
|
||||||
break;
|
break;
|
||||||
|
@ -423,12 +418,11 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
||||||
default:
|
default:
|
||||||
throw new BadRequest('Unknown property: ' . $property);
|
throw new BadRequest('Unknown property: ' . $property);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to make sure the displayname is set. Some clients may refuse
|
// Fallback to make sure the displayname is set. Some clients may refuse
|
||||||
// to work with addressbooks not having a displayname.
|
// to work with addressbooks not having a displayname.
|
||||||
if(is_null($values['displayname'])) {
|
if (is_null($values['displayname'])) {
|
||||||
$values['displayname'] = $url;
|
$values['displayname'] = $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,7 +469,6 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
||||||
$query->delete($this->dbCardsPropertiesTable)
|
$query->delete($this->dbCardsPropertiesTable)
|
||||||
->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
|
->where($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId)))
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -506,7 +499,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
||||||
$cards = [];
|
$cards = [];
|
||||||
|
|
||||||
$result = $query->execute();
|
$result = $query->execute();
|
||||||
while($row = $result->fetch()) {
|
while ($row = $result->fetch()) {
|
||||||
$row['etag'] = '"' . $row['etag'] . '"';
|
$row['etag'] = '"' . $row['etag'] . '"';
|
||||||
$row['carddata'] = $this->readBlob($row['carddata']);
|
$row['carddata'] = $this->readBlob($row['carddata']);
|
||||||
$cards[] = $row;
|
$cards[] = $row;
|
||||||
|
@ -680,7 +673,6 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function updateCard($addressBookId, $cardUri, $cardData) {
|
function updateCard($addressBookId, $cardUri, $cardData) {
|
||||||
|
|
||||||
$uid = $this->getUID($cardData);
|
$uid = $this->getUID($cardData);
|
||||||
$etag = md5($cardData);
|
$etag = md5($cardData);
|
||||||
$query = $this->db->getQueryBuilder();
|
$query = $this->db->getQueryBuilder();
|
||||||
|
@ -804,7 +796,9 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
||||||
$stmt->execute([ $addressBookId ]);
|
$stmt->execute([ $addressBookId ]);
|
||||||
$currentToken = $stmt->fetchColumn(0);
|
$currentToken = $stmt->fetchColumn(0);
|
||||||
|
|
||||||
if (is_null($currentToken)) return null;
|
if (is_null($currentToken)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
$result = [
|
$result = [
|
||||||
'syncToken' => $currentToken,
|
'syncToken' => $currentToken,
|
||||||
|
@ -814,7 +808,6 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($syncToken) {
|
if ($syncToken) {
|
||||||
|
|
||||||
$query = "SELECT `uri`, `operation` FROM `*PREFIX*addressbookchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `addressbookid` = ? ORDER BY `synctoken`";
|
$query = "SELECT `uri`, `operation` FROM `*PREFIX*addressbookchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `addressbookid` = ? ORDER BY `synctoken`";
|
||||||
if ($limit>0) {
|
if ($limit>0) {
|
||||||
$query .= " LIMIT " . (int)$limit;
|
$query .= " LIMIT " . (int)$limit;
|
||||||
|
@ -828,15 +821,12 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
||||||
|
|
||||||
// This loop ensures that any duplicates are overwritten, only the
|
// This loop ensures that any duplicates are overwritten, only the
|
||||||
// last change on a node is relevant.
|
// last change on a node is relevant.
|
||||||
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
|
|
||||||
$changes[$row['uri']] = $row['operation'];
|
$changes[$row['uri']] = $row['operation'];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($changes as $uri => $operation) {
|
foreach ($changes as $uri => $operation) {
|
||||||
|
switch ($operation) {
|
||||||
switch($operation) {
|
|
||||||
case 1:
|
case 1:
|
||||||
$result['added'][] = $uri;
|
$result['added'][] = $uri;
|
||||||
break;
|
break;
|
||||||
|
@ -847,7 +837,6 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
||||||
$result['deleted'][] = $uri;
|
$result['deleted'][] = $uri;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// No synctoken supplied, this is the initial sync.
|
// No synctoken supplied, this is the initial sync.
|
||||||
|
@ -924,7 +913,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
||||||
|
|
||||||
// No need for like when the pattern is empty
|
// No need for like when the pattern is empty
|
||||||
if ('' !== $pattern) {
|
if ('' !== $pattern) {
|
||||||
if(\array_key_exists('escape_like_param', $options) && $options['escape_like_param'] === false) {
|
if (\array_key_exists('escape_like_param', $options) && $options['escape_like_param'] === false) {
|
||||||
$query2->andWhere($query2->expr()->ilike('cp.value', $query->createNamedParameter($pattern)));
|
$query2->andWhere($query2->expr()->ilike('cp.value', $query->createNamedParameter($pattern)));
|
||||||
} else {
|
} else {
|
||||||
$query2->andWhere($query2->expr()->ilike('cp.value', $query->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%')));
|
$query2->andWhere($query2->expr()->ilike('cp.value', $query->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%')));
|
||||||
|
@ -1053,11 +1042,11 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($vCard->children() as $property) {
|
foreach ($vCard->children() as $property) {
|
||||||
if(!in_array($property->name, self::$indexProperties)) {
|
if (!in_array($property->name, self::$indexProperties)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$preferred = 0;
|
$preferred = 0;
|
||||||
foreach($property->parameters as $parameter) {
|
foreach ($property->parameters as $parameter) {
|
||||||
if ($parameter->name === 'TYPE' && strtoupper($parameter->getValue()) === 'PREF') {
|
if ($parameter->name === 'TYPE' && strtoupper($parameter->getValue()) === 'PREF') {
|
||||||
$preferred = 1;
|
$preferred = 1;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -86,5 +86,4 @@ class ContactsManager {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,6 @@ class Converter {
|
||||||
* @return VCard|null
|
* @return VCard|null
|
||||||
*/
|
*/
|
||||||
public function createCardFromUser(IUser $user) {
|
public function createCardFromUser(IUser $user) {
|
||||||
|
|
||||||
$userData = $this->accountManager->getUser($user);
|
$userData = $this->accountManager->getUser($user);
|
||||||
|
|
||||||
$uid = $user->getUID();
|
$uid = $user->getUID();
|
||||||
|
@ -68,7 +67,6 @@ class Converter {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($userData as $property => $value) {
|
foreach ($userData as $property => $value) {
|
||||||
|
|
||||||
$shareWithTrustedServers =
|
$shareWithTrustedServers =
|
||||||
$value['scope'] === AccountManager::VISIBILITY_CONTACTS_ONLY ||
|
$value['scope'] === AccountManager::VISIBILITY_CONTACTS_ONLY ||
|
||||||
$value['scope'] === AccountManager::VISIBILITY_PUBLIC;
|
$value['scope'] === AccountManager::VISIBILITY_PUBLIC;
|
||||||
|
@ -150,5 +148,4 @@ class Converter {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,6 @@ class HasPhotoPlugin extends ServerPlugin {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function propFind(PropFind $propFind, INode $node) {
|
function propFind(PropFind $propFind, INode $node) {
|
||||||
|
|
||||||
$ns = '{http://nextcloud.com/ns}';
|
$ns = '{http://nextcloud.com/ns}';
|
||||||
|
|
||||||
if ($node instanceof Card) {
|
if ($node instanceof Card) {
|
||||||
|
@ -96,7 +95,5 @@ class HasPhotoPlugin extends ServerPlugin {
|
||||||
'name' => $this->getPluginName(),
|
'name' => $this->getPluginName(),
|
||||||
'description' => 'Return a boolean stating if the vcard have a photo property set or not.'
|
'description' => 'Return a boolean stating if the vcard have a photo property set or not.'
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,6 @@ class ImageExportPlugin extends ServerPlugin {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function httpGet(RequestInterface $request, ResponseInterface $response) {
|
public function httpGet(RequestInterface $request, ResponseInterface $response) {
|
||||||
|
|
||||||
$queryParams = $request->getQueryParameters();
|
$queryParams = $request->getQueryParameters();
|
||||||
// TODO: in addition to photo we should also add logo some point in time
|
// TODO: in addition to photo we should also add logo some point in time
|
||||||
if (!array_key_exists('photo', $queryParams)) {
|
if (!array_key_exists('photo', $queryParams)) {
|
||||||
|
|
|
@ -87,7 +87,6 @@ abstract class ExternalAddressBook implements IAddressBook, DAV\IProperties {
|
||||||
*/
|
*/
|
||||||
final public function createDirectory($name) {
|
final public function createDirectory($name) {
|
||||||
throw new DAV\Exception\MethodNotAllowed('Creating collections in address book objects is not allowed');
|
throw new DAV\Exception\MethodNotAllowed('Creating collections in address book objects is not allowed');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,5 +129,4 @@ abstract class ExternalAddressBook implements IAddressBook, DAV\IProperties {
|
||||||
public static function doesViolateReservedName(string $uri): bool {
|
public static function doesViolateReservedName(string $uri): bool {
|
||||||
return strpos($uri, self::PREFIX) === 0;
|
return strpos($uri, self::PREFIX) === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,5 +68,4 @@ interface IAddressBookProvider {
|
||||||
*@since 19.0.0
|
*@since 19.0.0
|
||||||
*/
|
*/
|
||||||
public function getAddressBookInAddressBookHome(string $principalUri, string $uri): ?ExternalAddressBook;
|
public function getAddressBookInAddressBookHome(string $principalUri, string $uri): ?ExternalAddressBook;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@ class MultiGetExportPlugin extends DAV\ServerPlugin {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function httpReport(RequestInterface $request, ResponseInterface $response) {
|
public function httpReport(RequestInterface $request, ResponseInterface $response) {
|
||||||
|
|
||||||
$queryParams = $request->getQueryParameters();
|
$queryParams = $request->getQueryParameters();
|
||||||
if (!array_key_exists('export', $queryParams)) {
|
if (!array_key_exists('export', $queryParams)) {
|
||||||
return;
|
return;
|
||||||
|
@ -118,7 +117,5 @@ class MultiGetExportPlugin extends DAV\ServerPlugin {
|
||||||
'name' => $this->getPluginName(),
|
'name' => $this->getPluginName(),
|
||||||
'description' => 'Intercept a multi-get request and return a single vcf file instead.'
|
'description' => 'Intercept a multi-get request and return a single vcf file instead.'
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,7 +164,6 @@ class PhotoCache {
|
||||||
$file = $folder->newFile($path);
|
$file = $folder->newFile($path);
|
||||||
$file->putContent($photo->data());
|
$file->putContent($photo->data());
|
||||||
} catch (NotPermittedException $e) {
|
} catch (NotPermittedException $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +179,7 @@ class PhotoCache {
|
||||||
try {
|
try {
|
||||||
return $this->appData->getFolder($hash);
|
return $this->appData->getFolder($hash);
|
||||||
} catch (NotFoundException $e) {
|
} catch (NotFoundException $e) {
|
||||||
if($createIfNotExists) {
|
if ($createIfNotExists) {
|
||||||
return $this->appData->newFolder($hash);
|
return $this->appData->newFolder($hash);
|
||||||
} else {
|
} else {
|
||||||
throw $e;
|
throw $e;
|
||||||
|
|
|
@ -30,7 +30,6 @@ use Sabre\DAV\PropFind;
|
||||||
use Sabre\DAV\Server;
|
use Sabre\DAV\Server;
|
||||||
|
|
||||||
class Plugin extends \Sabre\CardDAV\Plugin {
|
class Plugin extends \Sabre\CardDAV\Plugin {
|
||||||
|
|
||||||
function initialize(Server $server) {
|
function initialize(Server $server) {
|
||||||
$server->on('propFind', [$this, 'propFind']);
|
$server->on('propFind', [$this, 'propFind']);
|
||||||
parent::initialize($server);
|
parent::initialize($server);
|
||||||
|
@ -65,11 +64,9 @@ class Plugin extends \Sabre\CardDAV\Plugin {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function propFind(PropFind $propFind, INode $node) {
|
function propFind(PropFind $propFind, INode $node) {
|
||||||
|
|
||||||
$ns = '{http://owncloud.org/ns}';
|
$ns = '{http://owncloud.org/ns}';
|
||||||
|
|
||||||
if ($node instanceof AddressBook) {
|
if ($node instanceof AddressBook) {
|
||||||
|
|
||||||
$propFind->handle($ns . 'groups', function () use ($node) {
|
$propFind->handle($ns . 'groups', function () use ($node) {
|
||||||
return new Groups($node->getContactsGroups());
|
return new Groups($node->getContactsGroups());
|
||||||
});
|
});
|
||||||
|
|
|
@ -196,17 +196,17 @@ class SyncService {
|
||||||
* @param string $syncToken
|
* @param string $syncToken
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function requestSyncReport($url, $userName, $addressBookUrl, $sharedSecret, $syncToken) {
|
protected function requestSyncReport($url, $userName, $addressBookUrl, $sharedSecret, $syncToken) {
|
||||||
$client = $this->getClient($url, $userName, $sharedSecret);
|
$client = $this->getClient($url, $userName, $sharedSecret);
|
||||||
|
|
||||||
$body = $this->buildSyncCollectionRequestBody($syncToken);
|
$body = $this->buildSyncCollectionRequestBody($syncToken);
|
||||||
|
|
||||||
$response = $client->request('REPORT', $addressBookUrl, $body, [
|
$response = $client->request('REPORT', $addressBookUrl, $body, [
|
||||||
'Content-Type' => 'application/xml'
|
'Content-Type' => 'application/xml'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->parseMultiStatus($response['body']);
|
return $this->parseMultiStatus($response['body']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $url
|
* @param string $url
|
||||||
|
@ -225,7 +225,6 @@ class SyncService {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function buildSyncCollectionRequestBody($syncToken) {
|
private function buildSyncCollectionRequestBody($syncToken) {
|
||||||
|
|
||||||
$dom = new \DOMDocument('1.0', 'UTF-8');
|
$dom = new \DOMDocument('1.0', 'UTF-8');
|
||||||
$dom->formatOutput = true;
|
$dom->formatOutput = true;
|
||||||
$root = $dom->createElementNS('DAV:', 'd:sync-collection');
|
$root = $dom->createElementNS('DAV:', 'd:sync-collection');
|
||||||
|
@ -297,7 +296,7 @@ class SyncService {
|
||||||
*/
|
*/
|
||||||
public function deleteUser($userOrCardId) {
|
public function deleteUser($userOrCardId) {
|
||||||
$systemAddressBook = $this->getLocalSystemAddressBook();
|
$systemAddressBook = $this->getLocalSystemAddressBook();
|
||||||
if ($userOrCardId instanceof IUser){
|
if ($userOrCardId instanceof IUser) {
|
||||||
$name = $userOrCardId->getBackendClassName();
|
$name = $userOrCardId->getBackendClassName();
|
||||||
$userId = $userOrCardId->getUID();
|
$userId = $userOrCardId->getUID();
|
||||||
|
|
||||||
|
@ -331,7 +330,7 @@ class SyncService {
|
||||||
|
|
||||||
// remove no longer existing
|
// remove no longer existing
|
||||||
$allCards = $this->backend->getCards($systemAddressBook['id']);
|
$allCards = $this->backend->getCards($systemAddressBook['id']);
|
||||||
foreach($allCards as $card) {
|
foreach ($allCards as $card) {
|
||||||
$vCard = Reader::read($card['carddata']);
|
$vCard = Reader::read($card['carddata']);
|
||||||
$uid = $vCard->UID->getValue();
|
$uid = $vCard->UID->getValue();
|
||||||
// load backend and see if user exists
|
// load backend and see if user exists
|
||||||
|
@ -340,6 +339,4 @@ class SyncService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,6 @@ class UserAddressBooks extends \Sabre\CardDAV\AddressBookHome {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getACL() {
|
function getACL() {
|
||||||
|
|
||||||
$acl = parent::getACL();
|
$acl = parent::getACL();
|
||||||
if ($this->principalUri === 'principals/system/system') {
|
if ($this->principalUri === 'principals/system/system') {
|
||||||
$acl[] = [
|
$acl[] = [
|
||||||
|
@ -120,5 +119,4 @@ class UserAddressBooks extends \Sabre\CardDAV\AddressBookHome {
|
||||||
|
|
||||||
return $acl;
|
return $acl;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ class ListCalendars extends Command {
|
||||||
$calendars = $this->caldav->getCalendarsForUser("principals/users/$user");
|
$calendars = $this->caldav->getCalendarsForUser("principals/users/$user");
|
||||||
|
|
||||||
$calendarTableData = [];
|
$calendarTableData = [];
|
||||||
foreach($calendars as $calendar) {
|
foreach ($calendars as $calendar) {
|
||||||
// skip birthday calendar
|
// skip birthday calendar
|
||||||
if ($calendar['uri'] === BirthdayService::BIRTHDAY_CALENDAR_URI) {
|
if ($calendar['uri'] === BirthdayService::BIRTHDAY_CALENDAR_URI) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -101,5 +101,4 @@ class ListCalendars extends Command {
|
||||||
$output->writeln("<info>User <$user> has no calendars</info>");
|
$output->writeln("<info>User <$user> has no calendars</info>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue