diff options
-rw-r--r-- | core/Application.php | 3 | ||||
-rw-r--r-- | core/Controller/OCSController.php | 88 | ||||
-rw-r--r-- | core/routes.php | 4 | ||||
-rw-r--r-- | lib/private/OCS/Cloud.php | 55 | ||||
-rw-r--r-- | lib/private/Route/Router.php | 5 | ||||
-rw-r--r-- | lib/private/legacy/ocs/cloud.php | 28 | ||||
-rw-r--r-- | ocs/routes.php | 15 |
7 files changed, 100 insertions, 98 deletions
diff --git a/core/Application.php b/core/Application.php index a0deaff2b93..e8c924432d1 100644 --- a/core/Application.php +++ b/core/Application.php @@ -186,6 +186,9 @@ class Application extends App { $container->registerService('TwoFactorAuthManager', function(SimpleContainer $c) { return $c->query('ServerContainer')->getTwoFactorAuthManager(); }); + $container->registerService('OC\CapabilitiesManager', function(SimpleContainer $c) { + return $c->query('ServerContainer')->getCapabilitiesManager(); + }); } } diff --git a/core/Controller/OCSController.php b/core/Controller/OCSController.php new file mode 100644 index 00000000000..d5783ae32e9 --- /dev/null +++ b/core/Controller/OCSController.php @@ -0,0 +1,88 @@ +<?php +/** + * + * @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 OC\Core\Controller; + +use OC\CapabilitiesManager; +use OCP\AppFramework\Http\DataResponse; +use OCP\IRequest; +use OCP\IUserSession; + +class OCSController extends \OCP\AppFramework\OCSController { + + /** @var CapabilitiesManager */ + private $capabilitiesManager; + + /** @var IUserSession */ + private $userSession; + + /** + * OCSController constructor. + * + * @param string $appName + * @param IRequest $request + * @param CapabilitiesManager $capabilitiesManager + * @param IUserSession $userSession + */ + public function __construct($appName, + IRequest $request, + CapabilitiesManager $capabilitiesManager, + IUserSession $userSession) { + parent::__construct($appName, $request); + + $this->capabilitiesManager = $capabilitiesManager; + $this->userSession = $userSession; + } + + /** + * @NoAdminRequired + * @return DataResponse + */ + public function getCapabilities() { + $result = []; + list($major, $minor, $micro) = \OCP\Util::getVersion(); + $result['version'] = array( + 'major' => $major, + 'minor' => $minor, + 'micro' => $micro, + 'string' => \OC_Util::getVersionString(), + 'edition' => \OC_Util::getEditionString(), + ); + + $result['capabilities'] = $this->capabilitiesManager->getCapabilities(); + + return new DataResponse(['data' => $result]); + } + + /** + * @NoAdminRequired + * @return DataResponse + */ + public function getCurrentUser() { + $userObject = $this->userSession->getUser(); + $data = [ + 'id' => $userObject->getUID(), + 'display-name' => $userObject->getDisplayName(), + 'email' => $userObject->getEMailAddress(), + ]; + return new DataResponse(['data' => $data]); + } +} diff --git a/core/routes.php b/core/routes.php index 98454946d45..b4868c14cf3 100644 --- a/core/routes.php +++ b/core/routes.php @@ -53,6 +53,10 @@ $application->registerRoutes($this, [ ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], ], + 'ocs' => [ + ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], + ['root' => '/cloud', 'name' => 'OCS#getCurrentUser', 'url' => '/user', 'verb' => 'GET'], + ], ]); // Post installation check diff --git a/lib/private/OCS/Cloud.php b/lib/private/OCS/Cloud.php deleted file mode 100644 index 84fcfe6e512..00000000000 --- a/lib/private/OCS/Cloud.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php -/** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * @author Tom Needham <tom@owncloud.com> - * - * @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 OC\OCS; - -class Cloud { - - public static function getCapabilities() { - $result = array(); - list($major, $minor, $micro) = \OCP\Util::getVersion(); - $result['version'] = array( - 'major' => $major, - 'minor' => $minor, - 'micro' => $micro, - 'string' => \OC_Util::getVersionString(), - 'edition' => \OC_Util::getEditionString(), - ); - - $result['capabilities'] = \OC::$server->getCapabilitiesManager()->getCapabilities(); - - return new Result($result); - } - - public static function getCurrentUser() { - $userObject = \OC::$server->getUserManager()->get(\OC_User::getUser()); - $data = array( - 'id' => $userObject->getUID(), - 'display-name' => $userObject->getDisplayName(), - 'email' => $userObject->getEMailAddress(), - ); - return new Result($data); - } -} diff --git a/lib/private/Route/Router.php b/lib/private/Route/Router.php index 9df74184448..59f403d66e8 100644 --- a/lib/private/Route/Router.php +++ b/lib/private/Route/Router.php @@ -163,6 +163,11 @@ class Router implements IRouter { $this->useCollection('root'); require_once __DIR__ . '/../../../settings/routes.php'; require_once __DIR__ . '/../../../core/routes.php'; + + // Also add the OCS collection + $collection = $this->getCollection('root.ocs'); + $collection->addPrefix('/ocsapp'); + $this->root->addCollection($collection); } if ($this->loaded) { // include ocs routes, must be loaded last for /ocs prefix diff --git a/lib/private/legacy/ocs/cloud.php b/lib/private/legacy/ocs/cloud.php deleted file mode 100644 index 11152958301..00000000000 --- a/lib/private/legacy/ocs/cloud.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @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/> - * - */ - -/** - * @deprecated Since 9.1.0 use \OC\OCS\Cloud - */ -class OC_OCS_Cloud extends \OC\OCS\Cloud { -} diff --git a/ocs/routes.php b/ocs/routes.php index 0606fe3e309..ae2ef05adcd 100644 --- a/ocs/routes.php +++ b/ocs/routes.php @@ -83,21 +83,6 @@ API::register( 'core', API::USER_AUTH ); -// cloud -API::register( - 'get', - '/cloud/capabilities', - array('OC_OCS_Cloud', 'getCapabilities'), - 'core', - API::USER_AUTH - ); -API::register( - 'get', - '/cloud/user', - array('OC_OCS_Cloud', 'getCurrentUser'), - 'core', - API::USER_AUTH -); // Server-to-Server Sharing if (\OC::$server->getAppManager()->isEnabledForUser('files_sharing')) { |