From f9995d7cb6314baabe5f2c8460a21c4d5a529561 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 24 Dec 2016 13:04:31 +0100 Subject: [PATCH 01/43] new type API --- lam/lib/lists.inc | 152 +++++++++++++++------------------- lam/lib/types.inc | 35 ++++++-- lam/lib/types/asteriskExt.inc | 19 ++--- lam/lib/types/dhcp.inc | 16 ++-- lam/lib/types/user.inc | 4 +- lam/templates/lists/list.php | 15 ++-- lam/templates/main.php | 19 +++-- 7 files changed, 137 insertions(+), 123 deletions(-) diff --git a/lam/lib/lists.inc b/lam/lib/lists.inc index 32efcc4e..49b7750a 100644 --- a/lam/lib/lists.inc +++ b/lam/lib/lists.inc @@ -1,4 +1,6 @@ configOptions) > 0) { - if (isset($_COOKIE["ListOptions_" . $this->type])) { - $cookieValue = $_COOKIE["ListOptions_" . $this->type]; + if (isset($_COOKIE["ListOptions_" . $this->type->getId()])) { + $cookieValue = $_COOKIE["ListOptions_" . $this->type->getId()]; $valueParts = explode(";", $cookieValue); $values = array(); for ($i = 0; $i < sizeof($valueParts); $i++) { @@ -172,7 +174,7 @@ class lamList { // show form echo "
"; echo "
\n"; - echo ("
type . "&norefresh=true\" method=\"post\">\n"); + echo ("type->getId() . "&norefresh=true\" method=\"post\">\n"); // draw account list if accounts were found if (sizeof($this->entries) > 0) { // buttons @@ -289,12 +291,12 @@ class lamList { if ($count > $this->maxPageEntries) { echo(""); if ($this->page != 1) { - echo("type . "&norefresh=true&page=1" . + echo("type->getId() . "&norefresh=true&page=1" . "&sort=" . $this->sortColumn . "&sortdirection=" . $this->sortDirection . $filter . "\">" . "\"\"\n"); } if ($this->page > 11) { - echo("type . "&norefresh=true&page=" . ($this->page - 10) . + echo("type->getId() . "&norefresh=true&page=" . ($this->page - 10) . "&sort=" . $this->sortColumn . "&sortdirection=" . $this->sortDirection . $filter . "\">" . "\"\"\n"); } @@ -307,24 +309,24 @@ class lamList { continue; } if ($i == $this->page - 1) { - $url = "list.php?type=" . $this->type . "&norefresh=true" . + $url = "list.php?type=" . $this->type->getId() . "&norefresh=true" . "&sort=" . $this->sortColumn . "&sortdirection=" . $this->sortDirection . $filter; echo ''; } else { - echo " type . "&norefresh=true&page=" . ($i + 1) . + echo " type->getId() . "&norefresh=true&page=" . ($i + 1) . "&sort=" . $this->sortColumn . "&sortdirection=" . $this->sortDirection . $filter . "\">" . ($i + 1) . "\n"; } } if ($this->page < ($pageCount - 10)) { - echo("type . "&norefresh=true&page=" . ($this->page + 10) . + echo("type->getId() . "&norefresh=true&page=" . ($this->page + 10) . "&sort=" . $this->sortColumn . "&sortdirection=" . $this->sortDirection . $filter . "\">" . "\"\"\n"); } if ($this->page < $pageCount) { - echo("type . "&norefresh=true&page=" . $pageCount . + echo("type->getId() . "&norefresh=true&page=" . $pageCount . "&sort=" . $this->sortColumn . "&sortdirection=" . $this->sortDirection . $filter . "\">" . "\"\"\n"); } @@ -352,8 +354,8 @@ class lamList { protected function listPrintTableHeader() { $filter = $this->getFilterAsTextForURL(); // print table header - echo "type . "-border collapse accountlist ui-corner-all\" width=\"100%\">\n"; - echo "type . "-dark\">\n"; + echo "
type->getScope() . "-border collapse accountlist ui-corner-all\" width=\"100%\">\n"; + echo "type->getScope() . "-dark\">\n"; echo "\n"; echo "\n"; @@ -364,17 +366,17 @@ class lamList { if ($this->sortDirection < 0) { $sortImage = "sort_desc.png"; } - echo "\n"; } - else echo "\n"; } echo "\n"; // print filter row - echo "type . "-bright\">\n"; + echo "type->getScope() . "-bright\">\n"; echo "\n"; @@ -389,7 +391,7 @@ class lamList { $clearFilterButton->setTitle(_('Clear filter')); $filterGroup->addElement($clearFilterButton); } - parseHtml(null, $filterGroup, array(), false, $this->tabindex, $this->type); + parseHtml(null, $filterGroup, array(), false, $this->tabindex, $this->type->getScope()); echo "\n"; // print input boxes for filters for ($k = 0; $k < sizeof($this->descArray); $k++) { @@ -416,10 +418,10 @@ class lamList { } } $filterInput = new htmlInputField('filter' . strtolower($attrName), $value); - $filterInput->setCSSClasses(array($this->type . '-dark')); + $filterInput->setCSSClasses(array($this->type->getScope() . '-dark')); $filterInput->setFieldSize('15'); $filterInput->setOnKeyPress("SubmitForm('apply_filter', event);"); - parseHtml(null, $filterInput, array(), false, $this->tabindex, $this->type); + parseHtml(null, $filterInput, array(), false, $this->tabindex, $this->type->getScope()); } /** @@ -459,14 +461,14 @@ class lamList { $index = $sortMapping[$i]; $rowID = base64_encode($info[$index]['dn']); if ((($i - $table_begin) % 2) == 1) { - $classes = ' ' . $this->type . '-bright'; + $classes = ' ' . $this->type->getScope() . '-bright'; } else { - $classes = ' ' . $this->type . '-dark'; + $classes = ' ' . $this->type->getScope() . '-dark'; } echo("type . "&DN=" . rawurlencode($info[$index]['dn']) . "'\">\n"); + " onDblClick=\"top.location.href='../account/edit.php?type=" . $this->type->getId() . "&DN=" . rawurlencode($info[$index]['dn']) . "'\">\n"); echo " \n"; $this->listPrintToolLinks($info[$index], $rowID); @@ -480,7 +482,7 @@ class lamList { } // display select all link $colspan = sizeof($this->attrArray) + 1; - echo "type . "-bright\">\n"; + echo "type->getScope() . "-bright\">\n"; echo "\n"; echo "\n"; @@ -499,13 +501,13 @@ class lamList { $toolCount = 0; $group = new htmlGroup(); // edit link - $editLink = new htmlLink('', "../account/edit.php?type=" . $this->type . "&DN='" . rawurlencode($account['dn']) . "'", '../../graphics/edit.png'); + $editLink = new htmlLink('', "../account/edit.php?type=" . $this->type->getId() . "&DN='" . rawurlencode($account['dn']) . "'", '../../graphics/edit.png'); $editLink->setTitle(_("Edit")); $group->addElement($editLink); $toolCount++; // delete link - if (checkIfWriteAccessIsAllowed($this->type) && checkIfDeleteEntriesIsAllowed($this->type)) { - $deleteLink = new htmlLink('', "deletelink.php?type=" . $this->type . "&DN='" . rawurlencode($account['dn']) . "'", '../../graphics/delete.png'); + if (checkIfWriteAccessIsAllowed($this->type->getId()) && checkIfDeleteEntriesIsAllowed($this->type->getId())) { + $deleteLink = new htmlLink('', "deletelink.php?type=" . $this->type->getId() . "&DN='" . rawurlencode($account['dn']) . "'", '../../graphics/delete.png'); $deleteLink->setTitle(_("Delete")); $group->addElement($deleteLink); $toolCount++; @@ -518,14 +520,14 @@ class lamList { // additional tools $tools = $this->getAdditionalTools(); for ($i = 0; $i < sizeof($tools); $i++) { - $toolLink = new htmlLink('', $tools[$i]->getLinkTarget() . "?type=" . $this->type . "&DN='" . rawurlencode($account['dn']) . "'", '../../graphics/' . $tools[$i]->getImage()); + $toolLink = new htmlLink('', $tools[$i]->getLinkTarget() . "?type=" . $this->type->getId() . "&DN='" . rawurlencode($account['dn']) . "'", '../../graphics/' . $tools[$i]->getImage()); $toolLink->setTitle($tools[$i]->getName()); $group->addElement($toolLink); $toolCount++; } $width = ($toolCount * 20) + 20; echo "\n"; } @@ -560,16 +562,16 @@ class lamList { } // check if button was pressed and if we have to add/delete an account or call file upload if (isset($_POST['new']) || isset($_POST['del']) || isset($_POST['fileUpload'])){ - if (!checkIfWriteAccessIsAllowed($this->type)) { + if (!checkIfWriteAccessIsAllowed($this->type->getId())) { die(); } // add new account - if (isset($_POST['new']) && checkIfNewEntriesAreAllowed($this->type)){ - metaRefresh("../account/edit.php?type=" . $this->type . "&suffix=" . $this->suffix); + if (isset($_POST['new']) && checkIfNewEntriesAreAllowed($this->type->getId())){ + metaRefresh("../account/edit.php?type=" . $this->type->getId() . "&suffix=" . $this->suffix); exit; } // delete account(s) - elseif (isset($_POST['del']) && checkIfDeleteEntriesIsAllowed($this->type)){ + elseif (isset($_POST['del']) && checkIfDeleteEntriesIsAllowed($this->type->getId())){ // search for checkboxes $accounts = array_keys($_POST, "on"); // build DN list @@ -578,13 +580,13 @@ class lamList { $_SESSION['delete_dn'][] = base64_decode($accounts[$i]); } if (sizeof($accounts) > 0) { - metaRefresh("../delete.php?type=" . $this->type); + metaRefresh("../delete.php?type=" . $this->type->getId()); exit; } } // file upload - elseif (isset($_POST['fileUpload']) && checkIfNewEntriesAreAllowed($this->type)){ - metaRefresh("../upload/masscreate.php?type=" . $this->type); + elseif (isset($_POST['fileUpload']) && checkIfNewEntriesAreAllowed($this->type->getId())){ + metaRefresh("../upload/masscreate.php?type=" . $this->type->getId()); exit; } } @@ -662,7 +664,7 @@ class lamList { $cookieValue .= $this->configOptions[$i]->getID() . "=" . $this->configOptions[$i]->getValue() . ';'; } // save options as cookie for one year - setcookie("ListOptions_" . $this->type, $cookieValue, time()+60*60*24*365, "/", null, null, true); + setcookie("ListOptions_" . $this->type->getId(), $cookieValue, time()+60*60*24*365, "/", null, null, true); // notify subclasses $this->listConfigurationChanged(); } @@ -688,17 +690,17 @@ class lamList { $selAccounts[] = $id; } // get possible PDF structures - $pdf_structures = getPDFStructureDefinitions($this->type); + $pdf_structures = getPDFStructureDefinitions($this->type->getId()); $this->listPrintHeader(); - echo "
type . "-bright\">"; + echo "
type->getScope() . "-bright\">"; echo "
\n"; $refresh = '&norefresh=true'; if (isset($_GET['refresh']) && ($_GET['refresh'] == 'true')) { $refresh = '&refresh=true'; } - echo "type . $refresh . "\" method=\"post\">\n"; + echo "type->getId() . $refresh . "\" method=\"post\">\n"; $container = new htmlTable(); $container->addElement(new htmlSubTitle(_('Create PDF file')), true); @@ -735,7 +737,7 @@ class lamList { $container->addElement(new htmlHiddenInput('clickedAccount', $id)); addSecurityTokenToMetaHTML($container); - parseHtml(null, $container, array(), false, $this->tabindex, $this->type); + parseHtml(null, $container, array(), false, $this->tabindex, $this->type->getScope()); $this->listPrintFooter(); } @@ -753,7 +755,7 @@ class lamList { $suffixList[getAbstractDN($this->possibleSuffixes[$i])] = $this->possibleSuffixes[$i]; } $suffixSelect = new htmlSelect('suffix', $suffixList, array($this->suffix)); - $suffixSelect->setOnchangeEvent("listOUchanged('" . $this->type . "', this)"); + $suffixSelect->setOnchangeEvent("listOUchanged('" . $this->type->getId() . "', this)"); $suffixSelect->setRightToLeftTextDirection(true); $suffixSelect->setSortElements(false); $suffixSelect->setHasDescriptiveElements(true); @@ -774,23 +776,22 @@ class lamList { $left = new htmlGroup(); // button part $left->alignment = htmlElement::ALIGN_LEFT; - if (checkIfWriteAccessIsAllowed($this->type)) { + if (checkIfWriteAccessIsAllowed($this->type->getId())) { // add button - if (checkIfNewEntriesAreAllowed($this->type)) { + if (checkIfNewEntriesAreAllowed($this->type->getId())) { $newButton = new htmlButton('new', $this->labels['newEntry']); $newButton->setIconClass('createButton'); $left->addElement($newButton); } // delete button - if (!$createOnly && checkIfDeleteEntriesIsAllowed($this->type)) { + if (!$createOnly && checkIfDeleteEntriesIsAllowed($this->type->getId())) { $left->addElement(new htmlSpacer('1px', null)); $delButton = new htmlButton('del', $this->labels['deleteEntry']); $delButton->setIconClass('deleteButton'); $left->addElement($delButton); } - $type = new $this->type(); $toolSettings = $_SESSION['config']->getToolSettings(); - if ($type->supportsFileUpload() && checkIfNewEntriesAreAllowed($this->type) + if ($this->type->getBaseType()->supportsFileUpload() && checkIfNewEntriesAreAllowed($this->type->getId()) && !(isset($toolSettings['tool_hide_toolFileUpload']) && ($toolSettings['tool_hide_toolFileUpload'] == 'true'))) { $left->addElement(new htmlSpacer('20px', null)); $uploadButton = new htmlButton('fileUpload', _('File upload')); @@ -815,7 +816,7 @@ class lamList { $this->addExtraInputElementsToTopArea($left, $right); $table->addElement($left); $table->addElement($right); - parseHtml(null, $table, array(), false, $this->tabindex, $this->type); + parseHtml(null, $table, array(), false, $this->tabindex, $this->type->getScope()); } /** @@ -844,8 +845,8 @@ class lamList {
diff --git a/lam/templates/upload/masscreate.php b/lam/templates/upload/masscreate.php index 9fad8e51..6b29a4eb 100644 --- a/lam/templates/upload/masscreate.php +++ b/lam/templates/upload/masscreate.php @@ -1,9 +1,28 @@ get_ActiveTypes(); +$typeManager = new \LAM\TYPES\TypeManager(); +$types = $typeManager->getConfiguredTypes(); $count = sizeof($types); for ($i = 0; $i < $count; $i++) { - $myType = new $types[$i](); - if (!$myType->supportsFileUpload() || isAccountTypeHidden($types[$i]) - || !checkIfNewEntriesAreAllowed($types[$i]) || !checkIfWriteAccessIsAllowed($types[$i])) { + $myType = $types[$i]; + if (!$myType->getBaseType()->supportsFileUpload() || $myType->isHidden() + || !checkIfNewEntriesAreAllowed($myType->getId()) || !checkIfWriteAccessIsAllowed($myType->getId())) { unset($types[$i]); } } @@ -93,26 +113,27 @@ $types = array_values($types); // check if account specific page should be shown if (isset($_POST['type'])) { // get selected type - $scope = htmlspecialchars($_POST['type']); + $typeId = htmlspecialchars($_POST['type']); + $type = $typeManager->getConfiguredType($typeId); // get selected modules $selectedModules = array(); $checkedBoxes = array_keys($_POST, 'on'); for ($i = 0; $i < sizeof($checkedBoxes); $i++) { - if (strpos($checkedBoxes[$i], $scope . '_') === 0) { - $selectedModules[] = substr($checkedBoxes[$i], strlen($scope) + 1); + if (strpos($checkedBoxes[$i], $typeId . '___') === 0) { + $selectedModules[] = substr($checkedBoxes[$i], strlen($typeId) + strlen('___')); } } - $deps = getModulesDependencies($scope); + $deps = getModulesDependencies($type->getScope()); $depErrors = check_module_depends($selectedModules, $deps); if (is_array($depErrors) && (sizeof($depErrors) > 0)) { for ($i = 0; $i < sizeof($depErrors); $i++) { StatusMessage('ERROR', _("Unsolved dependency:") . ' ' . - getModuleAlias($depErrors[$i][0], $scope) . " (" . - getModuleAlias($depErrors[$i][1], $scope) . ")"); + getModuleAlias($depErrors[$i][0], $type->getScope()) . " (" . + getModuleAlias($depErrors[$i][1], $type->getScope()) . ")"); } } else { - showMainPage($scope, $selectedModules); + showMainPage($type, $selectedModules); exit; } } @@ -120,7 +141,7 @@ if (isset($_POST['type'])) { // show start page $divClass = 'user'; if (isset($_REQUEST['type'])) { - $divClass = $_REQUEST['type']; + $divClass = \LAM\TYPES\getScopeFromTypeId($_REQUEST['type']); } echo '
'; echo "
\n"; @@ -141,15 +162,15 @@ $table = new htmlTable(); // account type $typeList = array(); -for ($i = 0; $i < sizeof($types); $i++) { - $typeList[LAM\TYPES\getTypeAlias($types[$i])] = $types[$i]; +foreach ($types as $type) { + $typeList[$type->getAlias()] = $type->getId(); } $selectedType = array(); if (isset($_REQUEST['type'])) { $selectedType[] = $_REQUEST['type']; } elseif (!empty($types)) { - $selectedType[] = $types[0]; + $selectedType[] = $types[0]->getId(); } $typeSelect = new htmlTableExtendedSelect('type', $typeList, $selectedType, _("Account type")); $typeSelect->setHasDescriptiveElements(true); @@ -162,32 +183,32 @@ $moduleLabel = new htmlOutputText(_('Selected modules')); $moduleLabel->alignment = htmlElement::ALIGN_TOP; $table->addElement($moduleLabel); $moduleGroup = new htmlGroup(); -for ($i = 0; $i < sizeof($types); $i++) { +foreach ($types as $type) { $divClasses = array('typeOptions'); - if ((!isset($_REQUEST['type']) && ($i != 0)) || (isset($_REQUEST['type']) && ($_REQUEST['type'] != $types[$i]))) { + if ((!isset($_REQUEST['type']) && ($i != 0)) || (isset($_REQUEST['type']) && ($_REQUEST['type'] != $type->getId()))) { $divClasses[] = 'hidden'; } $innerTable = new htmlTable(); - $modules = $_SESSION['config']->get_AccountModules($types[$i]); + $modules = $_SESSION['config']->get_AccountModules($type->getId()); for ($m = 0; $m < sizeof($modules); $m++) { if (($m != 0) && ($m%3 == 0)) { echo $innerTable->addNewLine(); } - $module = moduleCache::getModule($modules[$m], $types[$i]); + $module = moduleCache::getModule($modules[$m], $type->getScope()); $iconImage = $module->getIcon(); if (!is_null($iconImage) && !(strpos($iconImage, 'http') === 0) && !(strpos($iconImage, '/') === 0)) { $iconImage = '../../graphics/' . $iconImage; } $innerTable->addElement(new htmlImage($iconImage)); $enabled = true; - if (is_base_module($modules[$m], $types[$i])) { + if (is_base_module($modules[$m], $type->getScope())) { $enabled = false; } $checked = true; - if (isset($_POST['submit']) && !isset($_POST[$types[$i] . '_' . $modules[$m]])) { + if (isset($_POST['submit']) && !isset($_POST[$type->getId() . '___' . $modules[$m]])) { $checked = false; } - $checkbox = new htmlTableExtendedInputCheckbox($types[$i] . '_' . $modules[$m], $checked, getModuleAlias($modules[$m], $types[$i]), null, false); + $checkbox = new htmlTableExtendedInputCheckbox($type->getId() . '___' . $modules[$m], $checked, getModuleAlias($modules[$m], $type->getScope()), null, false); $checkbox->setIsEnabled($enabled); if ($enabled) { $innerTable->addElement($checkbox); @@ -196,12 +217,12 @@ for ($i = 0; $i < sizeof($types); $i++) { $boxGroup = new htmlGroup(); $boxGroup->addElement($checkbox); // add hidden field to fake disabled checkbox value - $boxGroup->addElement(new htmlHiddenInput($types[$i] . '_' . $modules[$m], 'on')); + $boxGroup->addElement(new htmlHiddenInput($type->getId() . '___' . $modules[$m], 'on')); $innerTable->addElement($boxGroup); } $innerTable->addElement(new htmlSpacer('10px', null)); } - $typeDiv = new htmlDiv($types[$i], $innerTable); + $typeDiv = new htmlDiv($type->getId(), $innerTable); $typeDiv->setCSSClasses($divClasses); $moduleGroup->addElement($typeDiv); } @@ -231,10 +252,11 @@ include '../main_footer.php'; /** * Displays the acount type specific main page of the upload. * -* @param string $scope account type +* @param \LAM\TYPES\ConfiguredType $type account type * @param array $selectedModules list of selected account modules */ -function showMainPage($scope, $selectedModules) { +function showMainPage($type, $selectedModules) { + $scope = $type->getScope(); echo '
'; // get input fields from modules $columns = getUploadColumns($scope, $selectedModules); @@ -257,7 +279,7 @@ function showMainPage($scope, $selectedModules) { $inputContainer->addElement(new htmlInputFileUpload('inputfile')); $inputContainer->addElement(new htmlSpacer('10px', null)); $inputContainer->addElement(new htmlLink(_("Download sample CSV file"), 'masscreate.php?getCSV=1', '../../graphics/save.png', true)); - $inputContainer->addElement(new htmlHiddenInput('scope', $scope)); + $inputContainer->addElement(new htmlHiddenInput('typeId', $type->getId())); $inputContainer->addElement(new htmlHiddenInput('selectedModules', implode(',', $selectedModules)), true); // PDF $createPDF = false; @@ -267,7 +289,7 @@ function showMainPage($scope, $selectedModules) { $pdfCheckbox = new htmlTableExtendedInputCheckbox('createPDF', $createPDF, _('Create PDF files')); $pdfCheckbox->setTableRowsToShow(array('pdfStructure')); $inputContainer->addElement($pdfCheckbox, true); - $pdfStructures = \LAM\PDF\getPDFStructures($scope); + $pdfStructures = \LAM\PDF\getPDFStructures($type->getId()); $pdfSelected = array(); if (isset($_POST['pdfStructure'])) { $pdfSelected = array($_POST['pdfStructure']); @@ -321,9 +343,9 @@ function showMainPage($scope, $selectedModules) { $dnSuffixRowCells[] = $columnSpacer; $dnSuffixRowCells[] = new htmlOutputText('dn_suffix'); $dnSuffixRowCells[] = $columnSpacer; - $dnSuffixRowCells[] = new htmlOutputText($_SESSION['config']->get_Suffix($scope)); + $dnSuffixRowCells[] = new htmlOutputText($type->getSuffix()); $dnSuffixRowCells[] = $columnSpacer; - $dnSuffixRowCells[] = new htmlOutputText($_SESSION['config']->get_Suffix($scope)); + $dnSuffixRowCells[] = new htmlOutputText($type->getSuffix()); $dnSuffixRowCells[] = $columnSpacer; $dnSuffixRowCells[] = new htmlOutputText(''); $dnSuffixRowCells[] = new htmlSpacer(null, '25px'); @@ -340,7 +362,7 @@ function showMainPage($scope, $selectedModules) { $dnRDNRowCells[] = $columnSpacer; $dnRDNRowCells[] = new htmlOutputText('dn_rdn'); $dnRDNRowCells[] = $columnSpacer; - $rdnAttributes = getRDNAttributes($scope, $selectedModules); + $rdnAttributes = getRDNAttributes($type->getId(), $selectedModules); $dnRDNRowCells[] = new htmlOutputText($rdnAttributes[0]); $dnRDNRowCells[] = $columnSpacer; $dnRDNRowCells[] = new htmlOutputText(''); @@ -456,9 +478,9 @@ function showMainPage($scope, $selectedModules) { $sampleCSV_head[] = "\"" . $columns[$modules[$m]][$i]['name'] . "\""; } } - $RDNs = getRDNAttributes($scope, $selectedModules); + $RDNs = getRDNAttributes($type->getId(), $selectedModules); // DN attributes - $sampleCSV_row[] = "\"" . $_SESSION['config']->get_Suffix($scope) . "\""; + $sampleCSV_row[] = "\"" . $type->getSuffix() . "\""; $sampleCSV_row[] = "\"" . $RDNs[0] . "\""; // module attributes for ($m = 0; $m < sizeof($modules); $m++) { From 84f2b4392318421fb0e4564adf6003b118e00b7f Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 7 Jan 2017 18:39:40 +0100 Subject: [PATCH 39/43] new type API for delete --- lam/templates/delete.php | 44 +++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/lam/templates/delete.php b/lam/templates/delete.php index 4078836b..4b299ebd 100644 --- a/lam/templates/delete.php +++ b/lam/templates/delete.php @@ -1,10 +1,11 @@ getConfiguredType($_POST['type']) == null)) { logNewMessage(LOG_ERR, 'Invalid type: ' . $_POST['type']); die(); } if (isset($_GET['type']) && isset($_SESSION['delete_dn'])) { - if (!preg_match('/^[a-z0-9_]+$/i', $_GET['type'])) { - logNewMessage(LOG_ERR, 'Invalid type: ' . $_GET['type']); + $typeId = $_GET['type']; + $type = $typeManager->getConfiguredType($typeId); + if ($type == null) { + logNewMessage(LOG_ERR, 'Invalid type: ' . $type->getId()); die(); } - if (!checkIfDeleteEntriesIsAllowed($_GET['type']) || !checkIfWriteAccessIsAllowed($_GET['type'])) { - logNewMessage(LOG_ERR, 'User tried to delete entries of forbidden type '. $_GET['type']); + if (!checkIfDeleteEntriesIsAllowed($type->getId()) || !checkIfWriteAccessIsAllowed($type->getId())) { + logNewMessage(LOG_ERR, 'User tried to delete entries of forbidden type '. $type->getId()); die(); } // Create account list @@ -88,15 +93,14 @@ if (isset($_GET['type']) && isset($_SESSION['delete_dn'])) { } //load account - $typeManager = new LAM\TYPES\TypeManager(); - $_SESSION['account'] = new accountContainer($typeManager->getConfiguredType($_GET['type']), 'account'); + $_SESSION['account'] = new \accountContainer($type, 'account'); // Show HTML Page include 'main_header.php'; - echo "
"; + echo "
getScope() . "-bright smallPaddingContent\">"; echo "
\n"; echo "
\n"; echo ''; - echo "\n"; + echo "getId() . "\">\n"; echo "" . _("Do you really want to remove the following accounts?") . ""; echo "

\n"; echo "
\"select " . "" . _("Select all") . "type . "&". + echo "type->getId() . "&". "sort=" . strtolower($this->attrArray[$k]) . $filter . "&norefresh=y" . "\">" . $this->descArray[$k] . " \"sorttype . "&". + else echo "type->getId() . "&". "sort=" . strtolower($this->attrArray[$k]) . $filter . "&norefresh=y" . "\">" . $this->descArray[$k] . "
"; printHelpLink(getHelp('', '250'), '250'); echo "
\"select " . "" . _("Select all") . ""; - parseHtml(null, $group, array(), false, $this->tabindex, $this->type); + parseHtml(null, $group, array(), false, $this->tabindex, $this->type->getScope()); echo "
\n"; @@ -117,12 +121,12 @@ if (isset($_GET['type']) && isset($_SESSION['delete_dn'])) { echo "
\n"; // Print delete rows from modules echo "
\n
"; - $modules = $_SESSION['config']->get_AccountModules($_GET['type']); + $modules = $_SESSION['config']->get_AccountModules($type->getId()); $values = array(); $tabindex = 100; foreach ($modules as $module) { - $module = moduleCache::getModule($module, $_GET['type']); - parseHtml(get_class($module), $module->display_html_delete(), $values, true, $tabindex, $_GET['type']); + $module = \moduleCache::getModule($module, $type->getScope()); + parseHtml(get_class($module), $module->display_html_delete(), $values, true, $tabindex, $type->getScope()); } echo "
\n"; echo "
\n"; @@ -131,7 +135,7 @@ if (isset($_GET['type']) && isset($_SESSION['delete_dn'])) { echo "\n"; echo "
\n"; ?> -