From 207cd984cebe45dac04929371b3071bb8453fe52 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 24 Dec 2016 15:39:02 +0100 Subject: [PATCH] new type API --- lam/lib/modules.inc | 95 ++++++++++++++++------------------ lam/lib/pdf.inc | 2 +- lam/lib/types.inc | 6 +++ lam/lib/upload.inc | 3 +- lam/templates/account/edit.php | 26 +++++----- lam/templates/delete.php | 3 +- 6 files changed, 69 insertions(+), 66 deletions(-) diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index e54bb1b1..35c8173a 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -1,4 +1,6 @@ type = $type; $this->base = $base; @@ -800,7 +797,7 @@ class accountContainer { /** * Returns the accout type of this object (e.g. user, group, host). * - * @return string account type + * @return ConfiguredType account type */ function get_type() { return $this->type; @@ -812,7 +809,7 @@ class accountContainer { */ function continue_main() { if (!empty($_POST['account_randomID']) && ($this->randomID != $_POST['account_randomID'])) { - metaRefresh("../lists/list.php?type=" . $this->type . '&accountEditInvalidID=true'); + metaRefresh("../lists/list.php?type=" . $this->type->getId() . '&accountEditInvalidID=true'); exit(); } $oldPage = $this->current_page; @@ -821,7 +818,7 @@ class accountContainer { $result = array(); $stopProcessing = false; // when set to true, no module options are displayed $errorsOccured = false; - $typeObject = new $this->type(); + $typeObject = $this->type->getBaseType(); $profileLoaded = $this->loadProfileIfRequested(); if ($this->subpage=='') $this->subpage='attributes'; if (isset($_POST['accountContainerReset'])) { @@ -843,30 +840,30 @@ class accountContainer { if (isset($_POST['accountContainerCreateAgain'])) { // open fresh account page unset($_SESSION[$this->base]); - metaRefresh("edit.php?type=" . $this->type . "&suffix=" . $this->dnSuffix); + metaRefresh("edit.php?type=" . $this->type->getId() . "&suffix=" . $this->dnSuffix); exit(); } // reedit account if (isset($_POST['accountContainerBackToEdit'])) { // open fresh account page unset($_SESSION[$this->base]); - metaRefresh("edit.php?type=" . $this->type . "&DN=" . urlencode($this->finalDN)); + metaRefresh("edit.php?type=" . $this->type->getId() . "&DN=" . urlencode($this->finalDN)); exit(); } // back to account list if (isset($_POST['accountContainerBackToList'])) { // Return to account list unset($_SESSION[$this->base]); - metaRefresh("../lists/list.php?type=" . $this->type . '&accountEditBack=true'); + metaRefresh("../lists/list.php?type=" . $this->type->getId() . '&accountEditBack=true'); exit; } // create PDF file if (isset($_POST['accountContainerCreatePDF'])) { - metaRefresh('../lists/list.php?printPDF=1&type=' . $this->type . "&refresh=true&PDFSessionID=" . $this->base); + metaRefresh('../lists/list.php?printPDF=1&type=' . $this->type->getId() . "&refresh=true&PDFSessionID=" . $this->base); exit; } // module actions - if ((sizeof($_POST) > 0) && checkIfWriteAccessIsAllowed($this->type)) { + if ((sizeof($_POST) > 0) && checkIfWriteAccessIsAllowed($this->type->getId())) { $result = call_user_func(array(&$this->module[$this->order[$this->current_page]], 'process_'.$this->subpage)); if (is_array($result)) { // messages were returned, check for errors for ($i = 0; $i < sizeof($result); $i++) { @@ -987,13 +984,13 @@ class accountContainer { } } echo '
'; - echo "type."-bright\" border=0 width=\"100%\" style=\"border-collapse: collapse;\">\n"; - if (checkIfWriteAccessIsAllowed($this->type)) { - echo "type."-bright\">
\n"; + echo "type->getScope()."-bright\" border=0 width=\"100%\" style=\"border-collapse: collapse;\">\n"; + if (checkIfWriteAccessIsAllowed($this->type->getId())) { + echo "type->getScope() . "-bright\">\n"; } - echo "type."-bright\" valign=\"top\">type->getScope() . "-bright\" valign=\"top\">'; echo ''; @@ -1114,9 +1111,9 @@ class accountContainer { if (!(strpos($buttonImage, 'http') === 0) && !(strpos($buttonImage, '/') === 0)) { $buttonImage = '../../graphics/' . $buttonImage; } - $moduleContainer->addElement(new htmlImage($buttonImage, null, null, getModuleAlias($name, $this->type))); + $moduleContainer->addElement(new htmlImage($buttonImage, null, null, getModuleAlias($name, $this->type->getScope()))); } - $moduleContainer->addElement(new htmlTableExtendedInputCheckbox('password_cb_' . $name, true, getModuleAlias($name, $this->type), null, false)); + $moduleContainer->addElement(new htmlTableExtendedInputCheckbox('password_cb_' . $name, true, getModuleAlias($name, $this->type->getScope()), null, false)); $moduleContainer->addElement(new htmlSpacer('10px', null)); } } @@ -1125,7 +1122,7 @@ class accountContainer { // generate HTML $tabindex = 2000; if ($printContainer) { - parseHtml(null, $container, array(), false, $tabindex, $this->type); + parseHtml(null, $container, array(), false, $tabindex, $this->type->getScope()); } echo "\n"; } @@ -1260,7 +1257,7 @@ class accountContainer { $rightGroup = new htmlGroup(); $rightGroup->alignment = htmlElement::ALIGN_RIGHT; // profile selection - $profilelist = getAccountProfiles($this->type); + $profilelist = getAccountProfiles($this->type->getId()); if (sizeof($profilelist) > 0) { $rightGroup->addElement(new htmlSelect('accountContainerSelectLoadProfile', $profilelist, array($this->lastLoadedProfile))); $profileButton = new htmlButton('accountContainerLoadProfile', _('Load profile')); @@ -1275,7 +1272,7 @@ class accountContainer { } $table->addElement($rightGroup); - parseHtml(null, $table, array(), false, $tabindex, $this->type); + parseHtml(null, $table, array(), false, $tabindex, $this->type->getScope()); ?>
\n"; $this->printCommonControls($tabindex); echo "
"; + echo "
"; // print title bar echo '
'; echo ''; @@ -1021,10 +1018,10 @@ class accountContainer { // RDN selection $group->addElement(new htmlOutputText(_('RDN identifier'))); $group->addElement(new htmlSpacer('2px', null)); - $rdnlist = getRDNAttributes($this->type); + $rdnlist = getRDNAttributes($this->type->getId()); $group->addElement(new htmlSelect('accountContainerRDN', $rdnlist, array($this->rdn))); $group->addElement(new htmlHelpLink('301')); - parseHtml(null, $group, array(), true, $tabindex, $this->type); + parseHtml(null, $group, array(), true, $tabindex, $this->type->getScope()); echo ''; echo '
'; if ($this->titleBarSubtitle != null) { @@ -1044,7 +1041,7 @@ class accountContainer { // display html-code from modules $return = call_user_func(array($this->module[$this->order[$this->current_page]], 'display_html_'.$this->subpage)); $y = 5000; - parseHtml($this->order[$this->current_page], $return, array(), false, $y, $this->type); + parseHtml($this->order[$this->current_page], $return, array(), false, $y, $this->type->getScope()); echo "
\n"; echo '