First stage of new Wizard, neither feature complete nor ready
parent
652caa1c88
commit
53db1fe5ac
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - user_ldap
|
||||
*
|
||||
* @author Arthur Schiwon
|
||||
* @copyright 2013 Arthur Schiwon blizzz@owncloud.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
// Check user and app status
|
||||
OCP\JSON::checkAdminUser();
|
||||
OCP\JSON::checkAppEnabled('user_ldap');
|
||||
OCP\JSON::callCheck();
|
||||
|
||||
$l=OC_L10N::get('user_ldap');
|
||||
|
||||
if(!isset($_POST['action'])) {
|
||||
\OCP\JSON::error(array('message' => $l->t('No action specified')));
|
||||
}
|
||||
$action = $_POST['action'];
|
||||
|
||||
|
||||
if(!isset($_POST['ldap_serverconfig_chooser'])) {
|
||||
\OCP\JSON::error(array('message' => $l->t('No configuration specified')));
|
||||
}
|
||||
$prefix = $_POST['ldap_serverconfig_chooser'];
|
||||
|
||||
$ldapWrapper = new OCA\user_ldap\lib\LDAP();
|
||||
$configuration = new \OCA\user_ldap\lib\Configuration($prefix);
|
||||
$wizard = new \OCA\user_ldap\lib\Wizard($configuration, $ldapWrapper);
|
||||
|
||||
switch($action) {
|
||||
case 'guessPortAndTLS':
|
||||
try {
|
||||
$result = $wizard->$action();
|
||||
if($result !== false) {
|
||||
OCP\JSON::success($result->getResultArray());
|
||||
exit;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\OCP\JSON::error(array('message' => $e->getMessage()));
|
||||
exit;
|
||||
}
|
||||
\OCP\JSON::error();
|
||||
exit;
|
||||
break;
|
||||
|
||||
case 'save':
|
||||
$key = isset($_POST['cfgkey']) ? $_POST['cfgkey'] : false;
|
||||
$val = isset($_POST['cfgval']) ? $_POST['cfgval'] : null;
|
||||
if($key === false || is_null($val)) {
|
||||
\OCP\JSON::error(array('message' => $l->t('No data specified')));
|
||||
exit;
|
||||
}
|
||||
$cfg = array($key => $val);
|
||||
$setParameters = array();
|
||||
$configuration->setConfiguration($cfg, $setParameters);
|
||||
if(!in_array($key, $setParameters)) {
|
||||
\OCP\JSON::error(array('message' => $l->t($key.' Could not set configuration '.$setParameters[0])));
|
||||
exit;
|
||||
}
|
||||
$configuration->saveConfiguration();
|
||||
OCP\JSON::success();
|
||||
break;
|
||||
default:
|
||||
//TODO: return 4xx error
|
||||
break;
|
||||
}
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
<div class="ldapSettingControls">
|
||||
<input id="ldap_submit" type="submit" value="Save" />
|
||||
<button id="ldap_action_test_connection" name="ldap_action_test_connection">
|
||||
<?php p($l->t('Test Configuration'));?>
|
||||
</button>
|
||||
<a href="<?php p($theme->getDocBaseUrl()); ?>/server/5.0/admin_manual/auth_ldap.html"
|
||||
target="_blank">
|
||||
<img src="<?php print_unescaped(OCP\Util::imagePath('', 'actions/info.png')); ?>"
|
||||
style="height:1.75ex" />
|
||||
<?php p($l->t('Help'));?>
|
||||
</a>
|
||||
</div>
|
||||
@ -0,0 +1,76 @@
|
||||
<fieldset id="ldapWizard1">
|
||||
<p>
|
||||
<select id="ldap_serverconfig_chooser" name="ldap_serverconfig_chooser">
|
||||
<?php if(count($_['serverConfigurationPrefixes']) === 0 ) {
|
||||
?>
|
||||
<option value="" selected>1. Server</option>');
|
||||
<?php
|
||||
} else {
|
||||
$i = 1;
|
||||
$sel = ' selected';
|
||||
foreach($_['serverConfigurationPrefixes'] as $prefix) {
|
||||
?>
|
||||
<option value="<?php p($prefix); ?>"<?php p($sel); $sel = ''; ?>><?php p($i++); ?>. Server: <?php p($_['serverConfigurationHosts'][$prefix]); ?></option>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
<option value="NEW"><?php p($l->t('Add Server Configuration'));?></option>
|
||||
</select>
|
||||
<button id="ldap_action_delete_configuration"
|
||||
name="ldap_action_delete_configuration">Delete Configuration</button>
|
||||
</p>
|
||||
|
||||
<div class="hostPortCombinator">
|
||||
<div class="tablerow">
|
||||
<div class="tablecell">
|
||||
<div class="table">
|
||||
<input type="text" class="host tablecell lwautosave" id="ldap_host"
|
||||
name="ldap_host"
|
||||
data-default="<?php p($_['ldap_host_default']); ?>"
|
||||
placeholder="<?php p($l->t('Host'));?>"
|
||||
title="<?php p($l->t('You can omit the protocol, except you require SSL. Then start with ldaps://'));?>"
|
||||
/>
|
||||
<span>
|
||||
<input type="number" id="ldap_port" name="ldap_port"
|
||||
class="hidden lwautosave"
|
||||
data-default="<?php p($_['ldap_port_default']); ?>"
|
||||
placeholder="<?php p($l->t('Port'));?>" />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tablerow">
|
||||
<input type="text" id="ldap_dn" name="ldap_dn"
|
||||
class="tablecell lwautosave"
|
||||
data-default="<?php p($_['ldap_dn_default']); ?>"
|
||||
placeholder="<?php p($l->t('User DN'));?>"
|
||||
title="<?php p($l->t('The DN of the client user with which the bind shall be done, e.g. uid=agent,dc=example,dc=com. For anonymous access, leave DN and Password empty.'));?>"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="tablerow">
|
||||
<input type="password" id="ldap_agent_password"
|
||||
class="tablecell lwautosave" name="ldap_agent_password"
|
||||
data-default="<?php p($_['ldap_agent_password_default']); ?>"
|
||||
placeholder="<?php p($l->t('Password'));?>"
|
||||
title="<?php p($l->t('For anonymous access, leave DN and Password empty.'));?>"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="tablerow">
|
||||
<textarea id="ldap_base" name="ldap_base"
|
||||
class="tablecell hidden lwautosave"
|
||||
placeholder="<?php p($l->t('One Base DN per line'));?>"
|
||||
title="<?php p($l->t('You can specify Base DN for users and groups in the Advanced tab'));?>"
|
||||
data-default="<?php p($_['ldap_base_default']); ?>" >
|
||||
</textarea>
|
||||
</div>
|
||||
|
||||
<div class="tablerow">
|
||||
<div class="tablecell ldapWizardInfo hidden">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php print_unescaped($_['wizardControls']); ?>
|
||||
</fieldset>
|
||||
@ -0,0 +1,14 @@
|
||||
<div class="ldapWizardControls">
|
||||
<button id="ldap_action_back" name="ldap_action_back" class="hidden">
|
||||
<?php p($l->t('Back'));?>
|
||||
</button>
|
||||
<button id="ldap_action_continue" name="ldap_action_continue">
|
||||
<?php p($l->t('Continue'));?>
|
||||
</button>
|
||||
<a href="<?php p($theme->getDocBaseUrl()); ?>/server/5.0/admin_manual/auth_ldap.html"
|
||||
target="_blank">
|
||||
<img src="<?php print_unescaped(OCP\Util::imagePath('', 'actions/info.png')); ?>"
|
||||
style="height:1.75ex" />
|
||||
<?php p($l->t('Help'));?>
|
||||
</a>
|
||||
</div>
|
||||
Loading…
Reference in New Issue