templates for server profiles

This commit is contained in:
Roland Gruber 2014-12-25 07:31:04 +00:00
parent 772b9c3127
commit a8159dc4e0
6 changed files with 48 additions and 3 deletions

View File

@ -1,3 +1,7 @@
March 2015
- templates for server profiles
16.12.2014 4.8
- Active Directory: support paged result as workaround for size limit exceeded
- FreeRadius: support dialupAccess and radiusProfileDn

View File

@ -1 +1 @@
4.8
4.9.TEST

View File

@ -183,6 +183,8 @@ $helpArray = array (
"Text" => _('Sets this account type to read-only.')),
"266" => array ("Headline" => _("Paged results"),
"Text" => _("This is a workaround for Active Directory. Enable it if you get messages about size limit exceeded.")),
"267" => array ("Headline" => _('Template'),
"Text" => _('Please select the template for the new server profile. You can either select an existing server profile or use one of the built-in templates.')),
// 300 - 399
// profile editor, file upload
"301" => array ("Headline" => _("RDN identifier"),

View File

@ -143,6 +143,28 @@ function getConfigProfiles() {
return $ret;
}
/**
* Returns an array of string with all available configuration templates (without .conf.sample)
*
* @return array template names
*/
function getConfigTemplates() {
$dir = dir(dirname(__FILE__) . "/../config");
$ret = array();
$pos = 0;
while ($entry = $dir->read()){
$ext = substr($entry, strlen($entry)-12, 12);
$name = substr($entry, 0, strlen($entry) - 12);
// check if extension is right, add to profile list
if ($ext == ".conf.sample") {
$ret[$pos] = $name;
$pos ++;
}
}
sort($ret);
return $ret;
}
/**
* Creates a new server profile.
*

View File

@ -1260,7 +1260,8 @@ class htmlSelect extends htmlElement {
}
/**
* Specifies if the elements are divided into optgroups.
* Specifies if the elements are divided into optgroups.
* In this case the provided options are an array where the key is the optgroup label and the value is an array containing the options for the optgroup.
*
* @param boolean $containsOptgroups activates optgroups
*/

View File

@ -57,7 +57,7 @@ if (isset($_POST['action'])) {
elseif ($_POST['action'] == "add") {
// check profile password
if ($_POST['addpassword'] && $_POST['addpassword2'] && ($_POST['addpassword'] == $_POST['addpassword2'])) {
$result = createConfigProfile($_POST['addprofile'], $_POST['addpassword'], 'lam.conf.sample');
$result = createConfigProfile($_POST['addprofile'], $_POST['addpassword'], $_POST['addTemplate']);
if ($result === true) {
$_SESSION['conf_isAuthenticated'] = $_POST['addprofile'];
$_SESSION['conf_config'] = new LAMConfig($_POST['addprofile']);
@ -235,6 +235,22 @@ $profileNewPwd2->setIsPassword(true);
$profileNewPwd2->setFieldSize(15);
$profileNewPwd2->setSameValueFieldID('addpassword');
$container->addElement($profileNewPwd2, true);
$existing = array();
foreach ($files as $file) {
$existing[$file] = $file . '.conf';
}
$builtIn = array();
foreach (getConfigTemplates() as $file) {
$builtIn[$file] = $file . '.conf.sample';
}
$templates = array(
_('Existing server profiles') => $existing,
_('Built-in templates') => $builtIn
);
$addTemplateSelect = new htmlTableExtendedSelect('addTemplate', $templates, array('lam.conf.sample'), _('Template'), '267');
$addTemplateSelect->setContainsOptgroups(true);
$addTemplateSelect->setHasDescriptiveElements(true);
$container->addElement($addTemplateSelect, true);
$newProfileButton = new htmlButton('btnAddProfile', _('Add'));
$newProfileButton->setOnClick("jQuery('#action').val('add');showConfirmationDialog('" . _("Add profile") . "', '" .
_('Ok') . "', '" . _('Cancel') . "', 'passwordDialogDiv', 'profileForm', null); document.getElementById('passwd').focus();");