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 " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
"; print _("Try decreasing Resolution or Color Depth to speed up your connection if things seem slow when connected to a remote computer."); print "
" . _("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 "
" . _("RDP Port") . ":\n"; print " \n"; printSubmitErr(RDPPORTERR); 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"; ########################### # temporary if(! array_key_exists('usepublickeys', $user)) { $user['usepublickeys'] = 0; $_SESSION['user']['usepublickeys'] = 0; $user['sshpublickeys'] = ''; $_SESSION['user']['sshpublickeys'] = ''; } # end temporary ########################### if($user['usepublickeys']) { $selected['enabled'] = 'checked'; $selected['disabled'] = ''; } else { $selected['enabled'] = ''; $selected['disabled'] = 'checked'; } print "

" . _("Use public key authentication for SSH logins:") . "
\n"; print "
\n"; print "

\n"; print " " . _("Public keys:") . "
\n"; print "

"; print "\n "; print _("Public keys can only contain letters, numbers, spaces, and these characters: + / @ . ="); print "
\n"; print "

\n"; print "" . _("NOTE:") . " "; $h = " " . _("Images using network storage (such as AFS) may not work well with public key authentication. In some cases, you may still be prompted for a password. In other cases, you may need to run additional commands after logging in to gain access to the network storage."); print preg_replace("/(.{1,55}([ \n]|$))/", '\1
', $h) . "\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 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"); 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 "
" . _("Resolution:") . "" . $data["resolution"] . "
" . _("Color Depth:") . "" . $colordepth[$data["bpp"]] . "
" . _("Audio:") . "$audio
" . _("Map Local Drives:") . "$drives
" . _("Map Local Printers:") . "$printers
" . _("Map Local Serial Ports:") . "$serial
" . _("RDP Port") . ":{$data['rdpport']}
\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"; 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; } } updateUserPrefs($user['id'], $data["preferredname"], $width, $height, $data["bpp"], $data["audiomode"], $data["mapdrives"], $data["mapprinters"], $data["mapserial"], $data['rdpport']); 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); $pubkeyauth = processInputVar('pubkeyauth', ARG_NUMERIC); $pubkeys = processInputVar('pubkeys', ARG_STRING); if($groupview != 'affiliation' && $groupview != 'allgroups') { $printedHTMLheader = 1; print $HTMLheader; userpreferences(); return; } if($emailnotify != 1 && $emailnotify != 2) { $printedHTMLheader = 1; print $HTMLheader; userpreferences(); return; } if($pubkeyauth != 1 && $pubkeyauth != 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; } if(($user['usepublickeys'] == 1 && $pubkeyauth == 1) || ($user['usepublickeys'] == 0 && $pubkeyauth == 2)) { $newval = $pubkeyauth - 1; $query = "UPDATE user SET usepublickeys = $newval WHERE id = {$user['id']}"; doQuery($query); $_SESSION['user']['usepublickeys'] = $newval; $user['usepublickeys'] = $newval; } if($pubkeyauth == 2 && preg_match('|^[-a-zA-Z0-9\+/ @=\.]*$|', $pubkeys)) { if(get_magic_quotes_gpc()) $pubkeys = stripslashes($pubkeys); $_pubkeys = mysql_real_escape_string($pubkeys); $query = "UPDATE user SET sshpublickeys = '$_pubkeys' WHERE id = {$user['id']}"; doQuery($query); $_SESSION['user']['sshpublickeys'] = htmlspecialchars($pubkeys); $user['sshpublickeys'] = htmlspecialchars($pubkeys); } 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["rdpport"] = processInputVar("rdpport" , ARG_NUMERIC, 3389); 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"); } } if($return['rdpport'] != $user['rdpport']) { $requests = getUserRequests('all'); $nochange = 0; foreach($requests as $req) { if(preg_match('/^(3|8|24|25|26|27|28|29)$/', $req['currstateid']) || ($req['currstateid'] == 14 && preg_match('/^(3|8|24|25|26|27|28|29)$/', $req['laststateid']))) { $nochange = 1; break; } } if($nochange) { $submitErr |= RDPPORTERR; $submitErrMsg[RDPPORTERR] = _("RDP Port cannot be changed while you have active reservations"); } } if(! ($submitErr & RDPPORTERR) && ($return['rdpport'] < 1024 || $return['rdpport'] > 65535)) { $submitErr |= RDPPORTERR; $submitErrMsg[RDPPORTERR] = _("RDP Port must be between 1024 and 65535"); } return $return; } //////////////////////////////////////////////////////////////////////////////// /// /// \fn printUserprefJavascript() /// /// \brief prints javascript used in user preferences page /// //////////////////////////////////////////////////////////////////////////////// function printUserprefJavascript() { global $submitErr; 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"; } function validatePublicKeys() { var data = dijit.byId('pubkeys').value; var patt = /^[-a-zA-Z0-9\+/ @=\.\\n]{0,65535}$/; if(! patt.test(data)) { dojo.removeClass('pubkeyerr', 'hidden'); return false; } dojo.addClass('pubkeyerr', 'hidden'); return true; } function togglePubKeys(mode) { if(mode) dijit.byId('pubkeys').set('disabled', false); else dijit.byId('pubkeys').set('disabled', true); } HTMLdone; if(! ($submitErr & PREFNAMEERR) && ! ($submitErr & LOCALPASSWORDERR) && ($submitErr & RDPPORTERR)) print "show(\"rdpfile\");\n"; else print "show(\"personal\");\n"; print << HTMLdone; } ?>