--- loncom/interface/lonpreferences.pm 2009/08/12 20:43:18 1.168 +++ loncom/interface/lonpreferences.pm 2009/10/08 22:37:33 1.174 @@ -1,7 +1,7 @@ # The LearningOnline Network # Preferences # -# $Id: lonpreferences.pm,v 1.168 2009/08/12 20:43:18 www Exp $ +# $Id: lonpreferences.pm,v 1.174 2009/10/08 22:37:33 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,6 +42,7 @@ use Apache::loncommon(); use Apache::lonhtmlcommon(); use Apache::lonlocal; use Apache::lonnet; +use LONCAPA::lonauthcgi(); use LONCAPA(); # @@ -1338,6 +1339,8 @@ sub jscript_send { this.document.client.elements.uname.value; this.document.pserver.elements.udom.value = this.document.client.elements.udom.options[this.document.client.elements.udom.selectedIndex].value; + this.document.pserver.elements.email.value = + this.document.client.elements.email.value; |; } $ output .= qq| @@ -1356,7 +1359,8 @@ sub client_form { 'currentpass' => 'Current Password', 'newpass' => 'New Password', 'confirmpass' => 'Confirm Password', - 'changepass' => 'Save'); + 'changepass' => 'Save', + ); my $output = '
' .&Apache::lonhtmlcommon::start_pick_box(); @@ -1421,6 +1425,7 @@ sub server_form { + |; } @@ -1565,7 +1570,7 @@ ENDERROR # Inform the user the password has (not?) been changed my $message; if ($result =~ /^ok$/) { - $message = &Apache::lonhtmlcommon::confirm_success(&mt('The password for user [_1] was successfully changed.',''.$user.'')); + $message = &Apache::lonhtmlcommon::confirm_success(&mt('The password for user [_1] was successfully changed.',''.$user.'')); if ($caller eq 'reset_by_email') { $r->print($message.'
'); } else { @@ -1573,13 +1578,18 @@ ENDERROR } } else { # error error: run in circles, scream and shout - $message = &Apache::lonhtmlcommon::confirm_success( - &mt("The password for user [_1] was not changed.",''.$user.'').' '.&mt('Please make sure your old password was entered correctly.'),1); - unless ($caller eq 'reset_by_email') { + if ($caller eq 'reset_by_email') { + if (!$result) { + return 1; + } else { + return $result; + } + } else { + $message = &Apache::lonhtmlcommon::confirm_success( + &mt("The password for user [_1] was not changed.",''.$user.'').' '.&mt('Please make sure your old password was entered correctly.'),1); $message=&Apache::loncommon::confirmwrapper($message); &print_main_menu($r, $message); } - return 1; } return; } @@ -1607,7 +1617,7 @@ sub discussionchanger { } } if (defined($userenv{'discmarkread'})) { - unless ($userenv{'discdisplay'} eq '') { + unless ($userenv{'discmarkread'} eq '') { $discmark = $userenv{'discmarkread'}; } } @@ -1651,7 +1661,7 @@ sub discussionchanger { $currmark = $lt{'ondisp'}; $newmark = 'onmark'; } - + $r->print(<<"END"); @@ -1700,11 +1710,11 @@ sub verify_and_change_discussion { if (defined($env{'form.discdisp'}) ) { my $newdisp = $env{'form.newdisp'}; if ($newdisp eq 'unread') { - $message .=&mt('In discussions: only new posts will be displayed.').'
'; + $message .=&Apache::lonhtmlcommon::confirm_success(&mt('In discussions: only new posts will be displayed.')).'
'; &Apache::lonnet::put('environment',{'discdisplay' => $newdisp}); &Apache::lonnet::appenv({'environment.discdisplay' => $newdisp}); } else { - $message .= &mt('In discussions: all posts will be displayed.').'
'; + $message .= &Apache::lonhtmlcommon::confirm_success(&mt('In discussions: all posts will be displayed.')).'
'; &Apache::lonnet::del('environment',['discdisplay']); &Apache::lonnet::delenv('environment.discdisplay'); } @@ -1943,7 +1953,7 @@ push(@{ $menu[1]->{items} }, { url => '/adm/remote?url=/adm/preferences&action=launch', permission => 'F', #help => '', - icon => 'network-wireless.png', + icon => 'remotecontrol.png', linktitle => 'Launch the remote control for LON-CAPA.', }); }else{ @@ -1952,7 +1962,7 @@ push(@{ $menu[1]->{items} }, { url => '/adm/remote?url=/adm/preferences&action=collapse', permission => 'F', #help => '', - icon => 'network-wireless.png', + icon => 'remotecontrol.png', linktitle => 'Collapse the remote control for LON-CAPA.', }); } @@ -1981,9 +1991,9 @@ push(@{ $menu[4]->{items} }, { }); } - if ($env{'user.name'} =~ /^(albertel|fox|foxr|kortemey|korte|raeburn)$/) { + if (&can_toggle_debug()) { push(@{ $menu[4]->{items} }, { - linktext => 'Toggle Debug Messages (Current:'.$env{'user.debug'}.')', + linktext => 'Toggle Debug Messages (Currently '.($env{'user.debug'} ? 'on)' : 'off)'), url => '/adm/preferences?action=debugtoggle', permission => 'F', #help => '', @@ -2082,7 +2092,9 @@ sub handler { }elsif($env{'form.action'} eq 'verify_and_change_coursepage'){ &verify_and_change_coursepage($r); }elsif($env{'form.action'} eq 'debugtoggle'){ - &toggle_debug(); + if (&can_toggle_debug()) { + &toggle_debug(); + } &print_main_menu($r); } @@ -2105,5 +2117,16 @@ sub toggle_debug { } } +sub can_toggle_debug { + my $can_toggle = 0; + my $page = 'toggledebug'; + if (&LONCAPA::lonauthcgi::can_view($page)) { + $can_toggle = 1; + } elsif (&LONCAPA::lonauthcgi::check_ipbased_access($page)) { + $can_toggle = 1; + } + return $can_toggle; +} + 1; __END__