]> source.dussan.org Git - nextcloud-server.git/commitdiff
Initial work on Apps page split:
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Mon, 8 Aug 2016 21:31:26 +0000 (23:31 +0200)
committerLukas Reschke <lukas@statuscode.ch>
Tue, 16 Aug 2016 19:04:22 +0000 (21:04 +0200)
* interfaces for the Admin settings (IAdmin) and section (ISection)
* SettingsManager service
* example setup with LDAP app

31 files changed:
apps/user_ldap/appinfo/info.xml
apps/user_ldap/lib/Settings/Admin.php [new file with mode: 0644]
apps/user_ldap/lib/Settings/Section.php [new file with mode: 0644]
core/templates/untrustedDomain.php
db_structure.xml
lib/private/Installer.php
lib/private/Server.php
lib/private/Settings/Admin/Encryption.php [new file with mode: 0644]
lib/private/Settings/Admin/Logging.php [new file with mode: 0644]
lib/private/Settings/Admin/Server.php [new file with mode: 0644]
lib/private/Settings/Admin/Sharing.php [new file with mode: 0644]
lib/private/Settings/Admin/TipsTricks.php [new file with mode: 0644]
lib/private/Settings/Manager.php [new file with mode: 0644]
lib/private/Settings/Section.php [new file with mode: 0644]
lib/private/legacy/app.php
lib/public/Settings/IAdmin.php [new file with mode: 0644]
lib/public/Settings/IManager.php [new file with mode: 0644]
lib/public/Settings/ISection.php [new file with mode: 0644]
reset.php [new file with mode: 0644]
settings/Application.php
settings/Controller/AdminSettingsController.php [new file with mode: 0644]
settings/Controller/CheckSetupController.php
settings/admin.php [deleted file]
settings/routes.php
settings/templates/admin.php [deleted file]
settings/templates/admin/encryption.php [new file with mode: 0644]
settings/templates/admin/frame.php [new file with mode: 0644]
settings/templates/admin/logging.php [new file with mode: 0644]
settings/templates/admin/server.php [new file with mode: 0644]
settings/templates/admin/sharing.php [new file with mode: 0644]
settings/templates/admin/tipstricks.php [new file with mode: 0644]

index fc44a01687e3e0a2da97da57b094e66f95654cc2..a84b6c22a6b568ab511311d6c019b583cb3fd42e 100644 (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>
diff --git a/apps/user_ldap/lib/Settings/Admin.php b/apps/user_ldap/lib/Settings/Admin.php
new file mode 100644 (file)
index 0000000..11e2627
--- /dev/null
@@ -0,0 +1,115 @@
+<?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\IL10N;
+use OCP\Settings\IAdmin;
+use OCP\Template;
+
+class Admin implements IAdmin {
+
+       /** @var IL10N */
+       private $l;
+
+       public function __construct(IL10N $l) {
+               $this->l = $l;
+       }
+
+       /**
+        * @return Template all parameters are supposed to be assigned
+        */
+       public function render() {
+               $settings = new Template('user_ldap', 'settings');
+
+               $helper = new Helper();
+               $prefixes = $helper->getServerConfigurationPrefixes();
+               $hosts = $helper->getServerConfigurationHosts();
+
+               $wizardHtml = '';
+               $toc = [];
+
+               $wControls = new Template('user_ldap', 'part.wizardcontrols');
+               $wControls = $wControls->fetchPage();
+               $sControls = new Template('user_ldap', 'part.settingcontrols');
+               $sControls = $sControls->fetchPage();
+
+               $wizTabs = [
+                       ['tpl' => 'part.wizard-server',      'cap' => $this->l->t('Server')],
+                       ['tpl' => 'part.wizard-userfilter',  'cap' => $this->l->t('Users')],
+                       ['tpl' => 'part.wizard-loginfilter', 'cap' => $this->l->t('Login Attributes')],
+                       ['tpl' => 'part.wizard-groupfilter', 'cap' => $this->l->t('Groups')],
+               ];
+               $wizTabsCount = count($wizTabs);
+               for($i = 0; $i < $wizTabsCount; $i++) {
+                       $tab = new 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'];
+               }
+
+               $settings->assign('tabs', $wizardHtml);
+               $settings->assign('toc', $toc);
+               $settings->assign('settingControls', $sControls);
+
+               // assign default values
+               $config = new Configuration('', false);
+               $defaults = $config->getDefaults();
+               foreach($defaults as $key => $default) {
+                       $settings->assign($key.'_default', $default);
+               }
+
+               return $settings;
+       }
+
+       /**
+        * @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;
+       }
+
+       private function renderControls() {
+               $controls = new Template('user_ldap', 'part.settingcontrols');
+               return $controls->fetchPage();
+
+       }
+}
diff --git a/apps/user_ldap/lib/Settings/Section.php b/apps/user_ldap/lib/Settings/Section.php
new file mode 100644 (file)
index 0000000..a10bd7c
--- /dev/null
@@ -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;
+       }
+}
index 46bad2168225fe237b32e857b116d7e254219586..735f83fedec3fca455f7c02e03529deb47d0b944 100644 (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>
index 04c91ea494f70704d52d150560594a5ae1c74d00..f6955be8e0665a20c8c637b9ea3f02b80bb74396 100644 (file)
 
        </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>
+                               <unique>true</unique>
+                               <field>
+                                       <name>id</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_sections_id_index</name>
+                               <unique>true</unique>
+                               <field>
+                                       <name>id</name>
+                                       <sorting>ascending</sorting>
+                               </field>
+                       </index>
+
+               </declaration>
+       </table>
+
 </database>
index eed97e18d94ce7eea862b0124ca802527f9f42fe..a4300785002aebd76da5092dfdf43a300030b2cb 100644 (file)
@@ -135,6 +135,7 @@ class Installer {
                }
 
                \OC_App::setupBackgroundJobs($info['background-jobs']);
+               \OC::$server->getSettingsManager()->setupSettings($info['settings']);
 
                //run appinfo/install.php
                if((!isset($data['noinstall']) or $data['noinstall']==false)) {
index 16a6ee3ba64234058981e2033ac0aa2a8225f42c..7de927eb88c466b1491e683f3a9111fabb82259a 100644 (file)
@@ -721,6 +721,17 @@ 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()
+                       );
+                       return $manager;
+               });
        }
 
        /**
@@ -1424,4 +1435,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');
+       }
 }
diff --git a/lib/private/Settings/Admin/Encryption.php b/lib/private/Settings/Admin/Encryption.php
new file mode 100644 (file)
index 0000000..38197f7
--- /dev/null
@@ -0,0 +1,78 @@
+<?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\IUserManager;
+use OCP\Settings\IAdmin;
+use OCP\Template;
+
+class Encryption implements IAdmin {
+       /** @var Manager */
+       private $manager;
+
+       /** @var IUserManager */
+       private $userManager;
+
+       public function __construct(Manager $manager, IUserManager $userManager) {
+               $this->manager = $manager;
+               $this->userManager = $userManager;
+       }
+
+       /**
+        * @return Template all parameters are supposed to be assigned
+        */
+       public function render() {
+               $parameters = [
+                       // Encryption API
+                       'encryptionEnabled'       => $this->manager->isEnabled(),
+                       'encryptionReady'         => $this->manager->isReady(),
+                       'externalBackendsEnabled' => count($this->userManager->getBackends()) > 1,
+               ];
+
+               $form = new Template('settings', 'admin/encryption');
+               foreach ($parameters as $key => $value) {
+                       $form->assign($key, $value);
+               }
+               return $form;
+       }
+
+       /**
+        * @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;
+       }
+}
diff --git a/lib/private/Settings/Admin/Logging.php b/lib/private/Settings/Admin/Logging.php
new file mode 100644 (file)
index 0000000..ead5581
--- /dev/null
@@ -0,0 +1,87 @@
+<?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\File as LogFile;
+use OCP\IConfig;
+use OCP\Settings\IAdmin;
+use OCP\Template;
+
+class Logging implements IAdmin {
+       /** @var IConfig */
+       private $config;
+
+       public function __construct(IConfig $config) {
+               $this->config = $config;
+       }
+
+       /**
+        * @return Template all parameters are supposed to be assigned
+        */
+       public function render() {
+               $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,
+               ];
+
+               $form = new Template('settings', 'admin/logging');
+               foreach ($parameters as $key => $value) {
+                       $form->assign($key, $value);
+               }
+               return $form;
+       }
+
+       /**
+        * @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;
+       }
+}
diff --git a/lib/private/Settings/Admin/Server.php b/lib/private/Settings/Admin/Server.php
new file mode 100644 (file)
index 0000000..c0f3584
--- /dev/null
@@ -0,0 +1,114 @@
+<?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 OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\Settings\IAdmin;
+use OCP\Template;
+
+class Server implements IAdmin {
+
+       /** @var IDBConnection|Connection */
+       private $db;
+
+       /** @var IConfig */
+       private $config;
+
+       public function __construct(IDBConnection $db, IConfig $config) {
+               $this->db = $db;
+               $this->config = $config;
+       }
+
+       /**
+        * @return Template all parameters are supposed to be assigned
+        */
+       public function render() {
+               try {
+                       if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) {
+                               $invalidTransactionIsolationLevel = false;
+                       } else {
+                               $invalidTransactionIsolationLevel = $this->db->getTransactionIsolation() !== Connection::TRANSACTION_READ_COMMITTED;
+                       }
+               } catch (DBALException $e) {
+                       // ignore
+                       $invalidTransactionIsolationLevel = false;
+               }
+
+               $parameters = [
+                       // Diagnosis
+                       'readOnlyConfigEnabled' => \OC_Helper::isReadOnlyConfigEnabled(),
+                       'isLocaleWorking' => \OC_Util::isSetLocaleWorking(),
+                       'isAnnotationsWorking' => \OC_Util::isAnnotationsWorking(),
+                       'checkForWorkingWellKnownSetup', $this->config->getSystemValue('check_for_working_wellknown_setup'),
+                       'has_fileinfo' => \OC_Util::fileInfoLoaded(),
+                       'invalidTransactionIsolationLevel' => $invalidTransactionIsolationLevel,
+
+                       // 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),
+
+                       // 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', ''),
+               ];
+
+               $form = new Template('settings', 'admin/server');
+               foreach ($parameters as $key => $value) {
+                       $form->assign($key, $value);
+               }
+               return $form;
+       }
+
+       /**
+        * @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;
+       }
+}
diff --git a/lib/private/Settings/Admin/Sharing.php b/lib/private/Settings/Admin/Sharing.php
new file mode 100644 (file)
index 0000000..7fefa40
--- /dev/null
@@ -0,0 +1,79 @@
+<?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\IConfig;
+use OCP\Settings\IAdmin;
+use OCP\Template;
+
+class Sharing implements IAdmin {
+       /** @var IConfig */
+       private $config;
+
+       public function __construct(IConfig $config) {
+               $this->config = $config;
+       }
+
+       /**
+        * @return Template all parameters are supposed to be assigned
+        */
+       public function render() {
+               $excludeGroupsList = !is_null(json_decode($this->config->getAppValue('core', 'shareapi_exclude_groups_list', '')))
+                       ? implode('|', $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '')) : '';
+
+               $parameters = [
+                       // Built-In Sharing
+                       '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,
+               ];
+
+               $form = new Template('settings', 'admin/sharing');
+               foreach ($parameters as $key => $value) {
+                       $form->assign($key, $value);
+               }
+               return $form;
+       }
+
+       /**
+        * @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;
+       }
+}
diff --git a/lib/private/Settings/Admin/TipsTricks.php b/lib/private/Settings/Admin/TipsTricks.php
new file mode 100644 (file)
index 0000000..a0465f5
--- /dev/null
@@ -0,0 +1,72 @@
+<?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\IConfig;
+use OCP\Settings\IAdmin;
+use OCP\Template;
+
+class TipsTricks implements IAdmin {
+       /** @var IConfig */
+       private $config;
+
+       public function __construct(IConfig $config) {
+               $this->config = $config;
+       }
+
+       /**
+        * @return Template all parameters are supposed to be assigned
+        */
+       public function render() {
+               $databaseOverload = (strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false);
+
+               $parameters = [
+                       'databaseOverload' => $databaseOverload,
+               ];
+
+               $form = new Template('settings', 'admin/tipstricks');
+               foreach ($parameters as $key => $value) {
+                       $form->assign($key, $value);
+               }
+               return $form;
+       }
+
+       /**
+        * @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;
+       }
+}
diff --git a/lib/private/Settings/Manager.php b/lib/private/Settings/Manager.php
new file mode 100644 (file)
index 0000000..b7d02dd
--- /dev/null
@@ -0,0 +1,297 @@
+<?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\Settings\IAdmin;
+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 */
+       /** @var ILogger */
+       private $log;
+
+       /** @var IDBConnection */
+       private $dbc;
+
+       /** @var IL10N */
+       private $l;
+
+       /** @var IConfig */
+       private $config;
+
+       /** @var EncryptionManager */
+       private $encryptionManager;
+
+       /** @var IUserManager */
+       private $userManager;
+
+       public function __construct(
+               ILogger $log,
+               IDBConnection $dbc,
+               IL10N $l,
+               IConfig $config,
+               EncryptionManager $encryptionManager,
+               IUserManager $userManager
+       ) {
+               $this->log = $log;
+               $this->dbc = $dbc;
+               $this->l = $l;
+               $this->config = $config;
+               $this->encryptionManager = $encryptionManager;
+               $this->userManager = $userManager;
+       }
+
+       /**
+        * @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]);
+               }
+       }
+
+       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($section)) {
+                       $this->addAdminSection($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(IAdmin $settings) {
+               $this->add(self::TABLE_ADMIN_SETTINGS, [
+                       'class' => get_class($settings),
+                       'section' => $settings->getSection(),
+                       'priority' => $settings->getPriority(),
+               ]);
+       }
+
+       private function add($table, $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 hasAdminSection(ISection $section) {
+               return $this->has(self::TABLE_ADMIN_SECTIONS, 'id', $section->getID());
+       }
+
+       private function hasAdminSettings($pageClass) {
+               return $this->has(self::TABLE_ADMIN_SETTINGS, 'class', $pageClass);
+       }
+
+
+       private function has($table, $idCol, $id) {
+               $query = $this->dbc->getQueryBuilder();
+               $query->select($idCol)
+                       ->from($table)
+                       ->where($query->expr()->eq($idCol, $query->createNamedParameter($id)))
+                       ->setMaxResults(1);
+
+               $result = $query->execute();
+               $row = $result->fetch();
+               $result->closeCursor();
+
+               return (bool) $row;
+       }
+
+       private function setupAdminSettings($settingsClassName) {
+               if(!class_exists($settingsClassName)) {
+                       $this->log->debug('Could not find admin section class ' . $settingsClassName);
+                       return;
+               }
+
+               try {
+                       $settings = $this->query($settingsClassName);
+               } catch (QueryException $e) {
+                       // cancel
+                       return;
+               }
+
+               if(!$settings instanceof IAdmin) {
+                       $this->log->error(
+                               'Admin section instance must implement \OCP\ISection. Invalid class: {class}',
+                               ['class' => $settingsClassName]
+                       );
+                       return;
+               }
+               if(!$this->hasAdminSettings($settings)) {
+                       $this->addAdminSettings($settings);
+               }
+       }
+
+       private function query($className) {
+               try {
+                       return \OC::$server->query($className);
+               } catch (QueryException $e) {
+                       $this->log->logException($e);
+                       throw $e;
+               }
+       }
+
+       /**
+        * returns a list of the admin sections
+        *
+        * @return ISection[]
+        */
+       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)],
+                       //15 => [new Section('collaboration', $this->l->t('Collaboration'), 0)],
+                       //30 => [new Section('theming',       $this->l->t('Theming'), 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 IAdmin $form */
+                               $form = new Admin\Server($this->dbc, $this->config);
+                               $forms[$form->getPriority()] = [$form];
+                       }
+                       if($section === 'encryption') {
+                               /** @var IAdmin $form */
+                               $form = new Admin\Encryption($this->encryptionManager, $this->userManager);
+                               $forms[$form->getPriority()] = [$form];
+                       }
+                       if($section === 'sharing') {
+                               /** @var IAdmin $form */
+                               $form = new Admin\Sharing($this->config);
+                               $forms[$form->getPriority()] = [$form];
+                       }
+                       if($section === 'logging') {
+                               /** @var IAdmin $form */
+                               $form = new Admin\Logging($this->config);
+                               $forms[$form->getPriority()] = [$form];
+                       }
+                       if($section === 'tips-tricks') {
+                               /** @var IAdmin $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);
+       }
+
+       public function getAdminSettings($section) {
+               $settings = $this->getBuiltInAdminSettings($section);
+               $this->getAdminSettingsFromDB($section, $settings);
+               return $settings;
+       }
+
+
+}
diff --git a/lib/private/Settings/Section.php b/lib/private/Settings/Section.php
new file mode 100644 (file)
index 0000000..2ea614b
--- /dev/null
@@ -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;
+
+       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;
+       }
+}
index 5395d1daeee2a308e6b4d9651ce425e78a78238b..39f2f1a0efe07909df62613bf2f3082f976ca26e 100644 (file)
@@ -471,7 +471,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")
                                );
@@ -1199,6 +1199,9 @@ class OC_App {
                        include $appPath . '/appinfo/update.php';
                }
                self::setupBackgroundJobs($appData['background-jobs']);
+               if(isset($appData['settings']) && is_array($appData['settings'])) {
+                       \OC::$server->getSettingsManager()->setupSettings($appData['settings']);
+               }
 
                //set remote/public handlers
                if (array_key_exists('ocsid', $appData)) {
diff --git a/lib/public/Settings/IAdmin.php b/lib/public/Settings/IAdmin.php
new file mode 100644 (file)
index 0000000..ce52e3d
--- /dev/null
@@ -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/>.
+ *
+ */
+
+namespace OCP\Settings;
+
+use OCP\Template;
+
+interface IAdmin {
+
+       /**
+        * @return Template all parameters are supposed to be assigned
+        */
+       public function render();
+
+       /**
+        * @return string the section ID, e.g. 'sharing'
+        */
+       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
+        */
+       public function getPriority();
+}
diff --git a/lib/public/Settings/IManager.php b/lib/public/Settings/IManager.php
new file mode 100644 (file)
index 0000000..ba0d9da
--- /dev/null
@@ -0,0 +1,65 @@
+<?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;
+
+
+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);
+
+       /**
+        * returns a list of the admin sections
+        *
+        * @return array array of ISection[] where key is the priority
+        */
+       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
+        */
+       public function getAdminSettings($section);
+}
diff --git a/lib/public/Settings/ISection.php b/lib/public/Settings/ISection.php
new file mode 100644 (file)
index 0000000..7802c9b
--- /dev/null
@@ -0,0 +1,51 @@
+<?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;
+
+interface ISection {
+       /**
+        * returns the ID of the section. It is supposed to be a lower case string,
+        * e.g. 'ldap'
+        *
+        * @returns string
+        */
+       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
+        */
+       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
+        */
+       public function getPriority();
+}
diff --git a/reset.php b/reset.php
new file mode 100644 (file)
index 0000000..f1b772e
--- /dev/null
+++ b/reset.php
@@ -0,0 +1,5 @@
+<?php
+$RUNTIME_NOAPPS = TRUE;
+require_once 'lib/base.php';
+$be = new OC_User_Database();
+$be->setPassword('master', 'master');
index 657b3fe490a5bd45d3ab7f2c530bf05955abfeb2..17e0902a9458ee637f9487051ce84b8352a6e038 100644 (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,19 @@ 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('L10N'),
+                               $c->query('Config'),
+                               $c->query('EncryptionManager'),
+                               $c->query('UserManager'),
+                               $c->query('DatabaseConnection'),
+                               $c->query('SettingsManager')
+                       );
+               });
 
                /**
                 * Middleware
@@ -268,5 +282,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();
+               });
        }
 }
diff --git a/settings/Controller/AdminSettingsController.php b/settings/Controller/AdminSettingsController.php
new file mode 100644 (file)
index 0000000..68707ad
--- /dev/null
@@ -0,0 +1,114 @@
+<?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\Controller;
+
+use Doctrine\DBAL\Connection;
+use OCP\AppFramework\Controller;
+use OCP\AppFramework\Http\TemplateResponse;
+use OC\Encryption\Manager as EncryptionManager;
+use OCP\IConfig;
+use OCP\IDBConnection;
+use OCP\IL10N;
+use OCP\INavigationManager;
+use OCP\IRequest;
+use OCP\IUserManager;
+use OCP\Settings\IManager as ISettingsManager;
+
+/**
+ * @package OC\Settings\Controller
+ */
+class AdminSettingsController extends Controller {
+
+       /** @var INavigationManager */
+       private $navigationManager;
+
+       /** @var ISettingsManager */
+       private $settingsManager;
+
+       public function __construct(
+               $appName,
+               IRequest $request,
+               INavigationManager $navigationManager,
+               IL10N $l,
+               IConfig $config,
+               EncryptionManager $encryptionManager,
+               IUserManager $userManager,
+               IDBConnection $db,
+               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());
+               $templateParams = array_merge($templateParams, $this->getSettings($section));
+
+               return new TemplateResponse('settings', 'admin/frame', $templateParams);
+       }
+
+       public function form() {
+
+       }
+
+       private function getSettings($section) {
+               $settings = $this->settingsManager->getAdminSettings($section);
+               $html = '';
+               foreach ($settings as $prioritizedSettings) {
+                       foreach ($prioritizedSettings as $setting) {
+                               /** @var \OCP\Settings\IAdmin $setting */
+                               $form = $setting->render();
+                               $html .= $form->fetchPage();
+                       }
+               }
+               return ['content' => $html];
+       }
+
+       private function getNavigationParameters() {
+               $a = 'anchor';
+               $name = 'section-name';
+
+               $sections = $this->settingsManager->getAdminSections();
+               $templateParameters = [];
+               foreach($sections as $prioritizedSections) {
+                       foreach ($prioritizedSections as $section) {
+                               $templateParameters[] = [$a => $section->getID(), $name => $section->getName()];
+                       }
+               }
+
+               return [
+                       'forms' => $templateParameters
+               ];
+       }
+}
index 48c0783f17db3d6fd1d106e42a06e8dfe3df64e6..86b9b768747f4c66f7158af7db29ef07fdda185d 100644 (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')
                );
        }
 
diff --git a/settings/admin.php b/settings/admin.php
deleted file mode 100644 (file)
index 11d3a3f..0000000
+++ /dev/null
@@ -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());
-
index 94732b3192a6a56b9aceb022481cbc0543a76d27..f77da543e1006ca728382d1b36f264ee8adac8ab 100644 (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')
diff --git a/settings/templates/admin.php b/settings/templates/admin.php
deleted file mode 100644 (file)
index 1bd055a..0000000
+++ /dev/null
@@ -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>
diff --git a/settings/templates/admin/encryption.php b/settings/templates/admin/encryption.php
new file mode 100644 (file)
index 0000000..d4c3be8
--- /dev/null
@@ -0,0 +1,92 @@
+<?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 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>
diff --git a/settings/templates/admin/frame.php b/settings/templates/admin/frame.php
new file mode 100644 (file)
index 0000000..e0fee15
--- /dev/null
@@ -0,0 +1,47 @@
+<?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'];
+                               print_unescaped(sprintf("<li><a href='%s'>%s</a></li>", \OCP\Util::sanitizeHTML($anchor), \OCP\Util::sanitizeHTML($sectionName)));
+                       }
+               }?>
+       </ul>
+</div>
+
+<div id="app-content">
+       <?php print_unescaped($_['content']); ?>
+</div>
diff --git a/settings/templates/admin/logging.php b/settings/templates/admin/logging.php
new file mode 100644 (file)
index 0000000..2f60629
--- /dev/null
@@ -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>
diff --git a/settings/templates/admin/server.php b/settings/templates/admin/server.php
new file mode 100644 (file)
index 0000000..1bf068d
--- /dev/null
@@ -0,0 +1,325 @@
+<?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',
+       'smtp',
+];
+if ($_['sendmail_is_available']) {
+       $mail_smtpmode[] = 'sendmail';
+}
+if ($_['mail_smtpmode'] == 'qmail') {
+       $mail_smtpmode[] = 'qmail';
+}
+?>
+
+<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" 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 == $_['mail_smtpmode']):
+                                               $selected = 'selected="selected"';
+                                       endif; ?>
+                                       <option value='<?php p($smtpmode)?>' <?php p($selected) ?>><?php p($smtpmode) ?></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">
+       <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>
diff --git a/settings/templates/admin/sharing.php b/settings/templates/admin/sharing.php
new file mode 100644 (file)
index 0000000..c81f7e2
--- /dev/null
@@ -0,0 +1,109 @@
+<?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>
+
+       <?php print_unescaped($_['fileSharingSettings']); ?>
+</div>
diff --git a/settings/templates/admin/tipstricks.php b/settings/templates/admin/tipstricks.php
new file mode 100644 (file)
index 0000000..e924a96
--- /dev/null
@@ -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>