summaryrefslogtreecommitdiffstats
path: root/settings/admin.php
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-10-30 13:44:40 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2014-10-30 13:44:40 +0100
commitd9db791c67cfb309b0e3ec49ea03fffeb0d71d02 (patch)
tree056a43709b7e8f8d5d68f1266b3004bb24ed7a7c /settings/admin.php
parentea55848fa11eee7469c9ccee7b2c544ab976d3a1 (diff)
downloadnextcloud-server-d9db791c67cfb309b0e3ec49ea03fffeb0d71d02.tar.gz
nextcloud-server-d9db791c67cfb309b0e3ec49ea03fffeb0d71d02.zip
introduce sidebar for admin page
Diffstat (limited to 'settings/admin.php')
-rw-r--r--settings/admin.php162
1 files changed, 95 insertions, 67 deletions
diff --git a/settings/admin.php b/settings/admin.php
index f77145e0340..292bf2b0ff5 100644
--- a/settings/admin.php
+++ b/settings/admin.php
@@ -6,89 +6,117 @@
*/
OC_Util::checkAdminUser();
+OC_App::setActiveNavigationEntry("admin");
-OCP\Util::addStyle('settings', 'settings');
-OCP\Util::addScript('settings', 'settings');
-OCP\Util::addScript( "settings", "admin" );
-OCP\Util::addScript( "settings", "log" );
-OCP\Util::addScript( 'core', 'multiselect' );
-OCP\Util::addScript('core', 'select2/select2');
-OCP\Util::addStyle('core', 'select2/select2');
-OCP\Util::addScript('core', 'setupchecks');
-OC_App::setActiveNavigationEntry( "admin" );
-
-$tmpl = new OC_Template( 'settings', 'admin', 'user');
-$forms=OC_App::getForms('admin');
-$htaccessworking=OC_Util::isHtaccessWorking();
-
-$entries=OC_Log_Owncloud::getEntries(3);
-$entriesremain = count(OC_Log_Owncloud::getEntries(4)) > 3;
+$template = new OC_Template('settings', 'admin', 'user');
+$htAccessWorking = OC_Util::isHtaccessWorking();
+
+$entries = OC_Log_Owncloud::getEntries(3);
+$entriesRemaining = count(OC_Log_Owncloud::getEntries(4)) > 3;
$config = \OC::$server->getConfig();
+$appConfig = \OC::$server->getAppConfig();
// Should we display sendmail as an option?
-$tmpl->assign('sendmail_is_available', (bool) findBinaryPath('sendmail'));
-
-$tmpl->assign('loglevel', OC_Config::getValue( "loglevel", 2 ));
-$tmpl->assign('mail_domain', OC_Config::getValue( "mail_domain", '' ));
-$tmpl->assign('mail_from_address', OC_Config::getValue( "mail_from_address", '' ));
-$tmpl->assign('mail_smtpmode', OC_Config::getValue( "mail_smtpmode", '' ));
-$tmpl->assign('mail_smtpsecure', OC_Config::getValue( "mail_smtpsecure", '' ));
-$tmpl->assign('mail_smtphost', OC_Config::getValue( "mail_smtphost", '' ));
-$tmpl->assign('mail_smtpport', OC_Config::getValue( "mail_smtpport", '' ));
-$tmpl->assign('mail_smtpauthtype', OC_Config::getValue( "mail_smtpauthtype", '' ));
-$tmpl->assign('mail_smtpauth', OC_Config::getValue( "mail_smtpauth", false ));
-$tmpl->assign('mail_smtpname', OC_Config::getValue( "mail_smtpname", '' ));
-$tmpl->assign('mail_smtppassword', OC_Config::getValue( "mail_smtppassword", '' ));
-$tmpl->assign('entries', $entries);
-$tmpl->assign('entriesremain', $entriesremain);
-$tmpl->assign('htaccessworking', $htaccessworking);
-$tmpl->assign('isLocaleWorking', OC_Util::isSetLocaleWorking());
-$tmpl->assign('isPhpCharSetUtf8', OC_Util::isPhpCharSetUtf8());
-$tmpl->assign('isAnnotationsWorking', OC_Util::isAnnotationsWorking());
-$tmpl->assign('has_fileinfo', OC_Util::fileInfoLoaded());
-$tmpl->assign('old_php', OC_Util::isPHPoutdated());
-$tmpl->assign('backgroundjobs_mode', OC_Appconfig::getValue('core', 'backgroundjobs_mode', 'ajax'));
-$tmpl->assign('cron_log', OC_Config::getValue('cron_log', true));
-$tmpl->assign('lastcron', OC_Appconfig::getValue('core', 'lastcron', false));
-$tmpl->assign('shareAPIEnabled', OC_Appconfig::getValue('core', 'shareapi_enabled', 'yes'));
-$tmpl->assign('shareDefaultExpireDateSet', OC_Appconfig::getValue('core', 'shareapi_default_expire_date', 'no'));
-$tmpl->assign('shareExpireAfterNDays', OC_Appconfig::getValue('core', 'shareapi_expire_after_n_days', '7'));
-$tmpl->assign('shareEnforceExpireDate', OC_Appconfig::getValue('core', 'shareapi_enforce_expire_date', 'no'));
-$excludeGroups = OC_Appconfig::getValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false;
-$tmpl->assign('shareExcludeGroups', $excludeGroups);
-$excludedGroupsList = OC_Appconfig::getValue('core', 'shareapi_exclude_groups_list', '');
+$template->assign('sendmail_is_available', (bool)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('htaccessworking', $htAccessWorking);
+$template->assign('isLocaleWorking', OC_Util::isSetLocaleWorking());
+$template->assign('isPhpCharSetUtf8', OC_Util::isPhpCharSetUtf8());
+$template->assign('isAnnotationsWorking', OC_Util::isAnnotationsWorking());
+$template->assign('has_fileinfo', OC_Util::fileInfoLoaded());
+$template->assign('old_php', OC_Util::isPHPoutdated());
+$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 = explode(',', $excludedGroupsList); // FIXME: this should be JSON!
-$tmpl->assign('shareExcludedGroupsList', implode('|', $excludedGroupsList));
+$template->assign('shareExcludedGroupsList', implode('|', $excludedGroupsList));
// Check if connected using HTTPS
-$tmpl->assign('isConnectedViaHTTPS', OC_Request::serverProtocol() === 'https');
-$tmpl->assign('enforceHTTPSEnabled', OC_Config::getValue( "forcessl", false));
+$template->assign('isConnectedViaHTTPS', OC_Request::serverProtocol() === 'https');
+$template->assign('enforceHTTPSEnabled', $config->getSystemValue("forcessl", false));
-// If the current webroot is non-empty but the webroot from the config is,
+// 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.
-$shouldSuggestOverwriteWebroot = $config->getAppValue('core', 'backgroundjobs_mode', 'ajax') === 'cron' &&
+$shouldSuggestOverwriteWebRoot = $config->getAppValue('core', 'backgroundjobs_mode', 'ajax') === 'cron' &&
\OC::$WEBROOT && \OC::$WEBROOT !== '/' &&
!$config->getSystemValue('overwritewebroot', '');
-$tmpl->assign('suggestedOverwriteWebroot', ($shouldSuggestOverwriteWebroot) ? \OC::$WEBROOT : '');
-
-$tmpl->assign('allowLinks', OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes'));
-$tmpl->assign('enforceLinkPassword', \OCP\Util::isPublicLinkPasswordRequired());
-$tmpl->assign('allowPublicUpload', OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes'));
-$tmpl->assign('allowResharing', OC_Appconfig::getValue('core', 'shareapi_allow_resharing', 'yes'));
-$tmpl->assign('allowMailNotification', OC_Appconfig::getValue('core', 'shareapi_allow_mail_notification', 'no'));
-$tmpl->assign('onlyShareWithGroupMembers', \OC\Share\Share::shareWithGroupMembersOnly());
-$tmpl->assign('forms', array());
-foreach($forms as $form) {
- $tmpl->append('forms', $form);
-}
+$suggestedOverwriteWebRoot = ($shouldSuggestOverwriteWebRoot) ? \OC::$WEBROOT : '';
+$template->assign('suggestedOverwriteWebroot', $suggestedOverwriteWebRoot);
+$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('allowMailNotification', $appConfig->getValue('core', 'shareapi_allow_mail_notification', 'no'));
+$template->assign('onlyShareWithGroupMembers', \OC\Share\Share::shareWithGroupMembersOnly());
$databaseOverload = (strpos(\OCP\Config::getSystemValue('dbtype'), 'sqlite') !== false);
-$tmpl->assign('databaseOverload', $databaseOverload);
+$template->assign('databaseOverload', $databaseOverload);
+
+
+// add hardcoded forms from the template
+$forms = OC_App::getForms('admin');
+$l = OC_L10N::get('settings');
+$formsAndMore = array();
+if (OC_Request::serverProtocol() !== 'https' || !$htAccessWorking || !OC_Util::isAnnotationsWorking() ||
+ $suggestedOverwriteWebRoot || !OC_Util::isSetLocaleWorking() || !OC_Util::isPhpCharSetUtf8() ||
+ OC_Util::isPHPoutdated() || !OC_Util::fileInfoLoaded() || $databaseOverload
+) {
+ $formsAndMore[] = array('anchor' => 'security-warning', 'section-name' => $l->t('Security & Setup Warnings'));
+}
+
+$formsMap = array_map(function ($form) {
+ if (preg_match('%(<h2[^>]*>.*?</h2>)%i', $form, $regs)) {
+ $sectionName = str_replace('<h2>', '', $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[] = array('anchor' => 'backgroundjobs', 'section-name' => $l->t('Cron'));
+$formsAndMore[] = array('anchor' => 'shareAPI', 'section-name' => $l->t('Sharing'));
+$formsAndMore[] = array('anchor' => 'security', 'section-name' => $l->t('Security'));
+$formsAndMore[] = array('anchor' => 'mail_general_settings', 'section-name' => $l->t('Email Server'));
+$formsAndMore[] = array('anchor' => 'log', 'section-name' => $l->t('Log'));
+
+$template->assign('forms', $formsAndMore);
-$tmpl->printPage();
+$template->printPage();
/**
- * Try to find a programm
+ * Try to find a program
*
* @param string $program
* @return null|string