diff options
Diffstat (limited to 'apps/workflowengine/lib/Controller')
5 files changed, 63 insertions, 142 deletions
diff --git a/apps/workflowengine/lib/Controller/AWorkflowController.php b/apps/workflowengine/lib/Controller/AWorkflowController.php index 77e50526092..6395d0d98f6 100644 --- a/apps/workflowengine/lib/Controller/AWorkflowController.php +++ b/apps/workflowengine/lib/Controller/AWorkflowController.php @@ -3,33 +3,15 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author blizzz <blizzz@arthur-schiwon.de> - * @author 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/>. - * + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\WorkflowEngine\Controller; use Doctrine\DBAL\Exception; use OCA\WorkflowEngine\Helper\ScopeContext; use OCA\WorkflowEngine\Manager; +use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCS\OCSBadRequestException; use OCP\AppFramework\OCS\OCSException; @@ -40,22 +22,13 @@ use Psr\Log\LoggerInterface; abstract class AWorkflowController extends OCSController { - /** @var Manager */ - protected $manager; - - /** @var LoggerInterface */ - private $logger; - public function __construct( $appName, IRequest $request, - Manager $manager, - LoggerInterface $logger + protected Manager $manager, + private LoggerInterface $logger, ) { parent::__construct($appName, $request); - - $this->manager = $manager; - $this->logger = $logger; } /** @@ -103,13 +76,14 @@ abstract class AWorkflowController extends OCSController { * @throws OCSForbiddenException * @throws OCSException */ + #[PasswordConfirmationRequired] public function create( string $class, string $name, array $checks, string $operation, string $entity, - array $events + array $events, ): DataResponse { $context = $this->getScopeContext(); try { @@ -131,13 +105,14 @@ abstract class AWorkflowController extends OCSController { * @throws OCSForbiddenException * @throws OCSException */ + #[PasswordConfirmationRequired] public function update( int $id, string $name, array $checks, string $operation, string $entity, - array $events + array $events, ): DataResponse { try { $context = $this->getScopeContext(); @@ -159,6 +134,7 @@ abstract class AWorkflowController extends OCSController { * @throws OCSForbiddenException * @throws OCSException */ + #[PasswordConfirmationRequired] public function destroy(int $id): DataResponse { try { $deleted = $this->manager->deleteOperation($id, $this->getScopeContext()); diff --git a/apps/workflowengine/lib/Controller/GlobalWorkflowsController.php b/apps/workflowengine/lib/Controller/GlobalWorkflowsController.php index 8778f85365f..001c673df35 100644 --- a/apps/workflowengine/lib/Controller/GlobalWorkflowsController.php +++ b/apps/workflowengine/lib/Controller/GlobalWorkflowsController.php @@ -3,26 +3,8 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author 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/>. - * + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\WorkflowEngine\Controller; diff --git a/apps/workflowengine/lib/Controller/RequestTime.php b/apps/workflowengine/lib/Controller/RequestTime.php deleted file mode 100644 index a1d9ff4a630..00000000000 --- a/apps/workflowengine/lib/Controller/RequestTime.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php -/** - * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> - * - * @author Joas Schilling <coding@schilljs.com> - * @author Morris Jobke <hey@morrisjobke.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 OCA\WorkflowEngine\Controller; - -use OCP\AppFramework\Controller; -use OCP\AppFramework\Http\JSONResponse; - -class RequestTime extends Controller { - - /** - * @NoAdminRequired - * - * @param string $search - * @return JSONResponse - */ - public function getTimezones($search = '') { - $timezones = \DateTimeZone::listIdentifiers(); - - if ($search !== '') { - $timezones = array_filter($timezones, function ($timezone) use ($search) { - return stripos($timezone, $search) !== false; - }); - } - - $timezones = array_slice($timezones, 0, 10); - - $response = []; - foreach ($timezones as $timezone) { - $response[$timezone] = $timezone; - } - return new JSONResponse($response); - } -} diff --git a/apps/workflowengine/lib/Controller/RequestTimeController.php b/apps/workflowengine/lib/Controller/RequestTimeController.php new file mode 100644 index 00000000000..4b34f16ce0a --- /dev/null +++ b/apps/workflowengine/lib/Controller/RequestTimeController.php @@ -0,0 +1,37 @@ +<?php + +/** + * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCA\WorkflowEngine\Controller; + +use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; +use OCP\AppFramework\Http\JSONResponse; + +class RequestTimeController extends Controller { + + /** + * @param string $search + * @return JSONResponse + */ + #[NoAdminRequired] + public function getTimezones($search = '') { + $timezones = \DateTimeZone::listIdentifiers(); + + if ($search !== '') { + $timezones = array_filter($timezones, function ($timezone) use ($search) { + return stripos($timezone, $search) !== false; + }); + } + + $timezones = array_slice($timezones, 0, 10); + + $response = []; + foreach ($timezones as $timezone) { + $response[$timezone] = $timezone; + } + return new JSONResponse($response); + } +} diff --git a/apps/workflowengine/lib/Controller/UserWorkflowsController.php b/apps/workflowengine/lib/Controller/UserWorkflowsController.php index dd2457dd9e8..953ce149233 100644 --- a/apps/workflowengine/lib/Controller/UserWorkflowsController.php +++ b/apps/workflowengine/lib/Controller/UserWorkflowsController.php @@ -3,32 +3,15 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2019 Arthur Schiwon <blizzz@arthur-schiwon.de> - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @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/>. - * + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\WorkflowEngine\Controller; use OCA\WorkflowEngine\Helper\ScopeContext; use OCA\WorkflowEngine\Manager; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; +use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCS\OCSBadRequestException; use OCP\AppFramework\OCS\OCSForbiddenException; @@ -39,9 +22,6 @@ use Psr\Log\LoggerInterface; class UserWorkflowsController extends AWorkflowController { - /** @var IUserSession */ - private $session; - /** @var ScopeContext */ private $scopeContext; @@ -49,12 +29,10 @@ class UserWorkflowsController extends AWorkflowController { $appName, IRequest $request, Manager $manager, - IUserSession $session, - LoggerInterface $logger + private IUserSession $session, + LoggerInterface $logger, ) { parent::__construct($appName, $request, $manager, $logger); - - $this->session = $session; } /** @@ -62,45 +40,47 @@ class UserWorkflowsController extends AWorkflowController { * * Example: curl -u joann -H "OCS-APIREQUEST: true" "http://my.nc.srvr/ocs/v2.php/apps/workflowengine/api/v1/workflows/user?format=json" * - * @NoAdminRequired * @throws OCSForbiddenException */ + #[NoAdminRequired] public function index(): DataResponse { return parent::index(); } /** - * @NoAdminRequired - * * Example: curl -u joann -H "OCS-APIREQUEST: true" "http://my.nc.srvr/ocs/v2.php/apps/workflowengine/api/v1/workflows/user/OCA\\Workflow_DocToPdf\\Operation?format=json" * @throws OCSForbiddenException */ + #[NoAdminRequired] public function show(string $id): DataResponse { return parent::show($id); } /** - * @NoAdminRequired * @throws OCSBadRequestException * @throws OCSForbiddenException */ + #[NoAdminRequired] + #[PasswordConfirmationRequired] public function create(string $class, string $name, array $checks, string $operation, string $entity, array $events): DataResponse { return parent::create($class, $name, $checks, $operation, $entity, $events); } /** - * @NoAdminRequired * @throws OCSBadRequestException * @throws OCSForbiddenException */ + #[NoAdminRequired] + #[PasswordConfirmationRequired] public function update(int $id, string $name, array $checks, string $operation, string $entity, array $events): DataResponse { return parent::update($id, $name, $checks, $operation, $entity, $events); } /** - * @NoAdminRequired * @throws OCSForbiddenException */ + #[NoAdminRequired] + #[PasswordConfirmationRequired] public function destroy(int $id): DataResponse { return parent::destroy($id); } |