removed profilecreate.php for better error handling
This commit is contained in:
parent
9190f72711
commit
6a265412ea
Binary file not shown.
Before Width: | Height: | Size: 6.3 KiB After Width: | Height: | Size: 5.5 KiB |
|
@ -9,8 +9,8 @@
|
||||||
<body>
|
<body>
|
||||||
<h1 style="text-align: center;">Profile editor<br>
|
<h1 style="text-align: center;">Profile editor<br>
|
||||||
</h1>
|
</h1>
|
||||||
<div style="text-align: center;"><img alt="profile editor"
|
<div style="text-align: center;"><img alt=""
|
||||||
src="images/lam_profedit.png" style="width: 502px; height: 236px;"><br>
|
src="images/lam_profedit.png" style="width: 354px; height: 236px;"><br>
|
||||||
</div>
|
</div>
|
||||||
<div style="text-align: center;"><br>
|
<div style="text-align: center;"><br>
|
||||||
<div style="text-align: left;">The <span style="font-style: italic;">profile
|
<div style="text-align: left;">The <span style="font-style: italic;">profile
|
||||||
|
@ -50,24 +50,19 @@ for a complete list of supported types.<br>
|
||||||
<br>
|
<br>
|
||||||
The profiles have unique names under which they are saved. If a profile
|
The profiles have unique names under which they are saved. If a profile
|
||||||
with the same name already exists it will be overwritten.<br>
|
with the same name already exists it will be overwritten.<br>
|
||||||
When the user selects to save the profile he will be redirected to
|
|
||||||
profilecreate.php.<br>
|
|
||||||
<br>
|
|
||||||
<h2>Profilecreate.php</h2>
|
|
||||||
This script takes the values which were entered in profilepage.php and
|
|
||||||
checks them for correctness. <br>
|
|
||||||
<br>
|
<br>
|
||||||
|
When the user selects to save the profile then
|
||||||
|
profilepage.php will check the input for correctness.<br>
|
||||||
First the values are converted to the correct type (checkbox ->
|
First the values are converted to the correct type (checkbox ->
|
||||||
Boolean) by checking <span style="font-weight: bold;">$_SESSION['profile_types']</span>.<br>
|
Boolean) by checking <span style="font-weight: bold;">$_SESSION['profile_types']</span>.
|
||||||
<br>
|
|
||||||
Then LAM will replace all "\'" with "'" if <span
|
Then LAM will replace all "\'" with "'" if <span
|
||||||
style="font-style: italic;">magic_quotes_gpc</span> is on.<br>
|
style="font-style: italic;">magic_quotes_gpc</span> is on. Now the
|
||||||
<br>
|
input data is checked for correctness by calling <span
|
||||||
Now the input data is checked for correctness by calling <span
|
style="font-weight: bold;">checkProfileOptions()</span>.<br>
|
||||||
style="font-weight: bold;">checkProfileOptions()</span>. The <span
|
The <span style="font-style: italic;">account modules</span> return a
|
||||||
style="font-style: italic;">account modules</span> return a list of
|
list of
|
||||||
error messages if one or more options are incorrect.<br>
|
error messages if one or more options are incorrect. If there are
|
||||||
If there are errors they will be displayed, otherwise the profile is
|
errors they will be displayed, otherwise the profile is
|
||||||
saved by calling <span style="font-weight: bold;">saveAccountProfile()</span>.<br>
|
saved by calling <span style="font-weight: bold;">saveAccountProfile()</span>.<br>
|
||||||
<br>
|
<br>
|
||||||
<h2>Profiledelete.php</h2>
|
<h2>Profiledelete.php</h2>
|
||||||
|
|
|
@ -1,120 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
$Id$
|
|
||||||
|
|
||||||
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
|
|
||||||
Copyright (C) 2003 Roland Gruber
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Saves new/modified profiles.
|
|
||||||
*
|
|
||||||
* @package profiles
|
|
||||||
* @author Roland Gruber
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** Used to display status messages */
|
|
||||||
include_once("../../lib/status.inc");
|
|
||||||
/** access to account modules */
|
|
||||||
include_once("../../lib/modules.inc");
|
|
||||||
/** helper functions for profiles */
|
|
||||||
include_once("../../lib/profiles.inc");
|
|
||||||
/** access to LDAP server */
|
|
||||||
include_once("../../lib/ldap.inc");
|
|
||||||
/** access to configuration options */
|
|
||||||
include_once("../../lib/config.inc");
|
|
||||||
|
|
||||||
// start session
|
|
||||||
session_save_path("../../sess");
|
|
||||||
@session_start();
|
|
||||||
|
|
||||||
setlanguage();
|
|
||||||
|
|
||||||
// abort button was pressed in profileuser/~host.php
|
|
||||||
// back to profile editor
|
|
||||||
if ($_POST['abort']) {
|
|
||||||
metaRefresh("profilemain.php");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if user is logged in, if not go to login
|
|
||||||
if (!$_SESSION['ldap'] || !$_SESSION['ldap']->server()) {
|
|
||||||
metaRefresh("../login.php");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// print header
|
|
||||||
echo $_SESSION['header'];
|
|
||||||
echo "<title></title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
|
|
||||||
echo "</head>\n<body>\n<br>\n";
|
|
||||||
|
|
||||||
// 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]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else { // input data is valid, save profile
|
|
||||||
// save profile
|
|
||||||
if (saveAccountProfile($options, $_POST['profname'], $_POST['accounttype'])) {
|
|
||||||
echo StatusMessage("INFO", _("Profile was saved."), $_POST['profname']);
|
|
||||||
}
|
|
||||||
else StatusMessage("ERROR", _("Unable to save profile!"), $_POST['profname']);
|
|
||||||
echo ("<br><p><a href=\"profilemain.php\">" . _("Back to Profile Editor") . "</a></p>");
|
|
||||||
}
|
|
||||||
|
|
||||||
echo ("</body></html>\n");
|
|
||||||
|
|
||||||
?>
|
|
|
@ -36,6 +36,8 @@ include_once("../../lib/ldap.inc");
|
||||||
include_once("../../lib/config.inc");
|
include_once("../../lib/config.inc");
|
||||||
/** access to account modules */
|
/** access to account modules */
|
||||||
include_once("../../lib/modules.inc");
|
include_once("../../lib/modules.inc");
|
||||||
|
/** Used to display status messages */
|
||||||
|
include_once("../../lib/status.inc");
|
||||||
|
|
||||||
// start session
|
// start session
|
||||||
session_save_path("../../sess");
|
session_save_path("../../sess");
|
||||||
|
@ -49,14 +51,83 @@ if (!$_SESSION['ldap'] || !$_SESSION['ldap']->server()) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// empty list of attribute types
|
// copy type and profile name from POST to GET
|
||||||
$_SESSION['profile_types'] = array();
|
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
|
// print header
|
||||||
echo $_SESSION['header'];
|
echo $_SESSION['header'];
|
||||||
echo "<title></title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
|
echo "<title></title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
|
||||||
echo "</head><body><br>\n";
|
echo "</head><body><br>\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 "<br>\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 ("<br><p><a href=\"profilemain.php\">" . _("Back to Profile Editor") . "</a></p>");
|
||||||
|
echo "</body></html>";
|
||||||
|
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
|
// check if account type is valid
|
||||||
$type = $_GET['type'];
|
$type = $_GET['type'];
|
||||||
if (!(($type == 'user') || ($type == 'group') || ($type == 'host'))) meta_refresh('profilemain.php');
|
if (!(($type == 'user') || ($type == 'group') || ($type == 'host'))) meta_refresh('profilemain.php');
|
||||||
|
@ -64,14 +135,25 @@ if (!(($type == 'user') || ($type == 'group') || ($type == 'host'))) meta_refres
|
||||||
// get module options
|
// get module options
|
||||||
$options = getProfileOptions($type);
|
$options = getProfileOptions($type);
|
||||||
|
|
||||||
// load old profile if needed
|
// load old profile or POST values if needed
|
||||||
$old_options = array();
|
$old_options = array();
|
||||||
if ($_GET['edit']) {
|
if (isset($_POST['save'])) {
|
||||||
|
$postKeys = array_keys($_POST);
|
||||||
|
for ($i = 0; $i < sizeof($postKeys); $i++) {
|
||||||
|
if (!is_array($_POST[$postKeys[$i]])) {
|
||||||
|
$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);
|
$old_options = loadAccountProfile($_GET['edit'], $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// display formular
|
// display formular
|
||||||
echo ("<form action=\"profilecreate.php?type=$type\" method=\"post\">\n");
|
echo ("<form action=\"profilepage.php?type=$type\" method=\"post\">\n");
|
||||||
|
|
||||||
// suffix box
|
// suffix box
|
||||||
// get root suffix
|
// get root suffix
|
||||||
|
@ -157,7 +239,7 @@ echo "<a href=\"../help.php?HelpNumber=360\" target=\"lamhelp\">";
|
||||||
echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
|
echo "<img src=\"../../graphics/help.png\" alt=\"" . _('Help') . "\" title=\"" . _('Help') . "\">";
|
||||||
echo "</a><br><br>\n";
|
echo "</a><br><br>\n";
|
||||||
$tabindex++;
|
$tabindex++;
|
||||||
echo ("<input tabindex=\"$tabindex\" type=\"submit\" name=\"submit\" value=\"" . _("Save") . "\">\n");
|
echo ("<input tabindex=\"$tabindex\" type=\"submit\" name=\"save\" value=\"" . _("Save") . "\">\n");
|
||||||
$tabindex++;
|
$tabindex++;
|
||||||
echo ("<input tabindex=\"$tabindex\" type=\"reset\" name=\"reset\" value=\"" . _("Reset") . "\">\n");
|
echo ("<input tabindex=\"$tabindex\" type=\"reset\" name=\"reset\" value=\"" . _("Reset") . "\">\n");
|
||||||
$tabindex++;
|
$tabindex++;
|
||||||
|
|
Loading…
Reference in New Issue