summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2016-08-10 15:21:25 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2016-08-10 15:21:25 +0200
commit1eb8b951c2eb6388efdd628c878110d78ae4e77d (patch)
tree30f62ea3dd0acf69384cd57d34024c8e82bbea13 /apps/user_ldap
parent518545fc2fc93f31d1885f143a0386c5449679f4 (diff)
downloadnextcloud-server-1eb8b951c2eb6388efdd628c878110d78ae4e77d.tar.gz
nextcloud-server-1eb8b951c2eb6388efdd628c878110d78ae4e77d.zip
more admin page splitup improvements
* bump version to ensure tables are created * make updatenotification app use settings api * change IAdmin::render() to getForm() and change return type from Template to TemplateResponse * adjust User_LDAP accordingly, as well as built-in forms * add IDateTimeFormatter to AppFramework/DependencyInjection/DIContainer.php. This is important so that \OC::$server->query() is able to resolve the constructor parameters. We should ensure that all OCP/* stuff that is available from \OC::$server is available here. Kudos to @LukasReschke * make sure apps that have settings info in their info.xml are loaded before triggering adding the settings setup method
Diffstat (limited to 'apps/user_ldap')
-rw-r--r--apps/user_ldap/appinfo/info.xml4
-rw-r--r--apps/user_ldap/lib/Settings/Admin.php40
-rw-r--r--apps/user_ldap/templates/settings.php29
3 files changed, 29 insertions, 44 deletions
diff --git a/apps/user_ldap/appinfo/info.xml b/apps/user_ldap/appinfo/info.xml
index dac4f62879d..b16824925c0 100644
--- a/apps/user_ldap/appinfo/info.xml
+++ b/apps/user_ldap/appinfo/info.xml
@@ -29,7 +29,7 @@ A user logs into ownCloud with their LDAP or AD credentials, and is granted acce
</background-jobs>
<settings>
- <admin>\OCA\User_LDAP\Settings\Admin</admin>
- <admin-section>\OCA\User_LDAP\Settings\Section</admin-section>
+ <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
index 11e2627dedd..f155f1cec8d 100644
--- a/apps/user_ldap/lib/Settings/Admin.php
+++ b/apps/user_ldap/lib/Settings/Admin.php
@@ -23,9 +23,9 @@
namespace OCA\User_LDAP\Settings;
-
use OCA\User_LDAP\Configuration;
use OCA\User_LDAP\Helper;
+use OCP\AppFramework\Http\TemplateResponse;
use OCP\IL10N;
use OCP\Settings\IAdmin;
use OCP\Template;
@@ -40,53 +40,31 @@ class Admin implements IAdmin {
}
/**
- * @return Template all parameters are supposed to be assigned
+ * @return TemplateResponse
*/
- public function render() {
- $settings = new Template('user_ldap', 'settings');
-
+ public function getForm() {
$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);
+ $parameters['serverConfigurationPrefixes'] = $prefixes;
+ $parameters['serverConfigurationHosts'] = $hosts;
+ $parameters['settingControls'] = $sControls;
+ $parameters['wizardControls'] = $wControls;
// assign default values
$config = new Configuration('', false);
$defaults = $config->getDefaults();
foreach($defaults as $key => $default) {
- $settings->assign($key.'_default', $default);
+ $parameters[$key.'_default'] = $default;
}
- return $settings;
+ return new TemplateResponse('user_ldap', 'settings', $parameters);
}
/**
diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php
index a1511071af4..eb4c7b99127 100644
--- a/apps/user_ldap/templates/settings.php
+++ b/apps/user_ldap/templates/settings.php
@@ -49,6 +49,9 @@ script('user_ldap', [
style('user_ldap', 'settings');
+/** @var \OCP\IL10N $l */
+/** @var array $_ */
+
?>
<form id="ldap" class="section" action="#" method="post">
@@ -56,20 +59,24 @@ style('user_ldap', 'settings');
<div id="ldapSettings">
<ul>
- <?php foreach($_['toc'] as $id => $title) { ?>
- <li id="<?php p($id); ?>"><a href="<?php p($id); ?>"><?php p($title); ?></a></li>
- <?php } ?>
+ <li id="#ldapWizard1"><a href="#ldapWizard1"><?php p($l->t('Server'));?></a></li>
+ <li id="#ldapWizard2"><a href="#ldapWizard2"><?php p($l->t('Users'));?></a></li>
+ <li id="#ldapWizard3"><a href="#ldapWizard3"><?php p($l->t('Login Attributes'));?></a></li>
+ <li id="#ldapWizard4"><a href="#ldapWizard4"><?php p($l->t('Groups'));?></a></li>
<li class="ldapSettingsTabs"><a href="#ldapSettings-2"><?php p($l->t('Expert'));?></a></li>
<li class="ldapSettingsTabs"><a href="#ldapSettings-1"><?php p($l->t('Advanced'));?></a></li>
</ul>
- <?php if(OCP\App::isEnabled('user_webdavauth')) {
- print_unescaped('<p class="ldapwarning">'.$l->t('<b>Warning:</b> Apps user_ldap and user_webdavauth are incompatible. You may experience unexpected behavior. Please ask your system administrator to disable one of them.').'</p>');
- }
- if(!function_exists('ldap_connect')) {
- print_unescaped('<p class="ldapwarning">'.$l->t('<b>Warning:</b> The PHP LDAP module is not installed, the backend will not work. Please ask your system administrator to install it.').'</p>');
- }
- ?>
- <?php print_unescaped($_['tabs']); ?>
+ <?php if(OCP\App::isEnabled('user_webdavauth')) {
+ print_unescaped('<p class="ldapwarning">'.$l->t('<b>Warning:</b> Apps user_ldap and user_webdavauth are incompatible. You may experience unexpected behavior. Please ask your system administrator to disable one of them.').'</p>');
+ }
+ if(!function_exists('ldap_connect')) {
+ print_unescaped('<p class="ldapwarning">'.$l->t('<b>Warning:</b> The PHP LDAP module is not installed, the backend will not work. Please ask your system administrator to install it.').'</p>');
+ }
+ ?>
+ <?php require_once(__DIR__ . '/part.wizard-server.php'); ?>
+ <?php require_once(__DIR__ . '/part.wizard-userfilter.php'); ?>
+ <?php require_once(__DIR__ . '/part.wizard-loginfilter.php'); ?>
+ <?php require_once(__DIR__ . '/part.wizard-groupfilter.php'); ?>
<fieldset id="ldapSettings-1">
<div id="ldapAdvancedAccordion">
<h3><?php p($l->t('Connection Settings'));?></h3>