From 4531545c6102a06fee7ea9a31f65375a866c257c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 17 Oct 2016 12:21:44 +0200 Subject: Use PSR-4 loading for normal files Signed-off-by: Joas Schilling --- lib/Controller/AliasesController.php | 103 +++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 lib/Controller/AliasesController.php (limited to 'lib/Controller/AliasesController.php') diff --git a/lib/Controller/AliasesController.php b/lib/Controller/AliasesController.php new file mode 100644 index 000000000..7ce23850e --- /dev/null +++ b/lib/Controller/AliasesController.php @@ -0,0 +1,103 @@ + + * + * Mail + * + * 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 + * + */ + +namespace OCA\Mail\Controller; + +use OCA\Mail\Db\Alias; +use OCP\IRequest; +use OCA\Mail\Service\AliasesService; +use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\JSONResponse; +use OCP\AppFramework\Http; +use OCP\IUserSession; + +class AliasesController extends Controller { + + /** @var AliasesService */ + private $aliasService; + + /** + * @var \OCP\IUser + */ + private $currentUser; + + /** + * @param string $appName + * @param IRequest $request + * @param AliasesService $aliasesService + */ + public function __construct($appName, IRequest $request, AliasesService $aliasesService, IUserSession $userSession) { + parent::__construct($appName, $request); + $this->aliasService = $aliasesService; + $this->currentUser = $userSession->getUser(); + } + + /** + * @NoAdminRequired + * @NoCSRFRequired + * @param int $accountId + * @return Alias[] + */ + public function index($accountId) { + return $this->aliasService->findAll($accountId, $this->currentUser->getUID()); + } + + /** + * @NoAdminRequired + * @NoCSRFRequired + */ + public function show() { + $response = new JSONResponse(); + $response->setStatus(Http::STATUS_NOT_IMPLEMENTED); + return $response; + } + + /** + * @NoAdminRequired + * @NoCSRFRequired + */ + public function update() { + $response = new JSONResponse(); + $response->setStatus(Http::STATUS_NOT_IMPLEMENTED); + return $response; + } + + /** + * @NoAdminRequired + * @NoCSRFRequired + * @param int $id + * @return Alias[] + */ + public function destroy($id) { + return $this->aliasService->delete($id, $this->currentUser->getUID()); + } + + /** + * @NoAdminRequired + * @NoCSRFRequired + * @param int $accountId + * @param string $alias + * @param string $aliasName + * @return Alias[] + */ + public function create($accountId, $alias, $aliasName) { + return $this->aliasService->create($accountId, $alias, $aliasName); + } +} -- cgit v1.2.3