--- loncom/interface/lonpreferences.pm 2009/07/09 19:28:36 1.167 +++ loncom/interface/lonpreferences.pm 2009/12/15 14:52:00 1.181 @@ -1,7 +1,7 @@ # The LearningOnline Network # Preferences # -# $Id: lonpreferences.pm,v 1.167 2009/07/09 19:28:36 droeschl Exp $ +# $Id: lonpreferences.pm,v 1.181 2009/12/15 14:52:00 wenzelju 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(); # @@ -165,8 +166,11 @@ sub languagechanger { = &Apache::loncommon::plainlanguagedescription($_); } } - my $selectionbox=&Apache::loncommon::select_form($language,'language', - %langchoices); + my $selectionbox= + &Apache::loncommon::select_form( + $language, + 'language', + &Apache::lonlocal::texthash(%langchoices)); $r->print(< @@ -205,9 +209,9 @@ sub texenginechanger { my $r = shift; Apache::lonhtmlcommon::add_breadcrumb( { href => '/adm/preferences?action=changetexenginepref', - text => 'Change How Math Equations Are Displayed'}); + text => 'Math display settings'}); $r->print(Apache::loncommon::start_page('Content Display Settings')); - $r->print(Apache::lonhtmlcommon::breadcrumbs('Change How Math Equations Are Displayed')); + $r->print(Apache::lonhtmlcommon::breadcrumbs('Math display settings')); my $user = $env{'user.name'}; my $domain = $env{'user.domain'}; my %userenv = &Apache::lonnet::get('environment',['texengine']); @@ -217,14 +221,18 @@ sub texenginechanger { 'tth' => 'tth (TeX to HTML)', #'ttm' => 'TeX to MathML', 'jsMath' => 'jsMath', - 'mimetex' => 'mimetex (Convert to Images)' + 'mimetex' => 'mimetex (Convert to Images)', + 'raw' => 'Raw (Screen Reader)' ); - my $selectionbox=&Apache::loncommon::select_form($texengine,'texengine', - %mathchoices); + my $selectionbox= + &Apache::loncommon::select_form( + $texengine, + 'texengine', + &Apache::lonlocal::texthash(%mathchoices)); my $jsMath_start=&Apache::lontexconvert::jsMath_header(); my %lt=&Apache::lonlocal::texthash( - 'headline' => 'Change Math Preferences', - 'preftxt' => 'Preferred method to display Math', + 'headline' => 'Change how math is displayed', + 'preftxt' => 'Preferred method to display math', 'change' => 'Save', 'exmpl' => 'Examples', 'jsmath' => 'jsMath:', @@ -279,7 +287,7 @@ if (jsMath.nofonts == 1) {

$lt{'tth'}

- +

ENDLSCREEN if ($env{'environment.texengine'} ne 'jsMath') { @@ -391,13 +399,20 @@ sub rolesprefchanger {

-
-
'.&mt('Number of '.$role.'s in Hotlist:').' - -

'.&mt('This list below can be used to freeze '.$lc_role.'s on your screen. Those marked as frozen will not be removed from the list, even if they have not been used recently.').' +
'. +'

'.&mt('Recent '.$role.'s Hotlist').'

'. +&Apache::lonhtmlcommon::start_pick_box(). +&Apache::lonhtmlcommon::row_title(''). +''. +&Apache::lonhtmlcommon::row_closure(). +&Apache::lonhtmlcommon::row_title(''). +''. +&Apache::lonhtmlcommon::row_closure(1). +&Apache::lonhtmlcommon::end_pick_box(). +'

'.&mt('Freeze Roles').'

'. +'

'.&mt('This list below can be used to freeze '.$lc_role.'s on your screen. Those marked as frozen will not be removed from the list, even if they have not been used recently.').'

'.$roles_check_list.'
@@ -447,19 +462,15 @@ sub verify_and_change_rolespref { if ($hotlist_flag) { &Apache::lonnet::put('environment',{'recentroles' => $hotlist_flag}); &Apache::lonnet::appenv({'environment.recentroles' => $hotlist_flag}); - $message=&mt('Recent '.$role.'s Hotlist is Enabled'); + $message=&Apache::lonhtmlcommon::confirm_success(&mt('Recent '.$role.'s Hotlist is Enabled.')." ".&mt('Display [_1] Most Recent '.$role.'s.',$hotlist_n)); } else { &Apache::lonnet::del('environment',['recentroles']); &Apache::lonnet::delenv('environment.recentroles'); - $message=&mt('Recent '.$role.'s Hotlist is Disabled'); + $message=&Apache::lonhtmlcommon::confirm_success(&mt('Recent '.$role.'s Hotlist is Disabled')); } if ($hotlist_n) { &Apache::lonnet::put('environment',{'recentrolesn' => $hotlist_n}); &Apache::lonnet::appenv({'environment.recentrolesn' => $hotlist_n}); - if ($hotlist_flag) { - $message.="
". - &mt('Display [_1] Most Recent '.$role.'s',$hotlist_n)."\n"; - } } # Get list of froze roles and list of recent roles @@ -777,11 +788,11 @@ sub msgforwardchanger { all => 'All', crit => 'Critical only', reg => 'Non-critical only', - foad => 'Forwarding Address(es)', - noti => 'Notification E-mail Address(es)', + foad => 'Forward to account(s)', + fwdm => 'Forward messages to other account(s) in LON-CAPA', + noti => 'E-mail notification of LON-CAPA messages', foad_exmpl => 'e.g. userA:domain1,userB:domain2,...', - mnot => 'E-mail Address(es) which should be notified about new LON-CAPA messages', - # old: 'Message Notification Email Address(es)', + mnot => 'E-mail address(es) which should be notified about new LON-CAPA messages', mnot_exmpl => 'e.g. joe@doe.com', chg => 'Save', email => 'The e-mail address entered in row ', @@ -791,9 +802,9 @@ sub msgforwardchanger { ); Apache::lonhtmlcommon::add_breadcrumb( { href => '/adm/preferences?action=changemsgforward', - text => 'Change Message Forwarding/Notification'}); - $r->print(Apache::loncommon::start_page('Message Management')); - $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Message Forwarding/Notification')); + text => 'Messages & Notifications'}); + $r->print(Apache::loncommon::start_page('Messages & Notifications')); + $r->print(Apache::lonhtmlcommon::breadcrumbs('Messages & Notifications')); my $forwardingHelp = &Apache::loncommon::help_open_topic("Prefs_Forwarding"); my $notificationHelp = &Apache::loncommon::help_open_topic("Prefs_Notification"); my $criticalMessageHelp = &Apache::loncommon::help_open_topic("Course_Critical_Message"); @@ -859,11 +870,12 @@ $validatescript $r->print(<$lt{'foad'} $forwardingHelp +

$lt{'fwdm'} $forwardingHelp

$lt{'foad'} ($lt{'foad_exmpl'}): -
+ +

$lt{'noti'} $notificationHelp

$lt{'mnot'} ($lt{'mnot_exmpl'}):
ENDMSG @@ -908,7 +920,7 @@ ENDMSG ''. - $lt{$type}.' '; + $lt{$type}.''.(' ' x4); } my $htmlon = ''; my $htmloff = ''; @@ -920,7 +932,7 @@ ENDMSG $output .= ' '. + &mt('Yes').''.(' ' x3). ''.(' ' x4); } $output .= ' '. + '" value="1" />'.&mt('Yes').''.(' ' x3). ''. @@ -1002,12 +1014,11 @@ sub verify_and_change_msgforward { if ($newscreen) { &Apache::lonnet::put('environment',{'msgforward' => $newscreen}); &Apache::lonnet::appenv({'environment.msgforward' => $newscreen}); - $message .= &mt('Set message forwarding to ').'"'.$newscreen.'".' - .'
'; + $message .= &Apache::lonhtmlcommon::confirm_success(&mt('Set message forwarding to ').'"'.$newscreen.'".
'); } else { &Apache::lonnet::del('environment',['msgforward']); &Apache::lonnet::delenv('environment.msgforward'); - $message.= &mt("Set message forwarding to 'off'.").'
'; + $message.= &Apache::lonhtmlcommon::confirm_success(&mt("Set message forwarding to 'off'.").'
'); } my $critnotification; my $notification; @@ -1043,43 +1054,41 @@ sub verify_and_change_msgforward { if ($notification) { &Apache::lonnet::put('environment',{'notification' => $notification}); &Apache::lonnet::appenv({'environment.notification' => $notification}); - $message.=&mt('Set non-critical message notification address(es) to ').'"'.$notification.'".
'; + $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Set non-critical message notification address(es) to ').'"'.$notification.'".
'); } else { &Apache::lonnet::del('environment',['notification']); &Apache::lonnet::delenv('environment.notification'); - $message.=&mt("Set non-critical message notification to 'off'.").'
'; + $message.=&Apache::lonhtmlcommon::confirm_success(&mt("Set non-critical message notification to 'off'.").'
'); } if ($critnotification) { &Apache::lonnet::put('environment',{'critnotification' => $critnotification}); &Apache::lonnet::appenv({'environment.critnotification' => $critnotification}); - $message.=&mt('Set critical message notification address(es) to ').'"'.$critnotification.'".
'; + $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Set critical message notification address(es) to ').'"'.$critnotification.'".
'); } else { &Apache::lonnet::del('environment',['critnotification']); &Apache::lonnet::delenv('environment.critnotification'); - $message.=&mt("Set critical message notification to 'off'.").'
'; + $message.=&Apache::lonhtmlcommon::confirm_success(&mt("Set critical message notification to 'off'.").'
'); } if ($critnotification || $notification) { if ($notify_with_html) { &Apache::lonnet::put('environment',{'notifywithhtml' => $notify_with_html}); &Apache::lonnet::appenv({'environment.notifywithhtml' => $notify_with_html}); - $message.=&mt('Set address(es) to receive excerpts with html retained ').'"'.$notify_with_html.'".'; + $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Set address(es) to receive excerpts with html retained ').'"'.$notify_with_html.'".'); } else { &Apache::lonnet::del('environment',['notifywithhtml']); &Apache::lonnet::delenv('environment.notifywithhtml'); if ($totaladdresses == 1) { - $message.=&mt("Set notification address to receive excerpts with html stripped."); + $message.=&Apache::lonhtmlcommon::confirm_success(&mt("Set notification address to receive excerpts with html stripped.")); } else { - $message.=&mt("Set all notification addresses to receive excerpts with html stripped."); + $message.=&Apache::lonhtmlcommon::confirm_success(&mt("Set all notification addresses to receive excerpts with html stripped.")); } } } else { &Apache::lonnet::del('environment',['notifywithhtml']); &Apache::lonnet::delenv('environment.notifywithhtml'); } - if ($message) { - $message .= '

'; - } &Apache::loncommon::flush_email_cache($user,$domain); + $message=&Apache::loncommon::confirmwrapper($message); &msgforwardchanger($r,$message); } @@ -1337,6 +1346,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| @@ -1355,7 +1366,8 @@ sub client_form { 'currentpass' => 'Current Password', 'newpass' => 'New Password', 'confirmpass' => 'Confirm Password', - 'changepass' => 'Save'); + 'changepass' => 'Save', + ); my $output = '' .&Apache::lonhtmlcommon::start_pick_box(); @@ -1420,6 +1432,7 @@ sub server_form { + |; } @@ -1564,7 +1577,8 @@ 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.'')); + $message = &Apache::loncommon::confirmwrapper($message); if ($caller eq 'reset_by_email') { $r->print($message.'
'); } else { @@ -1572,13 +1586,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; } @@ -1591,7 +1610,7 @@ sub discussionchanger { Apache::lonhtmlcommon::add_breadcrumb( { href => '/adm/preferences?action=changediscussions', text => 'Change Discussion Preferences'}); - $r->print(Apache::loncommon::start_page('Message Management')); + $r->print(Apache::loncommon::start_page('Change Discussion Preferences')); $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Discussion Preferences')); my $user = $env{'user.name'}; my $domain = $env{'user.domain'}; @@ -1606,7 +1625,7 @@ sub discussionchanger { } } if (defined($userenv{'discmarkread'})) { - unless ($userenv{'discdisplay'} eq '') { + unless ($userenv{'discmarkread'} eq '') { $discmark = $userenv{'discmarkread'}; } } @@ -1650,7 +1669,7 @@ sub discussionchanger { $currmark = $lt{'ondisp'}; $newmark = 'onmark'; } - + $r->print(<<"END"); @@ -1699,11 +1718,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'); } @@ -1802,13 +1821,15 @@ sub verify_and_change_coursepage { my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my ($furl,$ferr)= &Apache::lonuserstate::readmap($cdom.'/'.$cnum); - $message .= '
'.$lt{'gtts'}.' '.&mt('now').''; + $message .= '
'.$lt{'gtts'}.' '.&mt('now').''; } else { - $message .= '
'.$lt{'dasp'}.''; + $message .= '
'.$lt{'dasp'}.''; } } - &print_main_menu($r, &Apache::lonhtmlcommon::confirm_success($message)); + $message = &Apache::lonhtmlcommon::confirm_success($message); + $message = &Apache::loncommon::confirmwrapper($message); + &print_main_menu($r,$message); } sub print_main_menu { @@ -1886,16 +1907,16 @@ my @menu= icon => 'sctr.png', linktitle => 'Configure the roles hotlist.' }, - { linktext => 'Display of Scientific Equations', + { linktext => 'Math display settings', url => '/adm/preferences?action=changetexenginepref', permission => 'F', #help => '', icon => 'stat.png', - linktitle => 'Change how Scientific Equations are displayed.' + linktitle => 'Change how math is displayed.' }, ] }, - { categorytitle=>'Message Management', + { categorytitle=>'Messages & Notifications', items =>[ { linktext => 'Messages & Notifications', url => '/adm/preferences?action=changemsgforward', @@ -1942,7 +1963,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{ @@ -1951,7 +1972,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.', }); } @@ -1980,9 +2001,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 => '', @@ -2081,7 +2102,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); } @@ -2104,5 +2127,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__