User Preferences\n"; print "
\n"; if($mode == "submituserprefs") { print "User preferences successfully updated
\n"; } print "
\n"; print "\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print " \n"; print " \n"; if($showpersonal) { print "
\n"; print " Personal\n"; print "
\n"; print " \n"; $showsubmit = 0; if(! empty($user['firstname'])) { print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; } if(! empty($user['lastname'])) { print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; } # preferred name is stored locally; allow setting preferred name if a firstname is defined if(! empty($user['firstname'])) { print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; $showsubmit = 1; } if(! empty($user['email'])) { print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; } if($user['affiliation'] == 'Local') { print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; $showsubmit = 1; } print "
First Name*:" . $user["firstname"] . "
Last Name*:" . $user["lastname"] . "
Preferred Name:\n"; print " "; printSubmitErr(PREFNAMEERR); print "
Email Address*:" . $user["email"] . "

Change Password

Current Password:\n"; print " \n"; print " \n"; print " "; printSubmitErr(LOCALPASSWORDERR); print "
New Password:\n"; print " \n"; print " \n"; print "
Confirm Password:\n"; print " \n"; print " \n"; print "
\n"; $updateText = getAffiliationDataUpdateText($user['affiliationid']); print "\n"; if(! empty($updateText[$user['affiliationid']])) print "{$updateText[$user['affiliationid']]}

"; if($showsubmit) { $cont = addContinuationsEntry('confirmpersonalprefs', array(), SECINDAY, 1, 1, 1); print " \n"; print "
\n"; print " \n"; print "
\n"; } print "
\n"; print "
\n"; } print "
\n"; print " RDP\n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; $resolutionArray = array("Full Screen" => "Full Screen", "1920x1440" => "1920x1440", "1600x1200" => "1600x1200", "1280x1024" => "1280x1024", "1152x864" => "1152x864", "1024x768" => "1024x768", "800x600" => "800x600", "640x480" => "640x480", "1680x1050" => "1680x1050", "1600x1024" => "1600x1024", "1440x900" => "1440x900", "1280x854" => "1280x854", "1280x768" => "1280x768", "1024x576" => "1024x576"); print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
Try decreasing Resolution or "; print "Color Depth to
speed up your connection if things seem "; print "slow
when connected to a remote computer.
Resolution:\n"; printSelectInput("resolution", $resolutionArray, $data["resolution"]); print "
Color Depth:\n"; #$colordepth = array("8" => "8", "16" => "16", "24" => "24"); $colordepth = array("8" => "8", "16" => "16", "24" => "24", "32" => "32 (Vista only)"); printSelectInput("bpp", $colordepth, $data["bpp"]); print "
Audio:\n"; $audio = array("none" => "None", "local" => "Use my speakers"); printSelectInput("audiomode", $audio, $data["audiomode"]); print "
Map Local Drives:\n"; $yesno = array(1 => "Yes", 0 => "No"); printSelectInput("mapdrives", $yesno, $data["mapdrives"]); print "
Map Local Printers:\n"; printSelectInput("mapprinters", $yesno, $data["mapprinters"]); print "
Map Local Serial Ports:\n"; printSelectInput("mapserial", $yesno, $data["mapserial"]); print "
\n"; $cont = addContinuationsEntry('confirmrdpprefs', array(), SECINDAY, 1, 1, 1); print " \n"; print "
\n"; print " \n"; print "
\n"; print "
\n"; print "
\n"; print "
\n"; print "
\n"; print " General Preferences\n"; print "
\n"; $cdata = array(); if(in_array("userGrant", $user["privileges"])) { if($user['showallgroups']) { $selected['affiliation'] = ''; $selected['allgroups'] = 'checked'; } else { $selected['affiliation'] = 'checked'; $selected['allgroups'] = ''; } print "

View User Groups:
\n"; print "
\n"; print "

\n"; } else $cdata['groupview'] = 'affiliation'; if($user['emailnotices']) { $selected['enabled'] = 'checked'; $selected['disabled'] = ''; } else { $selected['enabled'] = ''; $selected['disabled'] = 'checked'; } print "

Send email notifications about reservations:
\n"; print "
\n"; print "

\n"; $cont = addContinuationsEntry('submitgeneralprefs', $cdata, SECINDAY, 1, 0); print " \n"; print " \n"; print "
\n"; print "
\n"; print "
\n"; print "
\n"; if($adminleveldeveloper) { print "
\n"; print " View Mode\n"; print "
\n"; if($viewmode == ADMIN_FULL) { $selected[ADMIN_NONE] = ""; $selected[ADMIN_FULL] = "checked"; $selected[ADMIN_DEVELOPER] = ""; } elseif($viewmode == ADMIN_DEVELOPER) { $selected[ADMIN_NONE] = ""; $selected[ADMIN_FULL] = ""; $selected[ADMIN_DEVELOPER] = "checked"; } else { $selected[ADMIN_NONE] = "checked"; $selected[ADMIN_FULL] = ""; $selected[ADMIN_DEVELOPER] = ""; } if($user["adminlevelid"] != ADMIN_NONE) { print "

View site as:
\n"; print " Normal User
\n"; if($user["adminlevel"] == "full" || $user["adminlevel"] == "developer") { print " Admin Level
\n"; } if($user["adminlevel"] == "developer") { print " Developer Level
\n"; } print "

\n"; } print " View As User: \n"; else print "size=20 value=\"{$data["unityid"]}@{$data['affiliation']}\">\n"; printSubmitErr(VIEWASUSERERR); print "
\n"; $cont = addContinuationsEntry('submitviewmode', array(), SECINDAY, 1, 0); print " \n"; print " \n"; print "
\n"; print "
\n"; } print "
\n"; print "
\n"; printUserprefJavascript(); } //////////////////////////////////////////////////////////////////////////////// /// /// \fn confirmUserPrefs($type) /// /// \param $type - 0 for personal prefs, 1 for rdp prefs /// /// \brief prints a page for user to confirm changes to preferences /// //////////////////////////////////////////////////////////////////////////////// function confirmUserPrefs($type) { global $submitErr, $user; $data = processUserPrefsInput(1); if($submitErr) { userpreferences(); return; } if($data["audiomode"] == "none") $audio = "None"; else $audio = "Use my speakers"; if($data["mapdrives"] == 0) $drives = "No"; else $drives = "Yes"; if($data["mapprinters"] == 0) $printers = "No"; else $printers = "Yes"; if($data["mapserial"] == 0) $serial = "No"; else $serial = "Yes"; print "
\n"; if($type == 0) { print "

Personal Information

\n"; print "

Submit the following changes?

\n"; print "\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
Preferred Name:" . $data["preferredname"] . "
\n"; if($user['affiliation'] == 'Local' && ! empty($data['newpassword'])) { print "New password will be submitted
\n"; } } elseif($type == 1) { print "

RDP File Preferences

\n"; print "

Submit the following changes?

\n"; print "\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; $colordepth = array("8" => "8", "16" => "16", "24" => "24", "32" => "32 (Vista only)"); print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
Resolution:" . $data["resolution"] . "
Color Depth:" . $colordepth[$data["bpp"]] . "
Audio:$audio
Map Local Drives:$drives
Map Local Printers:$printers
Map Local Serial Ports:$serial
\n"; } print "\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print "
\n"; $cont = addContinuationsEntry('submituserprefs', $data, SECINWEEK, 0, 0); print " \n"; print " \n"; print "
\n"; print "
\n"; print "
\n"; $cont = addContinuationsEntry('userpreferences'); print " \n"; print " \n"; print "
\n"; print "
\n"; } //////////////////////////////////////////////////////////////////////////////// /// /// \fn submitUserPrefs() /// /// \brief updates user prefs and prints a page informing the user of success /// //////////////////////////////////////////////////////////////////////////////// function submitUserPrefs() { global $user; $data = getContinuationVar(); if($data["resolution"] == "Full Screen") { $width = 0; $height = 0; } else { list($width, $height) = explode('x', $data["resolution"]); if(! is_numeric($width) || ! is_numeric($height)) { $width = 0; $height = 0; } } if(updateUserPrefs($user['id'], $data["preferredname"], $width, $height, $data["bpp"], $data["audiomode"], $data["mapdrives"], $data["mapprinters"], $data["mapserial"])) { } if($user['affiliation'] == 'Local' && ! empty($data['newpassword'])) { $query = "SELECT l.salt " . "FROM localauth l, " . "user u " . "WHERE u.id = '{$user['id']}' AND " . "l.userid = u.id"; $qh = doQuery($query, 101); if(! ($row = mysql_fetch_assoc($qh))) abort(); $passhash = sha1("{$data['newpassword']}{$row['salt']}"); $query = "UPDATE localauth " . "SET passhash = '$passhash' " . "WHERE userid = {$user['id']}"; doQuery($query, 101); } $user = getUserInfo($user["id"], 1, 1); $_SESSION['user'] = $user; userpreferences(); } //////////////////////////////////////////////////////////////////////////////// /// /// \fn submitGeneralPreferences() /// /// \brief updates user general preferences and calls userpreferences /// //////////////////////////////////////////////////////////////////////////////// function submitGeneralPreferences() { global $user, $HTMLheader, $printedHTMLheader, $mode, $viewmode; $groupview = getContinuationVar('groupview', processInputVar('groupview', ARG_STRING)); $emailnotify = processInputVar('emailnotify', ARG_NUMERIC); if($groupview != 'affiliation' && $groupview != 'allgroups') { $printedHTMLheader = 1; print $HTMLheader; userpreferences(); return; } if($emailnotify != 1 && $emailnotify != 2) { $printedHTMLheader = 1; print $HTMLheader; userpreferences(); return; } if(($groupview == 'allgroups' && $user['showallgroups'] == 0) || ($groupview == 'affiliation' && $user['showallgroups'] == 1)) { if($groupview == 'allgroups') $value = 1; else $value = 0; $query = "UPDATE user SET showallgroups = $value WHERE id = {$user['id']}"; doQuery($query, 101); $_SESSION['user']['showallgroups'] = $value; $user['showallgroups'] = $value; } if(($user['emailnotices'] == 1 && $emailnotify == 1) || ($user['emailnotices'] == 0 && $emailnotify == 2)) { $newval = $emailnotify - 1; $query = "UPDATE user SET emailnotices = $newval WHERE id = {$user['id']}"; doQuery($query, 101); $_SESSION['user']['emailnotices'] = $newval; $user['emailnotices'] = $newval; } print $HTMLheader; $printedHTMLheader = 1; $mode = 'submituserprefs'; # FIXME might need to clear some cache items for cached lists of groups userpreferences(); } //////////////////////////////////////////////////////////////////////////////// /// /// \fn processUserPrefsInput($checks) /// /// \param $checks - (optional) 1 to perform validation, 0 not to /// /// \return an array with the following indexes:\n /// preferredname, resolution, bpp, audiomode, mapdrives, mapprinters, /// mapserial, unityid /// /// \brief validates input from the previous form; if anything was improperly /// submitted, sets submitErr and submitErrMsg /// //////////////////////////////////////////////////////////////////////////////// function processUserPrefsInput($checks=1) { global $submitErr, $submitErrMsg, $user; $return = array(); $defaultres = $user["width"] . 'x' . $user["height"]; $return["preferredname"] = processInputVar("preferredname" , ARG_STRING, $user["preferredname"]); $return["resolution"] = processInputVar("resolution" , ARG_STRING, $defaultres); $return["bpp"] = processInputVar("bpp" , ARG_NUMERIC, $user["bpp"]); $return["audiomode"] = processInputVar("audiomode" , ARG_STRING, $user["audiomode"]); $return["mapdrives"] = processInputVar("mapdrives" , ARG_NUMERIC, $user["mapdrives"]); $return["mapprinters"] = processInputVar("mapprinters" , ARG_NUMERIC, $user["mapprinters"]); $return["mapserial"] = processInputVar("mapserial" , ARG_NUMERIC, $user["mapserial"]); $return['unityid'] = "{$user['unityid']}@{$user['affiliation']}"; if(! $checks) { return $return; } if(strlen($return["preferredname"]) > 25) { $submitErr |= PREFNAMEERR; $submitErrMsg[PREFNAMEERR] = "Preferred name can only be up to 25 characters"; } if(! preg_match('/^[a-zA-Z ]*$/', $return["preferredname"])) { $submitErr |= PREFNAMEERR; $submitErrMsg[PREFNAMEERR] = "Preferred name can only contain letters and spaces"; } if(array_key_exists('unityid', $return) && ! validateUserid($return['unityid'])) { $submitErr |= VIEWASUSERERR; $submitErrMsg[VIEWASUSERERR] = "Invalid user id"; } if($user['affiliation'] == 'Local' && array_key_exists('newpassword', $_POST)) { $return['newpassword'] = $_POST['newpassword']; $confirmpwd = $_POST['confirmpassword']; $curr = $_POST['currentpassword']; if(get_magic_quotes_gpc()) { $return['newpassword'] = stripslashes($return['newpassword']); $confirmpwd = stripslashes($confirmpwd); $curr = stripslashes($curr); } if(! empty($return['newpassword']) && ! empty($confirmpwd) && ! validateLocalAccount($user['unityid'], $curr)) { $submitErr |= LOCALPASSWORDERR; $submitErrMsg[LOCALPASSWORDERR] = "Password incorrect"; } elseif((empty($return['newpassword']) && ! empty($confirmpwd)) || (! empty($return['newpassword']) && empty($confirmpwd)) || ($return['newpassword'] != $confirmpwd)) { $submitErr |= LOCALPASSWORDERR; $submitErrMsg[LOCALPASSWORDERR] = "Passwords do not match"; } } return $return; } //////////////////////////////////////////////////////////////////////////////// /// /// \fn printUserprefJavascript() /// /// \brief prints javascript used in user preferences page /// //////////////////////////////////////////////////////////////////////////////// function printUserprefJavascript() { print << function show(id) { var obj = document.getElementById("personal"); if(obj) obj.className = "hidden"; document.getElementById("rdpfile").className = "hidden"; document.getElementById("uiprefs").className = "hidden"; document.getElementById("viewmode").className = "hidden"; document.getElementById("status").className = "hidden"; if(id == 'personal' && ! obj) id = 'rdpfile'; document.getElementById(id).className = "shown"; } show("personal"); document.getElementById("preflinks").className = "shown"; document.getElementById("status").className = "visible"; HTMLdone; } ?>