From 493150ab6f45c92258570ef97e452c51252a3607 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 23 Aug 2019 22:03:29 +0200 Subject: [PATCH] responsive --- lam/lib/modules/ddns.inc | 29 +++++++++--------- lam/lib/modules/dhcp_settings.inc | 50 +++++++++++++++---------------- lam/lib/modules/eduPerson.inc | 50 ++++++++++++++----------------- lam/lib/modules/fixed_ip.inc | 48 +++++++++++++++-------------- 4 files changed, 87 insertions(+), 90 deletions(-) diff --git a/lam/lib/modules/ddns.inc b/lam/lib/modules/ddns.inc index c3c5e90d..06b7b98b 100644 --- a/lam/lib/modules/ddns.inc +++ b/lam/lib/modules/ddns.inc @@ -1,10 +1,9 @@ attributes = &$this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes; $this->orig = &$this->getAccountContainer()->getAccountModule('dhcp_settings')->orig; - $return = new htmlTable(); + $return = new htmlResponsiveRow(); // check if DHCP main settings and valid DHCP entry if ($this->isRootNode()) { if (!in_array_ignore_case('dhcpService', $this->attributes['objectClass']) && !in_array_ignore_case('dhcpServer', $this->attributes['objectClass'])) { @@ -364,21 +363,21 @@ class ddns extends baseModule { return $return; } // DHCP main settings - $return->addElement(new htmlTableExtendedInputCheckbox('active', $this->isDynDNSActivated(), _('Activate DynDNS'), 'active'), true); - $return->addElement(new htmlTableExtendedInputCheckbox('insert_fixed', $this->addFixIPs(), _('Add fix IP addresses to DNS'), 'fixed_ips'), true); - $return->addElement(new htmlTableExtendedInputCheckbox('client_insert', $this->isIgnoreClientUpdates(), _('Disable client updates'), 'client_insert'), true); - $keyInput = new htmlTableExtendedInputField(_('Path to key for DNS updates'), 'key_path', $this->getUpdateKey(), 'keypath'); - $return->addElement($keyInput); + $return->add(new htmlResponsiveInputCheckbox('active', $this->isDynDNSActivated(), _('Activate DynDNS'), 'active'), 12); + $return->add(new htmlResponsiveInputCheckbox('insert_fixed', $this->addFixIPs(), _('Add fix IP addresses to DNS'), 'fixed_ips'), 12); + $return->add(new htmlResponsiveInputCheckbox('client_insert', $this->isIgnoreClientUpdates(), _('Disable client updates'), 'client_insert'), 12); + $keyInput = new htmlResponsiveInputField(_('Path to key for DNS updates'), 'key_path', $this->getUpdateKey(), 'keypath'); + $return->add($keyInput, 12); } else { // Account edit if (!$this->check_if_ddns_is_enable()) { - $return->addElement(new htmlOutputText(_("DDNS ist not activated. You can activate it in the DHCP settings (DDNS)."))); + $return->add(new htmlOutputText(_("DDNS ist not activated. You can activate it in the DHCP settings (DDNS).")), 12); } else { // DNS server - $serverInput = new htmlTableExtendedInputField(_('IP address of the DNS server'), 'ip', $this->getDNSServer(), 'dns'); - $return->addElement($serverInput, true); + $serverInput = new htmlResponsiveInputField(_('IP address of the DNS server'), 'ip', $this->getDNSServer(), 'dns'); + $return->add($serverInput, 12); $zones = $this->getZoneNames(); $zone = ''; @@ -390,11 +389,11 @@ class ddns extends baseModule { $revzone = $zones[1]; } // zone name - $zoneInput = new htmlTableExtendedInputField(_('Zone name'), 'zone', $zone, 'zone'); - $return->addElement($zoneInput, true); + $zoneInput = new htmlResponsiveInputField(_('Zone name'), 'zone', $zone, 'zone'); + $return->add($zoneInput, 12); // reverse zone name - $revZoneInput = new htmlTableExtendedInputField(_('Reverse zone name'), 'zone_reverse', $revzone, 'zone_reverse'); - $return->addElement($revZoneInput); + $revZoneInput = new htmlResponsiveInputField(_('Reverse zone name'), 'zone_reverse', $revzone, 'zone_reverse'); + $return->add($revZoneInput, 12); } } diff --git a/lam/lib/modules/dhcp_settings.inc b/lam/lib/modules/dhcp_settings.inc index 73c2e6cf..236f6ba9 100644 --- a/lam/lib/modules/dhcp_settings.inc +++ b/lam/lib/modules/dhcp_settings.inc @@ -3,7 +3,7 @@ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2008 Thomas Manninger - 2008 - 2018 Roland Gruber + 2008 - 2019 Roland Gruber 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 @@ -566,11 +566,11 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I * @return htmlElement HTML meta data */ public function display_html_attributes() { - $return = new htmlTable(); + $return = new htmlResponsiveRow(); // check if DHCP main settings and valid DHCP entry if ($this->isRootNode()) { if (!in_array_ignore_case('dhcpService', $this->attributes['objectClass']) && !in_array_ignore_case('dhcpServer', $this->attributes['objectClass'])) { - $return->addElement(new htmlStatusMessage('ERROR', _('Please set your LDAP suffix to an LDAP entry with object class "dhcpService" or "dhcpServer".'))); + $return->add(new htmlStatusMessage('ERROR', _('Please set your LDAP suffix to an LDAP entry with object class "dhcpService" or "dhcpServer".')), 12); return $return; } } @@ -580,23 +580,22 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I if (isset($this->attributes['cn'][0])) { $cn = $this->attributes['cn'][0]; } - $subnetInput = new htmlTableExtendedInputField(_('Subnet'), 'cn', $cn, 'subnet'); + $subnetInput = new htmlResponsiveInputField(_('Subnet'), 'cn', $cn, 'subnet'); $subnetInput->setRequired(true); - $return->addElement($subnetInput); - $return->addElement(new htmlOutputText(_('Example') . ": 192.168.10.0"), true); + $return->add($subnetInput, 12); } // domain name - $return->addElement(new htmlTableExtendedInputField(_('Domain name'), 'domainname', $this->getDHCPOption('domain-name'), 'domainname'), true); + $return->add(new htmlResponsiveInputField(_('Domain name'), 'domainname', $this->getDHCPOption('domain-name'), 'domainname'), 12); // lease Time - $leasetimeInput = new htmlTableExtendedInputField(_('Lease time'), 'lease_time', $this->getDefaultLeaseTime(), 'leasetime'); + $leasetimeInput = new htmlResponsiveInputField(_('Lease time'), 'lease_time', $this->getDefaultLeaseTime(), 'leasetime'); $leasetimeInput->setValidationRule(htmlElement::VALIDATE_NUMERIC); - $return->addElement($leasetimeInput, true); + $return->add($leasetimeInput, 12); // max lease time - $max_leasetimeInput = new htmlTableExtendedInputField(_('Maximum lease time'), 'max_lease_time', $this->getMaxLeaseTime(), 'max_leasetime'); + $max_leasetimeInput = new htmlResponsiveInputField(_('Maximum lease time'), 'max_lease_time', $this->getMaxLeaseTime(), 'max_leasetime'); $max_leasetimeInput->setValidationRule(htmlElement::VALIDATE_NUMERIC); - $return->addElement($max_leasetimeInput, true); + $return->add($max_leasetimeInput, 12); // DNS - $return->addElement(new htmlTableExtendedInputField(_('DNS'), 'dns', $this->getDHCPOption('domain-name-servers'), 'dns'), true); + $return->add(new htmlResponsiveInputField(_('DNS'), 'dns', $this->getDHCPOption('domain-name-servers'), 'dns'), 12); // domain search $domainSearchEntries = $this->getDHCPOption('domain-search'); if ($domainSearchEntries === null) { @@ -606,9 +605,9 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I $this->attributes['INFO_domain-search'] = $domainSearchEntries; $this->addMultiValueInputTextField($return, 'INFO_domain-search', _('Search domains')); // gateway - $return->addElement(new htmlTableExtendedInputField(_('Default gateway'), 'routers', $this->getDHCPOption('routers'), 'gateway'), true); + $return->add(new htmlResponsiveInputField(_('Default gateway'), 'routers', $this->getDHCPOption('routers'), 'gateway'), 12); // netbios name servers - $return->addElement(new htmlTableExtendedInputField(_('Netbios name servers'), 'netbios', $this->getDHCPOption('netbios-name-servers'), 'netbios'), true); + $return->add(new htmlResponsiveInputField(_('Netbios name servers'), 'netbios', $this->getDHCPOption('netbios-name-servers'), 'netbios'), 12); // netbios node type $nodeType = $this->getDHCPOption('netbios-node-type'); if ($nodeType == '') { @@ -618,9 +617,9 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I foreach ($this->all_netbios_node_types as $key => $value) { $nodeOptions[$value] = $key; } - $nodeSelect = new htmlTableExtendedSelect('netbios_node_type', $nodeOptions, array($nodeType), _('Netbios node type'), 'netbios_type'); + $nodeSelect = new htmlResponsiveSelect('netbios_node_type', $nodeOptions, array($nodeType), _('Netbios node type'), 'netbios_type'); $nodeSelect->setHasDescriptiveElements(true); - $return->addElement($nodeSelect, true); + $return->add($nodeSelect, 12); if (!$this->isRootNode()) { // unknown clients @@ -629,17 +628,13 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I $unknownClients = '-'; } $unknownClientsOptions = array_flip($this->allowDenyOptions); - $unknownClientsSelect = new htmlTableExtendedSelect('unknownClients', $unknownClientsOptions, array($unknownClients), _('Unknown clients'), 'unknownClients'); + $unknownClientsSelect = new htmlResponsiveSelect('unknownClients', $unknownClientsOptions, array($unknownClients), _('Unknown clients'), 'unknownClients'); $unknownClientsSelect->setHasDescriptiveElements(true); - $return->addElement($unknownClientsSelect, true); + $return->add($unknownClientsSelect, 12); // subnetmask - $subnetMaskInput = new htmlTableExtendedInputField(_('Subnet mask'), 'subnet', $this->getDHCPOption('subnet-mask'), 'subnetmask'); + $subnetMaskInput = new htmlResponsiveInputField(_('Subnet mask'), 'subnet', $this->getDHCPOption('subnet-mask'), 'subnetmask'); $subnetMaskInput->setRequired(true); - $return->addElement($subnetMaskInput, true); - // netmask - $return->addElement(new htmlOutputText(_('Net mask'))); - $return->addElement(new htmlOutputText($this->attributes['dhcpNetMask'][0])); - $return->addElement(new htmlHelpLink('netmask'), true); + $return->add($subnetMaskInput, 12); } // description @@ -647,7 +642,12 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I if (isset($this->attributes['dhcpComments'][0])) { $description = $this->attributes['dhcpComments'][0]; } - $return->addElement(new htmlTableExtendedInputField(_('Description'), 'description', $description, 'description'), true); + $return->add(new htmlResponsiveInputField(_('Description'), 'description', $description, 'description'), 12); + if (!$this->isRootNode()) { + // netmask + $return->addLabel(new htmlOutputText(_('Net mask'))); + $return->addField(new htmlOutputText($this->attributes['dhcpNetMask'][0])); + } return $return; } diff --git a/lam/lib/modules/eduPerson.inc b/lam/lib/modules/eduPerson.inc index 6dd13135..b24b3405 100644 --- a/lam/lib/modules/eduPerson.inc +++ b/lam/lib/modules/eduPerson.inc @@ -2,7 +2,7 @@ /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2009 - 2018 Roland Gruber + Copyright (C) 2009 - 2019 Roland Gruber 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 @@ -270,7 +270,7 @@ class eduPerson extends baseModule { * @return htmlElement HTML meta data */ function display_html_attributes() { - $return = new htmlTable(); + $return = new htmlResponsiveRow(); if (in_array('eduPerson', $this->attributes['objectClass'])) { // principal name $this->addSimpleInputTextField($return, 'eduPersonPrincipalName', _('Principal name')); @@ -279,18 +279,18 @@ class eduPerson extends baseModule { if (isset($this->attributes['eduPersonPrimaryAffiliation'][0])) { $primaryAffiliation = array($this->attributes['eduPersonPrimaryAffiliation'][0]); } - $return->addElement(new htmlTableExtendedSelect('primaryAffiliation', $this->affiliationTypes, $primaryAffiliation, _('Primary affiliation'), 'primaryAffiliation'), true); + $return->add(new htmlResponsiveSelect('primaryAffiliation', $this->affiliationTypes, $primaryAffiliation, _('Primary affiliation'), 'primaryAffiliation'), 12); // scoped affiliations $scopedAffiliationLabel = new htmlOutputText(_('Scoped affiliations')); $scopedAffiliationLabel->alignment = htmlElement::ALIGN_TOP; - $return->addElement($scopedAffiliationLabel); + $return->addLabel($scopedAffiliationLabel); $scopedAffiliations = new htmlTable(); if (isset($this->attributes['eduPersonScopedAffiliation'][0])) { for ($i = 0; $i < sizeof($this->attributes['eduPersonScopedAffiliation']); $i++) { $parts = explode('@', $this->attributes['eduPersonScopedAffiliation'][$i]); $scopedAffiliationPrefix = array($parts[0]); $scopedAffiliation = substr($this->attributes['eduPersonScopedAffiliation'][$i], strlen($parts[0]) + 1); - $scopedAffiliationContainer = new htmlGroup(); + $scopedAffiliationContainer = new htmlTable(); $scopedAffiliationContainer->addElement(new htmlSelect('scopedAffiliationPrefix' . $i, $this->affiliationTypes, $scopedAffiliationPrefix)); $scopedAffiliationContainer->addElement(new htmlOutputText('@')); $scopedAffiliationContainer->addElement(new htmlInputField('scopedAffiliation' . $i, $scopedAffiliation)); @@ -305,38 +305,35 @@ class eduPerson extends baseModule { $scopedAffiliationContainer = new htmlGroup(); $scopedAffiliationContainer->addElement(new htmlOutputText('-')); $scopedAffiliationContainer->addElement(new htmlSpacer('10px', null)); - $scopedAffiliationContainer->addElement(new htmlButton('addeduPersonScopedAffiliation', 'add.png', true)); + $scopedAffiliationContainer->addElement(new htmlButton('addeduPersonScopedAffiliation', 'add.png')); + $scopedAffiliationContainer->addElement(new htmlHelpLink('scopedAffiliation'), true); $scopedAffiliations->addElement($scopedAffiliationContainer); } - $return->addElement($scopedAffiliations); - $scopedAffiliationHelp = new htmlHelpLink('scopedAffiliation'); - $scopedAffiliationHelp->alignment = htmlElement::ALIGN_TOP; - $return->addElement($scopedAffiliationHelp, true); + $return->addField($scopedAffiliations); // affiliations $affiliations = new htmlTable(); if (isset($this->attributes['eduPersonAffiliation'][0])) { for ($i = 0; $i < sizeof($this->attributes['eduPersonAffiliation']); $i++) { $affiliations->addElement(new htmlSelect('affiliation' . $i, $this->affiliationTypes, array($this->attributes['eduPersonAffiliation'][$i]))); $affiliationButton = new htmlButton('delAffiliation' . $i, 'del.png', true); - $affiliations->addElement($affiliationButton, true); + $affiliations->addElement($affiliationButton); + if ($i === 0) { + $affiliations->addElement(new htmlHelpLink('affiliation')); + } + $affiliations->addNewLine(); } } else { - $affiliations->addElement(new htmlOutputText('-'), true); + $affiliations->addElement(new htmlOutputText('-')); + $affiliations->addElement(new htmlHelpLink('affiliation'), true); } + $affiliations->addElement(new htmlSelect('affiliation', $this->affiliationTypes)); + $affiliations->addElement(new htmlButton('newAffiliation', 'add.png', true)); $affiliationLabel = new htmlOutputText(_('Affiliations')); $affiliationLabel->alignment = htmlElement::ALIGN_TOP; - $return->addElement($affiliationLabel); - $return->addElement($affiliations); - $affiliationHelp = new htmlHelpLink('affiliation'); - $affiliationHelp->alignment = htmlElement::ALIGN_TOP; - $return->addElement($affiliationHelp, true); - $return->addElement(new htmlOutputText('')); - $newAffiliationContainer = new htmlTable(); - $newAffiliationContainer->addElement(new htmlSelect('affiliation', $this->affiliationTypes)); - $newAffiliationContainer->addElement(new htmlButton('newAffiliation', 'add.png', true)); - $return->addElement($newAffiliationContainer); - $return->addElement(new htmlOutputText(''), true); + $return->addLabel($affiliationLabel); + $return->addField($affiliations); + $return->addVerticalSpacer('0.5rem'); // nick names $this->addMultiValueInputTextField($return, 'eduPersonNickname', _('Nick names')); // entitlements @@ -350,13 +347,12 @@ class eduPerson extends baseModule { // assurance profiles $this->addMultiValueInputTextField($return, 'eduPersonAssurance', _('Assurance profiles')); // remove button - $return->addElement(new htmlSpacer(null, '10px'), true); + $return->addVerticalSpacer('2rem'); $addButton = new htmlButton('remObjectClass', _('Remove EDU person extension')); - $addButton->colspan = 3; - $return->addElement($addButton); + $return->add($addButton, 12, 12, 12, 'text-center'); } else { - $return->addElement(new htmlButton('addObjectClass', _('Add EDU person extension'))); + $return->add(new htmlButton('addObjectClass', _('Add EDU person extension')), 12); } return $return; } diff --git a/lam/lib/modules/fixed_ip.inc b/lam/lib/modules/fixed_ip.inc index 834f4a5b..1e4b7d3e 100644 --- a/lam/lib/modules/fixed_ip.inc +++ b/lam/lib/modules/fixed_ip.inc @@ -3,11 +3,10 @@ use \LAM\PDF\PDFTable; use \LAM\PDF\PDFTableCell; use \LAM\PDF\PDFTableRow; /* -$Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2008 Thomas Manninger - 2008 - 2018 Roland Gruber + 2008 - 2019 Roland Gruber 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 @@ -449,27 +448,29 @@ class fixed_ip extends baseModule { $this->fixed_ip = array(); } $pcs = array(); + $messages = array(); foreach($this->fixed_ip AS $id => $arr) { // pc name - $pcError = ""; - $existsInDifferentDn = !empty($_POST['pc_' . $id]) && $this->hostNameExists($_POST['pc_' . $id]); - if (!$this->processed) { - $pcError = ""; + $existsInDifferentDn = false; + if (!empty($_POST['pc_' . $id])) { + $existsInDifferentDn = $this->hostNameExists($_POST['pc_' . $id]); } - elseif (strlen($this->fixed_ip[$id]['cn'])>20) { - $pcError = _("The PC name may not be longer than 20 characters."); - } - elseif (strlen($this->fixed_ip[$id]['cn'])<2) { - $pcError = _("The PC name needs to be at least 2 characters long."); - } - elseif (in_array($this->fixed_ip[$id]['cn'], $pcs) ) { - $pcError = _("This PC name already exists."); - } - elseif (isset($_POST['pc_'.$id]) && !preg_match("/^[A-Za-z0-9\\._-]*$/", $_POST['pc_'.$id])) { - $pcError = _("The PC name may only contain A-Z, a-z and 0-9."); - } - elseif ($existsInDifferentDn !== false) { - $pcError = sprintf(_('This PC name already exists in %s. Use e.g. %s.'), $existsInDifferentDn[0], $existsInDifferentDn[1]); + if ($this->processed) { + if (strlen($this->fixed_ip[$id]['cn']) > 20) { + $messages[] = new htmlStatusMessage('ERROR', _("The PC name may not be longer than 20 characters."), htmlspecialchars($this->fixed_ip[$id]['cn'])); + } + elseif (strlen($this->fixed_ip[$id]['cn']) < 2) { + $messages[] = new htmlStatusMessage('ERROR', _("The PC name needs to be at least 2 characters long."), htmlspecialchars($this->fixed_ip[$id]['cn'])); + } + elseif (in_array($this->fixed_ip[$id]['cn'], $pcs) ) { + $messages[] = new htmlStatusMessage('ERROR', _("This PC name already exists."), htmlspecialchars($this->fixed_ip[$id]['cn'])); + } + elseif (isset($_POST['pc_' . $id]) && !preg_match("/^[A-Za-z0-9\\._-]*$/", $_POST['pc_' . $id])) { + $messages[] = new htmlStatusMessage('ERROR', _("The PC name may only contain A-Z, a-z and 0-9."), htmlspecialchars($_POST['pc_' . $id])); + } + elseif ($existsInDifferentDn !== false) { + $messages[] = new htmlStatusMessage('ERROR', sprintf(_('This PC name already exists in %s. Use e.g. %s.'), $existsInDifferentDn[0], $existsInDifferentDn[1])); + } } $pcs[] = $this->fixed_ip[$id]['cn']; @@ -508,9 +509,6 @@ class fixed_ip extends baseModule { $ipError = _("The IP address is already in use."); } $error = ''; - if ($pcError != '') { - $error .= ' ' . $pcError; - } if ($macError != '') { $error .= ' ' . $macError; } @@ -545,6 +543,10 @@ class fixed_ip extends baseModule { $return->addElement(new htmlInputCheckbox('active_add', true)); $return->addElement(new htmlButton('add_ip', 'add.png', true), true); + foreach ($messages as $message) { + $return->addElement($message, true); + } + // add existing host entry if (!empty($this->hostCache)) { $return->addVerticalSpace('20px');