responsive main configuration

This commit is contained in:
Roland Gruber 2017-11-03 18:53:10 +01:00
parent 8d601c57ff
commit d143e59889
3 changed files with 208 additions and 122 deletions

View File

@ -363,7 +363,7 @@ class htmlTableRow extends htmlElement {
* @param array $cells list of htmlElements * @param array $cells list of htmlElements
* @see htmlElement * @see htmlElement
*/ */
function __construct($cells) { public function __construct($cells) {
$this->cells = $cells; $this->cells = $cells;
} }
@ -378,7 +378,7 @@ class htmlTableRow extends htmlElement {
* @param string $scope Account type * @param string $scope Account type
* @return array List of input field names and their type (name => type) * @return array List of input field names and their type (name => type)
*/ */
function generateHTML($module, $input, $values, $restricted, &$tabindex, $scope) { public function generateHTML($module, $input, $values, $restricted, &$tabindex, $scope) {
$types = array(); $types = array();
$classAttr = ''; $classAttr = '';
if (sizeof($this->cssClasses) > 0) { if (sizeof($this->cssClasses) > 0) {
@ -1449,18 +1449,19 @@ class htmlSelect extends htmlElement {
if (!empty($this->tableRowsToShow)) { if (!empty($this->tableRowsToShow)) {
$values = array_merge($values, array_keys($this->tableRowsToShow)); $values = array_merge($values, array_keys($this->tableRowsToShow));
} }
$selector = $this->getShowHideSelector();
// build Java script to show/hide depending fields // build Java script to show/hide depending fields
foreach ($values as $val) { foreach ($values as $val) {
// build onChange listener // build onChange listener
$onChange .= 'if (jQuery(\'#' . $this->name . '\').val() == \'' . $val . '\') {'; $onChange .= 'if (jQuery(\'#' . $this->name . '\').val() == \'' . $val . '\') {';
if (isset($this->tableRowsToShow[$val])) { if (isset($this->tableRowsToShow[$val])) {
for ($i = 0; $i < sizeof($this->tableRowsToShow[$val]); $i++) { for ($i = 0; $i < sizeof($this->tableRowsToShow[$val]); $i++) {
$onChange .= 'jQuery(\'#' . $this->tableRowsToShow[$val][$i] . '\').closest(\'tr\').removeClass(\'hidden\');'; $onChange .= 'jQuery(\'#' . $this->tableRowsToShow[$val][$i] . '\').closest(\'' . $selector . '\').removeClass(\'hidden\');';
} }
} }
if (isset($this->tableRowsToHide[$val])) { if (isset($this->tableRowsToHide[$val])) {
for ($i = 0; $i < sizeof($this->tableRowsToHide[$val]); $i++) { for ($i = 0; $i < sizeof($this->tableRowsToHide[$val]); $i++) {
$onChange .= 'jQuery(\'#' . $this->tableRowsToHide[$val][$i] . '\').closest(\'tr\').addClass(\'hidden\');'; $onChange .= 'jQuery(\'#' . $this->tableRowsToHide[$val][$i] . '\').closest(\'' . $selector . '\').addClass(\'hidden\');';
} }
} }
$onChange .= '};'; $onChange .= '};';
@ -1470,19 +1471,28 @@ class htmlSelect extends htmlElement {
if (isset($this->tableRowsToShow[$this->selectedElements[0]])) { if (isset($this->tableRowsToShow[$this->selectedElements[0]])) {
for ($i = 0; $i < sizeof($this->tableRowsToShow[$this->selectedElements[0]]); $i++) { for ($i = 0; $i < sizeof($this->tableRowsToShow[$this->selectedElements[0]]); $i++) {
$classType = 'removeClass'; $classType = 'removeClass';
$script .= 'jQuery(\'#' . $this->tableRowsToShow[$this->selectedElements[0]][$i] . '\').closest(\'tr\').' . $classType . '(\'hidden\');' . "\n"; $script .= 'jQuery(\'#' . $this->tableRowsToShow[$this->selectedElements[0]][$i] . '\').closest(\'' . $selector . '\').' . $classType . '(\'hidden\');' . "\n";
} }
} }
if (isset($this->tableRowsToHide[$this->selectedElements[0]])) { if (isset($this->tableRowsToHide[$this->selectedElements[0]])) {
for ($i = 0; $i < sizeof($this->tableRowsToHide[$this->selectedElements[0]]); $i++) { for ($i = 0; $i < sizeof($this->tableRowsToHide[$this->selectedElements[0]]); $i++) {
$classType = 'addClass'; $classType = 'addClass';
$script .= 'jQuery(\'#' . $this->tableRowsToHide[$this->selectedElements[0]][$i] . '\').closest(\'tr\').' . $classType . '(\'hidden\');' . "\n"; $script .= 'jQuery(\'#' . $this->tableRowsToHide[$this->selectedElements[0]][$i] . '\').closest(\'' . $selector . '\').' . $classType . '(\'hidden\');' . "\n";
} }
} }
$script .= '});</script>'; $script .= '});</script>';
echo $script; echo $script;
} }
/**
* Returns the selector to use to find the show/hide elements.
*
* @return string selector
*/
protected function getShowHideSelector() {
return 'tr';
}
} }
/** /**
@ -3044,10 +3054,12 @@ class htmlDiv extends htmlElement {
* @param String $id unique ID * @param String $id unique ID
* @param htmlElement $content inner content * @param htmlElement $content inner content
* @param array $classes CSS classes * @param array $classes CSS classes
* @param string[] $cssClasses CSS classes
*/ */
function __construct($id, $content) { function __construct($id, $content, $cssClasses = null) {
$this->id = htmlspecialchars($id); $this->id = htmlspecialchars($id);
$this->content = $content; $this->content = $content;
$this->cssClasses = $cssClasses;
} }
/** /**
@ -3562,6 +3574,15 @@ class htmlResponsiveRow extends htmlElement {
return $return; return $return;
} }
/**
* Adds a vertical spacer with 12 columns.
*
* @param string $space space in px or rem
*/
public function addVerticalSpacer($space) {
$this->add(new htmlSpacer(null, $space), 12);
}
} }
/** /**
@ -3664,14 +3685,21 @@ class htmlResponsiveInputField extends htmlInputField {
if (is_dir("../graphics")) $graphicsPath = "../graphics"; if (is_dir("../graphics")) $graphicsPath = "../graphics";
$labelGroup->addElement(new htmlImage($graphicsPath . '/required.png', 16, 16, _('required'), _('required'))); $labelGroup->addElement(new htmlImage($graphicsPath . '/required.png', 16, 16, _('required'), _('required')));
} }
if (!empty($this->helpID)) {
$helpLinkLabel = new htmlHelpLink($this->helpID);
$helpLinkLabel->setCSSClasses(array('hide-on-tablet', 'margin-left5'));
$labelGroup->addElement($helpLinkLabel);
}
$row->add($labelGroup, 12, 6, 6, 'responsiveLabel'); $row->add($labelGroup, 12, 6, 6, 'responsiveLabel');
// input field // input field
$fieldGroup = new htmlGroup(); $fieldGroup = new htmlGroup();
$fieldGroup->addElement($this); $fieldGroup->addElement($this);
if (!empty($this->helpID)) { if (!empty($this->helpID)) {
$fieldGroup->addElement(new htmlHelpLink($this->helpID)); $helpLinkField = new htmlHelpLink($this->helpID);
$helpLinkField->setCSSClasses(array('hide-on-mobile'));
$fieldGroup->addElement($helpLinkField);
} }
$row->add($fieldGroup, 12, 6, 6, 'responsiveField'); $row->add($fieldGroup, 12, 6, 6, 'responsiveField nowrap');
return $row->generateHTML($module, $input, $values, $restricted, $tabindex, $scope); return $row->generateHTML($module, $input, $values, $restricted, $tabindex, $scope);
} }
@ -3820,6 +3848,78 @@ class htmlResponsiveSelect extends htmlSelect {
return $row->generateHTML($module, $input, $values, $restricted, $tabindex, $scope); return $row->generateHTML($module, $input, $values, $restricted, $tabindex, $scope);
} }
/**
* {@inheritDoc}
* @see htmlSelect::getShowHideSelector()
*/
protected function getShowHideSelector() {
return '.row';
}
}
/**
* Responsive select with label and help link.
*
* @package metaHTML
*/
class htmlResponsiveRadio extends htmlRadio {
/** descriptive label */
private $label;
/** help ID */
private $helpID;
/** render HTML of parent class */
private $renderParentHtml = false;
/**
* Constructor.
*
* @param String $name element name
* @param array $elements list of elememts
* @param array $selectedElements list of selected elements
* @param String $label descriptive label
* @param String $helpID help ID (optional, default none)
* @param int $size size (optional, default = 1)
*/
function __construct($label, $name, $elements, $selectedElement = null, $helpID = null) {
parent::__construct($name, $elements, $selectedElement);
$this->label = htmlspecialchars($label);
$this->helpID = $helpID;
}
/**
* {@inheritDoc}
* @see htmlInputField::generateHTML()
*/
function generateHTML($module, $input, $values, $restricted, &$tabindex, $scope) {
if ($this->renderParentHtml) {
return parent::generateHTML($module, $input, $values, $restricted, $tabindex, $scope);
}
// HTML of parent class is rendered on second call (done by htmlResponsiveRow)
$this->renderParentHtml = true;
$row = new htmlResponsiveRow();
// label text
$labelGroup = new htmlGroup();
$labelGroup->addElement(new htmlOutputText($this->label));
if (!empty($this->helpID)) {
$helpLinkLabel = new htmlHelpLink($this->helpID);
$helpLinkLabel->setCSSClasses(array('hide-on-tablet', 'margin-left5'));
$labelGroup->addElement($helpLinkLabel);
}
$row->add($labelGroup, 12, 6, 6, 'responsiveLabel');
// input field
$fieldGroup = new htmlGroup();
$fieldGroup->addElement(new htmlDiv(null, $this, array('float-left')));
if (!empty($this->helpID)) {
$helpLink = new htmlHelpLink($this->helpID);
$helpLink->setCSSClasses(array('hide-on-mobile'));
$fieldGroup->addElement(new htmlDiv(null, $helpLink));
}
$row->add($fieldGroup, 12, 6, 6, 'responsiveField nowrap');
return $row->generateHTML($module, $input, $values, $restricted, $tabindex, $scope);
}
} }
/** /**

View File

@ -159,6 +159,10 @@ input {
border-collapse: separate; border-collapse: separate;
} }
.float-left {
float: left;
}
.hoverHighlight { .hoverHighlight {
border: 1px solid transparent; border: 1px solid transparent;
} }

View File

@ -5,25 +5,23 @@ use \htmlTable;
use \htmlTitle; use \htmlTitle;
use \htmlStatusMessage; use \htmlStatusMessage;
use \htmlSubTitle; use \htmlSubTitle;
use \htmlTableExtendedInputTextarea;
use \htmlSpacer; use \htmlSpacer;
use \htmlTableExtendedSelect;
use \htmlOutputText; use \htmlOutputText;
use \htmlTableExtendedInputCheckbox;
use \htmlLink; use \htmlLink;
use \htmlGroup; use \htmlGroup;
use \htmlButton; use \htmlButton;
use \htmlHelpLink; use \htmlHelpLink;
use \htmlInputField; use \htmlInputField;
use \htmlInputFileUpload; use \htmlInputFileUpload;
use \htmlEqualWidth;
use \htmlTableExtendedRadio;
use \htmlHiddenInput;
use \htmlTableExtendedInputField;
use \DateTime; use \DateTime;
use \DateTimeZone; use \DateTimeZone;
use \htmlResponsiveRow;
use \htmlResponsiveInputTextarea;
use \htmlResponsiveSelect;
use \htmlResponsiveInputCheckbox;
use \htmlResponsiveInputField;
use \htmlDiv;
/* /*
$Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2017 Roland Gruber Copyright (C) 2003 - 2017 Roland Gruber
@ -89,7 +87,7 @@ if (isset($_POST['cancel'])) {
$errors = array(); $errors = array();
$messages = array(); $messages = array();
// check if submit button was pressed // check if submit button was pressed
if (isset($_POST['submitFormData'])) { if (isset($_POST['submit'])) {
// set master password // set master password
if (isset($_POST['masterpassword']) && ($_POST['masterpassword'] != "")) { if (isset($_POST['masterpassword']) && ($_POST['masterpassword'] != "")) {
if ($_POST['masterpassword'] && $_POST['masterpassword2'] && ($_POST['masterpassword'] == $_POST['masterpassword2'])) { if ($_POST['masterpassword'] && $_POST['masterpassword2'] && ($_POST['masterpassword'] == $_POST['masterpassword2'])) {
@ -203,7 +201,7 @@ if (isset($_POST['submitFormData'])) {
} }
if (isset($_POST['sslCaCertImport'])) { if (isset($_POST['sslCaCertImport'])) {
$matches = array(); $matches = array();
if (preg_match('/^([a-zA-Z0-9_\\.-]+)(:([0-9]+))?$/', $_POST['serverurl'], $matches)) { if (preg_match('/^ldaps:\\/\\/([a-zA-Z0-9_\\.-]+)(:([0-9]+))?$/', $_POST['serverurl'], $matches)) {
$port = '636'; $port = '636';
if (isset($matches[3]) && !empty($matches[3])) { if (isset($matches[3]) && !empty($matches[3])) {
$port = $matches[3]; $port = $matches[3];
@ -247,11 +245,15 @@ echo $_SESSION['header'];
?> ?>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> <title>
<?php <?php
echo _("Edit general settings"); echo _("Edit general settings");
?> ?>
</title> </title>
<link rel="stylesheet" type="text/css" href="../../style/responsive/105_normalize.css">
<link rel="stylesheet" type="text/css" href="../../style/responsive/110_foundation.css">
<link rel="stylesheet" type="text/css" href="../../style/responsive/120_lam.css">
<?php <?php
// include all CSS files // include all CSS files
$cssDirName = dirname(__FILE__) . '/../../style'; $cssDirName = dirname(__FILE__) . '/../../style';
@ -272,7 +274,7 @@ echo $_SESSION['header'];
<link rel="shortcut icon" type="image/x-icon" href="../../graphics/favicon.ico"> <link rel="shortcut icon" type="image/x-icon" href="../../graphics/favicon.ico">
<link rel="icon" href="../../graphics/logo136.png"> <link rel="icon" href="../../graphics/logo136.png">
</head> </head>
<body> <body class="admin">
<table border=0 width="100%" class="lamHeader ui-corner-all"> <table border=0 width="100%" class="lamHeader ui-corner-all">
<tr> <tr>
<td align="left" height="30"> <td align="left" height="30">
@ -298,48 +300,47 @@ foreach ($jsFiles as $jsEntry) {
echo "<script type=\"text/javascript\" src=\"../lib/" . $jsEntry . "\"></script>\n"; echo "<script type=\"text/javascript\" src=\"../lib/" . $jsEntry . "\"></script>\n";
} }
$container = new htmlTable('100%'); $tabindex = 1;
$container->setCSSClasses(array('ui-corner-all', 'roundedShadowBox'));
$container->addElement(new htmlTitle(_('General settings')), true); $row = new htmlResponsiveRow();
$row->add(new htmlTitle(_('General settings')), 12);
// print messages // print messages
for ($i = 0; $i < sizeof($errors); $i++) { for ($i = 0; $i < sizeof($errors); $i++) {
$container->addElement(new htmlStatusMessage("ERROR", $errors[$i]), true); $row->add(new htmlStatusMessage("ERROR", $errors[$i]), 12);
} }
for ($i = 0; $i < sizeof($messages); $i++) { for ($i = 0; $i < sizeof($messages); $i++) {
$container->addElement(new htmlStatusMessage("INFO", $messages[$i]), true); $row->add(new htmlStatusMessage("INFO", $messages[$i]), 12);
} }
// check if config file is writable // check if config file is writable
if (!$cfg->isWritable()) { if (!$cfg->isWritable()) {
$container->addElement(new htmlStatusMessage('WARN', 'The config file is not writable.', 'Your changes cannot be saved until you make the file writable for the webserver user.'), true); $row->add(new htmlStatusMessage('WARN', 'The config file is not writable.', 'Your changes cannot be saved until you make the file writable for the webserver user.'), 12);
} }
// license // license
if (isLAMProVersion()) { if (isLAMProVersion()) {
$container->addElement(new htmlSubTitle(_('Licence')), true); $row->add(new htmlSubTitle(_('Licence')), 12);
$licenseTable = new htmlTable(); $row->add(new htmlResponsiveInputTextarea('license', implode("\n", $cfg->getLicenseLines()), null, 10, _('Licence'), '287'), 12);
$licenseTable->addElement(new htmlTableExtendedInputTextarea('license', implode("\n", $cfg->getLicenseLines()), 50, 10, _('Licence'), '287'));
$container->addElement($licenseTable, true);
$container->addElement(new htmlSpacer(null, '10px'), true); $row->add(new htmlSpacer(null, '1rem'), true);
} }
// security settings // security settings
$container->addElement(new htmlSubTitle(_("Security settings")), true); $row->add(new htmlSubTitle(_("Security settings")), 12);
$securityTable = new htmlTable();
$options = array(5, 10, 20, 30, 60, 90, 120, 240); $options = array(5, 10, 20, 30, 60, 90, 120, 240);
$securityTable->addElement(new htmlTableExtendedSelect('sessionTimeout', $options, array($cfg->sessionTimeout), _("Session timeout"), '238'), true); $row->add(new htmlResponsiveSelect('sessionTimeout', $options, array($cfg->sessionTimeout), _("Session timeout"), '238'), 12);
$securityTable->addElement(new htmlTableExtendedInputTextarea('allowedHosts', implode("\n", explode(",", $cfg->allowedHosts)), '30', '7', _("Allowed hosts"), '241'), true); $row->add(new htmlResponsiveInputTextarea('allowedHosts', implode("\n", explode(",", $cfg->allowedHosts)), null, '7', _("Allowed hosts"), '241'), 12);
if (isLAMProVersion()) { if (isLAMProVersion()) {
$securityTable->addElement(new htmlTableExtendedInputTextarea('allowedHostsSelfService', implode("\n", explode(",", $cfg->allowedHostsSelfService)), '30', '7', _("Allowed hosts (self service)"), '241'), true); $row->add(new htmlResponsiveInputTextarea('allowedHostsSelfService', implode("\n", explode(",", $cfg->allowedHostsSelfService)), null, '7', _("Allowed hosts (self service)"), '241'), 12);
} }
$encryptSession = ($cfg->encryptSession === 'true'); $encryptSession = ($cfg->encryptSession === 'true');
$encryptSessionBox = new htmlTableExtendedInputCheckbox('encryptSession', $encryptSession, _('Encrypt session'), '245'); $encryptSessionBox = new htmlResponsiveInputCheckbox('encryptSession', $encryptSession, _('Encrypt session'), '245');
$encryptSessionBox->setIsEnabled(function_exists('openssl_random_pseudo_bytes')); $encryptSessionBox->setIsEnabled(function_exists('openssl_random_pseudo_bytes'));
$securityTable->addElement($encryptSessionBox, true); $row->add($encryptSessionBox, 12);
// SSL certificate // SSL certificate
$securityTable->addElement(new htmlOutputText(_('SSL certificates'))); $row->addVerticalSpacer('1rem');
$row->addLabel(new htmlOutputText(_('SSL certificates')));
$sslMethod = _('use system certificates'); $sslMethod = _('use system certificates');
$sslFileName = $cfg->getSSLCaCertTempFileName(); $sslFileName = $cfg->getSSLCaCertTempFileName();
if ($sslFileName != null) { if ($sslFileName != null) {
@ -358,91 +359,70 @@ if ($sslFileName != null) {
$sslDeleteBtn->setTitle(_('Delete all CA certificates')); $sslDeleteBtn->setTitle(_('Delete all CA certificates'));
$sslDelSaveGroup->addElement($sslDeleteBtn); $sslDelSaveGroup->addElement($sslDeleteBtn);
} }
$securityTable->addElement($sslDelSaveGroup); $sslDelSaveGroup->addElement(new htmlHelpLink('204'));
$securityTable->addElement(new htmlHelpLink('204')); $row->addField($sslDelSaveGroup);
$securityTable->addElement(new htmlSpacer('250px', null), true); $row->addLabel(new htmlInputFileUpload('sslCaCert'));
$securityTable->addElement(new htmlOutputText(''));
$sslButtonTable = new htmlTable();
$sslButtonTable->colspan = 3;
$sslButtonTable->addElement(new htmlInputFileUpload('sslCaCert'));
$sslUploadBtn = new htmlButton('sslCaCertUpload', _('Upload')); $sslUploadBtn = new htmlButton('sslCaCertUpload', _('Upload'));
$sslUploadBtn->setIconClass('upButton'); $sslUploadBtn->setIconClass('upButton');
$sslUploadBtn->setTitle(_('Upload CA certificate in DER/PEM format.')); $sslUploadBtn->setTitle(_('Upload CA certificate in DER/PEM format.'));
$sslButtonTable->addElement($sslUploadBtn, true); $row->addField($sslUploadBtn);
if (function_exists('stream_socket_client') && function_exists('stream_context_get_params')) { if (function_exists('stream_socket_client') && function_exists('stream_context_get_params')) {
$sslImportGroup = new htmlGroup(); $sslImportServerUrl = !empty($_POST['serverurl']) ? $_POST['serverurl'] : 'ldaps://';
$sslImportGroup->addElement(new htmlOutputText('ldaps://')); $serverUrlUpload = new htmlInputField('serverurl', $sslImportServerUrl);
$sslImportServerUrl = !empty($_POST['serverurl']) ? $_POST['serverurl'] : ''; $row->addLabel($serverUrlUpload);
$sslImportGroup->addElement(new htmlInputField('serverurl'));
$sslButtonTable->addElement($sslImportGroup);
$sslImportBtn = new htmlButton('sslCaCertImport', _('Import from server')); $sslImportBtn = new htmlButton('sslCaCertImport', _('Import from server'));
$sslImportBtn->setIconClass('downButton'); $sslImportBtn->setIconClass('downButton');
$sslImportBtn->setTitle(_('Imports the certificate directly from your LDAP server.')); $sslImportBtn->setTitle(_('Imports the certificate directly from your LDAP server.'));
$sslImportBtn->setCSSClasses(array('nowrap')); $row->addField($sslImportBtn);
$sslButtonTable->addElement($sslImportBtn);
$sslButtonTable->addElement(new htmlEqualWidth(array('btn_sslCaCertUpload', 'btn_sslCaCertImport')));
} }
$securityTable->addElement($sslButtonTable, true);
$sslCerts = $cfg->getSSLCaCertificates(); $sslCerts = $cfg->getSSLCaCertificates();
if (sizeof($sslCerts) > 0) { if (sizeof($sslCerts) > 0) {
$certTable = new htmlTable(); $certsTitles = array(_('Common name'), _('Valid to'), _('Serial number'), _('Delete'));
$certTable->colspan = 3; $certsData = array();
$certSpace = new htmlSpacer('5px', null);
$certTable->addElement(new htmlOutputText(''));
$certTable->addElement(new htmlOutputText(_('Serial number')));
$certTable->addElement($certSpace);
$certTable->addElement(new htmlOutputText(_('Valid to')));
$certTable->addElement($certSpace);
$certTable->addElement(new htmlOutputText(_('Common name')), true);
for ($i = 0; $i < sizeof($sslCerts); $i++) { for ($i = 0; $i < sizeof($sslCerts); $i++) {
$serial = isset($sslCerts[$i]['serialNumber']) ? $sslCerts[$i]['serialNumber'] : ''; $serial = isset($sslCerts[$i]['serialNumber']) ? $sslCerts[$i]['serialNumber'] : '';
$validTo = isset($sslCerts[$i]['validTo_time_t']) ? $sslCerts[$i]['validTo_time_t'] : ''; $validTo = isset($sslCerts[$i]['validTo_time_t']) ? $sslCerts[$i]['validTo_time_t'] : '';
$cn = isset($sslCerts[$i]['subject']['CN']) ? $sslCerts[$i]['subject']['CN'] : ''; $cn = isset($sslCerts[$i]['subject']['CN']) ? $sslCerts[$i]['subject']['CN'] : '';
$certTable->addElement(new htmlButton('deleteCert_' . $i, 'delete.png', true)); $delBtn = new htmlButton('deleteCert_' . $i, 'delete.png', true);
$certTable->addElement(new htmlOutputText($serial)); $certsData[] = array(
$certTable->addElement($certSpace); new htmlOutputText($cn),
$certTable->addElement(new htmlOutputText(formatSSLTimestamp($validTo))); new htmlOutputText($validTo),
$certTable->addElement($certSpace); new htmlOutputText($serial),
$certTable->addElement(new htmlOutputText($cn), true); $delBtn
);
} }
$securityTable->addElement(new htmlOutputText('')); $certsTable = new \htmlResponsiveTable($certsTitles, $certsData);
$securityTable->addElement($certTable, true); $row->add($certsTable, 12);
} }
$container->addElement($securityTable, true);
$container->addElement(new htmlSpacer(null, '10px'), true);
// password policy // password policy
$container->addElement(new htmlSubTitle(_("Password policy")), true); $row->add(new htmlSubTitle(_("Password policy")), 12);
$policyTable = new htmlTable();
$options20 = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20); $options20 = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
$options4 = array(0, 1, 2, 3, 4); $options4 = array(0, 1, 2, 3, 4);
$policyTable->addElement(new htmlTableExtendedSelect('passwordMinLength', $options20, array($cfg->passwordMinLength), _('Minimum password length'), '242'), true); $row->add(new htmlResponsiveSelect('passwordMinLength', $options20, array($cfg->passwordMinLength), _('Minimum password length'), '242'), 12);
$policyTable->addVerticalSpace('5px'); $row->addVerticalSpacer('1rem');
$policyTable->addElement(new htmlTableExtendedSelect('passwordMinLower', $options20, array($cfg->passwordMinLower), _('Minimum lowercase characters'), '242'), true); $row->add(new htmlResponsiveSelect('passwordMinLower', $options20, array($cfg->passwordMinLower), _('Minimum lowercase characters'), '242'), 12);
$policyTable->addElement(new htmlTableExtendedSelect('passwordMinUpper', $options20, array($cfg->passwordMinUpper), _('Minimum uppercase characters'), '242'), true); $row->add(new htmlResponsiveSelect('passwordMinUpper', $options20, array($cfg->passwordMinUpper), _('Minimum uppercase characters'), '242'), 12);
$policyTable->addElement(new htmlTableExtendedSelect('passwordMinNumeric', $options20, array($cfg->passwordMinNumeric), _('Minimum numeric characters'), '242'), true); $row->add(new htmlResponsiveSelect('passwordMinNumeric', $options20, array($cfg->passwordMinNumeric), _('Minimum numeric characters'), '242'), 12);
$policyTable->addElement(new htmlTableExtendedSelect('passwordMinSymbol', $options20, array($cfg->passwordMinSymbol), _('Minimum symbolic characters'), '242'), true); $row->add(new htmlResponsiveSelect('passwordMinSymbol', $options20, array($cfg->passwordMinSymbol), _('Minimum symbolic characters'), '242'), 12);
$policyTable->addElement(new htmlTableExtendedSelect('passwordMinClasses', $options4, array($cfg->passwordMinClasses), _('Minimum character classes'), '242'), true); $row->add(new htmlResponsiveSelect('passwordMinClasses', $options4, array($cfg->passwordMinClasses), _('Minimum character classes'), '242'), 12);
$policyTable->addVerticalSpace('5px'); $row->addVerticalSpacer('1rem');
$rulesCountOptions = array(_('all') => '-1', '3' => '3', '4' => '4'); $rulesCountOptions = array(_('all') => '-1', '3' => '3', '4' => '4');
$rulesCountSelect = new htmlTableExtendedSelect('passwordRulesCount', $rulesCountOptions, array($cfg->checkedRulesCount), _('Number of rules that must match'), '246'); $rulesCountSelect = new htmlResponsiveSelect('passwordRulesCount', $rulesCountOptions, array($cfg->checkedRulesCount), _('Number of rules that must match'), '246');
$rulesCountSelect->setHasDescriptiveElements(true); $rulesCountSelect->setHasDescriptiveElements(true);
$policyTable->addElement($rulesCountSelect, true); $row->add($rulesCountSelect, 12);
$passwordMustNotContainUser = ($cfg->passwordMustNotContainUser === 'true') ? true : false; $passwordMustNotContainUser = ($cfg->passwordMustNotContainUser === 'true') ? true : false;
$policyTable->addElement(new htmlTableExtendedInputCheckbox('passwordMustNotContainUser',$passwordMustNotContainUser , _('Password must not contain user name'), '247'), true); $row->add(new htmlResponsiveInputCheckbox('passwordMustNotContainUser',$passwordMustNotContainUser , _('Password must not contain user name'), '247'), 12);
$passwordMustNotContain3Chars = ($cfg->passwordMustNotContain3Chars === 'true') ? true : false; $passwordMustNotContain3Chars = ($cfg->passwordMustNotContain3Chars === 'true') ? true : false;
$policyTable->addElement(new htmlTableExtendedInputCheckbox('passwordMustNotContain3Chars', $passwordMustNotContain3Chars, _('Password must not contain part of user/first/last name'), '248'), true); $row->add(new htmlResponsiveInputCheckbox('passwordMustNotContain3Chars', $passwordMustNotContain3Chars, _('Password must not contain part of user/first/last name'), '248'), 12);
$container->addElement($policyTable, true);
$container->addElement(new htmlSpacer(null, '10px'), true);
// logging // logging
$container->addElement(new htmlSubTitle(_("Logging")), true); $row->add(new htmlSubTitle(_("Logging")), 12);
$loggingTable = new htmlTable();
$levelOptions = array(_("Debug") => LOG_DEBUG, _("Notice") => LOG_NOTICE, _("Warning") => LOG_WARNING, _("Error") => LOG_ERR); $levelOptions = array(_("Debug") => LOG_DEBUG, _("Notice") => LOG_NOTICE, _("Warning") => LOG_WARNING, _("Error") => LOG_ERR);
$levelSelect = new htmlTableExtendedSelect('logLevel', $levelOptions, array($cfg->logLevel), _("Log level"), '239'); $levelSelect = new htmlResponsiveSelect('logLevel', $levelOptions, array($cfg->logLevel), _("Log level"), '239');
$levelSelect->setHasDescriptiveElements(true); $levelSelect->setHasDescriptiveElements(true);
$loggingTable->addElement($levelSelect, true); $row->add($levelSelect, 12);
$destinationOptions = array(_("No logging") => "none", _("System logging") => "syslog", _("File") => 'file'); $destinationOptions = array(_("No logging") => "none", _("System logging") => "syslog", _("File") => 'file');
$destinationSelected = 'file'; $destinationSelected = 'file';
$destinationPath = $cfg->logDestination; $destinationPath = $cfg->logDestination;
@ -454,61 +434,63 @@ elseif ($cfg->logDestination == 'SYSLOG') {
$destinationSelected = 'syslog'; $destinationSelected = 'syslog';
$destinationPath = ''; $destinationPath = '';
} }
$loggingTable->addElement(new htmlTableExtendedRadio(_("Log destination"), 'logDestination', $destinationOptions, $destinationSelected, '240'), true); $logDestinationSelect = new htmlResponsiveSelect('logDestination', $destinationOptions, array($destinationSelected), _("Log destination"), '240');
$loggingTable->addElement(new htmlOutputText('')); $logDestinationSelect->setTableRowsToHide(array(
$loggingTable->addElement(new htmlInputField('logFile', $destinationPath), true); 'none' => array('logFile'),
$loggingTable->addElement(new htmlSpacer(null, '10px'), true); 'syslog' => array('logFile'),
));
$logDestinationSelect->setTableRowsToShow(array(
'file' => array('logFile'),
));
$logDestinationSelect->setHasDescriptiveElements(true);
$row->add($logDestinationSelect, 12);
$row->add(new htmlResponsiveInputField(_('File'), 'logFile', $destinationPath), 12);
$errorLogOptions = array( $errorLogOptions = array(
_('PHP system setting') => LAMCfgMain::ERROR_REPORTING_SYSTEM, _('PHP system setting') => LAMCfgMain::ERROR_REPORTING_SYSTEM,
_('default') => LAMCfgMain::ERROR_REPORTING_DEFAULT, _('default') => LAMCfgMain::ERROR_REPORTING_DEFAULT,
_('all') => LAMCfgMain::ERROR_REPORTING_ALL _('all') => LAMCfgMain::ERROR_REPORTING_ALL
); );
$errorLogSelect = new htmlTableExtendedSelect('errorReporting', $errorLogOptions, array($cfg->errorReporting), _('PHP error reporting'), '244'); $errorLogSelect = new htmlResponsiveSelect('errorReporting', $errorLogOptions, array($cfg->errorReporting), _('PHP error reporting'), '244');
$errorLogSelect->setHasDescriptiveElements(true); $errorLogSelect->setHasDescriptiveElements(true);
$loggingTable->addElement($errorLogSelect, true); $row->add($errorLogSelect, 12);
$container->addElement($loggingTable, true);
$container->addElement(new htmlSpacer(null, '10px'), true);
// additional options // additional options
if (isLAMProVersion()) { if (isLAMProVersion()) {
$container->addElement(new htmlSubTitle(_('Additional options')), true); $row->add(new htmlSubTitle(_('Additional options')), 12);
$additionalTable = new htmlTable();
$mailEOLOptions = array( $mailEOLOptions = array(
_('Default (\r\n)') => 'default', _('Default (\r\n)') => 'default',
_('Non-standard (\n)') => 'unix' _('Non-standard (\n)') => 'unix'
); );
$mailEOLSelect = new htmlTableExtendedSelect('mailEOL', $mailEOLOptions, array($cfg->mailEOL), _('Email format'), '243'); $mailEOLSelect = new htmlResponsiveSelect('mailEOL', $mailEOLOptions, array($cfg->mailEOL), _('Email format'), '243');
$mailEOLSelect->setHasDescriptiveElements(true); $mailEOLSelect->setHasDescriptiveElements(true);
$additionalTable->addElement($mailEOLSelect, true); $row->add($mailEOLSelect, 12);
$container->addElement($additionalTable, true);
$container->addElement(new htmlSpacer(null, '10px'), true);
} }
$row->addVerticalSpacer('3rem');
// change master password // change master password
$container->addElement(new htmlSubTitle(_("Change master password")), true); $row->add(new htmlSubTitle(_("Change master password")), 12);
$passwordTable = new htmlTable(); $pwd1 = new htmlResponsiveInputField(_("New master password"), 'masterpassword', '', '235');
$pwd1 = new htmlTableExtendedInputField(_("New master password"), 'masterpassword', '', '235');
$pwd1->setIsPassword(true); $pwd1->setIsPassword(true);
$passwordTable->addElement($pwd1, true); $row->add($pwd1, 12);
$pwd2 = new htmlTableExtendedInputField(_("Reenter password"), 'masterpassword2', ''); $pwd2 = new htmlResponsiveInputField(_("Reenter password"), 'masterpassword2', '');
$pwd2->setIsPassword(true); $pwd2->setIsPassword(true);
$pwd2->setSameValueFieldID('masterpassword'); $pwd2->setSameValueFieldID('masterpassword');
$passwordTable->addElement($pwd2, true); $row->add($pwd2, 12);
$container->addElement($passwordTable, true); $row->addVerticalSpacer('3rem');
$container->addElement(new htmlSpacer(null, '20px'), true);
// buttons // buttons
if ($cfg->isWritable()) { if ($cfg->isWritable()) {
$buttonTable = new htmlTable(); $buttonTable = new htmlTable();
$buttonTable->addElement(new htmlButton('submit', _("Ok"))); $buttonTable->addElement(new htmlButton('submit', _("Ok")));
$buttonTable->addElement(new htmlSpacer('1rem', null));
$buttonTable->addElement(new htmlButton('cancel', _("Cancel"))); $buttonTable->addElement(new htmlButton('cancel', _("Cancel")));
$container->addElement($buttonTable, true); $row->add($buttonTable, 12);
} }
$container->addElement(new htmlHiddenInput('submitFormData', '1'), true); $box = new htmlDiv(null, $row);
$box->setCSSClasses(array('ui-corner-all', 'roundedShadowBox'));
parseHtml(null, $box, array(), false, $tabindex, 'user');
$tabindex = 1;
parseHtml(null, $container, array(), false, $tabindex, 'user');
/** /**
* Formats an LDAP time string (e.g. from createTimestamp). * Formats an LDAP time string (e.g. from createTimestamp).