2004-12-12 03:51:51 +00:00
|
|
|
<?php
|
2005-01-17 04:30:39 +00:00
|
|
|
/*******************************/
|
|
|
|
|
/* preferences and user editor */
|
|
|
|
|
/*******************************/
|
2004-12-25 20:08:00 +00:00
|
|
|
|
|
|
|
|
/*
|
2004-12-27 23:54:55 +00:00
|
|
|
* application environment
|
2004-12-25 20:08:00 +00:00
|
|
|
*/
|
2004-03-15 16:22:00 +00:00
|
|
|
include("path.php");
|
|
|
|
|
include(BASE."include/"."incl.php");
|
|
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
if(!$_SESSION['current']->isLoggedIn())
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
|
|
|
|
errorpage("You must be logged in to edit preferences");
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-16 02:04:03 +00:00
|
|
|
// we come from the administration to edit an user
|
2005-01-30 23:12:48 +00:00
|
|
|
if($_SESSION['current']->hasPriv("admin") &&
|
2005-01-16 02:04:03 +00:00
|
|
|
is_numeric($_REQUEST['userId']) &&
|
|
|
|
|
is_numeric($_REQUEST['iLimit']) &&
|
|
|
|
|
in_array($_REQUEST['sOrderBy'],array("email","realname","created"))
|
|
|
|
|
)
|
|
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
$oUser = new User($_REQUEST['userId']);
|
2005-01-16 02:04:03 +00:00
|
|
|
} else
|
|
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
$oUser = &$_SESSION['current'];
|
2005-01-16 02:04:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-03-15 16:22:00 +00:00
|
|
|
function build_prefs_list()
|
|
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
global $oUser;
|
2005-01-14 05:28:58 +00:00
|
|
|
$result = query_appdb("SELECT * FROM prefs_list ORDER BY id");
|
|
|
|
|
while($result && $r = mysql_fetch_object($result))
|
2004-12-13 03:50:11 +00:00
|
|
|
{
|
|
|
|
|
//skip admin options
|
|
|
|
|
//TODO: add a field to prefs_list to flag the user level for the pref
|
2005-01-30 23:12:48 +00:00
|
|
|
if(!$_SESSION['current']->hasPriv("admin"))
|
2004-12-13 03:50:11 +00:00
|
|
|
{
|
|
|
|
|
if($r->name == "query:mode")
|
|
|
|
|
continue;
|
|
|
|
|
if($r->name == "sidebar")
|
|
|
|
|
continue;
|
|
|
|
|
if($r->name == "window:query")
|
|
|
|
|
continue;
|
|
|
|
|
if($r->name == "query:hide_header")
|
|
|
|
|
continue;
|
|
|
|
|
if($r->name == "query:hide_sidebar")
|
|
|
|
|
continue;
|
|
|
|
|
if($r->name == "debug")
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$input = html_select("pref_$r->name", explode('|', $r->value_list),
|
2005-01-30 23:12:48 +00:00
|
|
|
$oUser->getpref($r->name, $r->def_value));
|
2004-12-13 03:50:11 +00:00
|
|
|
echo html_tr(array(" $r->description", $input));
|
|
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function show_user_fields()
|
|
|
|
|
{
|
2005-01-30 23:12:48 +00:00
|
|
|
global $oUser;
|
|
|
|
|
|
|
|
|
|
$ext_realname = $oUser->sRealname;
|
|
|
|
|
$ext_email = $oUser->sEmail;
|
|
|
|
|
$CVSrelease = $oUser->sWineRelease;
|
|
|
|
|
if($oUser->hasPriv("admin"))
|
|
|
|
|
$ext_hasadmin = 'checked="true"';
|
|
|
|
|
else
|
|
|
|
|
$ext_hasadmin = "";
|
|
|
|
|
|
|
|
|
|
include(BASE."include/form_edit.php");
|
2005-01-16 02:04:03 +00:00
|
|
|
|
|
|
|
|
echo "<tr><td> Wine version </td><td>";
|
|
|
|
|
make_bugzilla_version_list("CVSrelease", $CVSrelease);
|
|
|
|
|
echo "</td></tr>";
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-18 01:50:58 +00:00
|
|
|
if($_POST)
|
2004-12-15 00:10:27 +00:00
|
|
|
{
|
|
|
|
|
while(list($key, $value) = each($_REQUEST))
|
2004-12-13 03:50:11 +00:00
|
|
|
{
|
|
|
|
|
if(!ereg("^pref_(.+)$", $key, $arr))
|
|
|
|
|
continue;
|
2005-01-30 23:12:48 +00:00
|
|
|
$oUser->setPref($arr[1], $value);
|
2004-12-13 03:50:11 +00:00
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
|
2004-12-15 00:10:27 +00:00
|
|
|
if ($_REQUEST['ext_password'] == $_REQUEST['ext_password2'])
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
2004-12-15 00:10:27 +00:00
|
|
|
$str_passwd = $_REQUEST['ext_password'];
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
2004-12-15 00:10:27 +00:00
|
|
|
else if ($_REQUEST['ext_password'])
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
|
|
|
|
addmsg("The Passwords you entered did not match.", "red");
|
|
|
|
|
}
|
2005-01-30 23:12:48 +00:00
|
|
|
if ($oUser->update($_REQUEST['ext_email'], $str_passwd, $_REQUEST['ext_realname'], $_REQUEST['CVSrelease']))
|
2004-03-15 16:22:00 +00:00
|
|
|
{
|
|
|
|
|
addmsg("Preferences Updated", "green");
|
2005-01-17 04:30:39 +00:00
|
|
|
// we were managing an user, let's go back to the admin after updating tha admin status
|
2005-01-30 23:12:48 +00:00
|
|
|
if($oUser->iUserId == $_REQUEST['userId'] && $_SESSION['current']->hasPriv("admin"))
|
2005-01-16 02:04:03 +00:00
|
|
|
{
|
2005-01-17 04:30:39 +00:00
|
|
|
if($_POST['ext_hasadmin']=="on")
|
2005-01-30 23:12:48 +00:00
|
|
|
$oUser->addPriv("admin");
|
2005-01-17 04:30:39 +00:00
|
|
|
else
|
2005-01-30 23:12:48 +00:00
|
|
|
$oUser->delPriv("admin");
|
|
|
|
|
redirect(BASE."admin/adminUsers.php?userId=".$oUser->iUserId."&sSearch=".$_REQUEST['sSearch']."&iLimit=".$_REQUEST['iLimit']."&sOrderBy=".$_REQUEST['sOrderBy']."&sSubmit=true");
|
2005-01-16 02:04:03 +00:00
|
|
|
}
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2006-06-06 18:54:12 +00:00
|
|
|
addmsg("There was a problem updating your user info", "red");
|
2004-03-15 16:22:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
apidb_header("User Preferences");
|
|
|
|
|
|
2005-01-16 02:04:03 +00:00
|
|
|
echo "<form method=\"post\" action=\"preferences.php\">\n";
|
|
|
|
|
|
|
|
|
|
// if we manage another user we give the parameters to go back to the admin
|
2005-01-30 23:12:48 +00:00
|
|
|
if($oUser->iUserId == $_REQUEST['userId'])
|
2005-01-16 02:04:03 +00:00
|
|
|
{
|
|
|
|
|
echo "<input type=\"hidden\" name=\"iLimit\" value=\"".$_REQUEST['iLimit']."\">\n";
|
|
|
|
|
echo "<input type=\"hidden\" name=\"sOrderBy\" value=\"".$_REQUEST['sOrderBy']."\">\n";
|
|
|
|
|
echo "<input type=\"hidden\" name=\"sSearch\" value=\"".addslashes($_REQUEST['sSearch'])."\">\n";
|
|
|
|
|
echo "<input type=\"hidden\" name=\"userId\" value=\"".$_REQUEST['userId']."\">\n";
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-30 23:12:48 +00:00
|
|
|
echo html_frame_start("Preferences for ".$oUser->sRealname, "80%");
|
2004-03-15 16:22:00 +00:00
|
|
|
echo html_table_begin("width='100%' border=0 align=left cellspacing=0 class='box-body'");
|
|
|
|
|
|
|
|
|
|
show_user_fields();
|
2005-01-16 02:04:03 +00:00
|
|
|
|
|
|
|
|
// if we don't manage another user
|
2005-01-30 23:12:48 +00:00
|
|
|
if($oUser->iUserId != $_REQUEST['userId']) build_prefs_list();
|
2004-03-15 16:22:00 +00:00
|
|
|
|
|
|
|
|
echo html_table_end();
|
|
|
|
|
echo html_frame_end();
|
2005-01-16 02:04:03 +00:00
|
|
|
echo "<br /> <div align=center> <input type=\"submit\" value=\"Update\" /> </div> <br />\n";
|
2004-03-15 16:22:00 +00:00
|
|
|
echo "</form>\n";
|
|
|
|
|
|
|
|
|
|
apidb_footer();
|
|
|
|
|
?>
|