diff options
author | Stanimir Bozhilov <stanimir.bozhilov.1998@gmail.com> | 2022-12-19 09:07:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-19 09:07:38 +0100 |
commit | 7dcd6eb561f4bba7ed36ce1178c725278dd9b80e (patch) | |
tree | 8de1664f1a18df2e3b7b3dafadb3e0b6c3a8b439 /lib/public | |
parent | ed902d58b62150a46c745b5e87c895fc3fc67509 (diff) | |
parent | e12aaa298861743f798d9adf644d626ac8e89a95 (diff) | |
download | nextcloud-server-7dcd6eb561f4bba7ed36ce1178c725278dd9b80e.tar.gz nextcloud-server-7dcd6eb561f4bba7ed36ce1178c725278dd9b80e.zip |
Merge branch 'master' into add-scim-json-support
Signed-off-by: Stanimir Bozhilov <stanimir.bozhilov.1998@gmail.com>
Diffstat (limited to 'lib/public')
38 files changed, 912 insertions, 512 deletions
diff --git a/lib/public/Accounts/IAccountManager.php b/lib/public/Accounts/IAccountManager.php index e41327171b4..77c32d6ff4e 100644 --- a/lib/public/Accounts/IAccountManager.php +++ b/lib/public/Accounts/IAccountManager.php @@ -112,6 +112,7 @@ interface IAccountManager { public const PROPERTY_WEBSITE = 'website'; public const PROPERTY_ADDRESS = 'address'; public const PROPERTY_TWITTER = 'twitter'; + public const PROPERTY_FEDIVERSE = 'fediverse'; /** * @since 23.0.0 @@ -151,6 +152,7 @@ interface IAccountManager { self::PROPERTY_WEBSITE, self::PROPERTY_ADDRESS, self::PROPERTY_TWITTER, + self::PROPERTY_FEDIVERSE, self::PROPERTY_ORGANISATION, self::PROPERTY_ROLE, self::PROPERTY_HEADLINE, diff --git a/lib/public/AppFramework/Db/Mapper.php b/lib/public/AppFramework/Db/Mapper.php deleted file mode 100644 index 2d0dc87ebb3..00000000000 --- a/lib/public/AppFramework/Db/Mapper.php +++ /dev/null @@ -1,370 +0,0 @@ -<?php -/** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Bernhard Posselt <dev@bernhard-posselt.com> - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Joas Schilling <coding@schilljs.com> - * @author Lukas Reschke <lukas@statuscode.ch> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * 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, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ -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 - * @since 7.0.0 - * @deprecated 14.0.0 Move over to QBMapper - */ -abstract class Mapper { - protected $tableName; - protected $entityClass; - protected $db; - - /** - * @param IDBConnection $db Instance of the Db abstraction layer - * @param string $tableName the name of the table. set this to allow entity - * @param string $entityClass the name of the entity that the sql should be - * mapped to queries without using sql - * @since 7.0.0 - * @deprecated 14.0.0 Move over to QBMapper - */ - public function __construct(IDBConnection $db, $tableName, $entityClass = null) { - $this->db = $db; - $this->tableName = '*PREFIX*' . $tableName; - - // if not given set the entity name to the class without the mapper part - // cache it here for later use since reflection is slow - if ($entityClass === null) { - $this->entityClass = str_replace('Mapper', '', get_class($this)); - } else { - $this->entityClass = $entityClass; - } - } - - - /** - * @return string the table name - * @since 7.0.0 - * @deprecated 14.0.0 Move over to QBMapper - */ - public function getTableName() { - return $this->tableName; - } - - - /** - * Deletes an entity from the table - * @param Entity $entity the entity that should be deleted - * @return Entity the deleted entity - * @since 7.0.0 - return value added in 8.1.0 - * @deprecated 14.0.0 Move over to QBMapper - */ - public function delete(Entity $entity) { - $sql = 'DELETE FROM `' . $this->tableName . '` WHERE `id` = ?'; - $stmt = $this->execute($sql, [$entity->getId()]); - $stmt->closeCursor(); - return $entity; - } - - - /** - * Creates a new entry in the db from an entity - * @param Entity $entity the entity that should be created - * @return Entity the saved entity with the set id - * @since 7.0.0 - * @deprecated 14.0.0 Move over to QBMapper - */ - public function insert(Entity $entity) { - // get updated fields to save, fields have to be set using a setter to - // be saved - $properties = $entity->getUpdatedFields(); - $values = ''; - $columns = ''; - $params = []; - - // build the fields - $i = 0; - foreach ($properties as $property => $updated) { - $column = $entity->propertyToColumn($property); - $getter = 'get' . ucfirst($property); - - $columns .= '`' . $column . '`'; - $values .= '?'; - - // only append colon if there are more entries - if ($i < count($properties) - 1) { - $columns .= ','; - $values .= ','; - } - - $params[] = $entity->$getter(); - $i++; - } - - $sql = 'INSERT INTO `' . $this->tableName . '`(' . - $columns . ') VALUES(' . $values . ')'; - - $stmt = $this->execute($sql, $params); - - $entity->setId((int) $this->db->lastInsertId($this->tableName)); - - $stmt->closeCursor(); - - return $entity; - } - - - - /** - * Updates an entry in the db from an entity - * @throws \InvalidArgumentException if entity has no id - * @param Entity $entity the entity that should be created - * @return Entity the saved entity with the set id - * @since 7.0.0 - return value was added in 8.0.0 - * @deprecated 14.0.0 Move over to QBMapper - */ - public function update(Entity $entity) { - // if entity wasn't changed it makes no sense to run a db query - $properties = $entity->getUpdatedFields(); - if (count($properties) === 0) { - return $entity; - } - - // entity needs an id - $id = $entity->getId(); - if ($id === null) { - throw new \InvalidArgumentException( - 'Entity which should be updated has no id'); - } - - // get updated fields to save, fields have to be set using a setter to - // be saved - // do not update the id field - unset($properties['id']); - - $columns = ''; - $params = []; - - // build the fields - $i = 0; - foreach ($properties as $property => $updated) { - $column = $entity->propertyToColumn($property); - $getter = 'get' . ucfirst($property); - - $columns .= '`' . $column . '` = ?'; - - // only append colon if there are more entries - if ($i < count($properties) - 1) { - $columns .= ','; - } - - $params[] = $entity->$getter(); - $i++; - } - - $sql = 'UPDATE `' . $this->tableName . '` SET ' . - $columns . ' WHERE `id` = ?'; - $params[] = $id; - - $stmt = $this->execute($sql, $params); - $stmt->closeCursor(); - - return $entity; - } - - /** - * Checks if an array is associative - * @param array $array - * @return bool true if associative - * @since 8.1.0 - * @deprecated 14.0.0 Move over to QBMapper - */ - private function isAssocArray(array $array) { - return array_values($array) !== $array; - } - - /** - * Returns the correct PDO constant based on the value type - * @param $value - * @return int PDO constant - * @since 8.1.0 - * @deprecated 14.0.0 Move over to QBMapper - */ - private function getPDOType($value) { - switch (gettype($value)) { - case 'integer': - return \PDO::PARAM_INT; - case 'boolean': - return \PDO::PARAM_BOOL; - default: - return \PDO::PARAM_STR; - } - } - - - /** - * Runs an sql query - * @param string $sql the prepare string - * @param array $params the params which should replace the ? in the sql query - * @param int $limit the maximum number of rows - * @param int $offset from which row we want to start - * @return \PDOStatement the database query result - * @since 7.0.0 - * @deprecated 14.0.0 Move over to QBMapper - */ - protected function execute($sql, array $params = [], $limit = null, $offset = null) { - $query = $this->db->prepare($sql, $limit, $offset); - - if ($this->isAssocArray($params)) { - foreach ($params as $key => $param) { - $pdoConstant = $this->getPDOType($param); - $query->bindValue($key, $param, $pdoConstant); - } - } else { - $index = 1; // bindParam is 1 indexed - foreach ($params as $param) { - $pdoConstant = $this->getPDOType($param); - $query->bindValue($index, $param, $pdoConstant); - $index++; - } - } - - $query->execute(); - - return $query; - } - - /** - * Returns an db result and throws exceptions when there are more or less - * results - * @see findEntity - * @param string $sql the sql query - * @param array $params the parameters of the sql query - * @param int $limit the maximum number of rows - * @param int $offset from which row we want to start - * @throws DoesNotExistException if the item does not exist - * @throws MultipleObjectsReturnedException if more than one item exist - * @return array the result as row - * @since 7.0.0 - * @deprecated 14.0.0 Move over to QBMapper - */ - protected function findOneQuery($sql, array $params = [], $limit = null, $offset = null) { - $stmt = $this->execute($sql, $params, $limit, $offset); - $row = $stmt->fetch(); - - if ($row === false || $row === null) { - $stmt->closeCursor(); - $msg = $this->buildDebugMessage( - 'Did expect one result but found none when executing', $sql, $params, $limit, $offset - ); - throw new DoesNotExistException($msg); - } - $row2 = $stmt->fetch(); - $stmt->closeCursor(); - //MDB2 returns null, PDO and doctrine false when no row is available - if (! ($row2 === false || $row2 === null)) { - $msg = $this->buildDebugMessage( - 'Did not expect more than one result when executing', $sql, $params, $limit, $offset - ); - throw new MultipleObjectsReturnedException($msg); - } else { - return $row; - } - } - - /** - * Builds an error message by prepending the $msg to an error message which - * has the parameters - * @see findEntity - * @param string $sql the sql query - * @param array $params the parameters of the sql query - * @param int $limit the maximum number of rows - * @param int $offset from which row we want to start - * @return string formatted error message string - * @since 9.1.0 - * @deprecated 14.0.0 Move over to QBMapper - */ - private function buildDebugMessage($msg, $sql, array $params = [], $limit = null, $offset = null) { - return $msg . - ': query "' . $sql . '"; ' . - 'parameters ' . print_r($params, true) . '; ' . - 'limit "' . $limit . '"; '. - 'offset "' . $offset . '"'; - } - - - /** - * Creates an entity from a row. Automatically determines the entity class - * from the current mapper name (MyEntityMapper -> MyEntity) - * @param array $row the row which should be converted to an entity - * @return Entity the entity - * @since 7.0.0 - * @deprecated 14.0.0 Move over to QBMapper - */ - protected function mapRowToEntity($row) { - return call_user_func($this->entityClass .'::fromRow', $row); - } - - - /** - * Runs a sql query and returns an array of entities - * @param string $sql the prepare string - * @param array $params the params which should replace the ? in the sql query - * @param int $limit the maximum number of rows - * @param int $offset from which row we want to start - * @return array all fetched entities - * @since 7.0.0 - * @deprecated 14.0.0 Move over to QBMapper - */ - protected function findEntities($sql, array $params = [], $limit = null, $offset = null) { - $stmt = $this->execute($sql, $params, $limit, $offset); - - $entities = []; - - while ($row = $stmt->fetch()) { - $entities[] = $this->mapRowToEntity($row); - } - - $stmt->closeCursor(); - - return $entities; - } - - - /** - * Returns an db result and throws exceptions when there are more or less - * results - * @param string $sql the sql query - * @param array $params the parameters of the sql query - * @param int $limit the maximum number of rows - * @param int $offset from which row we want to start - * @throws DoesNotExistException if the item does not exist - * @throws MultipleObjectsReturnedException if more than one item exist - * @return Entity the entity - * @since 7.0.0 - * @deprecated 14.0.0 Move over to QBMapper - */ - protected function findEntity($sql, array $params = [], $limit = null, $offset = null) { - return $this->mapRowToEntity($this->findOneQuery($sql, $params, $limit, $offset)); - } -} diff --git a/lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php b/lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php index e957b245e53..ad11b53637b 100644 --- a/lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php +++ b/lib/public/AppFramework/Http/RedirectToDefaultAppResponse.php @@ -32,14 +32,14 @@ use OCP\IURLGenerator; * Redirects to the default app * * @since 16.0.0 - * @depreacted 23.0.0 Use RedirectResponse() with IURLGenerator::linkToDefaultPageUrl() instead + * @deprecated 23.0.0 Use RedirectResponse() with IURLGenerator::linkToDefaultPageUrl() instead */ class RedirectToDefaultAppResponse extends RedirectResponse { /** * Creates a response that redirects to the default app * * @since 16.0.0 - * @depreacted 23.0.0 Use RedirectResponse() with IURLGenerator::linkToDefaultPageUrl() instead + * @deprecated 23.0.0 Use RedirectResponse() with IURLGenerator::linkToDefaultPageUrl() instead */ public function __construct() { /** @var IURLGenerator $urlGenerator */ diff --git a/lib/public/AppFramework/OCSController.php b/lib/public/AppFramework/OCSController.php index 09c28667dcd..11bac9effd5 100644 --- a/lib/public/AppFramework/OCSController.php +++ b/lib/public/AppFramework/OCSController.php @@ -61,7 +61,7 @@ abstract class OCSController extends ApiController { public function __construct($appName, IRequest $request, $corsMethods = 'PUT, POST, GET, DELETE, PATCH', - $corsAllowedHeaders = 'Authorization, Content-Type, Accept', + $corsAllowedHeaders = 'Authorization, Content-Type, Accept, OCS-APIRequest', $corsMaxAge = 1728000) { parent::__construct($appName, $request, $corsMethods, $corsAllowedHeaders, $corsMaxAge); diff --git a/lib/public/Authentication/Events/AnyLoginFailedEvent.php b/lib/public/Authentication/Events/AnyLoginFailedEvent.php new file mode 100644 index 00000000000..ddfec6d9da8 --- /dev/null +++ b/lib/public/Authentication/Events/AnyLoginFailedEvent.php @@ -0,0 +1,62 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2022, 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\Authentication\Events; + +use OCP\EventDispatcher\Event; + +/** + * Emitted when the authentication fails + * + * @since 26.0.0 + */ +class AnyLoginFailedEvent extends Event { + private string $loginName; + private ?string $password; + + /** + * @since 26.0.0 + */ + public function __construct(string $loginName, ?string $password) { + parent::__construct(); + + $this->loginName = $loginName; + $this->password = $password; + } + + /** + * @since 26.0.0 + */ + public function geLoginName(): string { + return $this->loginName; + } + + /** + * @since 26.0.0 + */ + public function getPassword(): ?string { + return $this->password; + } +} diff --git a/lib/public/Authentication/TwoFactorAuth/IRegistry.php b/lib/public/Authentication/TwoFactorAuth/IRegistry.php index 1f1b82a4426..0f164902f67 100644 --- a/lib/public/Authentication/TwoFactorAuth/IRegistry.php +++ b/lib/public/Authentication/TwoFactorAuth/IRegistry.php @@ -53,7 +53,7 @@ interface IRegistry { * the given user. * * @since 14.0.0 - * @return string[] where the array key is the provider ID (string) and the + * @return array<string, bool> where the array key is the provider ID (string) and the * value is the enabled state (bool) */ public function getProviderStates(IUser $user): array; diff --git a/lib/public/BeforeSabrePubliclyLoadedEvent.php b/lib/public/BeforeSabrePubliclyLoadedEvent.php new file mode 100644 index 00000000000..afb68a8a952 --- /dev/null +++ b/lib/public/BeforeSabrePubliclyLoadedEvent.php @@ -0,0 +1,31 @@ +<?php +/** + * @copyright Julien Veyssier <eneiluj@posteo.net> 2022 + * + * @author Julien Veyssier <eneiluj@posteo.net> + * + * @license AGPL-3.0-or-later + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * 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, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ +namespace OCP; + +/** + * Dispatched before Sabre is loaded when accessing public webdav endpoints + * This can be used to inject a Sabre plugin for example + * + * @since 26.0.0 + */ +class BeforeSabrePubliclyLoadedEvent extends SabrePluginEvent { +} diff --git a/lib/public/Calendar/ICalendar.php b/lib/public/Calendar/ICalendar.php index 0d08e2ba268..2631ef327fc 100644 --- a/lib/public/Calendar/ICalendar.php +++ b/lib/public/Calendar/ICalendar.php @@ -37,9 +37,10 @@ interface ICalendar { * @return string defining the technical unique key * @since 13.0.0 */ - public function getKey(); + public function getKey(): string; /** + * In comparison to getKey() this function returns a unique uri within the scope of the principal * @since 24.0.0 */ public function getUri(): string; @@ -49,30 +50,36 @@ interface ICalendar { * @return null|string * @since 13.0.0 */ - public function getDisplayName(); + public function getDisplayName(): ?string; /** * Calendar color * @return null|string * @since 13.0.0 */ - public function getDisplayColor(); + public function getDisplayColor(): ?string; /** * @param string $pattern which should match within the $searchProperties * @param array $searchProperties defines the properties within the query pattern should match * @param array $options - optional parameters: * ['timerange' => ['start' => new DateTime(...), 'end' => new DateTime(...)]] - * @param integer|null $limit - limit number of search results - * @param integer|null $offset - offset for paging of search results + * @param int|null $limit - limit number of search results + * @param int|null $offset - offset for paging of search results * @return array an array of events/journals/todos which are arrays of key-value-pairs * @since 13.0.0 */ - public function search($pattern, array $searchProperties = [], array $options = [], $limit = null, $offset = null); + public function search(string $pattern, array $searchProperties = [], array $options = [], ?int $limit = null, ?int $offset = null): array; /** - * @return integer build up using \OCP\Constants + * @return int build up using \OCP\Constants * @since 13.0.0 */ - public function getPermissions(); + public function getPermissions(): int; + + /** + * Whether the calendar is deleted + * @since 26.0.0 + */ + public function isDeleted(): bool; } diff --git a/lib/public/Calendar/ICreateFromString.php b/lib/public/Calendar/ICreateFromString.php index 8c4bdd44041..17d529cdef3 100644 --- a/lib/public/Calendar/ICreateFromString.php +++ b/lib/public/Calendar/ICreateFromString.php @@ -40,11 +40,4 @@ interface ICreateFromString extends ICalendar { * @throws CalendarException */ public function createFromString(string $name, string $calendarData): void; - - /** - * @since 25.0.0 - * - * @throws CalendarException - */ - public function handleIMipMessage(string $name, string $calendarData): void; } diff --git a/lib/public/Calendar/IHandleImipMessage.php b/lib/public/Calendar/IHandleImipMessage.php new file mode 100644 index 00000000000..58c1400d987 --- /dev/null +++ b/lib/public/Calendar/IHandleImipMessage.php @@ -0,0 +1,48 @@ +<?php + +declare(strict_types=1); +/** + * @copyright 2022 Anna Larch <anna.larch@gmx.net> + * + * @author Anna Larch <anna.larch@gmx.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\Calendar; + +use OCP\Calendar\Exceptions\CalendarException; + +/** + * Extends the current ICalendar interface + * to add a public write method to handle + * iMIP data + * + * @link https://www.rfc-editor.org/rfc/rfc6047 + * + * @since 26.0.0 + */ +interface IHandleImipMessage extends ICalendar { + + /** + * Handle an iMIP VEvent for validation and processing + * + * @since 26.0.0 + * + * @throws CalendarException on validation failure or calendar write error + */ + public function handleIMipMessage(string $name, string $calendarData): void; +} diff --git a/lib/public/Collaboration/Reference/IReference.php b/lib/public/Collaboration/Reference/IReference.php index 0155ae86dd8..31608b52cc5 100644 --- a/lib/public/Collaboration/Reference/IReference.php +++ b/lib/public/Collaboration/Reference/IReference.php @@ -98,7 +98,7 @@ interface IReference extends JsonSerializable { /** * @since 25.0.0 */ - public function getUrl(): ?string; + public function getUrl(): string; /** * Set the reference specific rich object representation diff --git a/lib/public/Collaboration/Reference/Reference.php b/lib/public/Collaboration/Reference/Reference.php new file mode 100644 index 00000000000..6b92a0fae52 --- /dev/null +++ b/lib/public/Collaboration/Reference/Reference.php @@ -0,0 +1,249 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2022 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\Collaboration\Reference; + +/** + * @since 25.0.0 + */ +class Reference implements IReference { + protected string $reference; + + protected bool $accessible = true; + + protected ?string $title = null; + protected ?string $description = null; + protected ?string $imageUrl = null; + protected ?string $contentType = null; + protected ?string $url = null; + + protected ?string $richObjectType = null; + protected ?array $richObject = null; + + /** + * @since 25.0.0 + */ + public function __construct(string $reference) { + $this->reference = $reference; + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function getId(): string { + return $this->reference; + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function setAccessible(bool $accessible): void { + $this->accessible = $accessible; + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function getAccessible(): bool { + return $this->accessible; + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function setTitle(string $title): void { + $this->title = $title; + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function getTitle(): string { + return $this->title ?? $this->reference; + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function setDescription(?string $description): void { + $this->description = $description; + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function getDescription(): ?string { + return $this->description; + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function setImageUrl(?string $imageUrl): void { + $this->imageUrl = $imageUrl; + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function getImageUrl(): ?string { + return $this->imageUrl; + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function setImageContentType(?string $contentType): void { + $this->contentType = $contentType; + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function getImageContentType(): ?string { + return $this->contentType; + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function setUrl(?string $url): void { + $this->url = $url; + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function getUrl(): string { + return $this->url ?? $this->reference; + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function setRichObject(string $type, ?array $richObject): void { + $this->richObjectType = $type; + $this->richObject = $richObject; + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function getRichObjectType(): string { + if ($this->richObjectType === null) { + return 'open-graph'; + } + return $this->richObjectType; + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function getRichObject(): array { + if ($this->richObject === null) { + return $this->getOpenGraphObject(); + } + return $this->richObject; + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function getOpenGraphObject(): array { + return [ + 'id' => $this->getId(), + 'name' => $this->getTitle(), + 'description' => $this->getDescription(), + 'thumb' => $this->getImageUrl(), + 'link' => $this->getUrl() + ]; + } + + /** + * @param IReference $reference + * @return array + * @since 25.0.0 + */ + public static function toCache(IReference $reference): array { + return [ + 'id' => $reference->getId(), + 'title' => $reference->getTitle(), + 'imageUrl' => $reference->getImageUrl(), + 'imageContentType' => $reference->getImageContentType(), + 'description' => $reference->getDescription(), + 'link' => $reference->getUrl(), + 'accessible' => $reference->getAccessible(), + 'richObjectType' => $reference->getRichObjectType(), + 'richObject' => $reference->getRichObject(), + ]; + } + + /** + * @param array $cache + * @return IReference + * @since 25.0.0 + */ + public static function fromCache(array $cache): IReference { + $reference = new Reference($cache['id']); + $reference->setTitle($cache['title']); + $reference->setDescription($cache['description']); + $reference->setImageUrl($cache['imageUrl']); + $reference->setImageContentType($cache['imageContentType']); + $reference->setUrl($cache['link']); + $reference->setRichObject($cache['richObjectType'], $cache['richObject']); + $reference->setAccessible($cache['accessible']); + return $reference; + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function jsonSerialize() { + return [ + 'richObjectType' => $this->getRichObjectType(), + 'richObject' => $this->getRichObject(), + 'openGraphObject' => $this->getOpenGraphObject(), + 'accessible' => $this->accessible + ]; + } +} diff --git a/lib/public/Contacts/IManager.php b/lib/public/Contacts/IManager.php index 65be12c4c39..ce50f8d5b32 100644 --- a/lib/public/Contacts/IManager.php +++ b/lib/public/Contacts/IManager.php @@ -160,15 +160,6 @@ interface IManager { public function register(\Closure $callable); /** - * Return a list of the user's addressbooks display names - * - * @return array - * @since 6.0.0 - * @deprecated 16.0.0 - Use `$this->getUserAddressBooks()` instead - */ - public function getAddressBooks(); - - /** * Return a list of the user's addressbooks * * @return \OCP\IAddressBook[] diff --git a/lib/public/Dashboard/IConditionalWidget.php b/lib/public/Dashboard/IConditionalWidget.php new file mode 100644 index 00000000000..4fdeec700d3 --- /dev/null +++ b/lib/public/Dashboard/IConditionalWidget.php @@ -0,0 +1,44 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2022 Joas Schilling <coding@schilljs.com> + * + * @author 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\Dashboard; + +/** + * interface IConditionalWidget + * + * Allows an app to lazy-register a widget and in the lazy part of the code + * it can decide if the widget should really be registered. + * + * @since 26.0.0 + */ +interface IConditionalWidget extends IWidget { + + /** + * @return bool Whether the widget is enabled and should be registered + * @since 26.0.0 + */ + public function isEnabled(): bool; +} diff --git a/lib/public/Defaults.php b/lib/public/Defaults.php index 7c6d73bcaea..cbef0ec79a4 100644 --- a/lib/public/Defaults.php +++ b/lib/public/Defaults.php @@ -135,7 +135,7 @@ class Defaults { * name of your ownCloud instance containing HTML styles * @return string * @since 8.0.0 - * @depreacted 22.0.0 + * @deprecated 22.0.0 */ public function getHTMLName(): string { return $this->defaults->getHTMLName(); diff --git a/lib/public/Files/SimpleFS/ISimpleFolder.php b/lib/public/Files/SimpleFS/ISimpleFolder.php index 3c8e6e88ab3..ca60cc4c418 100644 --- a/lib/public/Files/SimpleFS/ISimpleFolder.php +++ b/lib/public/Files/SimpleFS/ISimpleFolder.php @@ -80,4 +80,21 @@ interface ISimpleFolder { * @since 11.0.0 */ public function getName(): string; + + /** + * Get the folder named $name from the current folder + * + * @throws NotFoundException + * @since 25.0.0 + */ + public function getFolder(string $name): ISimpleFolder; + + /** + * Creates a new folder with $name in the current folder + * + * @param string|resource|null $content @since 19.0.0 + * @throws NotPermittedException + * @since 25.0.0 + */ + public function newFolder(string $path): ISimpleFolder; } diff --git a/lib/public/Files/Storage.php b/lib/public/Files/Storage.php index 0a1a504b137..6f5a2f53673 100644 --- a/lib/public/Files/Storage.php +++ b/lib/public/Files/Storage.php @@ -244,22 +244,22 @@ interface Storage extends IStorage { /** * see https://www.php.net/manual/en/function.rename.php * - * @param string $path1 - * @param string $path2 + * @param string $source + * @param string $target * @return bool * @since 6.0.0 */ - public function rename($path1, $path2); + public function rename($source, $target); /** * see https://www.php.net/manual/en/function.copy.php * - * @param string $path1 - * @param string $path2 + * @param string $soruce + * @param string $target * @return bool * @since 6.0.0 */ - public function copy($path1, $path2); + public function copy($source, $target); /** * see https://www.php.net/manual/en/function.fopen.php diff --git a/lib/public/Files/Storage/IStorage.php b/lib/public/Files/Storage/IStorage.php index f42eb81bfec..eb5522909c6 100644 --- a/lib/public/Files/Storage/IStorage.php +++ b/lib/public/Files/Storage/IStorage.php @@ -241,22 +241,22 @@ interface IStorage { /** * see https://www.php.net/manual/en/function.rename.php * - * @param string $path1 - * @param string $path2 + * @param string $source + * @param string $target * @return bool * @since 9.0.0 */ - public function rename($path1, $path2); + public function rename($source, $target); /** * see https://www.php.net/manual/en/function.copy.php * - * @param string $path1 - * @param string $path2 + * @param string $source + * @param string $target * @return bool * @since 9.0.0 */ - public function copy($path1, $path2); + public function copy($source, $target); /** * see https://www.php.net/manual/en/function.fopen.php diff --git a/lib/public/Group/Events/GroupChangedEvent.php b/lib/public/Group/Events/GroupChangedEvent.php new file mode 100644 index 00000000000..9cb5007a916 --- /dev/null +++ b/lib/public/Group/Events/GroupChangedEvent.php @@ -0,0 +1,94 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright 2022 Anna Larch <anna.larch@gmx.net> + * + * @author Anna Larch <anna.larch@gmx.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\Group\Events; + +use OCP\EventDispatcher\Event; +use OCP\IGroup; + +/** + * @since 26.0.0 + */ +class GroupChangedEvent extends Event { + private IGroup $group; + private string $feature; + /** @var mixed */ + private $value; + /** @var mixed */ + private $oldValue; + + /** + * @since 26.0.0 + */ + public function __construct(IGroup $group, + string $feature, + $value, + $oldValue = null) { + parent::__construct(); + $this->group = $group; + $this->feature = $feature; + $this->value = $value; + $this->oldValue = $oldValue; + } + + /** + * + * @since 26.0.0 + * + * @return IGroup + */ + public function getGroup(): IGroup { + return $this->group; + } + + /** + * + * @since 26.0.0 + * + * @return string + */ + public function getFeature(): string { + return $this->feature; + } + + /** + * @since 26.0.0 + * + * @return mixed + */ + public function getValue() { + return $this->value; + } + + /** + * + * @since 26.0.0 + * + * @return mixed + */ + public function getOldValue() { + return $this->oldValue; + } +} diff --git a/lib/public/IGroupManager.php b/lib/public/IGroupManager.php index d942caac9b4..2e2685eeeb4 100644 --- a/lib/public/IGroupManager.php +++ b/lib/public/IGroupManager.php @@ -145,4 +145,14 @@ interface IGroupManager { * @since 8.0.0 */ public function isInGroup($userId, $group); + + /** + * Get the display name of a Nextcloud group + * + * @param string $groupId + * @return ?string display name, if any + * + * @since 26.0.0 + */ + public function getDisplayName(string $groupId): ?string; } diff --git a/lib/public/IImage.php b/lib/public/IImage.php index 659cd24720d..f1ac3bf1a50 100644 --- a/lib/public/IImage.php +++ b/lib/public/IImage.php @@ -1,4 +1,7 @@ <?php + +declare(strict_types=1); + /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -33,69 +36,60 @@ interface IImage { /** * Determine whether the object contains an image resource. * - * @return bool * @since 8.1.0 */ - public function valid(); + public function valid(): bool; /** - * Returns the MIME type of the image or an empty string if no image is loaded. + * Returns the MIME type of the image or null if no image is loaded. * - * @return string * @since 8.1.0 */ - public function mimeType(); + public function mimeType(): ?string; /** * Returns the width of the image or -1 if no image is loaded. * - * @return int * @since 8.1.0 */ - public function width(); + public function width(): int; /** * Returns the height of the image or -1 if no image is loaded. * - * @return int * @since 8.1.0 */ - public function height(); + public function height(): int; /** * Returns the width when the image orientation is top-left. * - * @return int * @since 8.1.0 */ - public function widthTopLeft(); + public function widthTopLeft(): int; /** * Returns the height when the image orientation is top-left. * - * @return int * @since 8.1.0 */ - public function heightTopLeft(); + public function heightTopLeft(): int; /** * Outputs the image. * - * @param string $mimeType - * @return bool * @since 8.1.0 */ - public function show($mimeType = null); + public function show(?string $mimeType = null): bool; /** * Saves the image. * * @param string $filePath * @param string $mimeType - * @return bool * @since 8.1.0 */ - public function save($filePath = null, $mimeType = null); + public function save(?string $filePath = null, ?string $mimeType = null): bool; /** * @return false|resource|\GdImage Returns the image resource if any @@ -104,16 +98,17 @@ interface IImage { public function resource(); /** - * @return string Returns the raw data mimetype + * @return string Returns the mimetype of the data. Returns null + * if the data is not valid. * @since 13.0.0 */ - public function dataMimeType(); + public function dataMimeType(): ?string; /** * @return string Returns the raw image data. * @since 8.1.0 */ - public function data(); + public function data(): ?string; /** * (I'm open for suggestions on better method name ;) @@ -122,25 +117,23 @@ interface IImage { * @return int The orientation or -1 if no EXIF data is available. * @since 8.1.0 */ - public function getOrientation(); + public function getOrientation(): int; /** * (I'm open for suggestions on better method name ;) * Fixes orientation based on EXIF data. * - * @return bool * @since 8.1.0 */ - public function fixOrientation(); + public function fixOrientation(): bool; /** * Resizes the image preserving ratio. * * @param integer $maxSize The maximum size of either the width or height. - * @return bool * @since 8.1.0 */ - public function resize($maxSize); + public function resize(int $maxSize): bool; /** * @param int $width @@ -157,7 +150,7 @@ interface IImage { * @return bool for success or failure * @since 8.1.0 */ - public function centerCrop($size = 0); + public function centerCrop(int $size = 0): bool; /** * Crops the image from point $x$y with dimension $wx$h. @@ -174,22 +167,22 @@ interface IImage { /** * Resizes the image to fit within a boundary while preserving ratio. * - * @param integer $maxWidth - * @param integer $maxHeight - * @return bool + * Warning: Images smaller than $maxWidth x $maxHeight will end up being scaled up + * + * @param int $maxWidth + * @param int $maxHeight * @since 8.1.0 */ - public function fitIn($maxWidth, $maxHeight); + public function fitIn(int $maxWidth, int $maxHeight): bool; /** * Shrinks the image to fit within a boundary while preserving ratio. * - * @param integer $maxWidth - * @param integer $maxHeight - * @return bool + * @param int $maxWidth + * @param int $maxHeight * @since 8.1.0 */ - public function scaleDownToFit($maxWidth, $maxHeight); + public function scaleDownToFit(int $maxWidth, int $maxHeight): bool; /** * create a copy of this image @@ -222,9 +215,9 @@ interface IImage { public function preciseResizeCopy(int $width, int $height): IImage; /** - * create a new resized copy of this image + * Resizes the image preserving ratio, returning a new copy * - * @param integer $maxSize The maximum size of either the width or height. + * @param int $maxSize The maximum size of either the width or height. * @return IImage * @since 19.0.0 */ diff --git a/lib/public/ITags.php b/lib/public/ITags.php index 03bcb845f4e..06497781bee 100644 --- a/lib/public/ITags.php +++ b/lib/public/ITags.php @@ -32,9 +32,6 @@ namespace OCP; use OC\Tags; -// FIXME: Where should I put this? Or should it be implemented as a Listener? -\OC_Hook::connect('OC_User', 'post_deleteUser', Tags::class, 'post_deleteUser'); - /** * Class for easily tagging objects by their id * @@ -55,11 +52,9 @@ interface ITags { /** * Check if any tags are saved for this type and user. - * - * @return boolean * @since 6.0.0 */ - public function isEmpty(); + public function isEmpty(): bool; /** * Returns an array mapping a given tag's properties to its values: @@ -69,34 +64,40 @@ interface ITags { * @return array|false * @since 8.0.0 */ - public function getTag($id); + public function getTag(string $id); /** * Get the tags for a specific user. * * This returns an array with id/name maps: + * + * ```php * [ * ['id' => 0, 'name' = 'First tag'], * ['id' => 1, 'name' = 'Second tag'], * ] + * ``` * - * @return array + * @return array<array-key, array{id: int, name: string}> * @since 6.0.0 */ - public function getTags(); + public function getTags(): array; /** * Get a list of tags for the given item ids. * * This returns an array with object id / tag names: + * + * ```php * [ * 1 => array('First tag', 'Second tag'), * 2 => array('Second tag'), * 3 => array('Second tag', 'Third tag'), * ] + * ``` * * @param array $objIds item ids - * @return array|boolean with object id as key and an array + * @return array|false with object id as key and an array * of tag names as value or false if an error occurred * @since 8.0.0 */ @@ -117,10 +118,9 @@ interface ITags { * Checks whether a tag is already saved. * * @param string $name The name to check for. - * @return bool * @since 6.0.0 */ - public function hasTag($name); + public function hasTag(string $name): bool; /** * Checks whether a tag is saved for the given user, @@ -131,7 +131,7 @@ interface ITags { * @return bool * @since 8.0.0 */ - public function userHasTag($name, $user); + public function userHasTag(string $name, string $user): bool; /** * Add a new tag. @@ -140,7 +140,7 @@ interface ITags { * @return int|false the id of the added tag or false if it already exists. * @since 6.0.0 */ - public function add($name); + public function add(string $name); /** * Rename tag. @@ -150,19 +150,19 @@ interface ITags { * @return bool * @since 6.0.0 */ - public function rename($from, $to); + public function rename($from, string $to): bool; /** * Add a list of new tags. * - * @param string[] $names A string with a name or an array of strings containing + * @param string|string[] $names A string with a name or an array of strings containing * the name(s) of the to add. * @param bool $sync When true, save the tags * @param int|null $id int Optional object id to add to this|these tag(s) * @return bool Returns false on error. * @since 6.0.0 */ - public function addMultiple($names, $sync = false, $id = null); + public function addMultiple($names, bool $sync = false, ?int $id = null): bool; /** * Delete tag/object relations from the db diff --git a/lib/public/IURLGenerator.php b/lib/public/IURLGenerator.php index 808ba66c862..b6d78876478 100644 --- a/lib/public/IURLGenerator.php +++ b/lib/public/IURLGenerator.php @@ -43,7 +43,16 @@ interface IURLGenerator { * * @since 25.0.0 */ - public const URL_REGEX = '/(\s|\n|^)(https?:\/\/)?((?:[-A-Z0-9+_]+\.)+[-A-Z]+(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|\n|$)/mi'; + public const URL_REGEX = '/' . self::URL_REGEX_NO_MODIFIERS . '/mi'; + + /** + * Regex for matching http(s) urls (without modifiers for client compatibility) + * + * This is a copy of the frontend regex in core/src/OCP/comments.js, make sure to adjust both when changing + * + * @since 25.0.0 + */ + public const URL_REGEX_NO_MODIFIERS = '(\s|\n|^)(https?:\/\/)((?:[-A-Z0-9+_]+\.)+[-A-Z]+(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|\n|$)'; /** * Returns the URL for a route diff --git a/lib/public/IUserManager.php b/lib/public/IUserManager.php index af0d5f08809..8caa027468b 100644 --- a/lib/public/IUserManager.php +++ b/lib/public/IUserManager.php @@ -212,4 +212,12 @@ interface IUserManager { * @since 9.1.0 */ public function getByEmail($email); + + /** + * @param string $uid The user ID to validate + * @param bool $checkDataDirectory Whether it should be checked if files for the ID exist inside the data directory + * @throws \InvalidArgumentException Message is an already translated string with a reason why the ID is not valid + * @since 26.0.0 + */ + public function validateUserId(string $uid, bool $checkDataDirectory = false): void; } diff --git a/lib/public/Migration/IMigrationStep.php b/lib/public/Migration/IMigrationStep.php index 1b5aa828994..da9f62e861e 100644 --- a/lib/public/Migration/IMigrationStep.php +++ b/lib/public/Migration/IMigrationStep.php @@ -27,6 +27,7 @@ declare(strict_types=1); */ namespace OCP\Migration; +use Closure; use OCP\DB\ISchemaWrapper; /** @@ -34,7 +35,7 @@ use OCP\DB\ISchemaWrapper; */ interface IMigrationStep { /** - * Human readable name of the migration step + * Human-readable name of the migration step * * @return string * @since 14.0.0 @@ -42,7 +43,7 @@ interface IMigrationStep { public function name(): string; /** - * Human readable description of the migration steps + * Human-readable description of the migration step * * @return string * @since 14.0.0 @@ -51,29 +52,29 @@ interface IMigrationStep { /** * @param IOutput $output - * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @psalm-param Closure():ISchemaWrapper $schemaClosure * @param array $options * @since 13.0.0 */ - public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options); + public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options); /** * @param IOutput $output - * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @psalm-param Closure():ISchemaWrapper $schemaClosure * @param array $options * @return null|ISchemaWrapper * @since 13.0.0 */ - public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options); + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options); /** * @param IOutput $output - * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @psalm-param Closure():ISchemaWrapper $schemaClosure * @param array $options * @since 13.0.0 */ - public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options); + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options); } diff --git a/lib/public/Migration/SimpleMigrationStep.php b/lib/public/Migration/SimpleMigrationStep.php index e8d19f533ac..ee657cda470 100644 --- a/lib/public/Migration/SimpleMigrationStep.php +++ b/lib/public/Migration/SimpleMigrationStep.php @@ -28,12 +28,15 @@ declare(strict_types=1); */ namespace OCP\Migration; +use Closure; +use OCP\DB\ISchemaWrapper; + /** * @since 13.0.0 */ abstract class SimpleMigrationStep implements IMigrationStep { /** - * Human readable name of the migration step + * Human-readable name of the migration step * * @return string * @since 14.0.0 @@ -43,7 +46,7 @@ abstract class SimpleMigrationStep implements IMigrationStep { } /** - * Human readable description of the migration step + * Human-readable description of the migration step * * @return string * @since 14.0.0 @@ -53,16 +56,21 @@ abstract class SimpleMigrationStep implements IMigrationStep { } /** - * {@inheritDoc} - * + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @psalm-param Closure():ISchemaWrapper $schemaClosure + * @param array $options * @since 13.0.0 */ public function preSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { } /** - * {@inheritDoc} - * + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @psalm-param Closure():ISchemaWrapper $schemaClosure + * @param array $options + * @return null|ISchemaWrapper * @since 13.0.0 */ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { @@ -70,8 +78,10 @@ abstract class SimpleMigrationStep implements IMigrationStep { } /** - * {@inheritDoc} - * + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @psalm-param Closure():ISchemaWrapper $schemaClosure + * @param array $options * @since 13.0.0 */ public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { diff --git a/lib/public/Notification/IManager.php b/lib/public/Notification/IManager.php index dbf4aab4ea4..82f0ced07ed 100644 --- a/lib/public/Notification/IManager.php +++ b/lib/public/Notification/IManager.php @@ -52,7 +52,7 @@ interface IManager extends IApp, INotifier { * @param string $notifierService The service must implement INotifier, otherwise a * \InvalidArgumentException is thrown later * @since 17.0.0 - * @depreacted 22.0.0 use the IBootStrap registration context + * @deprecated 22.0.0 use the IBootStrap registration context */ public function registerNotifierService(string $notifierService): void; diff --git a/lib/public/Preview/BeforePreviewFetchedEvent.php b/lib/public/Preview/BeforePreviewFetchedEvent.php new file mode 100644 index 00000000000..37da63b95a1 --- /dev/null +++ b/lib/public/Preview/BeforePreviewFetchedEvent.php @@ -0,0 +1,51 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2022 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\Preview; + +use OCP\Files\Node; + +/** + * @since 25.0.1 + */ +class BeforePreviewFetchedEvent extends \OCP\EventDispatcher\Event { + private Node $node; + + /** + * @since 25.0.1 + */ + public function __construct(Node $node) { + parent::__construct(); + $this->node = $node; + } + + /** + * @since 25.0.1 + */ + public function getNode(): Node { + return $this->node; + } +} diff --git a/lib/public/Profiler/IProfiler.php b/lib/public/Profiler/IProfiler.php index 78325089523..5fa4582add7 100644 --- a/lib/public/Profiler/IProfiler.php +++ b/lib/public/Profiler/IProfiler.php @@ -98,4 +98,10 @@ interface IProfiler { * @since 24.0.0 */ public function collect(Request $request, Response $response): IProfile; + + /** + * Clear the stored profiles + * @since 25.0.0 + */ + public function clear(): void; } diff --git a/lib/public/Security/IRemoteHostValidator.php b/lib/public/Security/IRemoteHostValidator.php new file mode 100644 index 00000000000..99f149aee04 --- /dev/null +++ b/lib/public/Security/IRemoteHostValidator.php @@ -0,0 +1,51 @@ +<?php + +declare(strict_types=1); + +/* + * @copyright 2022 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2022 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; + +/** + * Validator for remote hosts + * + * @since 26.0.0 + */ +interface IRemoteHostValidator { + + /** + * Validate if a host may be connected to + * + * By default, Nextcloud does not connect to any local servers. That is neither + * localhost nor any host in the local network. + * + * Admins can overwrite this behavior with the global `allow_local_remote_servers` + * settings flag. If the flag is set to `true`, local hosts will be considered + * valid. + * + * @param string $host hostname of the remote server, IPv4 or IPv6 address + * + * @return bool + * @since 26.0.0 + */ + public function isValid(string $host): bool; +} diff --git a/lib/public/Server.php b/lib/public/Server.php index f4522e8ae10..92560e2b17e 100644 --- a/lib/public/Server.php +++ b/lib/public/Server.php @@ -41,9 +41,11 @@ use Psr\Container\NotFoundExceptionInterface; final class Server { /** * @template T - * @template S as class-string<T>|string - * @param S $serviceName - * @return (S is class-string<T> ? T : mixed) + * @param class-string<T>|string $serviceName + * @return T|mixed + * @psalm-template S as class-string<T>|string + * @psalm-param S $serviceName + * @psalm-return (S is class-string<T> ? T : mixed) * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface * @since 25.0.0 diff --git a/lib/public/Share/IManager.php b/lib/public/Share/IManager.php index 0810acc673a..82a92428b31 100644 --- a/lib/public/Share/IManager.php +++ b/lib/public/Share/IManager.php @@ -211,7 +211,7 @@ interface IManager { * Verify the password of a public share * * @param IShare $share - * @param string $password + * @param ?string $password * @return bool * @since 9.0.0 */ diff --git a/lib/public/Support/Subscription/IAssertion.php b/lib/public/Support/Subscription/IAssertion.php new file mode 100644 index 00000000000..1ef6a7b7187 --- /dev/null +++ b/lib/public/Support/Subscription/IAssertion.php @@ -0,0 +1,44 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2022 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 <https://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Support\Subscription; + +use OCP\HintException; + +/** + * @since 26.0.0 + */ +interface IAssertion { + /** + * This method throws a localized exception when user limits are exceeded, + * if applicable. Notifications are also created in that case. It is a + * shorthand for a check against IRegistry::delegateIsHardUserLimitReached(). + * + * @throws HintException + * @since 26.0.0 + */ + public function createUserIsLegit(): void; +} diff --git a/lib/public/Talk/IBroker.php b/lib/public/Talk/IBroker.php index d28771544c8..705c39d2c01 100644 --- a/lib/public/Talk/IBroker.php +++ b/lib/public/Talk/IBroker.php @@ -71,4 +71,15 @@ interface IBroker { public function createConversation(string $name, array $moderators, IConversationOptions $options = null): IConversation; + + /** + * Delete a conversation by id + * + * @param string $id conversation id + * + * @return void + * @throws NoBackendException when Talk is not available + * @since 26.0.0 + */ + public function deleteConversation(string $id): void; } diff --git a/lib/public/Talk/IConversation.php b/lib/public/Talk/IConversation.php index 43698b9069f..efa33c0b357 100644 --- a/lib/public/Talk/IConversation.php +++ b/lib/public/Talk/IConversation.php @@ -31,6 +31,14 @@ namespace OCP\Talk; interface IConversation { /** + * Get the unique token that identifies this conversation + * + * @return string + * @since 26.0.0 + */ + public function getId(): string; + + /** * Get the absolute URL to this conversation * * @return string diff --git a/lib/public/Talk/ITalkBackend.php b/lib/public/Talk/ITalkBackend.php index 700d5d8c4d3..605a15680d0 100644 --- a/lib/public/Talk/ITalkBackend.php +++ b/lib/public/Talk/ITalkBackend.php @@ -49,4 +49,14 @@ interface ITalkBackend { public function createConversation(string $name, array $moderators, IConversationOptions $options): IConversation; + + /** + * Delete a conversation by id + * + * @param string $id conversation id + * + * @return void + * @since 26.0.0 + */ + public function deleteConversation(string $id): void; } diff --git a/lib/public/User/Backend/ICountMappedUsersBackend.php b/lib/public/User/Backend/ICountMappedUsersBackend.php new file mode 100644 index 00000000000..bf8770d484f --- /dev/null +++ b/lib/public/User/Backend/ICountMappedUsersBackend.php @@ -0,0 +1,39 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2022 Côme Chilliet <come.chilliet@nextcloud.com> + * + * @author Côme Chilliet <come.chilliet@nextcloud.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\User\Backend; + +/** + * @since 24.0.7 + */ +interface ICountMappedUsersBackend { + /** + * @since 24.0.7 + * + * @return int The number of users already mapped to a Nextcloud account + */ + public function countMappedUsers(): int; +} diff --git a/lib/public/Util.php b/lib/public/Util.php index 6cd3eaa7f85..b2b3322fe86 100644 --- a/lib/public/Util.php +++ b/lib/public/Util.php @@ -56,27 +56,6 @@ use bantu\IniGetWrapper\IniGetWrapper; * @since 4.0.0 */ class Util { - /** - * @deprecated 14.0.0 use \OCP\ILogger::DEBUG - */ - public const DEBUG = 0; - /** - * @deprecated 14.0.0 use \OCP\ILogger::INFO - */ - public const INFO = 1; - /** - * @deprecated 14.0.0 use \OCP\ILogger::WARN - */ - public const WARN = 2; - /** - * @deprecated 14.0.0 use \OCP\ILogger::ERROR - */ - public const ERROR = 3; - /** - * @deprecated 14.0.0 use \OCP\ILogger::FATAL - */ - public const FATAL = 4; - /** @var \OCP\Share\IManager */ private static $shareManager; @@ -344,11 +323,11 @@ class Util { * is passed to this function * @since 5.0.0 */ - public static function getDefaultEmailAddress($user_part) { + public static function getDefaultEmailAddress(string $user_part): string { $config = \OC::$server->getConfig(); - $user_part = $config->getSystemValue('mail_from_address', $user_part); + $user_part = $config->getSystemValueString('mail_from_address', $user_part); $host_name = self::getServerHostName(); - $host_name = $config->getSystemValue('mail_domain', $host_name); + $host_name = $config->getSystemValueString('mail_domain', $host_name); $defaultEmailAddress = $user_part.'@'.$host_name; $mailer = \OC::$server->getMailer(); |