<?php
if (isset($_REQUEST['selectedUser'])) {
$selectedUser = intval($_REQUEST['selectedUser']);
if (!isset($_REQUEST['update'])) {
$formFields = "<input type=\"hidden\" name=\"selectedUser\" value=\"{$selectedUser}\" />";
}
$adminUserInfo = $bugDatabase->lists['user'][$selectedUser];
$comment = htmlentities($adminUserInfo['comment']);
$userOptions = array();
$userOptions['frames'] = "";
$userOptions['notify'] = "";
$userOptions['popup'] = "";
$userOptions['refresh_list'] = "";
$userOptions['list_sort_reverse'] = "";
$userOptions['short_notification_notify'] = "";
$userOptions['no_paging'] = "";
if ($adminUserInfo['options'] & OPTION_FRAMES) {
$userOptions['frames'] = " checked";
}
if ($adminUserInfo['options'] & OPTION_NOTIFY) {
$userOptions['notify'] = " checked";
}
if ($adminUserInfo['options'] & OPTION_POPUP) {
$userOptions['popup'] = " checked";
}
if ($adminUserInfo['options'] & OPTION_REFRESH_LIST) {
$userOptions['refresh_list'] = " checked";
}
if ($adminUserInfo['options'] & OPTION_LIST_SORT_REVERSE) {
$userOptions['list_sort_reverse'] = " checked";
}
if ($adminUserInfo['options'] & OPTION_SHORT_NOTIFICATION_NOTIFY) {
$userOptions['short_notification_notify'] = " checked";
}
if ($adminUserInfo['options'] & OPTION_NO_PAGING) {
$userOptions['no_paging'] = " checked";
}
// Assemble the language
buginError("Generating priority list", 1);
$langList = generateOptionList($bugDatabase->lists['lang'], "id", $userinfo['lang']);
if (isset($mod)) {
$formUserOptions = 0;
$formUserOptions += ($mod['flags']['frames'] ? OPTION_FRAMES : 0);
$formUserOptions += ($mod['flags']['notify'] ? OPTION_NOTIFY : 0);
$formUserOptions += ($mod['flags']['popup'] ? OPTION_POPUP : 0);
$formUserOptions += ($mod['flags']['refresh_list'] ? OPTION_REFRESH_LIST : 0);
$formUserOptions += ($mod['flags']['list_sort_reverse'] ? OPTION_LIST_SORT_REVERSE : 0);
$formUserOptions += ($mod['flags']['short_notification_notify'] ? OPTION_SHORT_NOTIFICATION_NOTIFY : 0);
$formUserOptions += ($mod['flags']['no_paging'] ? OPTION_NO_PAGING : 0);
if (isset($_REQUEST['adminWriteChanges'])) {
$adminWriteChanges = intval($_REQUEST['adminWriteChanges']);
$upNum = 0;
$adminGroups = @implode($mod['user_group'], ",");
// Upgate the groups if the user is an admin.
if ($_SESSION['userinfo']['isAdmin'] && ($adminGroups != @implode($adminUserInfo['user_group'], ","))) {
$update[0]['modify'][$upNum]['fieldName'] = "user_group";
$update[0]['modify'][$upNum]['fieldValue'] = $bugDatabase->db->qstr($adminGroups);
$upNum ++;
buginError("Modifiying User Groups", 1);
}
// Upgate the groups if the user is an admin.
if ($mod['name'] != $adminUserInfo['name']) {
$update[0]['modify'][$upNum]['fieldName'] = "name";
$update[0]['modify'][$upNum]['fieldValue'] = $bugDatabase->db->qstr($mod['name']);
$upNum ++;
buginError("Modifiying User Name", 1);
}
// Update the password if both are set and the same.
if (($mod['passwd1'] && $mod['passwd2']) && ($mod['passwd1'] == $mod['passwd2'])) {
$update[0]['modify'][$upNum]['fieldName'] = "pass";
$update[0]['modify'][$upNum]['fieldValue'] = $bugDatabase->db->qstr(md5($mod['passwd1']));
$upNum ++;
buginError("Modifiying User Password", 1);
}
elseif ($mod['passwd1'] && $mod['passwd2']) {
$ueditMessage .= "Passwords do not match!<br>";
}
// Update the e-mail address
if ($mod['email'] != $adminUserInfo['email']) {
$update[0]['modify'][$upNum]['fieldName'] = "email";
$update[0]['modify'][$upNum]['fieldValue'] = $bugDatabase->db->qstr($mod['email']);
$upNum ++;
}
// Update the phone number
if ($mod['phone'] != $adminUserInfo['phone']) {
$update[0]['modify'][$upNum]['fieldName'] = "phone";
$update[0]['modify'][$upNum]['fieldValue'] = $bugDatabase->db->qstr($mod['phone']);
$upNum ++;
}
// Update the language
if ($mod['lang'] != $adminUserInfo['lang']) {
$update[0]['modify'][$upNum]['fieldName'] = "lang";
$update[0]['modify'][$upNum]['fieldValue'] = intval($mod['lang']);
$upNum ++;
}
// Update the options
if ($formUserOptions != $adminUserInfo['options']) {
$update[0]['modify'][$upNum]['fieldName'] = "options";
$update[0]['modify'][$upNum]['fieldValue'] = $formUserOptions;
$upNum ++;
}
// Update the comment
if ($mod['comment'] != $adminUserInfo['comment']) {
$update[0]['modify'][$upNum]['fieldName'] = "comment";
$update[0]['modify'][$upNum]['fieldValue'] = $bugDatabase->db->qstr($mod['comment']);
$upNum ++;
}
// We are updating the account now....
if (isset($update)) {
$update[0]['action'] = "change";
$update[0]['tableName'] = "users";
$update[0]['uniqueRow'] = "uid";
$update[0]['rowid'] = $adminUserInfo['uid'];
$bugDatabase->alterDb($update);
// If this is the current user, update their settings...
if ($_SESSION['userinfo']['uid'] == $adminUserInfo['uid']) {
if ($_SESSION['userinfo']['options'] & OPTION_FRAMES)
$bodyOptions .= "onLoad=\"parent.location.href='{$options['baseURL']}'\" ";
else
$bodyOptions .= "onLoad=\"location.href='{$options['baseURL']}'\" ";
$_SESSION['userinfo']['options'] = $formUserOptions;
$_SESSION['userinfo']['phone'] = $mod['phone'];
$_SESSION['userinfo']['email'] = $mod['email'];
$_SESSION['userinfo']['lang'] = $mod['lang'];
$_SESSION['userinfo']['user_group'] = $adminGroups;
$_SESSION['userinfo']['options'] = $formUserOptions;
$listFooter = 0;
}
else
header("Location: {$options['baseURL']}?area=admin&action=uedit");
}
}
}
else {
$showUser = 1;
}
}
?>