Skip to content

Commit

Permalink
Merge pull request owncloud#23 from owncloud/make_pass_appcode_check
Browse files Browse the repository at this point in the history
make app code compliant to public interface policy
  • Loading branch information
MorrisJobke committed Sep 23, 2015
2 parents 3bdf3b5 + 4d68e05 commit 46daa41
Show file tree
Hide file tree
Showing 14 changed files with 532 additions and 147 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
# test coverage
tests/clover.xml
34 changes: 16 additions & 18 deletions .travis.yml
Expand Up @@ -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
Expand All @@ -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://raw.githubusercontent.com/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
52 changes: 28 additions & 24 deletions ajax/disable.php
@@ -1,30 +1,34 @@
<?php

/**
* 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 <http://www.gnu.org/licenses/>.
*
*/
* 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 <http://www.gnu.org/licenses/>.
*
*/
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();
52 changes: 28 additions & 24 deletions ajax/enable.php
@@ -1,30 +1,34 @@
<?php

/**
* 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 <http://www.gnu.org/licenses/>.
*
*/
* 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 <http://www.gnu.org/licenses/>.
*
*/
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();
19 changes: 11 additions & 8 deletions appinfo/app.php
@@ -1,5 +1,4 @@
<?php

/**
* ownCloud - firstrunwizard App
*
Expand All @@ -20,16 +19,20 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
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');
}
76 changes: 76 additions & 0 deletions 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;
}
}
}
58 changes: 0 additions & 58 deletions lib/firstrunwizard.php

This file was deleted.

0 comments on commit 46daa41

Please sign in to comment.