--- loncom/interface/lonpreferences.pm 2004/07/09 21:05:14 1.46 +++ loncom/interface/lonpreferences.pm 2005/02/28 19:08:11 1.57 @@ -1,7 +1,7 @@ # The LearningOnline Network # Preferences # -# $Id: lonpreferences.pm,v 1.46 2004/07/09 21:05:14 raeburn Exp $ +# $Id: lonpreferences.pm,v 1.57 2005/02/28 19:08:11 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -177,6 +177,179 @@ $message ENDVCSCREEN } +################################################################ +# Tex Engine Change Subroutines # +################################################################ +sub texenginechanger { + my $r = shift; + my $user = $ENV{'user.name'}; + my $domain = $ENV{'user.domain'}; + my %userenv = &Apache::lonnet::get('environment',['texengine']); + my $texengine=$userenv{'texengine'}; + + my $pref=&mt('Preferred method to display Math'); + my %mathchoices=('' => 'No Preference', + 'tth' => 'TeX to HTML', + '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 $change=&mt('Change'); + $r->print(< + +

$pref: $selectionbox

+

+ +Examples: +

TeX to HTML
$tth_example

+ + +

jsMath
+ + + +$jsMath_example

+

Convert to Images
$mimetex_example

+ENDLSCREEN + if ($ENV{'environment.texengine'} ne 'jsMath') { + $r->print(''); + } +} + + +sub verify_and_change_texengine { + my $r = shift; + my $user = $ENV{'user.name'}; + my $domain = $ENV{'user.domain'}; +# Screenname + my $newtexengine = $ENV{'form.texengine'}; + $newtexengine=~s/[^\-\w]//g; + if ($newtexengine eq 'ttm') { + &Apache::lonnet::appenv('browser.mathml' => 1); + } else { + if ($ENV{'environment.texengine'} eq 'ttm') { + &Apache::lonnet::appenv('browser.mathml' => 0); + } + } + my $message=''; + if ($newtexengine) { + &Apache::lonnet::put('environment',{'texengine' => $newtexengine}); + &Apache::lonnet::appenv('environment.texengine' => $newtexengine); + $message='Set new preferred math display to '.$newtexengine; + } else { + &Apache::lonnet::del('environment',['texengine']); + &Apache::lonnet::delenv('environment\.texengine'); + $message='Reset preferred math display.'; + } + + + $r->print(< +$message +ENDVCSCREEN +} + +################################################################ +# Roles Page Preference Change Subroutines # +################################################################ +sub rolesprefchanger { + my $r = shift; + my $user = $ENV{'user.name'}; + my $domain = $ENV{'user.domain'}; + my %userenv = &Apache::lonnet::get + ('environment',['recentroles','recentrolesn']); + my $hotlist_flag=$userenv{'recentroles'}; + my $hotlist_n=$userenv{'recentrolesn'}; + my $checked; + if ($hotlist_flag) { + $checked = 'checked="checked"'; + } + + if (!$hotlist_n) { $hotlist_n=3; } + my $options; + for (my $i=1; $i<10; $i++) { + my $select; + if ($hotlist_n == $i) { $select = 'selected="selected"'; } + $options .= "\n"; + } + + $r->print(<Some LON-CAPA users have a long list of roles. The Recent Roles Hotlist +feature keeps track of the last N roles which have been +visited and places a table of these at the top of the roles page. +People with very few roles should leave this feature disabled. +

+ +
+ +
Enable Recent Roles Hotlist: + +
Number of roles in Hotlist: + +
+ +
+ENDSCREEN +} + +sub verify_and_change_rolespref { + my $r = shift; + my $user = $ENV{'user.name'}; + my $domain = $ENV{'user.domain'}; +# Recent Roles Hotlist Flag + my $hotlist_flag = $ENV{'form.recentroles'}; + my $hotlist_n = $ENV{'form.recentrolesn'}; + my $message=''; + if ($hotlist_flag) { + &Apache::lonnet::put('environment',{'recentroles' => $hotlist_flag}); + &Apache::lonnet::appenv('environment.recentroles' => $hotlist_flag); + $message='Recent Roles Hotlist is Enabled'; + } else { + &Apache::lonnet::del('environment',['recentroles']); + &Apache::lonnet::delenv('environment\.recentroles'); + $message='Recent Roles Hotlist is Disabled'; + } + if ($hotlist_n) { + &Apache::lonnet::put('environment',{'recentrolesn' => $hotlist_n}); + &Apache::lonnet::appenv('environment.recentrolesn' => $hotlist_n); + if ($hotlist_flag) { + $message.="
Display $hotlist_n Most Recent Roles\n"; + } + } + + $r->print(< +$message +ENDRPSCREEN +} + + ################################################################ # Anonymous Discussion Name Change Subroutines # @@ -490,7 +663,8 @@ sub passwordchanger { $lkey_npass2= hex($lkey_npass2); # Output javascript to deal with passwords # Output DES javascript - $r->print(""); + my $html=&Apache::lonxml::xmlbegin(); + $r->print($html.""); { my $include = $r->dir_config('lonIncludes'); my $jsh=Apache::File->new($include."/londes.js"); @@ -504,22 +678,22 @@ sub passwordchanger { lextkey=this.document.client.elements.lkey_cpass.value; initkeys(); - this.document.server.elements.currentpass.value + this.document.pserver.elements.currentpass.value =crypted(this.document.client.elements.currentpass.value); uextkey=this.document.client.elements.ukey_npass1.value; lextkey=this.document.client.elements.lkey_npass1.value; initkeys(); - this.document.server.elements.newpass_1.value + this.document.pserver.elements.newpass_1.value =crypted(this.document.client.elements.newpass_1.value); uextkey=this.document.client.elements.ukey_npass2.value; lextkey=this.document.client.elements.lkey_npass2.value; initkeys(); - this.document.server.elements.newpass_2.value + this.document.pserver.elements.newpass_2.value =crypted(this.document.client.elements.newpass_2.value); - this.document.server.submit(); + this.document.pserver.submit(); } @@ -530,7 +704,7 @@ $errormessage ensure that unencrypted passwords will not be sent out by a crappy browser --> -
+ @@ -571,8 +745,9 @@ 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(< +$html LON-CAPA Preferences: Change password for $user @@ -868,8 +1043,7 @@ sub handler { })); push (@Options,({ action => 'changemsgforward', - linktext => 'Change Message Forwarding', - text => 'and Notification Addresses', + linktext => 'Change Message Forwarding and Notification Addresses', href => '/adm/preferences', help => 'Prefs_Forwarding', breadcrumb => @@ -954,19 +1128,54 @@ sub handler { subroutine => \&verify_and_change_discussion, } )); - if ($ENV{'user.name'} =~ /^(albertel|koretemey|korte|hallmat3|turtle)$/) { + push (@Options,({ action => 'changerolespref', + linktext => 'Change Roles Page Preferences', + href => '/adm/preferences', + subroutine => \&rolesprefchanger, + breadcrumb => + { href => '/adm/preferences?action=changerolespref', + text => 'Change Roles Pref'}, + }, + { action => 'verify_and_change_rolespref', + subroutine => \&verify_and_change_rolespref, + breadcrumb => + { href => '/adm/preferences?action=changerolespref', + text => 'Change Roles Preferences'}, + printmenu => 'yes', + })); + + push (@Options,({ action => 'changetexenginepref', + linktext => 'Change How Math Equations Are Displayed', + href => '/adm/preferences', + subroutine => \&texenginechanger, + breadcrumb => + { href => '/adm/preferences?action=changetexenginepref', + text => 'Change Math Pref'}, + }, + { action => 'verify_and_change_texengine', + subroutine => \&verify_and_change_texengine, + breadcrumb => + { href => '/adm/preferences?action=changetexenginepref', + text => 'Change Math Preferences'}, + printmenu => 'yes', + })); + + + if ($ENV{'user.name'} =~ /^(albertel|fox|foxr|koretemey|korte|hallmat3|turtle)$/) { push (@Options,({ action => 'debugtoggle', printmenu => 'yes', subroutine => \&toggle_debug, })); } + my $html=&Apache::lonxml::xmlbegin(); $r->print(< +$html LON-CAPA Preferences ENDHEADER my $call = undef; + my $help = undef; my $printmenu = 'yes'; foreach my $option (@Options) { if ($option->{'action'} eq $ENV{'form.action'}) { @@ -976,18 +1185,19 @@ ENDHEADER &Apache::lonhtmlcommon::add_breadcrumb ($option->{'breadcrumb'}); } + $help=$option->{'help'}; } } $r->print(&Apache::loncommon::bodytag('Change Preferences')); $r->print(&Apache::lonhtmlcommon::breadcrumbs - (undef,'Change Preferences')); + (undef,'Change Preferences',$help)); if (defined($call)) { $call->($r); } if (($printmenu eq 'yes') && (!$ENV{'form.returnurl'})) { my $optionlist = ''; if ($ENV{'user.name'} =~ - /^(albertel|kortemey|korte|hallmat3|turtle)$/ + /^(albertel|kortemey|fox|foxr|korte|hallmat3|turtle)$/ ) { push (@Options,({ action => 'debugtoggle', linktext => 'Toggle Debug Messages', @@ -1004,10 +1214,10 @@ ENDHEADER $optiontext .= ''. - $option->{'linktext'}.''; + &mt($option->{'linktext'}).''; } if (exists($option->{'text'})) { - $optiontext .= ' '.$option->{'text'}; + $optiontext .= ' '.&mt($option->{'text'}); } if ($optiontext ne '') { $optiontext = ''.$optiontext.''; @@ -1028,10 +1238,7 @@ ENDHEADER $r->print('
'. &mt('Return').''); } - $r->print(< - -ENDFOOTER + $r->print(&Apache::loncommon::endbodytag().''); return OK; }