diff options
Diffstat (limited to 'lib/public')
214 files changed, 2681 insertions, 237 deletions
diff --git a/lib/public/API.php b/lib/public/API.php index d3c528ee4f9..5a41dfc7acb 100644 --- a/lib/public/API.php +++ b/lib/public/API.php @@ -32,6 +32,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/Accounts/IAccountProperty.php b/lib/public/Accounts/IAccountProperty.php index 1f85ac3ca86..c7213e278a6 100644 --- a/lib/public/Accounts/IAccountProperty.php +++ b/lib/public/Accounts/IAccountProperty.php @@ -101,5 +101,3 @@ interface IAccountProperty extends \JsonSerializable { public function getVerified(): string; } - - diff --git a/lib/public/Activity/IConsumer.php b/lib/public/Activity/IConsumer.php index d56719c4de3..56dbc840344 100644 --- a/lib/public/Activity/IConsumer.php +++ b/lib/public/Activity/IConsumer.php @@ -29,6 +29,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Activity; /** @@ -46,4 +47,3 @@ interface IConsumer { */ public function receive(IEvent $event); } - diff --git a/lib/public/Activity/IEvent.php b/lib/public/Activity/IEvent.php index e380eca5c24..767d10f965a 100644 --- a/lib/public/Activity/IEvent.php +++ b/lib/public/Activity/IEvent.php @@ -29,6 +29,7 @@ declare(strict_types=1); // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Activity; /** diff --git a/lib/public/Activity/IFilter.php b/lib/public/Activity/IFilter.php index b6e2025d2cd..ae5e65c605c 100644 --- a/lib/public/Activity/IFilter.php +++ b/lib/public/Activity/IFilter.php @@ -70,4 +70,3 @@ interface IFilter { */ public function allowedApps(); } - diff --git a/lib/public/Activity/ISetting.php b/lib/public/Activity/ISetting.php index f3b953e95e0..4aedc03dd22 100644 --- a/lib/public/Activity/ISetting.php +++ b/lib/public/Activity/ISetting.php @@ -75,4 +75,3 @@ interface ISetting { */ public function isDefaultEnabledMail(); } - diff --git a/lib/public/App.php b/lib/public/App.php index c731a5085f7..ff494e7b2fc 100644 --- a/lib/public/App.php +++ b/lib/public/App.php @@ -35,6 +35,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/App/AppPathNotFoundException.php b/lib/public/App/AppPathNotFoundException.php index db5a1803c83..fbca8899d3a 100644 --- a/lib/public/App/AppPathNotFoundException.php +++ b/lib/public/App/AppPathNotFoundException.php @@ -29,4 +29,4 @@ namespace OCP\App; * @package OCP\App * @since 11.0.0 */ -class AppPathNotFoundException extends \Exception {}
\ No newline at end of file +class AppPathNotFoundException extends \Exception {} diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php index aebd47b3a2d..46025d9831b 100644 --- a/lib/public/App/IAppManager.php +++ b/lib/public/App/IAppManager.php @@ -8,6 +8,7 @@ * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <robin@icewind.nl> * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Daniel Rudolf <nextcloud.com@daniel-rudolf.de> * * @license AGPL-3.0 * @@ -27,8 +28,8 @@ namespace OCP\App; -use OCP\IUser; use OCP\IGroup; +use OCP\IUser; /** * Interface IAppManager @@ -126,6 +127,16 @@ interface IAppManager { public function getAppPath($appId); /** + * Get the web path for the given app. + * + * @param string $appId + * @return string + * @since 18.0.0 + * @throws AppPathNotFoundException + */ + public function getAppWebPath(string $appId): string; + + /** * List all apps enabled for a user * * @param \OCP\IUser $user diff --git a/lib/public/App/ManagerEvent.php b/lib/public/App/ManagerEvent.php index f46318c2621..27dc3a44dea 100644 --- a/lib/public/App/ManagerEvent.php +++ b/lib/public/App/ManagerEvent.php @@ -23,7 +23,7 @@ namespace OCP\App; -use Symfony\Component\EventDispatcher\Event; +use OCP\EventDispatcher\Event; /** * Class ManagerEvent diff --git a/lib/public/AppFramework/ApiController.php b/lib/public/AppFramework/ApiController.php index 5c99e170e00..bb17a34e8ba 100644 --- a/lib/public/AppFramework/ApiController.php +++ b/lib/public/AppFramework/ApiController.php @@ -33,7 +33,6 @@ namespace OCP\AppFramework; use OCP\AppFramework\Http\Response; use OCP\IRequest; - /** * Base class to inherit your controllers from that are used for RESTful APIs * @since 7.0.0 diff --git a/lib/public/AppFramework/App.php b/lib/public/AppFramework/App.php index 06524e4bf02..6fd1646f3f9 100644 --- a/lib/public/AppFramework/App.php +++ b/lib/public/AppFramework/App.php @@ -34,9 +34,9 @@ declare(strict_types=1); namespace OCP\AppFramework; use OC\AppFramework\Routing\RouteConfig; +use OC\ServerContainer; use OCP\Route\IRouter; - /** * Class App * @package OCP\AppFramework @@ -51,8 +51,8 @@ class App { private $container; /** - * Turns an app id into a namespace by convetion. The id is split at the - * underscores, all parts are camelcased and reassembled. e.g.: + * Turns an app id into a namespace by convention. The id is split at the + * underscores, all parts are CamelCased and reassembled. e.g.: * some_app_id -> OCA\SomeAppId * @param string $appId the app id * @param string $topNamespace the namespace which should be prepended to @@ -71,6 +71,36 @@ class App { * @since 6.0.0 */ public function __construct(string $appName, array $urlParams = []) { + if (\OC::$server->getConfig()->getSystemValueBool('debug')) { + $applicationClassName = get_class($this); + $e = new \RuntimeException('App class ' . $applicationClassName . ' is not setup via query() but directly'); + $setUpViaQuery = false; + + $classNameParts = explode('\\', trim($applicationClassName, '\\')); + + foreach ($e->getTrace() as $step) { + if (isset($step['class'], $step['function'], $step['args'][0]) && + $step['class'] === ServerContainer::class && + $step['function'] === 'query' && + $step['args'][0] === $applicationClassName) { + $setUpViaQuery = true; + break; + } else if (isset($step['class'], $step['function'], $step['args'][0]) && + $step['class'] === ServerContainer::class && + $step['function'] === 'getAppContainer' && + $step['args'][1] === $classNameParts[1]) { + $setUpViaQuery = true; + break; + } + } + + if (!$setUpViaQuery && $applicationClassName !== \OCP\AppFramework\App::class) { + \OC::$server->getLogger()->logException($e, [ + 'app' => $appName, + ]); + } + } + try { $this->container = \OC::$server->getRegisteredAppContainer($appName); } catch (QueryException $e) { diff --git a/lib/public/AppFramework/Controller.php b/lib/public/AppFramework/Controller.php index 64be033d1d9..76390d09b4a 100644 --- a/lib/public/AppFramework/Controller.php +++ b/lib/public/AppFramework/Controller.php @@ -34,12 +34,11 @@ namespace OCP\AppFramework; -use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\DataResponse; +use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\Response; use OCP\IRequest; - /** * Base class to inherit your controllers from * @since 6.0.0 diff --git a/lib/public/AppFramework/Db/DoesNotExistException.php b/lib/public/AppFramework/Db/DoesNotExistException.php index 9823a0a1fa8..563d7d22aa8 100644 --- a/lib/public/AppFramework/Db/DoesNotExistException.php +++ b/lib/public/AppFramework/Db/DoesNotExistException.php @@ -22,7 +22,6 @@ declare(strict_types=1); * */ - namespace OCP\AppFramework\Db; diff --git a/lib/public/AppFramework/Db/Entity.php b/lib/public/AppFramework/Db/Entity.php index e339707d85f..8bd537211fc 100644 --- a/lib/public/AppFramework/Db/Entity.php +++ b/lib/public/AppFramework/Db/Entity.php @@ -24,6 +24,9 @@ namespace OCP\AppFramework\Db; +use function lcfirst; +use function substr; + /** * @method integer getId() * @method void setId(integer $id) @@ -84,7 +87,7 @@ abstract class Entity { return $this->_fieldTypes; } - + /** * Marks the entity as clean needed for setting the id after the insertion * @since 7.0.0 @@ -112,7 +115,7 @@ abstract class Entity { $this->$name = $args[0]; } else { - throw new \BadFunctionCallException($name . + throw new \BadFunctionCallException($name . ' is not a valid attribute'); } } @@ -126,7 +129,7 @@ abstract class Entity { if(property_exists($this, $name)){ return $this->$name; } else { - throw new \BadFunctionCallException($name . + throw new \BadFunctionCallException($name . ' is not a valid attribute'); } } @@ -134,25 +137,37 @@ abstract class Entity { /** * Each time a setter is called, push the part after set - * into an array: for instance setId will save Id in the + * into an array: for instance setId will save Id in the * updated fields array so it can be easily used to create the * getter method * @since 7.0.0 */ - public function __call($methodName, $args){ - $attr = lcfirst( substr($methodName, 3) ); - - if(strpos($methodName, 'set') === 0){ - $this->setter($attr, $args); - } elseif(strpos($methodName, 'get') === 0) { - return $this->getter($attr); + public function __call($methodName, $args) { + if (strpos($methodName, 'set') === 0) { + $this->setter(lcfirst(substr($methodName, 3)), $args); + } elseif (strpos($methodName, 'get') === 0) { + return $this->getter(lcfirst(substr($methodName, 3))); + } elseif ($this->isGetterForBoolProperty($methodName)) { + return $this->getter(lcfirst(substr($methodName, 2))); } else { - throw new \BadFunctionCallException($methodName . - ' does not exist'); + throw new \BadFunctionCallException($methodName . + ' does not exist'); } } + /** + * @param string $methodName + * @return bool + * @since 18.0.0 + */ + protected function isGetterForBoolProperty(string $methodName): bool { + if (strpos($methodName, 'is') === 0) { + $fieldName = lcfirst(substr($methodName, 2)); + return isset($this->_fieldTypes[$fieldName]) && strpos($this->_fieldTypes[$fieldName], 'bool') === 0; + } + return false; + } /** * Mark am attribute as updated @@ -165,7 +180,7 @@ abstract class Entity { /** - * Transform a database columnname to a property + * Transform a database columnname to a property * @param string $columnName the name of the column * @return string the property name * @since 7.0.0 diff --git a/lib/public/AppFramework/Db/Mapper.php b/lib/public/AppFramework/Db/Mapper.php index 6910757add0..d8de9e23aa7 100644 --- a/lib/public/AppFramework/Db/Mapper.php +++ b/lib/public/AppFramework/Db/Mapper.php @@ -24,12 +24,10 @@ * */ - namespace OCP\AppFramework\Db; use OCP\IDBConnection; - /** * Simple parent class for inheriting your data access layer from. This class * may be subject to change in the future diff --git a/lib/public/AppFramework/Db/MultipleObjectsReturnedException.php b/lib/public/AppFramework/Db/MultipleObjectsReturnedException.php index 3955c417d57..465c76c4dcb 100644 --- a/lib/public/AppFramework/Db/MultipleObjectsReturnedException.php +++ b/lib/public/AppFramework/Db/MultipleObjectsReturnedException.php @@ -22,7 +22,6 @@ declare(strict_types=1); * */ - namespace OCP\AppFramework\Db; diff --git a/lib/public/AppFramework/Http/DataDownloadResponse.php b/lib/public/AppFramework/Http/DataDownloadResponse.php index e9fcba8148d..78cf01f1ac7 100644 --- a/lib/public/AppFramework/Http/DataDownloadResponse.php +++ b/lib/public/AppFramework/Http/DataDownloadResponse.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\AppFramework\Http; /** diff --git a/lib/public/AppFramework/Http/DownloadResponse.php b/lib/public/AppFramework/Http/DownloadResponse.php index 774a6287cb2..4061dc42ad7 100644 --- a/lib/public/AppFramework/Http/DownloadResponse.php +++ b/lib/public/AppFramework/Http/DownloadResponse.php @@ -22,7 +22,6 @@ * */ - namespace OCP\AppFramework\Http; diff --git a/lib/public/AppFramework/Http/EmptyContentSecurityPolicy.php b/lib/public/AppFramework/Http/EmptyContentSecurityPolicy.php index b3f341ab054..2d32ce0aa01 100644 --- a/lib/public/AppFramework/Http/EmptyContentSecurityPolicy.php +++ b/lib/public/AppFramework/Http/EmptyContentSecurityPolicy.php @@ -110,6 +110,7 @@ class EmptyContentSecurityPolicy { * @param bool $state * @return $this * @since 8.1.0 + * @deprecated Eval should not be used anymore. Please update your scripts. This function will stop functioning in a future version of Nextcloud. */ public function allowEvalScript($state = true) { $this->evalScriptAllowed = $state; diff --git a/lib/public/AppFramework/Http/FileDisplayResponse.php b/lib/public/AppFramework/Http/FileDisplayResponse.php index 2d2dd29e6a1..a63a77ef4ef 100644 --- a/lib/public/AppFramework/Http/FileDisplayResponse.php +++ b/lib/public/AppFramework/Http/FileDisplayResponse.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ + namespace OCP\AppFramework\Http; use OCP\AppFramework\Http; diff --git a/lib/public/AppFramework/Http/NotFoundResponse.php b/lib/public/AppFramework/Http/NotFoundResponse.php index 6d764ec526e..2ae3c41fe4a 100644 --- a/lib/public/AppFramework/Http/NotFoundResponse.php +++ b/lib/public/AppFramework/Http/NotFoundResponse.php @@ -37,6 +37,7 @@ class NotFoundResponse extends Response { public function __construct() { parent::__construct(); + $this->setContentSecurityPolicy(new ContentSecurityPolicy()); $this->setStatus(404); } diff --git a/lib/public/AppFramework/Http/RedirectResponse.php b/lib/public/AppFramework/Http/RedirectResponse.php index dc44bbe999c..84f53936fe8 100644 --- a/lib/public/AppFramework/Http/RedirectResponse.php +++ b/lib/public/AppFramework/Http/RedirectResponse.php @@ -23,12 +23,10 @@ * */ - namespace OCP\AppFramework\Http; use OCP\AppFramework\Http; - /** * Redirects to a different URL * @since 7.0.0 diff --git a/lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php b/lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php index 2ec50137ef9..0a2f4c9d9ee 100644 --- a/lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php +++ b/lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php @@ -19,6 +19,7 @@ declare(strict_types=1); * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ + namespace OCP\AppFramework\Http; diff --git a/lib/public/AppFramework/Http/Response.php b/lib/public/AppFramework/Http/Response.php index bfee7d51549..f46aa9e2880 100644 --- a/lib/public/AppFramework/Http/Response.php +++ b/lib/public/AppFramework/Http/Response.php @@ -93,13 +93,9 @@ class Response { private $throttleMetadata = []; /** - * Response constructor. - * * @since 17.0.0 */ public function __construct() { - $this->setContentSecurityPolicy(new EmptyContentSecurityPolicy()); - $this->setFeaturePolicy(new EmptyFeaturePolicy()); } /** @@ -241,12 +237,8 @@ class Response { $this->lastModified->format(\DateTime::RFC2822); } - // Build Content-Security-Policy and use default if none has been specified - if(is_null($this->contentSecurityPolicy)) { - $this->setContentSecurityPolicy(new ContentSecurityPolicy()); - } - $this->headers['Content-Security-Policy'] = $this->contentSecurityPolicy->buildPolicy(); - $this->headers['Feature-Policy'] = $this->featurePolicy->buildPolicy(); + $this->headers['Content-Security-Policy'] = $this->getContentSecurityPolicy()->buildPolicy(); + $this->headers['Feature-Policy'] = $this->getFeaturePolicy()->buildPolicy(); if($this->ETag) { $mergeWith['ETag'] = '"' . $this->ETag . '"'; @@ -296,6 +288,9 @@ class Response { * @since 8.1.0 */ public function getContentSecurityPolicy() { + if ($this->contentSecurityPolicy === null) { + $this->setContentSecurityPolicy(new EmptyContentSecurityPolicy()); + } return $this->contentSecurityPolicy; } @@ -304,6 +299,9 @@ class Response { * @since 17.0.0 */ public function getFeaturePolicy(): EmptyFeaturePolicy { + if ($this->featurePolicy === null) { + $this->setFeaturePolicy(new EmptyFeaturePolicy()); + } return $this->featurePolicy; } diff --git a/lib/public/AppFramework/Http/Template/ExternalShareMenuAction.php b/lib/public/AppFramework/Http/Template/ExternalShareMenuAction.php index 4d455a9a755..84eb48b954c 100644 --- a/lib/public/AppFramework/Http/Template/ExternalShareMenuAction.php +++ b/lib/public/AppFramework/Http/Template/ExternalShareMenuAction.php @@ -25,6 +25,7 @@ namespace OCP\AppFramework\Http\Template; use OCP\AppFramework\Http\Template\SimpleMenuAction; use OCP\Util; + /** * Class LinkMenuAction * diff --git a/lib/public/AppFramework/Http/Template/IMenuAction.php b/lib/public/AppFramework/Http/Template/IMenuAction.php index e42d2057981..8a037b62e4b 100644 --- a/lib/public/AppFramework/Http/Template/IMenuAction.php +++ b/lib/public/AppFramework/Http/Template/IMenuAction.php @@ -61,4 +61,4 @@ interface IMenuAction { */ public function render(): string; -}
\ No newline at end of file +} diff --git a/lib/public/AppFramework/Http/Template/PublicTemplateResponse.php b/lib/public/AppFramework/Http/Template/PublicTemplateResponse.php index a520748a9ea..adffdd9ecdc 100644 --- a/lib/public/AppFramework/Http/Template/PublicTemplateResponse.php +++ b/lib/public/AppFramework/Http/Template/PublicTemplateResponse.php @@ -155,4 +155,4 @@ class PublicTemplateResponse extends TemplateResponse { return parent::render(); } -}
\ No newline at end of file +} diff --git a/lib/public/AppFramework/Http/Template/SimpleMenuAction.php b/lib/public/AppFramework/Http/Template/SimpleMenuAction.php index 60bb268661c..2a09d89d31a 100644 --- a/lib/public/AppFramework/Http/Template/SimpleMenuAction.php +++ b/lib/public/AppFramework/Http/Template/SimpleMenuAction.php @@ -123,4 +123,4 @@ class SimpleMenuAction implements IMenuAction { ); } -}
\ No newline at end of file +} diff --git a/lib/public/AppFramework/Http/ZipResponse.php b/lib/public/AppFramework/Http/ZipResponse.php index bec0812ab0c..4223912488b 100644 --- a/lib/public/AppFramework/Http/ZipResponse.php +++ b/lib/public/AppFramework/Http/ZipResponse.php @@ -25,8 +25,8 @@ declare(strict_types=1); namespace OCP\AppFramework\Http; -use OCP\IRequest; use OC\Streamer; +use OCP\IRequest; /** * Public library to send several files in one zip archive. diff --git a/lib/public/AppFramework/Middleware.php b/lib/public/AppFramework/Middleware.php index 4c9051a0b34..663e8e05452 100644 --- a/lib/public/AppFramework/Middleware.php +++ b/lib/public/AppFramework/Middleware.php @@ -33,7 +33,6 @@ namespace OCP\AppFramework; use OCP\AppFramework\Http\Response; - /** * Middleware is used to provide hooks before or after controller methods and * deal with possible exceptions raised in the controller methods. diff --git a/lib/public/AppFramework/OCS/OCSBadRequestException.php b/lib/public/AppFramework/OCS/OCSBadRequestException.php index 843f8a5e0a4..7e7c775c368 100644 --- a/lib/public/AppFramework/OCS/OCSBadRequestException.php +++ b/lib/public/AppFramework/OCS/OCSBadRequestException.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ + namespace OCP\AppFramework\OCS; use Exception; diff --git a/lib/public/AppFramework/OCS/OCSException.php b/lib/public/AppFramework/OCS/OCSException.php index 3ef6f3393ab..e6c506aef5c 100644 --- a/lib/public/AppFramework/OCS/OCSException.php +++ b/lib/public/AppFramework/OCS/OCSException.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ + namespace OCP\AppFramework\OCS; use Exception; diff --git a/lib/public/AppFramework/OCS/OCSForbiddenException.php b/lib/public/AppFramework/OCS/OCSForbiddenException.php index 7545d87c0bf..a163ca5f175 100644 --- a/lib/public/AppFramework/OCS/OCSForbiddenException.php +++ b/lib/public/AppFramework/OCS/OCSForbiddenException.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ + namespace OCP\AppFramework\OCS; use Exception; diff --git a/lib/public/AppFramework/OCS/OCSNotFoundException.php b/lib/public/AppFramework/OCS/OCSNotFoundException.php index 87a5ce20098..12e135251b4 100644 --- a/lib/public/AppFramework/OCS/OCSNotFoundException.php +++ b/lib/public/AppFramework/OCS/OCSNotFoundException.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ + namespace OCP\AppFramework\OCS; use Exception; diff --git a/lib/public/AppFramework/OCSController.php b/lib/public/AppFramework/OCSController.php index 29f26bf7e71..e1273a0ca3e 100644 --- a/lib/public/AppFramework/OCSController.php +++ b/lib/public/AppFramework/OCSController.php @@ -36,7 +36,6 @@ use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\Response; use OCP\IRequest; - /** * Base class to inherit your controllers from that are used for RESTful APIs * @since 8.1.0 diff --git a/lib/public/AppFramework/Utility/IControllerMethodReflector.php b/lib/public/AppFramework/Utility/IControllerMethodReflector.php index e2074b9fe00..bc9a04f44cf 100644 --- a/lib/public/AppFramework/Utility/IControllerMethodReflector.php +++ b/lib/public/AppFramework/Utility/IControllerMethodReflector.php @@ -40,6 +40,7 @@ interface IControllerMethodReflector { * @param string $method the method which we want to inspect * @return void * @since 8.0.0 + * @deprecated 17.0.0 Reflect should not be called multiple times and only be used internally. This will be removed in Nextcloud 18 */ public function reflect($object, string $method); diff --git a/lib/public/Authentication/IApacheBackend.php b/lib/public/Authentication/IApacheBackend.php index fcc1c1a9b87..3569c50a034 100644 --- a/lib/public/Authentication/IApacheBackend.php +++ b/lib/public/Authentication/IApacheBackend.php @@ -29,6 +29,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Authentication; /** diff --git a/lib/public/Authentication/LoginCredentials/IStore.php b/lib/public/Authentication/LoginCredentials/IStore.php index 5306eb6d6e9..054e6d85646 100644 --- a/lib/public/Authentication/LoginCredentials/IStore.php +++ b/lib/public/Authentication/LoginCredentials/IStore.php @@ -1,4 +1,5 @@ -<?php +<?php declare(strict_types=1); + /** * @copyright 2016 Christoph Wurst <christoph@winzerhof-wurst.at> * @@ -29,7 +30,7 @@ use OCP\Authentication\Exceptions\CredentialsUnavailableException; * @since 12 */ interface IStore { - + /** * Get login credentials of the currently logged in user * @@ -38,6 +39,6 @@ interface IStore { * @throws CredentialsUnavailableException * @return ICredentials the login credentials of the current user */ - public function getLoginCredentials(); - + public function getLoginCredentials(): ICredentials; + } diff --git a/lib/public/AutoloadNotAllowedException.php b/lib/public/AutoloadNotAllowedException.php index 6c7b979f2d6..563dbdcfe0f 100644 --- a/lib/public/AutoloadNotAllowedException.php +++ b/lib/public/AutoloadNotAllowedException.php @@ -35,4 +35,3 @@ class AutoloadNotAllowedException extends \DomainException { parent::__construct('Autoload path not allowed: '.$path); } } - diff --git a/lib/public/Broadcast/Events/IBroadcastEvent.php b/lib/public/Broadcast/Events/IBroadcastEvent.php new file mode 100644 index 00000000000..0aa7ff45eec --- /dev/null +++ b/lib/public/Broadcast/Events/IBroadcastEvent.php @@ -0,0 +1,57 @@ +<?php declare(strict_types=1); + +/** + * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Broadcast\Events; + +use JsonSerializable; + +/** + * @since 18.0.0 + */ +interface IBroadcastEvent { + + /** + * @return string the name of the event + * @since 18.0.0 + */ + public function getName(): string; + + /** + * @return string[] + * @since 18.0.0 + */ + public function getUids(): array; + + /** + * @return JsonSerializable the data to be sent to the client + * @since 18.0.0 + */ + public function getPayload(): JsonSerializable; + + /** + * @since 18.0.0 + */ + public function setBroadcasted(): void; + +} diff --git a/lib/public/Capabilities/ICapability.php b/lib/public/Capabilities/ICapability.php index 2a59689665d..918c97f8b68 100644 --- a/lib/public/Capabilities/ICapability.php +++ b/lib/public/Capabilities/ICapability.php @@ -44,4 +44,3 @@ interface ICapability { */ public function getCapabilities(); } - diff --git a/lib/public/Capabilities/IPublicCapability.php b/lib/public/Capabilities/IPublicCapability.php index c882a24d56f..7f5d39f0ae3 100644 --- a/lib/public/Capabilities/IPublicCapability.php +++ b/lib/public/Capabilities/IPublicCapability.php @@ -29,4 +29,3 @@ namespace OCP\Capabilities; * @since 13.0.0 */ interface IPublicCapability extends ICapability {} - diff --git a/lib/public/Comments/CommentsEntityEvent.php b/lib/public/Comments/CommentsEntityEvent.php index fe8585a213e..d3ffb710e2e 100644 --- a/lib/public/Comments/CommentsEntityEvent.php +++ b/lib/public/Comments/CommentsEntityEvent.php @@ -22,7 +22,7 @@ namespace OCP\Comments; -use Symfony\Component\EventDispatcher\Event; +use OCP\EventDispatcher\Event; /** * Class CommentsEntityEvent diff --git a/lib/public/Comments/CommentsEvent.php b/lib/public/Comments/CommentsEvent.php index eba4cebb3bf..43b8366a22f 100644 --- a/lib/public/Comments/CommentsEvent.php +++ b/lib/public/Comments/CommentsEvent.php @@ -23,7 +23,7 @@ namespace OCP\Comments; -use Symfony\Component\EventDispatcher\Event; +use OCP\EventDispatcher\Event; /** * Class CommentsEvent diff --git a/lib/public/Comments/IComment.php b/lib/public/Comments/IComment.php index c7c846bbe9d..3249d70f496 100644 --- a/lib/public/Comments/IComment.php +++ b/lib/public/Comments/IComment.php @@ -21,6 +21,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\Comments; /** @@ -262,4 +263,3 @@ interface IComment { public function setObject($objectType, $objectId); } - diff --git a/lib/public/Comments/ICommentsManager.php b/lib/public/Comments/ICommentsManager.php index 744263643ec..061dacba480 100644 --- a/lib/public/Comments/ICommentsManager.php +++ b/lib/public/Comments/ICommentsManager.php @@ -24,6 +24,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\Comments; use OCP\IUser; diff --git a/lib/public/Comments/ICommentsManagerFactory.php b/lib/public/Comments/ICommentsManagerFactory.php index 4a38d992bc3..bdd15c816cb 100644 --- a/lib/public/Comments/ICommentsManagerFactory.php +++ b/lib/public/Comments/ICommentsManagerFactory.php @@ -21,6 +21,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\Comments; use OCP\IServerContainer; diff --git a/lib/public/Comments/IllegalIDChangeException.php b/lib/public/Comments/IllegalIDChangeException.php index 97f18fee12e..605f373acf2 100644 --- a/lib/public/Comments/IllegalIDChangeException.php +++ b/lib/public/Comments/IllegalIDChangeException.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\Comments; /** diff --git a/lib/public/Comments/MessageTooLongException.php b/lib/public/Comments/MessageTooLongException.php index 4c46ed46524..19c93b8252e 100644 --- a/lib/public/Comments/MessageTooLongException.php +++ b/lib/public/Comments/MessageTooLongException.php @@ -19,6 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\Comments; /** diff --git a/lib/public/Comments/NotFoundException.php b/lib/public/Comments/NotFoundException.php index ab83e4095c2..56b48efcff0 100644 --- a/lib/public/Comments/NotFoundException.php +++ b/lib/public/Comments/NotFoundException.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\Comments; /** diff --git a/lib/public/Console/ConsoleEvent.php b/lib/public/Console/ConsoleEvent.php index 7b3201999a3..6645b20ac2e 100644 --- a/lib/public/Console/ConsoleEvent.php +++ b/lib/public/Console/ConsoleEvent.php @@ -22,7 +22,7 @@ namespace OCP\Console; -use Symfony\Component\EventDispatcher\Event; +use OCP\EventDispatcher\Event; /** * Class ConsoleEvent diff --git a/lib/public/Contacts/IManager.php b/lib/public/Contacts/IManager.php index 84948a929c0..b3ada74ba2d 100644 --- a/lib/public/Contacts/IManager.php +++ b/lib/public/Contacts/IManager.php @@ -30,6 +30,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Contacts; /** diff --git a/lib/public/DB/QueryBuilder/IFunctionBuilder.php b/lib/public/DB/QueryBuilder/IFunctionBuilder.php index 1e17290f145..d82d3ada8cf 100644 --- a/lib/public/DB/QueryBuilder/IFunctionBuilder.php +++ b/lib/public/DB/QueryBuilder/IFunctionBuilder.php @@ -104,5 +104,55 @@ interface IFunctionBuilder { * @return IQueryFunction * @since 14.0.0 */ - public function count($count, $alias = ''); + public function count($count = '', $alias = ''); + + /** + * Takes the maximum of all rows in a column + * + * If you want to get the maximum value of multiple columns in the same row, use `greatest` instead + * + * @param mixed $field the column to maximum + * + * @return IQueryFunction + * @since 18.0.0 + */ + public function max($field); + + /** + * Takes the minimum of all rows in a column + * + * If you want to get the minimum value of multiple columns in the same row, use `least` instead + * + * @param mixed $field the column to minimum + * + * @return IQueryFunction + * @since 18.0.0 + */ + public function min($field); + + /** + * Takes the maximum of multiple values + * + * If you want to get the maximum value of all rows in a column, use `max` instead + * + * @param mixed $x the first input field or number + * @param mixed $y the first input field or number + * + * @return IQueryFunction + * @since 18.0.0 + */ + public function greatest($x, $y); + + /** + * Takes the minimum of multiple values + * + * If you want to get the minimum value of all rows in a column, use `min` instead + * + * @param mixed $x the first input field or number + * @param mixed $y the first input field or number + * + * @return IQueryFunction + * @since 18.0.0 + */ + public function least($x, $y); } diff --git a/lib/public/DB/QueryBuilder/ILiteral.php b/lib/public/DB/QueryBuilder/ILiteral.php index 99b45ee7c29..1debf81f2b8 100644 --- a/lib/public/DB/QueryBuilder/ILiteral.php +++ b/lib/public/DB/QueryBuilder/ILiteral.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\DB\QueryBuilder; /** diff --git a/lib/public/DB/QueryBuilder/IParameter.php b/lib/public/DB/QueryBuilder/IParameter.php index c4e3fe29971..9e50c0905eb 100644 --- a/lib/public/DB/QueryBuilder/IParameter.php +++ b/lib/public/DB/QueryBuilder/IParameter.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\DB\QueryBuilder; /** diff --git a/lib/public/DB/QueryBuilder/IQueryBuilder.php b/lib/public/DB/QueryBuilder/IQueryBuilder.php index 7fea31f4688..fe5182f21b9 100644 --- a/lib/public/DB/QueryBuilder/IQueryBuilder.php +++ b/lib/public/DB/QueryBuilder/IQueryBuilder.php @@ -180,7 +180,7 @@ interface IQueryBuilder { * @param mixed $value The parameter value. * @param string|null|int $type One of the IQueryBuilder::PARAM_* constants. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function setParameter($key, $value, $type = null); @@ -202,7 +202,7 @@ interface IQueryBuilder { * @param array $params The query parameters to set. * @param array $types The query parameters types to set. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function setParameters(array $params, array $types = array()); @@ -248,7 +248,7 @@ interface IQueryBuilder { * * @param integer $firstResult The first result to return. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function setFirstResult($firstResult); @@ -267,7 +267,7 @@ interface IQueryBuilder { * * @param integer $maxResults The maximum number of results to retrieve. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function setMaxResults($maxResults); @@ -294,7 +294,7 @@ interface IQueryBuilder { * * @param mixed ...$selects The selection expressions. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function select(...$selects); @@ -312,7 +312,7 @@ interface IQueryBuilder { * @param mixed $select The selection expressions. * @param string $alias The column alias used in the constructed query. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.1 */ public function selectAlias($select, $alias); @@ -328,7 +328,7 @@ interface IQueryBuilder { * * @param mixed $select The selection expressions. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 9.0.0 */ public function selectDistinct($select); @@ -346,7 +346,7 @@ interface IQueryBuilder { * * @param mixed ...$select The selection expression. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function addSelect(...$select); @@ -365,7 +365,7 @@ interface IQueryBuilder { * @param string $delete The table whose rows are subject to the deletion. * @param string $alias The table alias used in the constructed query. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function delete($delete = null, $alias = null); @@ -384,7 +384,7 @@ interface IQueryBuilder { * @param string $update The table whose rows are subject to the update. * @param string $alias The table alias used in the constructed query. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function update($update = null, $alias = null); @@ -406,7 +406,7 @@ interface IQueryBuilder { * * @param string $insert The table into which the rows should be inserted. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function insert($insert = null); @@ -424,7 +424,7 @@ interface IQueryBuilder { * @param string $from The table. * @param string|null $alias The alias of the table. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function from($from, $alias = null); @@ -444,7 +444,7 @@ interface IQueryBuilder { * @param string $alias The alias of the join table. * @param string $condition The condition for the join. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function join($fromAlias, $join, $alias, $condition = null); @@ -464,7 +464,7 @@ interface IQueryBuilder { * @param string $alias The alias of the join table. * @param string $condition The condition for the join. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function innerJoin($fromAlias, $join, $alias, $condition = null); @@ -484,7 +484,7 @@ interface IQueryBuilder { * @param string $alias The alias of the join table. * @param string $condition The condition for the join. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function leftJoin($fromAlias, $join, $alias, $condition = null); @@ -504,7 +504,7 @@ interface IQueryBuilder { * @param string $alias The alias of the join table. * @param string $condition The condition for the join. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function rightJoin($fromAlias, $join, $alias, $condition = null); @@ -522,7 +522,7 @@ interface IQueryBuilder { * @param string $key The column to set. * @param string $value The value, expression, placeholder, etc. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function set($key, $value); @@ -551,7 +551,7 @@ interface IQueryBuilder { * * @param mixed $predicates The restriction predicates. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function where(...$predicates); @@ -570,7 +570,7 @@ interface IQueryBuilder { * * @param mixed ...$where The query restrictions. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * * @see where() * @since 8.2.0 @@ -591,7 +591,7 @@ interface IQueryBuilder { * * @param mixed ...$where The WHERE statement. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * * @see where() * @since 8.2.0 @@ -611,7 +611,7 @@ interface IQueryBuilder { * * @param mixed ...$groupBys The grouping expression. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function groupBy(...$groupBys); @@ -629,7 +629,7 @@ interface IQueryBuilder { * * @param mixed ...$groupBy The grouping expression. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function addGroupBy(...$groupBy); @@ -651,7 +651,7 @@ interface IQueryBuilder { * @param string $column The column into which the value should be inserted. * @param string $value The value that should be inserted into the column. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function setValue($column, $value); @@ -673,7 +673,7 @@ interface IQueryBuilder { * * @param array $values The values to specify for the insert query indexed by column names. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function values(array $values); @@ -684,7 +684,7 @@ interface IQueryBuilder { * * @param mixed ...$having The restriction over the groups. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function having(...$having); @@ -695,7 +695,7 @@ interface IQueryBuilder { * * @param mixed ...$having The restriction to append. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function andHaving(...$having); @@ -706,7 +706,7 @@ interface IQueryBuilder { * * @param mixed ...$having The restriction to add. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function orHaving(...$having); @@ -718,7 +718,7 @@ interface IQueryBuilder { * @param string $sort The ordering expression. * @param string $order The ordering direction. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function orderBy($sort, $order = null); @@ -729,7 +729,7 @@ interface IQueryBuilder { * @param string $sort The ordering expression. * @param string $order The ordering direction. * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function addOrderBy($sort, $order = null); @@ -757,7 +757,7 @@ interface IQueryBuilder { * * @param array|null $queryPartNames * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function resetQueryParts($queryPartNames = null); @@ -767,7 +767,7 @@ interface IQueryBuilder { * * @param string $queryPartName * - * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance. + * @return $this This QueryBuilder instance. * @since 8.2.0 */ public function resetQueryPart($queryPartName); diff --git a/lib/public/DB/QueryBuilder/IQueryFunction.php b/lib/public/DB/QueryBuilder/IQueryFunction.php index 5c319194739..afb676db565 100644 --- a/lib/public/DB/QueryBuilder/IQueryFunction.php +++ b/lib/public/DB/QueryBuilder/IQueryFunction.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\DB\QueryBuilder; /** diff --git a/lib/public/Dashboard/Exceptions/DashboardAppNotAvailableException.php b/lib/public/Dashboard/Exceptions/DashboardAppNotAvailableException.php index 4c3013000e8..1e3d420e0bf 100644 --- a/lib/public/Dashboard/Exceptions/DashboardAppNotAvailableException.php +++ b/lib/public/Dashboard/Exceptions/DashboardAppNotAvailableException.php @@ -38,4 +38,3 @@ namespace OCP\Dashboard\Exceptions; */ class DashboardAppNotAvailableException extends \Exception { } - diff --git a/lib/public/Dashboard/IDashboardManager.php b/lib/public/Dashboard/IDashboardManager.php index ede47c4baaf..93f96983583 100644 --- a/lib/public/Dashboard/IDashboardManager.php +++ b/lib/public/Dashboard/IDashboardManager.php @@ -27,7 +27,6 @@ declare(strict_types=1); * */ - namespace OCP\Dashboard; @@ -134,4 +133,3 @@ interface IDashboardManager { public function createGlobalEvent(string $widgetId, array $payload, string $uniqueId = ''); } - diff --git a/lib/public/Dashboard/IDashboardWidget.php b/lib/public/Dashboard/IDashboardWidget.php index bbbdf86da8f..b4bb3892911 100644 --- a/lib/public/Dashboard/IDashboardWidget.php +++ b/lib/public/Dashboard/IDashboardWidget.php @@ -27,14 +27,13 @@ declare(strict_types=1); * */ - namespace OCP\Dashboard; -use OCP\Dashboard\Model\WidgetSetup; -use OCP\Dashboard\Model\WidgetTemplate; use OCP\Dashboard\Model\IWidgetConfig; use OCP\Dashboard\Model\IWidgetRequest; +use OCP\Dashboard\Model\WidgetSetup; +use OCP\Dashboard\Model\WidgetTemplate; /** * Interface IDashboardWidget @@ -144,4 +143,3 @@ interface IDashboardWidget { public function requestWidget(IWidgetRequest $request); } - diff --git a/lib/public/Dashboard/Model/IWidgetConfig.php b/lib/public/Dashboard/Model/IWidgetConfig.php index 0ae4cad50a9..b06e97100b4 100644 --- a/lib/public/Dashboard/Model/IWidgetConfig.php +++ b/lib/public/Dashboard/Model/IWidgetConfig.php @@ -126,4 +126,3 @@ interface IWidgetConfig { } - diff --git a/lib/public/Dashboard/Model/IWidgetRequest.php b/lib/public/Dashboard/Model/IWidgetRequest.php index 3a3658b30b2..3df1e2d3693 100644 --- a/lib/public/Dashboard/Model/IWidgetRequest.php +++ b/lib/public/Dashboard/Model/IWidgetRequest.php @@ -32,7 +32,6 @@ namespace OCP\Dashboard\Model; use OCP\Dashboard\IDashboardWidget; - /** * Interface IWidgetRequest * @@ -134,4 +133,3 @@ interface IWidgetRequest { public function addResultArray(string $key, array $result): IWidgetRequest; } - diff --git a/lib/public/Dashboard/Model/WidgetSetting.php b/lib/public/Dashboard/Model/WidgetSetting.php index 616771f7bca..42d2f810bcd 100644 --- a/lib/public/Dashboard/Model/WidgetSetting.php +++ b/lib/public/Dashboard/Model/WidgetSetting.php @@ -32,7 +32,6 @@ namespace OCP\Dashboard\Model; use JsonSerializable; - /** * Interface WidgetSetting * @@ -239,4 +238,3 @@ final class WidgetSetting implements JsonSerializable { } - diff --git a/lib/public/Dashboard/Model/WidgetSetup.php b/lib/public/Dashboard/Model/WidgetSetup.php index 8f0881a3a17..7073bbc922d 100644 --- a/lib/public/Dashboard/Model/WidgetSetup.php +++ b/lib/public/Dashboard/Model/WidgetSetup.php @@ -32,7 +32,6 @@ namespace OCP\Dashboard\Model; use JsonSerializable; - /** * Interface WidgetSetup * @@ -268,4 +267,3 @@ final class WidgetSetup implements JsonSerializable { ]; } } - diff --git a/lib/public/Dashboard/Model/WidgetTemplate.php b/lib/public/Dashboard/Model/WidgetTemplate.php index 485d6298539..c668cfb7e7c 100644 --- a/lib/public/Dashboard/Model/WidgetTemplate.php +++ b/lib/public/Dashboard/Model/WidgetTemplate.php @@ -32,7 +32,6 @@ namespace OCP\Dashboard\Model; use JsonSerializable; - /** * Interface WidgetTemplate * @@ -316,4 +315,3 @@ final class WidgetTemplate implements JsonSerializable { } - diff --git a/lib/public/Dashboard/Service/IEventsService.php b/lib/public/Dashboard/Service/IEventsService.php index 4262e235fd5..6717b804296 100644 --- a/lib/public/Dashboard/Service/IEventsService.php +++ b/lib/public/Dashboard/Service/IEventsService.php @@ -27,7 +27,6 @@ declare(strict_types=1); * */ - namespace OCP\Dashboard\Service; @@ -91,4 +90,3 @@ interface IEventsService { } - diff --git a/lib/public/Dashboard/Service/IWidgetsService.php b/lib/public/Dashboard/Service/IWidgetsService.php index b9a4482b4fc..e2869f7f70c 100644 --- a/lib/public/Dashboard/Service/IWidgetsService.php +++ b/lib/public/Dashboard/Service/IWidgetsService.php @@ -27,7 +27,6 @@ declare(strict_types=1); * */ - namespace OCP\Dashboard\Service; @@ -59,4 +58,3 @@ interface IWidgetsService { public function getWidgetConfig(string $widgetId, string $userId): IWidgetConfig; } - diff --git a/lib/public/Defaults.php b/lib/public/Defaults.php index bf790bb7239..82bf5be3843 100644 --- a/lib/public/Defaults.php +++ b/lib/public/Defaults.php @@ -32,6 +32,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/DirectEditing/ACreateEmpty.php b/lib/public/DirectEditing/ACreateEmpty.php new file mode 100644 index 00000000000..ab7f7fd3ae8 --- /dev/null +++ b/lib/public/DirectEditing/ACreateEmpty.php @@ -0,0 +1,79 @@ +<?php +/** + * @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net> + * + * @author Julius Härtl <jus@bitgrid.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\DirectEditing; + + +use OCP\Files\File; + +/** + * @since 18.0.0 + */ +abstract class ACreateEmpty { + + /** + * Unique id for the creator to filter templates + * + * e.g. document/spreadsheet/presentation + * + * @since 18.0.0 + * @return string + */ + abstract public function getId(): string; + + /** + * Descriptive name for the create action + * + * e.g Create a new document + * + * @since 18.0.0 + * @return string + */ + abstract public function getName(): string; + + /** + * Default file extension for the new file + * + * @since 18.0.0 + * @return string + */ + abstract public function getExtension(): string; + + /** + * Mimetype of the resulting created file + * + * @since 18.0.0 + * @return string + */ + abstract public function getMimetype(): string; + + /** + * Add content when creating empty files + * + * @since 18.0.0 + * @param File $file + */ + public function create(File $file, string $creatorId = null, string $templateId = null): void { + + } +} diff --git a/lib/public/DirectEditing/ACreateFromTemplate.php b/lib/public/DirectEditing/ACreateFromTemplate.php new file mode 100644 index 00000000000..89420a63743 --- /dev/null +++ b/lib/public/DirectEditing/ACreateFromTemplate.php @@ -0,0 +1,39 @@ +<?php +/** + * @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net> + * + * @author Julius Härtl <jus@bitgrid.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\DirectEditing; + +/** + * @since 18.0.0 + */ +abstract class ACreateFromTemplate extends ACreateEmpty { + + /** + * List of available templates for the create from template action + * + * @since 18.0.0 + * @return ATemplate[] + */ + abstract public function getTemplates(): array; + +} diff --git a/lib/public/DirectEditing/ATemplate.php b/lib/public/DirectEditing/ATemplate.php new file mode 100644 index 00000000000..734317eebef --- /dev/null +++ b/lib/public/DirectEditing/ATemplate.php @@ -0,0 +1,71 @@ +<?php +/** + * @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net> + * + * @author Julius Härtl <jus@bitgrid.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\DirectEditing; + +use JsonSerializable; + +/** + * Class ATemplate + * + * @package OCP\DirectEditing + * @since 18.0.0 + */ +abstract class ATemplate implements JsonSerializable { + + /** + * Return a unique id so the app can identify the template + * + * @since 18.0.0 + * @return string + */ + abstract public function getId(): string; + + /** + * Return a title that is displayed to the user + * + * @since 18.0.0 + * @return string + */ + abstract public function getTitle(): string; + + /** + * Return a link to the template preview image + * + * @since 18.0.0 + * @return string + */ + abstract public function getPreview(): string; + + /** + * @since 18.0.0 + * @return array|mixed + */ + public function jsonSerialize() { + return [ + 'id' => $this->getId(), + 'title' => $this->getTitle(), + 'preview' => $this->getPreview(), + ]; + } +} diff --git a/lib/public/DirectEditing/IEditor.php b/lib/public/DirectEditing/IEditor.php new file mode 100644 index 00000000000..a2bc0d74255 --- /dev/null +++ b/lib/public/DirectEditing/IEditor.php @@ -0,0 +1,99 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net> + * + * @author Julius Härtl <jus@bitgrid.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\DirectEditing; + + +use OCP\AppFramework\Http\Response; + +/** + * @since 18.0.0 + */ +interface IEditor { + + /** + * Return a unique identifier for the editor + * + * e.g. richdocuments + * + * @since 18.0.0 + * @return string + */ + public function getId(): string; + + /** + * Return a readable name for the editor + * + * e.g. Collabora Online + * + * @since 18.0.0 + * @return string + */ + public function getName(): string; + + /** + * A list of mimetypes that should open the editor by default + * + * @since 18.0.0 + * @return string[] + */ + public function getMimetypes(): array; + + /** + * A list of mimetypes that can be opened in the editor optionally + * + * @since 18.0.0 + * @return string[] + */ + public function getMimetypesOptional(): array; + + /** + * Return a list of file creation options to be presented to the user + * + * @since 18.0.0 + * @return ACreateFromTemplate[]|ACreateEmpty[] + */ + public function getCreators(): array; + + /** + * Return if the view is able to securely view a file without downloading it to the browser + * + * @since 18.0.0 + * @return bool + */ + public function isSecure(): bool; + + /** + * Return a template response for displaying the editor + * + * open can only be called once when the client requests the editor with a one-time-use token + * For handling editing and later requests, editors need to impelement their own token handling and take care of invalidation + * + * This behavior is similar to the current direct editing implementation in collabora where we generate a one-time token and switch over to the regular wopi token for the actual editing/saving process + * + * @since 18.0.0 + * @return Response + */ + public function open(IToken $token): Response; +} diff --git a/lib/public/DirectEditing/IManager.php b/lib/public/DirectEditing/IManager.php new file mode 100644 index 00000000000..07b9c5a1e4e --- /dev/null +++ b/lib/public/DirectEditing/IManager.php @@ -0,0 +1,88 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net> + * + * @author Julius Härtl <jus@bitgrid.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\DirectEditing; + +use OCP\AppFramework\Http\Response; +use OCP\Files\NotPermittedException; +use RuntimeException; + +/** + * Interface IManager + * + * @package OCP\DirectEditing + * @since 18.0.0 + */ +interface IManager { + + /** + * Register a new editor + * + * @since 18.0.0 + * @param IEditor $directEditor + */ + public function registerDirectEditor(IEditor $directEditor): void; + + /** + * Open the editing page for a provided token + * + * @since 18.0.0 + * @param string $token + * @return Response + */ + public function edit(string $token): Response; + + /** + * Create a new token based on the file path and editor details + * + * @since 18.0.0 + * @param string $path + * @param string $editorId + * @param string $creatorId + * @param null $templateId + * @return string + * @throws NotPermittedException + * @throws RuntimeException + */ + public function create(string $path, string $editorId, string $creatorId, $templateId = null): string; + + /** + * Get the token details for a given token + * + * @since 18.0.0 + * @param string $token + * @return IToken + */ + public function getToken(string $token): IToken; + + /** + * Cleanup expired tokens + * + * @since 18.0.0 + * @return int number of deleted tokens + */ + public function cleanup(): int; + +} + diff --git a/lib/public/DirectEditing/IToken.php b/lib/public/DirectEditing/IToken.php new file mode 100644 index 00000000000..a7eb415e28e --- /dev/null +++ b/lib/public/DirectEditing/IToken.php @@ -0,0 +1,83 @@ +<?php +/** + * @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net> + * + * @author Julius Härtl <jus@bitgrid.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\DirectEditing; + + +use OCP\Files\File; + +/** + * @since 18.0.0 + */ +interface IToken { + + /** + * Extend the token validity time + * + * @since 18.0.0 + */ + public function extend(): void; + + /** + * Invalidate the token + * + * @since 18.0.0 + */ + public function invalidate(): void; + + /** + * Check if the token has already been used + * + * @since 18.0.0 + * @return bool + */ + public function hasBeenAccessed(): bool; + + /** + * Change to the user scope of the token + * + * @since 18.0.0 + */ + public function useTokenScope(): void; + + /** + * Get the file that is related to the token + * + * @since 18.0.0 + * @return File + */ + public function getFile(): File; + + /** + * @since 18.0.0 + * @return string + */ + public function getEditor(): string; + + /** + * @since 18.0.0 + * @return string + */ + public function getUser(): string; + +} diff --git a/lib/public/DirectEditing/RegisterDirectEditorEvent.php b/lib/public/DirectEditing/RegisterDirectEditorEvent.php new file mode 100644 index 00000000000..801e9f8fb1b --- /dev/null +++ b/lib/public/DirectEditing/RegisterDirectEditorEvent.php @@ -0,0 +1,57 @@ +<?php +/** + * @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net> + * + * @author Julius Härtl <jus@bitgrid.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\DirectEditing; + +use OCP\EventDispatcher\Event; + +/** + * @since 18.0.0 + */ +class RegisterDirectEditorEvent extends Event { + + /** + * @var IManager + */ + private $manager; + + /** + * RegisterDirectEditorEvent constructor. + * + * @param IManager $manager + * @since 18.0.0 + */ + public function __construct(IManager $manager) { + parent::__construct(); + $this->manager = $manager; + } + + /** + * @since 18.0.0 + * @param IEditor $editor + */ + public function register(IEditor $editor): void { + $this->manager->registerDirectEditor($editor); + } + +} diff --git a/lib/public/Encryption/IManager.php b/lib/public/Encryption/IManager.php index b32ccf03eb6..89e5525701b 100644 --- a/lib/public/Encryption/IManager.php +++ b/lib/public/Encryption/IManager.php @@ -24,8 +24,8 @@ namespace OCP\Encryption; -use OC\Encryption\Exceptions\ModuleDoesNotExistsException; use OC\Encryption\Exceptions\ModuleAlreadyExistsException; +use OC\Encryption\Exceptions\ModuleDoesNotExistsException; /** * This class provides access to files encryption apps. diff --git a/lib/public/EventDispatcher/ABroadcastedEvent.php b/lib/public/EventDispatcher/ABroadcastedEvent.php new file mode 100644 index 00000000000..1c240b4fb73 --- /dev/null +++ b/lib/public/EventDispatcher/ABroadcastedEvent.php @@ -0,0 +1,71 @@ +<?php declare(strict_types=1); + +/** + * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\EventDispatcher; + +use JsonSerializable; + +/** + * @since 18.0.0 + */ +abstract class ABroadcastedEvent extends Event implements JsonSerializable { + + /** + * @since 18.0.0 + */ + private $broadcasted = false; + + /** + * Get the name of the event, as received on the client-side + * + * Uses the fully qualified event class name by default + * + * @return string + * @since 18.0.0 + */ + public function broadcastAs(): string { + return get_class($this); + } + + /** + * @return string[] + * @since 18.0.0 + */ + abstract public function getUids(): array; + + /** + * @since 18.0.0 + */ + public function setBroadcasted(): void { + $this->broadcasted = true; + } + + /** + * @since 18.0.0 + */ + public function isBroadcasted(): bool { + return $this->broadcasted; + } + +} diff --git a/lib/public/EventDispatcher/Event.php b/lib/public/EventDispatcher/Event.php index 7f8554d7a86..368f352292e 100644 --- a/lib/public/EventDispatcher/Event.php +++ b/lib/public/EventDispatcher/Event.php @@ -25,7 +25,7 @@ declare(strict_types=1); namespace OCP\EventDispatcher; -use Symfony\Component\EventDispatcher\GenericEvent; +use Symfony\Contracts\EventDispatcher\Event as SymfonyEvent; /** * Base event class for the event dispatcher service @@ -35,6 +35,20 @@ use Symfony\Component\EventDispatcher\GenericEvent; * * @since 17.0.0 */ -class Event extends GenericEvent { +class Event extends SymfonyEvent { + + /** + * Compatibility constructor + * + * In Nextcloud 17.0.0 this event class used a now deprecated/removed Symfony base + * class that had a constructor (with default arguments). To lower the risk of + * a breaking change (PHP won't allow parent constructor calls if there is none), + * this empty constructor's only purpose is to hopefully not break existing sub- + * classes of this class. + * + * @since 18.0.0 + */ + public function __construct() { + } } diff --git a/lib/public/EventDispatcher/GenericEvent.php b/lib/public/EventDispatcher/GenericEvent.php new file mode 100644 index 00000000000..4607e6621ae --- /dev/null +++ b/lib/public/EventDispatcher/GenericEvent.php @@ -0,0 +1,169 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\EventDispatcher; + +use ArrayAccess; +use ArrayIterator; +use InvalidArgumentException; +use IteratorAggregate; +use Traversable; +use function array_key_exists; + +/** + * Class GenericEvent + * + * convenience reimplementation of \Symfony\Component\GenericEvent against + * \OCP\EventDispatcher\Event + * + * @package OCP\EventDispatcher + * @since 18.0.0 + */ +class GenericEvent extends Event implements ArrayAccess, IteratorAggregate { + protected $subject; + protected $arguments; + + /** + * Encapsulate an event with $subject and $args. + * + * @since 18.0.0 + */ + public function __construct($subject = null, array $arguments = []) { + $this->subject = $subject; + $this->arguments = $arguments; + } + + /** + * Getter for subject property. + * + * @since 18.0.0 + */ + public function getSubject() { + return $this->subject; + } + + /** + * Get argument by key. + * + * @throws InvalidArgumentException if key is not found + * @since 18.0.0 + */ + public function getArgument(string $key) { + if ($this->hasArgument($key)) { + return $this->arguments[$key]; + } + + throw new InvalidArgumentException(sprintf('Argument "%s" not found.', $key)); + } + + /** + * Add argument to event. + * + * @since 18.0.0 + */ + public function setArgument($key, $value): GenericEvent { + $this->arguments[$key] = $value; + return $this; + } + + /** + * Getter for all arguments. + * + * @since 18.0.0 + */ + public function getArguments(): array { + return $this->arguments; + } + + /** + * Set args property. + * + * @since 18.0.0 + */ + public function setArguments(array $args = []): GenericEvent { + $this->arguments = $args; + return $this; + } + + /** + * Has argument. + * + * @since 18.0.0 + */ + public function hasArgument($key): bool { + return array_key_exists($key, $this->arguments); + } + + /** + * Retrieve an external iterator + * + * @link https://php.net/manual/en/iteratoraggregate.getiterator.php + * @since 18.0.0 + */ + public function getIterator(): Traversable { + return new ArrayIterator($this->arguments); + } + + /** + * Whether a offset exists + * + * @link https://php.net/manual/en/arrayaccess.offsetexists.php + * @since 18.0.0 + */ + public function offsetExists($offset): bool { + return $this->hasArgument($offset); + } + + /** + * Offset to retrieve + * + * @link https://php.net/manual/en/arrayaccess.offsetget.php + * @since 18.0.0 + */ + public function offsetGet($offset) { + return $this->arguments[$offset]; + } + + /** + * Offset to set + * + * @link https://php.net/manual/en/arrayaccess.offsetset.php + * @since 18.0.0 + */ + public function offsetSet($offset, $value): void { + $this->setArgument($offset, $value); + } + + /** + * Offset to unset + * + * @link https://php.net/manual/en/arrayaccess.offsetunset.php + * @since 18.0.0 + */ + public function offsetUnset($offset): void { + if ($this->hasArgument($offset)) { + unset($this->arguments[$offset]); + } + } +} diff --git a/lib/public/EventDispatcher/IEventDispatcher.php b/lib/public/EventDispatcher/IEventDispatcher.php index af4d5316a7b..630b7e3c8a0 100644 --- a/lib/public/EventDispatcher/IEventDispatcher.php +++ b/lib/public/EventDispatcher/IEventDispatcher.php @@ -58,4 +58,16 @@ interface IEventDispatcher { */ public function dispatch(string $eventName, Event $event): void; + /** + * Dispatch a typed event + * + * Only use this with subclasses of ``\OCP\EventDispatcher\Event``. + * The object's class will determine the event name. + * + * @param Event $event + * + * @since 18.0.0 + */ + public function dispatchTyped(Event $event): void; + } diff --git a/lib/public/Federation/ICloudFederationProvider.php b/lib/public/Federation/ICloudFederationProvider.php index b3574535cb0..ef0c7c9bcc3 100644 --- a/lib/public/Federation/ICloudFederationProvider.php +++ b/lib/public/Federation/ICloudFederationProvider.php @@ -25,7 +25,7 @@ use OCP\Federation\Exceptions\ActionNotSupportedException; use OCP\Federation\Exceptions\AuthenticationFailedException; use OCP\Federation\Exceptions\BadRequestException; use OCP\Federation\Exceptions\ProviderCouldNotAddShareException; -use \OCP\Share\Exceptions\ShareNotFound; +use OCP\Share\Exceptions\ShareNotFound; /** * Interface ICloudFederationProvider diff --git a/lib/public/Files.php b/lib/public/Files.php index 1cfd73fb288..e2983a8151d 100644 --- a/lib/public/Files.php +++ b/lib/public/Files.php @@ -38,6 +38,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/Files/AlreadyExistsException.php b/lib/public/Files/AlreadyExistsException.php index af801959247..51baf5f5d4e 100644 --- a/lib/public/Files/AlreadyExistsException.php +++ b/lib/public/Files/AlreadyExistsException.php @@ -28,6 +28,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; /** diff --git a/lib/public/Files/Cache/ICacheEntry.php b/lib/public/Files/Cache/ICacheEntry.php index bbc9982935e..5223720b006 100644 --- a/lib/public/Files/Cache/ICacheEntry.php +++ b/lib/public/Files/Cache/ICacheEntry.php @@ -132,4 +132,28 @@ interface ICacheEntry { * @since 9.0.0 */ public function isEncrypted(); + + /** + * Get the metadata etag for the file + * + * @return string | null + * @since 18.0.0 + */ + public function getMetadataEtag(): ?string; + + /** + * Get the last modified date as unix timestamp + * + * @return int | null + * @since 18.0.0 + */ + public function getCreationTime(): ?int; + + /** + * Get the last modified date as unix timestamp + * + * @return int | null + * @since 18.0.0 + */ + public function getUploadTime(): ?int; } diff --git a/lib/public/Files/Cache/IScanner.php b/lib/public/Files/Cache/IScanner.php index 8aa4dc04aa9..effd4a45667 100644 --- a/lib/public/Files/Cache/IScanner.php +++ b/lib/public/Files/Cache/IScanner.php @@ -81,4 +81,3 @@ interface IScanner { */ public function backgroundScan(); } - diff --git a/lib/public/Files/EntityTooLargeException.php b/lib/public/Files/EntityTooLargeException.php index 4a74403106c..0229f8357b0 100644 --- a/lib/public/Files/EntityTooLargeException.php +++ b/lib/public/Files/EntityTooLargeException.php @@ -28,6 +28,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; /** diff --git a/lib/public/Files/File.php b/lib/public/Files/File.php index 29a83b4df7d..bd3b3da0df2 100644 --- a/lib/public/Files/File.php +++ b/lib/public/Files/File.php @@ -30,8 +30,11 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; +use OCP\Lock\LockedException; + /** * Interface File * @@ -43,7 +46,8 @@ interface File extends Node { * Get the content of the file as string * * @return string - * @throws \OCP\Files\NotPermittedException + * @throws NotPermittedException + * @throws LockedException * @since 6.0.0 */ public function getContent(); @@ -52,8 +56,9 @@ interface File extends Node { * Write to the file from string data * * @param string|resource $data - * @throws \OCP\Files\NotPermittedException - * @throws \OCP\Files\GenericFileException + * @throws NotPermittedException + * @throws GenericFileException + * @throws LockedException * @since 6.0.0 */ public function putContent($data); @@ -71,7 +76,8 @@ interface File extends Node { * * @param string $mode * @return resource - * @throws \OCP\Files\NotPermittedException + * @throws NotPermittedException + * @throws LockedException * @since 6.0.0 */ public function fopen($mode); diff --git a/lib/public/Files/FileInfo.php b/lib/public/Files/FileInfo.php index c256f0980f0..f09896bf93a 100644 --- a/lib/public/Files/FileInfo.php +++ b/lib/public/Files/FileInfo.php @@ -25,6 +25,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\Files; /** @@ -268,4 +269,30 @@ interface FileInfo { * @since 15.0.0 */ public function getExtension(): string; + + /** + * Get the creation date as unix timestamp + * + * If the creation time is not known, 0 will be returned + * + * creation time is not set automatically by the server and is generally only available + * for files uploaded by the sync clients + * + * @return int + * @since 18.0.0 + */ + public function getCreationTime(): int; + + /** + * Get the upload date as unix timestamp + * + * If the upload time is not known, 0 will be returned + * + * Upload time will be set automatically by the server for files uploaded over DAV + * files created by Nextcloud apps generally do not have an the upload time set + * + * @return int + * @since 18.0.0 + */ + public function getUploadTime(): int; } diff --git a/lib/public/Files/FileNameTooLongException.php b/lib/public/Files/FileNameTooLongException.php index 8c46b7f5519..d2302cd66f9 100644 --- a/lib/public/Files/FileNameTooLongException.php +++ b/lib/public/Files/FileNameTooLongException.php @@ -28,6 +28,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; /** diff --git a/lib/public/Files/Folder.php b/lib/public/Files/Folder.php index 425813c7e21..8e45051a118 100644 --- a/lib/public/Files/Folder.php +++ b/lib/public/Files/Folder.php @@ -29,6 +29,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; use OCP\Files\Search\ISearchQuery; diff --git a/lib/public/Files/ForbiddenException.php b/lib/public/Files/ForbiddenException.php index 4432c0d4934..03b0286695b 100644 --- a/lib/public/Files/ForbiddenException.php +++ b/lib/public/Files/ForbiddenException.php @@ -23,6 +23,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; /** diff --git a/lib/public/Files/GenericFileException.php b/lib/public/Files/GenericFileException.php index b5da4aabebd..dcbcd93bab8 100644 --- a/lib/public/Files/GenericFileException.php +++ b/lib/public/Files/GenericFileException.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ + namespace OCP\Files; /** diff --git a/lib/public/Files/IAppData.php b/lib/public/Files/IAppData.php index fd0d0649810..875463c98bf 100644 --- a/lib/public/Files/IAppData.php +++ b/lib/public/Files/IAppData.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ + namespace OCP\Files; use OCP\Files\SimpleFS\ISimpleRoot; diff --git a/lib/public/Files/IHomeStorage.php b/lib/public/Files/IHomeStorage.php index 3144dd8bc94..0d5f351ebad 100644 --- a/lib/public/Files/IHomeStorage.php +++ b/lib/public/Files/IHomeStorage.php @@ -28,6 +28,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; /** diff --git a/lib/public/Files/IMimeTypeDetector.php b/lib/public/Files/IMimeTypeDetector.php index f66eb4e0b9f..318927f2ffa 100644 --- a/lib/public/Files/IMimeTypeDetector.php +++ b/lib/public/Files/IMimeTypeDetector.php @@ -22,6 +22,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; diff --git a/lib/public/Files/IRootFolder.php b/lib/public/Files/IRootFolder.php index b041bcae301..aa5ca5b8dc9 100644 --- a/lib/public/Files/IRootFolder.php +++ b/lib/public/Files/IRootFolder.php @@ -21,7 +21,6 @@ * */ - namespace OCP\Files; use OC\Hooks\Emitter; @@ -43,4 +42,3 @@ interface IRootFolder extends Folder, Emitter { */ public function getUserFolder($userId); } - diff --git a/lib/public/Files/InvalidCharacterInPathException.php b/lib/public/Files/InvalidCharacterInPathException.php index 8e8f1a15e3a..40c51cb2544 100644 --- a/lib/public/Files/InvalidCharacterInPathException.php +++ b/lib/public/Files/InvalidCharacterInPathException.php @@ -28,6 +28,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; /** diff --git a/lib/public/Files/InvalidContentException.php b/lib/public/Files/InvalidContentException.php index bdde7909b58..b8f449b6462 100644 --- a/lib/public/Files/InvalidContentException.php +++ b/lib/public/Files/InvalidContentException.php @@ -28,6 +28,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; /** diff --git a/lib/public/Files/InvalidPathException.php b/lib/public/Files/InvalidPathException.php index bb8aff50913..2f2caa95a62 100644 --- a/lib/public/Files/InvalidPathException.php +++ b/lib/public/Files/InvalidPathException.php @@ -28,6 +28,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; /** diff --git a/lib/public/Files/LockNotAcquiredException.php b/lib/public/Files/LockNotAcquiredException.php index 1ef0e676b34..ece55b6c375 100644 --- a/lib/public/Files/LockNotAcquiredException.php +++ b/lib/public/Files/LockNotAcquiredException.php @@ -29,6 +29,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; /** diff --git a/lib/public/Files/Node.php b/lib/public/Files/Node.php index 016b217afc3..af7d9454ca6 100644 --- a/lib/public/Files/Node.php +++ b/lib/public/Files/Node.php @@ -31,8 +31,11 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; +use OCP\Lock\LockedException; + /** * Interface Node * @@ -44,15 +47,22 @@ interface Node extends FileInfo { * Move the file or folder to a new location * * @param string $targetPath the absolute target path - * @throws \OCP\Files\NotPermittedException - * @return \OCP\Files\Node + * @return Node + * @throws NotFoundException + * @throws NotPermittedException if move not allowed or failed + * @throws LockedException + * @throws InvalidPathException * @since 6.0.0 */ public function move($targetPath); /** * Delete the file or folder + * * @return void + * @throws NotPermittedException + * @throws InvalidPathException + * @throws NotFoundException * @since 6.0.0 */ public function delete(); @@ -61,7 +71,7 @@ interface Node extends FileInfo { * Cope the file or folder to a new location * * @param string $targetPath the absolute target path - * @return \OCP\Files\Node + * @return Node * @since 6.0.0 */ public function copy($targetPath); @@ -71,7 +81,9 @@ interface Node extends FileInfo { * If $mtime is omitted the current time will be used * * @param int $mtime (optional) modified date as unix timestamp - * @throws \OCP\Files\NotPermittedException + * @throws InvalidPathException + * @throws NotFoundException + * @throws NotPermittedException * @return void * @since 6.0.0 */ @@ -80,8 +92,8 @@ interface Node extends FileInfo { /** * Get the storage backend the file or folder is stored on * - * @return \OCP\Files\Storage - * @throws \OCP\Files\NotFoundException + * @return Storage + * @throws NotFoundException * @since 6.0.0 */ public function getStorage(); @@ -246,7 +258,7 @@ interface Node extends FileInfo { * any filesystem operation will automatically acquire the relevant locks for that operation. * * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE - * @throws \OCP\Lock\LockedException + * @throws LockedException * @since 9.1.0 */ public function lock($type); @@ -261,7 +273,7 @@ interface Node extends FileInfo { * Note that this is also the case if no existing lock exists for the file. * * @param int $targetType \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE - * @throws \OCP\Lock\LockedException + * @throws LockedException * @since 9.1.0 */ public function changeLock($targetType); @@ -274,7 +286,7 @@ interface Node extends FileInfo { * Note that this method will not give any sort of error when trying to free a lock that doesn't exist. * * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE - * @throws \OCP\Lock\LockedException + * @throws LockedException * @since 9.1.0 */ public function unlock($type); diff --git a/lib/public/Files/NotEnoughSpaceException.php b/lib/public/Files/NotEnoughSpaceException.php index f4407a95785..f7b4b6c59d4 100644 --- a/lib/public/Files/NotEnoughSpaceException.php +++ b/lib/public/Files/NotEnoughSpaceException.php @@ -28,6 +28,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; /** diff --git a/lib/public/Files/NotFoundException.php b/lib/public/Files/NotFoundException.php index f0ccb90a52b..d285dafd32d 100644 --- a/lib/public/Files/NotFoundException.php +++ b/lib/public/Files/NotFoundException.php @@ -28,6 +28,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; /** diff --git a/lib/public/Files/NotPermittedException.php b/lib/public/Files/NotPermittedException.php index 516c323181b..75f34b787ce 100644 --- a/lib/public/Files/NotPermittedException.php +++ b/lib/public/Files/NotPermittedException.php @@ -28,6 +28,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; /** diff --git a/lib/public/Files/ObjectStore/IObjectStore.php b/lib/public/Files/ObjectStore/IObjectStore.php index 83c4b1065d6..580a92729d9 100644 --- a/lib/public/Files/ObjectStore/IObjectStore.php +++ b/lib/public/Files/ObjectStore/IObjectStore.php @@ -21,6 +21,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\Files\ObjectStore; use OCP\Files\NotFoundException; diff --git a/lib/public/Files/ReservedWordException.php b/lib/public/Files/ReservedWordException.php index 67b205de57b..64f88ca5187 100644 --- a/lib/public/Files/ReservedWordException.php +++ b/lib/public/Files/ReservedWordException.php @@ -28,6 +28,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; /** diff --git a/lib/public/Files/SimpleFS/ISimpleFile.php b/lib/public/Files/SimpleFS/ISimpleFile.php index b00f5c482c6..041e915643e 100644 --- a/lib/public/Files/SimpleFS/ISimpleFile.php +++ b/lib/public/Files/SimpleFS/ISimpleFile.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ + namespace OCP\Files\SimpleFS; use OCP\Files\NotFoundException; diff --git a/lib/public/Files/SimpleFS/ISimpleFolder.php b/lib/public/Files/SimpleFS/ISimpleFolder.php index 54fbd466e46..ab3db007c54 100644 --- a/lib/public/Files/SimpleFS/ISimpleFolder.php +++ b/lib/public/Files/SimpleFS/ISimpleFolder.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ + namespace OCP\Files\SimpleFS; use OCP\Files\NotFoundException; diff --git a/lib/public/Files/SimpleFS/ISimpleRoot.php b/lib/public/Files/SimpleFS/ISimpleRoot.php index 054106fbaca..649f0233b02 100644 --- a/lib/public/Files/SimpleFS/ISimpleRoot.php +++ b/lib/public/Files/SimpleFS/ISimpleRoot.php @@ -21,6 +21,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ + namespace OCP\Files\SimpleFS; use OCP\Files\NotFoundException; diff --git a/lib/public/Files/Storage.php b/lib/public/Files/Storage.php index 1cbba104dee..3fab0877990 100644 --- a/lib/public/Files/Storage.php +++ b/lib/public/Files/Storage.php @@ -35,6 +35,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; use OCP\Files\Storage\IStorage; diff --git a/lib/public/Files/Storage/IDisableEncryptionStorage.php b/lib/public/Files/Storage/IDisableEncryptionStorage.php index 5ec4a2be843..8b62491d39a 100644 --- a/lib/public/Files/Storage/IDisableEncryptionStorage.php +++ b/lib/public/Files/Storage/IDisableEncryptionStorage.php @@ -28,4 +28,4 @@ namespace OCP\Files\Storage; */ interface IDisableEncryptionStorage { -}
\ No newline at end of file +} diff --git a/lib/public/Files/Storage/IStorage.php b/lib/public/Files/Storage/IStorage.php index 1fc45c041c3..1d9fa5363dc 100644 --- a/lib/public/Files/Storage/IStorage.php +++ b/lib/public/Files/Storage/IStorage.php @@ -28,6 +28,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files\Storage; use OCP\Files\Cache\ICache; diff --git a/lib/public/Files/StorageAuthException.php b/lib/public/Files/StorageAuthException.php index 4e216b0f01f..526feebb463 100644 --- a/lib/public/Files/StorageAuthException.php +++ b/lib/public/Files/StorageAuthException.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\Files; /** diff --git a/lib/public/Files/StorageBadConfigException.php b/lib/public/Files/StorageBadConfigException.php index ea525b91f45..6cd3ee06b24 100644 --- a/lib/public/Files/StorageBadConfigException.php +++ b/lib/public/Files/StorageBadConfigException.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\Files; /** diff --git a/lib/public/Files/StorageConnectionException.php b/lib/public/Files/StorageConnectionException.php index 7702460a2f8..be901b60a04 100644 --- a/lib/public/Files/StorageConnectionException.php +++ b/lib/public/Files/StorageConnectionException.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\Files; /** diff --git a/lib/public/Files/StorageInvalidException.php b/lib/public/Files/StorageInvalidException.php index c772a714fcd..7f8d489304e 100644 --- a/lib/public/Files/StorageInvalidException.php +++ b/lib/public/Files/StorageInvalidException.php @@ -28,6 +28,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; /** diff --git a/lib/public/Files/StorageNotAvailableException.php b/lib/public/Files/StorageNotAvailableException.php index 7a060417acb..3cf87331999 100644 --- a/lib/public/Files/StorageNotAvailableException.php +++ b/lib/public/Files/StorageNotAvailableException.php @@ -33,6 +33,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; use OC\HintException; diff --git a/lib/public/Files/StorageTimeoutException.php b/lib/public/Files/StorageTimeoutException.php index 90b56095074..614b04c33f8 100644 --- a/lib/public/Files/StorageTimeoutException.php +++ b/lib/public/Files/StorageTimeoutException.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\Files; /** diff --git a/lib/public/Files/UnseekableException.php b/lib/public/Files/UnseekableException.php index 059a8d55126..5185f0c056f 100644 --- a/lib/public/Files/UnseekableException.php +++ b/lib/public/Files/UnseekableException.php @@ -27,6 +27,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP\Files; /** diff --git a/lib/public/Files_FullTextSearch/Model/AFilesDocument.php b/lib/public/Files_FullTextSearch/Model/AFilesDocument.php index 143788f33ad..d239521da44 100644 --- a/lib/public/Files_FullTextSearch/Model/AFilesDocument.php +++ b/lib/public/Files_FullTextSearch/Model/AFilesDocument.php @@ -27,14 +27,12 @@ declare(strict_types=1); * */ - namespace OCP\Files_FullTextSearch\Model; use OC\FullTextSearch\Model\IndexDocument; use OCP\FullTextSearch\Model\IIndexDocument; - /** * Abstract Class AFilesDocument * @@ -108,4 +106,3 @@ abstract class AFilesDocument extends IndexDocument { abstract public function getPath(): string; } - diff --git a/lib/public/FullTextSearch/Exceptions/FullTextSearchAppNotAvailableException.php b/lib/public/FullTextSearch/Exceptions/FullTextSearchAppNotAvailableException.php index 4363376f0f4..5d533ff467d 100644 --- a/lib/public/FullTextSearch/Exceptions/FullTextSearchAppNotAvailableException.php +++ b/lib/public/FullTextSearch/Exceptions/FullTextSearchAppNotAvailableException.php @@ -27,7 +27,6 @@ declare(strict_types=1); * */ - namespace OCP\FullTextSearch\Exceptions; /** @@ -39,4 +38,3 @@ namespace OCP\FullTextSearch\Exceptions; */ class FullTextSearchAppNotAvailableException extends \Exception { } - diff --git a/lib/public/FullTextSearch/IFullTextSearchManager.php b/lib/public/FullTextSearch/IFullTextSearchManager.php index 3c2aa6324d7..1cc58a78909 100644 --- a/lib/public/FullTextSearch/IFullTextSearchManager.php +++ b/lib/public/FullTextSearch/IFullTextSearchManager.php @@ -27,7 +27,6 @@ declare(strict_types=1); * */ - namespace OCP\FullTextSearch; @@ -37,7 +36,6 @@ use OCP\FullTextSearch\Service\IIndexService; use OCP\FullTextSearch\Service\IProviderService; use OCP\FullTextSearch\Service\ISearchService; - /** * Interface IFullTextSearchManager * @@ -193,4 +191,3 @@ interface IFullTextSearchManager { } - diff --git a/lib/public/FullTextSearch/IFullTextSearchPlatform.php b/lib/public/FullTextSearch/IFullTextSearchPlatform.php index 01016269f6b..0ae355b0eef 100644 --- a/lib/public/FullTextSearch/IFullTextSearchPlatform.php +++ b/lib/public/FullTextSearch/IFullTextSearchPlatform.php @@ -27,7 +27,6 @@ declare(strict_types=1); * */ - namespace OCP\FullTextSearch; @@ -37,7 +36,6 @@ use OCP\FullTextSearch\Model\IIndexDocument; use OCP\FullTextSearch\Model\IRunner; use OCP\FullTextSearch\Model\ISearchResult; - /** * Interface IFullTextSearchPlatform * @@ -224,4 +222,3 @@ interface IFullTextSearchPlatform { } - diff --git a/lib/public/FullTextSearch/IFullTextSearchProvider.php b/lib/public/FullTextSearch/IFullTextSearchProvider.php index b72c9e55435..1405a04420d 100644 --- a/lib/public/FullTextSearch/IFullTextSearchProvider.php +++ b/lib/public/FullTextSearch/IFullTextSearchProvider.php @@ -27,19 +27,17 @@ declare(strict_types=1); * */ - namespace OCP\FullTextSearch; use OCP\FullTextSearch\Model\IIndex; -use OCP\FullTextSearch\Model\IIndexOptions; use OCP\FullTextSearch\Model\IIndexDocument; +use OCP\FullTextSearch\Model\IIndexOptions; use OCP\FullTextSearch\Model\IRunner; use OCP\FullTextSearch\Model\ISearchRequest; use OCP\FullTextSearch\Model\ISearchResult; use OCP\FullTextSearch\Model\ISearchTemplate; - /** * Interface IFullTextSearchProvider * diff --git a/lib/public/FullTextSearch/Model/IDocumentAccess.php b/lib/public/FullTextSearch/Model/IDocumentAccess.php index 848e2200f60..bbd1e47411b 100644 --- a/lib/public/FullTextSearch/Model/IDocumentAccess.php +++ b/lib/public/FullTextSearch/Model/IDocumentAccess.php @@ -27,7 +27,6 @@ declare(strict_types=1); * */ - namespace OCP\FullTextSearch\Model; @@ -261,4 +260,3 @@ interface IDocumentAccess { public function getLinks(): array; } - diff --git a/lib/public/FullTextSearch/Model/IIndex.php b/lib/public/FullTextSearch/Model/IIndex.php index c1c83db2d4b..fd7a887ca46 100644 --- a/lib/public/FullTextSearch/Model/IIndex.php +++ b/lib/public/FullTextSearch/Model/IIndex.php @@ -27,7 +27,6 @@ declare(strict_types=1); * */ - namespace OCP\FullTextSearch\Model; @@ -289,4 +288,3 @@ interface IIndex { } - diff --git a/lib/public/FullTextSearch/Model/IIndexDocument.php b/lib/public/FullTextSearch/Model/IIndexDocument.php index d3184530a7f..3effb2c1afc 100644 --- a/lib/public/FullTextSearch/Model/IIndexDocument.php +++ b/lib/public/FullTextSearch/Model/IIndexDocument.php @@ -27,7 +27,6 @@ declare(strict_types=1); * */ - namespace OCP\FullTextSearch\Model; @@ -633,4 +632,3 @@ interface IIndexDocument { public function getInfoAll(): array; } - diff --git a/lib/public/FullTextSearch/Model/IIndexOptions.php b/lib/public/FullTextSearch/Model/IIndexOptions.php index 8cc5da13d4d..81087101544 100644 --- a/lib/public/FullTextSearch/Model/IIndexOptions.php +++ b/lib/public/FullTextSearch/Model/IIndexOptions.php @@ -27,7 +27,6 @@ declare(strict_types=1); * */ - namespace OCP\FullTextSearch\Model; @@ -83,4 +82,3 @@ interface IIndexOptions { public function getOptionBool(string $option, bool $default): bool; } - diff --git a/lib/public/FullTextSearch/Model/IRunner.php b/lib/public/FullTextSearch/Model/IRunner.php index 0dff82bd5a0..21867be4d59 100644 --- a/lib/public/FullTextSearch/Model/IRunner.php +++ b/lib/public/FullTextSearch/Model/IRunner.php @@ -27,7 +27,6 @@ declare(strict_types=1); * */ - namespace OCP\FullTextSearch\Model; @@ -139,4 +138,3 @@ interface IRunner { } - diff --git a/lib/public/FullTextSearch/Model/ISearchOption.php b/lib/public/FullTextSearch/Model/ISearchOption.php index 4ac995ad75f..e8f031e89cb 100644 --- a/lib/public/FullTextSearch/Model/ISearchOption.php +++ b/lib/public/FullTextSearch/Model/ISearchOption.php @@ -27,7 +27,6 @@ declare(strict_types=1); * */ - namespace OCP\FullTextSearch\Model; diff --git a/lib/public/FullTextSearch/Model/ISearchRequest.php b/lib/public/FullTextSearch/Model/ISearchRequest.php index 6874cf161b6..a8117789154 100644 --- a/lib/public/FullTextSearch/Model/ISearchRequest.php +++ b/lib/public/FullTextSearch/Model/ISearchRequest.php @@ -27,7 +27,6 @@ declare(strict_types=1); * */ - namespace OCP\FullTextSearch\Model; @@ -365,4 +364,3 @@ interface ISearchRequest { public function getSimpleQueries(): array; } - diff --git a/lib/public/FullTextSearch/Model/ISearchRequestSimpleQuery.php b/lib/public/FullTextSearch/Model/ISearchRequestSimpleQuery.php index 08884e25c2b..e040d5c8d4a 100644 --- a/lib/public/FullTextSearch/Model/ISearchRequestSimpleQuery.php +++ b/lib/public/FullTextSearch/Model/ISearchRequestSimpleQuery.php @@ -27,7 +27,6 @@ declare(strict_types=1); * */ - namespace OCP\FullTextSearch\Model; @@ -136,4 +135,3 @@ interface ISearchRequestSimpleQuery { public function addValueBool(bool $value): ISearchRequestSimpleQuery; } - diff --git a/lib/public/FullTextSearch/Model/ISearchResult.php b/lib/public/FullTextSearch/Model/ISearchResult.php index 2ca61c2f37b..53fbaf9bf74 100644 --- a/lib/public/FullTextSearch/Model/ISearchResult.php +++ b/lib/public/FullTextSearch/Model/ISearchResult.php @@ -27,13 +27,11 @@ declare(strict_types=1); * */ - namespace OCP\FullTextSearch\Model; use OCP\FullTextSearch\IFullTextSearchProvider; - /** * Interface ISearchResult * @@ -195,4 +193,3 @@ interface ISearchResult { public function setTimedOut(bool $timedOut): ISearchResult; } - diff --git a/lib/public/FullTextSearch/Model/ISearchTemplate.php b/lib/public/FullTextSearch/Model/ISearchTemplate.php index 9cd6753f2a7..6abeaca581b 100644 --- a/lib/public/FullTextSearch/Model/ISearchTemplate.php +++ b/lib/public/FullTextSearch/Model/ISearchTemplate.php @@ -27,13 +27,11 @@ declare(strict_types=1); * */ - namespace OCP\FullTextSearch\Model; use OCP\FullTextSearch\IFullTextSearchProvider; - /** * Class ISearchTemplate * @@ -176,4 +174,3 @@ interface ISearchTemplate { public function getNavigationOptions(): array; } - diff --git a/lib/public/FullTextSearch/Service/IIndexService.php b/lib/public/FullTextSearch/Service/IIndexService.php index b70c7eb965f..abc0fcb6faa 100644 --- a/lib/public/FullTextSearch/Service/IIndexService.php +++ b/lib/public/FullTextSearch/Service/IIndexService.php @@ -27,13 +27,11 @@ declare(strict_types=1); * */ - namespace OCP\FullTextSearch\Service; use OCP\FullTextSearch\Model\IIndex; - /** * Interface IIndexService * @@ -110,4 +108,3 @@ interface IIndexService { public function updateIndexes(array $indexes); } - diff --git a/lib/public/FullTextSearch/Service/IProviderService.php b/lib/public/FullTextSearch/Service/IProviderService.php index 64153c13965..26ce5d0c56f 100644 --- a/lib/public/FullTextSearch/Service/IProviderService.php +++ b/lib/public/FullTextSearch/Service/IProviderService.php @@ -27,7 +27,6 @@ declare(strict_types=1); * */ - namespace OCP\FullTextSearch\Service; @@ -62,4 +61,3 @@ interface IProviderService { } - diff --git a/lib/public/FullTextSearch/Service/ISearchService.php b/lib/public/FullTextSearch/Service/ISearchService.php index 7da38e44f5c..ac0d252f426 100644 --- a/lib/public/FullTextSearch/Service/ISearchService.php +++ b/lib/public/FullTextSearch/Service/ISearchService.php @@ -27,14 +27,12 @@ declare(strict_types=1); * */ - namespace OCP\FullTextSearch\Service; use OCP\FullTextSearch\Model\ISearchRequest; use OCP\FullTextSearch\Model\ISearchResult; - /** * Interface ISearchService * @@ -86,4 +84,3 @@ interface ISearchService { public function search(string $userId, ISearchRequest $searchRequest): array; } - diff --git a/lib/public/GlobalScale/IConfig.php b/lib/public/GlobalScale/IConfig.php index e67470f2e1a..ef6c22ebd8e 100644 --- a/lib/public/GlobalScale/IConfig.php +++ b/lib/public/GlobalScale/IConfig.php @@ -21,7 +21,6 @@ * */ - namespace OCP\GlobalScale; /** diff --git a/lib/public/Group/Backend/IGetDisplayNameBackend.php b/lib/public/Group/Backend/IGetDisplayNameBackend.php index 69d1742a1e5..2d750b83855 100644 --- a/lib/public/Group/Backend/IGetDisplayNameBackend.php +++ b/lib/public/Group/Backend/IGetDisplayNameBackend.php @@ -28,7 +28,10 @@ namespace OCP\Group\Backend; * @since 17.0.0 */ interface IGetDisplayNameBackend { + /** + * @param string $gid + * @return string * @since 17.0.0 */ public function getDisplayName(string $gid): string; diff --git a/lib/public/Group/Backend/ISetDisplayNameBackend.php b/lib/public/Group/Backend/ISetDisplayNameBackend.php new file mode 100644 index 00000000000..f75be69438d --- /dev/null +++ b/lib/public/Group/Backend/ISetDisplayNameBackend.php @@ -0,0 +1,38 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Group\Backend; + +/** + * @since 18.0.0 + */ +interface ISetDisplayNameBackend { + + /** + * @param string $gid + * @param string $displayName + * @return bool + * @since 18.0.0 + */ + public function setDisplayName(string $gid, string $displayName): bool; + +} diff --git a/lib/public/GroupInterface.php b/lib/public/GroupInterface.php index 35d11755fac..2c67aafdba5 100644 --- a/lib/public/GroupInterface.php +++ b/lib/public/GroupInterface.php @@ -32,6 +32,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/IAddressBook.php b/lib/public/IAddressBook.php index 8d86773e771..77fc7b6567b 100644 --- a/lib/public/IAddressBook.php +++ b/lib/public/IAddressBook.php @@ -30,6 +30,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP { /** * Interface IAddressBook diff --git a/lib/public/IAppConfig.php b/lib/public/IAppConfig.php index 2f268185e62..aae8bce025c 100644 --- a/lib/public/IAppConfig.php +++ b/lib/public/IAppConfig.php @@ -23,6 +23,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP; /** diff --git a/lib/public/ICache.php b/lib/public/ICache.php index ba61100925b..5aa6dc9fc87 100644 --- a/lib/public/ICache.php +++ b/lib/public/ICache.php @@ -31,6 +31,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/IConfig.php b/lib/public/IConfig.php index 878c0acf0c3..95c72bb1fc8 100644 --- a/lib/public/IConfig.php +++ b/lib/public/IConfig.php @@ -34,6 +34,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/IContainer.php b/lib/public/IContainer.php index 558c72291c5..b9afa2f1d87 100644 --- a/lib/public/IContainer.php +++ b/lib/public/IContainer.php @@ -31,12 +31,12 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; use Closure; use OCP\AppFramework\QueryException; - /** * Class IContainer * diff --git a/lib/public/IDBConnection.php b/lib/public/IDBConnection.php index 4c66896a2fe..da89d5bb842 100644 --- a/lib/public/IDBConnection.php +++ b/lib/public/IDBConnection.php @@ -34,6 +34,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; use Doctrine\DBAL\Schema\Schema; use OCP\DB\QueryBuilder\IQueryBuilder; diff --git a/lib/public/IGroup.php b/lib/public/IGroup.php index 48fa84df393..8b0eaf0ec0c 100644 --- a/lib/public/IGroup.php +++ b/lib/public/IGroup.php @@ -48,6 +48,15 @@ interface IGroup { public function getDisplayName(); /** + * Set the group display name + * + * @param string $displayName + * @return bool + * @since 18.0.0 + */ + public function setDisplayName(string $displayName): bool; + + /** * get all users in the group * * @return \OCP\IUser[] diff --git a/lib/public/IGroupManager.php b/lib/public/IGroupManager.php index f7a63dfefb7..d8a557777bc 100644 --- a/lib/public/IGroupManager.php +++ b/lib/public/IGroupManager.php @@ -75,7 +75,7 @@ interface IGroupManager { /** * @param string $gid - * @return \OCP\IGroup + * @return \OCP\IGroup|null * @since 8.0.0 */ public function get($gid); @@ -89,7 +89,7 @@ interface IGroupManager { /** * @param string $gid - * @return \OCP\IGroup + * @return \OCP\IGroup|null * @since 8.0.0 */ public function createGroup($gid); diff --git a/lib/public/IL10N.php b/lib/public/IL10N.php index 53decd78051..f7baa10b5e9 100644 --- a/lib/public/IL10N.php +++ b/lib/public/IL10N.php @@ -34,6 +34,7 @@ declare(strict_types=1); // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/IMemcache.php b/lib/public/IMemcache.php index 8f182553b67..19d89b86832 100644 --- a/lib/public/IMemcache.php +++ b/lib/public/IMemcache.php @@ -29,6 +29,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/INavigationManager.php b/lib/public/INavigationManager.php index f840bc8c8a5..68969d0c3f7 100644 --- a/lib/public/INavigationManager.php +++ b/lib/public/INavigationManager.php @@ -32,6 +32,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/IPreview.php b/lib/public/IPreview.php index ba32300a284..08a428ebeb1 100644 --- a/lib/public/IPreview.php +++ b/lib/public/IPreview.php @@ -32,11 +32,12 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; use OCP\Files\File; -use OCP\Files\SimpleFS\ISimpleFile; use OCP\Files\NotFoundException; +use OCP\Files\SimpleFS\ISimpleFile; /** * This class provides functions to render and show thumbnails and previews of files @@ -80,18 +81,6 @@ interface IPreview { public function hasProviders(); /** - * Return a preview of a file - * @param string $file The path to the file where you want a thumbnail from - * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image - * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image - * @param boolean $scaleUp Scale smaller images up to the thumbnail size or not. Might look ugly - * @return \OCP\IImage - * @since 6.0.0 - * @deprecated 11 Use getPreview - */ - public function createPreview($file, $maxX = 100, $maxY = 75, $scaleUp = false); - - /** * Returns a preview of a file * * The cache is searched first and if nothing usable was found then a preview is diff --git a/lib/public/IRequest.php b/lib/public/IRequest.php index 05948cd480f..f61c1da0885 100644 --- a/lib/public/IRequest.php +++ b/lib/public/IRequest.php @@ -36,6 +36,7 @@ declare(strict_types=1); // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/IServerContainer.php b/lib/public/IServerContainer.php index bcdb6e6c9f5..79d4ed9f71b 100644 --- a/lib/public/IServerContainer.php +++ b/lib/public/IServerContainer.php @@ -43,14 +43,14 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; -use OCP\Log\ILogFactory; use OCP\Federation\ICloudFederationFactory; use OCP\Federation\ICloudFederationProviderManager; +use OCP\Log\ILogFactory; use OCP\Security\IContentSecurityPolicyManager; use Symfony\Component\EventDispatcher\EventDispatcherInterface; - /** * Class IServerContainer * @package OCP diff --git a/lib/public/ISession.php b/lib/public/ISession.php index bbf36c86520..3d2f32f7f75 100644 --- a/lib/public/ISession.php +++ b/lib/public/ISession.php @@ -33,6 +33,7 @@ declare(strict_types=1); // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; use OCP\Session\Exceptions\SessionNotAvailableException; diff --git a/lib/public/ITagManager.php b/lib/public/ITagManager.php index 60d547e44ad..b0c9f0d7d90 100644 --- a/lib/public/ITagManager.php +++ b/lib/public/ITagManager.php @@ -31,6 +31,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/ITags.php b/lib/public/ITags.php index fce47bb5bc7..c39117e924f 100644 --- a/lib/public/ITags.php +++ b/lib/public/ITags.php @@ -31,6 +31,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; use OC\Tags; diff --git a/lib/public/IUserBackend.php b/lib/public/IUserBackend.php index 502856fc354..41123e8b7ae 100644 --- a/lib/public/IUserBackend.php +++ b/lib/public/IUserBackend.php @@ -28,6 +28,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/IUserSession.php b/lib/public/IUserSession.php index d7bf5f9a385..48fe135f28e 100644 --- a/lib/public/IUserSession.php +++ b/lib/public/IUserSession.php @@ -33,6 +33,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** @@ -42,6 +43,7 @@ namespace OCP; interface IUserSession { /** * Do a user login + * * @param string $user the username * @param string $password the password * @return bool true if successful @@ -52,6 +54,7 @@ interface IUserSession { /** * Logs the user out including all the session data * Logout, destroys session + * * @return void * @since 6.0.0 */ @@ -80,4 +83,19 @@ interface IUserSession { * @since 8.0.0 */ public function isLoggedIn(); + + /** + * get getImpersonatingUserID + * + * @return string|null + * @since 18.0.0 + */ + public function getImpersonatingUserID(): ?string; + + /** + * set setImpersonatingUserID + * + * @since 18.0.0 + */ + public function setImpersonatingUserID(bool $useCurrentUser = true): void; } diff --git a/lib/public/Image.php b/lib/public/Image.php index d583dffe91d..55060f3da48 100644 --- a/lib/public/Image.php +++ b/lib/public/Image.php @@ -30,6 +30,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/L10N/IFactory.php b/lib/public/L10N/IFactory.php index de904d0eec1..04548046f55 100644 --- a/lib/public/L10N/IFactory.php +++ b/lib/public/L10N/IFactory.php @@ -19,6 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\L10N; use OCP\IUser; diff --git a/lib/public/Migration/IOutput.php b/lib/public/Migration/IOutput.php index 7c6b12ceaf4..8d3ea7cb669 100644 --- a/lib/public/Migration/IOutput.php +++ b/lib/public/Migration/IOutput.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\Migration; /** diff --git a/lib/public/Migration/IRepairStep.php b/lib/public/Migration/IRepairStep.php index 0ba834e2cbf..1a39531bcde 100644 --- a/lib/public/Migration/IRepairStep.php +++ b/lib/public/Migration/IRepairStep.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\Migration; /** diff --git a/lib/public/OCS/IDiscoveryService.php b/lib/public/OCS/IDiscoveryService.php index ad1499e75fd..f294cffe94f 100644 --- a/lib/public/OCS/IDiscoveryService.php +++ b/lib/public/OCS/IDiscoveryService.php @@ -22,7 +22,6 @@ declare(strict_types=1); * */ - namespace OCP\OCS; /** diff --git a/lib/public/PreConditionNotMetException.php b/lib/public/PreConditionNotMetException.php index ea6350afb4d..cbf0ec2f9b7 100644 --- a/lib/public/PreConditionNotMetException.php +++ b/lib/public/PreConditionNotMetException.php @@ -22,6 +22,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/Preview/IProvider.php b/lib/public/Preview/IProvider.php index 5d62b3ce6d0..6642b7e26c6 100644 --- a/lib/public/Preview/IProvider.php +++ b/lib/public/Preview/IProvider.php @@ -20,6 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\Preview; /** diff --git a/lib/public/RichObjectStrings/Definitions.php b/lib/public/RichObjectStrings/Definitions.php index 69cabe638ad..55c31607659 100644 --- a/lib/public/RichObjectStrings/Definitions.php +++ b/lib/public/RichObjectStrings/Definitions.php @@ -268,6 +268,25 @@ class Definitions { ], ], ], + 'guest' => [ + 'author' => 'Nextcloud', + 'app' => 'spreed', + 'since' => '17.0.0', + 'parameters' => [ + 'id' => [ + 'since' => '17.0.0', + 'required' => true, + 'description' => 'The id used to identify the guest user', + 'example' => '42', + ], + 'name' => [ + 'since' => '17.0.0', + 'required' => true, + 'description' => 'Potential displayname of the guest user', + 'example' => 'Foobar Cats', + ], + ], + ], 'highlight' => [ 'author' => 'Nextcloud', 'app' => 'core', @@ -386,6 +405,43 @@ class Definitions { ], ], ], + 'talk-attachment' => [ + 'author' => 'Nextcloud', + 'app' => 'talk', + 'since' => '18.0.0', + 'parameters' => [ + 'id' => [ + 'since' => '18.0.0', + 'required' => true, + 'description' => 'The id used to identify the attachment on the instance', + 'example' => '12345', + ], + 'name' => [ + 'since' => '18.0.0', + 'required' => true, + 'description' => 'The name of the attachment', + 'example' => 'John Doe', + ], + 'conversation' => [ + 'since' => '18.0.0', + 'required' => true, + 'description' => 'The token of the conversation', + 'example' => 'a1b2c3d4', + ], + 'mimetype' => [ + 'since' => '18.0.0', + 'required' => false, + 'description' => 'The mimetype of the file/folder to allow clients to show a placeholder', + 'example' => 'text/plain', + ], + 'preview-available' => [ + 'since' => '18.0.0', + 'required' => false, + 'description' => 'Whether or not a preview is available. If `no` the mimetype icon should be used', + 'example' => 'yes', + ], + ], + ], 'user' => [ 'author' => 'Nextcloud', 'app' => 'core', diff --git a/lib/public/Route/IRoute.php b/lib/public/Route/IRoute.php index 9b8218085ad..40566413508 100644 --- a/lib/public/Route/IRoute.php +++ b/lib/public/Route/IRoute.php @@ -22,6 +22,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\Route; /** diff --git a/lib/public/SabrePluginEvent.php b/lib/public/SabrePluginEvent.php index d75c84965f6..165cccc22d2 100644 --- a/lib/public/SabrePluginEvent.php +++ b/lib/public/SabrePluginEvent.php @@ -25,8 +25,8 @@ namespace OCP; use OCP\AppFramework\Http; +use OCP\EventDispatcher\Event; use Sabre\DAV\Server; -use Symfony\Component\EventDispatcher\Event; /** * @since 8.2.0 diff --git a/lib/public/Security/CSP/AddContentSecurityPolicyEvent.php b/lib/public/Security/CSP/AddContentSecurityPolicyEvent.php index 9bf1d57e77e..9c48f4038d8 100644 --- a/lib/public/Security/CSP/AddContentSecurityPolicyEvent.php +++ b/lib/public/Security/CSP/AddContentSecurityPolicyEvent.php @@ -40,6 +40,7 @@ class AddContentSecurityPolicyEvent extends Event { * @since 17.0.0 */ public function __construct(ContentSecurityPolicyManager $policyManager) { + parent::__construct(); $this->policyManager = $policyManager; } diff --git a/lib/public/Security/Events/GenerateSecurePasswordEvent.php b/lib/public/Security/Events/GenerateSecurePasswordEvent.php new file mode 100644 index 00000000000..a55c8daafbd --- /dev/null +++ b/lib/public/Security/Events/GenerateSecurePasswordEvent.php @@ -0,0 +1,50 @@ +<?php declare(strict_types=1); + +/** + * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace OCP\Security\Events; + +use OCP\EventDispatcher\Event; + +/** + * @since 18.0.0 + */ +class GenerateSecurePasswordEvent extends Event { + + /** @var null|string */ + private $password; + + /** + * @since 18.0.0 + */ + public function getPassword(): ?string { + return $this->password; + } + + /** + * @since 18.0.0 + */ + public function setPassword(string $password): void { + $this->password = $password; + } + +} diff --git a/lib/public/Security/Events/ValidatePasswordPolicyEvent.php b/lib/public/Security/Events/ValidatePasswordPolicyEvent.php new file mode 100644 index 00000000000..11378526cc7 --- /dev/null +++ b/lib/public/Security/Events/ValidatePasswordPolicyEvent.php @@ -0,0 +1,51 @@ +<?php declare(strict_types=1); + +/** + * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace OCP\Security\Events; + +use OCP\EventDispatcher\Event; + +/** + * @since 18.0.0 + */ +class ValidatePasswordPolicyEvent extends Event { + + /** @var string */ + private $password; + + /** + * @since 18.0.0 + */ + public function __construct(string $password) { + parent::__construct(); + $this->password = $password; + } + + /** + * @since 18.0.0 + */ + public function getPassword(): string { + return $this->password; + } + +} diff --git a/lib/public/Security/FeaturePolicy/AddFeaturePolicyEvent.php b/lib/public/Security/FeaturePolicy/AddFeaturePolicyEvent.php index ab93844c3f8..e840f910769 100644 --- a/lib/public/Security/FeaturePolicy/AddFeaturePolicyEvent.php +++ b/lib/public/Security/FeaturePolicy/AddFeaturePolicyEvent.php @@ -40,6 +40,7 @@ class AddFeaturePolicyEvent extends Event { * @since 17.0.0 */ public function __construct(FeaturePolicyManager $policyManager) { + parent::__construct(); $this->policyManager = $policyManager; } diff --git a/lib/public/Share.php b/lib/public/Share.php index f433a35f17a..10c7324d903 100644 --- a/lib/public/Share.php +++ b/lib/public/Share.php @@ -34,6 +34,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/Share/Exceptions/GenericShareException.php b/lib/public/Share/Exceptions/GenericShareException.php index ef5586a362f..7ccac2fb2db 100644 --- a/lib/public/Share/Exceptions/GenericShareException.php +++ b/lib/public/Share/Exceptions/GenericShareException.php @@ -21,6 +21,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\Share\Exceptions; use OC\HintException; diff --git a/lib/public/Share/Exceptions/IllegalIDChangeException.php b/lib/public/Share/Exceptions/IllegalIDChangeException.php index 46cbe5fbf9f..fd5ef0dc2cd 100644 --- a/lib/public/Share/Exceptions/IllegalIDChangeException.php +++ b/lib/public/Share/Exceptions/IllegalIDChangeException.php @@ -19,6 +19,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\Share\Exceptions; /** diff --git a/lib/public/Share/IManager.php b/lib/public/Share/IManager.php index 302be523327..3127c74be5e 100644 --- a/lib/public/Share/IManager.php +++ b/lib/public/Share/IManager.php @@ -54,6 +54,7 @@ interface IManager { * Update a share. * The target of the share can't be changed this way: use moveShare * The share can't be removed this way (permission 0): use deleteShare + * The state can't be changed this way: use acceptShare * * @param IShare $share * @return IShare The share object @@ -63,6 +64,17 @@ interface IManager { public function updateShare(IShare $share); /** + * Accept a share. + * + * @param IShare $share + * @param string $recipientId + * @return IShare The share object + * @throws \InvalidArgumentException + * @since 18.0.0 + */ + public function acceptShare(IShare $share, string $recipientId): IShare; + + /** * Delete a share * * @param IShare $share @@ -385,4 +397,16 @@ interface IManager { */ public function shareProviderExists($shareType); + /** + * @Internal + * + * Get all the shares as iterable to reduce memory overhead + * Note, since this opens up database cursors the iterable should + * be fully itterated. + * + * @return iterable + * @since 18.0.0 + */ + public function getAllShares(): iterable; + } diff --git a/lib/public/Share/IProviderFactory.php b/lib/public/Share/IProviderFactory.php index ad43b64229d..8d14b78f462 100644 --- a/lib/public/Share/IProviderFactory.php +++ b/lib/public/Share/IProviderFactory.php @@ -35,13 +35,6 @@ use OCP\IServerContainer; interface IProviderFactory { /** - * IProviderFactory constructor. - * @param IServerContainer $serverContainer - * @since 9.0.0 - */ - public function __construct(IServerContainer $serverContainer); - - /** * @param string $id * @return IShareProvider * @throws ProviderException diff --git a/lib/public/Share/IShare.php b/lib/public/Share/IShare.php index 7bcecbdc872..1064f59e6d5 100644 --- a/lib/public/Share/IShare.php +++ b/lib/public/Share/IShare.php @@ -40,6 +40,84 @@ use OCP\Share\Exceptions\IllegalIDChangeException; interface IShare { /** + * @since 17.0.0 + */ + public const TYPE_USER = 0; + + /** + * @since 17.0.0 + */ + public const TYPE_GROUP = 1; + + /** + * @internal + * @since 18.0.0 + */ + public const TYPE_USERGROUP = 2; + + /** + * @since 17.0.0 + */ + public const TYPE_LINK = 3; + + /** + * @since 17.0.0 + */ + public const TYPE_EMAIL = 4; + + /** + * ToDo Check if it is still in use otherwise remove it + * @since 17.0.0 + */ + // public const TYPE_CONTACT = 5; + + /** + * @since 17.0.0 + */ + public const TYPE_REMOTE = 6; + + /** + * @since 17.0.0 + */ + public const TYPE_CIRCLE = 7; + + /** + * @since 17.0.0 + */ + public const TYPE_GUEST = 8; + + /** + * @since 17.0.0 + */ + public const TYPE_REMOTE_GROUP = 9; + + /** + * @since 17.0.0 + */ + public const TYPE_ROOM = 10; + + /** + * Internal type used by RoomShareProvider + * @since 17.0.0 + */ + // const TYPE_USERROOM = 11; + + /** + * @since 18.0.0 + */ + public const STATUS_PENDING = 0; + + /** + * @since 18.0.0 + */ + public const STATUS_ACCEPTED = 1; + + /** + * @since 18.0.0 + */ + public const STATUS_REJECTED = 2; + + /** * Set the internal id of the share * It is only allowed to set the internal id of a share once. * Attempts to override the internal id will result in an IllegalIDChangeException @@ -223,6 +301,25 @@ interface IShare { public function getPermissions(); /** + * Set the accepted status + * See self::STATUS_* + * + * @param int $status + * @return IShare The modified object + * @since 18.0.0 + */ + public function setStatus(int $status): IShare; + + /** + * Get the accepted status + * See self::STATUS_* + * + * @return int + * @since 18.0.0 + */ + public function getStatus(): int; + + /** * Attach a note to a share * * @param string $note @@ -258,6 +355,14 @@ interface IShare { public function getExpirationDate(); /** + * Is the share expired ? + * + * @return boolean + * @since 18.0.0 + */ + public function isExpired(); + + /** * set a label for a share, some shares, e.g. public links can have a label * * @param string $label diff --git a/lib/public/Share/IShareHelper.php b/lib/public/Share/IShareHelper.php index c957a815e89..db9f2adbacd 100644 --- a/lib/public/Share/IShareHelper.php +++ b/lib/public/Share/IShareHelper.php @@ -21,6 +21,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ + namespace OCP\Share; use OCP\Files\Node; diff --git a/lib/public/Share/IShareProvider.php b/lib/public/Share/IShareProvider.php index 6731bf8882b..891e8bf1bb8 100644 --- a/lib/public/Share/IShareProvider.php +++ b/lib/public/Share/IShareProvider.php @@ -25,9 +25,9 @@ namespace OCP\Share; use OCP\Files\Folder; +use OCP\Files\Node; use OCP\Share\Exceptions\GenericShareException; use OCP\Share\Exceptions\ShareNotFound; -use OCP\Files\Node; /** * Interface IShareProvider @@ -64,6 +64,16 @@ interface IShareProvider { public function update(\OCP\Share\IShare $share); /** + * Accept a share. + * + * @param IShare $share + * @param string $recipient + * @return IShare The share object + * @since 17.0.0 + */ +// public function acceptShare(IShare $share, string $recipient): IShare; + + /** * Delete a share * * @param \OCP\Share\IShare $share @@ -217,4 +227,13 @@ interface IShareProvider { * @since 12 */ public function getAccessList($nodes, $currentAccess); + + /** + * Get all the shares in this provider returned as iterable to reduce memory + * overhead + * + * @return iterable + * @since 18.0.0 + */ + public function getAllShares(): iterable; } diff --git a/lib/public/Share_Backend.php b/lib/public/Share_Backend.php index 7ebad8b64d3..4aa55844027 100644 --- a/lib/public/Share_Backend.php +++ b/lib/public/Share_Backend.php @@ -25,6 +25,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/Share_Backend_Collection.php b/lib/public/Share_Backend_Collection.php index 0c87a58ce95..d5bb97a1c0c 100644 --- a/lib/public/Share_Backend_Collection.php +++ b/lib/public/Share_Backend_Collection.php @@ -23,6 +23,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/Share_Backend_File_Dependent.php b/lib/public/Share_Backend_File_Dependent.php index a7f866dd7d0..3ff8c86a6c7 100644 --- a/lib/public/Share_Backend_File_Dependent.php +++ b/lib/public/Share_Backend_File_Dependent.php @@ -23,6 +23,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/SystemTag/ISystemTag.php b/lib/public/SystemTag/ISystemTag.php index da434e8b5a0..8fa959fcc4d 100644 --- a/lib/public/SystemTag/ISystemTag.php +++ b/lib/public/SystemTag/ISystemTag.php @@ -67,4 +67,3 @@ interface ISystemTag { public function isUserAssignable(): bool; } - diff --git a/lib/public/SystemTag/ISystemTagManagerFactory.php b/lib/public/SystemTag/ISystemTagManagerFactory.php index 25956b41df4..5458cab8340 100644 --- a/lib/public/SystemTag/ISystemTagManagerFactory.php +++ b/lib/public/SystemTag/ISystemTagManagerFactory.php @@ -20,6 +20,7 @@ declare(strict_types=1); * along with this program. If not, see <http://www.gnu.org/licenses/> * */ + namespace OCP\SystemTag; use OCP\IServerContainer; diff --git a/lib/public/SystemTag/ManagerEvent.php b/lib/public/SystemTag/ManagerEvent.php index 452c0d5da8f..41155a64ea2 100644 --- a/lib/public/SystemTag/ManagerEvent.php +++ b/lib/public/SystemTag/ManagerEvent.php @@ -24,7 +24,7 @@ declare(strict_types=1); namespace OCP\SystemTag; -use Symfony\Component\EventDispatcher\Event; +use OCP\EventDispatcher\Event; /** * Class ManagerEvent diff --git a/lib/public/SystemTag/MapperEvent.php b/lib/public/SystemTag/MapperEvent.php index d98caf1317b..4e2c84fecaf 100644 --- a/lib/public/SystemTag/MapperEvent.php +++ b/lib/public/SystemTag/MapperEvent.php @@ -23,7 +23,7 @@ declare(strict_types=1); namespace OCP\SystemTag; -use Symfony\Component\EventDispatcher\Event; +use OCP\EventDispatcher\Event; /** * Class MapperEvent diff --git a/lib/public/SystemTag/SystemTagsEntityEvent.php b/lib/public/SystemTag/SystemTagsEntityEvent.php index e439c16d9c6..cb4982ae282 100644 --- a/lib/public/SystemTag/SystemTagsEntityEvent.php +++ b/lib/public/SystemTag/SystemTagsEntityEvent.php @@ -23,7 +23,7 @@ declare(strict_types=1); namespace OCP\SystemTag; -use Symfony\Component\EventDispatcher\Event; +use OCP\EventDispatcher\Event; /** * Class SystemTagsEntityEvent diff --git a/lib/public/User.php b/lib/public/User.php index a669a3a06fc..04254db08a1 100644 --- a/lib/public/User.php +++ b/lib/public/User.php @@ -38,6 +38,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/User/Events/CreateUserEvent.php b/lib/public/User/Events/CreateUserEvent.php new file mode 100644 index 00000000000..877899fcba0 --- /dev/null +++ b/lib/public/User/Events/CreateUserEvent.php @@ -0,0 +1,63 @@ +<?php declare(strict_types=1); + +/** + * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; + +/** + * @since 18.0.0 + */ +class CreateUserEvent extends Event { + + /** @var string */ + private $uid; + + /** @var string */ + private $password; + + /** + * @since 18.0.0 + */ + public function __construct(string $uid, + string $password) { + parent::__construct(); + $this->uid = $uid; + $this->password = $password; + } + + /** + * @since 18.0.0 + */ + public function getUid(): string { + return $this->uid; + } + + /** + * @since 18.0.0 + */ + public function getPassword(): string { + return $this->password; + } + +} diff --git a/lib/public/User/Events/PostLoginEvent.php b/lib/public/User/Events/PostLoginEvent.php new file mode 100644 index 00000000000..7cc7aab4cd3 --- /dev/null +++ b/lib/public/User/Events/PostLoginEvent.php @@ -0,0 +1,76 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> + * + * @author Roeland Jago Douma <roeland@famdouma.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; +use OCP\IUser; + +/** + * @since 18.0.0 + */ +class PostLoginEvent extends Event { + + /** @var IUser */ + private $user; + + /** @var string */ + private $password; + + /** @var bool */ + private $isTokenLogin; + + /** + * @since 18.0.0 + */ + public function __construct(IUser $user, string $password, bool $isTokenLogin) { + parent::__construct(); + $this->user = $user; + $this->password = $password; + $this->isTokenLogin = $isTokenLogin; + } + + /** + * @since 18.0.0 + */ + public function getUser(): IUser { + return $this->user; + } + + /** + * @since 18.0.0 + */ + public function getPassword(): string { + return $this->password; + } + + /** + * @since 18.0.0 + */ + public function isTokenLogin(): bool { + return $this->isTokenLogin; + } +} diff --git a/lib/public/User/Events/UserCreatedEvent.php b/lib/public/User/Events/UserCreatedEvent.php new file mode 100644 index 00000000000..53debf5ff5c --- /dev/null +++ b/lib/public/User/Events/UserCreatedEvent.php @@ -0,0 +1,71 @@ +<?php declare(strict_types=1); + +/** + * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace OCP\User\Events; + +use OCP\EventDispatcher\Event; +use OCP\IUser; + +/** + * @since 18.0.0 + */ +class UserCreatedEvent extends Event { + + /** @var IUser */ + private $user; + + /** @var string */ + private $password; + + /** + * @since 18.0.0 + */ + public function __construct(IUser $user, + string $password) { + parent::__construct(); + $this->user = $user; + $this->password = $password; + } + + /** + * @since 18.0.0 + */ + public function getUser(): IUser { + return $this->user; + } + + /** + * @since 18.0.0 + */ + public function getUid(): string { + return $this->user->getUID(); + } + + /** + * @since 18.0.0 + */ + public function getPassword(): string { + return $this->password; + } + +} diff --git a/lib/public/UserInterface.php b/lib/public/UserInterface.php index b82fc6ba550..d880f2f5df5 100644 --- a/lib/public/UserInterface.php +++ b/lib/public/UserInterface.php @@ -30,6 +30,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/Util.php b/lib/public/Util.php index 7e9f6b2efbc..a63e53b0720 100644 --- a/lib/public/Util.php +++ b/lib/public/Util.php @@ -50,6 +50,7 @@ // use OCP namespace for all classes that are considered public. // This means that they should be used by apps instead of the internal ownCloud classes + namespace OCP; /** diff --git a/lib/public/WorkflowEngine/EntityContext/IDisplayName.php b/lib/public/WorkflowEngine/EntityContext/IDisplayName.php new file mode 100644 index 00000000000..eeaf7887d5a --- /dev/null +++ b/lib/public/WorkflowEngine/EntityContext/IDisplayName.php @@ -0,0 +1,41 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\WorkflowEngine\EntityContext; + +/** + * Interface IDisplayName + * + * @package OCP\WorkflowEngine\EntityContext + * + * @since 18.0.0 + */ +interface IDisplayName { + /** + * returns the end user facing name of the object related to the entity + * + * @since 18.0.0 + */ + public function getDisplayName(): string; +} diff --git a/lib/public/WorkflowEngine/EntityContext/IDisplayText.php b/lib/public/WorkflowEngine/EntityContext/IDisplayText.php new file mode 100644 index 00000000000..5e74171883a --- /dev/null +++ b/lib/public/WorkflowEngine/EntityContext/IDisplayText.php @@ -0,0 +1,47 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\WorkflowEngine\EntityContext; + +/** + * Interface IDisplayText + * + * @package OCP\WorkflowEngine\EntityContext + * + * @since 18.0.0 + */ +interface IDisplayText { + + /** + * returns translated text used for display to the end user. For instance, + * it can describe the event in a human readable way. + * + * The entity may react to a verbosity level that is provided. With the + * basic level, 0, it would return brief information, and more with higher + * numbers. All information shall be shown at a level of 3. + * + * @since 18.0.0 + */ + public function getDisplayText(int $verbosity = 0): string; +} diff --git a/lib/public/WorkflowEngine/EntityContext/IIcon.php b/lib/public/WorkflowEngine/EntityContext/IIcon.php new file mode 100644 index 00000000000..cde340c9931 --- /dev/null +++ b/lib/public/WorkflowEngine/EntityContext/IIcon.php @@ -0,0 +1,42 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\WorkflowEngine\EntityContext; + +/** + * Interface IIcon + * + * @package OCP\WorkflowEngine\EntityContext + * + * @since 18.0.0 + */ +interface IIcon { + /** + * returns a URL to an icon that is related to the entity, for instance + * a group icon for groups. + * + * @since 18.0.0 + */ + public function getIconUrl(): string; +} diff --git a/lib/public/WorkflowEngine/EntityContext/IUrl.php b/lib/public/WorkflowEngine/EntityContext/IUrl.php new file mode 100644 index 00000000000..a847dfaad05 --- /dev/null +++ b/lib/public/WorkflowEngine/EntityContext/IUrl.php @@ -0,0 +1,41 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\WorkflowEngine\EntityContext; + +/** + * Interface IUrl + * + * @package OCP\WorkflowEngine\EntityContext + * + * @since 18.0.0 + */ +interface IUrl { + /** + * returns a URL that is related to the entity, e.g. the link to a share + * + * @since 18.0.0 + */ + public function getUrl(): string; +} diff --git a/lib/public/WorkflowEngine/GenericEntityEvent.php b/lib/public/WorkflowEngine/GenericEntityEvent.php new file mode 100644 index 00000000000..3ea34c6fb87 --- /dev/null +++ b/lib/public/WorkflowEngine/GenericEntityEvent.php @@ -0,0 +1,79 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\WorkflowEngine; + +/** + * Class GenericEntityEvent + * + * @package OCP\WorkflowEngine + * + * @since 18.0.0 + */ +class GenericEntityEvent implements IEntityEvent { + + /** @var string */ + private $displayName; + /** @var string */ + private $eventName; + + /** + * GenericEntityEvent constructor. + * + * @since 18.0.0 + */ + public function __construct(string $displayName, string $eventName) { + if(trim($displayName) === '') { + throw new \InvalidArgumentException('DisplayName must not be empty'); + } + if(trim($eventName) === '') { + throw new \InvalidArgumentException('EventName must not be empty'); + } + + $this->displayName = trim($displayName); + $this->eventName = trim($eventName); + } + + /** + * returns a translated name to be presented in the web interface. + * + * Example: "created" (en), "kreita" (eo) + * + * @since 18.0.0 + */ + public function getDisplayName(): string { + return $this->displayName; + } + + /** + * returns the event name that is emitted by the EventDispatcher, e.g.: + * + * Example: "OCA\MyApp\Factory\Cats::postCreated" + * + * @since 18.0.0 + */ + public function getEventName(): string { + return $this->eventName; + } +} diff --git a/lib/public/WorkflowEngine/ICheck.php b/lib/public/WorkflowEngine/ICheck.php index 1d4fc966460..f5586e83d51 100644 --- a/lib/public/WorkflowEngine/ICheck.php +++ b/lib/public/WorkflowEngine/ICheck.php @@ -2,6 +2,7 @@ /** * @copyright Copyright (c) 2016 Morris Jobke <hey@morrisjobke.de> * + * @author Arthur Schiwon <blizzz@arthur-schiwon.de> * @author Morris Jobke <hey@morrisjobke.de> * * @license GNU AGPL version 3 or any later version @@ -23,9 +24,6 @@ namespace OCP\WorkflowEngine; - -use OCP\Files\Storage\IStorage; - /** * Interface ICheck * @@ -34,13 +32,6 @@ use OCP\Files\Storage\IStorage; */ interface ICheck { /** - * @param IStorage $storage - * @param string $path - * @since 9.1 - */ - public function setFileInfo(IStorage $storage, $path); - - /** * @param string $operator * @param string $value * @return bool @@ -55,4 +46,28 @@ interface ICheck { * @since 9.1 */ public function validateCheck($operator, $value); + + /** + * returns a list of Entities the checker supports. The values must match + * the class name of the entity. + * + * An empty result means the check is universally available. + * + * @since 18.0.0 + */ + public function supportedEntities(): array; + + /** + * returns whether the operation can be used in the requested scope. + * + * Scope IDs are defined as constants in OCP\WorkflowEngine\IManager. At + * time of writing these are SCOPE_ADMIN and SCOPE_USER. + * + * For possibly unknown future scopes the recommended behaviour is: if + * user scope is permitted, the default behaviour should return `true`, + * otherwise `false`. + * + * @since 18.0.0 + */ + public function isAvailableForScope(int $scope): bool; } diff --git a/lib/public/WorkflowEngine/IComplexOperation.php b/lib/public/WorkflowEngine/IComplexOperation.php new file mode 100644 index 00000000000..63a4ca2460a --- /dev/null +++ b/lib/public/WorkflowEngine/IComplexOperation.php @@ -0,0 +1,56 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\WorkflowEngine; + +/** + * Interface IComplexOperation + * + * This interface represents an operator that is less generic and indicates + * that some of the tasks it does itself instead of relying on the engine. + * This includes: + * + * * registering listeners – the implementing app needs to ensure that the + * business logic registers listeners to the events it listens to. For example + * when direct storage access is required, adding a wrapper or listening to + * a specific one is required over usual file events. + * + * @package OCP\WorkflowEngine + * + * @since 18.0.0 + */ +interface IComplexOperation extends IOperation { + + /** + * As IComplexOperation chooses the triggering events itself, a hint has + * to be shown to the user so make clear when this operation is becoming + * active. This method returns such a translated string. + * + * Example: "When a file is accessed" (en) + * + * @since 18.0.0 + */ + public function getTriggerHint(): string; + +} diff --git a/lib/public/WorkflowEngine/IEntity.php b/lib/public/WorkflowEngine/IEntity.php new file mode 100644 index 00000000000..47e2f102199 --- /dev/null +++ b/lib/public/WorkflowEngine/IEntity.php @@ -0,0 +1,85 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\WorkflowEngine; + +use OCP\EventDispatcher\Event; + +/** + * Interface IEntity + * + * This interface represents an entity that supports events the workflow engine + * can listen to. For example a file with the create, update, etc. events. + * + * Ensure to listen to 'OCP/WorkflowEngine::loadEntities' for registering your + * entities. + * + * @package OCP\WorkflowEngine + * @since 18.0.0 + */ +interface IEntity { + + /** + * returns a translated name to be presented in the web interface. + * + * Example: "File" (en), "Dosiero" (eo) + * + * @since 18.0.0 + */ + public function getName(): string; + + /** + * returns the URL to the icon of the entity for display in the web interface. + * + * Usually, the implementation would utilize the `imagePath()` method of the + * `\OCP\IURLGenerator` instance and simply return its result. + * + * Example implementation: return $this->urlGenerator->imagePath('myApp', 'cat.svg'); + * + * @since 18.0.0 + */ + public function getIcon(): string; + + /** + * returns a list of supported events + * + * @return IEntityEvent[] + * @since 18.0.0 + */ + public function getEvents(): array; + + /** + * @since 18.0.0 + */ + public function prepareRuleMatcher(IRuleMatcher $ruleMatcher, string $eventName, Event $event): void; + + /** + * returns whether the provided user id is allowed to run a flow against + * the known context + * + * @since 18.0.0 + */ + public function isLegitimatedForUserId(string $userId): bool; + +} diff --git a/lib/public/WorkflowEngine/IEntityCheck.php b/lib/public/WorkflowEngine/IEntityCheck.php new file mode 100644 index 00000000000..d90535b4c99 --- /dev/null +++ b/lib/public/WorkflowEngine/IEntityCheck.php @@ -0,0 +1,51 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\WorkflowEngine; + +/** + * Interface IFileCheck + * + * @package OCP\WorkflowEngine + * @since 18.0.0 + */ +interface IEntityCheck { + /** + * Equips the check with a subject fitting the Entity. For instance, an + * entity of File will receive an instance of OCP\Files\Node, or a comment + * entity might get an IComment. + * + * The implementing check must be aware of the incoming type. + * + * If an unsupported subject is passed the implementation MAY throw an + * \UnexpectedValueException. + * + * @param IEntity $entity + * @param mixed $subject + * @throws \UnexpectedValueException + * @since 18.0.0 + */ + public function setEntitySubject(IEntity $entity, $subject): void; + +} diff --git a/lib/public/WorkflowEngine/IEntityCompat.php b/lib/public/WorkflowEngine/IEntityCompat.php new file mode 100644 index 00000000000..1a3ffc7bc10 --- /dev/null +++ b/lib/public/WorkflowEngine/IEntityCompat.php @@ -0,0 +1,47 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\WorkflowEngine; + +/** + * Interface IEntityCompat + * + * This interface extends IEntity to provide compatibility with old style + * Event classes. It is only present for a transition period and will be + * removed in 2023 again. + * + * @package OCP\WorkflowEngine + * @since 18.0.0 + * @deprecated + */ +interface IEntityCompat extends IEntity { + /** + * Like prepareRuleMatcherCompat, but works with events that are not based + * on \OCP\EventDispatcher\Event. + * + * @since 18.0.0 + * @deprecated + */ + public function prepareRuleMatcherCompat(IRuleMatcher $ruleMatcher, string $eventName, $event): void; +} diff --git a/lib/public/WorkflowEngine/IEntityEvent.php b/lib/public/WorkflowEngine/IEntityEvent.php new file mode 100644 index 00000000000..8baa0573fa8 --- /dev/null +++ b/lib/public/WorkflowEngine/IEntityEvent.php @@ -0,0 +1,54 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\WorkflowEngine; + +/** + * Interface IEntityEvent + * + * represents an entitiy event that is dispatched via EventDispatcher + * + * @package OCP\WorkflowEngine + * + * @since 18.0.0 + */ +interface IEntityEvent { + /** + * returns a translated name to be presented in the web interface. + * + * Example: "created" (en), "kreita" (eo) + * + * @since 18.0.0 + */ + public function getDisplayName(): string; + + /** + * returns the event name that is emitted by the EventDispatcher, e.g.: + * + * Example: "OCA\MyApp\Factory\Cats::postCreated" + * + * @since 18.0.0 + */ + public function getEventName(): string; +} diff --git a/lib/public/WorkflowEngine/IFileCheck.php b/lib/public/WorkflowEngine/IFileCheck.php new file mode 100644 index 00000000000..557ba0f3c10 --- /dev/null +++ b/lib/public/WorkflowEngine/IFileCheck.php @@ -0,0 +1,42 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\WorkflowEngine; + + +use OCP\Files\Storage\IStorage; + +/** + * Interface IFileCheck + * + * @package OCP\WorkflowEngine + * @since 18.0.0 + */ +interface IFileCheck extends IEntityCheck { + /** + * @since 18.0.0 + */ + public function setFileInfo(IStorage $storage, string $path); + +} diff --git a/lib/public/WorkflowEngine/IManager.php b/lib/public/WorkflowEngine/IManager.php index cd323a816f3..78fd718ec9e 100644 --- a/lib/public/WorkflowEngine/IManager.php +++ b/lib/public/WorkflowEngine/IManager.php @@ -23,9 +23,6 @@ namespace OCP\WorkflowEngine; - -use OCP\Files\Storage\IStorage; - /** * Interface IManager * @@ -33,18 +30,40 @@ use OCP\Files\Storage\IStorage; * @since 9.1 */ interface IManager { + + const SCOPE_ADMIN = 0; + const SCOPE_USER = 1; + + const EVENT_NAME_REG_OPERATION = 'OCP\WorkflowEngine::registerOperations'; + const EVENT_NAME_REG_ENTITY = 'OCP\WorkflowEngine::registerEntities'; + const EVENT_NAME_REG_CHECK = 'OCP\WorkflowEngine::registerChecks'; + + /** + * Listen to `\OCP\WorkflowEngine::EVENT_NAME_REG_ENTITY` at the + * EventDispatcher for registering your entities. + * + * @since 18.0.0 + */ + public function registerEntity(IEntity $entity): void; + + /** + * Listen to `\OCP\WorkflowEngine::EVENT_NAME_REG_OPERATION` at the + * EventDispatcher for registering your operators. + * + * @since 18.0.0 + */ + public function registerOperation(IOperation $operator): void; + /** - * @param IStorage $storage - * @param string $path - * @since 9.1 + * Listen to `\OCP\WorkflowEngine::EVENT_NAME_REG_CHECK` at the + * EventDispatcher for registering your operators. + * + * @since 18.0.0 */ - public function setFileInfo(IStorage $storage, $path); + public function registerCheck(ICheck $check): void; /** - * @param string $class - * @param bool $returnFirstMatchingOperationOnly - * @return array - * @since 9.1 + * @since 18.0.0 */ - public function getMatchingOperations($class, $returnFirstMatchingOperationOnly = true); + public function getRuleMatcher(): IRuleMatcher; } diff --git a/lib/public/WorkflowEngine/IOperation.php b/lib/public/WorkflowEngine/IOperation.php index 491a805909c..d01c6021c5f 100644 --- a/lib/public/WorkflowEngine/IOperation.php +++ b/lib/public/WorkflowEngine/IOperation.php @@ -23,6 +23,8 @@ namespace OCP\WorkflowEngine; +use OCP\EventDispatcher\Event; + /** * Interface IOperation * @@ -31,11 +33,71 @@ namespace OCP\WorkflowEngine; */ interface IOperation { /** - * @param string $name - * @param array[] $checks - * @param string $operation + * returns a translated name to be presented in the web interface + * + * Example: "Automated tagging" (en), "Aŭtomata etikedado" (eo) + * + * @since 18.0.0 + */ + public function getDisplayName(): string; + + /** + * returns a translated, descriptive text to be presented in the web interface. + * + * It should be short and precise. + * + * Example: "Tag based automatic deletion of files after a given time." (en) + * + * @since 18.0.0 + */ + public function getDescription(): string; + + /** + * returns the URL to the icon of the operator for display in the web interface. + * + * Usually, the implementation would utilize the `imagePath()` method of the + * `\OCP\IURLGenerator` instance and simply return its result. + * + * Example implementation: return $this->urlGenerator->imagePath('myApp', 'cat.svg'); + * + * @since 18.0.0 + */ + public function getIcon(): string; + + /** + * returns whether the operation can be used in the requested scope. + * + * Scope IDs are defined as constants in OCP\WorkflowEngine\IManager. At + * time of writing these are SCOPE_ADMIN and SCOPE_USER. + * + * For possibly unknown future scopes the recommended behaviour is: if + * user scope is permitted, the default behaviour should return `true`, + * otherwise `false`. + * + * @since 18.0.0 + */ + public function isAvailableForScope(int $scope): bool; + + /** + * Validates whether a configured workflow rule is valid. If it is not, + * an `\UnexpectedValueException` is supposed to be thrown. + * * @throws \UnexpectedValueException * @since 9.1 */ - public function validateOperation($name, array $checks, $operation); + public function validateOperation(string $name, array $checks, string $operation): void; + + /** + * Is being called by the workflow engine when an event was triggered that + * is configured for this operation. An evaluation whether the event + * qualifies for this operation to run has still to be done by the + * implementor by calling the RuleMatchers getMatchingOperations method + * and evaluating the results. + * + * If the implementor is an IComplexOperation, this method will not be + * called automatically. It can be used or left as no-op by the implementor. + * + * @since 18.0.0 + */ + public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatcher): void; } diff --git a/lib/public/WorkflowEngine/IOperationCompat.php b/lib/public/WorkflowEngine/IOperationCompat.php new file mode 100644 index 00000000000..434e6da0316 --- /dev/null +++ b/lib/public/WorkflowEngine/IOperationCompat.php @@ -0,0 +1,50 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\WorkflowEngine; + +/** + * Interface IOperationCompat + * + * This interface extends IOperation to provide compatibility with old style + * Event classes. It is only present for a transition period and will be + * removed in 2023 again. + * + * @package OCP\WorkflowEngine + * @since 18.0.0 + * @deprecated + */ +interface IOperationCompat { + /** + * Like onEvent, but used with events that are not based on + * \OCP\EventDispatcher\Event. + * + * This method is introduced for compatibility reasons and will be removed + * in 2023 again. + * + * @since 18.0.0 + * @deprecated + */ + public function onEventCompat(string $eventName, $event, IRuleMatcher $ruleMatcher): void; +} diff --git a/lib/public/WorkflowEngine/IRuleMatcher.php b/lib/public/WorkflowEngine/IRuleMatcher.php new file mode 100644 index 00000000000..28abaa56137 --- /dev/null +++ b/lib/public/WorkflowEngine/IRuleMatcher.php @@ -0,0 +1,79 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\WorkflowEngine; + +use RuntimeException; + +/** + * Class IRuleMatcher + * + * @package OCP\WorkflowEngine + * + * @since 18.0.0 + */ +interface IRuleMatcher extends IFileCheck { + /** + * This method is left for backwards compatibility and easier porting of + * apps. Please use 'getFlows' instead (and setOperation if you implement + * an IComplexOperation). + * + * @since 18.0.0 + * @deprecated 18.0.0 + */ + public function getMatchingOperations(string $class, bool $returnFirstMatchingOperationOnly = true): array; + + /** + * @throws RuntimeException + * @since 18.0.0 + */ + public function getFlows(bool $returnFirstMatchingOperationOnly = true): array; + + /** + * this method can only be called once and is typically called by the + * Flow engine, unless for IComplexOperations. + * + * @throws RuntimeException + * @since 18.0.0 + */ + public function setOperation(IOperation $operation): void; + + /** + * this method can only be called once and is typically called by the + * Flow engine, unless for IComplexOperations. + * + * @throws RuntimeException + * @since 18.0.0 + */ + public function setEntity(IEntity $entity): void; + + /** + * returns the entity which might provide more information, depending on + * the interfaces it implements + * + * @return IEntity + * @since 18.0.0 + */ + public function getEntity(): IEntity; +} diff --git a/lib/public/WorkflowEngine/ISpecificOperation.php b/lib/public/WorkflowEngine/ISpecificOperation.php new file mode 100644 index 00000000000..0b26770a13a --- /dev/null +++ b/lib/public/WorkflowEngine/ISpecificOperation.php @@ -0,0 +1,50 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @author Arthur Schiwon <blizzz@arthur-schiwon.de> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\WorkflowEngine; + +/** + * Interface ISpecificOperation + * + * This interface represents an operator that is designed to work with exactly + * one entity type. + * + * In almost all of the cases it is not necessary to have this limitation, + * because the action is not connected to the event. This mechanism suits + * special cases. + * + * @package OCP\WorkflowEngine + * @since 18.0.0 + */ +interface ISpecificOperation extends IOperation { + + /** + * returns the id of the entity the operator is designed for + * + * Example: 'WorkflowEngine_Entity_File' + * + * @since 18.0.0 + */ + public function getEntityId():string; +} |