From 691ccbc477496de55f0ee2488cd27e3d440f189f Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 20 Nov 2018 19:18:23 +0100 Subject: [PATCH] responsive delete page --- lam/graphics/cancel.png | Bin 0 -> 730 bytes lam/lib/baseModule.inc | 2 +- lam/lib/html.inc | 31 +++++++++- lam/lib/modules/posixAccount.inc | 10 +-- lam/style/500_layout.css | 2 +- lam/templates/delete.php | 101 ++++++++++++++++--------------- 6 files changed, 87 insertions(+), 59 deletions(-) create mode 100644 lam/graphics/cancel.png diff --git a/lam/graphics/cancel.png b/lam/graphics/cancel.png new file mode 100644 index 0000000000000000000000000000000000000000..a198c69fe70ddd9394b5c898fbbd7f21d1f3112e GIT binary patch literal 730 zcmV<00ww*4P)5){MiyNH`o5G@oL1gX$pFqG1j|G{6;Md>O+ zp{s&R%`S<%iArV>5uIW;G0>)ql5_7&H%4q4efQ5focB2#ciG$9t2CRKiIaNL{Sti8WM)#uIG8*7-KtyLgDc8@^Z{)@YdFr zzp}Ezq?Cbann}Ok|7S=ThP$;|?ZEea%`{C*N*NT3#Y0Ug_1tlsRUrh32+d}b6Vb;s zP0?z#J_AT+aHG-ChzLtdODGnLb;j5$-s|-)Y}-zxl!5EIjEGP!mzh#3a2zLDTU%?? z>-E+Qo=&G24u`7S?d~5RAAjKhvM7oo(=-#MR8TIL84Ccp<2Xs0rh#QyY&xCdDHs6Q zoT=0>jNeKrJcNk|N-5~N{u98D8GQc-4^_<2=w5Sy;+UJnL?d&PX-^L%0B z@i;RKgAoyg5R7vkRIAk_j^hYG#-D;aozDL4?d>-q#HJ8}NhzW0I?Ls9f#-Qi9LEt4 z!|=7|d0&0sU#Mz093Hu@d(AlybX{ivkk99trfET?Qi*w^(fGqT-!Vv+iEZv zMAd3F$>nlEKA&ewDU3#=o0F511Acyf{;Ntype = $type; $this->title = $title; $this->text = $text; $this->params = $params; } + /** + * Constructor with parameter array. + * + * @param array $params parameters in same order as normal constructor + * @return htmlStatusMessage + */ + public static function fromParamArray($params) { + if (sizeof($params) < 2) { + throw new BadMethodCallException("Invalid parameter count"); + } + + $count = count($params); + switch ($count) { + case 2: + return new htmlStatusMessage($params[0], $params[1]); + break; + case 3: + return new htmlStatusMessage($params[0], $params[1], $params[2]); + break; + case 4: + return new htmlStatusMessage($params[0], $params[1], $params[2], $params[3]); + break; + default: + throw new BadMethodCallException("Invalid parameter count"); + } + } + /** * Prints the HTML code for this element. * @@ -3018,7 +3045,7 @@ class htmlStatusMessage extends htmlElement { * @param string $scope Account 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) { StatusMessage($this->type, $this->title, $this->text, $this->params); return array(); } diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index 5ed738eb..7dfc63fd 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -1752,18 +1752,14 @@ class posixAccount extends baseModule implements passwordService { * @return htmlElement meta HTML code */ function display_html_delete() { - $return = null; + $return = new htmlResponsiveRow(); if ($this->get_scope() == 'user' && ($_SESSION['config']->get_scriptPath() != null)) { - $return = new htmlTable(); - $return->addElement(new htmlTableExtendedInputCheckbox('deletehomedir', true, _('Delete home directory'), 'deletehomedir'), true); + $return->add(new htmlResponsiveInputCheckbox('deletehomedir', true, _('Delete home directory'), 'deletehomedir'), 12); } $typeManager = new TypeManager(); $sudoTypes = $typeManager->getConfiguredTypesForScope('sudo'); if (($this->get_scope() == 'user') && !empty($sudoTypes)) { - if ($return == null) { - $return = new htmlTable(); - } - $return->addElement(new htmlTableExtendedInputCheckbox('deleteSudoers', true, _('Delete sudo rights'), 'deleteSudoers'), true); + $return->add(new htmlResponsiveInputCheckbox('deleteSudoers', true, _('Delete sudo rights'), 'deleteSudoers'), 12); } return $return; } diff --git a/lam/style/500_layout.css b/lam/style/500_layout.css index 790a67df..c598bc14 100644 --- a/lam/style/500_layout.css +++ b/lam/style/500_layout.css @@ -272,7 +272,7 @@ table.collapse { } .cancelButton { - background-image: url(../graphics/del.png) !important; + background-image: url(../graphics/cancel.png) !important; background-position: 0px 0px !important; } diff --git a/lam/templates/delete.php b/lam/templates/delete.php index d336b038..1d871e0c 100644 --- a/lam/templates/delete.php +++ b/lam/templates/delete.php @@ -1,11 +1,17 @@ getScope() . "-bright smallPaddingContent\">"; echo "
\n"; echo "
\n"; - echo ''; - echo "getId() . "\">\n"; - echo "" . _("Do you really want to remove the following accounts?") . ""; - echo "

\n"; - echo "\n"; + $tabindex = 1; + $container = new htmlResponsiveRow(); + $container->add(new htmlOutputText(_("Do you really want to remove the following accounts?")), 12); + $container->addVerticalSpacer('2rem'); $userCount = sizeof($users); for ($i = 0; $i < $userCount; $i++) { - echo "\n"; - echo "\n"; - echo "\n"; + $container->addLabel(new htmlOutputText(_("Account name:"))); + $container->addField(new htmlOutputText($users[$i])); + $container->addLabel(new htmlOutputText(_('DN') . ':')); + $container->addField(new htmlOutputText($_SESSION['delete_dn'][$i])); $_SESSION['account']->load_account($_SESSION['delete_dn'][$i]); if (!$_SESSION['account']->hasOnlyVirtualChildren()) { $childCount = getChildCount($_SESSION['delete_dn'][$i]); if ($childCount > 0) { - echo "\n"; + $container->addLabel(new htmlOutputText(_('Number of child entries') . ':')); + $container->addField(new htmlOutputText($childCount)); } } - echo "\n"; } - echo "
" . _("Account name:") . " " . htmlspecialchars($users[$i]) . "  " . _('DN') . ": " . htmlspecialchars($_SESSION['delete_dn'][$i]) . "  " . _('Number of child entries') . ": " . $childCount . "
\n"; - echo "
\n"; + addSecurityTokenToMetaHTML($container); + $container->add(new htmlHiddenInput('type', $type->getId()), 12); + $container->addVerticalSpacer('1rem'); + parseHtml(null, $container, array(), false, $tabindex, $type->getScope()); // Print delete rows from modules - echo "\n
"; $modules = $_SESSION['config']->get_AccountModules($type->getId()); $values = array(); - $tabindex = 100; foreach ($modules as $module) { $module = \moduleCache::getModule($module, $type->getScope()); parseHtml(get_class($module), $module->display_html_delete(), $values, true, $tabindex, $type->getScope()); } - echo "
\n"; - echo "
\n"; - echo " \n"; - echo "\n"; + $buttonContainer = new htmlResponsiveRow(); + $buttonContainer->addVerticalSpacer('1rem'); + $buttonGroup = new htmlGroup(); + $delButton = new htmlButton('delete', _('Delete')); + $delButton->setIconClass('deleteButton'); + $buttonGroup->addElement($delButton); + $buttonGroup->addElement(new htmlSpacer('0.5rem', null)); + $cancelButton = new htmlButton('cancel', _('Cancel')); + $cancelButton->setIconClass('cancelButton'); + $buttonGroup->addElement($cancelButton); + $buttonContainer->add($buttonGroup, 12); + $buttonContainer->addVerticalSpacer('1rem'); + parseHtml(null, $buttonContainer, array(), false, $tabindex, $type->getScope()); echo "
\n"; echo "\n"; - ?> - - \n"; - echo ''; - echo "getId() . "\">\n"; echo "
getScope() . "-bright smallPaddingContent\">
\n"; - echo "
\n"; + $container = new htmlResponsiveRow(); + addSecurityTokenToMetaHTML($container); + $container->add(new htmlHiddenInput('type', $type->getId()), 12); // Delete dns $allOk = true; @@ -289,41 +296,39 @@ if (isset($_POST['delete'])) { } } if (!$stopprocessing) { - echo sprintf(_('Deleted DN: %s'), $deleteDN) . "
\n"; + $container->add(new htmlOutputText(sprintf(_('Deleted DN: %s'), $deleteDN)), 12); foreach ($errors as $error) { - call_user_func_array('StatusMessage', $error); + $container->add(htmlStatusMessage::fromParamArray($error), 12); } - echo "
\n"; - flush(); } else { - echo sprintf(_('Error while deleting DN: %s'), $deleteDN) . "
\n"; + $container->add(new htmlOutputText(sprintf(_('Error while deleting DN: %s'), $deleteDN)), 12); foreach ($errors as $error) { - call_user_func_array('StatusMessage', $error); + $container->add(htmlStatusMessage::fromParamArray($error), 12); } - echo "
\n"; } $allErrors = array_merge($allErrors, $errors); } - echo "
\n"; - echo "
\n"; - echo "
\n"; + $container->addVerticalSpacer('2rem'); + $buttonName = $allOk ? 'cancelAllOk' : 'cancel'; + $container->add(new htmlButton($buttonName, _('Back to list')), 12); + $container->addVerticalSpacer('1rem'); + parseHtml(null, $container, array(), false, $tabindex, $type->getScope()); echo "
\n"; echo "\n"; ?>