diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..9ae0879d2fe8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# test coverage +tests/clover.xml diff --git a/.travis.yml b/.travis.yml index 82390afda434..1fc847f26ea7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,13 +3,7 @@ language: php # list any PHP version you want to test against php: - # using major version aliases - - # aliased to a recent 5.3.x version - - 5.3 - # aliased to a recent 5.4.x version - 5.4 - # aliased to a recent 5.5.x version - 5.5 # aliased to a recent 5.5.x version - 5.6 @@ -21,18 +15,22 @@ php: # - DB=mysql # - DB=pgsql -# execute any number of scripts before the test run, custom env's are available as variables -#before_script: -# - if [[ "$DB" == "pgsql" ]]; then psql -c "DROP DATABASE IF EXISTS hello_world_test;" -U postgres; fi -# - if [[ "$DB" == "pgsql" ]]; then psql -c "create database hello_world_test;" -U postgres; fi -# - if [[ "$DB" == "mysql" ]]; then mysql -e "create database IF NOT EXISTS hello_world_test;" -uroot; fi +env: + matrix: + - DB=sqlite + +before_install: + - wget https://github.com/raw/owncloud/administration/master/travis-ci/before_install.sh + - bash ./before_install.sh firstrunwizard master $DB + - cd ../core + - php occ app:enable firstrunwizard -# omitting "script:" will default to phpunit -# use the $DB env variable to determine the phpunit.xml to use -#script: phpunit --configuration phpunit_$DB.xml --coverage-text -script: ant test +before_script: + - cd apps/firstrunwizard -# configure notifications (email, IRC, campfire etc) -#notifications: -# irc: "irc.freenode.org#travis" +script: + - cd tests + - phpunit --configuration phpunit.xml +allow_failures: + - php: hhvm diff --git a/ajax/disable.php b/ajax/disable.php index f25b65eee929..abb021176bcd 100644 --- a/ajax/disable.php +++ b/ajax/disable.php @@ -1,30 +1,34 @@ . -* -*/ + * ownCloud - firstrunwizard application + * + * @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 . + * + */ +namespace OCA\FirstRunWizard; -OCP\JSON::checkLoggedIn(); -OCP\JSON::checkAppEnabled('firstrunwizard'); -OCP\JSON::callCheck(); +use OCP\JSON; -\OCA_FirstRunWizard\Config::disable(); +JSON::checkLoggedIn(); +JSON::checkAppEnabled('firstrunwizard'); +JSON::callCheck(); +$config = \OC::$server->getConfig(); +$userSession = \OC::$server->getUserSession(); +$firstRunConfig = new Config($config, $userSession); +$firstRunConfig->disable(); diff --git a/ajax/enable.php b/ajax/enable.php index 8fb749b477ee..903627136f24 100644 --- a/ajax/enable.php +++ b/ajax/enable.php @@ -1,30 +1,34 @@ . -* -*/ + * ownCloud - firstrunwizard application + * + * @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 . + * + */ +namespace OCA\FirstRunWizard; -OCP\JSON::checkLoggedIn(); -OCP\JSON::checkAppEnabled('firstrunwizard'); -OCP\JSON::callCheck(); +use OCP\JSON; -\OCA_FirstRunWizard\Config::enable(); +JSON::checkLoggedIn(); +JSON::checkAppEnabled('firstrunwizard'); +JSON::callCheck(); +$config = \OC::$server->getConfig(); +$userSession = \OC::$server->getUserSession(); +$firstRunConfig = new Config($config, $userSession); +$firstRunConfig->enable(); diff --git a/appinfo/app.php b/appinfo/app.php index 7a1e36f1d709..8286f85619f2 100755 --- a/appinfo/app.php +++ b/appinfo/app.php @@ -1,5 +1,4 @@ . * */ +namespace OCA\FirstRunWizard; +use OCP\Util; -OC::$CLASSPATH['OCA_FirstRunWizard\Config'] = 'firstrunwizard/lib/firstrunwizard.php'; +Util::addStyle('firstrunwizard', 'colorbox'); +Util::addScript('firstrunwizard', 'jquery.colorbox'); +Util::addScript('firstrunwizard', 'firstrunwizard'); -OCP\Util::addStyle( 'firstrunwizard', 'colorbox'); -OCP\Util::addScript( 'firstrunwizard', 'jquery.colorbox'); -OCP\Util::addScript( 'firstrunwizard', 'firstrunwizard'); +Util::addStyle('firstrunwizard', 'firstrunwizard'); -OCP\Util::addStyle('firstrunwizard', 'firstrunwizard'); +$config = \OC::$server->getConfig(); +$userSession = \OC::$server->getUserSession(); +$firstRunConfig = new Config($config, $userSession); -if(\OCP\User::isLoggedIn() and \OCA_FirstRunWizard\Config::isenabled()){ - OCP\Util::addScript( 'firstrunwizard', 'activate'); +if ($userSession->isLoggedIn() && $firstRunConfig->isEnabled()) { + Util::addScript( 'firstrunwizard', 'activate'); } diff --git a/lib/config.php b/lib/config.php new file mode 100755 index 000000000000..e04089104bfa --- /dev/null +++ b/lib/config.php @@ -0,0 +1,76 @@ +. + * + */ +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 24a4f60e3e61..000000000000 --- a/lib/firstrunwizard.php +++ /dev/null @@ -1,58 +0,0 @@ -. - * - */ - - -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 ); - if($conf==1) { - return(true); - }else{ - return(false); - } - } - - - -} diff --git a/lib/util.php b/lib/util.php new file mode 100644 index 000000000000..5f10c0ee569e --- /dev/null +++ b/lib/util.php @@ -0,0 +1,69 @@ +. + * + */ +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 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 diff --git a/templates/wizard.php b/templates/wizard.php index df5122ef52fd..b5d51e2a9198 100644 --- a/templates/wizard.php +++ b/templates/wizard.php @@ -4,7 +4,7 @@

t('Welcome to %s', array($theme->getTitle()))); ?>

- +

t('Your personal web services. All your files, contacts, calendar and more, in one place.'));?>

getSlogan()); ?>

@@ -25,7 +25,7 @@ alt="t('iOS app'));?>" /> - +

t('Connect your desktop apps to %s', array($theme->getName()))); ?>

- + t('There’s more information in the documentation and on our website.', array(link_to_docs('user_manual')))); ?>
t('If you like ownCloud, + + + . + + + + + ../firstrunwizard + + ../firstrunwizard/l10n + ../firstrunwizard/tests + + + + + + + + \ No newline at end of file diff --git a/wizard.php b/wizard.php index 0811d3736cb0..e412371c0276 100644 --- a/wizard.php +++ b/wizard.php @@ -20,22 +20,24 @@ * License along with this library. If not, see . * */ +namespace OCA\FirstRunWizard; +use OCP\Defaults; +use OCP\User; +use OCP\Util as CoreUtil; +use OCP\Template; // Check if we are a user -OCP\User::checkLoggedIn(); +User::checkLoggedIn(); -$defaults = new \OCP\Defaults(); +$appManager = \OC::$server->getAppManager(); +$config = \OC::$server->getConfig(); +$defaults = new Defaults(); -//links to clients -$clients = array( - 'desktop' => OCP\Config::getSystemValue('customclient_desktop', $defaults->getSyncClientUrl()), - 'android' => OCP\Config::getSystemValue('customclient_android', $defaults->getAndroidClientUrl()), - 'ios' => OCP\Config::getSystemValue('customclient_ios', $defaults->getiOSClientUrl()) -); +$util = new Util($appManager, $config, $defaults); -$tmpl = new OCP\Template( 'firstrunwizard', 'wizard', '' ); -$tmpl->assign('logo', OCP\Util::linkTo('core','img/logo-inverted.svg')); -$tmpl->assign('clients', $clients); +$tmpl = new Template('firstrunwizard', 'wizard', ''); +$tmpl->assign('logo', CoreUtil::linkTo('core','img/logo-inverted.svg')); +$tmpl->assign('clients', $util->getSyncClientUrls()); +$tmpl->assign('edition', $util->getEdition()); $tmpl->printPage(); -