responsive

This commit is contained in:
Roland Gruber 2019-11-01 20:39:17 +01:00
parent 58828c9836
commit 6039d77a7d
2 changed files with 113 additions and 119 deletions

View File

@ -1,9 +1,8 @@
<?php <?php
/* /*
$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) 2005 - 2015 Roland Gruber Copyright (C) 2005 - 2019 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -73,11 +72,11 @@ class sambaDomain extends baseModule {
'sambaMinPwdAge', 'sambaMaxPwdAge', 'sambaLockoutDuration', 'sambaLockoutObservationWindow'); 'sambaMinPwdAge', 'sambaMaxPwdAge', 'sambaLockoutDuration', 'sambaLockoutObservationWindow');
// help Entries // help Entries
$return['help'] = array( $return['help'] = array(
'domainName' => array( 'sambaDomainName' => array(
"Headline" => _("Domain name"), 'attr' => 'sambaDomainName', "Headline" => _("Domain name"), 'attr' => 'sambaDomainName',
"Text" => _("The name of your Windows domain or workgroup.") "Text" => _("The name of your Windows domain or workgroup.")
), ),
'domainSID' => array( 'sambaSID' => array(
"Headline" => _("Domain SID"), 'attr' => 'sambaSID', "Headline" => _("Domain SID"), 'attr' => 'sambaSID',
"Text" => _("The SID of your Samba server. Get it with \"net getlocalsid\".") "Text" => _("The SID of your Samba server. Get it with \"net getlocalsid\".")
), ),
@ -142,14 +141,14 @@ class sambaDomain extends baseModule {
array( array(
'name' => 'sambaDomain_domainName', 'name' => 'sambaDomain_domainName',
'description' => _('Domain name'), 'description' => _('Domain name'),
'help' => 'domainName', 'help' => 'sambaDomainName',
'example' => _('Workgroup'), 'example' => _('Workgroup'),
'required' => true 'required' => true
), ),
array( array(
'name' => 'sambaDomain_domainSID', 'name' => 'sambaDomain_domainSID',
'description' => _('Domain SID'), 'description' => _('Domain SID'),
'help' => 'domainSID', 'help' => 'sambaSID',
'example' => 'S-1-1-22-123-123-123', 'example' => 'S-1-1-22-123-123-123',
'required' => true 'required' => true
), ),
@ -231,39 +230,33 @@ class sambaDomain extends baseModule {
* @return htmlElement HTML meta data * @return htmlElement HTML meta data
*/ */
function display_html_attributes() { function display_html_attributes() {
$return = new htmlTable(); $return = new htmlResponsiveRow();
// domain name // domain name
$domainName = '';
if (isset($this->attributes['sambaDomainName'][0])) {
$domainName = $this->attributes['sambaDomainName'][0];
}
if ($this->getAccountContainer()->isNewAccount) { if ($this->getAccountContainer()->isNewAccount) {
$domainNameInput = new htmlTableExtendedInputField(_('Domain name'), 'domainName', $domainName, 'domainName'); $this->addSimpleInputTextField($return, 'sambaDomainName', _('Domain name'), true);
$domainNameInput->setRequired(true);
$return->addElement($domainNameInput, true);
} }
else { else {
$return->addElement(new htmlOutputText(_('Domain name'))); $return->addLabel(new htmlOutputText(_('Domain name')));
$return->addElement(new htmlOutputText($domainName)); $domainNameGroup = new htmlGroup();
$return->addElement(new htmlHelpLink('domainName'), true); $domainName = $this->attributes['sambaDomainName'][0];
$domainNameGroup->addElement(new htmlOutputText($domainName));
$domainNameGroup->addElement(new htmlHelpLink('sambaDomainName'));
$return->addField($domainNameGroup);
} }
// domain SID // domain SID
$domainSID = '';
if (isset($this->attributes['sambaSID'][0])) {
$domainSID = $this->attributes['sambaSID'][0];
}
if ($this->getAccountContainer()->isNewAccount) { if ($this->getAccountContainer()->isNewAccount) {
$domainSIDInput = new htmlTableExtendedInputField(_('Domain SID'), 'domainSID', $domainSID, 'domainSID'); $this->addSimpleInputTextField($return, 'sambaSID', _('Domain SID'), true);
$domainSIDInput->setRequired(true);
$return->addElement($domainSIDInput, true);
} }
else { else {
$return->addElement(new htmlOutputText(_('Domain SID'))); $return->addLabel(new htmlOutputText(_('Domain SID')));
$return->addElement(new htmlOutputText($domainSID)); $domainSidGroup = new htmlGroup();
$return->addElement(new htmlHelpLink('domainSID'), true); $domainSID = $this->attributes['sambaSID'][0];
$domainSidGroup->addElement(new htmlOutputText($domainSID));
$domainSidGroup->addElement(new htmlHelpLink('sambaSID'));
$return->addField($domainSidGroup);
} }
$return->addElement(new htmlSubTitle(_("Password policy")), true); $return->add(new htmlSubTitle(_("Password policy")), 12);
/* group policies */ /* group policies */
@ -272,84 +265,84 @@ class sambaDomain extends baseModule {
if (isset($this->attributes['sambaMinPwdLength'][0])) { if (isset($this->attributes['sambaMinPwdLength'][0])) {
$sambaMinPwdLength = $this->attributes['sambaMinPwdLength'][0]; $sambaMinPwdLength = $this->attributes['sambaMinPwdLength'][0];
} }
$return->addElement(new htmlTableExtendedSelect('minPwdLength', array('-', 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15), $return->add(new htmlResponsiveSelect('minPwdLength', array('-', 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15),
array($sambaMinPwdLength), _('Minimal password length'), 'minPwdLength'), true); array($sambaMinPwdLength), _('Minimal password length'), 'minPwdLength'), 12);
// password history length // password history length
$sambaPwdHistoryLength = '-'; $sambaPwdHistoryLength = '-';
if (isset($this->attributes['sambaPwdHistoryLength'][0])) { if (isset($this->attributes['sambaPwdHistoryLength'][0])) {
$sambaPwdHistoryLength = $this->attributes['sambaPwdHistoryLength'][0]; $sambaPwdHistoryLength = $this->attributes['sambaPwdHistoryLength'][0];
} }
$return->addElement(new htmlTableExtendedSelect('pwdHistLength', array('-', 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15), $return->add(new htmlResponsiveSelect('pwdHistLength', array('-', 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15),
array($sambaPwdHistoryLength), _('Password history length'), 'pwdHistLength'), true); array($sambaPwdHistoryLength), _('Password history length'), 'pwdHistLength'), 12);
// logon to change password // logon to change password
$sambaLogonToChgPwd = '-'; $sambaLogonToChgPwd = '-';
if (isset($this->attributes['sambaLogonToChgPwd'][0])) { if (isset($this->attributes['sambaLogonToChgPwd'][0])) {
$sambaLogonToChgPwd = $this->attributes['sambaLogonToChgPwd'][0]; $sambaLogonToChgPwd = $this->attributes['sambaLogonToChgPwd'][0];
} }
$logonPwdChangeSelect = new htmlTableExtendedSelect('logonToChgPwd', array('-' => '-', _('Off') => '0', _('On') => '2'), $logonPwdChangeSelect = new htmlResponsiveSelect('logonToChgPwd', array('-' => '-', _('Off') => '0', _('On') => '2'),
array($sambaLogonToChgPwd), _('Logon for password change'), 'logonToChgPwd'); array($sambaLogonToChgPwd), _('Logon for password change'), 'logonToChgPwd');
$logonPwdChangeSelect->setHasDescriptiveElements(true); $logonPwdChangeSelect->setHasDescriptiveElements(true);
$return->addElement($logonPwdChangeSelect, true); $return->add($logonPwdChangeSelect, 12);
// force logoff // force logoff
$sambaForceLogoff = '-'; $sambaForceLogoff = '-';
if (isset($this->attributes['sambaForceLogoff'][0])) { if (isset($this->attributes['sambaForceLogoff'][0])) {
$sambaForceLogoff = $this->attributes['sambaForceLogoff'][0]; $sambaForceLogoff = $this->attributes['sambaForceLogoff'][0];
} }
$forceLogoffSelect = new htmlTableExtendedSelect('forceLogoff', array('-' => '-', _('Off') => '-1', _('On') => '0'), $forceLogoffSelect = new htmlResponsiveSelect('forceLogoff', array('-' => '-', _('Off') => '-1', _('On') => '0'),
array($sambaForceLogoff), _('Disconnect users outside logon hours'), 'forceLogoff'); array($sambaForceLogoff), _('Disconnect users outside logon hours'), 'forceLogoff');
$forceLogoffSelect->setHasDescriptiveElements(true); $forceLogoffSelect->setHasDescriptiveElements(true);
$return->addElement($forceLogoffSelect, true); $return->add($forceLogoffSelect, 12);
// do not allow machine password change // do not allow machine password change
$sambaRefuseMachinePwdChange = '-'; $sambaRefuseMachinePwdChange = '-';
if (isset($this->attributes['sambaRefuseMachinePwdChange'][0])) { if (isset($this->attributes['sambaRefuseMachinePwdChange'][0])) {
$sambaRefuseMachinePwdChange = $this->attributes['sambaRefuseMachinePwdChange'][0]; $sambaRefuseMachinePwdChange = $this->attributes['sambaRefuseMachinePwdChange'][0];
} }
$refuseMachPwdChange = new htmlTableExtendedSelect('refuseMachinePwdChange', array('-' => '-', _('Off') => '0', _('On') => '1'), $refuseMachPwdChange = new htmlResponsiveSelect('refuseMachinePwdChange', array('-' => '-', _('Off') => '0', _('On') => '1'),
array($sambaRefuseMachinePwdChange), _('Allow machine password changes'), 'refuseMachinePwdChange'); array($sambaRefuseMachinePwdChange), _('Allow machine password changes'), 'refuseMachinePwdChange');
$refuseMachPwdChange->setHasDescriptiveElements(true); $refuseMachPwdChange->setHasDescriptiveElements(true);
$return->addElement($refuseMachPwdChange, true); $return->add($refuseMachPwdChange, 12);
// Lockout users after bad logon attempts // Lockout users after bad logon attempts
$sambaLockoutThreshold = ''; $sambaLockoutThreshold = '';
if (isset($this->attributes['sambaLockoutThreshold'][0])) { if (isset($this->attributes['sambaLockoutThreshold'][0])) {
$sambaLockoutThreshold = $this->attributes['sambaLockoutThreshold'][0]; $sambaLockoutThreshold = $this->attributes['sambaLockoutThreshold'][0];
} }
$sambaLockoutThresholdInput = new htmlTableExtendedInputField(_('Lockout users after bad logon attempts'), 'lockoutThreshold', $sambaLockoutThreshold, 'lockoutThreshold'); $sambaLockoutThresholdInput = new htmlResponsiveInputField(_('Lockout users after bad logon attempts'), 'lockoutThreshold', $sambaLockoutThreshold, 'lockoutThreshold');
$sambaLockoutThresholdInput->setValidationRule(htmlElement::VALIDATE_NUMERIC); $sambaLockoutThresholdInput->setValidationRule(htmlElement::VALIDATE_NUMERIC);
$return->addElement($sambaLockoutThresholdInput, true); $return->add($sambaLockoutThresholdInput, 12);
// Minimum password age // Minimum password age
$sambaMinPwdAge = ''; $sambaMinPwdAge = '';
if (isset($this->attributes['sambaMinPwdAge'][0])) { if (isset($this->attributes['sambaMinPwdAge'][0])) {
$sambaMinPwdAge = $this->attributes['sambaMinPwdAge'][0]; $sambaMinPwdAge = $this->attributes['sambaMinPwdAge'][0];
} }
$sambaMinPwdAgeInput = new htmlTableExtendedInputField(_('Minimum password age'), 'minPwdAge', $sambaMinPwdAge, 'minPwdAge'); $sambaMinPwdAgeInput = new htmlResponsiveInputField(_('Minimum password age'), 'minPwdAge', $sambaMinPwdAge, 'minPwdAge');
$sambaMinPwdAgeInput->setValidationRule(htmlElement::VALIDATE_NUMERIC); $sambaMinPwdAgeInput->setValidationRule(htmlElement::VALIDATE_NUMERIC);
$return->addElement($sambaMinPwdAgeInput, true); $return->add($sambaMinPwdAgeInput, 12);
// Maximum password age // Maximum password age
$sambaMaxPwdAge = ''; $sambaMaxPwdAge = '';
if (isset($this->attributes['sambaMaxPwdAge'][0])) { if (isset($this->attributes['sambaMaxPwdAge'][0])) {
$sambaMaxPwdAge = $this->attributes['sambaMaxPwdAge'][0]; $sambaMaxPwdAge = $this->attributes['sambaMaxPwdAge'][0];
} }
$sambaMaxPwdAgeInput = new htmlTableExtendedInputField(_('Maximum password age'), 'maxPwdAge', $sambaMaxPwdAge, 'maxPwdAge'); $sambaMaxPwdAgeInput = new htmlResponsiveInputField(_('Maximum password age'), 'maxPwdAge', $sambaMaxPwdAge, 'maxPwdAge');
$sambaMaxPwdAgeInput->setValidationRule(htmlElement::VALIDATE_NUMERIC_WITH_NEGATIVE); $sambaMaxPwdAgeInput->setValidationRule(htmlElement::VALIDATE_NUMERIC_WITH_NEGATIVE);
$return->addElement($sambaMaxPwdAgeInput, true); $return->add($sambaMaxPwdAgeInput, 12);
// Lockout duration // Lockout duration
$sambaLockoutDuration = ''; $sambaLockoutDuration = '';
if (isset($this->attributes['sambaLockoutDuration'][0])) { if (isset($this->attributes['sambaLockoutDuration'][0])) {
$sambaLockoutDuration = $this->attributes['sambaLockoutDuration'][0]; $sambaLockoutDuration = $this->attributes['sambaLockoutDuration'][0];
} }
$sambaLockoutDurationInput = new htmlTableExtendedInputField(_('Lockout duration'), 'lockoutDuration', $sambaLockoutDuration, 'lockoutDuration'); $sambaLockoutDurationInput = new htmlResponsiveInputField(_('Lockout duration'), 'lockoutDuration', $sambaLockoutDuration, 'lockoutDuration');
$sambaLockoutDurationInput->setValidationRule(htmlElement::VALIDATE_NUMERIC); $sambaLockoutDurationInput->setValidationRule(htmlElement::VALIDATE_NUMERIC);
$return->addElement($sambaLockoutDurationInput, true); $return->add($sambaLockoutDurationInput, 12);
// Reset time after lockout // Reset time after lockout
$sambaLockoutObservationWindow = ''; $sambaLockoutObservationWindow = '';
if (isset($this->attributes['sambaLockoutObservationWindow'][0])) { if (isset($this->attributes['sambaLockoutObservationWindow'][0])) {
$sambaLockoutObservationWindow = $this->attributes['sambaLockoutObservationWindow'][0]; $sambaLockoutObservationWindow = $this->attributes['sambaLockoutObservationWindow'][0];
} }
$sambaLockoutObservationWindowInput = new htmlTableExtendedInputField(_('Reset time after lockout'), 'lockoutObservationWindow', $sambaLockoutObservationWindow, 'lockoutObservationWindow'); $sambaLockoutObservationWindowInput = new htmlResponsiveInputField(_('Reset time after lockout'), 'lockoutObservationWindow', $sambaLockoutObservationWindow, 'lockoutObservationWindow');
$sambaLockoutObservationWindowInput->setValidationRule(htmlElement::VALIDATE_NUMERIC); $sambaLockoutObservationWindowInput->setValidationRule(htmlElement::VALIDATE_NUMERIC);
$return->addElement($sambaLockoutObservationWindowInput, true); $return->add($sambaLockoutObservationWindowInput, 12);
$return->addElement(new htmlSubTitle(_('RID settings')), true); $return->add(new htmlSubTitle(_('RID settings')), 12);
/* RID settings */ /* RID settings */
@ -358,37 +351,41 @@ class sambaDomain extends baseModule {
if (isset($this->attributes['sambaNextRid'][0])) { if (isset($this->attributes['sambaNextRid'][0])) {
$nextRID = $this->attributes['sambaNextRid'][0]; $nextRID = $this->attributes['sambaNextRid'][0];
} }
$nextRIDInput = new htmlTableExtendedInputField(_('Next RID'), 'nextRID', $nextRID, 'nextRID'); $nextRIDInput = new htmlResponsiveInputField(_('Next RID'), 'nextRID', $nextRID, 'nextRID');
$nextRIDInput->setValidationRule(htmlElement::VALIDATE_NUMERIC); $nextRIDInput->setValidationRule(htmlElement::VALIDATE_NUMERIC);
$return->addElement($nextRIDInput, true); $return->add($nextRIDInput, 12);
// next user RID // next user RID
$nextUserRID = ''; $nextUserRID = '';
if (isset($this->attributes['sambaNextUserRid'][0])) { if (isset($this->attributes['sambaNextUserRid'][0])) {
$nextUserRID = $this->attributes['sambaNextUserRid'][0]; $nextUserRID = $this->attributes['sambaNextUserRid'][0];
} }
$nextUserRIDInput = new htmlTableExtendedInputField(_('Next user RID'), 'nextUserRID', $nextUserRID, 'nextUserRID'); $nextUserRIDInput = new htmlResponsiveInputField(_('Next user RID'), 'nextUserRID', $nextUserRID, 'nextUserRID');
$nextUserRIDInput->setValidationRule(htmlElement::VALIDATE_NUMERIC); $nextUserRIDInput->setValidationRule(htmlElement::VALIDATE_NUMERIC);
$return->addElement($nextUserRIDInput, true); $return->add($nextUserRIDInput, 12);
// next group RID // next group RID
$nextGroupRID = ''; $nextGroupRID = '';
if (isset($this->attributes['sambaNextGroupRid'][0])) { if (isset($this->attributes['sambaNextGroupRid'][0])) {
$nextGroupRID = $this->attributes['sambaNextGroupRid'][0]; $nextGroupRID = $this->attributes['sambaNextGroupRid'][0];
} }
$nextGroupRIDInput = new htmlTableExtendedInputField(_('Next group RID'), 'nextGroupRID', $nextGroupRID, 'nextGroupRID'); $nextGroupRIDInput = new htmlResponsiveInputField(_('Next group RID'), 'nextGroupRID', $nextGroupRID, 'nextGroupRID');
$nextGroupRIDInput->setValidationRule(htmlElement::VALIDATE_NUMERIC); $nextGroupRIDInput->setValidationRule(htmlElement::VALIDATE_NUMERIC);
$return->addElement($nextGroupRIDInput, true); $return->add($nextGroupRIDInput, 12);
// RID base // RID base
if (!isset($this->attributes['sambaAlgorithmicRidBase'][0])) $this->attributes['sambaAlgorithmicRidBase'][0] = 1000; if (!isset($this->attributes['sambaAlgorithmicRidBase'][0])) {
$this->attributes['sambaAlgorithmicRidBase'][0] = 1000;
}
if ($this->getAccountContainer()->isNewAccount) { if ($this->getAccountContainer()->isNewAccount) {
$ridBaseInput = new htmlTableExtendedInputField(_('RID base'), 'RIDbase', $this->attributes['sambaAlgorithmicRidBase'][0], 'RIDbase'); $ridBaseInput = new htmlResponsiveInputField(_('RID base'), 'RIDbase', $this->attributes['sambaAlgorithmicRidBase'][0], 'RIDbase');
$ridBaseInput->setRequired(true); $ridBaseInput->setRequired(true);
$ridBaseInput->setValidationRule(htmlElement::VALIDATE_NUMERIC); $ridBaseInput->setValidationRule(htmlElement::VALIDATE_NUMERIC);
$return->addElement($ridBaseInput, true); $return->add($ridBaseInput, 12);
} }
else { else {
$return->addElement(new htmlOutputText(_('RID base'))); $return->addLabel(new htmlOutputText(_('RID base')));
$return->addElement(new htmlOutputText($this->attributes['sambaAlgorithmicRidBase'][0])); $ridBaseGroup = new htmlGroup();
$return->addElement(new htmlHelpLink('RIDbase'), true); $ridBaseGroup->addElement(new htmlOutputText($this->attributes['sambaAlgorithmicRidBase'][0]));
$ridBaseGroup->addElement(new htmlHelpLink('RIDbase'));
$return->addField($ridBaseGroup);
} }
return $return; return $return;
} }
@ -403,12 +400,12 @@ class sambaDomain extends baseModule {
$errors = array(); $errors = array();
if ($this->getAccountContainer()->isNewAccount) { if ($this->getAccountContainer()->isNewAccount) {
// domain SID // domain SID
$this->attributes['sambaSID'][0] = $_POST['domainSID']; $this->attributes['sambaSID'][0] = $_POST['sambaSID'];
if (!get_preg($_POST['domainSID'], 'domainSID')) { if (!get_preg($_POST['sambaSID'], 'domainSID')) {
$errors[] = $this->messages['domainSID'][0]; $errors[] = $this->messages['domainSID'][0];
} }
else { else {
$this->attributes['sambaSID'][0] = $_POST['domainSID']; $this->attributes['sambaSID'][0] = $_POST['sambaSID'];
} }
// RID base // RID base
if (!get_preg($_POST['RIDbase'], 'digit') && !($_POST['RIDbase'] == '')) { if (!get_preg($_POST['RIDbase'], 'digit') && !($_POST['RIDbase'] == '')) {
@ -418,11 +415,11 @@ class sambaDomain extends baseModule {
$this->attributes['sambaAlgorithmicRidBase'][0] = $_POST['RIDbase']; $this->attributes['sambaAlgorithmicRidBase'][0] = $_POST['RIDbase'];
} }
// domain name // domain name
if (!get_preg($_POST['domainName'], 'domainname') && !($_POST['domainName'] == '')) { if (!get_preg($_POST['sambaDomainName'], 'domainname') && !($_POST['sambaDomainName'] == '')) {
$errors[] = $this->messages['domainName'][0]; $errors[] = $this->messages['domainName'][0];
} }
else { else {
$this->attributes['sambaDomainName'][0] = $_POST['domainName']; $this->attributes['sambaDomainName'][0] = $_POST['sambaDomainName'];
} }
} }
// next RID // next RID

View File

@ -4,7 +4,7 @@ use \LAM\TYPES\TypeManager;
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 - 2006 Tilo Lutz Copyright (C) 2003 - 2006 Tilo Lutz
2007 - 2018 Roland Gruber 2007 - 2019 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -309,7 +309,7 @@ class sambaGroupMapping extends baseModule {
if (isset($_POST['addObjectClass'])) { if (isset($_POST['addObjectClass'])) {
$this->attributes['objectClass'][] = 'sambaGroupMapping'; $this->attributes['objectClass'][] = 'sambaGroupMapping';
} }
$return = new htmlTable(); $return = new htmlResponsiveRow();
if (in_array('sambaGroupMapping', $this->attributes['objectClass'])) { if (in_array('sambaGroupMapping', $this->attributes['objectClass'])) {
$sambaDomains = $this->getDomains(); $sambaDomains = $this->getDomains();
if (sizeof($sambaDomains) == 0) { if (sizeof($sambaDomains) == 0) {
@ -330,42 +330,48 @@ class sambaGroupMapping extends baseModule {
} }
// display name // display name
$displayName = ''; $displayName = '';
if (isset($this->attributes['displayName'][0])) $displayName = $this->attributes['displayName'][0]; if (isset($this->attributes['displayName'][0])) {
$displayNameInput = new htmlTableExtendedInputField(_('Display name'), 'displayName', $displayName, 'displayName'); $displayName = $this->attributes['displayName'][0];
}
$displayNameInput = new htmlResponsiveInputField(_('Display name'), 'displayName', $displayName, 'displayName');
$displayNameInput->setFieldMaxLength(50); $displayNameInput->setFieldMaxLength(50);
$return->addElement($displayNameInput, true); $return->add($displayNameInput, 12);
// Windows group // Windows group
$options = array($this->getCn()); $options = array($this->getCn());
$selected = array($this->getCn()); $selected = array($this->getCn());
$names = array_keys($this->rids); $names = array_keys($this->rids);
$wrid=false;
for ($i=0; $i<count($names); $i++) { for ($i=0; $i<count($names); $i++) {
if (isset($this->attributes['sambaSID'][0]) && ($this->attributes['sambaSID'][0]==$SID."-".$this->rids[$names[$i]])) { if (isset($this->attributes['sambaSID'][0]) && ($this->attributes['sambaSID'][0]==$SID."-".$this->rids[$names[$i]])) {
$selected = array($names[$i]); $selected = array($names[$i]);
$wrid=true;
} }
$options[] = $names[$i]; $options[] = $names[$i];
} }
$return->addElement(new htmlTableExtendedSelect('sambaSID', $options, $selected, _('Windows group'), 'sambaSID'), true); $return->add(new htmlResponsiveSelect('sambaSID', $options, $selected, _('Windows group'), 'sambaSID'), 12);
// group type // group type
$names = array_keys($this->sambaGroupTypes); $names = array_keys($this->sambaGroupTypes);
$selected = array( _('Domain group') ); $selected = array( _('Domain group') );
for ($i=0; $i<count($names); $i++) { for ($i=0; $i<count($names); $i++) {
if (!isset($this->attributes['sambaGroupType'][0])) break; if (!isset($this->attributes['sambaGroupType'][0])) {
if ($this->attributes['sambaGroupType'][0]==$this->sambaGroupTypes[$names[$i]]) $selected = array( $names[$i] ); break;
} }
$return->addElement(new htmlTableExtendedSelect('sambaGroupType', $names, $selected, _('Group type'), 'type'), true); if ($this->attributes['sambaGroupType'][0]==$this->sambaGroupTypes[$names[$i]]) {
$selected = array( $names[$i] );
}
}
$return->add(new htmlResponsiveSelect('sambaGroupType', $names, $selected, _('Group type'), 'type'), 12);
// domain // domain
$selectedDomain = array(); $selectedDomain = array();
if (isset($sel_domain)) $selectedDomain = array($sel_domain); if (isset($sel_domain)) {
$return->addElement(new htmlTableExtendedSelect('sambaDomainName', $sambaDomainNames, $selectedDomain, _('Domain'), 'sambaDomainName'), true); $selectedDomain = array($sel_domain);
}
$return->add(new htmlResponsiveSelect('sambaDomainName', $sambaDomainNames, $selectedDomain, _('Domain'), 'sambaDomainName'), 12);
// local group members // local group members
$memberLabel = new htmlOutputText(_('Local members')); $memberLabel = new htmlOutputText(_('Local members'));
$memberLabel->alignment = htmlElement::ALIGN_TOP; $return->addLabel($memberLabel);
$return->addElement($memberLabel);
$addMemberButton = new htmlAccountPageButton(get_class($this), 'members', 'open', 'add.png', true); $addMemberButton = new htmlAccountPageButton(get_class($this), 'members', 'open', 'add.png', true);
$addMemberButton->setTitle(_('Add')); $addMemberButton->setTitle(_('Add'));
$addMemberButton->alignment = htmlElement::ALIGN_TOP; $addMemberButton->alignment = htmlElement::ALIGN_TOP;
$memberHelp = new htmlHelpLink('sambaSIDList');
if (!empty($this->attributes['sambaSIDList'][0])) { if (!empty($this->attributes['sambaSIDList'][0])) {
$this->loadSIDCache(); $this->loadSIDCache();
$memberTable = new htmlTable(); $memberTable = new htmlTable();
@ -381,26 +387,26 @@ class sambaGroupMapping extends baseModule {
$memberTable->addElement($delButton); $memberTable->addElement($delButton);
if ($i == (sizeof($this->attributes['sambaSIDList']) - 1)) { if ($i == (sizeof($this->attributes['sambaSIDList']) - 1)) {
$memberTable->addElement($addMemberButton); $memberTable->addElement($addMemberButton);
$memberTable->addElement($memberHelp);
} }
$memberTable->addNewLine(); $memberTable->addNewLine();
} }
$return->addElement($memberTable); $return->addField($memberTable);
} }
else { else {
$return->addElement($addMemberButton); $memberGroup = new htmlGroup();
$memberGroup->addElement($addMemberButton);
$memberGroup->addElement($memberHelp);
$return->addField($memberGroup);
} }
$memberHelp = new htmlHelpLink('sambaSIDList');
$memberHelp->alignment = htmlElement::ALIGN_TOP;
$return->addElement($memberHelp, true);
$return->addElement(new htmlSpacer(null, '10px'), true); $return->addVerticalSpacer('2rem');
$remButton = new htmlButton('remObjectClass', _('Remove Samba 3 extension')); $remButton = new htmlButton('remObjectClass', _('Remove Samba 3 extension'));
$remButton->colspan = 3; $return->add($remButton, 12, 12, 12, 'text-center');
$return->addElement($remButton);
} }
else { else {
$return->addElement(new htmlButton('addObjectClass', _('Add Samba 3 extension'))); $return->add(new htmlButton('addObjectClass', _('Add Samba 3 extension')), 12);
} }
return $return; return $return;
} }
@ -411,18 +417,12 @@ class sambaGroupMapping extends baseModule {
* @return htmlElement HTML meta data * @return htmlElement HTML meta data
*/ */
function display_html_members() { function display_html_members() {
$return = new htmlTable(); $return = new htmlResponsiveRow();
$typeManager = new TypeManager(); $typeManager = new TypeManager();
// show list of possible new members // show list of possible new members
if ((isset($_POST['form_subpage_' . get_class($this) . '_members_select']) || isset($_POST['setFilter'])) && isset($_POST['type'])) { if ((isset($_POST['form_subpage_' . get_class($this) . '_members_select']) || isset($_POST['setFilter'])) && isset($_POST['type'])) {
$type = $typeManager->getConfiguredType($_POST['type']); $type = $typeManager->getConfiguredType($_POST['type']);
$this->loadSIDCache(); $this->loadSIDCache();
$userFilter = '';
$userFilterRegex = '';
if (isset($_POST['newFilter'])) {
$userFilter = $_POST['newFilter'];
$userFilterRegex = '/' . str_replace(array('*', '(', ')'), array('.*', '\(', '\)'), $_POST['newFilter']) . '/ui';
}
$options = array(); $options = array();
$filter = get_ldap_filter($type->getId()); $filter = get_ldap_filter($type->getId());
$entries = searchLDAP($type->getSuffix(), $filter, array('dn', 'cn', 'uid', 'sambaSID')); $entries = searchLDAP($type->getSuffix(), $filter, array('dn', 'cn', 'uid', 'sambaSID'));
@ -440,32 +440,30 @@ class sambaGroupMapping extends baseModule {
else { else {
$label = $sid; $label = $sid;
} }
// check filter
if (!empty($userFilter) && !preg_match($userFilterRegex, $label)) {
continue;
}
if (empty($this->attributes['sambaSIDList'][0]) || !in_array($sid, $this->attributes['sambaSIDList'])) { if (empty($this->attributes['sambaSIDList'][0]) || !in_array($sid, $this->attributes['sambaSIDList'])) {
$options[$label] = $sid; $options[$label] = $sid;
} }
} }
$size = 20; $size = 20;
if (sizeof($options) < 20) $size = sizeof($options); if (sizeof($options) < 20) {
$size = sizeof($options);
}
$membersSelect = new htmlSelect('members', $options, array(), $size); $membersSelect = new htmlSelect('members', $options, array(), $size);
$membersSelect->setHasDescriptiveElements(true); $membersSelect->setHasDescriptiveElements(true);
$membersSelect->setMultiSelect(true); $membersSelect->setMultiSelect(true);
$membersSelect->setTransformSingleSelect(false); $membersSelect->setTransformSingleSelect(false);
$return->addElement($membersSelect, true); $return->add($membersSelect, 12);
$return->addVerticalSpacer('0.5rem');
$filterGroup = new htmlGroup(); $filterGroup = new htmlGroup();
$filterGroup->addElement(new htmlInputField('newFilter', $userFilter)); $filterInput = new htmlInputField('newFilter');
$filterGroup->addElement(new htmlButton('setFilter', _('Filter'))); $filterInput->filterSelectBox('members');
$filterGroup->addElement(new htmlHelpLink('filter')); $filterGroup->addElement(new htmlOutputText(_('Filter')));
$filterGroup->addElement($filterInput);
$filterGroup->addElement(new htmlHiddenInput('type', $type->getId())); $filterGroup->addElement(new htmlHiddenInput('type', $type->getId()));
$return->addElement($filterGroup, true); $return->add($filterGroup, 12);
$return->addElement(new htmlSpacer(null, '10px'), true); $return->addVerticalSpacer('2rem');
$buttonTable = new htmlTable(); $return->addLabel(new htmlAccountPageButton(get_class($this), 'attributes', 'addMembers', _('Add')));
$buttonTable->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'addMembers', _('Add'))); $return->addField(new htmlAccountPageButton(get_class($this), 'attributes', 'cancel', _('Cancel')));
$buttonTable->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'cancel', _('Cancel')));
$return->addElement($buttonTable);
return $return; return $return;
} }
$types = $typeManager->getConfiguredTypesForScopes(array('user', 'group', 'host')); $types = $typeManager->getConfiguredTypesForScopes(array('user', 'group', 'host'));
@ -477,15 +475,14 @@ class sambaGroupMapping extends baseModule {
$optionsSelected[] = $type->getId(); $optionsSelected[] = $type->getId();
} }
} }
$typeTable = new htmlTable(); $return->addLabel(new htmlOutputText(_('Add entries of this type:')));
$typeTable->addElement(new htmlOutputText(_('Add entries of this type:') . ' '));
$typeSelect = new htmlSelect('type', $options, $optionsSelected); $typeSelect = new htmlSelect('type', $options, $optionsSelected);
$typeSelect->setHasDescriptiveElements(true); $typeSelect->setHasDescriptiveElements(true);
$typeTable->addElement($typeSelect); $return->addField($typeSelect);
$typeTable->addElement(new htmlAccountPageButton(get_class($this), 'members', 'select', _('Ok'))); $return->addLabel(new htmlOutputText('&nbsp;', false));
$return->addElement($typeTable, true); $return->addField(new htmlAccountPageButton(get_class($this), 'members', 'select', _('Ok')));
$return->addElement(new htmlOutputText('&nbsp;', false), true); $return->addVerticalSpacer('2rem');
$return->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'membersBack', _('Back'))); $return->add(new htmlAccountPageButton(get_class($this), 'attributes', 'membersBack', _('Back')), 12, 12, 12, 'text-center');
return $return; return $return;
} }