--- loncom/interface/lonpreferences.pm 2006/03/15 21:19:10 1.75 +++ loncom/interface/lonpreferences.pm 2006/05/08 18:50:27 1.84 @@ -1,7 +1,7 @@ # The LearningOnline Network # Preferences # -# $Id: lonpreferences.pm,v 1.75 2006/03/15 21:19:10 albertel Exp $ +# $Id: lonpreferences.pm,v 1.84 2006/05/08 18:50:27 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -98,16 +98,16 @@ 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(<<ENDLSCREEN); -<form name="server" action="/adm/preferences" method="post"> +<form name="prefs" action="/adm/preferences" method="POST"> <input type="hidden" name="action" value="set_wysiwyg" /> <br /> <label><input type="radio" name="wysiwyg" value="off" $onselect /> $switchoff</label><br /> @@ -147,7 +147,7 @@ sub languagechanger { my $selectionbox=&Apache::loncommon::select_form($language,'language', %langchoices); $r->print(<<ENDLSCREEN); -<form name="server" action="/adm/preferences" method="post"> +<form name="prefs" action="/adm/preferences" method="POST"> <input type="hidden" name="action" value="verify_and_change_languages" /> <br />$pref: $selectionbox ENDLSCREEN @@ -201,14 +201,14 @@ sub texenginechanger { $r->print(<<ENDLSCREEN); <br /> -<form name="server" action="/adm/preferences" method="post"> +<form name="prefs" action="/adm/preferences" method="POST"> <input type="hidden" name="action" value="verify_and_change_texengine" /> <p>$pref: $selectionbox</p> <p><input type="submit" value="$change" /></p> </form> Examples: <p> TeX to HTML <br /> -<iframe src="/res/adm/pages/math_example.tex?buttons=no&mode=tth" width="400" hieght="200"></iframe> +<iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=tth" width="400" hieght="200"></iframe> </p> <p>jsMath <br /> $jsMath_start @@ -228,12 +228,12 @@ if (jsMath.nofonts == 1) { +'</font></small></div></center>'); } </script> -<iframe src="/res/adm/pages/math_example.tex?buttons=no&mode=jsMath" width="400" hieght="200"></iframe> +<iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=jsMath" width="400" hieght="200"></iframe> </p> <p> Convert to Images <br /> <br /> -<iframe src="/res/adm/pages/math_example.tex?buttons=no&mode=mimetex" width="400" hieght="200"></iframe> +<iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=mimetex" width="400" hieght="200"></iframe> </p> ENDLSCREEN if ($env{'environment.texengine'} ne 'jsMath') { @@ -304,10 +304,10 @@ visited and places a table of these at t People with very few roles should leave this feature disabled. </p> -<form name="server" action="/adm/preferences" method="post"> +<form name="prefs" action="/adm/preferences" method="POST"> <input type="hidden" name="action" value="verify_and_change_rolespref" /> -<br />Enable Recent Roles Hotlist: -<input type="checkbox" $checked name="recentroles" value="true" /> +<br /><label>Enable Recent Roles Hotlist: +<input type="checkbox" $checked name="recentroles" value="true" /></label> <br />Number of roles in Hotlist: <select name="recentrolesn" size="1"> $options @@ -362,7 +362,7 @@ sub screennamechanger { my $screenname=$userenv{'screenname'}; my $nickname=$userenv{'nickname'}; $r->print(<<ENDSCREEN); -<form name="server" action="/adm/preferences" method="post"> +<form name="prefs" action="/adm/preferences" method="POST"> <input type="hidden" name="action" value="verify_and_change_screenname" /> <br />New screenname (shown if you post anonymously): <input type="text" size="20" value="$screenname" name="screenname" /> @@ -430,7 +430,7 @@ sub msgforwardchanger { $r->print(<<ENDMSG); $forwardingHelp <br /> -<form name="server" action="/adm/preferences" method="post"> +<form name="prefs" action="/adm/preferences" method="POST"> <input type="hidden" name="action" value="verify_and_change_msgforward" /> New Forwarding Address(es) (<tt>user:domain,user:domain,...</tt>): <input type="text" size="40" value="$msgforward" name="msgforward" /><hr /> @@ -505,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', @@ -524,19 +514,23 @@ sub colorschanger { 'link' => 'Un-Visited Link', 'vlink' => 'Visited Link', 'alink' => 'Active Link'); + my $start_data_table = &Apache::loncommon::start_data_table(); my $chtable=''; foreach my $item (sort(keys(%colortypes))) { my $curcol=&Apache::loncommon::designparm($function.'.'.$item,$domain); - $chtable.='<tr><td>'.$colortypes{$item}.'</td><td bgcolor="'.$curcol. + $chtable.=&Apache::loncommon::start_data_table_row(). + '<td>'.$colortypes{$item}.'</td><td style="background: '.$curcol. '"> </td><td><input name="'.$item. '" size="10" value="'.$curcol. '" /></td><td><a href="javascript:pjump('."'color_custom','".$colortypes{$item}. "','".$curcol."','" - .$item."','parmform.pres','psub'".');">Select</a></td></tr>'; + .$item."','parmform.pres','psub'".');">Select</a></td>'. + &Apache::loncommon::end_data_table_row()."\n"; } + my $end_data_table = &Apache::loncommon::end_data_table(); my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); $r->print(<<ENDCOL); -<script> +<script type="text/javascript"> function pclose() { parmwin=window.open("/adm/rat/empty.html","LONCAPAparms", @@ -550,7 +544,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;'); } @@ -567,10 +561,11 @@ sub colorschanger { <input type="hidden" name="pres_type" /> <input type="hidden" name="pres_value" /> </form> -<form name="server" action="/adm/preferences" method="post"> +<form name="prefs" action="/adm/preferences" method="POST"> <input type="hidden" name="action" value="verify_and_change_colors" /> -<table border="2"> +$start_data_table $chtable +$end_data_table </table> <input type="submit" value="Change Custom Colors" /> <input type="submit" name="resetall" value="Reset All Colors to Default" /> @@ -581,17 +576,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', @@ -615,9 +600,13 @@ sub verify_and_change_colors { $message.='Reset '.$colortypes{$item}.'<br />'; } } + my $now = time; + &Apache::lonnet::put('environment',{'color.timestamp' => $now}); + &Apache::lonnet::appenv('environment.color.timestamp' => $now); + $r->print(<<ENDVCCOL); $message -<form name="client" action="/adm/preferences" method="post"> +<form name="client" action="/adm/preferences" method="POST"> <input type="hidden" name="action" value="changecolors" /> </form> ENDVCCOL @@ -698,7 +687,7 @@ $errormessage ensure that unencrypted passwords will not be sent out by a crappy browser --> -<form name="pserver" action="/adm/preferences" method="post"> +<form name="pserver" action="/adm/preferences" method="POST"> <input type="hidden" name="logtoken" value="$logtoken" /> <input type="hidden" name="action" value="verify_and_change_pass" /> <input type="hidden" name="currentpass" value="" /> @@ -887,40 +876,38 @@ sub discussionchanger { } $r->print(<<"END"); -<form name="server" action="/adm/preferences" method="post"> +<form name="prefs" action="/adm/preferences" method="POST"> <input type="hidden" name="action" value="verify_and_change_discussion" /> <br /> $lt{'sdpf'}<br/> $lt{'prca'} <ol><li>$lt{'whpo'}</li><li>$lt{'unwh'}</li></ol> <br /> <br /> -<table border="0" cellpadding="0" cellspacing="0"> - <tr> - <td width="100%" bgcolor="#000000"> - <table width="100%" border="0" cellpadding="1" cellspacing="0"> - <tr> - <td width="100%" bgcolor="#000000"> - <table border="0" cellpadding="3" cellspacing="3" bgcolor="#FFFFFF"> - <tr bgcolor="$color"> - <td><b>$lt{'pref'}</b></td> - <td><b>$lt{'curr'}</b></td> - <td><b>$lt{'actn'}?</b></td> +END + $r->print(&Apache::loncommon::start_data_table()); + $r->print(<<"END"); + <tr> + <th>$lt{'pref'}</th> + <th>$lt{'curr'}</th> + <th>$lt{'actn'}?</th> </tr> - <tr bgcolor="#dddddd"> +END + $r->print(&Apache::loncommon::start_data_table_row()); + $r->print(<<"END"); <td>$lt{'disa'}</td> <td>$lt{$discdisp}</td> - <td><input type="checkbox" name="discdisp" /><input type="hidden" name="newdisp" value="$newdisp" /> $lt{'chgt'} "$dispchange"</td> - </tr><tr bgcolor="#eeeeee"> + <td><label><input type="checkbox" name="discdisp" /><input type="hidden" name="newdisp" value="$newdisp" /> $lt{'chgt'} "$dispchange"</label></td> +END + $r->print(&Apache::loncommon::end_data_table_row(). + &Apache::loncommon::start_data_table_row()); + $r->print(<<"END"); <td>$lt{'npmr'}</td> <td>$lt{$discmark}</td> - <td><input type="checkbox" name="discmark" /><input type="hidden" name="newmark" value="$newmark" /> $lt{'chgt'} "$markchange"</td> + <td><label><input type="checkbox" name="discmark" /><input type="hidden" name="newmark" value="$newmark" /> $lt{'chgt'} "$markchange"</label></td> </tr> - </table> - </td> - </tr> - </table> - </td> -</tr> -</table> +END + $r->print(&Apache::loncommon::end_data_table_row(). + &Apache::loncommon::end_data_table()); + $r->print(<<"END"); <br /> <br /> <input type="submit" name="sub" value="Store Changes" /> @@ -992,7 +979,7 @@ sub coursedisplaychanger { $r->print('<br /><b>'.&mt('Set the default page to be displayed when you select a course role').'</b> '.&mt('(Currently: [_1])',$pagenames{$currvalue}).'<br />'.&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',"<i>What's New</i>").'<br /><br />'); $r->print(<<ENDLSCREEN); -<form name="server" action="/adm/preferences" method="post"> +<form name="prefs" action="/adm/preferences" method="POST"> <input type="hidden" name="action" value="verify_and_change_coursepage" /> <br /> <label><input type="radio" name="newdisp" value="firstres" $firstselect /> $whatsnew_off</label><br /> @@ -1249,13 +1236,9 @@ sub handler { subroutine => \&toggle_debug, })); } - my $html=&Apache::lonxml::xmlbegin(); - $r->print(<<ENDHEADER); -$html -<head> -<title>LON-CAPA Preferences</title> -</head> -ENDHEADER + + $r->print(&Apache::loncommon::start_page('Change Preferences')); + my $call = undef; my $help = undef; my $printmenu = 'yes'; @@ -1270,9 +1253,7 @@ 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)) { $error = $call->($r); @@ -1323,7 +1304,7 @@ ENDHEADER $r->print('<br /><a href="'.$env{'form.returnurl'}.'"><font size="+1">'. &mt('Return').'</font></a>'); } - $r->print(&Apache::loncommon::endbodytag().'</html>'); + $r->print(&Apache::loncommon::end_page()); return OK; }