--- loncom/interface/lonpreferences.pm 2009/08/12 20:43:18 1.168 +++ loncom/interface/lonpreferences.pm 2010/09/19 14:22:40 1.179.2.4 @@ -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.179.2.4 2010/09/19 14:22:40 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(); # @@ -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']); @@ -220,12 +224,15 @@ sub texenginechanger { '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:', @@ -280,7 +287,7 @@ if (jsMath.nofonts == 1) {

$lt{'tth'}

- +

ENDLSCREEN if ($env{'environment.texengine'} ne 'jsMath') { @@ -778,11 +785,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 ', @@ -792,9 +799,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"); @@ -860,11 +867,12 @@ $validatescript $r->print(<$lt{'foad'} $forwardingHelp +

$lt{'fwdm'} $forwardingHelp

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

$lt{'noti'} $notificationHelp

$lt{'mnot'} ($lt{'mnot_exmpl'}):
ENDMSG @@ -909,7 +917,7 @@ ENDMSG ''. - $lt{$type}.' '; + $lt{$type}.''.(' ' x4); } my $htmlon = ''; my $htmloff = ''; @@ -921,7 +929,7 @@ ENDMSG $output .= ' '. + &mt('Yes').''.(' ' x3). ''.(' ' x4); } $output .= ' '. + '" value="1" />'.&mt('Yes').''.(' ' x3). ''. @@ -987,16 +995,21 @@ sub verify_and_change_msgforward { my $domain = $env{'user.domain'}; my $newscreen = ''; my $message=''; - foreach (split(/\,/,$env{'form.msgforward'})) { - my ($msuser,$msdomain)=split(/[\@\:]/,$_); + foreach my $recip (split(/\,/,$env{'form.msgforward'})) { + my ($msuser,$msdomain); + if ($recip =~ /:/) { + ($msuser,$msdomain)=split(':',$recip); + } else { + ($msuser,$msdomain)=split(/\@/,$recip); + } $msuser = &LONCAPA::clean_username($msuser); $msdomain = &LONCAPA::clean_domain($msdomain); if (($msuser) && ($msdomain)) { - if (&Apache::lonnet::homeserver($msuser,$msdomain) ne 'no_host') { - $newscreen.=$msuser.':'.$msdomain.','; - } else { - $message.= &mt('No such user: ').''.$msuser.':'.$msdomain.'
'; - } + if (&Apache::lonnet::homeserver($msuser,$msdomain) ne 'no_host') { + $newscreen.=$msuser.':'.$msdomain.','; + } else { + $message.= &mt('No such user: ').''.$msuser.':'.$msdomain.'
'; + } } } $newscreen=~s/\,$//; @@ -1338,6 +1351,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 +1371,8 @@ sub client_form { 'currentpass' => 'Current Password', 'newpass' => 'New Password', 'confirmpass' => 'Confirm Password', - 'changepass' => 'Save'); + 'changepass' => 'Save', + ); my $output = '' .&Apache::lonhtmlcommon::start_pick_box(); @@ -1367,7 +1383,7 @@ sub client_form { .&Apache::lonhtmlcommon::row_closure() .&Apache::lonhtmlcommon::row_title( '') - .'' + .'' .'' .&Apache::lonhtmlcommon::row_closure() .&Apache::lonhtmlcommon::row_title( @@ -1421,6 +1437,7 @@ sub server_form { + |; } @@ -1565,7 +1582,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 +1590,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; } @@ -1592,7 +1614,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'}; @@ -1607,7 +1629,7 @@ sub discussionchanger { } } if (defined($userenv{'discmarkread'})) { - unless ($userenv{'discdisplay'} eq '') { + unless ($userenv{'discmarkread'} eq '') { $discmark = $userenv{'discmarkread'}; } } @@ -1651,7 +1673,7 @@ sub discussionchanger { $currmark = $lt{'ondisp'}; $newmark = 'onmark'; } - + $r->print(<<"END"); @@ -1700,11 +1722,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'); } @@ -1828,23 +1850,8 @@ if (&Apache::lonnet::usertools_access($u } my @menu= ({ categorytitle=>'Personal Data', - items =>[ - { linktext => 'Personal Information Page', - url => $aboutmeurl, - permission => $permissions{'aboutme'}, - #help => 'Prefs_About_Me', - icon => 'system-users.png', - linktitle => 'Edit information about yourself that should be displayed on your public profile.' - }, - { linktext => 'Screen Name', - url => '/adm/preferences?action=changescreenname', - permission => 'F', - #help => 'Prefs_Screen_Name_Nickname', - icon => 'preferences-desktop-font.png', - linktitle => 'Change the name that is displayed in your posts.' - }, - ] - }, + items =>[] + }, { categorytitle=>'Page Display Settings', items =>[ { linktext => 'Color Scheme', @@ -1854,25 +1861,10 @@ my @menu= icon => 'preferences-desktop-theme.png', linktitle => 'Change LON-CAPA default colors.' }, - { linktext => 'Menu Display', - url => '/adm/preferences?action=changeicons', - permission => 'F', - #help => '', - icon => 'preferences-system-windows.png', - linktitle => 'Change whether the menus are displayed with buttons, icons or icons and text.' - } - ] }, { categorytitle=>'Content Display Settings', items =>[ - { linktext => 'Language', - url => '/adm/preferences?action=changelanguages', - permission => 'F', - #help => 'Prefs_Language', - icon => 'preferences-desktop-locale.png', - linktitle => 'Choose the default language for this user.' - }, { linktext => 'WYSIWYG Editor', url => '/adm/preferences?action=changewysiwyg', permission => 'F', @@ -1880,23 +1872,16 @@ my @menu= icon => 'edit-select-all.png', linktitle => 'Enable or disable the WYSIWYG-Editor.' }, - { linktext => $role.' Page', - url => '/adm/preferences?action=changerolespref', - permission => 'F', - #help => '', - 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', @@ -1905,28 +1890,36 @@ my @menu= icon => 'mail-reply-all.png', linktitle => 'Change messageforwarding or notifications settings.' }, - { linktext => 'Discussion Display', - url => '/adm/preferences?action=changediscussions', - permission => 'F', - #help => 'Change_Discussion_Display', - icon => 'mail-message-new.png', - linktitle => 'Set display preferences for discussion posts for both discussion boards and individual resources in all your courses.' - }, ] }, { categorytitle=>'Other', - items =>[ - { linktext => 'Register Response Devices ("Clickers")', - url => '/adm/preferences?action=changeclicker', - permission => 'F', - #help => '', - icon => 'network-workgroup.png', - linktitle => 'Register your clicker.' - }, - ] + items =>[] }, ); + if (&Apache::lonnet::usertools_access($env{'user.name'}, + $env{'user.domain'},'aboutme')) { + push(@{ $menu[0]->{items} }, + { linktext => 'Personal Information Page', + url => $aboutmeurl, + permission => $permissions{'aboutme'}, + #help => 'Prefs_About_Me', + icon => 'system-users.png', + linktitle => 'Edit information about yourself that should be displayed on your public profile.' + }); + } + + unless ($env{'user.domain'} eq 'gcitest') { + push(@{ $menu[0]->{items} }, + { linktext => 'Screen Name', + url => '/adm/preferences?action=changescreenname', + permission => 'F', + #help => 'Prefs_Screen_Name_Nickname', + icon => 'preferences-desktop-font.png', + linktitle => 'Change the name that is displayed in your posts.' + }); + } + if ($currentauth =~ /^(unix|internal):/) { push(@{ $menu[0]->{items} }, { linktext => 'Password', @@ -1937,25 +1930,29 @@ push(@{ $menu[0]->{items} }, { linktitle => 'Change your password.', }); } - if ($env{'environment.remote'} eq 'off') { -push(@{ $menu[1]->{items} }, { - linktext => 'Launch Remote Control', - url => '/adm/remote?url=/adm/preferences&action=launch', - permission => 'F', - #help => '', - icon => 'network-wireless.png', - linktitle => 'Launch the remote control for LON-CAPA.', - }); - }else{ -push(@{ $menu[1]->{items} }, { - linktext => 'Collapse Remote Control', - url => '/adm/remote?url=/adm/preferences&action=collapse', - permission => 'F', - #help => '', - icon => 'network-wireless.png', - linktitle => 'Collapse the remote control for LON-CAPA.', - }); + + unless ((&Apache::loncommon::needs_gci_custom()) || ($env{'user.domain'} eq 'gcitest')) { + push(@{ $menu[1]->{items} }, + { linktext => 'Menu Display', + url => '/adm/preferences?action=changeicons', + permission => 'F', + #help => '', + icon => 'preferences-system-windows.png', + linktitle => 'Change whether the menus are displayed with buttons, icons or icons and text.' + }); + } + + unless ($env{'user.domain'} eq 'gcitest') { + push(@{ $menu[3]->{items} }, + { linktext => 'Discussion Display', + url => '/adm/preferences?action=changediscussions', + permission => 'F', + #help => 'Change_Discussion_Display', + icon => 'mail-message-new.png', + linktitle => 'Set display preferences for discussion posts for both discussion boards and individual resources in all your courses.' + }); } + my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au']); if (keys(%author_roles) > 0) { push(@{ $menu[4]->{items} }, { @@ -1968,9 +1965,10 @@ push(@{ $menu[4]->{items} }, { }); } - if (&Apache::lonnet::allowed('whn',$env{'request.course.id'}) - || &Apache::lonnet::allowed('whn',$env{'request.course.id'}.'/' - .$env{'request.course.sec'})) { + unless ((&Apache::loncommon::needs_gci_custom()) || ($env{'user.domain'} eq 'gcitest')) { + if (&Apache::lonnet::allowed('whn',$env{'request.course.id'}) + || &Apache::lonnet::allowed('whn',$env{'request.course.id'}.'/' + .$env{'request.course.sec'})) { push(@{ $menu[4]->{items} }, { linktext => 'Course Initialization', url => '/adm/preferences?action=changecourseinit', @@ -1980,17 +1978,18 @@ push(@{ $menu[4]->{items} }, { linktitle => 'Set the default page to be displayed when you select a course role.', }); + } } - 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 => '', icon => 'blog.png', linktitle => 'Toggle Debug Messages.', }); - } + } $r->print(&Apache::loncommon::start_page('My Space')); $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Preferences')); @@ -2082,7 +2081,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 +2106,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__