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 TypeManager(); $type = $typeManager->getConfiguredType($_GET['type']); if (($type === null) || $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; } $accountProfilePersistenceManager = new AccountProfilePersistenceManager(); $errors = []; // save button was pressed if (isset($_POST['save'])) { // create option array to check and save $options = []; $opt_keys = array_keys($_SESSION['profile_types']); foreach ($opt_keys as $element) { // text fields if ($_SESSION['profile_types'][$element] == "text") { $options[$element] = [$_POST[$element]]; } // checkboxes elseif ($_SESSION['profile_types'][$element] == "checkbox") { $options[$element] = (isset($_POST[$element]) && ($_POST[$element] == "on")) ? ['true'] : ['false']; } // dropdownbox elseif ($_SESSION['profile_types'][$element] == "select") { $options[$element] = [$_POST[$element]]; } // multiselect elseif ($_SESSION['profile_types'][$element] == "multiselect") { $options[$element] = $_POST[$element] ?? []; } // textareas if ($_SESSION['profile_types'][$element] == "textarea") { $options[$element] = explode("\r\n", $_POST[$element]); } } // check options $errors = checkProfileOptions($_POST['accounttype'], $options); if (count($errors) === 0) { // input data is valid, save profile // save profile try { $accountProfilePersistenceManager->writeAccountProfile($_POST['accounttype'], $_POST['profname'], $_SESSION['config']->getName(), $options); metaRefresh('profilemain.php?savedSuccessfully=' . $_POST['profname']); exit(); } catch (LAMException $e) { logNewMessage(LOG_ERR, $e->getTitle()); $errors[] = ["ERROR", _("Unable to save profile!")]; } } } // print header include __DIR__ . '/../../lib/adminHeader.inc'; echo '