diff options
author | Georg Ehrke <developer@georgehrke.com> | 2015-05-26 17:52:56 +0300 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-09-23 11:02:38 +0300 |
commit | 4d68e05abf5ef8902cec6246cb8cc2e37af5dcfe (patch) | |
tree | 8273ab5159e5d3aa3be76a365e88d5bc198fbea1 /lib | |
parent | 8a3f8530fc5f64c55c861d0f5e0dc01d3fab7bf7 (diff) |
remove static methods and add unit tests
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/config.php | 76 | ||||
-rwxr-xr-x | lib/firstrunwizard.php | 54 | ||||
-rw-r--r-- | lib/util.php | 39 |
3 files changed, 111 insertions, 58 deletions
diff --git a/lib/config.php b/lib/config.php new file mode 100755 index 00000000..e0408910 --- /dev/null +++ b/lib/config.php @@ -0,0 +1,76 @@ +<?php + +/** + * ownCloud - firstrunwizard App + * + * @author Frank Karlitschek + * @copyright 2012 Frank Karlitschek frank@owncloud.org + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library 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 library. If not, see <http://www.gnu.org/licenses/>. + * + */ +namespace OCA\FirstRunWizard; + +use OCP\IConfig; +use OCP\IUserSession; + +class Config { + + protected $config; + + protected $userSession; + + /** + * @param IConfig $config + * @param IUserSession $userSession + */ + public function __construct(IConfig $config, IUserSession $userSession) { + $this->config = $config; + $this->userSession = $userSession; + } + + /** + * @brief Disable the FirstRunWizard + */ + public function enable() { + $user = $this->userSession->getUser(); + if ($user) { + $this->config->setUserValue($user->getUID(), 'firstrunwizard', 'show', 1); + } + } + + /** + * @brief Enable the FirstRunWizard + */ + public function disable() { + $user = $this->userSession->getUser(); + if ($user) { + $this->config->setUserValue($user->getUID(), 'firstrunwizard', 'show', 0); + } + } + + /** + * @brief Check if the FirstRunWizard is enabled or not + * @return bool + */ + public function isEnabled() { + $user = $this->userSession->getUser(); + if ($user) { + $conf = $this->config->getUserValue($user->getUID(), 'firstrunwizard', 'show', 1); + return (intval($conf) === 1); + } else { + return false; + } + } +} diff --git a/lib/firstrunwizard.php b/lib/firstrunwizard.php deleted file mode 100755 index 58f0b8ec..00000000 --- a/lib/firstrunwizard.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php - -/** - * ownCloud - firstrunwizard App - * - * @author Frank Karlitschek - * @copyright 2012 Frank Karlitschek frank@owncloud.org - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE - * License as published by the Free Software Foundation; either - * version 3 of the License, or any later version. - * - * This library 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 library. If not, see <http://www.gnu.org/licenses/>. - * - */ - - -namespace OCA_FirstRunWizard; - -class Config { - - /** - * @brief Disable the FirstRunWizard - */ - public static function enable() { - \OCP\Config::setUserValue( \OCP\User::getUser(), 'firstrunwizard', 'show', 1 ); - } - - /** - * @brief Enable the FirstRunWizard - */ - public static function disable() { - \OCP\Config::setUserValue( \OCP\User::getUser(), 'firstrunwizard', 'show', 0 ); - } - - /** - * @brief Check if the FirstRunWizard is enabled or not - * @return bool - */ - public static function isEnabled() { - $conf = \OCP\CONFIG::getUserValue( \OCP\User::getUser() , 'firstrunwizard' , 'show' , 1 ); - return (intval($conf) === 1); - } - - - -} diff --git a/lib/util.php b/lib/util.php index 318033e2..5f10c0ee 100644 --- a/lib/util.php +++ b/lib/util.php @@ -20,19 +20,50 @@ * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ - namespace OCA\FirstRunWizard; +use OCP\App\IAppManager; +use OCP\Defaults; +use OCP\IConfig; + class Util { + protected $appManager; + + protected $config; + + protected $defaults; + + /** + * @param IAppManager $appManager + * @param IConfig $config + * @param Defaults $defaults + */ + public function __construct(IAppManager $appManager, IConfig $config, Defaults $defaults) { + $this->appManager = $appManager; + $this->config = $config; + $this->defaults = $defaults; + } + /** * mimic \OC_Util::getEditionString() * @return string */ - public static function getEdition() { - if (\OC::$server->getAppManager()->isEnabledForUser('enterprise_key')) { - return "Enterprise"; + public function getEdition() { + if ($this->appManager->isEnabledForUser('enterprise_key')) { + return 'Enterprise'; } return ''; } + + /** + * @return array + */ + public function getSyncClientUrls() { + return array( + 'desktop' => $this->config->getSystemValue('customclient_desktop', $this->defaults->getSyncClientUrl()), + 'android' => $this->config->getSystemValue('customclient_android', $this->defaults->getAndroidClientUrl()), + 'ios' => $this->config->getSystemValue('customclient_ios', $this->defaults->getiOSClientUrl()) + ); + } }
\ No newline at end of file |