hasPriv("admin")) { 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; } /* Check if the permission only applies to a specific group */ if($r->show_for_group && !$_SESSION['current']->hasPriv($r->show_for_group)) continue; $input = html_select("pref_$r->name", explode('|', $r->value_list), $oUser->getpref($r->name, $r->def_value)); $oTableRow = new TableRow(); $oTableCell = new TableCell(" $r->description"); $oTableRow->AddCell($oTableCell); $oTableCell = new TableCell($input); $oTableRow->AddCell($oTableCell); $aTableRows[] = $oTableRow; } return $aTableRows; } // returns an array of TableRow instances function show_user_fields($oUser) { $aTableRows = array(); $sDXGLRelease = $oUser->sDXGLRelease; if($oUser->hasPriv("admin")) $sAdminChecked = 'checked="true"'; else $sAdminChecked = ""; // Edit admin privilege if($_SESSION['current']->hasPriv("admin")) { $oTableRow = new TableRow(); $oTableRow->AddTextCell(" Administrator"); $oTableRow->AddTextCell(""); $aTableRows[] = $oTableRow; } $oTableRow = new TableRow(); $oTableRow->AddTextCell(" DXGL version"); $sBugzillaVersionList = make_bugzilla_version_list("sDXGLRelease", $sDXGLRelease); $oTableRow->AddCell(new TableCell($sBugzillaVersionList)); $aTableRows[] = $oTableRow; // return the table rows return $aTableRows; } if(!$_SESSION['current']->isLoggedIn()) util_show_error_page_and_exit("You must be logged in to edit preferences"); // we come from the administration to edit an user if($_SESSION['current']->hasPriv("admin") && isset($aClean['iUserId']) && isset($aClean['iLimit']) && isset($aClean['sOrderBy']) && in_array($aClean['sOrderBy'],array("email","realname","created")) ) { $oUser = new User($aClean['iUserId']); } else { $oUser = &$_SESSION['current']; } if(isset($aClean['sSubmit']) && $aClean['sSubmit'] == "Update") { while(list($sKey, $sValue) = each($aClean)) { /* if a parameter lacks 'pref_' at its head it isn't a */ /* preference so skip over processing it */ if(!ereg("^pref_(.+)$", $sKey, $arr)) continue; $oUser->setPref($arr[1], $sValue); } /* make sure the user enters the same password twice */ if ($aClean['sUserPassword'] == $aClean['sUserPassword2']) { $str_passwd = $aClean['sUserPassword']; } else if ($aClean['sUserPassword']) { addmsg("The Passwords you entered did not match.", "red"); } /* update user data fields */ $oUser->sEmail = $aClean['sUserEmail']; $oUser->sRealname = $aClean['sUserRealname']; $oUser->sDXGLRelease = $aClean['sDXGLRelease']; /* if the password was empty in both cases then skip updating the users password */ if($str_passwd != "") { if(!$oUser->update_password($str_passwd)) addmsg("Failed to update password", "red"); } if ($oUser->update() == SUCCESS) { addmsg("Preferences Updated", "green"); // we were managing an user, let's go back to the admin after // updating tha admin status if($oUser->iUserId == $aClean['iUserId'] && $_SESSION['current']->hasPriv("admin")) { if($aClean['bIsAdmin'] == "true") $oUser->addPriv("admin"); else $oUser->delPriv("admin"); util_redirect_and_exit(BASE."admin/adminUsers.php?iUserId=".$oUser->iUserId. "&sSearch=".$aClean['sSearch']."&iLimit=".$aClean['iLimit']. "&sOrderBy=".$aClean['sOrderBy']."&sSubmit=true"); } } else { addmsg("There was a problem updating your user info", "red"); } } apidb_header("User Preferences"); echo "