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", "32" => "32"); 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($user['showallgroups']) { $selected['affiliation'] = ''; $selected['allgroups'] = 'checked'; } else { $selected['affiliation'] = 'checked'; $selected['allgroups'] = ''; } print _("

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

\n"; 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"; 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; $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"]); 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($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("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; } ?>