server()) { metaRefresh("../login.php"); exit; } // copy type and profile name from POST to GET if (isset($_POST['profname'])) { $_GET['edit'] = $_POST['profname']; } if (isset($_POST['accounttype'])) { $_GET['type'] = $_POST['accounttype']; } $typeManager = new \LAM\TYPES\TypeManager(); $type = $typeManager->getConfiguredType($_GET['type']); if ($type->isHidden() || !checkIfWriteAccessIsAllowed($_GET['type'])) { logNewMessage(LOG_ERR, 'User tried to access hidden account type profile: ' . $_GET['type']); die(); } // abort button was pressed // back to profile editor if (isset($_POST['abort'])) { metaRefresh("profilemain.php"); exit; } $errors = array(); // save button was presed if (isset($_POST['save'])) { // create option array to check and save $options = array(); $opt_keys = array_keys($_SESSION['profile_types']); foreach ($opt_keys as $element) { // text fields if ($_SESSION['profile_types'][$element] == "text") { $options[$element] = array($_POST[$element]); } // checkboxes elseif ($_SESSION['profile_types'][$element] == "checkbox") { if (isset($_POST[$element]) && ($_POST[$element] == "on")) $options[$element] = array('true'); else $options[$element] = array('false'); } // dropdownbox elseif ($_SESSION['profile_types'][$element] == "select") { $options[$element] = array($_POST[$element]); } // multiselect elseif ($_SESSION['profile_types'][$element] == "multiselect") { if (isset($_POST[$element])) $options[$element] = $_POST[$element]; // value is already an array else $options[$element] = array(); } // textareas if ($_SESSION['profile_types'][$element] == "textarea") { $options[$element] = explode("\r\n", $_POST[$element]); } } // check options $errors = checkProfileOptions($_POST['accounttype'], $options); if (sizeof($errors) == 0) { // input data is valid, save profile // save profile if (\LAM\PROFILES\saveAccountProfile($options, $_POST['profname'], $_POST['accounttype'])) { metaRefresh('profilemain.php?savedSuccessfully=' . $_POST['profname']); exit(); } else { $errors[] = array("ERROR", _("Unable to save profile!"), $_POST['profname']); } } } // print header include '../../lib/adminHeader.inc'; // print error messages if any if (sizeof($errors) > 0) { echo "
\n"; foreach ($errors as $error) { call_user_func_array('StatusMessage', $error); } } // empty list of attribute types $_SESSION['profile_types'] = array(); // get module options $options = getProfileOptions($type->getId()); // load old profile or POST values if needed $old_options = array(); if (isset($_POST['save'])) { foreach ($_POST as $key => $value) { if (!is_array($value)) { $old_options[$key] = array($value); } else { $old_options[$key] = $value; } } } elseif (isset($_GET['edit'])) { $old_options = \LAM\PROFILES\loadAccountProfile($_GET['edit'], $type->getId()); } // display formular echo "
getId() . "\" method=\"post\">\n"; echo ''; $profName = ''; if (isset($_GET['edit'])) { $profName = $_GET['edit']; } $tabindex = 1; $container = new htmlTable(); $container->addElement(new htmlTitle(_("Profile editor")), true); // general options $dnContent = new htmlTable(); $dnContent->addElement(new htmlTableExtendedInputField(_("Profile name") . '*', 'profname', $profName, '360'), true); $dnContent->addElement(new htmlSpacer(null, '10px'), true); // suffix box // get root suffix $rootsuffix = $type->getSuffix(); // get subsuffixes $suffixes = array('-' => '-'); $possibleSuffixes = $type->getSuffixList(); foreach ($possibleSuffixes as $suffix) { $suffixes[getAbstractDN($suffix)] = $suffix; } $selectedSuffix = array(); if (isset($old_options['ldap_suffix'][0])) { $selectedSuffix[] = $old_options['ldap_suffix'][0]; } $suffixSelect = new htmlTableExtendedSelect('ldap_suffix', $suffixes, $selectedSuffix, _("LDAP suffix"), '361'); $suffixSelect->setHasDescriptiveElements(true); $suffixSelect->setSortElements(false); $suffixSelect->setRightToLeftTextDirection(true); $dnContent->addElement($suffixSelect, true); // RDNs $rdns = getRDNAttributes($type->getId()); $selectedRDN = array(); if (isset($old_options['ldap_rdn'][0])) { $selectedRDN[] = $old_options['ldap_rdn'][0]; } $dnContent->addElement(new htmlTableExtendedSelect('ldap_rdn', $rdns, $selectedRDN, _("RDN identifier"), '301'), true); $container->addElement(new htmlFieldset($dnContent, _("General settings"), '../../graphics/logo32.png'), true); $container->addElement(new htmlSpacer(null, '15px'), true); $_SESSION['profile_types'] = parseHtml(null, $container, $old_options, false, $tabindex, $type->getScope()); // display module options foreach ($options as $moduleName => $moduleOptions) { // ignore modules without options if (sizeof($moduleOptions) < 1) { continue; } $module = new $moduleName($type->getScope()); $icon = $module->getIcon(); if (!empty($icon) && !(strpos($icon, 'http') === 0) && !(strpos($icon, '/') === 0)) { $icon = '../../graphics/' . $icon; } $container = new htmlTable(); $container->addElement(new htmlFieldset($moduleOptions, getModuleAlias($moduleName, $type->getScope()), $icon), true); $container->addElement(new htmlSpacer(null, '15px'), true); $_SESSION['profile_types'] = array_merge($_SESSION['profile_types'], parseHtml($moduleName, $container, $old_options, false, $tabindex, $type->getScope())); } // profile name and submit/abort buttons $buttonTable = new htmlTable(); $saveButton = new htmlButton('save', _('Save')); $saveButton->setIconClass('saveButton'); $buttonTable->addElement($saveButton); $cancelButton = new htmlButton('abort', _('Cancel')); $cancelButton->setIconClass('cancelButton'); $buttonTable->addElement($cancelButton); $buttonTable->addElement(new htmlHiddenInput('accounttype', $type->getId())); $_SESSION['profile_types'] = array_merge($_SESSION['profile_types'], parseHtml(null, $buttonTable, $old_options, false, $tabindex, $type->getScope())); ?> \n"); include '../../lib/adminFooter.inc'; ?>