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\\+/ @=\\.\\n\\r]*$|', $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(); }
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(); }