2003-05-29 20:33:43 +00:00
|
|
|
<?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
|
|
|
|
|
2004-06-10 22:13:39 +00:00
|
|
|
*/
|
2003-05-29 20:33:43 +00:00
|
|
|
|
2004-06-10 22:13:39 +00:00
|
|
|
/**
|
|
|
|
* Saves new/modified profiles.
|
|
|
|
*
|
|
|
|
* @package Profiles
|
|
|
|
* @author Roland Gruber
|
2003-05-29 20:33:43 +00:00
|
|
|
*/
|
|
|
|
|
2004-06-10 22:13:39 +00:00
|
|
|
/** Used to display status messages */
|
2003-05-31 23:26:25 +00:00
|
|
|
include_once("../../lib/status.inc");
|
2004-06-10 22:13:39 +00:00
|
|
|
/** access to account modules */
|
2004-03-15 16:34:16 +00:00
|
|
|
include_once("../../lib/modules.inc");
|
2004-06-10 22:13:39 +00:00
|
|
|
/** helper functions for profiles */
|
2003-05-31 23:26:25 +00:00
|
|
|
include_once("../../lib/profiles.inc");
|
2004-06-10 22:13:39 +00:00
|
|
|
/** access to LDAP server */
|
2003-05-31 23:26:25 +00:00
|
|
|
include_once("../../lib/ldap.inc");
|
2004-06-10 22:13:39 +00:00
|
|
|
/** access to configuration options */
|
2003-08-03 11:05:40 +00:00
|
|
|
include_once("../../lib/config.inc");
|
2003-05-31 23:26:25 +00:00
|
|
|
|
|
|
|
// start session
|
|
|
|
session_save_path("../../sess");
|
|
|
|
@session_start();
|
|
|
|
|
2003-08-03 11:05:40 +00:00
|
|
|
setlanguage();
|
|
|
|
|
2003-05-31 23:26:25 +00:00
|
|
|
// abort button was pressed in profileuser/~host.php
|
|
|
|
// back to profile editor
|
|
|
|
if ($_POST['abort']) {
|
2003-08-28 12:41:47 +00:00
|
|
|
metaRefresh("profilemain.php");
|
2003-05-31 23:26:25 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if user is logged in, if not go to login
|
|
|
|
if (!$_SESSION['ldap'] || !$_SESSION['ldap']->server()) {
|
2003-08-28 12:41:47 +00:00
|
|
|
metaRefresh("../login.php");
|
2003-05-31 23:26:25 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// print header
|
2003-07-29 11:52:26 +00:00
|
|
|
echo $_SESSION['header'];
|
2003-11-29 12:54:00 +00:00
|
|
|
echo "<title></title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"../../style/layout.css\">\n";
|
2003-10-21 16:56:44 +00:00
|
|
|
echo "</head>\n<body>\n<br>\n";
|
2003-05-31 23:26:25 +00:00
|
|
|
|
2004-03-15 16:34:16 +00:00
|
|
|
// 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]);
|
2003-05-31 23:26:25 +00:00
|
|
|
}
|
2004-03-15 16:34:16 +00:00
|
|
|
// checkboxes
|
|
|
|
elseif ($_SESSION['profile_types'][$element] == "checkbox") {
|
2004-04-04 14:43:12 +00:00
|
|
|
if ($_POST[$element] == "on") $options[$element] = array('true');
|
|
|
|
else $options[$element] = array('false');
|
2003-05-31 23:26:25 +00:00
|
|
|
}
|
2004-03-15 16:34:16 +00:00
|
|
|
// dropdownbox
|
|
|
|
elseif ($_SESSION['profile_types'][$element] == "select") {
|
|
|
|
$options[$element] = array($_POST[$element]);
|
2003-05-31 23:26:25 +00:00
|
|
|
}
|
2004-03-15 16:34:16 +00:00
|
|
|
// multiselect
|
|
|
|
elseif ($_SESSION['profile_types'][$element] == "multiselect") {
|
|
|
|
$options[$element] = $_POST[$element]; // value is already an array
|
2003-05-31 23:26:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-03 10:52:31 +00:00
|
|
|
// 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]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-15 16:34:16 +00:00
|
|
|
// 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]);
|
2003-09-20 17:02:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-03-15 16:34:16 +00:00
|
|
|
else { // input data is valid, save profile
|
|
|
|
// save profile
|
2004-10-06 20:00:17 +00:00
|
|
|
if (saveAccountProfile($options, $_POST['profname'], $_POST['accounttype'])) {
|
|
|
|
echo StatusMessage("INFO", _("Profile was saved."), $_POST['profname']);
|
2003-08-03 11:05:40 +00:00
|
|
|
}
|
2004-10-06 20:00:17 +00:00
|
|
|
else StatusMessage("ERROR", _("Unable to save profile!"), $_POST['profname']);
|
2003-07-04 16:54:58 +00:00
|
|
|
echo ("<br><p><a href=\"profilemain.php\">" . _("Back to Profile Editor") . "</a></p>");
|
2003-05-31 23:26:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
echo ("</body></html>\n");
|
|
|
|
|
|
|
|
?>
|