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']; // abort button was pressed // back to profile editor if ($_POST['abort']) { metaRefresh("profilemain.php"); exit; } // print header echo $_SESSION['header']; echo "\n\n"; echo "
\n"; // save button was presed if ($_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 ($_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") { $options[$element] = $_POST[$element]; // value is already an array } } // remove double slashes if magic quotes are on if (get_magic_quotes_gpc() == 1) { foreach ($opt_keys as $element) { if (is_string($options[$element][0])) $options[$element][0] = stripslashes($options[$element][0]); } } // check options $errors = checkProfileOptions($_POST['accounttype'], $options); // print error messages if any if (sizeof($errors) > 0) { for ($i = 0; $i < sizeof($errors); $i++) { if (sizeof($errors[$i]) > 3) { // messages with additional variables StatusMessage($errors[$i][0], $errors[$i][1], $errors[$i][2], $errors[$i][3]); } else { StatusMessage($errors[$i][0], $errors[$i][1], $errors[$i][2]); } } echo "
\n"; } else { // input data is valid, save profile // save profile if (saveAccountProfile($options, $_POST['profname'], $_POST['accounttype'])) { echo StatusMessage("INFO", _("Profile was saved."), $_POST['profname']); echo ("

" . _("Back to Profile Editor") . "

"); echo ""; exit(); } else StatusMessage("ERROR", _("Unable to save profile!"), $_POST['profname']); } } // empty list of attribute types $_SESSION['profile_types'] = array(); // check if account type is valid $type = $_GET['type']; if (!(($type == 'user') || ($type == 'group') || ($type == 'host'))) meta_refresh('profilemain.php'); // get module options $options = getProfileOptions($type); // load old profile or POST values if needed $old_options = array(); if (isset($_POST['save'])) { $postKeys = array_keys($_POST); for ($i = 0; $i < sizeof($postKeys); $i++) { if (!is_array($_POST[$postKeys[$i]])) { if (get_magic_quotes_gpc() == 1) { $old_options[$postKeys[$i]] = array(stripslashes($_POST[$postKeys[$i]])); } else { $old_options[$postKeys[$i]] = array($_POST[$postKeys[$i]]); } } else { $old_options[$postKeys[$i]] = $_POST[$postKeys[$i]]; } } } elseif (isset($_GET['edit'])) { $old_options = loadAccountProfile($_GET['edit'], $type); } // display formular echo ("
\n"); // suffix box // get root suffix $rootsuffix = $_SESSION['config']->get_Suffix($type); // get subsuffixes $suffixes = array(); foreach ($_SESSION['ldap']->search_units($rootsuffix) as $suffix) { $suffixes[] = $suffix; } // get RDNs $rdns = getRDNAttributes($type); echo "
\n" . _("LDAP") . "\n"; echo ""; echo ""; // LDAP RDN echo ""; echo "
"; // LDAP suffix echo _("LDAP suffix") . ":"; echo ""; echo "\n"; echo ""; // help link echo " "; echo "\"""; echo "
\n"; echo "
"; echo _("RDN identifier") . ":"; echo ""; echo "\n"; echo ""; // help link echo " "; echo "\"""; echo "
\n"; echo "
"; echo "
\n
\n"; $_SESSION['profile_types']['ldap_suffix'] = 'select'; $_SESSION['profile_types']['ldap_rdn'] = 'select'; // index for tab order (1 is LDAP suffix) $tabindex = 2; $tabindexLink = 1000; // links are at the end // display module options $modules = array_keys($options); for ($m = 0; $m < sizeof($modules); $m++) { // ignore modules without options if (sizeof($options[$modules[$m]]) < 1) continue; echo "
\n"; echo "" . getModuleAlias($modules[$m], $type) . "\n"; $profileTypes = parseHtml($modules[$m], $options[$modules[$m]], $old_options, true, $tabindex, $tabindexLink, $type); $_SESSION['profile_types'] = array_merge($profileTypes, $_SESSION['profile_types']); echo "
\n"; echo "
"; } // profile name and submit/abort buttons echo ("" . _("Profile name") . ": \n"); $tabindex++; echo ("\n"); // help link echo ""; echo "\"""; echo "

\n"; $tabindex++; echo ("\n"); $tabindex++; echo ("\n"); $tabindex++; echo ("\n"); echo "\n"; echo ("
\n"); ?>