Merge pull request #894 from nextcloud/stable10-implement_712

[Stable10] Backport 796
This commit is contained in:
Lukas Reschke 2016-08-17 09:39:35 +02:00 committed by GitHub
commit a2942c3e94
106 changed files with 5650 additions and 1354 deletions

View File

@ -19,7 +19,7 @@
<admin>admin-encryption</admin>
</documentation>
<rememberlogin>false</rememberlogin>
<version>1.3.0</version>
<version>1.3.1</version>
<types>
<filesystem/>
</types>
@ -27,5 +27,7 @@
<lib>openssl</lib>
<owncloud min-version="9.1" max-version="9.1" />
</dependencies>
<settings>
<admin>OCA\Encryption\Settings\Admin</admin>
</settings>
</info>

View File

@ -269,7 +269,6 @@ class Application extends \OCP\AppFramework\App {
public function registerSettings() {
// Register settings scripts
App::registerAdmin('encryption', 'settings/settings-admin');
App::registerPersonal('encryption', 'settings/settings-personal');
}
}

View File

@ -0,0 +1,127 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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 OCA\Encryption\Settings;
use OC\Files\View;
use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\Session;
use OCA\Encryption\Util;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IL10N;
use OCP\ILogger;
use OCP\ISession;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Settings\ISettings;
use OCP\IConfig;
class Admin implements ISettings {
/** @var IL10N */
private $l;
/** @var ILogger */
private $logger;
/** @var IUserSession */
private $userSession;
/** @var IConfig */
private $config;
/** @var IUserManager */
private $userManager;
/** @var ISession */
private $session;
public function __construct(
IL10N $l,
ILogger $logger,
IUserSession $userSession,
IConfig $config,
IUserManager $userManager,
ISession $session
) {
$this->l = $l;
$this->logger = $logger;
$this->userSession = $userSession;
$this->config = $config;
$this->userManager = $userManager;
$this->session = $session;
}
/**
* @return TemplateResponse
*/
public function getForm() {
$crypt = new Crypt(
$this->logger,
$this->userSession,
$this->config,
$this->l);
$util = new Util(
new View(),
$crypt,
$this->logger,
$this->userSession,
$this->config,
$this->userManager);
// Check if an adminRecovery account is enabled for recovering files after lost pwd
$recoveryAdminEnabled = $this->config->getAppValue('encryption', 'recoveryAdminEnabled', '0');
$session = new Session($this->session);
$encryptHomeStorage = $util->shouldEncryptHomeStorage();
$parameters = [
'recoveryEnabled' => $recoveryAdminEnabled,
'initStatus' => $session->getStatus(),
'encryptHomeStorage' => $encryptHomeStorage,
'masterKeyEnabled' => $util->isMasterKeyEnabled(),
];
return new TemplateResponse('encryption', 'settings-admin', $parameters, '');
}
/**
* @return string the section ID, e.g. 'sharing'
*/
public function getSection() {
return 'encryption';
}
/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
public function getPriority() {
return 5;
}
}

View File

@ -1,53 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Björn Schießle <bjoern@schiessle.org>
* @author Clark Tomlinson <fallen013@gmail.com>
* @author Lukas Reschke <lukas@statuscode.ch>
* @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/>
*
*/
$tmpl = new OCP\Template('encryption', 'settings-admin');
$crypt = new \OCA\Encryption\Crypto\Crypt(
\OC::$server->getLogger(),
\OC::$server->getUserSession(),
\OC::$server->getConfig(),
\OC::$server->getL10N('encryption'));
$util = new \OCA\Encryption\Util(
new \OC\Files\View(),
$crypt,
\OC::$server->getLogger(),
\OC::$server->getUserSession(),
\OC::$server->getConfig(),
\OC::$server->getUserManager());
// Check if an adminRecovery account is enabled for recovering files after lost pwd
$recoveryAdminEnabled = \OC::$server->getConfig()->getAppValue('encryption', 'recoveryAdminEnabled', '0');
$session = new \OCA\Encryption\Session(\OC::$server->getSession());
$encryptHomeStorage = $util->shouldEncryptHomeStorage();
$tmpl->assign('recoveryEnabled', $recoveryAdminEnabled);
$tmpl->assign('initStatus', $session->getStatus());
$tmpl->assign('encryptHomeStorage', $encryptHomeStorage);
$tmpl->assign('masterKeyEnabled', $util->isMasterKeyEnabled());
return $tmpl->fetchPage();

View File

@ -6,6 +6,7 @@ script('core', 'multiselect');
style('encryption', 'settings-admin');
?>
<form id="ocDefaultEncryptionModule" class="sub-section">
<h3><?php p($l->t("Default encryption module")); ?></h3>
<?php if(!$_["initStatus"]): ?>
<?php p($l->t("Encryption app is enabled but your keys are not initialized, please log-out and log-in again")); ?>
<?php else: ?>

View File

@ -0,0 +1,100 @@
<?php
/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @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 OCA\Encryption\Tests\Settings;
use OCA\Encryption\Settings\Admin;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\ISession;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\IL10N;
use OCP\ILogger;
use Test\TestCase;
class AdminTest extends TestCase {
/** @var Admin */
private $admin;
/** @var IL10N */
private $l;
/** @var ILogger */
private $logger;
/** @var IUserSession */
private $userSession;
/** @var IConfig */
private $config;
/** @var IUserManager */
private $userManager;
/** @var ISession */
private $session;
public function setUp() {
parent::setUp();
$this->l = $this->getMockBuilder('\OCP\IL10N')->getMock();
$this->logger = $this->getMockBuilder('\OCP\ILogger')->getMock();
$this->userSession = $this->getMockBuilder('\OCP\IUserSession')->getMock();
$this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
$this->userManager = $this->getMockBuilder('\OCP\IUserManager')->getMock();
$this->session = $this->getMockBuilder('\OCP\ISession')->getMock();
$this->admin = new Admin(
$this->l,
$this->logger,
$this->userSession,
$this->config,
$this->userManager,
$this->session
);
}
public function testGetForm() {
$this->config
->expects($this->at(0))
->method('getAppValue')
->with('encryption', 'recoveryAdminEnabled', '0')
->willReturn(1);
$this->config
->expects($this->at(1))
->method('getAppValue')
->with('encryption', 'encryptHomeStorage', '1')
->willReturn(1);
$params = [
'recoveryEnabled' => 1,
'initStatus' => '0',
'encryptHomeStorage' => false,
'masterKeyEnabled' => false
];
$expected = new TemplateResponse('encryption', 'settings-admin', $params, '');
$this->assertEquals($expected, $this->admin->getForm());
}
public function testGetSection() {
$this->assertSame('encryption', $this->admin->getSection());
}
public function testGetPriority() {
$this->assertSame(5, $this->admin->getPriority());
}
}

View File

@ -5,10 +5,13 @@
<description>Provide federated file sharing across servers</description>
<licence>AGPL</licence>
<author>Bjoern Schiessle, Roeland Jago Douma</author>
<version>1.0.0</version>
<version>1.0.1</version>
<namespace>FederatedFileSharing</namespace>
<category>other</category>
<dependencies>
<owncloud min-version="9.1" max-version="9.1" />
</dependencies>
<settings>
<admin>OCA\FederatedFileSharing\Settings\Admin</admin>
</settings>
</info>

View File

@ -40,7 +40,6 @@ class Application extends App {
* register personal and admin settings page
*/
public function registerSettings() {
\OCP\App::registerAdmin('federatedfilesharing', 'settings-admin');
\OCP\App::registerPersonal('federatedfilesharing', 'settings-personal');
}

View File

@ -0,0 +1,69 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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 OCA\FederatedFileSharing\Settings;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Settings\ISettings;
class Admin implements ISettings {
/** @var FederatedShareProvider */
private $fedShareProvider;
public function __construct(FederatedShareProvider $fedShareProvider) {
$this->fedShareProvider = $fedShareProvider;
}
/**
* @return TemplateResponse
*/
public function getForm() {
$parameters = [
'outgoingServer2serverShareEnabled' => $this->fedShareProvider->isOutgoingServer2serverShareEnabled(),
'incomingServer2serverShareEnabled' => $this->fedShareProvider->isIncomingServer2serverShareEnabled(),
];
return new TemplateResponse('federatedfilesharing', 'settings-admin', $parameters, '');
}
/**
* @return string the section ID, e.g. 'sharing'
*/
public function getSection() {
return 'sharing';
}
/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
public function getPriority() {
return 20;
}
}

View File

@ -1,34 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Bjoern Schiessle <bjoern@schiessle.org>
* @author Björn Schießle <bjoern@schiessle.org>
* @author Morris Jobke <hey@morrisjobke.de>
*
* @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/>
*
*/
use OCA\FederatedFileSharing\AppInfo\Application;
$app = new Application();
$federatedShareProvider = $app->getFederatedShareProvider();
$tmpl = new OCP\Template('federatedfilesharing', 'settings-admin');
$tmpl->assign('outgoingServer2serverShareEnabled', $federatedShareProvider->isOutgoingServer2serverShareEnabled());
$tmpl->assign('incomingServer2serverShareEnabled', $federatedShareProvider->isIncomingServer2serverShareEnabled());
return $tmpl->fetchPage();

View File

@ -4,7 +4,7 @@
script('federatedfilesharing', 'settings-admin');
?>
<div id="fileSharingSettings">
<div id="fileSharingSettings" class="followupsection">
<h3><?php p($l->t('Federated Cloud Sharing'));?></h3>
<a target="_blank" rel="noreferrer" class="icon-info svg"
title="<?php p($l->t('Open documentation'));?>"

View File

@ -0,0 +1,84 @@
<?php
/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @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 OCA\FederatedFileSharing\Tests\Settings;
use OCA\FederatedFileSharing\Settings\Admin;
use OCP\AppFramework\Http\TemplateResponse;
use Test\TestCase;
class AdminTest extends TestCase {
/** @var Admin */
private $admin;
/** @var \OCA\FederatedFileSharing\FederatedShareProvider */
private $federatedShareProvider;
public function setUp() {
parent::setUp();
$this->federatedShareProvider = $this->getMockBuilder('\OCA\FederatedFileSharing\FederatedShareProvider')->disableOriginalConstructor()->getMock();
$this->admin = new Admin(
$this->federatedShareProvider
);
}
public function sharingStateProvider() {
return [
[
true,
],
[
false,
]
];
}
/**
* @dataProvider sharingStateProvider
* @param bool $state
*/
public function testGetForm($state) {
$this->federatedShareProvider
->expects($this->once())
->method('isOutgoingServer2serverShareEnabled')
->willReturn($state);
$this->federatedShareProvider
->expects($this->once())
->method('isIncomingServer2serverShareEnabled')
->willReturn($state);
$params = [
'outgoingServer2serverShareEnabled' => $state,
'incomingServer2serverShareEnabled' => $state,
];
$expected = new TemplateResponse('federatedfilesharing', 'settings-admin', $params, '');
$this->assertEquals($expected, $this->admin->getForm());
}
public function testGetSection() {
$this->assertSame('sharing', $this->admin->getSection());
}
public function testGetPriority() {
$this->assertSame(20, $this->admin->getPriority());
}
}

View File

@ -23,5 +23,4 @@
namespace OCA\Federation\AppInfo;
$app = new Application();
$app->registerSettings();
$app->registerHooks();

View File

@ -5,7 +5,7 @@
<description>Federation allows you to connect with other trusted servers to exchange the user directory. For example this will be used to auto-complete external users for federated sharing.</description>
<licence>AGPL</licence>
<author>Bjoern Schiessle</author>
<version>1.0.0</version>
<version>1.0.1</version>
<namespace>Federation</namespace>
<category>other</category>
<dependencies>
@ -19,4 +19,8 @@
<background-jobs>
<job>OCA\Federation\SyncJob</job>
</background-jobs>
<settings>
<admin>OCA\Federation\Settings\Admin</admin>
</settings>
</info>

View File

@ -51,13 +51,6 @@ class Application extends \OCP\AppFramework\App {
$this->registerMiddleware();
}
/**
* register setting scripts
*/
public function registerSettings() {
App::registerAdmin('federation', 'settings/settings-admin');
}
private function registerService() {
$container = $this->getContainer();

View File

@ -0,0 +1,69 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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 OCA\Federation\Settings;
use OCA\Federation\TrustedServers;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Settings\ISettings;
class Admin implements ISettings {
/** @var TrustedServers */
private $trustedServers;
public function __construct(TrustedServers $trustedServers) {
$this->trustedServers = $trustedServers;
}
/**
* @return TemplateResponse
*/
public function getForm() {
$parameters = [
'trustedServers' => $this->trustedServers->getServers(),
'autoAddServers' => $this->trustedServers->getAutoAddServers(),
];
return new TemplateResponse('federation', 'settings-admin', $parameters, '');
}
/**
* @return string the section ID, e.g. 'sharing'
*/
public function getSection() {
return 'sharing';
}
/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
public function getPriority() {
return 30;
}
}

View File

@ -1,43 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Björn Schießle <bjoern@schiessle.org>
*
* @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/>
*
*/
$template = new OCP\Template('federation', 'settings-admin');
$dbHandler = new \OCA\Federation\DbHandler(
\OC::$server->getDatabaseConnection(),
\OC::$server->getL10N('federation')
);
$trustedServers = new \OCA\Federation\TrustedServers(
$dbHandler,
\OC::$server->getHTTPClientService(),
\OC::$server->getLogger(),
\OC::$server->getJobList(),
\OC::$server->getSecureRandom(),
\OC::$server->getConfig(),
\OC::$server->getEventDispatcher()
);
$template->assign('trustedServers', $trustedServers->getServers());
$template->assign('autoAddServers', $trustedServers->getAutoAddServers());
return $template->fetchPage();

View File

@ -0,0 +1,70 @@
<?php
/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @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 OCA\Federation\Tests\Settings;
use OCA\Federation\Settings\Admin;
use OCA\Federation\TrustedServers;
use OCP\AppFramework\Http\TemplateResponse;
use Test\TestCase;
class AdminTest extends TestCase {
/** @var Admin */
private $admin;
/** @var TrustedServers */
private $trustedServers;
public function setUp() {
parent::setUp();
$this->trustedServers = $this->getMockBuilder('\OCA\Federation\TrustedServers')->disableOriginalConstructor()->getMock();
$this->admin = new Admin(
$this->trustedServers
);
}
public function testGetForm() {
$this->trustedServers
->expects($this->once())
->method('getServers')
->willReturn(['myserver', 'secondserver']);
$this->trustedServers
->expects($this->once())
->method('getAutoAddServers')
->willReturn(['autoserver1', 'autoserver2']);
$params = [
'trustedServers' => ['myserver', 'secondserver'],
'autoAddServers' => ['autoserver1', 'autoserver2'],
];
$expected = new TemplateResponse('federation', 'settings-admin', $params, '');
$this->assertEquals($expected, $this->admin->getForm());
}
public function testGetSection() {
$this->assertSame('sharing', $this->admin->getSection());
}
public function testGetPriority() {
$this->assertSame(30, $this->admin->getPriority());
}
}

View File

@ -1,51 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Clark Tomlinson <fallen013@gmail.com>
* @author Frank Karlitschek <frank@karlitschek.de>
* @author Michael Göhler <somebody.here@gmx.de>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author Robin McCorkell <robin@mccorkell.me.uk>
* @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/>
*
*/
$htaccessWorking=(getenv('htaccessWorking')=='true');
$upload_max_filesize = OC::$server->getIniWrapper()->getBytes('upload_max_filesize');
$post_max_size = OC::$server->getIniWrapper()->getBytes('post_max_size');
$maxUploadFilesize = OCP\Util::humanFileSize(min($upload_max_filesize, $post_max_size));
if($_POST && \OC::$server->getRequest()->passesCSRFCheck()) {
if(isset($_POST['maxUploadSize'])) {
if(($setMaxSize = OC_Files::setUploadLimit(OCP\Util::computerFileSize($_POST['maxUploadSize']))) !== false) {
$maxUploadFilesize = OCP\Util::humanFileSize($setMaxSize);
}
}
}
$htaccessWritable=is_writable(OC::$SERVERROOT.'/.htaccess');
$userIniWritable=is_writable(OC::$SERVERROOT.'/.user.ini');
$tmpl = new OCP\Template( 'files', 'admin' );
$tmpl->assign( 'uploadChangable', ($htaccessWorking and $htaccessWritable) or $userIniWritable );
$tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize);
// max possible makes only sense on a 32 bit system
$tmpl->assign( 'displayMaxPossibleUploadSize', PHP_INT_SIZE===4);
$tmpl->assign( 'maxPossibleUploadSize', OCP\Util::humanFileSize(PHP_INT_MAX));
return $tmpl->fetchPage();

View File

@ -26,8 +26,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
\OCP\App::registerAdmin('files', 'admin');
$l = \OC::$server->getL10N('files');
\OC::$server->getNavigationManager()->add(function () {
$urlGenerator = \OC::$server->getURLGenerator();

View File

@ -6,7 +6,7 @@
<licence>AGPL</licence>
<author>Robin Appelman, Vincent Petry</author>
<default_enable/>
<version>1.5.1</version>
<version>1.5.2</version>
<types>
<filesystem/>
</types>
@ -22,4 +22,8 @@
<job>OCA\Files\BackgroundJob\DeleteOrphanedItems</job>
<job>OCA\Files\BackgroundJob\CleanupFileLocks</job>
</background-jobs>
<settings>
<admin>OCA\Files\Settings\Admin</admin>
</settings>
</info>

View File

@ -0,0 +1,93 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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 OCA\Files\Settings;
use bantu\IniGetWrapper\IniGetWrapper;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IRequest;
use OCP\Settings\ISettings;
use OCP\Util;
class Admin implements ISettings {
/** @var IniGetWrapper */
private $iniWrapper;
/** @var IRequest */
private $request;
public function __construct(IniGetWrapper $iniWrapper, IRequest $request) {
$this->iniWrapper = $iniWrapper;
$this->request = $request;
}
/**
* @return TemplateResponse
*/
public function getForm() {
$htaccessWorking = (getenv('htaccessWorking') == 'true');
$htaccessWritable = is_writable(\OC::$SERVERROOT.'/.htaccess');
$userIniWritable = is_writable(\OC::$SERVERROOT.'/.user.ini');
$upload_max_filesize = $this->iniWrapper->getBytes('upload_max_filesize');
$post_max_size = $this->iniWrapper->getBytes('post_max_size');
$maxUploadFilesize = Util::humanFileSize(min($upload_max_filesize, $post_max_size));
if($_POST && $this->request->passesCSRFCheck()) {
if(isset($_POST['maxUploadSize'])) {
if(($setMaxSize = \OC_Files::setUploadLimit(Util::computerFileSize($_POST['maxUploadSize']))) !== false) {
$maxUploadFilesize = Util::humanFileSize($setMaxSize);
}
}
}
$parameters = [
'uploadChangable' => (($htaccessWorking and $htaccessWritable) or $userIniWritable ),
'uploadMaxFilesize' => $maxUploadFilesize,
// max possible makes only sense on a 32 bit system
'displayMaxPossibleUploadSize' => PHP_INT_SIZE === 4,
'maxPossibleUploadSize' => Util::humanFileSize(PHP_INT_MAX),
];
return new TemplateResponse('files', 'admin', $parameters, '');
}
/**
* @return string the section ID, e.g. 'sharing'
*/
public function getSection() {
return 'additional';
}
/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
public function getPriority() {
return 5;
}
}

View File

@ -0,0 +1,83 @@
<?php
/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @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 OCA\Files\Tests\Settings;
use bantu\IniGetWrapper\IniGetWrapper;
use OCA\Files\Settings\Admin;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IRequest;
use OCP\Util;
use Test\TestCase;
class AdminTest extends TestCase {
/** @var Admin */
private $admin;
/** @var IniGetWrapper */
private $iniGetWrapper;
/** @var IRequest */
private $request;
public function setUp() {
parent::setUp();
$this->iniGetWrapper = $this->getMockBuilder('\bantu\IniGetWrapper\IniGetWrapper')->disableOriginalConstructor()->getMock();
$this->request = $this->getMockBuilder('\OCP\IRequest')->getMock();
$this->admin = new Admin(
$this->iniGetWrapper,
$this->request
);
}
public function testGetForm() {
$htaccessWorking = (getenv('htaccessWorking') == 'true');
$htaccessWritable = is_writable(\OC::$SERVERROOT.'/.htaccess');
$userIniWritable = is_writable(\OC::$SERVERROOT.'/.user.ini');
$this->iniGetWrapper
->expects($this->at(0))
->method('getBytes')
->with('upload_max_filesize')
->willReturn(1234);
$this->iniGetWrapper
->expects($this->at(1))
->method('getBytes')
->with('post_max_size')
->willReturn(1234);
$params = [
'uploadChangable' => (($htaccessWorking and $htaccessWritable) or $userIniWritable ),
'uploadMaxFilesize' => '1 KB',
'displayMaxPossibleUploadSize' => PHP_INT_SIZE === 4,
'maxPossibleUploadSize' => Util::humanFileSize(PHP_INT_MAX),
];
$expected = new TemplateResponse('files', 'admin', $params, '');
$this->assertEquals($expected, $this->admin->getForm());
}
public function testGetSection() {
$this->assertSame('additional', $this->admin->getSection());
}
public function testGetPriority() {
$this->assertSame(5, $this->admin->getPriority());
}
}

View File

@ -13,7 +13,7 @@
<admin>admin-external-storage</admin>
</documentation>
<rememberlogin>false</rememberlogin>
<version>1.0.0</version>
<version>1.0.2</version>
<types>
<filesystem/>
</types>
@ -24,4 +24,9 @@
<dependencies>
<owncloud min-version="9.1" max-version="9.1" />
</dependencies>
<settings>
<admin>OCA\Files_External\Settings\Admin</admin>
<admin-section>OCA\Files_External\Settings\Section</admin-section>
</settings>
</info>

View File

@ -68,10 +68,6 @@ class Application extends App implements IBackendProvider, IAuthMechanismProvide
* Register settings templates
*/
public function registerSettings() {
$container = $this->getContainer();
$backendService = $container->query('OCA\\Files_External\\Service\\BackendService');
\OCP\App::registerAdmin('files_external', 'settings');
\OCP\App::registerPersonal('files_external', 'personal');
}

View File

@ -0,0 +1,96 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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 OCA\Files_External\Settings;
use OCA\Files_External\Lib\Auth\Password\GlobalAuth;
use OCA\Files_External\Service\BackendService;
use OCA\Files_External\Service\GlobalStoragesService;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Encryption\IManager;
use OCP\Settings\ISettings;
class Admin implements ISettings {
/** @var IManager */
private $encryptionManager;
/** @var GlobalStoragesService */
private $globalStoragesService;
/** @var BackendService */
private $backendService;
/** @var GlobalAuth */
private $globalAuth;
public function __construct(
IManager $encryptionManager,
GlobalStoragesService $globalStoragesService,
BackendService $backendService,
GlobalAuth $globalAuth
) {
$this->encryptionManager = $encryptionManager;
$this->globalStoragesService = $globalStoragesService;
$this->backendService = $backendService;
$this->globalAuth = $globalAuth;
}
/**
* @return TemplateResponse
*/
public function getForm() {
$parameters = [
'encryptionEnabled' => $this->encryptionManager->isEnabled(),
'visibilityType' => BackendService::VISIBILITY_ADMIN,
'storages' => $this->globalStoragesService->getStorages(),
'backends' => $this->backendService->getAvailableBackends(),
'authMechanisms' => $this->backendService->getAuthMechanisms(),
'dependencies' => \OC_Mount_Config::dependencyMessage($this->backendService->getBackends()),
'allowUserMounting' => $this->backendService->isUserMountingAllowed(),
'globalCredentials' => $this->globalAuth->getAuth(''),
'globalCredentialsUid' => '',
];
return new TemplateResponse('files_external', 'settings', $parameters, '');
}
/**
* @return string the section ID, e.g. 'sharing'
*/
public function getSection() {
return 'externalstorages';
}
/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
public function getPriority() {
return 40;
}
}

View File

@ -0,0 +1,67 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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 OCA\Files_External\Settings;
use OCP\IL10N;
use OCP\Settings\ISection;
class Section implements ISection {
/** @var IL10N */
private $l;
public function __construct(IL10N $l) {
$this->l = $l;
}
/**
* returns the ID of the section. It is supposed to be a lower case string,
* e.g. 'ldap'
*
* @returns string
*/
public function getID() {
return 'externalstorages';
}
/**
* returns the translated name as it should be displayed, e.g. 'LDAP / AD
* integration'. Use the L10N service to translate it.
*
* @return string
*/
public function getName() {
return $this->l->t('External storages');
}
/**
* @return int whether the form should be rather on the top or bottom of
* the settings navigation. The sections are arranged in ascending order of
* the priority values. It is required to return a value between 0 and 99.
*
* E.g.: 70
*/
public function getPriority() {
return 10;
}
}

View File

@ -1,48 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Joas Schilling <coding@schilljs.com>
* @author Michael Gapczynski <GapczynskiM@gmail.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author Robin McCorkell <robin@mccorkell.me.uk>
*
* @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/>
*
*/
use \OCA\Files_External\Service\BackendService;
// we must use the same container
$appContainer = \OC_Mount_Config::$app->getContainer();
$backendService = $appContainer->query('OCA\Files_External\Service\BackendService');
$globalStoragesService = $appContainer->query('OCA\Files_External\Service\GlobalStoragesService');
$globalAuth = $appContainer->query('OCA\Files_External\Lib\Auth\Password\GlobalAuth');
\OC_Util::addVendorScript('select2/select2');
\OC_Util::addVendorStyle('select2/select2');
$tmpl = new OCP\Template('files_external', 'settings');
$tmpl->assign('encryptionEnabled', \OC::$server->getEncryptionManager()->isEnabled());
$tmpl->assign('visibilityType', BackendService::VISIBILITY_ADMIN);
$tmpl->assign('storages', $globalStoragesService->getStorages());
$tmpl->assign('backends', $backendService->getAvailableBackends());
$tmpl->assign('authMechanisms', $backendService->getAuthMechanisms());
$tmpl->assign('dependencies', OC_Mount_Config::dependencyMessage($backendService->getBackends()));
$tmpl->assign('allowUserMounting', $backendService->isUserMountingAllowed());
$tmpl->assign('globalCredentials', $globalAuth->getAuth(''));
$tmpl->assign('globalCredentialsUid', '');
return $tmpl->fetchPage();

View File

@ -0,0 +1,109 @@
<?php
/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @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 OCA\Files_External\Tests\Settings;
use OCA\Files_External\Lib\Auth\Password\GlobalAuth;
use OCA\Files_External\Service\BackendService;
use OCA\Files_External\Service\GlobalStoragesService;
use OCA\Files_External\Settings\Admin;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Encryption\IManager;
use Test\TestCase;
class AdminTest extends TestCase {
/** @var Admin */
private $admin;
/** @var IManager */
private $encryptionManager;
/** @var GlobalStoragesService */
private $globalStoragesService;
/** @var BackendService */
private $backendService;
/** @var GlobalAuth */
private $globalAuth;
public function setUp() {
parent::setUp();
$this->encryptionManager = $this->getMockBuilder('\OCP\Encryption\IManager')->getMock();
$this->globalStoragesService = $this->getMockBuilder('\OCA\Files_External\Service\GlobalStoragesService')->disableOriginalConstructor()->getMock();
$this->backendService = $this->getMockBuilder('\OCA\Files_External\Service\BackendService')->disableOriginalConstructor()->getMock();
$this->globalAuth = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\Password\GlobalAuth')->disableOriginalConstructor()->getMock();
$this->admin = new Admin(
$this->encryptionManager,
$this->globalStoragesService,
$this->backendService,
$this->globalAuth
);
}
public function testGetForm() {
$this->encryptionManager
->expects($this->once())
->method('isEnabled')
->willReturn(false);
$this->globalStoragesService
->expects($this->once())
->method('getStorages')
->willReturn(['a', 'b', 'c']);
$this->backendService
->expects($this->once())
->method('getAvailableBackends')
->willReturn(['d', 'e', 'f']);
$this->backendService
->expects($this->once())
->method('getAuthMechanisms')
->willReturn(['g', 'h', 'i']);
$this->backendService
->expects($this->once())
->method('isUserMountingAllowed')
->willReturn(true);
$this->globalAuth
->expects($this->once())
->method('getAuth')
->with('')
->willReturn('asdf:asdf');
$params = [
'encryptionEnabled' => false,
'visibilityType' => BackendService::VISIBILITY_ADMIN,
'storages' => ['a', 'b', 'c'],
'backends' => ['d', 'e', 'f'],
'authMechanisms' => ['g', 'h', 'i'],
'dependencies' => \OC_Mount_Config::dependencyMessage($this->backendService->getBackends()),
'allowUserMounting' => true,
'globalCredentials' => 'asdf:asdf',
'globalCredentialsUid' => '',
];
$expected = new TemplateResponse('files_external', 'settings', $params, '');
$this->assertEquals($expected, $this->admin->getForm());
}
public function testGetSection() {
$this->assertSame('externalstorages', $this->admin->getSection());
}
public function testGetPriority() {
$this->assertSame(40, $this->admin->getPriority());
}
}

View File

@ -0,0 +1,62 @@
<?php
/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @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 OCA\Files_External\Tests\Settings;
use OCA\Files_External\Settings\Section;
use OCP\IL10N;
use Test\TestCase;
class SectionTest extends TestCase {
/** @var IL10N */
private $l;
/** @var Section */
private $section;
public function setUp() {
parent::setUp();
$this->l = $this->getMockBuilder('\OCP\IL10N')->disableOriginalConstructor()->getMock();
$this->section = new Section(
$this->l
);
}
public function testGetID() {
$this->assertSame('externalstorages', $this->section->getID());
}
public function testGetName() {
$this->l
->expects($this->once())
->method('t')
->with('External storages')
->willReturn('External storages');
$this->assertSame('External storages', $this->section->getName());
}
public function testGetPriority() {
$this->assertSame(10, $this->section->getPriority());
}
}

View File

@ -78,9 +78,6 @@ $mapperListener = function(MapperEvent $event) use ($activityManager) {
$eventDispatcher->addListener(MapperEvent::EVENT_ASSIGN, $mapperListener);
$eventDispatcher->addListener(MapperEvent::EVENT_UNASSIGN, $mapperListener);
$app = new \OCA\SystemTags\AppInfo\Application();
$app->registerAdminPage();
$l = \OC::$server->getL10N('systemtags');
\OCA\Files\App::getNavigationManager()->add(

View File

@ -7,7 +7,7 @@
<licence>AGPL</licence>
<author>Vincent Petry, Joas Schilling</author>
<default_enable/>
<version>1.0.0</version>
<version>1.0.1</version>
<dependencies>
<owncloud min-version="9.1" max-version="9.1" />
</dependencies>
@ -15,4 +15,7 @@
<types>
<logging/>
</types>
<settings>
<admin>OCA\SystemTags\Settings\Admin</admin>
</settings>
</info>

View File

@ -0,0 +1,56 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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 OCA\SystemTags\Settings;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Settings\ISettings;
class Admin implements ISettings {
/**
* @return TemplateResponse
*/
public function getForm() {
return new TemplateResponse('systemtags', 'admin', [], '');
}
/**
* @return string the section ID, e.g. 'sharing'
*/
public function getSection() {
return 'sharing';
}
/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
public function getPriority() {
return 70;
}
}

View File

@ -0,0 +1,52 @@
<?php
/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @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 OCA\SystemTags\Tests\Settings;
use OCA\SystemTags\Settings\Admin;
use OCP\AppFramework\Http\TemplateResponse;
use Test\TestCase;
class AdminTest extends TestCase {
/** @var Admin */
private $admin;
public function setUp() {
parent::setUp();
$this->admin = new Admin();
}
public function testGetForm() {
$expected = new TemplateResponse('systemtags', 'admin', [], '');
$this->assertEquals($expected, $this->admin->getForm());
}
public function testGetSection() {
$this->assertSame('sharing', $this->admin->getSection());
}
public function testGetPriority() {
$this->assertSame(70, $this->admin->getPriority());
}
}

View File

@ -23,8 +23,6 @@
*
*/
\OCP\App::registerAdmin('theming', 'settings/settings-admin');
$linkToCSS = \OC::$server->getURLGenerator()->linkToRoute(
'theming.Theming.getStylesheet',
[

View File

@ -5,7 +5,7 @@
<description>Adjust the Nextcloud theme</description>
<licence>AGPL</licence>
<author>Nextcloud</author>
<version>1.0.0</version>
<version>1.0.1</version>
<namespace>Theming</namespace>
<category>other</category>
@ -18,4 +18,9 @@
</types>
<default_enable/>
<settings>
<admin>OCA\Theming\Settings\Admin</admin>
<admin-section>OCA\Theming\Settings\Section</admin-section>
</settings>
</info>

View File

@ -27,7 +27,7 @@
namespace OCA\Theming\Controller;
use OCA\Theming\Template;
use OCA\Theming\ThemingDefaults;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataDownloadResponse;
@ -48,7 +48,7 @@ use OCA\Theming\Util;
* @package OCA\Theming\Controller
*/
class ThemingController extends Controller {
/** @var Template */
/** @var ThemingDefaults */
private $template;
/** @var Util */
private $util;
@ -67,7 +67,7 @@ class ThemingController extends Controller {
* @param string $appName
* @param IRequest $request
* @param IConfig $config
* @param Template $template
* @param ThemingDefaults $template
* @param Util $util
* @param ITimeFactory $timeFactory
* @param IL10N $l
@ -77,7 +77,7 @@ class ThemingController extends Controller {
$appName,
IRequest $request,
IConfig $config,
Template $template,
ThemingDefaults $template,
Util $util,
ITimeFactory $timeFactory,
IL10N $l,

View File

@ -0,0 +1,98 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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 OCA\Theming\Settings;
use OCA\Theming\ThemingDefaults;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\Settings\ISettings;
class Admin implements ISettings {
/** @var IConfig */
private $config;
/** @var IL10N */
private $l;
/** @var ThemingDefaults */
private $themingDefaults;
/** @var IURLGenerator */
private $urlGenerator;
public function __construct(IConfig $config,
IL10N $l,
ThemingDefaults $themingDefaults,
IURLGenerator $urlGenerator) {
$this->config = $config;
$this->l = $l;
$this->themingDefaults = $themingDefaults;
$this->urlGenerator = $urlGenerator;
}
/**
* @return TemplateResponse
*/
public function getForm() {
$path = $this->urlGenerator->linkToRoute('theming.Theming.updateLogo');
$themable = true;
$errorMessage = '';
$theme = $this->config->getSystemValue('theme', '');
if ($theme !== '') {
$themable = false;
$errorMessage = $this->l->t('You already use a custom theme');
}
$parameters = [
'themable' => $themable,
'errorMessage' => $errorMessage,
'name' => $this->themingDefaults->getEntity(),
'url' => $this->themingDefaults->getBaseUrl(),
'slogan' => $this->themingDefaults->getSlogan(),
'color' => $this->themingDefaults->getMailHeaderColor(),
'uploadLogoRoute' => $path,
];
return new TemplateResponse('theming', 'settings-admin', $parameters, '');
}
/**
* @return string the section ID, e.g. 'sharing'
*/
public function getSection() {
return 'theming';
}
/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
public function getPriority() {
return 5;
}
}

View File

@ -0,0 +1,67 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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 OCA\Theming\Settings;
use OCP\IL10N;
use OCP\Settings\ISection;
class Section implements ISection {
/** @var IL10N */
private $l;
public function __construct(IL10N $l) {
$this->l = $l;
}
/**
* returns the ID of the section. It is supposed to be a lower case string,
* e.g. 'ldap'
*
* @returns string
*/
public function getID() {
return 'theming';
}
/**
* returns the translated name as it should be displayed, e.g. 'LDAP / AD
* integration'. Use the L10N service to translate it.
*
* @return string
*/
public function getName() {
return $this->l->t('Theming');
}
/**
* @return int whether the form should be rather on the top or bottom of
* the settings navigation. The sections are arranged in ascending order of
* the priority values. It is required to return a value between 0 and 99.
*
* E.g.: 70
*/
public function getPriority() {
return 30;
}
}

View File

@ -1,11 +1,6 @@
<?php
/**
* @copyright Copyright (c) 2016 Bjoern Schiessle <bjoern@schiessle.org>
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
* @author Bjoern Schiessle <bjoern@schiessle.org>
* @author Joas Schilling <coding@schilljs.com>
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @license GNU AGPL version 3 or any later version
*
@ -24,20 +19,19 @@
*
*/
namespace OCA\Theming;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
/**
* Class Template
*
* Handle all the values which can be modified by this app
*
* @package OCA\Theming
*/
class Template extends \OC_Defaults {
class ThemingDefaults extends \OC_Defaults {
/** @var IConfig */
private $config;
/** @var IL10N */
@ -54,7 +48,7 @@ class Template extends \OC_Defaults {
private $color;
/**
* Template constructor.
* ThemingDefaults constructor.
*
* @param IConfig $config
* @param IL10N $l
@ -92,7 +86,7 @@ class Template extends \OC_Defaults {
public function getEntity() {
return $this->config->getAppValue('theming', 'name', $this->name);
}
public function getBaseUrl() {
return $this->config->getAppValue('theming', 'url', $this->url);
}
@ -168,4 +162,5 @@ class Template extends \OC_Defaults {
return $returnValue;
}
}

View File

@ -1,52 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2016 Bjoern Schiessle <bjoern@schiessle.org>
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
* @author Bjoern Schiessle <bjoern@schiessle.org>
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @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/>.
*
*/
$config = \OC::$server->getConfig();
$l = \OC::$server->getL10N('theming');
$urlGenerator = \OC::$server->getURLGenerator();
$theming = \OC::$server->getThemingDefaults();
$themable = true;
$errorMessage = '';
$theme = $config->getSystemValue('theme', '');
if ($theme !== '') {
$themable = false;
$errorMessage = $l->t('You already use a custom theme');
}
$template = new \OCP\Template('theming', 'settings-admin');
$template->assign('themable', $themable);
$template->assign('errorMessage', $errorMessage);
$template->assign('name', $theming->getEntity());
$template->assign('url', $theming->getBaseUrl());
$template->assign('slogan', $theming->getSlogan());
$template->assign('color', $theming->getMailHeaderColor());
$path = $urlGenerator->linkToRoute('theming.Theming.updateLogo');
$template->assign('uploadLogoRoute', $path);
return $template->fetchPage();

View File

@ -25,7 +25,6 @@
namespace OCA\Theming\Tests\Controller;
use OCA\Theming\Controller\ThemingController;
use OCA\Theming\Template;
use OCA\Theming\Util;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
@ -34,13 +33,14 @@ use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
use Test\TestCase;
use OCA\Theming\ThemingDefaults;
class ThemingControllerTest extends TestCase {
/** @var IRequest|\PHPUnit_Framework_MockObject_MockObject */
private $request;
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
private $config;
/** @var Template|\PHPUnit_Framework_MockObject_MockObject */
/** @var ThemingDefaults|\PHPUnit_Framework_MockObject_MockObject */
private $template;
/** @var Util */
private $util;
@ -56,7 +56,7 @@ class ThemingControllerTest extends TestCase {
public function setUp() {
$this->request = $this->getMockBuilder('OCP\IRequest')->getMock();
$this->config = $this->getMockBuilder('OCP\IConfig')->getMock();
$this->template = $this->getMockBuilder('OCA\Theming\Template')
$this->template = $this->getMockBuilder('OCA\Theming\ThemingDefaults')
->disableOriginalConstructor()->getMock();
$this->util = new Util();
$this->timeFactory = $this->getMockBuilder('OCP\AppFramework\Utility\ITimeFactory')

View File

@ -0,0 +1,155 @@
<?php
/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @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 OCA\Theming\Tests\Settings;
use OCA\Theming\Settings\Admin;
use OCA\Theming\ThemingDefaults;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
use Test\TestCase;
class AdminTest extends TestCase {
/** @var Admin */
private $admin;
/** @var IConfig */
private $config;
/** @var ThemingDefaults */
private $themingDefaults;
/** @var IURLGenerator */
private $urlGenerator;
/** @var IL10N */
private $l10n;
public function setUp() {
parent::setUp();
$this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
$this->l10n = $this->getMockBuilder('\OCP\IL10N')->getMock();
$this->themingDefaults = $this->getMockBuilder('\OCA\Theming\ThemingDefaults')->disableOriginalConstructor()->getMock();
$this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')->getMock();
$this->admin = new Admin(
$this->config,
$this->l10n,
$this->themingDefaults,
$this->urlGenerator
);
}
public function testGetFormNoErrors() {
$this->config
->expects($this->once())
->method('getSystemValue')
->with('theme', '')
->willReturn('');
$this->themingDefaults
->expects($this->once())
->method('getEntity')
->willReturn('MyEntity');
$this->themingDefaults
->expects($this->once())
->method('getBaseUrl')
->willReturn('https://example.com');
$this->themingDefaults
->expects($this->once())
->method('getSlogan')
->willReturn('MySlogan');
$this->themingDefaults
->expects($this->once())
->method('getMailHeaderColor')
->willReturn('#fff');
$this->urlGenerator
->expects($this->once())
->method('linkToRoute')
->with('theming.Theming.updateLogo')
->willReturn('/my/route');
$params = [
'themable' => true,
'errorMessage' => '',
'name' => 'MyEntity',
'url' => 'https://example.com',
'slogan' => 'MySlogan',
'color' => '#fff',
'uploadLogoRoute' => '/my/route',
];
$expected = new TemplateResponse('theming', 'settings-admin', $params, '');
$this->assertEquals($expected, $this->admin->getForm());
}
public function testGetFormWithErrors() {
$this->config
->expects($this->once())
->method('getSystemValue')
->with('theme', '')
->willReturn('MyCustomTheme');
$this->l10n
->expects($this->once())
->method('t')
->with('You already use a custom theme')
->willReturn('You already use a custom theme');
$this->themingDefaults
->expects($this->once())
->method('getEntity')
->willReturn('MyEntity');
$this->themingDefaults
->expects($this->once())
->method('getBaseUrl')
->willReturn('https://example.com');
$this->themingDefaults
->expects($this->once())
->method('getSlogan')
->willReturn('MySlogan');
$this->themingDefaults
->expects($this->once())
->method('getMailHeaderColor')
->willReturn('#fff');
$this->urlGenerator
->expects($this->once())
->method('linkToRoute')
->with('theming.Theming.updateLogo')
->willReturn('/my/route');
$params = [
'themable' => false,
'errorMessage' => 'You already use a custom theme',
'name' => 'MyEntity',
'url' => 'https://example.com',
'slogan' => 'MySlogan',
'color' => '#fff',
'uploadLogoRoute' => '/my/route',
];
$expected = new TemplateResponse('theming', 'settings-admin', $params, '');
$this->assertEquals($expected, $this->admin->getForm());
}
public function testGetSection() {
$this->assertSame('theming', $this->admin->getSection());
}
public function testGetPriority() {
$this->assertSame(5, $this->admin->getPriority());
}
}

View File

@ -0,0 +1,62 @@
<?php
/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @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 OCA\Theming\Tests\Settings;
use OCA\Theming\Settings\Section;
use OCP\IL10N;
use Test\TestCase;
class SectionTest extends TestCase {
/** @var IL10N */
private $l;
/** @var Section */
private $section;
public function setUp() {
parent::setUp();
$this->l = $this->getMockBuilder('\OCP\IL10N')->getMock();
$this->section = new Section(
$this->l
);
}
public function testGetID() {
$this->assertSame('theming', $this->section->getID());
}
public function testGetName() {
$this->l
->expects($this->once())
->method('t')
->with('Theming')
->willReturn('Theming');
$this->assertSame('Theming', $this->section->getName());
}
public function testGetPriority() {
$this->assertSame(30, $this->section->getPriority());
}
}

View File

@ -23,13 +23,13 @@
*/
namespace OCA\Theming\Tests;
use OCA\Theming\Template;
use OCA\Theming\ThemingDefaults;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
use Test\TestCase;
class TemplateTest extends TestCase {
class ThemingDefaultsTest extends TestCase {
/** @var IConfig */
private $config;
/** @var IL10N */
@ -38,7 +38,7 @@ class TemplateTest extends TestCase {
private $urlGenerator;
/** @var \OC_Defaults */
private $defaults;
/** @var Template */
/** @var ThemingDefaults */
private $template;
public function setUp() {
@ -64,7 +64,7 @@ class TemplateTest extends TestCase {
->expects($this->at(3))
->method('getMailHeaderColor')
->willReturn('#000');
$this->template = new Template(
$this->template = new ThemingDefaults(
$this->config,
$this->l10n,
$this->urlGenerator,

View File

@ -1,26 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @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/>
*
*/
$app = new \OCA\UpdateNotification\AppInfo\Application();
/** @var OCA\UpdateNotification\Controller\AdminController $controller */
$controller = $app->getContainer()->query('AdminController');
return $controller->displayPanel()->render();

View File

@ -38,7 +38,6 @@ if(\OC::$server->getConfig()->getSystemValue('updatechecker', true) === true) {
\OCP\Util::addScript('updatenotification', 'notification');
OC_Hook::connect('\OCP\Config', 'js', $updateChecker, 'getJavaScript');
}
\OC_App::registerAdmin('updatenotification', 'admin');
}
}

View File

@ -5,7 +5,7 @@
<description>Displays update notifications for ownCloud and provides the SSO for the updater.</description>
<licence>AGPL</licence>
<author>Lukas Reschke</author>
<version>1.0.0</version>
<version>1.0.1</version>
<namespace>UpdateNotification</namespace>
<default_enable/>
<dependencies>
@ -15,4 +15,8 @@
<background-jobs>
<job>OCA\UpdateNotification\Notification\BackgroundJob</job>
</background-jobs>
<settings>
<admin>OCA\UpdateNotification\Controller\AdminController</admin>
</settings>
</info>

View File

@ -34,8 +34,9 @@ use OCP\IDateTimeFormatter;
use OCP\IL10N;
use OCP\IRequest;
use OCP\Security\ISecureRandom;
use OCP\Settings\ISettings;
class AdminController extends Controller {
class AdminController extends Controller implements ISettings {
/** @var IJobList */
private $jobList;
/** @var ISecureRandom */
@ -144,4 +145,29 @@ class AdminController extends Controller {
return new DataResponse($newToken);
}
/**
* @return TemplateResponse returns the instance with all parameters set, ready to be rendered
*/
public function getForm() {
return $this->displayPanel();
}
/**
* @return string the section ID, e.g. 'sharing'
*/
public function getSection() {
return 'server';
}
/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
public function getPriority() {
return 1;
}
}

View File

@ -13,9 +13,7 @@
/** @var string $currentChannel */
$currentChannel = $_['currentChannel'];
?>
<form id="oca_updatenotification_section" class="section">
<h2><?php p($l->t('Updater')); ?></h2>
<form id="oca_updatenotification_section" class="followupsection">
<?php if($isNewVersionAvailable === true): ?>
<strong><?php p($l->t('A new version is available: %s', [$newVersionString])); ?></strong>
<input type="button" id="oca_updatenotification_button" value="<?php p($l->t('Open updater')) ?>">

View File

@ -59,15 +59,14 @@ class AdminControllerTest extends TestCase {
public function setUp() {
parent::setUp();
$this->request = $this->getMock('\\OCP\\IRequest');
$this->jobList = $this->getMock('\\OCP\\BackgroundJob\\IJobList');
$this->secureRandom = $this->getMock('\\OCP\\Security\\ISecureRandom');
$this->config = $this->getMock('\\OCP\\IConfig');
$this->timeFactory = $this->getMock('\\OCP\\AppFramework\\Utility\\ITimeFactory');
$this->l10n = $this->getMock('\\OCP\\IL10N');
$this->updateChecker = $this->getMockBuilder('\\OCA\\UpdateNotification\\UpdateChecker')
->disableOriginalConstructor()->getMock();
$this->dateTimeFormatter = $this->getMock('\\OCP\\IDateTimeFormatter');
$this->request = $this->getMockBuilder('\\OCP\\IRequest')->getMock();
$this->jobList = $this->getMockBuilder('\\OCP\\BackgroundJob\\IJobList')->getMock();
$this->secureRandom = $this->getMockBuilder('\\OCP\\Security\\ISecureRandom')->getMock();
$this->config = $this->getMockBuilder('\\OCP\\IConfig')->getMock();
$this->timeFactory = $this->getMockBuilder('\\OCP\\AppFramework\\Utility\\ITimeFactory')->getMock();
$this->l10n = $this->getMockBuilder('\\OCP\\IL10N')->getMock();
$this->updateChecker = $this->getMockBuilder('\\OCA\\UpdateNotification\\UpdateChecker')->disableOriginalConstructor()->getMock();
$this->dateTimeFormatter = $this->getMockBuilder('\\OCP\\IDateTimeFormatter')->getMock();
$this->adminController = new AdminController(
'updatenotification',
@ -197,4 +196,12 @@ class AdminControllerTest extends TestCase {
$expected = new DataResponse('MyGeneratedToken');
$this->assertEquals($expected, $this->adminController->createCredentials());
}
public function testGetSection() {
$this->assertSame('server', $this->adminController->getSection());
}
public function testGetPriority() {
$this->assertSame(1, $this->adminController->getPriority());
}
}

View File

@ -27,8 +27,6 @@
*
*/
OCP\App::registerAdmin('user_ldap', 'settings');
$helper = new \OCA\User_LDAP\Helper();
$configPrefixes = $helper->getServerConfigurationPrefixes(true);
$ldapWrapper = new OCA\User_LDAP\LDAP();

View File

@ -9,7 +9,7 @@ A user logs into ownCloud with their LDAP or AD credentials, and is granted acce
</description>
<licence>AGPL</licence>
<author>Dominik Schmidt and Arthur Schiwon</author>
<version>1.0.0</version>
<version>1.0.1</version>
<types>
<authentication/>
</types>
@ -27,4 +27,9 @@ A user logs into ownCloud with their LDAP or AD credentials, and is granted acce
<job>OCA\User_LDAP\Jobs\UpdateGroups</job>
<job>OCA\User_LDAP\Jobs\CleanUp</job>
</background-jobs>
<settings>
<admin>OCA\User_LDAP\Settings\Admin</admin>
<admin-section>OCA\User_LDAP\Settings\Section</admin-section>
</settings>
</info>

View File

@ -0,0 +1,89 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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 OCA\User_LDAP\Settings;
use OCA\User_LDAP\Configuration;
use OCA\User_LDAP\Helper;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IL10N;
use OCP\Settings\ISettings;
use OCP\Template;
class Admin implements ISettings {
/** @var IL10N */
private $l;
/**
* @param IL10N $l
*/
public function __construct(IL10N $l) {
$this->l = $l;
}
/**
* @return TemplateResponse
*/
public function getForm() {
$helper = new Helper();
$prefixes = $helper->getServerConfigurationPrefixes();
$hosts = $helper->getServerConfigurationHosts();
$wControls = new Template('user_ldap', 'part.wizardcontrols');
$wControls = $wControls->fetchPage();
$sControls = new Template('user_ldap', 'part.settingcontrols');
$sControls = $sControls->fetchPage();
$parameters['serverConfigurationPrefixes'] = $prefixes;
$parameters['serverConfigurationHosts'] = $hosts;
$parameters['settingControls'] = $sControls;
$parameters['wizardControls'] = $wControls;
// assign default values
$config = new Configuration('', false);
$defaults = $config->getDefaults();
foreach($defaults as $key => $default) {
$parameters[$key.'_default'] = $default;
}
return new TemplateResponse('user_ldap', 'settings', $parameters);
}
/**
* @return string the section ID, e.g. 'sharing'
*/
public function getSection() {
return 'ldap';
}
/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
public function getPriority() {
return 5;
}
}

View File

@ -0,0 +1,67 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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 OCA\User_LDAP\Settings;
use OCP\IL10N;
use OCP\Settings\ISection;
class Section implements ISection {
/** @var IL10N */
private $l;
public function __construct(IL10N $l) {
$this->l = $l;
}
/**
* returns the ID of the section. It is supposed to be a lower case string,
* e.g. 'ldap'
*
* @returns string
*/
public function getID() {
return 'ldap';
}
/**
* returns the translated name as it should be displayed, e.g. 'LDAP / AD
* integration'. Use the L10N service to translate it.
*
* @return string
*/
public function getName() {
return $this->l->t('LDAP / AD integration');
}
/**
* @return int whether the form should be rather on the top or bottom of
* the settings navigation. The sections are arranged in ascending order of
* the priority values. It is required to return a value between 0 and 99.
*
* E.g.: 70
*/
public function getPriority() {
return 25;
}
}

View File

@ -1,75 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Dominik Schmidt <dev@dominik-schmidt.de>
* @author Joas Schilling <coding@schilljs.com>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author Robin McCorkell <robin@mccorkell.me.uk>
* @author Volkan Gezer <volkangezer@gmail.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/>
*
*/
// fill template
$tmpl = new OCP\Template('user_ldap', 'settings');
$helper = new \OCA\User_LDAP\Helper();
$prefixes = $helper->getServerConfigurationPrefixes();
$hosts = $helper->getServerConfigurationHosts();
$wizardHtml = '';
$toc = array();
$wControls = new OCP\Template('user_ldap', 'part.wizardcontrols');
$wControls = $wControls->fetchPage();
$sControls = new OCP\Template('user_ldap', 'part.settingcontrols');
$sControls = $sControls->fetchPage();
$l = \OC::$server->getL10N('user_ldap');
$wizTabs = array();
$wizTabs[] = array('tpl' => 'part.wizard-server', 'cap' => $l->t('Server'));
$wizTabs[] = array('tpl' => 'part.wizard-userfilter', 'cap' => $l->t('Users'));
$wizTabs[] = array('tpl' => 'part.wizard-loginfilter', 'cap' => $l->t('Login Attributes'));
$wizTabs[] = array('tpl' => 'part.wizard-groupfilter', 'cap' => $l->t('Groups'));
$wizTabsCount = count($wizTabs);
for($i = 0; $i < $wizTabsCount; $i++) {
$tab = new OCP\Template('user_ldap', $wizTabs[$i]['tpl']);
if($i === 0) {
$tab->assign('serverConfigurationPrefixes', $prefixes);
$tab->assign('serverConfigurationHosts', $hosts);
}
$tab->assign('wizardControls', $wControls);
$wizardHtml .= $tab->fetchPage();
$toc['#ldapWizard'.($i+1)] = $wizTabs[$i]['cap'];
}
$tmpl->assign('tabs', $wizardHtml);
$tmpl->assign('toc', $toc);
$tmpl->assign('settingControls', $sControls);
// assign default values
$config = new \OCA\User_LDAP\Configuration('', false);
$defaults = $config->getDefaults();
foreach($defaults as $key => $default) {
$tmpl->assign($key.'_default', $default);
}
return $tmpl->fetchPage();

View File

@ -49,6 +49,9 @@ script('user_ldap', [
style('user_ldap', 'settings');
/** @var \OCP\IL10N $l */
/** @var array $_ */
?>
<form id="ldap" class="section" action="#" method="post">
@ -56,20 +59,24 @@ style('user_ldap', 'settings');
<div id="ldapSettings">
<ul>
<?php foreach($_['toc'] as $id => $title) { ?>
<li id="<?php p($id); ?>"><a href="<?php p($id); ?>"><?php p($title); ?></a></li>
<?php } ?>
<li id="#ldapWizard1"><a href="#ldapWizard1"><?php p($l->t('Server'));?></a></li>
<li id="#ldapWizard2"><a href="#ldapWizard2"><?php p($l->t('Users'));?></a></li>
<li id="#ldapWizard3"><a href="#ldapWizard3"><?php p($l->t('Login Attributes'));?></a></li>
<li id="#ldapWizard4"><a href="#ldapWizard4"><?php p($l->t('Groups'));?></a></li>
<li class="ldapSettingsTabs"><a href="#ldapSettings-2"><?php p($l->t('Expert'));?></a></li>
<li class="ldapSettingsTabs"><a href="#ldapSettings-1"><?php p($l->t('Advanced'));?></a></li>
</ul>
<?php if(OCP\App::isEnabled('user_webdavauth')) {
print_unescaped('<p class="ldapwarning">'.$l->t('<b>Warning:</b> Apps user_ldap and user_webdavauth are incompatible. You may experience unexpected behavior. Please ask your system administrator to disable one of them.').'</p>');
}
if(!function_exists('ldap_connect')) {
print_unescaped('<p class="ldapwarning">'.$l->t('<b>Warning:</b> The PHP LDAP module is not installed, the backend will not work. Please ask your system administrator to install it.').'</p>');
}
?>
<?php print_unescaped($_['tabs']); ?>
<?php if(OCP\App::isEnabled('user_webdavauth')) {
print_unescaped('<p class="ldapwarning">'.$l->t('<b>Warning:</b> Apps user_ldap and user_webdavauth are incompatible. You may experience unexpected behavior. Please ask your system administrator to disable one of them.').'</p>');
}
if(!function_exists('ldap_connect')) {
print_unescaped('<p class="ldapwarning">'.$l->t('<b>Warning:</b> The PHP LDAP module is not installed, the backend will not work. Please ask your system administrator to install it.').'</p>');
}
?>
<?php require_once(__DIR__ . '/part.wizard-server.php'); ?>
<?php require_once(__DIR__ . '/part.wizard-userfilter.php'); ?>
<?php require_once(__DIR__ . '/part.wizard-loginfilter.php'); ?>
<?php require_once(__DIR__ . '/part.wizard-groupfilter.php'); ?>
<fieldset id="ldapSettings-1">
<div id="ldapAdvancedAccordion">
<h3><?php p($l->t('Connection Settings'));?></h3>

View File

@ -0,0 +1,90 @@
<?php
/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @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 OCA\User_LDAP\Tests\Settings;
use OCA\User_LDAP\Configuration;
use OCA\User_LDAP\Helper;
use OCA\User_LDAP\Settings\Admin;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IL10N;
use OCP\Template;
use Test\TestCase;
/**
* @group DB
* @package OCA\User_LDAP\Tests\Settings
*/
class AdminTest extends TestCase {
/** @var Admin */
private $admin;
/** @var IL10N */
private $l10n;
public function setUp() {
parent::setUp();
$this->l10n = $this->getMockBuilder('\OCP\IL10N')->getMock();
$this->admin = new Admin(
$this->l10n
);
}
/**
* @UseDB
*/
public function testGetForm() {
$helper = new Helper();
$prefixes = $helper->getServerConfigurationPrefixes();
$hosts = $helper->getServerConfigurationHosts();
$wControls = new Template('user_ldap', 'part.wizardcontrols');
$wControls = $wControls->fetchPage();
$sControls = new Template('user_ldap', 'part.settingcontrols');
$sControls = $sControls->fetchPage();
$parameters['serverConfigurationPrefixes'] = $prefixes;
$parameters['serverConfigurationHosts'] = $hosts;
$parameters['settingControls'] = $sControls;
$parameters['wizardControls'] = $wControls;
// assign default values
$config = new Configuration('', false);
$defaults = $config->getDefaults();
foreach($defaults as $key => $default) {
$parameters[$key.'_default'] = $default;
}
$expected = new TemplateResponse('user_ldap', 'settings', $parameters);
$this->assertEquals($expected, $this->admin->getForm());
}
public function testGetSection() {
$this->assertSame('ldap', $this->admin->getSection());
}
public function testGetPriority() {
$this->assertSame(5, $this->admin->getPriority());
}
}

View File

@ -0,0 +1,62 @@
<?php
/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @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 OCA\User_LDAP\Tests\Settings;
use OCA\User_LDAP\Settings\Section;
use OCP\IL10N;
use Test\TestCase;
class SectionTest extends TestCase {
/** @var IL10N */
private $l;
/** @var Section */
private $section;
public function setUp() {
parent::setUp();
$this->l = $this->getMockBuilder('\OCP\IL10N')->getMock();
$this->section = new Section(
$this->l
);
}
public function testGetID() {
$this->assertSame('ldap', $this->section->getID());
}
public function testGetName() {
$this->l
->expects($this->once())
->method('t')
->with('LDAP / AD integration')
->willReturn('LDAP / AD integration');
$this->assertSame('LDAP / AD integration', $this->section->getName());
}
public function testGetPriority() {
$this->assertSame(25, $this->section->getPriority());
}
}

View File

@ -10,7 +10,7 @@
<?php p($l->t('Depending on your configuration, as an administrator you might also be able to use the button below to trust this domain.')); ?>
<br><br>
<p style="text-align:center;">
<a href="<?php print_unescaped(\OC::$server->getURLGenerator()->getAbsoluteURL(\OCP\Util::linkToRoute('settings_admin'))); ?>?trustDomain=<?php p($_['domain']); ?>" class="button">
<a href="<?php print_unescaped(\OC::$server->getURLGenerator()->getAbsoluteURL(\OCP\Util::linkToRoute('settings.AdminSettings.index'))); ?>?trustDomain=<?php p($_['domain']); ?>" class="button">
<?php p($l->t('Add "%s" as trusted domain', array($_['domain']))); ?>
</a>
</p>

View File

@ -1976,4 +1976,125 @@
</table>
<table>
<!-- Extra admin settings sections -->
<name>*dbprefix*admin_sections</name>
<declaration>
<field>
<name>id</name>
<type>text</type>
<default></default>
<notnull>false</notnull>
<length>64</length>
</field>
<field>
<name>class</name>
<type>text</type>
<default></default>
<notnull>true</notnull>
<length>255</length>
</field>
<field>
<name>priority</name>
<type>integer</type>
<default></default>
<notnull>true</notnull>
<length>1</length>
</field>
<index>
<name>admin_sections_id_index</name>
<primary>true</primary>
<field>
<name>id</name>
<sorting>ascending</sorting>
</field>
</index>
<index>
<name>admin_sections_class</name>
<unique>true</unique>
<field>
<name>class</name>
<sorting>ascending</sorting>
</field>
</index>
</declaration>
</table>
<table>
<!-- Extra admin settings -->
<name>*dbprefix*admin_settings</name>
<declaration>
<field>
<name>id</name>
<type>integer</type>
<default>0</default>
<notnull>true</notnull>
<autoincrement>1</autoincrement>
<length>4</length>
</field>
<field>
<name>class</name>
<type>text</type>
<default></default>
<notnull>true</notnull>
<length>255</length>
</field>
<!-- id of the section, foreign key: admin_sections.id -->
<field>
<name>section</name>
<type>text</type>
<default></default>
<notnull>false</notnull>
<length>64</length>
</field>
<field>
<name>priority</name>
<type>integer</type>
<default></default>
<notnull>true</notnull>
<length>1</length>
</field>
<index>
<name>admin_settings_id_index</name>
<primary>true</primary>
<field>
<name>id</name>
<sorting>ascending</sorting>
</field>
</index>
<index>
<name>admin_settings_class</name>
<unique>true</unique>
<field>
<name>class</name>
<sorting>ascending</sorting>
</field>
</index>
<index>
<name>admin_settings_section</name>
<unique>false</unique>
<field>
<name>section</name>
<sorting>ascending</sorting>
</field>
</index>
</declaration>
</table>
</database>

View File

@ -723,6 +723,7 @@ class OC {
self::registerLogRotate();
self::registerEncryptionWrapper();
self::registerEncryptionHooks();
self::registerSettingsHooks();
//make sure temporary files are cleaned up
$tmpManager = \OC::$server->getTempManager();
@ -801,6 +802,22 @@ class OC {
}
}
public static function registerSettingsHooks() {
$dispatcher = \OC::$server->getEventDispatcher();
$dispatcher->addListener(OCP\App\ManagerEvent::EVENT_APP_DISABLE, function($event) {
/** @var \OCP\App\ManagerEvent $event */
\OC::$server->getSettingsManager()->onAppDisabled($event->getAppID());
});
$dispatcher->addListener(OCP\App\ManagerEvent::EVENT_APP_UPDATE, function($event) {
/** @var \OCP\App\ManagerEvent $event */
$jobList = \OC::$server->getJobList();
$job = 'OC\\Settings\\RemoveOrphaned';
if(!($jobList->has($job, null))) {
$jobList->add($job);
}
});
}
private static function registerEncryptionWrapper() {
$manager = self::$server->getEncryptionManager();
\OCP\Util::connectHook('OC_Filesystem', 'preSetup', $manager, 'setupStorage');

View File

@ -124,6 +124,10 @@ class DIContainer extends SimpleContainer implements IAppContainer {
return $this->getServer()->getDateTimeZone();
});
$this->registerService('OCP\\IDateTimeFormatter', function($c) {
return $this->getServer()->getDateTimeFormatter();
});
$this->registerService('OCP\\IDb', function($c) {
return $this->getServer()->getDb();
});
@ -148,6 +152,10 @@ class DIContainer extends SimpleContainer implements IAppContainer {
return $this->getServer()->getMountProviderCollection();
});
$this->registerService('OCP\\Files\\Config\\IUserMountCache', function($c) {
return $this->getServer()->getUserMountCache();
});
$this->registerService('OCP\\Files\\IRootFolder', function($c) {
return $this->getServer()->getRootFolder();
});
@ -306,6 +314,10 @@ class DIContainer extends SimpleContainer implements IAppContainer {
return $c->query('ServerContainer')->getWebRoot();
});
$this->registerService('OCP\Encryption\IManager', function ($c) {
return $this->getServer()->getEncryptionManager();
});
/**
* App Framework APIs

View File

@ -593,6 +593,12 @@ class Installer {
OC_App::setAppTypes($info['id']);
if(isset($info['settings']) && is_array($info['settings'])) {
// requires that autoloading was registered for the app,
// as happens before running the install.php some lines above
\OC::$server->getSettingsManager()->setupSettings($info['settings']);
}
return $info['id'];
}

View File

@ -82,7 +82,7 @@ use OC\Security\SecureRandom;
use OC\Security\TrustedDomainHelper;
use OC\Session\CryptoWrapper;
use OC\Tagging\TagMapper;
use OCA\Theming\Template;
use OCA\Theming\ThemingDefaults;
use OCP\IL10N;
use OCP\IServerContainer;
use OCP\Security\IContentSecurityPolicyManager;
@ -650,7 +650,7 @@ class Server extends ServerContainer implements IServerContainer {
}
if ($classExists && $this->getConfig()->getSystemValue('installed', false) && $this->getAppManager()->isInstalled('theming')) {
return new Template(
return new ThemingDefaults(
$this->getConfig(),
$this->getL10N('theming'),
$this->getURLGenerator(),
@ -721,6 +721,18 @@ class Server extends ServerContainer implements IServerContainer {
return $manager;
});
$this->registerService('SettingsManager', function(Server $c) {
$manager = new \OC\Settings\Manager(
$c->getLogger(),
$c->getDatabaseConnection(),
$c->getL10N('core'),
$c->getConfig(),
$c->getEncryptionManager(),
$c->getUserManager(),
$c->getLockingProvider()
);
return $manager;
});
}
/**
@ -1276,6 +1288,11 @@ class Server extends ServerContainer implements IServerContainer {
return $this->query('MountManager');
}
/** @return \OCP\Files\Config\IUserMountCache */
function getUserMountCache() {
return $this->query('UserMountCache');
}
/**
* Get the MimeTypeDetector
*
@ -1424,4 +1441,11 @@ class Server extends ServerContainer implements IServerContainer {
public function getLDAPProvider() {
return $this->query('LDAPProvider');
}
/**
* @return \OCP\Settings\IManager
*/
public function getSettingsManager() {
return $this->query('SettingsManager');
}
}

View File

@ -0,0 +1,88 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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\Settings\Admin;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use OC\Lock\DBLockingProvider;
use OC\Lock\NoopLockingProvider;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\Lock\ILockingProvider;
use OCP\Settings\ISettings;
class Additional implements ISettings {
/** @var IConfig */
private $config;
/**
* @param IConfig $config
*/
public function __construct(IConfig $config) {
$this->config = $config;
}
/**
* @return TemplateResponse
*/
public function getForm() {
$parameters = [
// Mail
'sendmail_is_available' => (bool) \OC_Helper::findBinaryPath('sendmail'),
'mail_domain' => $this->config->getSystemValue('mail_domain', ''),
'mail_from_address' => $this->config->getSystemValue('mail_from_address', ''),
'mail_smtpmode' => $this->config->getSystemValue('mail_smtpmode', ''),
'mail_smtpsecure' => $this->config->getSystemValue('mail_smtpsecure', ''),
'mail_smtphost' => $this->config->getSystemValue('mail_smtphost', ''),
'mail_smtpport' => $this->config->getSystemValue('mail_smtpport', ''),
'mail_smtpauthtype' => $this->config->getSystemValue('mail_smtpauthtype', ''),
'mail_smtpauth' => $this->config->getSystemValue('mail_smtpauth', false),
'mail_smtpname' => $this->config->getSystemValue('mail_smtpname', ''),
'mail_smtppassword' => $this->config->getSystemValue('mail_smtppassword', ''),
];
return new TemplateResponse('settings', 'admin/additional-mail', $parameters, '');
}
/**
* @return string the section ID, e.g. 'sharing'
*/
public function getSection() {
return 'additional';
}
/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
public function getPriority() {
return 0;
}
}

View File

@ -0,0 +1,91 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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\Settings\Admin;
use OC\Encryption\Manager;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IUserManager;
use OCP\Settings\ISettings;
class Encryption implements ISettings {
/** @var Manager */
private $manager;
/** @var IUserManager */
private $userManager;
/**
* @param Manager $manager
* @param IUserManager $userManager
*/
public function __construct(Manager $manager, IUserManager $userManager) {
$this->manager = $manager;
$this->userManager = $userManager;
}
/**
* @return TemplateResponse
*/
public function getForm() {
$encryptionModules = $this->manager->getEncryptionModules();
$defaultEncryptionModuleId = $this->manager->getDefaultEncryptionModuleId();
$encryptionModuleList = [];
foreach ($encryptionModules as $module) {
$encryptionModuleList[$module['id']]['displayName'] = $module['displayName'];
$encryptionModuleList[$module['id']]['default'] = false;
if ($module['id'] === $defaultEncryptionModuleId) {
$encryptionModuleList[$module['id']]['default'] = true;
}
}
$parameters = [
// Encryption API
'encryptionEnabled' => $this->manager->isEnabled(),
'encryptionReady' => $this->manager->isReady(),
'externalBackendsEnabled' => count($this->userManager->getBackends()) > 1,
// Modules
'encryptionModules' => $encryptionModuleList,
];
return new TemplateResponse('settings', 'admin/encryption', $parameters, '');
}
/**
* @return string the section ID, e.g. 'sharing'
*/
public function getSection() {
return 'encryption';
}
/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
public function getPriority() {
return 0;
}
}

View File

@ -0,0 +1,86 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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\Settings\Admin;
use OC\Log\Owncloud as LogFile;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\Settings\ISettings;
class Logging implements ISettings {
/** @var IConfig */
private $config;
/**
* @param IConfig $config
*/
public function __construct(IConfig $config) {
$this->config = $config;
}
/**
* @return TemplateResponse
*/
public function getForm() {
$logType = $this->config->getSystemValue('log_type', 'file');
$showLog = ($logType === 'file' || $logType === 'owncloud');
$numEntriesToLoad = 5;
$entries = LogFile::getEntries($numEntriesToLoad + 1);
$entriesRemaining = count($entries) > $numEntriesToLoad;
$entries = array_slice($entries, 0, $numEntriesToLoad);
$logFileExists = file_exists(LogFile::getLogFilePath()) ;
$logFileSize = $logFileExists ? filesize(LogFile::getLogFilePath()) : 0;
$parameters = [
'loglevel' => $this->config->getSystemValue('loglevel', 2),
'entries' => $entries,
'entriesremain' => $entriesRemaining,
'doesLogFileExist' => $logFileExists,
'logFileSize' => $logFileSize,
'showLog' => $showLog,
];
return new TemplateResponse('settings', 'admin/logging', $parameters, '');
}
/**
* @return string the section ID, e.g. 'sharing'
*/
public function getSection() {
return 'logging';
}
/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
public function getPriority() {
return 0;
}
}

View File

@ -0,0 +1,149 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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\Settings\Admin;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use OC\Lock\DBLockingProvider;
use OC\Lock\NoopLockingProvider;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\Lock\ILockingProvider;
use OCP\Settings\ISettings;
class Server implements ISettings {
/** @var IDBConnection|Connection */
private $db;
/** @var IConfig */
private $config;
/** @var ILockingProvider */
private $lockingProvider;
/** @var IL10N */
private $l;
/**
* @param IDBConnection $db
* @param IConfig $config
* @param ILockingProvider $lockingProvider
* @param IL10N $l
*/
public function __construct(IDBConnection $db,
IConfig $config,
ILockingProvider $lockingProvider,
IL10N $l) {
$this->db = $db;
$this->config = $config;
$this->lockingProvider = $lockingProvider;
$this->l = $l;
}
/**
* @return TemplateResponse
*/
public function getForm() {
try {
if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) {
$invalidTransactionIsolationLevel = false;
} else {
$invalidTransactionIsolationLevel = $this->db->getTransactionIsolation() !== Connection::TRANSACTION_READ_COMMITTED;
}
} catch (DBALException $e) {
// ignore
$invalidTransactionIsolationLevel = false;
}
$envPath = getenv('PATH');
// warn if outdated version of a memcache module is used
$caches = [
'apcu' => ['name' => $this->l->t('APCu'), 'version' => '4.0.6'],
'redis' => ['name' => $this->l->t('Redis'), 'version' => '2.2.5'],
];
$outdatedCaches = [];
foreach ($caches as $php_module => $data) {
$isOutdated = extension_loaded($php_module) && version_compare(phpversion($php_module), $data['version'], '<');
if ($isOutdated) {
$outdatedCaches[$php_module] = $data;
}
}
if ($this->lockingProvider instanceof NoopLockingProvider) {
$fileLockingType = 'none';
} else if ($this->lockingProvider instanceof DBLockingProvider) {
$fileLockingType = 'db';
} else {
$fileLockingType = 'cache';
}
// If the current web root is non-empty but the web root from the config is,
// and system cron is used, the URL generator fails to build valid URLs.
$shouldSuggestOverwriteCliUrl = $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax') === 'cron'
&& \OC::$WEBROOT && \OC::$WEBROOT !== '/'
&& !$this->config->getSystemValue('overwrite.cli.url', '');
$suggestedOverwriteCliUrl = ($shouldSuggestOverwriteCliUrl) ? \OC::$WEBROOT : '';
$parameters = [
// Diagnosis
'readOnlyConfigEnabled' => \OC_Helper::isReadOnlyConfigEnabled(),
'isLocaleWorking' => \OC_Util::isSetLocaleWorking(),
'isAnnotationsWorking' => \OC_Util::isAnnotationsWorking(),
'checkForWorkingWellKnownSetup' => $this->config->getSystemValue('check_for_working_wellknown_setup', true),
'has_fileinfo' => \OC_Util::fileInfoLoaded(),
'invalidTransactionIsolationLevel' => $invalidTransactionIsolationLevel,
'getenvServerNotWorking' => empty($envPath),
'OutdatedCacheWarning' => $outdatedCaches,
'fileLockingType' => $fileLockingType,
'suggestedOverwriteCliUrl' => $suggestedOverwriteCliUrl,
// Background jobs
'backgroundjobs_mode' => $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax'),
'cron_log' => $this->config->getSystemValue('cron_log', true),
'lastcron' => $this->config->getAppValue('core', 'lastcron', false),
'cronErrors' => $this->config->getAppValue('core', 'cronErrors'),
];
return new TemplateResponse('settings', 'admin/server', $parameters, '');
}
/**
* @return string the section ID, e.g. 'sharing'
*/
public function getSection() {
return 'server';
}
/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
public function getPriority() {
return 0;
}
}

View File

@ -0,0 +1,90 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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\Settings\Admin;
use OC\Share\Share;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\Settings\ISettings;
use OCP\Util;
class Sharing implements ISettings {
/** @var IConfig */
private $config;
/**
* @param IConfig $config
*/
public function __construct(IConfig $config) {
$this->config = $config;
}
/**
* @return TemplateResponse
*/
public function getForm() {
$excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
$excludeGroupsList = !is_null(json_decode($excludedGroups))
? implode('|', json_decode($excludedGroups, true)) : '';
$parameters = [
// Built-In Sharing
'allowGroupSharing' => $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes'),
'allowLinks' => $this->config->getAppValue('core', 'shareapi_allow_links', 'yes'),
'allowMailNotification' => $this->config->getAppValue('core', 'shareapi_allow_mail_notification', 'no'),
'allowPublicMailNotification' => $this->config->getAppValue('core', 'shareapi_allow_public_notification', 'no'),
'allowPublicUpload' => $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes'),
'allowResharing' => $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes'),
'allowShareDialogUserEnumeration' => $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes'),
'enforceLinkPassword' => Util::isPublicLinkPasswordRequired(),
'onlyShareWithGroupMembers' => Share::shareWithGroupMembersOnly(),
'shareAPIEnabled' => $this->config->getAppValue('core', 'shareapi_enabled', 'yes'),
'shareDefaultExpireDateSet' => $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no'),
'shareExpireAfterNDays' => $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'),
'shareEnforceExpireDate' => $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no'),
'shareExcludeGroups' => $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false,
'shareExcludedGroupsList' => $excludeGroupsList,
];
return new TemplateResponse('settings', 'admin/sharing', $parameters, '');
}
/**
* @return string the section ID, e.g. 'sharing'
*/
public function getSection() {
return 'sharing';
}
/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
public function getPriority() {
return 0;
}
}

View File

@ -0,0 +1,71 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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\Settings\Admin;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\Settings\ISettings;
class TipsTricks implements ISettings {
/** @var IConfig */
private $config;
/**
* @param IConfig $config
*/
public function __construct(IConfig $config) {
$this->config = $config;
}
/**
* @return TemplateResponse
*/
public function getForm() {
$databaseOverload = (strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false);
$parameters = [
'databaseOverload' => $databaseOverload,
];
return new TemplateResponse('settings', 'admin/tipstricks', $parameters, '');
}
/**
* @return string the section ID, e.g. 'sharing'
*/
public function getSection() {
return 'tips-tricks';
}
/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
*/
public function getPriority() {
return 0;
}
}

View File

@ -0,0 +1,431 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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\Settings;
use OCP\AppFramework\QueryException;
use OCP\Encryption\IManager as EncryptionManager;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IUserManager;
use OCP\Lock\ILockingProvider;
use OCP\Settings\ISettings;
use OCP\Settings\IManager;
use OCP\Settings\ISection;
class Manager implements IManager {
const TABLE_ADMIN_SETTINGS = 'admin_settings';
const TABLE_ADMIN_SECTIONS = 'admin_sections';
/** @var ILogger */
private $log;
/** @var IDBConnection */
private $dbc;
/** @var IL10N */
private $l;
/** @var IConfig */
private $config;
/** @var EncryptionManager */
private $encryptionManager;
/** @var IUserManager */
private $userManager;
/** @var ILockingProvider */
private $lockingProvider;
/**
* @param ILogger $log
* @param IDBConnection $dbc
* @param IL10N $l
* @param IConfig $config
* @param EncryptionManager $encryptionManager
* @param IUserManager $userManager
* @param ILockingProvider $lockingProvider
*/
public function __construct(
ILogger $log,
IDBConnection $dbc,
IL10N $l,
IConfig $config,
EncryptionManager $encryptionManager,
IUserManager $userManager,
ILockingProvider $lockingProvider
) {
$this->log = $log;
$this->dbc = $dbc;
$this->l = $l;
$this->config = $config;
$this->encryptionManager = $encryptionManager;
$this->userManager = $userManager;
$this->lockingProvider = $lockingProvider;
}
/**
* @inheritdoc
*/
public function setupSettings(array $settings) {
if(isset($settings[IManager::KEY_ADMIN_SECTION])) {
$this->setupAdminSection($settings[IManager::KEY_ADMIN_SECTION]);
}
if(isset($settings[IManager::KEY_ADMIN_SETTINGS])) {
$this->setupAdminSettings($settings[IManager::KEY_ADMIN_SETTINGS]);
}
}
/**
* attempts to remove an apps section and/or settings entry. A listener is
* added centrally making sure that this method is called ones an app was
* disabled.
*
* @param string $appId
* @since 9.1.0
*/
public function onAppDisabled($appId) {
$appInfo = \OC_App::getAppInfo($appId); // hello static legacy
if(isset($appInfo['settings'][IManager::KEY_ADMIN_SECTION])) {
$this->remove(self::TABLE_ADMIN_SECTIONS, $appInfo['settings'][IManager::KEY_ADMIN_SECTION]);
}
if(isset($settings['settings'][IManager::KEY_ADMIN_SETTINGS])) {
$this->remove(self::TABLE_ADMIN_SETTINGS, $appInfo['settings'][IManager::KEY_ADMIN_SETTINGS]);
}
}
public function checkForOrphanedClassNames() {
$tables = [ self::TABLE_ADMIN_SECTIONS, self::TABLE_ADMIN_SETTINGS ];
foreach ($tables as $table) {
$classes = $this->getClasses($table);
foreach($classes as $className) {
try {
\OC::$server->query($className);
} catch (QueryException $e) {
$this->remove($table, $className);
}
}
}
}
/**
* returns the registerd classes in the given table
*
* @param $table
* @return string[]
*/
private function getClasses($table) {
$q = $this->dbc->getQueryBuilder();
$resultStatement = $q->select('class')
->from($table)
->execute();
$data = $resultStatement->fetchAll();
$resultStatement->closeCursor();
return array_map(function($row) { return $row['class']; }, $data);
}
/**
* @param string $sectionClassName
*/
private function setupAdminSection($sectionClassName) {
if(!class_exists($sectionClassName)) {
$this->log->debug('Could not find admin section class ' . $sectionClassName);
return;
}
try {
$section = $this->query($sectionClassName);
} catch (QueryException $e) {
// cancel
return;
}
if(!$section instanceof ISection) {
$this->log->error(
'Admin section instance must implement \OCP\ISection. Invalid class: {class}',
['class' => $sectionClassName]
);
return;
}
if(!$this->hasAdminSection(get_class($section))) {
$this->addAdminSection($section);
} else {
$this->updateAdminSection($section);
}
}
private function addAdminSection(ISection $section) {
$this->add(self::TABLE_ADMIN_SECTIONS, [
'id' => $section->getID(),
'class' => get_class($section),
'priority' => $section->getPriority(),
]);
}
private function addAdminSettings(ISettings $settings) {
$this->add(self::TABLE_ADMIN_SETTINGS, [
'class' => get_class($settings),
'section' => $settings->getSection(),
'priority' => $settings->getPriority(),
]);
}
/**
* @param string $table
* @param array $values
*/
private function add($table, array $values) {
$query = $this->dbc->getQueryBuilder();
$values = array_map(function($value) use ($query) {
return $query->createNamedParameter($value);
}, $values);
$query->insert($table)->values($values);
$query->execute();
}
private function updateAdminSettings(ISettings $settings) {
$this->update(
self::TABLE_ADMIN_SETTINGS,
'class',
get_class($settings),
[
'section' => $settings->getSection(),
'priority' => $settings->getPriority(),
]
);
}
private function updateAdminSection(ISection $section) {
$this->update(
self::TABLE_ADMIN_SECTIONS,
'class',
get_class($section),
[
'id' => $section->getID(),
'priority' => $section->getPriority(),
]
);
}
private function update($table, $idCol, $id, $values) {
$query = $this->dbc->getQueryBuilder();
$query->update($table);
foreach($values as $key => $value) {
$query->set($key, $query->createNamedParameter($value));
}
$query
->where($query->expr()->eq($idCol, $query->createParameter($idCol)))
->setParameter($idCol, $id)
->execute();
}
/**
* @param string $className
* @return bool
*/
private function hasAdminSection($className) {
return $this->has(self::TABLE_ADMIN_SECTIONS, $className);
}
/**
* @param string $className
* @return bool
*/
private function hasAdminSettings($className) {
return $this->has(self::TABLE_ADMIN_SETTINGS, $className);
}
/**
* @param string $table
* @param string $className
* @return bool
*/
private function has($table, $className) {
$query = $this->dbc->getQueryBuilder();
$query->select('class')
->from($table)
->where($query->expr()->eq('class', $query->createNamedParameter($className)))
->setMaxResults(1);
$result = $query->execute();
$row = $result->fetch();
$result->closeCursor();
return (bool) $row;
}
/**
* deletes an settings or admin entry from the given table
*
* @param $table
* @param $className
*/
private function remove($table, $className) {
$query = $this->dbc->getQueryBuilder();
$query->delete($table)
->where($query->expr()->eq('class', $query->createNamedParameter($className)));
$query->execute();
}
private function setupAdminSettings($settingsClassName) {
if(!class_exists($settingsClassName)) {
$this->log->debug('Could not find admin section class ' . $settingsClassName);
return;
}
try {
/** @var ISettings $settings */
$settings = $this->query($settingsClassName);
} catch (QueryException $e) {
// cancel
return;
}
if(!$settings instanceof ISettings) {
$this->log->error(
'Admin section instance must implement \OCP\ISection. Invalid class: {class}',
['class' => $settingsClassName]
);
return;
}
if(!$this->hasAdminSettings(get_class($settings))) {
$this->addAdminSettings($settings);
} else {
$this->updateAdminSettings($settings);
}
}
private function query($className) {
try {
return \OC::$server->query($className);
} catch (QueryException $e) {
$this->log->logException($e);
throw $e;
}
}
/**
* @inheritdoc
*/
public function getAdminSections() {
$query = $this->dbc->getQueryBuilder();
$query->select(['class', 'priority'])
->from(self::TABLE_ADMIN_SECTIONS);
// built-in sections
$sections = [
0 => [new Section('server', $this->l->t('Server settings'), 0)],
5 => [new Section('sharing', $this->l->t('Sharing'), 0)],
45 => [new Section('encryption', $this->l->t('Encryption'), 0)],
90 => [new Section('logging', $this->l->t('Logging'), 0)],
98 => [new Section('additional', $this->l->t('Additional settings'), 0)],
99 => [new Section('tips-tricks', $this->l->t('Tips & tricks'), 0)],
];
$result = $query->execute();
while($row = $result->fetch()) {
if(!isset($sections[$row['priority']])) {
$sections[$row['priority']] = [];
}
try {
$sections[$row['priority']][] = $this->query($row['class']);
} catch (QueryException $e) {
// skip
}
}
$result->closeCursor();
ksort($sections);
return $sections;
}
private function getBuiltInAdminSettings($section) {
$forms = [];
try {
if($section === 'server') {
/** @var ISettings $form */
$form = new Admin\Server($this->dbc, $this->config, $this->lockingProvider, $this->l);
$forms[$form->getPriority()] = [$form];
}
if($section === 'encryption') {
/** @var ISettings $form */
$form = new Admin\Encryption($this->encryptionManager, $this->userManager);
$forms[$form->getPriority()] = [$form];
}
if($section === 'sharing') {
/** @var ISettings $form */
$form = new Admin\Sharing($this->config);
$forms[$form->getPriority()] = [$form];
}
if($section === 'logging') {
/** @var ISettings $form */
$form = new Admin\Logging($this->config);
$forms[$form->getPriority()] = [$form];
}
if($section === 'additional') {
/** @var ISettings $form */
$form = new Admin\Additional($this->config);
$forms[$form->getPriority()] = [$form];
}
if($section === 'tips-tricks') {
/** @var ISettings $form */
$form = new Admin\TipsTricks($this->config);
$forms[$form->getPriority()] = [$form];
}
} catch (QueryException $e) {
// skip
}
return $forms;
}
private function getAdminSettingsFromDB($section, &$settings) {
$query = $this->dbc->getQueryBuilder();
$query->select(['class', 'priority'])
->from(self::TABLE_ADMIN_SETTINGS)
->where($query->expr()->eq('section', $this->dbc->getQueryBuilder()->createParameter('section')))
->setParameter('section', $section);
$result = $query->execute();
while($row = $result->fetch()) {
if(!isset($settings[$row['priority']])) {
$settings[$row['priority']] = [];
}
try {
$settings[$row['priority']][] = $this->query($row['class']);
} catch (QueryException $e) {
// skip
}
}
$result->closeCursor();
ksort($settings);
}
/**
* @inheritdoc
*/
public function getAdminSettings($section) {
$settings = $this->getBuiltInAdminSettings($section);
$this->getAdminSettingsFromDB($section, $settings);
return $settings;
}
}

View File

@ -0,0 +1,91 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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\Settings;
use OC\BackgroundJob\JobList;
use OC\BackgroundJob\TimedJob;
use OC\NeedsUpdateException;
use OCP\BackgroundJob\IJobList;
use OCP\ILogger;
/**
* Class RemoveOrphaned
*
* @package OC\Settings
*/
class RemoveOrphaned extends TimedJob {
/** @var IJobList */
private $jobList;
/** @var ILogger */
private $logger;
/** @var Manager */
private $manager;
public function __construct(Manager $manager = null) {
if($manager !== null) {
$this->manager = $manager;
} else {
// fix DI for Jobs
$this->manager = \OC::$server->getSettingsManager();
}
}
/**
* run the job, then remove it from the job list
*
* @param JobList $jobList
* @param ILogger $logger
*/
public function execute($jobList, ILogger $logger = null) {
// add an interval of 15 mins
$this->setInterval(15*60);
$this->jobList = $jobList;
$this->logger = $logger;
parent::execute($jobList, $logger);
}
/**
* @param array $argument
* @throws \Exception
* @throws \OC\NeedsUpdateException
*/
protected function run($argument) {
try {
\OC_App::loadApps();
} catch (NeedsUpdateException $ex) {
// only run when apps are up to date
return;
}
$this->manager->checkForOrphanedClassNames();
// remove the job once executed successfully
$this->jobList->remove($this);
}
}

View File

@ -0,0 +1,77 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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\Settings;
use OCP\Settings\ISection;
class Section implements ISection {
/** @var string */
private $id;
/** @var string */
private $name;
/** @var int */
private $priority;
/**
* @param string $id
* @param string $name
* @param int $priority
*/
public function __construct($id, $name, $priority) {
$this->id = $id;
$this->name = $name;
$this->priority = $priority;
}
/**
* returns the ID of the section. It is supposed to be a lower case string,
* e.g. 'ldap'
*
* @returns string
*/
public function getID() {
return $this->id;
}
/**
* returns the translated name as it should be displayed, e.g. 'LDAP / AD
* integration'. Use the L10N service to translate it.
*
* @return string
*/
public function getName() {
return $this->name;
}
/**
* @return int whether the form should be rather on the top or bottom of
* the settings navigation. The sections are arranged in ascending order of
* the priority values. It is required to return a value between 0 and 99.
*
* E.g.: 70
*/
public function getPriority() {
return $this->priority;
}
}

View File

@ -51,6 +51,7 @@ use OC\App\Platform;
use OC\Installer;
use OC\OCSClient;
use OC\Repair;
use OCP\App\ManagerEvent;
/**
* This class manages the apps. It allows them to register and integrate in the
@ -345,6 +346,13 @@ class OC_App {
} else {
$appManager->enableApp($app);
}
$info = self::getAppInfo($app);
if(isset($info['settings']) && is_array($info['settings'])) {
$appPath = self::getAppPath($app);
self::registerAutoloading($app, $appPath);
\OC::$server->getSettingsManager()->setupSettings($info['settings']);
}
}
/**
@ -471,7 +479,7 @@ class OC_App {
$settings[] = array(
"id" => "admin",
"order" => 1000,
"href" => $urlGenerator->linkToRoute('settings_admin'),
"href" => $urlGenerator->linkToRoute('settings.AdminSettings.index'),
"name" => $l->t("Admin"),
"icon" => $urlGenerator->imagePath("settings", "admin.svg")
);
@ -1162,6 +1170,13 @@ class OC_App {
if (isset($appData['id'])) {
$config->setAppValue($app, 'ocsid', $appData['id']);
}
if(isset($info['settings']) && is_array($info['settings'])) {
$appPath = self::getAppPath($app);
self::registerAutoloading($app, $appPath);
\OC::$server->getSettingsManager()->setupSettings($info['settings']);
}
\OC_Hook::emit('OC_App', 'post_enable', array('app' => $app));
} else {
if(empty($appName) ) {
@ -1199,6 +1214,11 @@ class OC_App {
include $appPath . '/appinfo/update.php';
}
self::setupBackgroundJobs($appData['background-jobs']);
if(isset($appData['settings']) && is_array($appData['settings'])) {
$appPath = self::getAppPath($appId);
self::registerAutoloading($appId, $appPath);
\OC::$server->getSettingsManager()->setupSettings($appData['settings']);
}
//set remote/public handlers
if (array_key_exists('ocsid', $appData)) {
@ -1218,6 +1238,10 @@ class OC_App {
$version = \OC_App::getAppVersion($appId);
\OC::$server->getAppConfig()->setValue($appId, 'installed_version', $version);
\OC::$server->getEventDispatcher()->dispatch(ManagerEvent::EVENT_APP_UPDATE, new ManagerEvent(
ManagerEvent::EVENT_APP_UPDATE, $appId
));
return true;
}

View File

@ -36,6 +36,11 @@ class ManagerEvent extends Event {
const EVENT_APP_ENABLE_FOR_GROUPS = 'OCP\App\IAppManager::enableAppForGroups';
const EVENT_APP_DISABLE = 'OCP\App\IAppManager::disableApp';
/**
* @since 9.1.0
*/
const EVENT_APP_UPDATE = 'OCP\App\IAppManager::updateApp';
/** @var string */
protected $event;
/** @var string */

View File

@ -0,0 +1,98 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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 OCP\Settings;
/**
* @since 9.1
*/
interface IManager {
/**
* @since 9.1.0
*/
const KEY_ADMIN_SETTINGS = 'admin';
/**
* @since 9.1.0
*/
const KEY_ADMIN_SECTION = 'admin-section';
/**
* sets up settings according to data specified by an apps info.xml, within
* the <settings> element.
*
* @param array $settings an associative array, allowed keys are as specified
* by the KEY_ constant of this interface. The value
* must always be a class name, implement either
* IAdmin or ISection. I.e. only one section and admin
* setting can be configured per app.
* @since 9.1.0
*/
public function setupSettings(array $settings);
/**
* attempts to remove an apps section and/or settings entry. A listener is
* added centrally making sure that this method is called ones an app was
* disabled.
*
* What this does not help with is when applications change their settings
* or section classes during their life time. New entries will be added,
* but inactive ones will still reside in the database.
*
* @param string $appId
* @since 9.1.0
*/
public function onAppDisabled($appId);
/**
* The method should check all registered classes whether they are still
* instantiable and remove them, if not. This method is called by a
* background job once, after one or more apps were updated.
*
* An app`s info.xml can change during an update and make it unknown whether
* a registered class name was changed or not. An old one would just stay
* registered. Another case is if an admin takes a radical approach and
* simply removes an app from the app folder. These unregular checks will
* take care of such situations.
*
* @since 9.1.0
*/
public function checkForOrphanedClassNames();
/**
* returns a list of the admin sections
*
* @return array array of ISection[] where key is the priority
* @since 9.1.0
*/
public function getAdminSections();
/**
* returns a list of the admin settings
*
* @param string $section the section id for which to load the settings
* @return array array of IAdmin[] where key is the priority
* @since 9.1.0
*/
public function getAdminSettings($section);
}

View File

@ -0,0 +1,57 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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 OCP\Settings;
/**
* @since 9.1
*/
interface ISection {
/**
* returns the ID of the section. It is supposed to be a lower case string,
* e.g. 'ldap'
*
* @returns string
* @since 9.1
*/
public function getID();
/**
* returns the translated name as it should be displayed, e.g. 'LDAP / AD
* integration'. Use the L10N service to translate it.
*
* @return string
* @since 9.1
*/
public function getName();
/**
* @return int whether the form should be rather on the top or bottom of
* the settings navigation. The sections are arranged in ascending order of
* the priority values. It is required to return a value between 0 and 99.
*
* E.g.: 70
* @since 9.1
*/
public function getPriority();
}

View File

@ -0,0 +1,54 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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 OCP\Settings;
use OCP\AppFramework\Http\TemplateResponse;
/**
* @since 9.1
*/
interface ISettings {
/**
* @return TemplateResponse returns the instance with all parameters set, ready to be rendered
* @since 9.1
*/
public function getForm();
/**
* @return string the section ID, e.g. 'sharing'
* @since 9.1
*/
public function getSection();
/**
* @return int whether the form should be rather on the top or bottom of
* the admin section. The forms are arranged in ascending order of the
* priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
* @since 9.1
*/
public function getPriority();
}

View File

@ -32,6 +32,7 @@ namespace OC\Settings;
use OC\Files\View;
use OC\Server;
use OC\Settings\Controller\AdminSettingsController;
use OC\Settings\Controller\AppSettingsController;
use OC\Settings\Controller\AuthSettingsController;
use OC\Settings\Controller\CertificateController;
@ -177,6 +178,14 @@ class Application extends App {
$c->query('Checker')
);
});
$container->registerService('AdminSettingsController', function(IContainer $c) {
return new AdminSettingsController(
$c->query('AppName'),
$c->query('Request'),
$c->query('INavigationManager'),
$c->query('SettingsManager')
);
});
/**
* Middleware
@ -268,5 +277,14 @@ class Application extends App {
$server = $c->query('ServerContainer');
return $server->getIntegrityCodeChecker();
});
$container->registerService('EventDispatcher', function (IContainer $c) {
return $c->query('ServerContainer')->getEventDispatcher();
});
$container->registerService('EncryptionManager', function (IContainer $c) {
return $c->query('ServerContainer')->getEncryptionManager();
});
$container->registerService('SettingsManager', function (IContainer $c) {
return $c->query('ServerContainer')->getSettingsManager();
});
}
}

View File

@ -0,0 +1,148 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @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\Settings\Controller;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\INavigationManager;
use OCP\IRequest;
use OCP\Settings\IManager as ISettingsManager;
use OCP\Template;
/**
* @package OC\Settings\Controller
*/
class AdminSettingsController extends Controller {
/** @var INavigationManager */
private $navigationManager;
/** @var ISettingsManager */
private $settingsManager;
/**
* @param string $appName
* @param IRequest $request
* @param INavigationManager $navigationManager
* @param ISettingsManager $settingsManager
*/
public function __construct(
$appName,
IRequest $request,
INavigationManager $navigationManager,
ISettingsManager $settingsManager
) {
parent::__construct($appName, $request);
$this->navigationManager = $navigationManager;
$this->settingsManager = $settingsManager;
}
/**
* @param string $section
* @return TemplateResponse
*
* @NoCSRFRequired
*/
public function index($section) {
$this->navigationManager->setActiveEntry('admin');
$templateParams = [];
$templateParams = array_merge($templateParams, $this->getNavigationParameters($section));
$templateParams = array_merge($templateParams, $this->getSettings($section));
return new TemplateResponse('settings', 'admin/frame', $templateParams);
}
/**
* @param string $section
* @return array
*/
private function getSettings($section) {
$html = '';
$settings = $this->settingsManager->getAdminSettings($section);
foreach ($settings as $prioritizedSettings) {
foreach ($prioritizedSettings as $setting) {
/** @var \OCP\Settings\ISettings $setting */
$form = $setting->getForm();
$html .= $form->renderAs('')->render();
}
}
if($section === 'additional') {
$html .= $this->getLegacyForms();
}
return ['content' => $html];
}
/**
* @return bool|string
*/
private function getLegacyForms() {
$forms = \OC_App::getForms('admin');
$forms = array_map(function ($form) {
if (preg_match('%(<h2(?P<class>[^>]*)>.*?</h2>)%i', $form, $regs)) {
$sectionName = str_replace('<h2' . $regs['class'] . '>', '', $regs[0]);
$sectionName = str_replace('</h2>', '', $sectionName);
$anchor = strtolower($sectionName);
$anchor = str_replace(' ', '-', $anchor);
return array(
'anchor' => $anchor,
'section-name' => $sectionName,
'form' => $form
);
}
return array(
'form' => $form
);
}, $forms);
$out = new Template('settings', 'admin/additional');
$out->assign('forms', $forms);
return $out->fetchPage();
}
/**
* @param string $currentSection
* @return array
*/
private function getNavigationParameters($currentSection) {
$sections = $this->settingsManager->getAdminSections();
$templateParameters = [];
/** @var \OC\Settings\Section[] $prioritizedSections */
foreach($sections as $prioritizedSections) {
foreach ($prioritizedSections as $section) {
$templateParameters[] = [
'anchor' => $section->getID(),
'section-name' => $section->getName(),
'active' => $section->getID() === $currentSection,
];
}
}
return [
'forms' => $templateParameters
];
}
}

View File

@ -268,7 +268,7 @@ class CheckSetupController extends Controller {
public function rescanFailedIntegrityCheck() {
$this->checker->runInstanceVerification();
return new RedirectResponse(
$this->urlGenerator->linkToRoute('settings_admin')
$this->urlGenerator->linkToRoute('settings.AdminSettings.index')
);
}

View File

@ -1,271 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Bart Visscher <bartv@thisnet.nl>
* @author Björn Schießle <bjoern@schiessle.org>
* @author Georg Ehrke <georg@owncloud.com>
* @author Jan-Christoph Borchardt <hey@jancborchardt.net>
* @author Joas Schilling <coding@schilljs.com>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Martin Mattel <martin.mattel@diemattels.at>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Vincent Petry <pvince81@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/>
*
*/
use OC\Lock\NoopLockingProvider;
OC_Util::checkAdminUser();
\OC::$server->getNavigationManager()->setActiveEntry("admin");
$template = new OC_Template('settings', 'admin', 'user');
$l = \OC::$server->getL10N('settings');
OC_Util::addScript('settings', 'certificates');
OC_Util::addScript('files', 'jquery.fileupload');
\OC::$server->getEventDispatcher()->dispatch('OC\Settings\Admin::loadAdditionalScripts');
$showLog = (\OC::$server->getConfig()->getSystemValue('log_type', 'owncloud') === 'owncloud');
$numEntriesToLoad = 3;
$entries = \OC\Log\Owncloud::getEntries($numEntriesToLoad + 1);
$entriesRemaining = count($entries) > $numEntriesToLoad;
$entries = array_slice($entries, 0, $numEntriesToLoad);
$logFilePath = \OC\Log\Owncloud::getLogFilePath();
$doesLogFileExist = file_exists($logFilePath);
$logFileSize = 0;
if($doesLogFileExist) {
$logFileSize = filesize($logFilePath);
}
$config = \OC::$server->getConfig();
$appConfig = \OC::$server->getAppConfig();
$request = \OC::$server->getRequest();
$certificateManager = \OC::$server->getCertificateManager(null);
$urlGenerator = \OC::$server->getURLGenerator();
// Should we display sendmail as an option?
$template->assign('sendmail_is_available', (bool) \OC_Helper::findBinaryPath('sendmail'));
$template->assign('loglevel', $config->getSystemValue("loglevel", 2));
$template->assign('mail_domain', $config->getSystemValue("mail_domain", ''));
$template->assign('mail_from_address', $config->getSystemValue("mail_from_address", ''));
$template->assign('mail_smtpmode', $config->getSystemValue("mail_smtpmode", ''));
$template->assign('mail_smtpsecure', $config->getSystemValue("mail_smtpsecure", ''));
$template->assign('mail_smtphost', $config->getSystemValue("mail_smtphost", ''));
$template->assign('mail_smtpport', $config->getSystemValue("mail_smtpport", ''));
$template->assign('mail_smtpauthtype', $config->getSystemValue("mail_smtpauthtype", ''));
$template->assign('mail_smtpauth', $config->getSystemValue("mail_smtpauth", false));
$template->assign('mail_smtpname', $config->getSystemValue("mail_smtpname", ''));
$template->assign('mail_smtppassword', $config->getSystemValue("mail_smtppassword", ''));
$template->assign('entries', $entries);
$template->assign('entriesremain', $entriesRemaining);
$template->assign('logFileSize', $logFileSize);
$template->assign('doesLogFileExist', $doesLogFileExist);
$template->assign('showLog', $showLog);
$template->assign('readOnlyConfigEnabled', OC_Helper::isReadOnlyConfigEnabled());
$template->assign('isLocaleWorking', OC_Util::isSetLocaleWorking());
$template->assign('isAnnotationsWorking', OC_Util::isAnnotationsWorking());
$template->assign('checkForWorkingWellKnownSetup', $config->getSystemValue('check_for_working_wellknown_setup', true));
$template->assign('has_fileinfo', OC_Util::fileInfoLoaded());
$template->assign('backgroundjobs_mode', $appConfig->getValue('core', 'backgroundjobs_mode', 'ajax'));
$template->assign('cron_log', $config->getSystemValue('cron_log', true));
$template->assign('lastcron', $appConfig->getValue('core', 'lastcron', false));
$template->assign('shareAPIEnabled', $appConfig->getValue('core', 'shareapi_enabled', 'yes'));
$template->assign('shareDefaultExpireDateSet', $appConfig->getValue('core', 'shareapi_default_expire_date', 'no'));
$template->assign('shareExpireAfterNDays', $appConfig->getValue('core', 'shareapi_expire_after_n_days', '7'));
$template->assign('shareEnforceExpireDate', $appConfig->getValue('core', 'shareapi_enforce_expire_date', 'no'));
$excludeGroups = $appConfig->getValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false;
$template->assign('shareExcludeGroups', $excludeGroups);
$excludedGroupsList = $appConfig->getValue('core', 'shareapi_exclude_groups_list', '');
$excludedGroupsList = json_decode($excludedGroupsList);
$template->assign('shareExcludedGroupsList', !is_null($excludedGroupsList) ? implode('|', $excludedGroupsList) : '');
$template->assign('encryptionEnabled', \OC::$server->getEncryptionManager()->isEnabled());
$backends = \OC::$server->getUserManager()->getBackends();
$externalBackends = (count($backends) > 1) ? true : false;
$template->assign('encryptionReady', \OC::$server->getEncryptionManager()->isReady());
$template->assign('externalBackendsEnabled', $externalBackends);
/** @var \Doctrine\DBAL\Connection $connection */
$connection = \OC::$server->getDatabaseConnection();
try {
if ($connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
$template->assign('invalidTransactionIsolationLevel', false);
} else {
$template->assign('invalidTransactionIsolationLevel', $connection->getTransactionIsolation() !== \Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED);
}
} catch (\Doctrine\DBAL\DBALException $e) {
// ignore
$template->assign('invalidTransactionIsolationLevel', false);
}
$encryptionModules = \OC::$server->getEncryptionManager()->getEncryptionModules();
$defaultEncryptionModuleId = \OC::$server->getEncryptionManager()->getDefaultEncryptionModuleId();
$encModulues = array();
foreach ($encryptionModules as $module) {
$encModulues[$module['id']]['displayName'] = $module['displayName'];
$encModulues[$module['id']]['default'] = false;
if ($module['id'] === $defaultEncryptionModuleId) {
$encModulues[$module['id']]['default'] = true;
}
}
$template->assign('encryptionModules', $encModulues);
// If the current web root is non-empty but the web root from the config is,
// and system cron is used, the URL generator fails to build valid URLs.
$shouldSuggestOverwriteCliUrl = $config->getAppValue('core', 'backgroundjobs_mode', 'ajax') === 'cron' &&
\OC::$WEBROOT && \OC::$WEBROOT !== '/' &&
!$config->getSystemValue('overwrite.cli.url', '');
$suggestedOverwriteCliUrl = ($shouldSuggestOverwriteCliUrl) ? \OC::$WEBROOT : '';
$template->assign('suggestedOverwriteCliUrl', $suggestedOverwriteCliUrl);
$template->assign('allowLinks', $appConfig->getValue('core', 'shareapi_allow_links', 'yes'));
$template->assign('enforceLinkPassword', \OCP\Util::isPublicLinkPasswordRequired());
$template->assign('allowPublicUpload', $appConfig->getValue('core', 'shareapi_allow_public_upload', 'yes'));
$template->assign('allowResharing', $appConfig->getValue('core', 'shareapi_allow_resharing', 'yes'));
$template->assign('allowPublicMailNotification', $appConfig->getValue('core', 'shareapi_allow_public_notification', 'no'));
$template->assign('allowMailNotification', $appConfig->getValue('core', 'shareapi_allow_mail_notification', 'no'));
$template->assign('allowShareDialogUserEnumeration', $appConfig->getValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes'));
$template->assign('onlyShareWithGroupMembers', \OC\Share\Share::shareWithGroupMembersOnly());
$template->assign('allowGroupSharing', $appConfig->getValue('core', 'shareapi_allow_group_sharing', 'yes'));
$databaseOverload = (strpos(\OCP\Config::getSystemValue('dbtype'), 'sqlite') !== false);
$template->assign('databaseOverload', $databaseOverload);
$template->assign('cronErrors', $appConfig->getValue('core', 'cronErrors'));
// warn if php is not setup properly to get system variables with getenv
$path = getenv('PATH');
$template->assign('getenvServerNotWorking', empty($path));
// warn if outdated version of a memcache module is used
$caches = [
'apcu' => ['name' => $l->t('APCu'), 'version' => '4.0.6'],
'redis' => ['name' => $l->t('Redis'), 'version' => '2.2.5'],
];
$outdatedCaches = [];
foreach ($caches as $php_module => $data) {
$isOutdated = extension_loaded($php_module) && version_compare(phpversion($php_module), $data['version'], '<');
if ($isOutdated) {
$outdatedCaches[$php_module] = $data;
}
}
$template->assign('OutdatedCacheWarning', $outdatedCaches);
// add hardcoded forms from the template
$forms = OC_App::getForms('admin');
if ($config->getSystemValue('enable_certificate_management', false)) {
$certificatesTemplate = new OC_Template('settings', 'certificates');
$certificatesTemplate->assign('type', 'admin');
$certificatesTemplate->assign('uploadRoute', 'settings.Certificate.addSystemRootCertificate');
$certificatesTemplate->assign('certs', $certificateManager->listCertificates());
$certificatesTemplate->assign('urlGenerator', $urlGenerator);
$forms[] = $certificatesTemplate->fetchPage();
}
$formsAndMore = array();
if ($request->getServerProtocol() !== 'https' || !OC_Util::isAnnotationsWorking() ||
$suggestedOverwriteCliUrl || !OC_Util::isSetLocaleWorking() ||
!OC_Util::fileInfoLoaded() || $databaseOverload
) {
$formsAndMore[] = array('anchor' => 'security-warning', 'section-name' => $l->t('Security & setup warnings'));
}
$formsAndMore[] = array('anchor' => 'shareAPI', 'section-name' => $l->t('Sharing'));
$formsAndMore[] = ['anchor' => 'encryptionAPI', 'section-name' => $l->t('Server-side encryption')];
// Prioritize fileSharingSettings and files_external and move updater to the version
$fileSharingSettings = $filesExternal = $updaterAppPanel = $ocDefaultEncryptionModulePanel = '';
foreach ($forms as $index => $form) {
if (strpos($form, 'id="fileSharingSettings"')) {
$fileSharingSettings = $form;
unset($forms[$index]);
continue;
}
if (strpos($form, 'id="files_external"')) {
$filesExternal = $form;
unset($forms[$index]);
continue;
}
if (strpos($form, 'class="updater-admin"')) {
$updaterAppPanel = $form;
unset($forms[$index]);
continue;
}
if (strpos($form, 'id="ocDefaultEncryptionModule"')) {
$ocDefaultEncryptionModulePanel = $form;
unset($forms[$index]);
continue;
}
}
if ($filesExternal) {
$formsAndMore[] = array('anchor' => 'files_external', 'section-name' => $l->t('External Storage'));
}
$template->assign('fileSharingSettings', $fileSharingSettings);
$template->assign('filesExternal', $filesExternal);
$template->assign('updaterAppPanel', $updaterAppPanel);
$template->assign('ocDefaultEncryptionModulePanel', $ocDefaultEncryptionModulePanel);
$lockingProvider = \OC::$server->getLockingProvider();
if ($lockingProvider instanceof NoopLockingProvider) {
$template->assign('fileLockingType', 'none');
} else if ($lockingProvider instanceof \OC\Lock\DBLockingProvider) {
$template->assign('fileLockingType', 'db');
} else {
$template->assign('fileLockingType', 'cache');
}
$formsMap = array_map(function ($form) {
if (preg_match('%(<h2(?P<class>[^>]*)>.*?</h2>)%i', $form, $regs)) {
$sectionName = str_replace('<h2'.$regs['class'].'>', '', $regs[0]);
$sectionName = str_replace('</h2>', '', $sectionName);
$anchor = strtolower($sectionName);
$anchor = str_replace(' ', '-', $anchor);
return array(
'anchor' => $anchor,
'section-name' => $sectionName,
'form' => $form
);
}
return array(
'form' => $form
);
}, $forms);
$formsAndMore = array_merge($formsAndMore, $formsMap);
// add bottom hardcoded forms from the template
$formsAndMore[] = ['anchor' => 'backgroundjobs', 'section-name' => $l->t('Cron')];
$formsAndMore[] = ['anchor' => 'mail_general_settings', 'section-name' => $l->t('Email server')];
$formsAndMore[] = ['anchor' => 'log-section', 'section-name' => $l->t('Log')];
$formsAndMore[] = ['anchor' => 'admin-tips', 'section-name' => $l->t('Tips & tricks')];
if ($updaterAppPanel) {
$formsAndMore[] = ['anchor' => 'updater', 'section-name' => $l->t('Updates')];
}
$template->assign('forms', $formsAndMore);
$template->printPage();
$util = new \OC_Util();
$util->createHtaccessTestFile(\OC::$server->getConfig());

View File

@ -372,6 +372,14 @@ span.version {
.section h2.app-name {
margin-bottom: 8px;
}
.followupsection {
display: block;
padding: 0 30px 30px 30px;
color: #555;
margin-bottom: 24px;
margin-top: -30px;
position: relative;
}
.app-image {
float: left;
padding-right: 10px;

View File

@ -64,6 +64,8 @@ $application->registerRoutes($this, [
['name' => 'Certificate#removePersonalRootCertificate', 'url' => '/settings/personal/certificate/{certificateIdentifier}', 'verb' => 'DELETE'],
['name' => 'Certificate#addSystemRootCertificate', 'url' => '/settings/admin/certificate', 'verb' => 'POST'],
['name' => 'Certificate#removeSystemRootCertificate', 'url' => '/settings/admin/certificate/{certificateIdentifier}', 'verb' => 'DELETE'],
['name' => 'AdminSettings#index', 'url' => '/settings/admin/{section}', 'verb' => 'GET', 'defaults' => ['section' => 'server']],
['name' => 'AdminSettings#form', 'url' => '/settings/admin/{section}', 'verb' => 'GET'],
]
]);
@ -76,8 +78,6 @@ $this->create('settings_personal', '/settings/personal')
->actionInclude('settings/personal.php');
$this->create('settings_users', '/settings/users')
->actionInclude('settings/users.php');
$this->create('settings_admin', '/settings/admin')
->actionInclude('settings/admin.php');
// Settings ajax actions
// users
$this->create('settings_ajax_setquota', '/settings/ajax/setquota.php')

View File

@ -1,578 +0,0 @@
<?php
/**
* Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com>
* This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file.
*/
/**
* @var array $_
* @var \OCP\IL10N $l
* @var OC_Defaults $theme
*/
style('settings', 'settings');
script('settings', [ 'settings', 'admin', 'log'] );
script('core', ['multiselect', 'setupchecks']);
vendor_script('select2/select2');
vendor_style('select2/select2');
$levels = ['Debug', 'Info', 'Warning', 'Error', 'Fatal'];
$levelLabels = [
$l->t( 'Everything (fatal issues, errors, warnings, info, debug)' ),
$l->t( 'Info, warnings, errors and fatal issues' ),
$l->t( 'Warnings, errors and fatal issues' ),
$l->t( 'Errors and fatal issues' ),
$l->t( 'Fatal issues only' ),
];
$mail_smtpauthtype = [
'' => $l->t('None'),
'LOGIN' => $l->t('Login'),
'PLAIN' => $l->t('Plain'),
'NTLM' => $l->t('NT LAN Manager'),
];
$mail_smtpsecure = [
'' => $l->t('None'),
'ssl' => $l->t('SSL'),
'tls' => $l->t('TLS'),
];
$mail_smtpmode = [
['php', 'PHP'],
['smtp', 'SMTP'],
];
if ($_['sendmail_is_available']) {
$mail_smtpmode[] = ['sendmail', 'Sendmail'];
}
if ($_['mail_smtpmode'] == 'qmail') {
$mail_smtpmode[] = ['qmail', 'qmail'];
}
?>
<div id="app-navigation">
<ul>
<?php foreach($_['forms'] as $form) {
if (isset($form['anchor'])) {
$anchor = '#' . $form['anchor'];
$sectionName = $form['section-name'];
print_unescaped(sprintf("<li><a href='%s'>%s</a></li>", \OCP\Util::sanitizeHTML($anchor), \OCP\Util::sanitizeHTML($sectionName)));
}
}?>
</ul>
</div>
<div id="app-content">
<div id="security-warning" class="section">
<h2><?php p($l->t('Security & setup warnings'));?></h2>
<ul>
<?php
// is php setup properly to query system environment variables like getenv('PATH')
if ($_['getenvServerNotWorking']) {
?>
<li>
<?php p($l->t('php does not seem to be setup properly to query system environment variables. The test with getenv("PATH") only returns an empty response.')); ?><br>
<?php print_unescaped($l->t('Please check the <a target="_blank" rel="noreferrer" href="%s">installation documentation ↗</a> for php configuration notes and the php configuration of your server, especially when using php-fpm.', link_to_docs('admin-php-fpm'))); ?>
</li>
<?php
}
// is read only config enabled
if ($_['readOnlyConfigEnabled']) {
?>
<li>
<?php p($l->t('The Read-Only config has been enabled. This prevents setting some configurations via the web-interface. Furthermore, the file needs to be made writable manually for every update.')); ?>
</li>
<?php
}
// Are doc blocks accessible?
if (!$_['isAnnotationsWorking']) {
?>
<li>
<?php p($l->t('PHP is apparently setup to strip inline doc blocks. This will make several core apps inaccessible.')); ?><br>
<?php p($l->t('This is probably caused by a cache/accelerator such as Zend OPcache or eAccelerator.')); ?>
</li>
<?php
}
// Is the Transaction isolation level READ_COMMITED?
if ($_['invalidTransactionIsolationLevel']) {
?>
<li>
<?php p($l->t('Your database does not run with "READ COMMITED" transaction isolation level. This can cause problems when multiple actions are executed in parallel.')); ?>
</li>
<?php
}
// Warning if memcache is outdated
foreach ($_['OutdatedCacheWarning'] as $php_module => $data) {
?>
<li>
<?php p($l->t('%1$s below version %2$s is installed, for stability and performance reasons we recommend updating to a newer %1$s version.', $data)); ?>
</li>
<?php
}
// if module fileinfo available?
if (!$_['has_fileinfo']) {
?>
<li>
<?php p($l->t('The PHP module \'fileinfo\' is missing. We strongly recommend to enable this module to get best results with mime-type detection.')); ?>
</li>
<?php
}
// locking configured optimally?
if ($_['fileLockingType'] === 'none') {
?>
<li>
<?php print_unescaped($l->t('Transactional file locking is disabled, this might lead to issues with race conditions. Enable \'filelocking.enabled\' in config.php to avoid these problems. See the <a target="_blank" rel="noreferrer" href="%s">documentation ↗</a> for more information.', link_to_docs('admin-transactional-locking'))); ?>
</li>
<?php
}
// is locale working ?
if (!$_['isLocaleWorking']) {
?>
<li>
<?php
$locales = 'en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8';
p($l->t('System locale can not be set to a one which supports UTF-8.'));
?>
<br>
<?php
p($l->t('This means that there might be problems with certain characters in file names.'));
?>
<br>
<?php
p($l->t('We strongly suggest installing the required packages on your system to support one of the following locales: %s.', [$locales]));
?>
</li>
<?php
}
if ($_['suggestedOverwriteCliUrl']) {
?>
<li>
<?php p($l->t('If your installation is not installed in the root of the domain and uses system cron, there can be issues with the URL generation. To avoid these problems, please set the "overwrite.cli.url" option in your config.php file to the webroot path of your installation (Suggested: "%s")', $_['suggestedOverwriteCliUrl'])); ?>
</li>
<?php
}
if ($_['cronErrors']) {
?>
<li>
<?php p($l->t('It was not possible to execute the cronjob via CLI. The following technical errors have appeared:')); ?>
<br>
<ol>
<?php foreach(json_decode($_['cronErrors']) as $error) { if(isset($error->error)) {?>
<li><?php p($error->error) ?> <?php p($error->hint) ?></li>
<?php }};?>
</ol>
</li>
<?php
}
?>
</ul>
<div id="postsetupchecks" data-check-wellknown="<?php if($_['checkForWorkingWellKnownSetup']) { p('true'); } else { p('false'); } ?>">
<div class="loading"></div>
<ul class="errors hidden"></ul>
<ul class="warnings hidden"></ul>
<ul class="info hidden"></ul>
<p class="hint hidden">
<?php print_unescaped($l->t('Please double check the <a target="_blank" rel="noreferrer" href="%s">installation guides ↗</a>, and check for any errors or warnings in the <a href="#log-section">log</a>.', link_to_docs('admin-install'))); ?>
</p>
</div>
<div id="security-warning-state">
<span class="hidden icon-checkmark"><?php p($l->t('All checks passed.'));?></span>
</div>
</div>
<div class="section" id="shareAPI">
<h2><?php p($l->t('Sharing'));?></h2>
<a target="_blank" el="noreferrer" class="icon-info"
title="<?php p($l->t('Open documentation'));?>"
href="<?php p(link_to_docs('admin-sharing')); ?>"></a>
<p id="enable">
<input type="checkbox" name="shareapi_enabled" id="shareAPIEnabled" class="checkbox"
value="1" <?php if ($_['shareAPIEnabled'] === 'yes') print_unescaped('checked="checked"'); ?> />
<label for="shareAPIEnabled"><?php p($l->t('Allow apps to use the Share API'));?></label><br/>
</p>
<p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
<input type="checkbox" name="shareapi_allow_links" id="allowLinks" class="checkbox"
value="1" <?php if ($_['allowLinks'] === 'yes') print_unescaped('checked="checked"'); ?> />
<label for="allowLinks"><?php p($l->t('Allow users to share via link'));?></label><br/>
</p>
<p id="publicLinkSettings" class="indent <?php if ($_['allowLinks'] !== 'yes' || $_['shareAPIEnabled'] === 'no') p('hidden'); ?>">
<input type="checkbox" name="shareapi_allow_public_upload" id="allowPublicUpload" class="checkbox"
value="1" <?php if ($_['allowPublicUpload'] == 'yes') print_unescaped('checked="checked"'); ?> />
<label for="allowPublicUpload"><?php p($l->t('Allow public uploads'));?></label><br/>
<input type="checkbox" name="shareapi_enforce_links_password" id="enforceLinkPassword" class="checkbox"
value="1" <?php if ($_['enforceLinkPassword']) print_unescaped('checked="checked"'); ?> />
<label for="enforceLinkPassword"><?php p($l->t('Enforce password protection'));?></label><br/>
<input type="checkbox" name="shareapi_default_expire_date" id="shareapiDefaultExpireDate" class="checkbox"
value="1" <?php if ($_['shareDefaultExpireDateSet'] === 'yes') print_unescaped('checked="checked"'); ?> />
<label for="shareapiDefaultExpireDate"><?php p($l->t('Set default expiration date'));?></label><br/>
<input type="checkbox" name="shareapi_allow_public_notification" id="allowPublicMailNotification" class="checkbox"
value="1" <?php if ($_['allowPublicMailNotification'] == 'yes') print_unescaped('checked="checked"'); ?> />
<label for="allowPublicMailNotification"><?php p($l->t('Allow users to send mail notification for shared files'));?></label><br/>
</p>
<p id="setDefaultExpireDate" class="double-indent <?php if ($_['allowLinks'] !== 'yes' || $_['shareDefaultExpireDateSet'] === 'no' || $_['shareAPIEnabled'] === 'no') p('hidden');?>">
<?php p($l->t( 'Expire after ' )); ?>
<input type="text" name='shareapi_expire_after_n_days' id="shareapiExpireAfterNDays" placeholder="<?php p('7')?>"
value='<?php p($_['shareExpireAfterNDays']) ?>' />
<?php p($l->t( 'days' )); ?>
<input type="checkbox" name="shareapi_enforce_expire_date" id="shareapiEnforceExpireDate" class="checkbox"
value="1" <?php if ($_['shareEnforceExpireDate'] === 'yes') print_unescaped('checked="checked"'); ?> />
<label for="shareapiEnforceExpireDate"><?php p($l->t('Enforce expiration date'));?></label><br/>
</p>
<p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
<input type="checkbox" name="shareapi_allow_resharing" id="allowResharing" class="checkbox"
value="1" <?php if ($_['allowResharing'] === 'yes') print_unescaped('checked="checked"'); ?> />
<label for="allowResharing"><?php p($l->t('Allow resharing'));?></label><br/>
</p>
<p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
<input type="checkbox" name="shareapi_allow_group_sharing" id="allowGroupSharing" class="checkbox"
value="1" <?php if ($_['allowGroupSharing'] === 'yes') print_unescaped('checked="checked"'); ?> />
<label for="allowGroupSharing"><?php p($l->t('Allow sharing with groups'));?></label><br />
</p>
<p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
<input type="checkbox" name="shareapi_only_share_with_group_members" id="onlyShareWithGroupMembers" class="checkbox"
value="1" <?php if ($_['onlyShareWithGroupMembers']) print_unescaped('checked="checked"'); ?> />
<label for="onlyShareWithGroupMembers"><?php p($l->t('Restrict users to only share with users in their groups'));?></label><br/>
</p>
<p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
<input type="checkbox" name="shareapi_allow_mail_notification" id="allowMailNotification" class="checkbox"
value="1" <?php if ($_['allowMailNotification'] === 'yes') print_unescaped('checked="checked"'); ?> />
<label for="allowMailNotification"><?php p($l->t('Allow users to send mail notification for shared files to other users'));?></label><br/>
</p>
<p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
<input type="checkbox" name="shareapi_exclude_groups" id="shareapiExcludeGroups" class="checkbox"
value="1" <?php if ($_['shareExcludeGroups']) print_unescaped('checked="checked"'); ?> />
<label for="shareapiExcludeGroups"><?php p($l->t('Exclude groups from sharing'));?></label><br/>
</p>
<p id="selectExcludedGroups" class="indent <?php if (!$_['shareExcludeGroups'] || $_['shareAPIEnabled'] === 'no') p('hidden'); ?>">
<input name="shareapi_exclude_groups_list" type="hidden" id="excludedGroups" value="<?php p($_['shareExcludedGroupsList']) ?>" style="width: 400px"/>
<br />
<em><?php p($l->t('These groups will still be able to receive shares, but not to initiate them.')); ?></em>
</p>
<p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
<input type="checkbox" name="shareapi_allow_share_dialog_user_enumeration" value="1" id="shareapi_allow_share_dialog_user_enumeration" class="checkbox"
<?php if ($_['allowShareDialogUserEnumeration'] === 'yes') print_unescaped('checked="checked"'); ?> />
<label for="shareapi_allow_share_dialog_user_enumeration"><?php p($l->t('Allow username autocompletion in share dialog. If this is disabled the full username needs to be entered.'));?></label><br />
</p>
<?php print_unescaped($_['fileSharingSettings']); ?>
</div>
<?php print_unescaped($_['filesExternal']); ?>
<?php foreach($_['forms'] as $form) {
if (isset($form['form'])) {?>
<div id="<?php isset($form['anchor']) ? p($form['anchor']) : p('');?>"><?php print_unescaped($form['form']);?></div>
<?php }
};?>
<div class="section" id="backgroundjobs">
<h2 class="inlineblock"><?php p($l->t('Cron'));?></h2>
<?php if ($_['cron_log']): ?>
<p class="cronlog inlineblock">
<?php if ($_['lastcron'] !== false):
$relative_time = relative_modified_date($_['lastcron']);
$absolute_time = OC_Util::formatDate($_['lastcron']);
if (time() - $_['lastcron'] <= 3600): ?>
<span class="status success"></span>
<span class="crondate" title="<?php p($absolute_time);?>">
<?php p($l->t("Last cron job execution: %s.", [$relative_time]));?>
</span>
<?php else: ?>
<span class="status error"></span>
<span class="crondate" title="<?php p($absolute_time);?>">
<?php p($l->t("Last cron job execution: %s. Something seems wrong.", [$relative_time]));?>
</span>
<?php endif;
else: ?>
<span class="status error"></span>
<?php p($l->t("Cron was not executed yet!"));
endif; ?>
</p>
<?php endif; ?>
<a target="_blank" rel="noreferrer" class="icon-info"
title="<?php p($l->t('Open documentation'));?>"
href="<?php p(link_to_docs('admin-background-jobs')); ?>"></a>
<p>
<input type="radio" name="mode" value="ajax" class="radio"
id="backgroundjobs_ajax" <?php if ($_['backgroundjobs_mode'] === "ajax") {
print_unescaped('checked="checked"');
} ?>>
<label for="backgroundjobs_ajax">AJAX</label><br/>
<em><?php p($l->t("Execute one task with each page loaded")); ?></em>
</p>
<p>
<input type="radio" name="mode" value="webcron" class="radio"
id="backgroundjobs_webcron" <?php if ($_['backgroundjobs_mode'] === "webcron") {
print_unescaped('checked="checked"');
} ?>>
<label for="backgroundjobs_webcron">Webcron</label><br/>
<em><?php p($l->t("cron.php is registered at a webcron service to call cron.php every 15 minutes over http.")); ?></em>
</p>
<p>
<input type="radio" name="mode" value="cron" class="radio"
id="backgroundjobs_cron" <?php if ($_['backgroundjobs_mode'] === "cron") {
print_unescaped('checked="checked"');
} ?>>
<label for="backgroundjobs_cron">Cron</label><br/>
<em><?php p($l->t("Use system's cron service to call the cron.php file every 15 minutes.")); ?></em>
</p>
</div>
<div class="section" id='encryptionAPI'>
<h2><?php p($l->t('Server-side encryption')); ?></h2>
<a target="_blank" rel="noreferrer" class="icon-info"
title="<?php p($l->t('Open documentation'));?>"
href="<?php p(link_to_docs('admin-encryption')); ?>"></a>
<p id="enable">
<input type="checkbox"
id="enableEncryption" class="checkbox"
value="1" <?php if ($_['encryptionEnabled']) print_unescaped('checked="checked" disabled="disabled"'); ?> />
<label
for="enableEncryption"><?php p($l->t('Enable server-side encryption')); ?> <span id="startmigration_msg" class="msg"></span> </label><br/>
</p>
<div id="EncryptionWarning" class="warning hidden">
<p><?php p($l->t('Please read carefully before activating server-side encryption: ')); ?></p>
<ul>
<li><?php p($l->t('Once encryption is enabled, all files uploaded to the server from that point forward will be encrypted at rest on the server. It will only be possible to disable encryption at a later date if the active encryption module supports that function, and all pre-conditions (e.g. setting a recover key) are met.')); ?></li>
<li><?php p($l->t('Encryption alone does not guarantee security of the system. Please see documentation for more information about how the encryption app works, and the supported use cases.')); ?></li>
<li><?php p($l->t('Be aware that encryption always increases the file size.')); ?></li>
<li><?php p($l->t('It is always good to create regular backups of your data, in case of encryption make sure to backup the encryption keys along with your data.')); ?></li>
</ul>
<p><?php p($l->t('This is the final warning: Do you really want to enable encryption?')) ?> <input type="button"
id="reallyEnableEncryption"
value="<?php p($l->t("Enable encryption")); ?>" /></p>
</div>
<div id="EncryptionSettingsArea" class="<?php if (!$_['encryptionEnabled']) p('hidden'); ?>">
<div id='selectEncryptionModules' class="<?php if (!$_['encryptionReady']) p('hidden'); ?>">
<?php
if (empty($_['encryptionModules'])) {
p($l->t('No encryption module loaded, please enable an encryption module in the app menu.'));
} else { ?>
<h3><?php p($l->t('Select default encryption module:')) ?></h3>
<fieldset id='encryptionModules'>
<?php foreach ($_['encryptionModules'] as $id => $module): ?>
<input type="radio" id="<?php p($id) ?>"
name="default_encryption_module"
value="<?php p($id) ?>"
<?php if ($module['default']) {
p('checked');
} ?>>
<label
for="<?php p($id) ?>"><?php p($module['displayName']) ?></label>
<br/>
<?php if ($id === 'OC_DEFAULT_MODULE') print_unescaped($_['ocDefaultEncryptionModulePanel']); ?>
<?php endforeach; ?>
</fieldset>
<?php } ?>
</div>
<div id="migrationWarning" class="<?php if ($_['encryptionReady']) p('hidden'); ?>">
<?php
if ($_['encryptionReady'] === false && $_['externalBackendsEnabled'] === true) {
p($l->t('You need to migrate your encryption keys from the old encryption (ownCloud <= 8.0) to the new one. Please enable the "Default encryption module" and run \'occ encryption:migrate\''));
} elseif ($_['encryptionReady'] === false && $_['externalBackendsEnabled'] === false) {
p($l->t('You need to migrate your encryption keys from the old encryption (ownCloud <= 8.0) to the new one.')); ?>
<input type="submit" name="startmigration" id="startmigration"
value="<?php p($l->t('Start migration')); ?>"/>
<?php } ?>
</div>
</div>
</div>
<div class="section" id="mail_general_settings">
<form id="mail_general_settings_form" class="mail_settings">
<h2><?php p($l->t('Email server'));?></h2>
<a target="_blank" rel="noreferrer" class="icon-info"
title="<?php p($l->t('Open documentation'));?>"
href="<?php p(link_to_docs('admin-email')); ?>"></a>
<p><?php p($l->t('This is used for sending out notifications.')); ?> <span id="mail_settings_msg" class="msg"></span></p>
<p>
<label for="mail_smtpmode"><?php p($l->t( 'Send mode' )); ?></label>
<select name='mail_smtpmode' id='mail_smtpmode'>
<?php foreach ($mail_smtpmode as $smtpmode):
$selected = '';
if ($smtpmode[0] == $_['mail_smtpmode']):
$selected = 'selected="selected"';
endif; ?>
<option value='<?php p($smtpmode[0])?>' <?php p($selected) ?>><?php p($smtpmode[1]) ?></option>
<?php endforeach;?>
</select>
<label id="mail_smtpsecure_label" for="mail_smtpsecure"
<?php if ($_['mail_smtpmode'] != 'smtp') print_unescaped(' class="hidden"'); ?>>
<?php p($l->t( 'Encryption' )); ?>
</label>
<select name="mail_smtpsecure" id="mail_smtpsecure"
<?php if ($_['mail_smtpmode'] != 'smtp') print_unescaped(' class="hidden"'); ?>>
<?php foreach ($mail_smtpsecure as $secure => $name):
$selected = '';
if ($secure == $_['mail_smtpsecure']):
$selected = 'selected="selected"';
endif; ?>
<option value='<?php p($secure)?>' <?php p($selected) ?>><?php p($name) ?></option>
<?php endforeach;?>
</select>
</p>
<p>
<label for="mail_from_address"><?php p($l->t( 'From address' )); ?></label>
<input type="text" name='mail_from_address' id="mail_from_address" placeholder="<?php p($l->t('mail'))?>"
value='<?php p($_['mail_from_address']) ?>' />@
<input type="text" name='mail_domain' id="mail_domain" placeholder="example.com"
value='<?php p($_['mail_domain']) ?>' />
</p>
<p id="setting_smtpauth" <?php if ($_['mail_smtpmode'] != 'smtp') print_unescaped(' class="hidden"'); ?>>
<label for="mail_smtpauthtype"><?php p($l->t( 'Authentication method' )); ?></label>
<select name='mail_smtpauthtype' id='mail_smtpauthtype'>
<?php foreach ($mail_smtpauthtype as $authtype => $name):
$selected = '';
if ($authtype == $_['mail_smtpauthtype']):
$selected = 'selected="selected"';
endif; ?>
<option value='<?php p($authtype)?>' <?php p($selected) ?>><?php p($name) ?></option>
<?php endforeach;?>
</select>
<input type="checkbox" name="mail_smtpauth" id="mail_smtpauth" class="checkbox" value="1"
<?php if ($_['mail_smtpauth']) print_unescaped('checked="checked"'); ?> />
<label for="mail_smtpauth"><?php p($l->t( 'Authentication required' )); ?></label>
</p>
<p id="setting_smtphost" <?php if ($_['mail_smtpmode'] != 'smtp') print_unescaped(' class="hidden"'); ?>>
<label for="mail_smtphost"><?php p($l->t( 'Server address' )); ?></label>
<input type="text" name='mail_smtphost' id="mail_smtphost" placeholder="smtp.example.com"
value='<?php p($_['mail_smtphost']) ?>' />
:
<input type="text" name='mail_smtpport' id="mail_smtpport" placeholder="<?php p($l->t('Port'))?>"
value='<?php p($_['mail_smtpport']) ?>' />
</p>
</form>
<form class="mail_settings" id="mail_credentials_settings">
<p id="mail_credentials" <?php if (!$_['mail_smtpauth'] || $_['mail_smtpmode'] != 'smtp') print_unescaped(' class="hidden"'); ?>>
<label for="mail_smtpname"><?php p($l->t( 'Credentials' )); ?></label>
<input type="text" name='mail_smtpname' id="mail_smtpname" placeholder="<?php p($l->t('SMTP Username'))?>"
value='<?php p($_['mail_smtpname']) ?>' />
<input type="password" name='mail_smtppassword' id="mail_smtppassword" autocomplete="off"
placeholder="<?php p($l->t('SMTP Password'))?>" value='<?php p($_['mail_smtppassword']) ?>' />
<input id="mail_credentials_settings_submit" type="button" value="<?php p($l->t('Store credentials')) ?>">
</p>
</form>
<br />
<em><?php p($l->t( 'Test email settings' )); ?></em>
<input type="submit" name="sendtestemail" id="sendtestemail" value="<?php p($l->t( 'Send email' )); ?>"/>
<span id="sendtestmail_msg" class="msg"></span>
</div>
<div class="section" id="log-section">
<h2><?php p($l->t('Log'));?></h2>
<?php if ($_['showLog'] && $_['doesLogFileExist']): ?>
<table id="log" class="grid">
<?php foreach ($_['entries'] as $entry): ?>
<tr>
<td>
<?php p($levels[$entry->level]);?>
</td>
<td>
<?php p($entry->app);?>
</td>
<td class="log-message">
<?php p($entry->message);?>
</td>
<td class="date">
<?php if(is_int($entry->time)){
p(OC_Util::formatDate($entry->time));
} else {
p($entry->time);
}?>
</td>
<td><?php isset($entry->user) ? p($entry->user) : p('--') ?></td>
</tr>
<?php endforeach;?>
</table>
<?php if ($_['logFileSize'] > 0): ?>
<a href="<?php print_unescaped(OC::$server->getURLGenerator()->linkToRoute('settings.LogSettings.download')); ?>" class="button" id="downloadLog"><?php p($l->t('Download logfile'));?></a>
<?php endif; ?>
<?php if ($_['entriesremain']): ?>
<input id="moreLog" type="button" value="<?php p($l->t('More'));?>...">
<input id="lessLog" type="button" value="<?php p($l->t('Less'));?>...">
<?php endif; ?>
<?php if ($_['logFileSize'] > (100 * 1024 * 1024)): ?>
<br>
<em>
<?php p($l->t('The logfile is bigger than 100 MB. Downloading it may take some time!')); ?>
</em>
<?php endif; ?>
<?php endif; ?>
<p><?php p($l->t('What to log'));?> <select name='loglevel' id='loglevel'>
<?php for ($i = 0; $i < 5; $i++):
$selected = '';
if ($i == $_['loglevel']):
$selected = 'selected="selected"';
endif; ?>
<option value='<?php p($i)?>' <?php p($selected) ?>><?php p($levelLabels[$i])?></option>
<?php endfor;?>
</select></p>
</div>
<div class="section" id="admin-tips">
<h2><?php p($l->t('Tips & tricks'));?></h2>
<ul>
<?php
// SQLite database performance issue
if ($_['databaseOverload']) {
?>
<li>
<?php p($l->t('SQLite is used as database. For larger installations we recommend to switch to a different database backend.')); ?><br>
<?php p($l->t('Especially when using the desktop client for file syncing the use of SQLite is discouraged.')); ?><br>
<?php print_unescaped($l->t('To migrate to another database use the command line tool: \'occ db:convert-type\', or see the <a target="_blank" rel="noreferrer" href="%s">documentation ↗</a>.', link_to_docs('admin-db-conversion') )); ?>
</li>
<?php } ?>
<li><a target="_blank" rel="noreferrer" href="<?php p(link_to_docs('admin-backup')); ?>"><?php p($l->t('How to do backups'));?> ↗</a></li>
<li><a target="_blank" rel="noreferrer" href="<?php p(link_to_docs('admin-monitoring')); ?>"><?php p($l->t('Advanced monitoring'));?> ↗</a></li>
<li><a target="_blank" rel="noreferrer" href="<?php p(link_to_docs('admin-performance')); ?>"><?php p($l->t('Performance tuning'));?> ↗</a></li>
<li><a target="_blank" rel="noreferrer" href="<?php p(link_to_docs('admin-config')); ?>"><?php p($l->t('Improving the config.php'));?> ↗</a></li>
<li><a target="_blank" rel="noreferrer" href="<?php p(link_to_docs('developer-theming')); ?>"><?php p($l->t('Theming'));?> ↗</a></li>
<li><a target="_blank" rel="noreferrer" href="<?php p(link_to_docs('admin-security')); ?>"><?php p($l->t('Hardening and security guidance'));?> ↗</a></li>
</ul>
</div>
<?php if (!empty($_['updaterAppPanel'])): ?>
<div id="updater"><?php print_unescaped($_['updaterAppPanel']); ?></div>
<?php endif; ?>
<div class="section">
<h2><?php p($l->t('Version'));?></h2>
<p><a href="<?php print_unescaped($theme->getBaseUrl()); ?>" rel="noreferrer" target="_blank"><?php p($theme->getTitle()); ?></a> <?php p(OC_Util::getHumanVersion()) ?></p>
<p><?php include('settings.development.notice.php'); ?></p>
</div>
</div>

View File

@ -0,0 +1,140 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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/>.
*
*/
/** @var \OCP\IL10N $l */
/** @var array $_ */
$mail_smtpauthtype = [
'' => $l->t('None'),
'LOGIN' => $l->t('Login'),
'PLAIN' => $l->t('Plain'),
'NTLM' => $l->t('NT LAN Manager'),
];
$mail_smtpsecure = [
'' => $l->t('None'),
'ssl' => $l->t('SSL'),
'tls' => $l->t('TLS'),
];
$mail_smtpmode = [
['php', 'PHP'],
['smtp', 'SMTP'],
];
if ($_['sendmail_is_available']) {
$mail_smtpmode[] = ['sendmail', 'Sendmail'];
}
if ($_['mail_smtpmode'] == 'qmail') {
$mail_smtpmode[] = ['qmail', 'qmail'];
}
?>
<div class="section" id="mail_general_settings">
<form id="mail_general_settings_form" class="mail_settings">
<h2><?php p($l->t('Email server'));?></h2>
<a target="_blank" rel="noreferrer" class="icon-info"
title="<?php p($l->t('Open documentation'));?>"
href="<?php p(link_to_docs('admin-email')); ?>"></a>
<p><?php p($l->t('This is used for sending out notifications.')); ?> <span id="mail_settings_msg" class="msg"></span></p>
<p>
<label for="mail_smtpmode"><?php p($l->t( 'Send mode' )); ?></label>
<select name='mail_smtpmode' id='mail_smtpmode'>
<?php foreach ($mail_smtpmode as $smtpmode):
$selected = '';
if ($smtpmode[0] == $_['mail_smtpmode']):
$selected = 'selected="selected"';
endif; ?>
<option value='<?php p($smtpmode[0])?>' <?php p($selected) ?>><?php p($smtpmode[1]) ?></option>
<?php endforeach;?>
</select>
<label id="mail_smtpsecure_label" for="mail_smtpsecure"
<?php if ($_['mail_smtpmode'] != 'smtp') print_unescaped(' class="hidden"'); ?>>
<?php p($l->t( 'Encryption' )); ?>
</label>
<select name="mail_smtpsecure" id="mail_smtpsecure"
<?php if ($_['mail_smtpmode'] != 'smtp') print_unescaped(' class="hidden"'); ?>>
<?php foreach ($mail_smtpsecure as $secure => $name):
$selected = '';
if ($secure == $_['mail_smtpsecure']):
$selected = 'selected="selected"';
endif; ?>
<option value='<?php p($secure)?>' <?php p($selected) ?>><?php p($name) ?></option>
<?php endforeach;?>
</select>
</p>
<p>
<label for="mail_from_address"><?php p($l->t( 'From address' )); ?></label>
<input type="text" name='mail_from_address' id="mail_from_address" placeholder="<?php p($l->t('mail'))?>"
value='<?php p($_['mail_from_address']) ?>' />@
<input type="text" name='mail_domain' id="mail_domain" placeholder="example.com"
value='<?php p($_['mail_domain']) ?>' />
</p>
<p id="setting_smtpauth" <?php if ($_['mail_smtpmode'] != 'smtp') print_unescaped(' class="hidden"'); ?>>
<label for="mail_smtpauthtype"><?php p($l->t( 'Authentication method' )); ?></label>
<select name='mail_smtpauthtype' id='mail_smtpauthtype'>
<?php foreach ($mail_smtpauthtype as $authtype => $name):
$selected = '';
if ($authtype == $_['mail_smtpauthtype']):
$selected = 'selected="selected"';
endif; ?>
<option value='<?php p($authtype)?>' <?php p($selected) ?>><?php p($name) ?></option>
<?php endforeach;?>
</select>
<input type="checkbox" name="mail_smtpauth" id="mail_smtpauth" class="checkbox" value="1"
<?php if ($_['mail_smtpauth']) print_unescaped('checked="checked"'); ?> />
<label for="mail_smtpauth"><?php p($l->t( 'Authentication required' )); ?></label>
</p>
<p id="setting_smtphost" <?php if ($_['mail_smtpmode'] != 'smtp') print_unescaped(' class="hidden"'); ?>>
<label for="mail_smtphost"><?php p($l->t( 'Server address' )); ?></label>
<input type="text" name='mail_smtphost' id="mail_smtphost" placeholder="smtp.example.com"
value='<?php p($_['mail_smtphost']) ?>' />
:
<input type="text" name='mail_smtpport' id="mail_smtpport" placeholder="<?php p($l->t('Port'))?>"
value='<?php p($_['mail_smtpport']) ?>' />
</p>
</form>
<form class="mail_settings" id="mail_credentials_settings">
<p id="mail_credentials" <?php if (!$_['mail_smtpauth'] || $_['mail_smtpmode'] != 'smtp') print_unescaped(' class="hidden"'); ?>>
<label for="mail_smtpname"><?php p($l->t( 'Credentials' )); ?></label>
<input type="text" name='mail_smtpname' id="mail_smtpname" placeholder="<?php p($l->t('SMTP Username'))?>"
value='<?php p($_['mail_smtpname']) ?>' />
<input type="password" name='mail_smtppassword' id="mail_smtppassword" autocomplete="off"
placeholder="<?php p($l->t('SMTP Password'))?>" value='<?php p($_['mail_smtppassword']) ?>' />
<input id="mail_credentials_settings_submit" type="button" value="<?php p($l->t('Store credentials')) ?>">
</p>
</form>
<br />
<em><?php p($l->t( 'Test email settings' )); ?></em>
<input type="submit" name="sendtestemail" id="sendtestemail" value="<?php p($l->t( 'Send email' )); ?>"/>
<span id="sendtestmail_msg" class="msg"></span>
</div>

View File

@ -1,6 +1,8 @@
<?php
/**
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @license GNU AGPL version 3 or any later version
*
@ -19,5 +21,13 @@
*
*/
$template = new \OCP\Template('systemtags', 'admin');
return $template->fetchPage();
/** @var \OCP\IL10N $l */
/** @var array $_ */
?>
<?php foreach($_['forms'] as $form) {
if (isset($form['form'])) {?>
<div id="<?php isset($form['anchor']) ? p($form['anchor']) : p('');?>"><?php print_unescaped($form['form']);?></div>
<?php }
};?>

View File

@ -0,0 +1,90 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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/>.
*
*/
/** @var \OCP\IL10N $l */
/** @var array $_ */
?>
<div class="section" id='encryptionAPI'>
<h2><?php p($l->t('Server-side encryption')); ?></h2>
<a target="_blank" rel="noreferrer" class="icon-info"
title="<?php p($l->t('Open documentation'));?>"
href="<?php p(link_to_docs('admin-encryption')); ?>"></a>
<p id="enable">
<input type="checkbox"
id="enableEncryption" class="checkbox"
value="1" <?php if ($_['encryptionEnabled']) print_unescaped('checked="checked" disabled="disabled"'); ?> />
<label
for="enableEncryption"><?php p($l->t('Enable server-side encryption')); ?> <span id="startmigration_msg" class="msg"></span> </label><br/>
</p>
<div id="EncryptionWarning" class="warning hidden">
<p><?php p($l->t('Please read carefully before activating server-side encryption: ')); ?></p>
<ul>
<li><?php p($l->t('Once encryption is enabled, all files uploaded to the server from that point forward will be encrypted at rest on the server. It will only be possible to disable encryption at a later date if the active encryption module supports that function, and all pre-conditions (e.g. setting a recover key) are met.')); ?></li>
<li><?php p($l->t('Encryption alone does not guarantee security of the system. Please see documentation for more information about how the encryption app works, and the supported use cases.')); ?></li>
<li><?php p($l->t('Be aware that encryption always increases the file size.')); ?></li>
<li><?php p($l->t('It is always good to create regular backups of your data, in case of encryption make sure to backup the encryption keys along with your data.')); ?></li>
</ul>
<p><?php p($l->t('This is the final warning: Do you really want to enable encryption?')) ?> <input type="button"
id="reallyEnableEncryption"
value="<?php p($l->t("Enable encryption")); ?>" /></p>
</div>
<div id="EncryptionSettingsArea" class="<?php if (!$_['encryptionEnabled']) p('hidden'); ?>">
<div id='selectEncryptionModules' class="<?php if (!$_['encryptionReady']) p('hidden'); ?>">
<?php
if (empty($_['encryptionModules'])) {
p($l->t('No encryption module loaded, please enable an encryption module in the app menu.'));
} else { ?>
<h3><?php p($l->t('Select default encryption module:')) ?></h3>
<fieldset id='encryptionModules'>
<?php foreach ($_['encryptionModules'] as $id => $module): ?>
<input type="radio" id="<?php p($id) ?>"
name="default_encryption_module"
value="<?php p($id) ?>"
<?php if ($module['default']) {
p('checked');
} ?>>
<label
for="<?php p($id) ?>"><?php p($module['displayName']) ?></label>
<br/>
<?php endforeach; ?>
</fieldset>
<?php } ?>
</div>
<div id="migrationWarning" class="<?php if ($_['encryptionReady']) p('hidden'); ?>">
<?php
if ($_['encryptionReady'] === false && $_['externalBackendsEnabled'] === true) {
p($l->t('You need to migrate your encryption keys from the old encryption (ownCloud <= 8.0) to the new one. Please enable the "Default encryption module" and run \'occ encryption:migrate\''));
} elseif ($_['encryptionReady'] === false && $_['externalBackendsEnabled'] === false) {
p($l->t('You need to migrate your encryption keys from the old encryption (ownCloud <= 8.0) to the new one.')); ?>
<input type="submit" name="startmigration" id="startmigration"
value="<?php p($l->t('Start migration')); ?>"/>
<?php } ?>
</div>
</div>
</div>

View File

@ -0,0 +1,48 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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/>.
*
*/
style('settings', 'settings');
script('settings', [ 'settings', 'admin', 'log', 'certificates'] );
script('core', ['multiselect', 'setupchecks']);
script('files', 'jquery.fileupload');
vendor_script('select2/select2');
vendor_style('select2/select2');
?>
<div id="app-navigation">
<ul>
<?php foreach($_['forms'] as $form) {
if (isset($form['anchor'])) {
$anchor = \OC::$server->getURLGenerator()->linkToRoute('settings.AdminSettings.index', ['section' => $form['anchor']]);
$sectionName = $form['section-name'];
$active = $form['active'] ? ' class="active"' : '';
print_unescaped(sprintf("<li%s><a href='%s'>%s</a></li>", $active, \OCP\Util::sanitizeHTML($anchor), \OCP\Util::sanitizeHTML($sectionName)));
}
}?>
</ul>
</div>
<div id="app-content">
<?php print_unescaped($_['content']); ?>
</div>

View File

@ -0,0 +1,88 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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/>.
*
*/
/** @var \OCP\IL10N $l */
/** @var array $_ */
$levels = ['Debug', 'Info', 'Warning', 'Error', 'Fatal'];
$levelLabels = [
$l->t( 'Everything (fatal issues, errors, warnings, info, debug)' ),
$l->t( 'Info, warnings, errors and fatal issues' ),
$l->t( 'Warnings, errors and fatal issues' ),
$l->t( 'Errors and fatal issues' ),
$l->t( 'Fatal issues only' ),
];
?>
<div class="section" id="log-section">
<h2><?php p($l->t('Log'));?></h2>
<?php if ($_['showLog'] && $_['doesLogFileExist']): ?>
<table id="log" class="grid">
<?php foreach ($_['entries'] as $entry): ?>
<tr>
<td>
<?php p($levels[$entry->level]);?>
</td>
<td>
<?php p($entry->app);?>
</td>
<td class="log-message">
<?php p($entry->message);?>
</td>
<td class="date">
<?php if(is_int($entry->time)){
p(OC_Util::formatDate($entry->time));
} else {
p($entry->time);
}?>
</td>
<td><?php isset($entry->user) ? p($entry->user) : p('--') ?></td>
</tr>
<?php endforeach;?>
</table>
<p><?php p($l->t('What to log'));?> <select name='loglevel' id='loglevel'>
<?php for ($i = 0; $i < 5; $i++):
$selected = '';
if ($i == $_['loglevel']):
$selected = 'selected="selected"';
endif; ?>
<option value='<?php p($i)?>' <?php p($selected) ?>><?php p($levelLabels[$i])?></option>
<?php endfor;?>
</select></p>
<?php if ($_['logFileSize'] > 0): ?>
<a href="<?php print_unescaped(OC::$server->getURLGenerator()->linkToRoute('settings.LogSettings.download')); ?>" class="button" id="downloadLog"><?php p($l->t('Download logfile'));?></a>
<?php endif; ?>
<?php if ($_['entriesremain']): ?>
<input id="moreLog" type="button" value="<?php p($l->t('More'));?>...">
<input id="lessLog" type="button" value="<?php p($l->t('Less'));?>...">
<?php endif; ?>
<?php if ($_['logFileSize'] > (100 * 1024 * 1024)): ?>
<br>
<em>
<?php p($l->t('The logfile is bigger than 100 MB. Downloading it may take some time!')); ?>
</em>
<?php endif; ?>
<?php endif; ?>
</div>

View File

@ -0,0 +1,215 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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/>.
*
*/
/** @var \OCP\IL10N $l */
/** @var array $_ */
?>
<div id="security-warning" class="section">
<h2><?php p($l->t('Security & setup warnings'));?></h2>
<ul>
<?php
// is php setup properly to query system environment variables like getenv('PATH')
if ($_['getenvServerNotWorking']) {
?>
<li>
<?php p($l->t('php does not seem to be setup properly to query system environment variables. The test with getenv("PATH") only returns an empty response.')); ?><br>
<?php print_unescaped($l->t('Please check the <a target="_blank" rel="noreferrer" href="%s">installation documentation ↗</a> for php configuration notes and the php configuration of your server, especially when using php-fpm.', link_to_docs('admin-php-fpm'))); ?>
</li>
<?php
}
// is read only config enabled
if ($_['readOnlyConfigEnabled']) {
?>
<li>
<?php p($l->t('The Read-Only config has been enabled. This prevents setting some configurations via the web-interface. Furthermore, the file needs to be made writable manually for every update.')); ?>
</li>
<?php
}
// Are doc blocks accessible?
if (!$_['isAnnotationsWorking']) {
?>
<li>
<?php p($l->t('PHP is apparently setup to strip inline doc blocks. This will make several core apps inaccessible.')); ?><br>
<?php p($l->t('This is probably caused by a cache/accelerator such as Zend OPcache or eAccelerator.')); ?>
</li>
<?php
}
// Is the Transaction isolation level READ_COMMITTED?
if ($_['invalidTransactionIsolationLevel']) {
?>
<li>
<?php p($l->t('Your database does not run with "READ COMMITTED" transaction isolation level. This can cause problems when multiple actions are executed in parallel.')); ?>
</li>
<?php
}
// Warning if memcache is outdated
foreach ($_['OutdatedCacheWarning'] as $php_module => $data) {
?>
<li>
<?php p($l->t('%1$s below version %2$s is installed, for stability and performance reasons we recommend updating to a newer %1$s version.', $data)); ?>
</li>
<?php
}
// if module fileinfo available?
if (!$_['has_fileinfo']) {
?>
<li>
<?php p($l->t('The PHP module \'fileinfo\' is missing. We strongly recommend to enable this module to get best results with mime-type detection.')); ?>
</li>
<?php
}
// locking configured optimally?
if ($_['fileLockingType'] === 'none') {
?>
<li>
<?php print_unescaped($l->t('Transactional file locking is disabled, this might lead to issues with race conditions. Enable \'filelocking.enabled\' in config.php to avoid these problems. See the <a target="_blank" rel="noreferrer" href="%s">documentation ↗</a> for more information.', link_to_docs('admin-transactional-locking'))); ?>
</li>
<?php
}
// is locale working ?
if (!$_['isLocaleWorking']) {
?>
<li>
<?php
$locales = 'en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8';
p($l->t('System locale can not be set to a one which supports UTF-8.'));
?>
<br>
<?php
p($l->t('This means that there might be problems with certain characters in file names.'));
?>
<br>
<?php
p($l->t('We strongly suggest installing the required packages on your system to support one of the following locales: %s.', [$locales]));
?>
</li>
<?php
}
if ($_['suggestedOverwriteCliUrl']) {
?>
<li>
<?php p($l->t('If your installation is not installed in the root of the domain and uses system cron, there can be issues with the URL generation. To avoid these problems, please set the "overwrite.cli.url" option in your config.php file to the webroot path of your installation (Suggested: "%s")', $_['suggestedOverwriteCliUrl'])); ?>
</li>
<?php
}
if ($_['cronErrors']) {
?>
<li>
<?php p($l->t('It was not possible to execute the cronjob via CLI. The following technical errors have appeared:')); ?>
<br>
<ol>
<?php foreach(json_decode($_['cronErrors']) as $error) { if(isset($error->error)) {?>
<li><?php p($error->error) ?> <?php p($error->hint) ?></li>
<?php }};?>
</ol>
</li>
<?php
}
?>
</ul>
<div id="postsetupchecks" data-check-wellknown="<?php if($_['checkForWorkingWellKnownSetup']) { p('true'); } else { p('false'); } ?>">
<div class="loading"></div>
<ul class="errors hidden"></ul>
<ul class="warnings hidden"></ul>
<ul class="info hidden"></ul>
<p class="hint hidden">
<?php print_unescaped($l->t('Please double check the <a target="_blank" rel="noreferrer" href="%s">installation guides ↗</a>, and check for any errors or warnings in the <a href="#log-section">log</a>.', link_to_docs('admin-install'))); ?>
</p>
</div>
<div id="security-warning-state">
<span class="hidden icon-checkmark"><?php p($l->t('All checks passed.'));?></span>
</div>
</div>
<div class="section" id="backgroundjobs">
<h2 class="inlineblock"><?php p($l->t('Cron'));?></h2>
<?php if ($_['cron_log']): ?>
<p class="cronlog inlineblock">
<?php if ($_['lastcron'] !== false):
$relative_time = relative_modified_date($_['lastcron']);
$absolute_time = OC_Util::formatDate($_['lastcron']);
if (time() - $_['lastcron'] <= 3600): ?>
<span class="status success"></span>
<span class="crondate" title="<?php p($absolute_time);?>">
<?php p($l->t("Last cron job execution: %s.", [$relative_time]));?>
</span>
<?php else: ?>
<span class="status error"></span>
<span class="crondate" title="<?php p($absolute_time);?>">
<?php p($l->t("Last cron job execution: %s. Something seems wrong.", [$relative_time]));?>
</span>
<?php endif;
else: ?>
<span class="status error"></span>
<?php p($l->t("Cron was not executed yet!"));
endif; ?>
</p>
<?php endif; ?>
<a target="_blank" rel="noreferrer" class="icon-info"
title="<?php p($l->t('Open documentation'));?>"
href="<?php p(link_to_docs('admin-background-jobs')); ?>"></a>
<p>
<input type="radio" name="mode" value="ajax" class="radio"
id="backgroundjobs_ajax" <?php if ($_['backgroundjobs_mode'] === "ajax") {
print_unescaped('checked="checked"');
} ?>>
<label for="backgroundjobs_ajax">AJAX</label><br/>
<em><?php p($l->t("Execute one task with each page loaded")); ?></em>
</p>
<p>
<input type="radio" name="mode" value="webcron" class="radio"
id="backgroundjobs_webcron" <?php if ($_['backgroundjobs_mode'] === "webcron") {
print_unescaped('checked="checked"');
} ?>>
<label for="backgroundjobs_webcron">Webcron</label><br/>
<em><?php p($l->t("cron.php is registered at a webcron service to call cron.php every 15 minutes over http.")); ?></em>
</p>
<p>
<input type="radio" name="mode" value="cron" class="radio"
id="backgroundjobs_cron" <?php if ($_['backgroundjobs_mode'] === "cron") {
print_unescaped('checked="checked"');
} ?>>
<label for="backgroundjobs_cron">Cron</label><br/>
<em><?php p($l->t("Use system's cron service to call the cron.php file every 15 minutes.")); ?></em>
</p>
</div>
<div class="section">
<!-- should be the last part, so Updater can follow if enabled (it has no heading therefore). -->
<h2><?php p($l->t('Version'));?></h2>
<p><a href="<?php print_unescaped($theme->getBaseUrl()); ?>" rel="noreferrer" target="_blank"><?php p($theme->getTitle()); ?></a> <?php p(OC_Util::getHumanVersion()) ?></p>
<p><?php include(__DIR__ . '/../settings.development.notice.php'); ?></p>
</div>

View File

@ -0,0 +1,107 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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/>.
*
*/
/** @var \OCP\IL10N $l */
/** @var array $_ */
?>
<div class="section" id="shareAPI">
<h2><?php p($l->t('Sharing'));?></h2>
<a target="_blank" rel="noreferrer" class="icon-info"
title="<?php p($l->t('Open documentation'));?>"
href="<?php p(link_to_docs('admin-sharing')); ?>"></a>
<p id="enable">
<input type="checkbox" name="shareapi_enabled" id="shareAPIEnabled" class="checkbox"
value="1" <?php if ($_['shareAPIEnabled'] === 'yes') print_unescaped('checked="checked"'); ?> />
<label for="shareAPIEnabled"><?php p($l->t('Allow apps to use the Share API'));?></label><br/>
</p>
<p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
<input type="checkbox" name="shareapi_allow_links" id="allowLinks" class="checkbox"
value="1" <?php if ($_['allowLinks'] === 'yes') print_unescaped('checked="checked"'); ?> />
<label for="allowLinks"><?php p($l->t('Allow users to share via link'));?></label><br/>
</p>
<p id="publicLinkSettings" class="indent <?php if ($_['allowLinks'] !== 'yes' || $_['shareAPIEnabled'] === 'no') p('hidden'); ?>">
<input type="checkbox" name="shareapi_allow_public_upload" id="allowPublicUpload" class="checkbox"
value="1" <?php if ($_['allowPublicUpload'] == 'yes') print_unescaped('checked="checked"'); ?> />
<label for="allowPublicUpload"><?php p($l->t('Allow public uploads'));?></label><br/>
<input type="checkbox" name="shareapi_enforce_links_password" id="enforceLinkPassword" class="checkbox"
value="1" <?php if ($_['enforceLinkPassword']) print_unescaped('checked="checked"'); ?> />
<label for="enforceLinkPassword"><?php p($l->t('Enforce password protection'));?></label><br/>
<input type="checkbox" name="shareapi_default_expire_date" id="shareapiDefaultExpireDate" class="checkbox"
value="1" <?php if ($_['shareDefaultExpireDateSet'] === 'yes') print_unescaped('checked="checked"'); ?> />
<label for="shareapiDefaultExpireDate"><?php p($l->t('Set default expiration date'));?></label><br/>
<input type="checkbox" name="shareapi_allow_public_notification" id="allowPublicMailNotification" class="checkbox"
value="1" <?php if ($_['allowPublicMailNotification'] == 'yes') print_unescaped('checked="checked"'); ?> />
<label for="allowPublicMailNotification"><?php p($l->t('Allow users to send mail notification for shared files'));?></label><br/>
</p>
<p id="setDefaultExpireDate" class="double-indent <?php if ($_['allowLinks'] !== 'yes' || $_['shareDefaultExpireDateSet'] === 'no' || $_['shareAPIEnabled'] === 'no') p('hidden');?>">
<?php p($l->t( 'Expire after ' )); ?>
<input type="text" name='shareapi_expire_after_n_days' id="shareapiExpireAfterNDays" placeholder="<?php p('7')?>"
value='<?php p($_['shareExpireAfterNDays']) ?>' />
<?php p($l->t( 'days' )); ?>
<input type="checkbox" name="shareapi_enforce_expire_date" id="shareapiEnforceExpireDate" class="checkbox"
value="1" <?php if ($_['shareEnforceExpireDate'] === 'yes') print_unescaped('checked="checked"'); ?> />
<label for="shareapiEnforceExpireDate"><?php p($l->t('Enforce expiration date'));?></label><br/>
</p>
<p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
<input type="checkbox" name="shareapi_allow_resharing" id="allowResharing" class="checkbox"
value="1" <?php if ($_['allowResharing'] === 'yes') print_unescaped('checked="checked"'); ?> />
<label for="allowResharing"><?php p($l->t('Allow resharing'));?></label><br/>
</p>
<p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
<input type="checkbox" name="shareapi_allow_group_sharing" id="allowGroupSharing" class="checkbox"
value="1" <?php if ($_['allowGroupSharing'] === 'yes') print_unescaped('checked="checked"'); ?> />
<label for="allowGroupSharing"><?php p($l->t('Allow sharing with groups'));?></label><br />
</p>
<p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
<input type="checkbox" name="shareapi_only_share_with_group_members" id="onlyShareWithGroupMembers" class="checkbox"
value="1" <?php if ($_['onlyShareWithGroupMembers']) print_unescaped('checked="checked"'); ?> />
<label for="onlyShareWithGroupMembers"><?php p($l->t('Restrict users to only share with users in their groups'));?></label><br/>
</p>
<p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
<input type="checkbox" name="shareapi_allow_mail_notification" id="allowMailNotification" class="checkbox"
value="1" <?php if ($_['allowMailNotification'] === 'yes') print_unescaped('checked="checked"'); ?> />
<label for="allowMailNotification"><?php p($l->t('Allow users to send mail notification for shared files to other users'));?></label><br/>
</p>
<p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
<input type="checkbox" name="shareapi_exclude_groups" id="shareapiExcludeGroups" class="checkbox"
value="1" <?php if ($_['shareExcludeGroups']) print_unescaped('checked="checked"'); ?> />
<label for="shareapiExcludeGroups"><?php p($l->t('Exclude groups from sharing'));?></label><br/>
</p>
<p id="selectExcludedGroups" class="indent <?php if (!$_['shareExcludeGroups'] || $_['shareAPIEnabled'] === 'no') p('hidden'); ?>">
<input name="shareapi_exclude_groups_list" type="hidden" id="excludedGroups" value="<?php p($_['shareExcludedGroupsList']) ?>" style="width: 400px"/>
<br />
<em><?php p($l->t('These groups will still be able to receive shares, but not to initiate them.')); ?></em>
</p>
<p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
<input type="checkbox" name="shareapi_allow_share_dialog_user_enumeration" value="1" id="shareapi_allow_share_dialog_user_enumeration" class="checkbox"
<?php if ($_['allowShareDialogUserEnumeration'] === 'yes') print_unescaped('checked="checked"'); ?> />
<label for="shareapi_allow_share_dialog_user_enumeration"><?php p($l->t('Allow username autocompletion in share dialog. If this is disabled the full username needs to be entered.'));?></label><br />
</p>
</div>

View File

@ -0,0 +1,49 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @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/>.
*
*/
/** @var \OCP\IL10N $l */
/** @var array $_ */
?>
<div class="section" id="admin-tips">
<h2><?php p($l->t('Tips & tricks'));?></h2>
<ul>
<?php
// SQLite database performance issue
if ($_['databaseOverload']) {
?>
<li>
<?php p($l->t('SQLite is used as database. For larger installations we recommend to switch to a different database backend.')); ?><br>
<?php p($l->t('Especially when using the desktop client for file syncing the use of SQLite is discouraged.')); ?><br>
<?php print_unescaped($l->t('To migrate to another database use the command line tool: \'occ db:convert-type\', or see the <a target="_blank" rel="noreferrer" href="%s">documentation ↗</a>.', link_to_docs('admin-db-conversion') )); ?>
</li>
<?php } ?>
<li><a target="_blank" rel="noreferrer" href="<?php p(link_to_docs('admin-backup')); ?>"><?php p($l->t('How to do backups'));?> ↗</a></li>
<li><a target="_blank" rel="noreferrer" href="<?php p(link_to_docs('admin-monitoring')); ?>"><?php p($l->t('Advanced monitoring'));?> ↗</a></li>
<li><a target="_blank" rel="noreferrer" href="<?php p(link_to_docs('admin-performance')); ?>"><?php p($l->t('Performance tuning'));?> ↗</a></li>
<li><a target="_blank" rel="noreferrer" href="<?php p(link_to_docs('admin-config')); ?>"><?php p($l->t('Improving the config.php'));?> ↗</a></li>
<li><a target="_blank" rel="noreferrer" href="<?php p(link_to_docs('developer-theming')); ?>"><?php p($l->t('Theming'));?> ↗</a></li>
<li><a target="_blank" rel="noreferrer" href="<?php p(link_to_docs('admin-security')); ?>"><?php p($l->t('Hardening and security guidance'));?> ↗</a></li>
</ul>
</div>

View File

@ -57,14 +57,14 @@ class LoginControllerTest extends TestCase {
public function setUp() {
parent::setUp();
$this->request = $this->createMock('\\OCP\\IRequest');
$this->userManager = $this->createMock('\\OCP\\IUserManager');
$this->config = $this->createMock('\\OCP\\IConfig');
$this->session = $this->createMock('\\OCP\\ISession');
$this->request = $this->getMockBuilder('\\OCP\\IRequest')->getMock();
$this->userManager = $this->getMockBuilder('\\OCP\\IUserManager')->getMock();
$this->config = $this->getMockBuilder('\\OCP\\IConfig')->getMock();
$this->session = $this->getMockBuilder('\\OCP\\ISession')->getMock();
$this->userSession = $this->getMockBuilder('\\OC\\User\\Session')
->disableOriginalConstructor()
->getMock();
$this->urlGenerator = $this->createMock('\\OCP\\IURLGenerator');
$this->urlGenerator = $this->getMockBuilder('\\OCP\\IURLGenerator')->getMock();
$this->twoFactorManager = $this->getMockBuilder('\OC\Authentication\TwoFactorAuth\Manager')
->disableOriginalConstructor()
->getMock();
@ -110,7 +110,7 @@ class LoginControllerTest extends TestCase {
->method('getCookie')
->with('oc_token')
->willReturn('MyLoginToken');
$user = $this->createMock('\\OCP\\IUser');
$user = $this->getMockBuilder('\\OCP\\IUser')->getMock();
$user
->expects($this->once())
->method('getUID')
@ -218,7 +218,7 @@ class LoginControllerTest extends TestCase {
->method('getSystemValue')
->with('lost_password_link')
->willReturn(false);
$user = $this->createMock('\\OCP\\IUser');
$user = $this->getMockBuilder('\\OCP\\IUser')->getMock();
$user
->expects($this->once())
->method('canChangePassword')
@ -257,7 +257,7 @@ class LoginControllerTest extends TestCase {
->method('getSystemValue')
->with('lost_password_link')
->willReturn(false);
$user = $this->createMock('\\OCP\\IUser');
$user = $this->getMockBuilder('\\OCP\\IUser')->getMock();
$user
->expects($this->once())
->method('canChangePassword')
@ -329,7 +329,7 @@ class LoginControllerTest extends TestCase {
public function testLoginWithValidCredentials() {
/** @var IUser | \PHPUnit_Framework_MockObject_MockObject $user */
$user = $this->createMock('\OCP\IUser');
$user = $this->getMockBuilder('\OCP\IUser')->getMock();
$password = 'secret';
$indexPageUrl = \OC_Util::getDefaultPageUrl();
@ -370,7 +370,7 @@ class LoginControllerTest extends TestCase {
public function testLoginWithoutPassedCsrfCheckAndNotLoggedIn() {
/** @var IUser | \PHPUnit_Framework_MockObject_MockObject $user */
$user = $this->createMock('\OCP\IUser');
$user = $this->getMockBuilder('\OCP\IUser')->getMock();
$user->expects($this->any())
->method('getUID')
->will($this->returnValue('jane'));
@ -405,7 +405,7 @@ class LoginControllerTest extends TestCase {
public function testLoginWithoutPassedCsrfCheckAndLoggedIn() {
/** @var IUser | \PHPUnit_Framework_MockObject_MockObject $user */
$user = $this->createMock('\OCP\IUser');
$user = $this->getMockBuilder('\OCP\IUser')->getMock();
$user->expects($this->any())
->method('getUID')
->will($this->returnValue('jane'));
@ -445,7 +445,7 @@ class LoginControllerTest extends TestCase {
public function testLoginWithValidCredentialsAndRedirectUrl() {
/** @var IUser | \PHPUnit_Framework_MockObject_MockObject $user */
$user = $this->createMock('\OCP\IUser');
$user = $this->getMockBuilder('\OCP\IUser')->getMock();
$user->expects($this->any())
->method('getUID')
->will($this->returnValue('jane'));
@ -492,7 +492,7 @@ class LoginControllerTest extends TestCase {
public function testLoginWithTwoFactorEnforced() {
/** @var IUser | \PHPUnit_Framework_MockObject_MockObject $user */
$user = $this->createMock('\OCP\IUser');
$user = $this->getMockBuilder('\OCP\IUser')->getMock();
$user->expects($this->any())
->method('getUID')
->will($this->returnValue('john'));
@ -543,7 +543,7 @@ class LoginControllerTest extends TestCase {
public function testToNotLeakLoginName() {
/** @var IUser | \PHPUnit_Framework_MockObject_MockObject $user */
$user = $this->createMock('\OCP\IUser');
$user = $this->getMockBuilder('\OCP\IUser')->getMock();
$user->expects($this->any())
->method('getUID')
->will($this->returnValue('john'));

View File

@ -0,0 +1,72 @@
<?php
/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @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 Tests\Settings\Controller;
use OC\Settings\Admin\TipsTricks;
use OC\Settings\Controller\AdminSettingsController;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\INavigationManager;
use OCP\IRequest;
use OCP\Settings\IManager;
use Test\TestCase;
class AdminSettingsControllerTest extends TestCase {
/** @var AdminSettingsController */
private $adminSettingsController;
/** @var IRequest */
private $request;
/** @var INavigationManager */
private $navigationManager;
/** @var IManager */
private $settingsManager;
public function setUp() {
parent::setUp();
$this->request = $this->getMockBuilder('\OCP\IRequest')->getMock();
$this->navigationManager = $this->getMockBuilder('\OCP\INavigationManager')->getMock();
$this->settingsManager = $this->getMockBuilder('\OCP\Settings\IManager')->getMock();
$this->adminSettingsController = new AdminSettingsController(
'settings',
$this->request,
$this->navigationManager,
$this->settingsManager
);
}
public function testIndex() {
$this->settingsManager
->expects($this->once())
->method('getAdminSections')
->willReturn([]);
$this->settingsManager
->expects($this->once())
->method('getAdminSettings')
->with('test')
->willReturn([5 => new TipsTricks($this->getMockBuilder('\OCP\IConfig')->getMock())]);
$expected = new TemplateResponse('settings', 'admin/frame', ['forms' => [], 'content' => '']);
$this->assertEquals($expected, $this->adminSettingsController->index('test'));
}
}

View File

@ -29,6 +29,7 @@ use OCP\AppFramework\Http\RedirectResponse;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IRequest;
use OCP\IURLGenerator;
use OC_Util;
@ -55,6 +56,8 @@ class CheckSetupControllerTest extends TestCase {
private $util;
/** @var IL10N */
private $l10n;
/** @var ILogger */
private $logger;
/** @var Checker */
private $checker;
@ -82,6 +85,7 @@ class CheckSetupControllerTest extends TestCase {
}));
$this->checker = $this->getMockBuilder('\OC\IntegrityCheck\Checker')
->disableOriginalConstructor()->getMock();
$this->logger = $this->getMockBuilder('\OCP\ILogger')->getMock();
$this->checkSetupController = $this->getMockBuilder('\OC\Settings\Controller\CheckSetupController')
->setConstructorArgs([
'settings',
@ -92,6 +96,7 @@ class CheckSetupControllerTest extends TestCase {
$this->util,
$this->l10n,
$this->checker,
$this->logger
])
->setMethods(['getCurlVersion', 'isPhpOutdated'])->getMock();
}
@ -366,7 +371,8 @@ class CheckSetupControllerTest extends TestCase {
$this->urlGenerator,
$this->util,
$this->l10n,
$this->checker
$this->checker,
$this->logger
])
->setMethods(null)->getMock();
@ -605,7 +611,7 @@ class CheckSetupControllerTest extends TestCase {
$this->urlGenerator
->expects($this->once())
->method('linkToRoute')
->with('settings_admin')
->with('settings.AdminSettings.index')
->will($this->returnValue('/admin'));
$expected = new RedirectResponse('/admin');

View File

@ -0,0 +1,127 @@
<?php
/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @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 Test\Settings\Admin;
use OC\Settings\Admin\Additional;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use Test\TestCase;
class AdditionalTest extends TestCase {
/** @var Additional */
private $admin;
/** @var IConfig */
private $config;
public function setUp() {
parent::setUp();
$this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
$this->admin = new Additional(
$this->config
);
}
public function testGetForm() {
$this->config
->expects($this->at(0))
->method('getSystemValue')
->with('mail_domain', '')
->willReturn('mx.nextcloud.com');
$this->config
->expects($this->at(1))
->method('getSystemValue')
->with('mail_from_address', '')
->willReturn('no-reply@nextcloud.com');
$this->config
->expects($this->at(2))
->method('getSystemValue')
->with('mail_smtpmode', '')
->willReturn('php');
$this->config
->expects($this->at(3))
->method('getSystemValue')
->with('mail_smtpsecure', '')
->willReturn(true);
$this->config
->expects($this->at(4))
->method('getSystemValue')
->with('mail_smtphost', '')
->willReturn('smtp.nextcloud.com');
$this->config
->expects($this->at(5))
->method('getSystemValue')
->with('mail_smtpport', '')
->willReturn(25);
$this->config
->expects($this->at(6))
->method('getSystemValue')
->with('mail_smtpauthtype', '')
->willReturn('login');
$this->config
->expects($this->at(7))
->method('getSystemValue')
->with('mail_smtpauth', false)
->willReturn(true);
$this->config
->expects($this->at(8))
->method('getSystemValue')
->with('mail_smtpname', '')
->willReturn('smtp.sender.com');
$this->config
->expects($this->at(9))
->method('getSystemValue')
->with('mail_smtppassword', '')
->willReturn('mypassword');
$expected = new TemplateResponse(
'settings',
'admin/additional-mail',
[
'sendmail_is_available' => (bool) \OC_Helper::findBinaryPath('sendmail'),
'mail_domain' => 'mx.nextcloud.com',
'mail_from_address' => 'no-reply@nextcloud.com',
'mail_smtpmode' => 'php',
'mail_smtpsecure' => true,
'mail_smtphost' => 'smtp.nextcloud.com',
'mail_smtpport' => 25,
'mail_smtpauthtype' => 'login',
'mail_smtpauth' => true,
'mail_smtpname' => 'smtp.sender.com',
'mail_smtppassword' => 'mypassword',
],
''
);
$this->assertEquals($expected, $this->admin->getForm());
}
public function testGetSection() {
$this->assertSame('additional', $this->admin->getSection());
}
public function testGetPriority() {
$this->assertSame(0, $this->admin->getPriority());
}
}

View File

@ -0,0 +1,138 @@
<?php
/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @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 Test\Settings\Admin;
use OC\Encryption\Manager;
use OC\Settings\Admin\Encryption;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IUserManager;
use Test\TestCase;
class EncryptionTest extends TestCase {
/** @var Encryption */
private $admin;
/** @var Manager */
private $manager;
/** @var IUserManager */
private $userManager;
public function setUp() {
parent::setUp();
$this->manager = $this->getMockBuilder('\OC\Encryption\Manager')->disableOriginalConstructor()->getMock();
$this->userManager = $this->getMockBuilder('\OCP\IUserManager')->getMock();
$this->admin = new Encryption(
$this->manager,
$this->userManager
);
}
/**
* @return array
*/
public function encryptionSettingsProvider() {
return [
[true],
[false],
];
}
/**
* @dataProvider encryptionSettingsProvider
* @param bool $enabled
*/
public function testGetFormWithOnlyOneBackend($enabled) {
$this->manager
->expects($this->once())
->method('isEnabled')
->willReturn($enabled);
$this->manager
->expects($this->once())
->method('isReady')
->willReturn($enabled);
$this->manager
->expects($this->once())
->method('getEncryptionModules')
->willReturn([]);
$this->userManager
->expects($this->once())
->method('getBackends')
->willReturn(['entry']);
$expected = new TemplateResponse(
'settings',
'admin/encryption',
[
'encryptionEnabled' => $enabled,
'encryptionReady' => $enabled,
'externalBackendsEnabled' => false,
'encryptionModules' => []
],
''
);
$this->assertEquals($expected, $this->admin->getForm());
}
/**
* @dataProvider encryptionSettingsProvider
* @param bool $enabled
*/
public function testGetFormWithMultipleBackends($enabled) {
$this->manager
->expects($this->once())
->method('isEnabled')
->willReturn($enabled);
$this->manager
->expects($this->once())
->method('isReady')
->willReturn($enabled);
$this->manager
->expects($this->once())
->method('getEncryptionModules')
->willReturn([]);
$this->userManager
->expects($this->once())
->method('getBackends')
->willReturn(['entry', 'entry']);
$expected = new TemplateResponse(
'settings',
'admin/encryption',
[
'encryptionEnabled' => $enabled,
'encryptionReady' => $enabled,
'externalBackendsEnabled' => true,
'encryptionModules' => []
],
''
);
$this->assertEquals($expected, $this->admin->getForm());
}
public function testGetSection() {
$this->assertSame('encryption', $this->admin->getSection());
}
public function testGetPriority() {
$this->assertSame(0, $this->admin->getPriority());
}
}

View File

@ -0,0 +1,91 @@
<?php
/**
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
*
* @author Lukas Reschke <lukas@statuscode.ch>
*
* @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 Test\Settings\Admin;
use OC\Settings\Admin\Logging;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use Test\TestCase;
use OC\Log\Owncloud as LogFile;
class LoggingTest extends TestCase {
/** @var Logging */
private $admin;
/** @var IConfig */
private $config;
public function setUp() {
parent::setUp();
$this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
$this->admin = new Logging(
$this->config
);
}
public function testGetForm() {
$this->config
->expects($this->at(0))
->method('getSystemValue')
->with('log_type', 'file')
->willReturn('owncloud');
$this->config
->expects($this->at(1))
->method('getSystemValue')
->with('loglevel', 2)
->willReturn(3);
$numEntriesToLoad = 5;
$entries = LogFile::getEntries($numEntriesToLoad + 1);
$entriesRemaining = count($entries) > $numEntriesToLoad;
$entries = array_slice($entries, 0, $numEntriesToLoad);
$logFileExists = file_exists(LogFile::getLogFilePath()) ;
$logFileSize = $logFileExists ? filesize(LogFile::getLogFilePath()) : 0;
$expected = new TemplateResponse(
'settings',
'admin/logging',
[
'loglevel' => 3,
'entries' => $entries,
'entriesremain' => $entriesRemaining,
'doesLogFileExist' => $logFileExists,
'logFileSize' => $logFileSize,
'showLog' => true,
],
''
);
$this->assertEquals($expected, $this->admin->getForm());
}
public function testGetSection() {
$this->assertSame('logging', $this->admin->getSection());
}
public function testGetPriority() {
$this->assertSame(0, $this->admin->getPriority());
}
}

Some files were not shown because too many files have changed in this diff Show More