--- loncom/interface/lonpreferences.pm 2005/06/06 22:39:59 1.63 +++ loncom/interface/lonpreferences.pm 2006/05/01 19:37:34 1.81 @@ -1,7 +1,7 @@ # The LearningOnline Network # Preferences # -# $Id: lonpreferences.pm,v 1.63 2005/06/06 22:39:59 raeburn Exp $ +# $Id: lonpreferences.pm,v 1.81 2006/05/01 19:37:34 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -98,20 +98,20 @@ sub wysiwygchanger { my $r = shift; my %userenv = &Apache::lonnet::get ('environment',['wysiwygeditor']); + my $onselect='checked="checked"'; my $offselect=''; - my $onselect='checked="1"'; - if ($userenv{'wysiwygeditor'}) { + if ($userenv{'wysiwygeditor'} eq 'on') { $onselect=''; - $offselect='checked="1"'; + $offselect='checked="checked"'; } my $switchoff=&mt('Disable WYSIWYG editor'); my $switchon=&mt('Enable WYSIWYG editor'); $r->print(< +

- $switchoff
- $switchon +
+ ENDLSCREEN $r->print('
'); } @@ -147,7 +147,7 @@ sub languagechanger { my $selectionbox=&Apache::loncommon::select_form($language,'language', %langchoices); $r->print(< +
$pref: $selectionbox ENDLSCREEN @@ -188,33 +188,30 @@ sub texenginechanger { my $texengine=$userenv{'texengine'}; my $pref=&mt('Preferred method to display Math'); - my %mathchoices=('' => 'No Preference', + my %mathchoices=('' => 'Default', 'tth' => 'TeX to HTML', - 'ttm' => 'TeX to MathML', + #'ttm' => 'TeX to MathML', 'jsMath' => 'jsMath', 'mimetex' => 'Convert to Images' ); my $selectionbox=&Apache::loncommon::select_form($texengine,'texengine', %mathchoices); - my $mathexample='$$\int\left(\frac{a+b}{c^6*d}\right)$$'; - my $jsMath_example=&Apache::lontexconvert::jsMath_converted(\$mathexample); - $mathexample='$$\int\left(\frac{a+b}{c^6*d}\right)$$'; - my $tth_example=&Apache::lontexconvert::tth_converted(\$mathexample); - $mathexample='$$\int\left(\frac{a+b}{c^6*d}\right)$$'; - my $mimetex_example=&Apache::lontexconvert::mimetex_converted(\$mathexample); + my $jsMath_start=&Apache::lontexconvert::jsMath_header(); my $change=&mt('Change'); $r->print(< +
+ +

$pref: $selectionbox

Examples: -

TeX to HTML
$tth_example

- - +

TeX to HTML
+ +

jsMath
- +$jsMath_start + -$jsMath_example

-

Convert to Images
$mimetex_example

+

+

Convert to Images
+
+ +

ENDLSCREEN if ($env{'environment.texengine'} ne 'jsMath') { $r->print(''); @@ -303,7 +304,7 @@ visited and places a table of these at t People with very few roles should leave this feature disabled.

-
+
Enable Recent Roles Hotlist: @@ -361,7 +362,7 @@ sub screennamechanger { my $screenname=$userenv{'screenname'}; my $nickname=$userenv{'nickname'}; $r->print(< +
New screenname (shown if you post anonymously): @@ -402,7 +403,7 @@ sub verify_and_change_screenname { &Apache::lonnet::delenv('environment\.nickname'); $message.='Reset nickname'; } - + &Apache::lonnet::devalidate_cache_new('namescache',$user.':'.$domain); $r->print(<print(< - + New Forwarding Address(es) (user:domain,user:domain,...):
@@ -504,17 +505,7 @@ ENDVCMSG sub colorschanger { my $r = shift; # figure out colors - my $function='student'; - if ($env{'request.role'}=~/^(cc|in|ta|ep)/) { - $function='coordinator'; - } - if ($env{'request.role'}=~/^(su|dc|ad|li)/) { - $function='admin'; - } - if (($env{'request.role'}=~/^(au|ca)/) || - ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) { - $function='author'; - } + my $function=&Apache::loncommon::get_users_function(); my $domain=&Apache::loncommon::determinedomain(); my %colortypes=('pgbg' => 'Page Background', 'tabbg' => 'Header Background', @@ -549,7 +540,7 @@ sub colorschanger { pclose(); if (document.parmform.pres_marker.value!='') { if (document.parmform.pres_type.value!='') { - eval('document.server.'+ + eval('document.prefs.'+ document.parmform.pres_marker.value+ '.value=document.parmform.pres_value.value;'); } @@ -566,7 +557,7 @@ sub colorschanger { -
+ $chtable @@ -580,17 +571,7 @@ ENDCOL sub verify_and_change_colors { my $r = shift; # figure out colors - my $function='student'; - if ($env{'request.role'}=~/^(cc|in|ta|ep)/) { - $function='coordinator'; - } - if ($env{'request.role'}=~/^(su|dc|ad|li)/) { - $function='admin'; - } - if (($env{'request.role'}=~/^(au|ca)/) || - ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) { - $function='author'; - } + my $function=&Apache::loncommon::get_users_function(); my $domain=&Apache::loncommon::determinedomain(); my %colortypes=('pgbg' => 'Page Background', 'tabbg' => 'Header Background', @@ -616,7 +597,7 @@ sub verify_and_change_colors { } $r->print(< + ENDVCCOL @@ -658,8 +639,6 @@ sub passwordchanger { $lkey_npass2= hex($lkey_npass2); # Output javascript to deal with passwords # Output DES javascript - my $html=&Apache::lonxml::xmlbegin(); - $r->print($html.""); { my $include = $r->dir_config('lonIncludes'); my $jsh=Apache::File->new($include."/londes.js"); @@ -699,7 +678,7 @@ $errormessage ensure that unencrypted passwords will not be sent out by a crappy browser --> -
+ @@ -740,14 +719,6 @@ sub verify_and_change_password { # Check for authentication types that allow changing of the password. return if ($currentauth !~ /^(unix|internal):/); # - my $html=&Apache::lonxml::xmlbegin(); - $r->print(< -LON-CAPA Preferences: Change password for $user - -ENDHEADER - # my $currentpass = $env{'form.currentpass'}; my $newpass1 = $env{'form.newpass_1'}; my $newpass2 = $env{'form.newpass_2'}; @@ -772,7 +743,7 @@ password decryption. Please log out and

ENDERROR # Probably should log an error here - return; + return 1; } my ($ckey,$n1key,$n2key)=split(/&/,$tmpinfo); # @@ -785,14 +756,14 @@ ENDERROR 'ERROR:'. 'The new passwords you entered do not match. '. 'Please try again.'); - return; + return 1; } if (length($newpass1) < 7) { &passwordchanger($r, 'ERROR:'. 'Passwords must be a minimum of 7 characters long. '. 'Please try again.'); - return; + return 1; } # # Check for bad characters @@ -827,6 +798,7 @@ ENDTEXT

The password for $user was not changed

Please make sure your old password was entered correctly. ENDERROR + return 1; } return; } @@ -895,7 +867,7 @@ sub discussionchanger { } $r->print(<<"END"); - +
$lt{'sdpf'}
$lt{'prca'}
  1. $lt{'whpo'}
  2. $lt{'unwh'}
@@ -980,26 +952,33 @@ sub coursedisplaychanger { my $r = shift; my $user = $env{'user.name'}; my $domain = $env{'user.domain'}; - my %userenv = &Apache::lonnet::get - ('environment',['course_init_display']); - - my $firstselect='checked="checked"'; - my $whatsnewselect=''; - if ($userenv{'course_init_display'} eq 'firstres') { - $firstselect=''; - $whatsnewselect='checked="checked"'; + my %userenv = &Apache::lonnet::get('environment',['course_init_display']); + my $currvalue = 'whatsnew'; + my $firstselect = ''; + my $whatsnewselect = 'checked="checked"'; + if (exists($userenv{'course_init_display'})) { + if ($userenv{'course_init_display'} eq 'firstres') { + $currvalue = 'firstres'; + $firstselect = 'checked="checked"'; + $whatsnewselect = ''; + } } - my $whatsnew_off=&mt('Display the first resource in the course.'); - my $whatsnew_on=&mt('Display a summary of items in the course which require action from the course coordinator.'); + my %pagenames = ( + firstres => 'First resource', + whatsnew => "What's new page", + ); + my $whatsnew_off=&mt('Display the [_1] in the course.','first resource'); + my $whatsnew_on=&mt('Display the "[_1]" page - a summary of items in the course which require attention.',"What's New"); - $r->print('
'.&mt('Set the page to be displayed when you select the role of Course Coordinator').':'); + $r->print('
'.&mt('Set the default page to be displayed when you select a course role').' '.&mt('(Currently: [_1])',$pagenames{$currvalue}).'
'.&mt('The global user preference you set for your courses can be overridden in an individual course by setting a course specific setting via the "[_1]" page in the course',"What's New").'

'); $r->print(< + - $whatsnew_off
- $whatsnew_on +
+
+ ENDLSCREEN - $r->print('
+ $r->print('

'); } @@ -1007,22 +986,25 @@ sub verify_and_change_coursepage { my $r = shift; my $message=''; my %lt = &Apache::lonlocal::texthash( - 'when' => 'Whenever you select the Course Coordinator role from the roles screen', + 'defs' => 'Default now set', + 'when' => 'when you select a course role from the roles screen', 'ywbt' => 'you will be taken to the start of the course.', 'apwb' => 'a page will be displayed that lists items in the course that may require action from you.', 'gtts' => 'Go to the start of the course', - 'dasp' => 'Display a summary page listing course action items', + 'dasp' => "Display the What's New page listing course action items", ); my $newdisp = $env{'form.newdisp'}; + $message = ''.$lt{'defs'}.': '.$lt{'when'}.', '; if ($newdisp eq 'firstres') { - $message .= $lt{'when'}.', '.$lt{'ywbt'}.'
'; + $message .= $lt{'ywbt'}.'
'; &Apache::lonnet::put('environment',{'course_init_display' => $newdisp}); &Apache::lonnet::appenv('environment.course_init_display' => $newdisp); } else { - $message .= $lt{'when'}.', '.$lt{'apwb'}.'
'; + $message .= $lt{'apwb'}.'
'; &Apache::lonnet::del('environment',['course_init_display']); &Apache::lonnet::delenv('environment\.course_init_display'); } + my $refpage = $env{'form.refpage'}; if (($env{'request.course.fn'}) && ($env{'request.course.id'})) { if ($newdisp eq 'firstres') { my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; @@ -1031,7 +1013,8 @@ sub verify_and_change_coursepage { &Apache::lonuserstate::readmap($cdom.'/'.$cnum); $message .= '
'.$lt{'gtts'}.' '.&mt('now').''; } else { - $message .= '
'.$lt{'dasp'}.''; + $message .= '
'.$lt{'dasp'}.''; } } $r->print(<header_only; # &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['action','wysiwyg','returnurl']); + ['action','wysiwyg','returnurl','refpage']); # &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb @@ -1084,7 +1067,7 @@ sub handler { breadcrumb => { href =>'/adm/preferences?action=changepass', text => 'Change Password'}, - printmenu => 'yes', + printmenu => 'not_on_error', })); } push (@Options,({ action => 'changescreenname', @@ -1221,7 +1204,9 @@ sub handler { text => 'Change Math Preferences'}, printmenu => 'yes', })); - if($env{'request.role'} =~ /^cc\.\//) { + if (&Apache::lonnet::allowed('whn',$env{'request.course.id'}) + || &Apache::lonnet::allowed('whn',$env{'request.course.id'}.'/' + .$env{'request.course.sec'})) { push (@Options,({ action => 'changecourseinit', linktext => 'Change Course Initialization Preference', href => '/adm/preferences', @@ -1244,13 +1229,9 @@ sub handler { subroutine => \&toggle_debug, })); } - my $html=&Apache::lonxml::xmlbegin(); - $r->print(< -LON-CAPA Preferences - -ENDHEADER + + $r->print(&Apache::loncommon::start_page('Change Preferences')); + my $call = undef; my $help = undef; my $printmenu = 'yes'; @@ -1265,13 +1246,14 @@ ENDHEADER $help=$option->{'help'}; } } - $r->print(&Apache::loncommon::bodytag('Change Preferences')); - $r->print(&Apache::lonhtmlcommon::breadcrumbs - (undef,'Change Preferences',$help)); + $r->print(&Apache::lonhtmlcommon::breadcrumbs('Change Preferences',$help)); + my $error; if (defined($call)) { - $call->($r); + $error = $call->($r); } - if (($printmenu eq 'yes') && (!$env{'form.returnurl'})) { + if ( ( ($printmenu eq 'yes') + || ($printmenu eq 'not_on_error' && !$error) ) + && (!$env{'form.returnurl'})) { my $optionlist = '
'; if ($env{'user.name'} =~ /^(albertel|kortemey|fox|foxr|korte|hallmat3|turtle|raeburn)$/ @@ -1315,7 +1297,7 @@ ENDHEADER $r->print('
'. &mt('Return').''); } - $r->print(&Apache::loncommon::endbodytag().''); + $r->print(&Apache::loncommon::end_page()); return OK; }