File:  [LON-CAPA] / loncom / interface / lonpreferences.pm
Revision 1.125: download - view: text, annotated - select for diffs
Fri Jul 18 12:36:11 2008 UTC (15 years, 9 months ago) by raeburn
Branches: MAIN
CVS tags: version_2_9_X, version_2_8_X, version_2_7_X, version_2_7_1, version_2_7_0, version_2_6_99_1, HEAD, GCI_2, GCI_1
- Only show "Restrict Domain Coordinator Access" link if user has an active author role.

    1: # The LearningOnline Network
    2: # Preferences
    3: #
    4: # $Id: lonpreferences.pm,v 1.125 2008/07/18 12:36:11 raeburn Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: # This package uses the "londes.js" javascript code. 
   29: #
   30: # TODOs that have to be completed:
   31: #    interface with lonnet to change the password
   32:  
   33: package Apache::lonpreferences;
   34: 
   35: use strict;
   36: use LONCAPA;
   37: use Apache::Constants qw(:common);
   38: use Apache::File;
   39: use Crypt::DES;
   40: use DynaLoader; # for Crypt::DES version
   41: use Apache::loncommon();
   42: use Apache::lonhtmlcommon();
   43: use Apache::lonlocal;
   44: use Apache::lonnet;
   45: use LONCAPA();
   46: 
   47: #
   48: # Write lonnet::passwd to do the call below.
   49: # Use:
   50: #   my $answer=reply("encrypt:passwd:$udom:$uname:$upass",$tryserver);
   51: #
   52: ##################################################
   53: #          password associated functions         #
   54: ##################################################
   55: sub des_keys {
   56:     # Make a new key for DES encryption.
   57:     # Each key has two parts which are returned separately.
   58:     # Please note:  Each key must be passed through the &hex function
   59:     # before it is output to the web browser.  The hex versions cannot
   60:     # be used to decrypt.
   61:     my @hexstr=('0','1','2','3','4','5','6','7',
   62:                 '8','9','a','b','c','d','e','f');
   63:     my $lkey='';
   64:     for (0..7) {
   65:         $lkey.=$hexstr[rand(15)];
   66:     }
   67:     my $ukey='';
   68:     for (0..7) {
   69:         $ukey.=$hexstr[rand(15)];
   70:     }
   71:     return ($lkey,$ukey);
   72: }
   73: 
   74: sub des_decrypt {
   75:     my ($key,$cyphertext) = @_;
   76:     my $keybin=pack("H16",$key);
   77:     my $cypher;
   78:     if ($Crypt::DES::VERSION>=2.03) {
   79:         $cypher=new Crypt::DES $keybin;
   80:     } else {
   81:         $cypher=new DES $keybin;
   82:     }
   83:     my $plaintext=
   84: 	$cypher->decrypt(unpack("a8",pack("H16",substr($cyphertext,0,16))));
   85:     $plaintext.=
   86: 	$cypher->decrypt(unpack("a8",pack("H16",substr($cyphertext,16,16))));
   87:     $plaintext=substr($plaintext,1,ord(substr($plaintext,0,1)) );
   88:     return $plaintext;
   89: }
   90: 
   91: ################################################################
   92: #                       Handler subroutines                    #
   93: ################################################################
   94: 
   95: ################################################################
   96: #         Language Change Subroutines                          #
   97: ################################################################
   98: 
   99: sub wysiwygchanger {
  100:     my $r = shift;
  101:     my %userenv = &Apache::lonnet::get
  102:         ('environment',['wysiwygeditor']);
  103:     my $onselect='checked="checked"';
  104:     my $offselect='';
  105:     if ($userenv{'wysiwygeditor'} eq 'on') {
  106: 	$onselect='';
  107: 	$offselect='checked="checked"';
  108:     }
  109:     my $switchoff=&mt('Disable WYSIWYG editor');
  110:     my $switchon=&mt('Enable WYSIWYG editor');
  111:     my $warning='';
  112:     if ($env{'user.adv'}) {
  113:        $warning.="<p>".&mt("The WYSIWYG editor only supports simple HTML and is in many cases unsuited for advanced authoring. In a number of cases, it may destroy advanced authoring involving LaTeX and script function calls.")."</p>";
  114:     }
  115:     $r->print(<<ENDLSCREEN);
  116: <form name="prefs" action="/adm/preferences" method="post">
  117: <input type="hidden" name="action" value="set_wysiwyg" />
  118: $warning
  119: <br />
  120: <label><input type="radio" name="wysiwyg" value="off" $onselect /> $switchoff</label><br />
  121: <label><input type="radio" name="wysiwyg" value="on" $offselect /> $switchon</label>
  122: ENDLSCREEN
  123:     $r->print('<br /><input type="submit" value="'.&mt('Change').'" />');
  124: }
  125: 
  126: 
  127: sub verify_and_change_wysiwyg {
  128:     my $r = shift;
  129:     my $newsetting=$env{'form.wysiwyg'};
  130:     &Apache::lonnet::put('environment',{'wysiwygeditor' => $newsetting});
  131:     &Apache::lonnet::appenv({'environment.wysiwygeditor' => $newsetting});
  132:     $r->print('<p>'.&mt('Setting WYSIWYG editor to:').' '.&mt($newsetting).'</p>');
  133: }
  134: 
  135: ################################################################
  136: #         Language Change Subroutines                          #
  137: ################################################################
  138: sub languagechanger {
  139:     my $r = shift;
  140:     my $user       = $env{'user.name'};
  141:     my $domain     = $env{'user.domain'};
  142:     my %userenv = &Apache::lonnet::get
  143:         ('environment',['languages']);
  144:     my $language=$userenv{'languages'};
  145: 
  146:     my $pref=&mt('Preferred language');
  147:     my %langchoices=('' => 'No language preference');
  148:     foreach (&Apache::loncommon::languageids()) {
  149: 	if (&Apache::loncommon::supportedlanguagecode($_)) {
  150: 	    $langchoices{&Apache::loncommon::supportedlanguagecode($_)}
  151: 	               = &Apache::loncommon::plainlanguagedescription($_);
  152: 	}
  153:     }
  154:     my $selectionbox=&Apache::loncommon::select_form($language,'language',
  155: 						     %langchoices);
  156:     $r->print(<<ENDLSCREEN);
  157: <form name="prefs" action="/adm/preferences" method="post">
  158: <input type="hidden" name="action" value="verify_and_change_languages" />
  159: <br />$pref: $selectionbox
  160: ENDLSCREEN
  161:     $r->print('<br /><input type="submit" value="'.&mt('Change').'" />');
  162: }
  163: 
  164: 
  165: sub verify_and_change_languages {
  166:     my $r = shift;
  167:     my $user       = $env{'user.name'};
  168:     my $domain     = $env{'user.domain'};
  169: # Screenname
  170:     my $newlanguage  = $env{'form.language'};
  171:     $newlanguage=~s/[^\-\w]//g;
  172:     my $message='';
  173:     if ($newlanguage) {
  174:         &Apache::lonnet::put('environment',{'languages' => $newlanguage});
  175:         &Apache::lonnet::appenv({'environment.languages' => $newlanguage});
  176:         $message=&mt('Set new preferred languages to ').'<tt>"'.$newlanguage.'"</tt>.';
  177:     } else {
  178:         &Apache::lonnet::del('environment',['languages']);
  179:         &Apache::lonnet::delenv('environment\.languages');
  180:         $message=&mt('Reset preferred language.');
  181:     }
  182:     $r->print(<<ENDVCSCREEN);
  183: $message
  184: ENDVCSCREEN
  185: }
  186: 
  187: ################################################################
  188: #         Tex Engine Change Subroutines                        #
  189: ################################################################
  190: sub texenginechanger {
  191:     my $r = shift;
  192:     my $user       = $env{'user.name'};
  193:     my $domain     = $env{'user.domain'};
  194:     my %userenv = &Apache::lonnet::get('environment',['texengine']);
  195:     my $texengine=$userenv{'texengine'};
  196: 
  197:     my %mathchoices=('' => 'Default',
  198: 		     'tth' => 'tth (TeX to HTML)',
  199: 		     #'ttm' => 'TeX to MathML',
  200: 		     'jsMath' => 'jsMath',
  201: 		     'mimetex' => 'mimetex (Convert to Images)'
  202:                      );
  203:     my $selectionbox=&Apache::loncommon::select_form($texengine,'texengine',
  204: 						     %mathchoices);
  205:     my $jsMath_start=&Apache::lontexconvert::jsMath_header();
  206:     my %lt=&Apache::lonlocal::texthash(
  207:       'headline' => 'Change Math Preferences',
  208:       'preftxt'  => 'Preferred method to display Math',
  209:       'change'   => 'Change',
  210:       'exmpl'    => 'Examples',
  211:       'jsmath'   => 'jsMath:',
  212:       'tth'      => 'tth (TeX to HTML):',
  213:       'mimetex'  => 'mimetex (Convert to Images):',
  214:     );
  215: 
  216:     $r->print(<<ENDLSCREEN);
  217: <h2>$lt{'headline'}</h2>
  218: <form name="prefs" action="/adm/preferences" method="post">
  219: <input type="hidden" name="action" value="verify_and_change_texengine" />
  220: <p>
  221: $lt{'preftxt'}:<br />
  222: $selectionbox <input type="submit" value="$lt{'change'}" />
  223: </p>
  224: </form>
  225: <br />
  226: <hr />
  227: $lt{'exmpl'}
  228: 
  229: <h3>$lt{'jsmath'}</h3> 
  230: <p>
  231: $jsMath_start
  232: <script type="text/javascript">
  233: if (jsMath.nofonts == 1) {
  234:     document.writeln
  235:         ('<div style="padding: 10; border-style: solid; border-width:3;'
  236: 	 +' border-color: #DD0000; background-color: #FFF8F8; width: 75%; text-align: left">'
  237: 	 +'<small><font color="#AA0000"><b>Warning:</b> '
  238: 	 +'It looks like you don\\\'t have the TeX math fonts installed. '
  239: 	 +'The jsMath example on this page may not look right without them. '
  240: 	 +'The <a href="http://www.math.union.edu/locate/jsMath/" target="_blank"> '
  241: 	 +'jsMath Home Page</a> has information on how to download the '
  242: 	 +'needed fonts.  In the meantime, jsMath will do the best it can '
  243: 	 +'with the fonts you have, but it may not be pretty and some equations '
  244: 	 +'may not be rendered correctly. '
  245: 	 +'</font></small></div>');
  246: }
  247: </script>
  248: <iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=jsMath" width="400" height="120"></iframe>
  249: </p>
  250: 
  251: <h3>$lt{'mimetex'}</h3>
  252: <p>
  253: <iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=mimetex" width="400" height="100"></iframe>
  254: </p>
  255: 
  256: <h3>$lt{'tth'}</h3>
  257: <p>
  258: <iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=tth" width="400" height="200"></iframe>
  259: </p>
  260: ENDLSCREEN
  261:     if ($env{'environment.texengine'} ne 'jsMath') {
  262: 	$r->print('<script type="text/javascript">jsMath.Process()</script>');
  263:     }
  264: }
  265: 
  266: 
  267: sub verify_and_change_texengine {
  268:     my $r = shift;
  269:     my $user       = $env{'user.name'};
  270:     my $domain     = $env{'user.domain'};
  271: # Screenname
  272:     my $newtexengine  = $env{'form.texengine'};
  273:     $newtexengine=~s/[^\-\w]//g;
  274:     if ($newtexengine eq 'ttm') {
  275: 	&Apache::lonnet::appenv({'browser.mathml' => 1});
  276:     } else {
  277: 	if ($env{'environment.texengine'} eq 'ttm') {
  278: 	    &Apache::lonnet::appenv({'browser.mathml' => 0});
  279: 	}
  280:     }
  281:     my $message='';
  282:     if ($newtexengine) {
  283:         &Apache::lonnet::put('environment',{'texengine' => $newtexengine});
  284:         &Apache::lonnet::appenv({'environment.texengine' => $newtexengine});
  285:         $message=&mt('Set new preferred math display to ').'<tt>"'.$newtexengine.'"</tt>.';
  286:     } else {
  287:         &Apache::lonnet::del('environment',['texengine']);
  288:         &Apache::lonnet::delenv('environment\.texengine');
  289:         $message=&mt('Reset preferred math display.');
  290:     }
  291: 
  292: 
  293:     $r->print(<<ENDVCSCREEN);
  294: $message
  295: ENDVCSCREEN
  296: }
  297: 
  298: ################################################################
  299: #         Roles Page Preference Change Subroutines         #
  300: ################################################################
  301: sub rolesprefchanger {
  302:     my $r = shift;
  303:     my $role    = ($env{'user.adv'} ? 'Role' : 'Course');
  304:     my $lc_role = ($env{'user.adv'} ? 'role' : 'course');
  305:     my $user       = $env{'user.name'};
  306:     my $domain     = $env{'user.domain'};
  307:     my %userenv = &Apache::lonnet::get
  308:         ('environment',['recentroles','recentrolesn']);
  309:     my $hotlist_flag=$userenv{'recentroles'};
  310:     my $hotlist_n=$userenv{'recentrolesn'};
  311:     my $checked;
  312:     if ($hotlist_flag) {
  313: 	$checked = 'checked="checked"';
  314:     }
  315:     
  316:     if (!$hotlist_n) { $hotlist_n=3; }
  317:     my $options;
  318:     for (my $i=1; $i<10; $i++) {
  319: 	my $select;
  320: 	if ($hotlist_n == $i) { $select = 'selected="selected"'; }
  321: 	$options .= "<option $select>$i</option>\n";
  322:     }
  323: 
  324: # Get list of recent roles and display with checkbox in front
  325:     my $roles_check_list = '';
  326:     my $role_key='';
  327:     if ($env{'environment.recentroles'}) {
  328:         my %recent_roles =
  329:                &Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'});
  330:         my %frozen_roles =
  331:                &Apache::lonhtmlcommon::get_recent_frozen('roles',$env{'environment.recentrolesn'});
  332:         
  333:         my %role_text = &rolespref_get_role_text([keys(%recent_roles)]);
  334:         my @sorted_roles = sort {$role_text{$a} cmp $role_text{$b}} keys(%role_text);
  335: 
  336:         $roles_check_list .=
  337: 	    &Apache::loncommon::start_data_table().
  338: 	    &Apache::loncommon::start_data_table_header_row().
  339: 	    "<th>".&mt('Freeze '.$role)."</th>".
  340: 	    "<th>".&mt($role)."</td>".
  341: 	    &Apache::loncommon::end_data_table_header_row().
  342: 	    "\n";
  343: 	my $count;
  344:         foreach $role_key (@sorted_roles) {
  345:             my $checked = "";
  346:             my $value = $recent_roles{$role_key};
  347:             if ($frozen_roles{$role_key}) {
  348:                 $checked = "checked=\"checked\"";
  349:             }
  350: 	    $count++;
  351:             $roles_check_list .=
  352: 		&Apache::loncommon::start_data_table_row().
  353: 		'<td class="LC_table_cell_checkbox">'.
  354: 		"<input type=\"checkbox\" $checked name=\"freezeroles\"".
  355: 		" id=\"freezeroles$count\" value=\"$role_key\" /></td>".
  356: 		"<td><label for=\"freezeroles$count\">".
  357: 		"$role_text{$role_key}</label></td>".
  358: 		&Apache::loncommon::end_data_table_row(). "\n";
  359:         }
  360:         $roles_check_list .= "</table>\n";
  361:     }
  362: 
  363:     $r->print('
  364: <p>'.&mt('Some LON-CAPA users have a long list of '.$lc_role.'s. The Recent '.$role.'s Hotlist feature keeps track of the last N '.$lc_role.'s which have been visited and places a table of these at the top of the '.$lc_role.'s page. People with very few '.$lc_role.'s should leave this feature disabled.').'
  365: </p>
  366: <form name="prefs" action="/adm/preferences" method="POST">
  367: <input type="hidden" name="action" value="verify_and_change_rolespref" />
  368: <br /><label>'.&mt('Enable Recent '.$role.'s Hotlist:').'
  369: <input type="checkbox" '.$checked.' name="recentroles" value="true" /></label>
  370: <br />'.&mt('Number of '.$role.'s in Hotlist:').'
  371: <select name="recentrolesn" size="1">
  372: '.$options.'
  373: </select>
  374: <p>'.&mt('This list below can be used to <q>freeze</q> '.$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.').'
  375: </p>
  376: '.$roles_check_list.'
  377: <br />
  378: <input type="submit" value="'.&mt('Change').'" />
  379: </form>');
  380: }
  381: 
  382: sub rolespref_get_role_text {
  383: # Get a line of text for each role
  384:     my ($roles) = @_;
  385:     my %roletext = ();
  386: 
  387:     foreach my $item (@$roles) {
  388: # get course information
  389:         my ($role,$rest) = split(/\./, $item);
  390:         my $trole = "";
  391:         $trole = &Apache::lonnet::plaintext($role);
  392:         my ($tdomain,$other,$tsection)= split(/\//,Apache::lonnet::declutter($rest));
  393:         my $tother = '-';
  394:         if ($role =~ /^(cc|st|in|ta|ep|cr)/ ) {
  395:             my %newhash=&Apache::lonnet::coursedescription($tdomain."_".$other);
  396:             $tother = " - ".$newhash{'description'};
  397:         } elsif ($role =~ /dc/) {
  398:             $tother = "";
  399:         } else {
  400:             $tother = " - $other";
  401:         }
  402:  
  403:         my $section="";
  404:         if ($tsection) {
  405:             $section = " - Section/Group: $tsection";
  406:         }
  407:         $roletext{$item} = $tdomain." - ".$trole.$tother.$section;
  408:     }
  409:     return %roletext;
  410: }
  411: 
  412: sub verify_and_change_rolespref {
  413:     my $r = shift;
  414:     my $role = ($env{'user.adv'} ? 'Role' : 'Course');
  415:     my $user       = $env{'user.name'};
  416:     my $domain     = $env{'user.domain'};
  417: # Recent Roles Hotlist Flag
  418:     my $hotlist_flag  = $env{'form.recentroles'};
  419:     my $hotlist_n  = $env{'form.recentrolesn'};
  420:     my $message='<hr />';
  421:     if ($hotlist_flag) {
  422:         &Apache::lonnet::put('environment',{'recentroles' => $hotlist_flag});
  423:         &Apache::lonnet::appenv({'environment.recentroles' => $hotlist_flag});
  424:         $message=&mt('Recent '.$role.'s Hotlist is Enabled');
  425:     } else {
  426:         &Apache::lonnet::del('environment',['recentroles']);
  427:         &Apache::lonnet::delenv('environment\.recentroles');
  428:         $message=&mt('Recent '.$role.'s Hotlist is Disabled');
  429:     }
  430:     if ($hotlist_n) {
  431:         &Apache::lonnet::put('environment',{'recentrolesn' => $hotlist_n});
  432:         &Apache::lonnet::appenv({'environment.recentrolesn' => $hotlist_n});
  433:         if ($hotlist_flag) {
  434:             $message.="<br />".
  435: 		&mt('Display [_1] Most Recent '.$role.'s',$hotlist_n)."\n";
  436:         }
  437:     }
  438: 
  439: # Get list of froze roles and list of recent roles
  440:     my @freeze_list = &Apache::loncommon::get_env_multiple('form.freezeroles');
  441:     my %freeze = ();
  442:     my %roletext = ();
  443: 
  444:     foreach my $key (@freeze_list) {
  445:         $freeze{$key}='1';
  446:     }
  447: 
  448:     my %recent_roles =
  449:         &Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'});
  450:     my %frozen_roles =
  451:         &Apache::lonhtmlcommon::get_recent_frozen('roles',$env{'environment.recentrolesn'});
  452:     my %role_text = &rolespref_get_role_text([keys(%recent_roles)]);
  453: 
  454: # Unset any roles that were previously frozen but aren't in list
  455:     foreach my $role_key (sort(keys(%recent_roles))) {
  456:         if (($frozen_roles{$role_key}) && (!exists($freeze{$role_key}))) {
  457: 	    $message .= "<br />".&mt('Unfreezing '.$role.': [_1]',$role_text{$role_key})."\n";
  458: 	    &Apache::lonhtmlcommon::store_recent('roles',$role_key,' ',0);
  459:         }
  460:     }
  461: 
  462: # Freeze selected roles
  463:     foreach my $role_key (@freeze_list) {
  464:         if (!$frozen_roles{$role_key}) {
  465:              $message .= "<br />".&mt('Freezing '.$role.': [_1]',$role_text{$role_key})."\n";
  466:              &Apache::lonhtmlcommon::store_recent('roles',
  467:                                           $role_key,' ',1);
  468:         }
  469:     }
  470:     $message .= "<hr /><br />\n";
  471: 
  472:     $r->print(<<ENDRPSCREEN);
  473: $message
  474: ENDRPSCREEN
  475: }
  476: 
  477: 
  478: 
  479: ################################################################
  480: #         Anonymous Discussion Name Change Subroutines         #
  481: ################################################################
  482: sub screennamechanger {
  483:     my $r = shift;
  484:     my $user       = $env{'user.name'};
  485:     my $domain     = $env{'user.domain'};
  486:     my %userenv = &Apache::lonnet::get
  487:         ('environment',['screenname','nickname']);
  488:     my $screenname=$userenv{'screenname'};
  489:     my $nickname=$userenv{'nickname'};
  490:     my %lt = &Apache::lonlocal::texthash(
  491:                                           text_screenname  => 'New screenname (shown if you post anonymously):',
  492:                                           text_nickname  => 'New nickname (shown if you post non-anonymously):',
  493:                                           text_submit => 'Change',
  494:                                         );
  495:     $r->print(<<ENDSCREEN);
  496: <form name="prefs" action="/adm/preferences" method="post">
  497: <input type="hidden" name="action" value="verify_and_change_screenname" />
  498: <br />$lt{'text_screenname'}
  499: <input type="text" size="20" value="$screenname" name="screenname" />
  500: <br />$lt{'text_nickname'}
  501: <input type="text" size="20" value="$nickname" name="nickname" />
  502: <br />
  503: <input type="submit" value="$lt{'text_submit'}" />
  504: </form>
  505: ENDSCREEN
  506: }
  507: 
  508: sub verify_and_change_screenname {
  509:     my $r = shift;
  510:     my $user       = $env{'user.name'};
  511:     my $domain     = $env{'user.domain'};
  512: # Screenname
  513:     my $newscreen  = $env{'form.screenname'};
  514:     $newscreen=~s/[^ \w]//g;
  515:     my $message='';
  516:     if ($newscreen) {
  517:         &Apache::lonnet::put('environment',{'screenname' => $newscreen});
  518:         &Apache::lonnet::appenv({'environment.screenname' => $newscreen});
  519:         $message=&mt('Set new screenname to ').'<tt>"'.$newscreen.'."</tt>.';
  520:     } else {
  521:         &Apache::lonnet::del('environment',['screenname']);
  522:         &Apache::lonnet::delenv('environment\.screenname');
  523:         $message=&mt('Reset screenname.');
  524:     }
  525: # Nickname
  526:     $message.='<br />';
  527:     $newscreen  = $env{'form.nickname'};
  528:     $newscreen=~s/[^ \w]//g;
  529:     if ($newscreen) {
  530:         &Apache::lonnet::put('environment',{'nickname' => $newscreen});
  531:         &Apache::lonnet::appenv({'environment.nickname' => $newscreen});
  532:         $message.=&mt('Set new nickname to ').'<tt>"'.$newscreen.'"</tt>.';
  533:     } else {
  534:         &Apache::lonnet::del('environment',['nickname']);
  535:         &Apache::lonnet::delenv('environment\.nickname');
  536:         $message.=&mt('Reset nickname.');
  537:     }
  538:     &Apache::lonnet::devalidate_cache_new('namescache',$user.':'.$domain);
  539:     $r->print(<<ENDVCSCREEN);
  540: $message
  541: ENDVCSCREEN
  542: }
  543: 
  544: ################################################################
  545: #                     Icon Subroutines                         #
  546: ################################################################
  547: sub iconchanger {
  548:     my $r = shift;
  549:     my $user       = $env{'user.name'};
  550:     my $domain     = $env{'user.domain'};
  551:     my %userenv = &Apache::lonnet::get
  552:         ('environment',['icons']);
  553:     my $iconic='checked="checked"';
  554:     my $classic='';
  555:     my $onlyicon='';
  556:     if ($userenv{'icons'} eq 'classic') {
  557:        $classic='checked="checked"';
  558:        $iconic='';
  559:     }
  560:     if ($userenv{'icons'} eq 'iconsonly') {
  561:        $onlyicon='checked="checked"';
  562:        $iconic='';
  563:     }
  564:     my $useicons=&mt('Use icons and text');
  565:     my $usebuttons=&mt('Use buttons and text');
  566:     my $useicononly=&mt('Use icons only');
  567:     my $change=&mt('Change');
  568:     $r->print(<<ENDSCREEN);
  569: <form name="prefs" action="/adm/preferences" method="post">
  570: <input type="hidden" name="action" value="verify_and_change_icons" />
  571: <label><input type="radio" name="menumode" value="iconic" $iconic /> $useicons</label><br />
  572: <label><input type="radio" name="menumode" value="classic" $classic /> $usebuttons</label><br />
  573: <label><input type="radio" name="menumode" value="iconsonly" $onlyicon /> $useicononly</label><br />
  574: <input type="submit" value="$change" />
  575: </form>
  576: ENDSCREEN
  577: }
  578: 
  579: sub verify_and_change_icons {
  580:     my $r = shift;
  581:     my $user       = $env{'user.name'};
  582:     my $domain     = $env{'user.domain'};
  583:     my $newicons  = $env{'form.menumode'};
  584: 
  585:     &Apache::lonnet::put('environment',{'icons' => $newicons});
  586:     &Apache::lonnet::appenv({'environment.icons' => $newicons});
  587:     $r->print(&mt('Set menu mode to [_1].',$newicons));
  588: }
  589: 
  590: ################################################################
  591: #                     Clicker Subroutines                      #
  592: ################################################################
  593: 
  594: sub clickerchanger {
  595:     my $r = shift;
  596:     my $user       = $env{'user.name'};
  597:     my $domain     = $env{'user.domain'};
  598:     my %userenv = &Apache::lonnet::get
  599:         ('environment',['clickers']);
  600:     my $clickers=$userenv{'clickers'};
  601:     $clickers=~s/\,/\n/gs;
  602:     my $text=&mt('Enter response device ("clicker") numbers');
  603:     my $change=&mt('Register');
  604:     my $helplink=&Apache::loncommon::help_open_topic('Clicker_Registration',&mt('Locating your clicker ID'));
  605:     $r->print(<<ENDSCREEN);
  606: <form name="prefs" action="/adm/preferences" method="post">
  607: <input type="hidden" name="action" value="verify_and_change_clicker" />
  608: <label>$text $helplink<br />
  609: <textarea name="clickers" rows="5" cols="20">$clickers</textarea>
  610: </label>
  611: <input type="submit" value="$change" />
  612: </form>
  613: ENDSCREEN
  614: }
  615: 
  616: sub verify_and_change_clicker {
  617:     my $r = shift;
  618:     my $user       = $env{'user.name'};
  619:     my $domain     = $env{'user.domain'};
  620:     my $newclickers  = $env{'form.clickers'};
  621:     $newclickers=~s/[^\w\:\-]+/\,/gs;
  622:     $newclickers=~tr/a-z/A-Z/;
  623:     $newclickers=~s/[\:\-]+/\-/g;
  624:     $newclickers=~s/\,+/\,/g;
  625:     $newclickers=~s/^\,//;
  626:     $newclickers=~s/\,$//;
  627:     &Apache::lonnet::put('environment',{'clickers' => $newclickers});
  628:     &Apache::lonnet::appenv({'environment.clickers' => $newclickers});
  629:     $r->print(&mt('Registering clickers: [_1]',$newclickers));
  630: }
  631: 
  632: ################################################################
  633: #               Domcoord Access Subroutines                    #
  634: ################################################################
  635: 
  636: sub domcoordchanger {
  637:     my $r = shift;
  638:     my $user       = $env{'user.name'};
  639:     my $domain     = $env{'user.domain'};
  640:     my %userenv = &Apache::lonnet::get
  641:         ('environment',['domcoord.author']);
  642:     my $constchecked='';
  643:     if ($userenv{'domcoord.author'} eq 'blocked') {
  644:        $constchecked='checked="checked"';
  645:     }
  646:     my $text=&mt('By default, the Domain Coordinator can enter your construction space.');
  647:     my $construction=&mt('Block access to construction space');
  648:     my $change=&mt('Change');
  649:     $r->print(<<ENDSCREEN);
  650: <form name="prefs" action="/adm/preferences" method="post">
  651: <input type="hidden" name="action" value="verify_and_change_domcoord" />
  652: $text<br />
  653: <label><input type="checkbox" name="construction" $constchecked />$construction</label><br />
  654: <input type="submit" value="$change" />
  655: </form>
  656: ENDSCREEN
  657: }
  658: 
  659: sub verify_and_change_domcoord {
  660:     my $r = shift;
  661:     my $user       = $env{'user.name'};
  662:     my $domain     = $env{'user.domain'};
  663:     my %domcoord=('domcoord.author' => '');
  664:     if ($env{'form.construction'}) { $domcoord{'domcoord.author'}='blocked'; }
  665:     &Apache::lonnet::put('environment',\%domcoord);
  666:     &Apache::lonnet::appenv({'environment.domcoord.author' => $domcoord{'domcoord.author'}});
  667:     $r->print(&mt('Registering Domain Coordinator access restrictions.'));
  668: }
  669: 
  670: #################################################################
  671: ##                      Lock Subroutines                        #
  672: #################################################################
  673: 
  674: sub lockwarning {
  675:     my $r = shift;
  676:     my $title=&mt('Action locked');
  677:     my $texttop=&mt('LON-CAPA is currently performing the following actions:');
  678:     my $textbottom=&mt('Changing roles or logging out may result in data corruption.');
  679:     my ($num,%which)=&Apache::lonnet::get_locks();
  680:     my $which='';
  681:     foreach my $id (keys %which) {
  682:        $which.='<li>'.$which{$id}.'</li>';
  683:     }
  684:     my $change=&mt('Override');
  685:     $r->print(<<ENDSCREEN);
  686: <form name="prefs" action="/adm/preferences" method="post">
  687: <input type="hidden" name="action" value="verify_and_change_locks" />
  688: <h1>$title</h1>
  689: $texttop
  690: <ul>
  691: $which
  692: </ul>
  693: $textbottom
  694: <input type="submit" value="$change" />
  695: </form>
  696: ENDSCREEN
  697: }
  698: 
  699: sub verify_and_change_lockwarning {
  700:     my $r = shift;
  701:     &Apache::lonnet::remove_all_locks();
  702:     $r->print(&mt('Cleared locks.'));
  703: }
  704: 
  705: 
  706: ################################################################
  707: #         Message Forward                                      #
  708: ################################################################
  709: 
  710: sub msgforwardchanger {
  711:     my ($r,$message) = @_;
  712:     my $user       = $env{'user.name'};
  713:     my $domain     = $env{'user.domain'};
  714:     my %userenv = &Apache::lonnet::get('environment',['msgforward','notification','critnotification','notifywithhtml']);
  715:     my $msgforward=$userenv{'msgforward'};
  716:     my %lt = &Apache::lonlocal::texthash(
  717:                                           all   => 'All',
  718:                                           crit  => 'Critical only',
  719:                                           reg   => 'Non-critical only',
  720:                                           foad  => 'Forwarding Address(es)',
  721:                                           noti  => 'Notification E-mail Address(es)', 
  722:                                           foad_exmpl => 'e.g. <tt>userA:domain1,userB:domain2,...</tt>',
  723:                                           mnot  => 'Email Address(es) which should be notified about new LON-CAPA messages', # old: 'Message Notification Email Address(es)',
  724:                                           mnot_exmpl => 'e.g. <tt>joe@doe.com</tt>',
  725:                                           chg   => 'Change',
  726:                                           email => 'The e-mail address entered in row ',
  727:                                           notv => 'is not a valid e-mail address',
  728:                                           toen => "To enter multiple addresses, enter one address at a time, click 'Change' and then add the next one", 
  729:                                           prme => 'Back to preferences menu',
  730:                                         );
  731:     my $forwardingHelp = &Apache::loncommon::help_open_topic("Prefs_Forwarding");
  732:     my $notificationHelp = &Apache::loncommon::help_open_topic("Prefs_Notification");
  733:     my $criticalMessageHelp = &Apache::loncommon::help_open_topic("Course_Critical_Message");
  734:     my @allow_html = split(/,/,$userenv{'notifywithhtml'});
  735:     my %allnot = &get_notifications(\%userenv);
  736:     my $validatescript = &Apache::lonhtmlcommon::javascript_valid_email();
  737:     my $jscript = qq|
  738: <script type="text/javascript">
  739: function validate() {
  740:     for (var i=0; i<document.prefs.numnotify.value; i++) {
  741:         var checkaddress = 0;
  742:         var addr = document.prefs.elements['address_'+i].value;
  743:         var rownum = i+1;
  744:         if (i < document.prefs.numnotify.value-1) {
  745:             if (document.prefs.elements['modify_notify_'+i].checked) {
  746:                 checkaddress = 1;
  747:             }
  748:         } else {
  749:             if (document.prefs.elements['add_notify_'+i].checked == true) { 
  750:                 checkaddress = 1;
  751:             }
  752:         }
  753:         if (checkaddress == 1)  {
  754:             var addr = document.prefs.elements['address_'+i].value;
  755:             if (validmail(document.prefs.elements['address_'+i]) == false) {
  756:                 var multimsg = '';
  757:                 if (addr.indexOf(",") >= 0) {
  758:                     multimsg = "\\n($lt{'toen'}).";
  759:                 }
  760:                 alert("$lt{'email'} "+rownum+" ('"+addr+"') $lt{'notv'}."+multimsg);
  761:                 return;
  762:             }
  763:         }
  764:     }
  765:     document.prefs.submit();
  766: }
  767: 
  768: function address_changes (adnum) {
  769:      if (!document.prefs.elements['del_notify_'+adnum].checked) { 
  770:          document.prefs.elements['modify_notify_'+adnum].checked = true;
  771:      }   
  772: }
  773: 
  774: function new_address(adnum) {
  775:      document.prefs.elements['add_notify_'+adnum].checked = true;
  776: }
  777: 
  778: function delete_address(adnum) {
  779:      if (document.prefs.elements['del_notify_'+adnum].checked) {
  780:           document.prefs.elements['modify_notify_'+adnum].checked = false;
  781:      }
  782: }
  783: 
  784: function modify_address(adnum) {
  785:     if (document.prefs.elements['modify_notify_'+adnum].checked) {
  786:         document.prefs.elements['del_notify_'+adnum].checked = false;
  787:     }
  788: } 
  789: 
  790: $validatescript
  791: </script>
  792: |;
  793:     $r->print(<<ENDMSG);
  794: $jscript
  795: $message
  796: <h3>$lt{'foad'} $forwardingHelp</h3>
  797: <form name="prefs" action="/adm/preferences" method="post">
  798: <input type="hidden" name="action" value="verify_and_change_msgforward" />
  799: $lt{'foad'} ($lt{'foad_exmpl'}):
  800: <input type="text" size="40" value="$msgforward" name="msgforward" /><br />
  801: <h3>$lt{'noti'} $notificationHelp</h3>
  802: $lt{'mnot'} ($lt{'mnot_exmpl'}):<br />
  803: ENDMSG
  804:     my @sortforwards = sort (keys(%allnot));
  805:     my $output = &Apache::loncommon::start_data_table().
  806:                  &Apache::loncommon::start_data_table_header_row().
  807:                  '<th>&nbsp;</th>'.
  808:                  '<th>'.&mt('Action').'</th>'.
  809:                  '<th>'.&mt('Notification address').'</th><th>'.
  810:                  &mt('Types of message for which notification is sent').
  811:                  $criticalMessageHelp.'</th><th>'.
  812:                  &mt('Excerpt retains HTML tags in message').'</th>'.
  813:                  &Apache::loncommon::end_data_table_header_row();
  814:     my $num = 0;
  815:     my $counter = 1;
  816:     foreach my $item (@sortforwards) {
  817:         $output .= &Apache::loncommon::start_data_table_row().
  818:                    '<td><b>'.$counter.'</b></td>'.
  819:                    '<td><span class="LC_nobreak"><label>'.
  820:                    '<input type="checkbox" name="modify_notify_'.
  821:                    $num.'" onclick="javscript:modify_address('."'$num'".')" />'.
  822:                    &mt('Modify').'</label></span>&nbsp;&nbsp; '.
  823:                    '<span class="LC_nobreak"><label>'.
  824:                    '<input type="checkbox" name="del_notify_'.$num.
  825:                    '" onclick="javscript:delete_address('."'$num'".')" />'.
  826:                    &mt('Delete').'</label></span></td>'.
  827:                    '<td><input type="text" value="'.$item.'" name="address_'.
  828:                    $num.'" onFocus="javascript:address_changes('."'$num'".
  829:                    ')" /></td><td>';
  830:         my %chk;
  831:         if (defined($allnot{$item}{'crit'})) {
  832:             if (defined($allnot{$item}{'reg'})) {
  833:                 $chk{'all'} = 'checked="checked" ';
  834:             } else {
  835:                 $chk{'crit'} = 'checked="checked" ';
  836:             }
  837:         } else {
  838:             $chk{'reg'} = 'checked="checked" ';
  839:         }
  840:         foreach my $type ('all','crit','reg') {
  841:             $output .= '<span class="LC_nobreak"><label>'.
  842:                        '<input type="radio" name="notify_type_'.$num. 
  843:                        '" value="'.$type.'" '.$chk{$type}.
  844:                        ' onchange="javascript:address_changes('."'$num'".')" />'.
  845:                        $lt{$type}.'</label></span>&nbsp;';
  846:         }
  847:         my $htmlon = '';
  848:         my $htmloff = '';
  849:         if (grep/^\Q$item\E/,@allow_html) {
  850:             $htmlon = 'checked="checked" '; 
  851:         } else {
  852:             $htmloff = 'checked="checked" ';
  853:         }
  854:         $output .= '</td><td><label><input type="radio" name="html_'.$num.
  855:                    '" value="1" '.$htmlon.
  856:                    ' onchange="javascript:address_changes('."'$num'".')" />'.
  857:                    &mt('Yes').'</label>&nbsp;'.
  858:                    '<label><input type="radio" name="html_'.$num.'" value="0" '.
  859:                    $htmloff. ' onchange="javascript:address_changes('."'$num'".
  860: ')" />'.
  861:                    &mt('No').'</label></td>'.
  862:                    &Apache::loncommon::end_data_table_row();
  863:         $num ++;
  864:         $counter ++;
  865:     }
  866:     my %defchk = (
  867:                    all => 'checked="checked" ',
  868:                    crit => '',
  869:                    reg => '',
  870:                  );
  871:     $output .= &Apache::loncommon::start_data_table_row().
  872:                '<td><b>'.$counter.'</b></td>'.
  873:                '<td><span class="LC_nobreak"><label>'.
  874:                '<input type="checkbox" name="add_notify_'.$num.
  875:                '" value="1" />'.&mt('Add new address').'</label></span></td>'.
  876:                '<td><input type="text" value="" name="address_'.$num.
  877:                '" onFocus="javascript:new_address('."'$num'".')" /></td><td>';
  878:     foreach my $type ('all','crit','reg') {
  879:         $output .= '<span class="LC_nobreak"><label>'.
  880:                    '<input type="radio" name="notify_type_'.$num.
  881:                    '" value="'.$type.'" '.$defchk{$type}.'/>'.
  882:                    $lt{$type}.'</label></span>&nbsp;';
  883:     }
  884:     $output .= '</td><td><label><input type="radio" name="html_'.$num.
  885:                '" value="1" />'.&mt('Yes').'</label>&nbsp;'.
  886:                '<label><input type="radio" name="html_'.$num.'" value="0" '.
  887:                ' checked="checked" />'.
  888:                &mt('No').'</label></td>'.
  889:                &Apache::loncommon::end_data_table_row().
  890:                &Apache::loncommon::end_data_table();
  891:     $num ++;
  892:     $r->print($output);
  893:     $r->print(qq|
  894: <br /><hr />
  895: <input type="hidden" name="numnotify" value="$num" />
  896: <input type="button" value="$lt{'chg'}" onclick="javascript:validate()" />
  897: <input type="button" value="$lt{'prme'}" onclick="location.href='/adm/preferences'" />
  898: </form>
  899: |);
  900: 
  901: }
  902: 
  903: sub get_notifications {
  904:     my ($userenv) = @_;
  905:     my %allnot;
  906:     my @critnot = split(/,/,$userenv->{'critnotification'});
  907:     my @regnot = split(/,/,$userenv->{'notification'});
  908:     foreach my $item (@critnot) {
  909:         $allnot{$item}{crit} = 1;
  910:     }
  911:     foreach my $item (@regnot) {
  912:         $allnot{$item}{reg} = 1;
  913:     }
  914:     return %allnot;
  915: }
  916: 
  917: sub verify_and_change_msgforward {
  918:     my $r = shift;
  919:     my $user       = $env{'user.name'};
  920:     my $domain     = $env{'user.domain'};
  921:     my $newscreen  = '';
  922:     my $message='';
  923:     foreach (split(/\,/,$env{'form.msgforward'})) {
  924: 	my ($msuser,$msdomain)=split(/[\@\:]/,$_);
  925:         $msuser = &LONCAPA::clean_username($msuser);
  926:         $msdomain = &LONCAPA::clean_domain($msdomain);
  927:         if (($msuser) && ($msdomain)) {
  928: 	    if (&Apache::lonnet::homeserver($msuser,$msdomain) ne 'no_host') {
  929:                $newscreen.=$msuser.':'.$msdomain.',';
  930: 	   } else {
  931:                $message.= &mt('No such user: ').'<tt>'.$msuser.':'.$msdomain.'</tt><br>';
  932:            }
  933:         }
  934:     }
  935:     $newscreen=~s/\,$//;
  936:     if ($newscreen) {
  937:         &Apache::lonnet::put('environment',{'msgforward' => $newscreen});
  938:         &Apache::lonnet::appenv({'environment.msgforward' => $newscreen});
  939:         $message .= &mt('Set message forwarding to ').'<tt>"'.$newscreen.'"</tt>.'
  940:                     .'<br />';
  941:     } else {
  942:         &Apache::lonnet::del('environment',['msgforward']);
  943:         &Apache::lonnet::delenv('environment\.msgforward');
  944:         $message.= &mt("Set message forwarding to 'off'.").'<br />';
  945:     }
  946:     my $critnotification;
  947:     my $notification;
  948:     my $notify_with_html;
  949:     my $lastnotify = $env{'form.numnotify'}-1;
  950:     my $totaladdresses = 0;
  951:     for (my $i=0; $i<$env{'form.numnotify'}; $i++) {
  952:         if ((!defined($env{'form.del_notify_'.$i})) &&  
  953:            ((($i==$lastnotify) && ($env{'form.add_notify_'.$lastnotify} == 1)) ||
  954:             ($i<$lastnotify))) {
  955:             if (defined($env{'form.address_'.$i})) {
  956:                 if ($env{'form.notify_type_'.$i} eq 'all') {
  957:                     $critnotification .= $env{'form.address_'.$i}.',';
  958:                     $notification .= $env{'form.address_'.$i}.',';
  959:                 } elsif ($env{'form.notify_type_'.$i} eq 'crit') {
  960:                     $critnotification .= $env{'form.address_'.$i}.',';
  961:                 } elsif ($env{'form.notify_type_'.$i} eq 'reg') {
  962:                     $notification .= $env{'form.address_'.$i}.','; 
  963:                 }
  964:                 if ($env{'form.html_'.$i} eq '1') {
  965: 		    $notify_with_html .= $env{'form.address_'.$i}.',';       	
  966:                 }
  967:                 $totaladdresses ++;
  968:             }
  969:         }
  970:     }
  971:     $critnotification =~ s/,$//;
  972:     $critnotification=~s/\s//gs;
  973:     $notification =~ s/,$//;
  974:     $notification=~s/\s//gs;
  975:     $notify_with_html =~ s/,$//;
  976:     $notify_with_html =~ s/\s//gs;
  977:     if ($notification) {
  978:         &Apache::lonnet::put('environment',{'notification' => $notification});
  979:         &Apache::lonnet::appenv({'environment.notification' => $notification});
  980:         $message.=&mt('Set non-critical message notification address(es) to ').'<tt>"'.$notification.'"</tt>.<br />';
  981:     } else {
  982:         &Apache::lonnet::del('environment',['notification']);
  983:         &Apache::lonnet::delenv('environment\.notification');
  984:         $message.=&mt("Set non-critical message notification to 'off'.").'<br />';
  985:     }
  986:     if ($critnotification) {
  987:         &Apache::lonnet::put('environment',{'critnotification' => $critnotification});
  988:         &Apache::lonnet::appenv({'environment.critnotification' => $critnotification});
  989:         $message.=&mt('Set critical message notification address(es) to ').'<tt>"'.$critnotification.'"</tt>.<br />';
  990:     } else {
  991:         &Apache::lonnet::del('environment',['critnotification']);
  992:         &Apache::lonnet::delenv('environment\.critnotification');
  993:         $message.=&mt("Set critical message notification to 'off'.").'<br />';
  994:     }
  995:     if ($critnotification || $notification) {
  996:         if ($notify_with_html) {
  997:             &Apache::lonnet::put('environment',{'notifywithhtml' => $notify_with_html});
  998:             &Apache::lonnet::appenv({'environment.notifywithhtml' => $notify_with_html});
  999:             $message.=&mt('Set address(es) to receive excerpts with html retained ').'<tt>"'.$notify_with_html.'"</tt>.';
 1000:         } else {
 1001:             &Apache::lonnet::del('environment',['notifywithhtml']);
 1002:             &Apache::lonnet::delenv('environment\.notifywithhtml');
 1003:             if ($totaladdresses == 1) {
 1004:                 $message.=&mt("Set notification address to receive excerpts with html stripped.");
 1005:             } else {
 1006:                 $message.=&mt("Set all notification addresses to receive excerpts with html stripped.");
 1007:             }
 1008:         }
 1009:     } else {
 1010:         &Apache::lonnet::del('environment',['notifywithhtml']);
 1011:         &Apache::lonnet::delenv('environment\.notifywithhtml');
 1012:     }
 1013:     if ($message) {
 1014:         $message .= '<br /><hr />';
 1015:     }
 1016:     &Apache::loncommon::flush_email_cache($user,$domain);
 1017:     &msgforwardchanger($r,$message);
 1018: }
 1019: 
 1020: ################################################################
 1021: #         Colors                                               #
 1022: ################################################################
 1023: 
 1024: sub colorschanger {
 1025:     my $r = shift;
 1026: # figure out colors
 1027:     my $function=&Apache::loncommon::get_users_function();
 1028:     my $domain=&Apache::loncommon::determinedomain();
 1029:     my %colortypes=('pgbg'  => 'Page Background',
 1030:                     'tabbg' => 'Header Background',
 1031:                     'sidebg'=> 'Header Border',
 1032:                     'font'  => 'Font',
 1033:                     'link'  => 'Un-Visited Link',
 1034:                     'vlink' => 'Visited Link',
 1035:                     'alink' => 'Active Link');
 1036:     my $start_data_table = &Apache::loncommon::start_data_table();
 1037:     my $chtable='';
 1038:     foreach my $item (sort(keys(%colortypes))) {
 1039:        my $curcol=&Apache::loncommon::designparm($function.'.'.$item,$domain);
 1040:        $chtable.=&Apache::loncommon::start_data_table_row().
 1041: 	   '<td>'.$colortypes{$item}.'</td><td style="background: '.$curcol.
 1042:         '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td><input name="'.$item.
 1043:         '" size="10" value="'.$curcol.
 1044: '" /></td><td><a href="javascript:pjump('."'color_custom','".$colortypes{$item}.
 1045: "','".$curcol."','"
 1046: 	    .$item."','parmform.pres','psub'".');">Select</a></td>'.
 1047: 	    &Apache::loncommon::end_data_table_row()."\n";
 1048:     }
 1049:     my $end_data_table = &Apache::loncommon::end_data_table();
 1050:     my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
 1051:     $r->print(<<ENDCOL);
 1052: <script type="text/javascript">
 1053: 
 1054:     function pclose() {
 1055:         parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
 1056:                  "height=350,width=350,scrollbars=no,menubar=no");
 1057:         parmwin.close();
 1058:     }
 1059: 
 1060:     $pjump_def
 1061: 
 1062:     function psub() {
 1063:         pclose();
 1064:         if (document.parmform.pres_marker.value!='') {
 1065:             if (document.parmform.pres_type.value!='') {
 1066:                 eval('document.prefs.'+
 1067:                      document.parmform.pres_marker.value+
 1068: 		     '.value=document.parmform.pres_value.value;');
 1069: 	    }
 1070:         } else {
 1071:             document.parmform.pres_value.value='';
 1072:             document.parmform.pres_marker.value='';
 1073:         }
 1074:     }
 1075: 
 1076: 
 1077: </script>
 1078: <form name="parmform">
 1079: <input type="hidden" name="pres_marker" />
 1080: <input type="hidden" name="pres_type" />
 1081: <input type="hidden" name="pres_value" />
 1082: </form>
 1083: <form name="prefs" action="/adm/preferences" method="post">
 1084: <input type="hidden" name="action" value="verify_and_change_colors" />
 1085: $start_data_table
 1086: $chtable
 1087: $end_data_table
 1088: </table>
 1089: <input type="submit" value="Change Custom Colors" />
 1090: <input type="submit" name="resetall" value="Reset All Colors to Default" />
 1091: </form>
 1092: ENDCOL
 1093: }
 1094: 
 1095: sub verify_and_change_colors {
 1096:     my $r = shift;
 1097: # figure out colors
 1098:     my $function=&Apache::loncommon::get_users_function();
 1099:     my $domain=&Apache::loncommon::determinedomain();
 1100:     my %colortypes=('pgbg'  => 'Page Background',
 1101:                     'tabbg' => 'Header Background',
 1102:                     'sidebg'=> 'Header Border',
 1103:                     'font'  => 'Font',
 1104:                     'link'  => 'Un-Visited Link',
 1105:                     'vlink' => 'Visited Link',
 1106:                     'alink' => 'Active Link');
 1107: 
 1108:     my $message='';
 1109:     foreach my $item (keys %colortypes) {
 1110:         my $color=$env{'form.'.$item};
 1111:         my $entry='color.'.$function.'.'.$item;
 1112: 	if (($color=~/^\#[0-9A-Fa-f]{6}$/) && (!$env{'form.resetall'})) {
 1113: 	    &Apache::lonnet::put('environment',{$entry => $color});
 1114: 	    &Apache::lonnet::appenv({'environment.'.$entry => $color});
 1115: 	    $message.=&mt('Set '.$colortypes{$item}.' to ').'<tt>"'.$color.'"</tt>.<br />';
 1116: 	} else {
 1117: 	    &Apache::lonnet::del('environment',[$entry]);
 1118: 	    &Apache::lonnet::delenv('environment\.'.$entry);
 1119: 	    $message.=&mt('Reset '.$colortypes{$item}.'.').'<br />';
 1120: 	}
 1121:     }
 1122:     my $now = time;
 1123:     &Apache::lonnet::put('environment',{'color.timestamp' => $now});
 1124:     &Apache::lonnet::appenv({'environment.color.timestamp' => $now});
 1125: 
 1126:     $r->print(<<ENDVCCOL);
 1127: $message
 1128: <form name="client" action="/adm/preferences" method="post">
 1129: <input type="hidden" name="action" value="changecolors" />
 1130: </form>
 1131: ENDVCCOL
 1132: }
 1133: 
 1134: ######################################################
 1135: #            password handler subroutines            #
 1136: ######################################################
 1137: sub passwordchanger {
 1138:     my ($r,$errormessage,$caller,$mailtoken) = @_;
 1139:     # This function is a bit of a mess....
 1140:     # Passwords are encrypted using londes.js (DES encryption)
 1141:     $errormessage = ($errormessage || '');
 1142:     my ($user,$domain,$currentpass,$defdom);
 1143:     if ((!defined($caller)) || ($caller eq 'preferences')) {
 1144:         $user = $env{'user.name'};
 1145:         $domain = $env{'user.domain'};
 1146:         if (!defined($caller)) {
 1147:             $caller = 'preferences';
 1148:         }
 1149:     } elsif ($caller eq 'reset_by_email') {
 1150:             $defdom = $r->dir_config('lonDefDomain');
 1151:             my %data = &Apache::lonnet::tmpget($mailtoken);
 1152:             if (keys(%data) == 0) {
 1153:                 $r->print(&mt('Sorry, the URL you provided to complete the reset of your password was invalid. Either the token included in the URL has been deleted or the URL you provided was invalid. Please submit a <a href="/adm/resetpw">new request</a> for a password reset, and follow the link to the new URL included in the e-mail that will be sent to you, to allow you to enter a new password.'));
 1154:                 return;
 1155:             }
 1156:             if (defined($data{time})) {
 1157:                 if (time - $data{'time'} < 7200) {
 1158:                     $user = $data{'username'};
 1159:                     $domain = $data{'domain'};
 1160:                     $currentpass = $data{'temppasswd'};
 1161:                 } else {
 1162:                     $r->print(&mt('Sorry, the token generated when you requested a password reset has expired.').'<br />');
 1163:                     return;
 1164:                 }
 1165:             } else {
 1166:                 $r->print(&mt('Sorry, the URL generated when you requested reset of your password contained incomplete information.').'<br />');
 1167:                 return;
 1168:             }
 1169:    } else {
 1170:         $r->print(&mt('Page requested in unexpected context').'<br />');
 1171:         return;
 1172:     }
 1173:     my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
 1174:     # Check for authentication types that allow changing of the password.
 1175:     return if ($currentauth !~ /^(unix|internal):/);
 1176:     #
 1177:     # Generate keys
 1178:     my ($lkey_cpass ,$ukey_cpass ) = &des_keys();
 1179:     my ($lkey_npass1,$ukey_npass1) = &des_keys();
 1180:     my ($lkey_npass2,$ukey_npass2) = &des_keys();
 1181:     # Store the keys in the log files
 1182:     my $lonhost = $r->dir_config('lonHostID');
 1183:     my $logtoken=Apache::lonnet::reply('tmpput:'
 1184: 				       .$ukey_cpass  . $lkey_cpass .'&'
 1185: 				       .$ukey_npass1 . $lkey_npass1.'&'
 1186: 				       .$ukey_npass2 . $lkey_npass2,
 1187: 				       $lonhost);
 1188:     # Hexify the keys for output as javascript variables
 1189:     my %hexkey;
 1190:     $hexkey{'ukey_cpass'}  = hex($ukey_cpass);
 1191:     $hexkey{'lkey_cpass'}  = hex($lkey_cpass);
 1192:     $hexkey{'ukey_npass1'} = hex($ukey_npass1);
 1193:     $hexkey{'lkey_npass1'} = hex($lkey_npass1);
 1194:     $hexkey{'ukey_npass2'} = hex($ukey_npass2);
 1195:     $hexkey{'lkey_npass2'} = hex($lkey_npass2);
 1196:     # Output javascript to deal with passwords
 1197:     # Output DES javascript
 1198:     {
 1199: 	my $include = $r->dir_config('lonIncludes');
 1200: 	my $jsh=Apache::File->new($include."/londes.js");
 1201: 	$r->print(<$jsh>);
 1202:     }
 1203:     $r->print(&jscript_send($caller));
 1204:     $r->print(<<ENDFORM);
 1205: $errormessage
 1206: 
 1207: <p>
 1208: <!-- We separate the forms into 'server' and 'client' in order to
 1209:      ensure that unencrypted passwords will not be sent out by a
 1210:      crappy browser -->
 1211: ENDFORM
 1212:     $r->print(&server_form($logtoken,$caller,$mailtoken));
 1213:     $r->print(&client_form($caller,\%hexkey,$currentpass,$defdom));
 1214: 
 1215:     #
 1216:     return;
 1217: }
 1218: 
 1219: sub jscript_send {
 1220:     my ($caller) = @_;
 1221:     my $output = qq|
 1222: <script language="JavaScript">
 1223: 
 1224:     function send() {
 1225:         uextkey=this.document.client.elements.ukey_cpass.value;
 1226:         lextkey=this.document.client.elements.lkey_cpass.value;
 1227:         initkeys();
 1228: 
 1229:         this.document.pserver.elements.currentpass.value
 1230:             =crypted(this.document.client.elements.currentpass.value);
 1231: 
 1232:         uextkey=this.document.client.elements.ukey_npass1.value;
 1233:         lextkey=this.document.client.elements.lkey_npass1.value;
 1234:         initkeys();
 1235:         this.document.pserver.elements.newpass_1.value
 1236:             =crypted(this.document.client.elements.newpass_1.value);
 1237: 
 1238:         uextkey=this.document.client.elements.ukey_npass2.value;
 1239:         lextkey=this.document.client.elements.lkey_npass2.value;
 1240:         initkeys();
 1241:         this.document.pserver.elements.newpass_2.value
 1242:             =crypted(this.document.client.elements.newpass_2.value);
 1243: |;
 1244:     if ($caller eq 'reset_by_email') {
 1245:         $output .= qq|
 1246:         this.document.pserver.elements.uname.value =
 1247:                    this.document.client.elements.uname.value;
 1248:         this.document.pserver.elements.udom.value =
 1249:                    this.document.client.elements.udom.options[this.document.client.elements.udom.selectedIndex].value;
 1250: |;
 1251:     }
 1252:     $ output .= qq|
 1253:         this.document.pserver.submit();
 1254:     }
 1255: </script>
 1256: |;
 1257: }
 1258: 
 1259: sub client_form {
 1260:     my ($caller,$hexkey,$currentpass,$defdom) = @_;
 1261:     my %lt=&Apache::lonlocal::texthash(
 1262:                 'email' => 'E-mail Address',
 1263:                 'username' => 'Username',
 1264:                 'domain' => 'Domain',
 1265:                 'currentpass' => 'Current Password',
 1266:                 'newpass' => 'New Password',
 1267:                 'confirmpass' => 'Confirm Password',
 1268:                 'changepass' => 'Change Password');
 1269: 
 1270:     my $output = qq|
 1271: <form name="client" >
 1272: <table>
 1273: |;
 1274:     if ($caller eq 'reset_by_email') {
 1275:         $output .= qq|
 1276: <tr><td class="LC_preferences_labeltext"><label for="email">$lt{'email'}</label>:</td>
 1277:     <td><input type="text" name="email" size="30" /> </td></tr>
 1278: <tr><td class="LC_preferences_labeltext"><label for="uname">$lt{'username'}</label>:</td>
 1279:     <td>
 1280:      <input type="text" name="uname" size="15" />
 1281:      <input type="hidden" name="currentpass" value="$currentpass" />
 1282:     </td></tr>
 1283: <tr><td class="LC_preferences_labeltext"><label for="udom">$lt{'domain'}</label>:</td>
 1284:     <td>
 1285: |;
 1286:         $output .= &Apache::loncommon::select_dom_form($defdom,'udom').'
 1287:    </td>
 1288: </tr>
 1289: ';
 1290:     } else {
 1291:         $output .= qq|
 1292: <tr><td class="LC_preferences_labeltext"><label for="currentpass">$lt{'currentpass'}</label></td>
 1293:     <td><input type="password" name="currentpass" size="10"/> </td></tr>
 1294: |;
 1295:     }
 1296:     $output .= <<"ENDFORM";
 1297: <tr><td class="LC_preferences_labeltext"><label for="newpass_1">$lt{'newpass'}</label></td>
 1298:     <td><input type="password" name="newpass_1" size="10"  /> </td></tr>
 1299: <tr><td class="LC_preferences_labeltext"><label for="newpass_2">$lt{'confirmpass'}</label></td>
 1300:     <td><input type="password" name="newpass_2" size="10"  /> </td></tr>
 1301: <tr><td colspan="2" align="center">
 1302:     <input type="button" value="$lt{'changepass'}" onClick="send();">
 1303: </table>
 1304: <input type="hidden" name="ukey_cpass"  value="$hexkey->{'ukey_cpass'}" />
 1305: <input type="hidden" name="lkey_cpass"  value="$hexkey->{'lkey_cpass'}" />
 1306: <input type="hidden" name="ukey_npass1" value="$hexkey->{'ukey_npass1'}" />
 1307: <input type="hidden" name="lkey_npass1" value="$hexkey->{'lkey_npass1'}" />
 1308: <input type="hidden" name="ukey_npass2" value="$hexkey->{'ukey_npass2'}" />
 1309: <input type="hidden" name="lkey_npass2" value="$hexkey->{'lkey_npass2'}" />
 1310: </form>
 1311: </p>
 1312: ENDFORM
 1313:     return $output;
 1314: }
 1315: 
 1316: sub server_form {
 1317:     my ($logtoken,$caller,$mailtoken) = @_;
 1318:     my $action = '/adm/preferences';
 1319:     if ($caller eq 'reset_by_email') {
 1320:         $action = '/adm/resetpw';
 1321:     }
 1322:     my $output = qq|
 1323: <form name="pserver" action="$action" method="post">
 1324: <input type="hidden" name="logtoken"    value="$logtoken" />
 1325: <input type="hidden" name="currentpass" value="" />
 1326: <input type="hidden" name="newpass_1"   value="" />
 1327: <input type="hidden" name="newpass_2"   value="" />
 1328:     |;
 1329:     if ($caller eq 'reset_by_email') {
 1330:         $output .=  qq|
 1331: <input type="hidden" name="token"   value="$mailtoken" />
 1332: <input type="hidden" name="uname"   value="" />
 1333: <input type="hidden" name="udom"   value="" />
 1334: 
 1335: |;
 1336:     }
 1337:     $output .= qq|
 1338: <input type="hidden" name="action" value="verify_and_change_pass" />
 1339: </form>
 1340: |;
 1341:     return $output;
 1342: }
 1343: 
 1344: sub verify_and_change_password {
 1345:     my ($r,$caller,$mailtoken) = @_;
 1346:     my ($user,$domain,$homeserver);
 1347:     if ($caller eq 'reset_by_email') {
 1348:         $user       = $env{'form.uname'};
 1349:         $domain     = $env{'form.udom'};
 1350:         if ($user ne '' && $domain ne '') {
 1351:             $homeserver = &Apache::lonnet::homeserver($user,$domain);
 1352:             if ($homeserver eq 'no_host') {
 1353:         &passwordchanger($r,"<p>\n<span class='LC_error'>".
 1354:                          &mt("Invalid username and/or domain")."</span>\n</p>",
 1355:                          $caller,$mailtoken);
 1356:                 return 1;
 1357:             }
 1358:         } else {
 1359:             &passwordchanger($r,"<p>\n<span class='LC_error'>".
 1360:                              &mt("Username and domain were blank")."</span>\n</p>",
 1361:                              $caller,$mailtoken);
 1362:             return 1;
 1363:         }
 1364:     } else {
 1365:         $user       = $env{'user.name'};
 1366:         $domain     = $env{'user.domain'};
 1367:         $homeserver = $env{'user.home'};
 1368:     }
 1369:     my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
 1370:     # Check for authentication types that allow changing of the password.
 1371:     if ($currentauth !~ /^(unix|internal):/) {
 1372:         if ($caller eq 'reset_by_email') {
 1373:             &passwordchanger($r,"<p>\n<span class='LC_error'>".
 1374:                              &mt("Authentication type for this user can not be changed by this mechanism").
 1375:                              "</span>\n</p>",
 1376:                               $caller,$mailtoken);
 1377:             return 1;
 1378:         } else {
 1379:             return;
 1380:         }
 1381:     }
 1382:     #
 1383:     my $currentpass = $env{'form.currentpass'}; 
 1384:     my $newpass1    = $env{'form.newpass_1'}; 
 1385:     my $newpass2    = $env{'form.newpass_2'};
 1386:     my $logtoken    = $env{'form.logtoken'};
 1387:     # Check for empty data 
 1388:     unless (defined($currentpass) && 
 1389: 	    defined($newpass1)    && 
 1390: 	    defined($newpass2)    ){
 1391: 	&passwordchanger($r,"<p>\n<span class='LC_error'>".
 1392: 			 &mt("One or more password fields were blank").
 1393:                          "</span>\n</p>",$caller,$mailtoken);
 1394: 	return;
 1395:     }
 1396:     # Get the keys
 1397:     my $lonhost = $r->dir_config('lonHostID');
 1398:     my $tmpinfo = Apache::lonnet::reply('tmpget:'.$logtoken,$lonhost);
 1399:     if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost')) {
 1400:         # I do not a have a better idea about how to handle this
 1401:         my $tryagain_text = &mt('Please log out and try again.');
 1402:         if ($caller eq 'reset_by_email') {
 1403:             $tryagain_text = &mt('Please try again later.');
 1404:         }
 1405:         my $unable=&mt("Unable to retrieve saved token for password decryption");
 1406: 	$r->print(<<ENDERROR);
 1407: <p>
 1408: <span class="LC_error">$unable.  $tryagain_text</span>
 1409: </p>
 1410: ENDERROR
 1411:         # Probably should log an error here
 1412:         return 1;
 1413:     }
 1414:     my ($ckey,$n1key,$n2key)=split(/&/,$tmpinfo);
 1415:     # 
 1416:     $currentpass = &des_decrypt($ckey ,$currentpass);
 1417:     $newpass1    = &des_decrypt($n1key,$newpass1);
 1418:     $newpass2    = &des_decrypt($n2key,$newpass2);
 1419:     #
 1420:     if ($caller eq 'reset_by_email') {
 1421:         my %data = &Apache::lonnet::tmpget($mailtoken);
 1422:         if (keys(%data) == 0) {
 1423:             &passwordchanger($r,
 1424:                          '<span class="LC_error">'.
 1425:                          &mt('Could not verify current authentication.').'  '.
 1426:                          &mt('Please try again.').'</span>',$caller,$mailtoken);
 1427:             return 1;
 1428:         }
 1429:         if ($currentpass ne $data{'temppasswd'}) {
 1430:             &passwordchanger($r,
 1431:                          '<span class="LC_error">'.
 1432:                          &mt('Could not verify current authentication.').'  '.
 1433:                          &mt('Please try again.').'</span>',$caller,$mailtoken);
 1434:             return 1;
 1435:         }
 1436:     } 
 1437:     if ($newpass1 ne $newpass2) {
 1438: 	&passwordchanger($r,
 1439: 			 '<span class="LC_error">'.
 1440: 			 &mt('The new passwords you entered do not match.').'  '.
 1441: 			 &mt('Please try again.').'</span>',$caller,$mailtoken);
 1442: 	return 1;
 1443:     }
 1444:     if (length($newpass1) < 7) {
 1445: 	&passwordchanger($r,
 1446: 			 '<span class="LC_error">'.
 1447: 			 &mt('Passwords must be a minimum of 7 characters long.').'  '.
 1448: 			 &mt('Please try again.').'</span>',$caller,$mailtoken);
 1449: 	return 1;
 1450:     }
 1451:     #
 1452:     # Check for bad characters
 1453:     my $badpassword = 0;
 1454:     foreach (split(//,$newpass1)) {
 1455: 	$badpassword = 1 if ((ord($_)<32)||(ord($_)>126));
 1456:     }
 1457:     if ($badpassword) {
 1458: 	# I can't figure out how to enter bad characters on my browser.
 1459: 	my $errormessage ='<span class="LC_error">'.
 1460:            &mt('The password you entered contained illegal characters.').'<br />'.
 1461:            &mt('Valid characters are').(<<"ENDERROR");
 1462: : space and <br />
 1463: <pre>
 1464: !&quot;\#$%&amp;\'()*+,-./0123456789:;&lt;=&gt;?\@
 1465: ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}~
 1466: </pre></span>
 1467: ENDERROR
 1468:         &passwordchanger($r,$errormessage,$caller,$mailtoken);
 1469:         return 1;
 1470:     }
 1471:     # 
 1472:     # Change the password (finally)
 1473:     my $result = &Apache::lonnet::changepass
 1474: 	($user,$domain,$currentpass,$newpass1,$homeserver,$caller);
 1475:     # Inform the user the password has (not?) been changed
 1476:     if ($result =~ /^ok$/) {
 1477: 	$r->print("<h3>".&mt('The password for [_1] was successfully changed',$user)."</h3>");
 1478:     } else {
 1479: 	# error error: run in circles, scream and shout
 1480:         $r->print("<h3><span class='LC_error'>".&mt("The password for [_1] was not changed",$user)."</span></h3>".
 1481:                   &mt('Please make sure your old password was entered correctly.'));
 1482:         return 1;
 1483:     }
 1484:     return;
 1485: }
 1486: 
 1487: ################################################################
 1488: #            discussion display subroutines 
 1489: ################################################################
 1490: sub discussionchanger {
 1491:     my $r = shift;
 1492:     my $user       = $env{'user.name'};
 1493:     my $domain     = $env{'user.domain'};
 1494:     my %userenv = &Apache::lonnet::get
 1495:         ('environment',['discdisplay','discmarkread']);
 1496:     my $discdisp = 'allposts';
 1497:     my $discmark = 'onmark';
 1498: 
 1499:     if (defined($userenv{'discdisplay'})) {
 1500:         unless ($userenv{'discdisplay'} eq '') { 
 1501:             $discdisp = $userenv{'discdisplay'};
 1502:         }
 1503:     }
 1504:     if (defined($userenv{'discmarkread'})) {
 1505:         unless ($userenv{'discdisplay'} eq '') { 
 1506:             $discmark = $userenv{'discmarkread'};
 1507:         }
 1508:     }
 1509: 
 1510:     my $newdisp = 'unread';
 1511:     my $newmark = 'ondisp';
 1512: 
 1513:     my $function = &Apache::loncommon::get_users_function();
 1514:     my $color = &Apache::loncommon::designparm($function.'.tabbg',
 1515:                                                     $env{'user.domain'});
 1516:     my %lt = &Apache::lonlocal::texthash(
 1517:         'pref' => 'Display Preference',
 1518:         'curr' => 'Current setting ',
 1519:         'actn' => 'Action',
 1520:         'sdpf' => 'Set display preferences for discussion posts for both bulletin boards and individual resources in all your courses.',
 1521:         'prca' => 'Preferences can be set that determine',
 1522:         'whpo' => 'Which posts are displayed when you display a bulletin board or resource, and',
 1523:         'unwh' => 'Under what circumstances posts are identfied as "New"',
 1524:         'allposts' => 'All posts',
 1525:         'unread' => 'New posts only',
 1526:         'ondisp' => 'Once displayed',
 1527:         'onmark' => 'Once marked as read',
 1528:         'disa' => 'Posts displayed?',
 1529:         'npmr' => 'New posts cease to be identified as "New"?',
 1530:         'thde'  => 'The preferences you set here can be overridden within each individual discussion.',
 1531:         'chgt' => 'Change to '
 1532:     );
 1533:     my $dispchange = $lt{'unread'};
 1534:     my $markchange = $lt{'ondisp'};
 1535:     my $currdisp = $lt{'allposts'};
 1536:     my $currmark = $lt{'onmark'};
 1537: 
 1538:     if ($discdisp eq 'unread') {
 1539:         $dispchange = $lt{'allposts'};
 1540:         $currdisp = $lt{'unread'};
 1541:         $newdisp = 'allposts';
 1542:     }
 1543: 
 1544:     if ($discmark eq 'ondisp') {
 1545:         $markchange = $lt{'onmark'};
 1546:         $currmark = $lt{'ondisp'};
 1547:         $newmark = 'onmark';
 1548:     }
 1549:     
 1550:     $r->print(<<"END");
 1551: <form name="prefs" action="/adm/preferences" method="post">
 1552: <input type="hidden" name="action" value="verify_and_change_discussion" />
 1553: <br />
 1554: $lt{'sdpf'}<br /> $lt{'prca'}  <ol><li>$lt{'whpo'}</li><li>$lt{'unwh'}</li></ol> 
 1555: <br />
 1556: <br />
 1557: END
 1558:     $r->print(&Apache::loncommon::start_data_table());
 1559:     $r->print(<<"END");
 1560:        <tr>
 1561:         <th>$lt{'pref'}</th>
 1562:         <th>$lt{'curr'}</th>
 1563:         <th>$lt{'actn'}?</th>
 1564:        </tr>
 1565: END
 1566:     $r->print(&Apache::loncommon::start_data_table_row());
 1567:     $r->print(<<"END");
 1568:        <td>$lt{'disa'}</td>
 1569:        <td>$lt{$discdisp}</td>
 1570:        <td><label><input type="checkbox" name="discdisp" /><input type="hidden" name="newdisp" value="$newdisp" />&nbsp;$lt{'chgt'} "$dispchange"</label></td>
 1571: END
 1572:     $r->print(&Apache::loncommon::end_data_table_row().
 1573: 	      &Apache::loncommon::start_data_table_row());
 1574:     $r->print(<<"END");
 1575:        <td>$lt{'npmr'}</td>
 1576:        <td>$lt{$discmark}</td>
 1577:        <td><label><input type="checkbox" name="discmark" /><input type="hidden" name="newmark" value="$newmark" />&nbsp;$lt{'chgt'} "$markchange"</label></td>
 1578:       </tr>
 1579: END
 1580:     $r->print(&Apache::loncommon::end_data_table_row().
 1581: 	      &Apache::loncommon::end_data_table());
 1582:     $r->print(<<"END");
 1583: <br />
 1584: <br />
 1585: <input type="submit" name="sub" value="Save Changes" />
 1586: <br />
 1587: <br />
 1588: Note: $lt{'thde'}
 1589: </form>
 1590: END
 1591: }
 1592:                                                                                                                 
 1593: sub verify_and_change_discussion {
 1594:     my $r = shift;
 1595:     my $user     = $env{'user.name'};
 1596:     my $domain   = $env{'user.domain'};
 1597:     my $message='';
 1598:     if (defined($env{'form.discdisp'}) ) {
 1599:         my $newdisp  = $env{'form.newdisp'};
 1600:         if ($newdisp eq 'unread') {
 1601:             $message .=&mt('In discussions: only new posts will be displayed.').'<br />';
 1602:             &Apache::lonnet::put('environment',{'discdisplay' => $newdisp});
 1603:             &Apache::lonnet::appenv({'environment.discdisplay' => $newdisp});
 1604:         } else {
 1605:             $message .= &mt('In discussions: all posts will be displayed.').'<br />';
 1606:             &Apache::lonnet::del('environment',['discdisplay']);
 1607:             &Apache::lonnet::delenv('environment\.discdisplay');
 1608:         }
 1609:     }
 1610:     if (defined($env{'form.discmark'}) ) {
 1611:         my $newmark = $env{'form.newmark'};
 1612:         if ($newmark eq 'ondisp') {
 1613:            $message.=&mt('In discussions: new posts will be cease to be identified as "NEW" after display.').'<br />';
 1614:             &Apache::lonnet::put('environment',{'discmarkread' => $newmark});
 1615:             &Apache::lonnet::appenv({'environment.discmarkread' => $newmark});
 1616:         } else {
 1617:             $message.=&mt('In discussions: posts will be identified as "NEW" until marked as read by the reader.').'<br />';
 1618:             &Apache::lonnet::del('environment',['discmarkread']);
 1619:             &Apache::lonnet::delenv('environment\.discmarkread');
 1620:         }
 1621:     }
 1622:     $r->print(<<ENDVCSCREEN);
 1623: $message
 1624: ENDVCSCREEN
 1625: }
 1626: 
 1627: ################################################################
 1628: # Subroutines for page display on course access (Course Coordinators)
 1629: ################################################################
 1630: sub coursedisplaychanger {
 1631:     my $r = shift;
 1632:     my $user       = $env{'user.name'};
 1633:     my $domain     = $env{'user.domain'};
 1634:     my %userenv = &Apache::lonnet::get('environment',['course_init_display']);
 1635:     my $currvalue = 'whatsnew';
 1636:     my $firstselect = '';
 1637:     my $whatsnewselect = 'checked="checked"';
 1638:     if (exists($userenv{'course_init_display'})) {
 1639:         if ($userenv{'course_init_display'} eq 'firstres') {
 1640:             $currvalue = 'firstres';
 1641:             $firstselect = 'checked="checked"';
 1642: 	    $whatsnewselect = '';
 1643:         }
 1644:     }
 1645:     my %pagenames = (
 1646:                        firstres => 'First resource',
 1647:                        whatsnew => "What's new page",
 1648:                     );
 1649:     my $whatsnew_off=&mt('Display the [_1] in the course.','<b>first resource</b>');
 1650:     my $whatsnew_on=&mt('Display the "[_1]" page - a summary of items in the course which require attention.',"<b>What's New</b>");
 1651: 
 1652:     $r->print('<br /><b>'.&mt('Set the default page to be displayed when you select a course role').'</b>&nbsp;'.&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 />');
 1653:     $r->print(<<ENDLSCREEN);
 1654: <form name="prefs" action="/adm/preferences" method="post">
 1655: <input type="hidden" name="action" value="verify_and_change_coursepage" />
 1656: <br />
 1657: <label><input type="radio" name="newdisp" value="firstres" $firstselect /> $whatsnew_off</label><br />
 1658: <label><input type="radio" name="newdisp" value="whatsnew" $whatsnewselect /> $whatsnew_on</label><input type="hidden" name="refpage" value="$env{'form.refpage'}" />
 1659: ENDLSCREEN
 1660:     $r->print('<br /><br /><input type="submit" value="'.&mt('Change').'" />
 1661: </form>');
 1662: }
 1663: 
 1664: sub verify_and_change_coursepage {
 1665:     my $r = shift;
 1666:     my $message='';
 1667:     my %lt = &Apache::lonlocal::texthash(
 1668:         'defs' => 'Default now set',
 1669:         'when' => 'when you select a course role from the roles screen',
 1670:         'ywbt' => 'you will be taken to the start of the course.',
 1671:         'apwb' => 'a page will be displayed that lists items in the course that may require action from you.',
 1672:         'gtts' => 'Go to the start of the course',
 1673:         'dasp' => "Display the What's New page listing course action items", 
 1674:     );
 1675:     my $newdisp  = $env{'form.newdisp'};
 1676:     $message = '<b>'.$lt{'defs'}.'</b>: '.$lt{'when'}.', ';
 1677:     if ($newdisp eq 'firstres') {
 1678:         $message .= $lt{'ywbt'}.'<br />';
 1679:         &Apache::lonnet::put('environment',{'course_init_display' => $newdisp});
 1680:         &Apache::lonnet::appenv({'environment.course_init_display' => $newdisp});
 1681:     } else {
 1682:         $message .= $lt{'apwb'}.'<br />';
 1683:         &Apache::lonnet::del('environment',['course_init_display']);
 1684:         &Apache::lonnet::delenv('environment\.course_init_display');
 1685:     }
 1686:     my $refpage = $env{'form.refpage'};
 1687:     if (($env{'request.course.fn'}) && ($env{'request.course.id'})) {
 1688:         if ($newdisp eq 'firstres') {
 1689:             my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
 1690:             my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; 
 1691:             my ($furl,$ferr)=
 1692:                 &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
 1693:             $message .= '<br /><font size="+1"><a href="'.$furl.'">'.$lt{'gtts'}.' <i>'.&mt('now').'</i></a></font>';
 1694:         } else {
 1695:             $message .= '<br /><font size="+1"><a href="/adm/whatsnew?refpage='.
 1696:                         $refpage.'">'.$lt{'dasp'}.'</a></font>';
 1697:         }
 1698:     }
 1699:     $r->print(<<ENDVCSCREEN);
 1700: $message
 1701: <br /><br />
 1702: ENDVCSCREEN
 1703: }
 1704: 
 1705: 
 1706: ######################################################
 1707: #            other handler subroutines               #
 1708: ######################################################
 1709: 
 1710: ################################################################
 1711: #                          Main handler                        #
 1712: ################################################################
 1713: sub handler {
 1714:     my $r = shift;
 1715:     my $user = $env{'user.name'};
 1716:     my $domain = $env{'user.domain'};
 1717:     &Apache::loncommon::content_type($r,'text/html');
 1718:     # Some pages contain DES keys and should not be cached.
 1719:     &Apache::loncommon::no_cache($r);
 1720:     $r->send_http_header;
 1721:     return OK if $r->header_only;
 1722:     #
 1723:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
 1724:                                    ['action','wysiwyg','returnurl','refpage']);
 1725:     #
 1726:     &Apache::lonhtmlcommon::clear_breadcrumbs();
 1727:     &Apache::lonhtmlcommon::add_breadcrumb
 1728:         ({href => '/adm/preferences',
 1729:           text => 'Set User Preferences'});
 1730: 
 1731:     my @Options;
 1732:     # Determine current authentication method
 1733:     my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
 1734:     if ($currentauth =~ /^(unix|internal):/) {
 1735:         push (@Options,({ action   => 'changepass',
 1736:                           linktext => 'Change Password',
 1737:                           href     => '/adm/preferences',
 1738:                           help     => 'Change_Password',
 1739:                           subroutine => \&passwordchanger,
 1740:                           breadcrumb => 
 1741:                               { href => '/adm/preferences?action=changepass',
 1742:                                 text => 'Change Password'},
 1743:                           },
 1744:                         { action => 'verify_and_change_pass',
 1745:                           subroutine => \&verify_and_change_password,
 1746:                           breadcrumb => 
 1747:                               { href =>'/adm/preferences?action=changepass',
 1748:                                 text => 'Change Password'},
 1749:                           printmenu => 'not_on_error',
 1750:                           }));
 1751:     }
 1752:     push (@Options,({ action   => 'changescreenname',
 1753:                       linktext => 'Change Screen Name',
 1754:                       href     => '/adm/preferences',
 1755:                       help     => 'Prefs_Screen_Name_Nickname',
 1756:                       subroutine => \&screennamechanger,
 1757:                       breadcrumb => 
 1758:                           { href => '/adm/preferences?action=changescreenname',
 1759:                             text => 'Change Screen Name'},
 1760:                       },
 1761:                     { action   => 'verify_and_change_screenname',
 1762:                       subroutine => \&verify_and_change_screenname,
 1763:                       breadcrumb => 
 1764:                           { href => '/adm/preferences?action=changescreenname',
 1765:                             text => 'Change Screen Name'},
 1766:                       printmenu => 'yes',
 1767:                       }));
 1768: 
 1769:     push (@Options,({ action   => 'changemsgforward',
 1770:                       linktext => 'Change Message Forwarding and Notification Email Addresses',
 1771:                       href     => '/adm/preferences',
 1772:                       help     => 'Prefs_Messages',
 1773:                       breadcrumb => 
 1774:                           { href => '/adm/preferences?action=changemsgforward',
 1775:                             text => 'Change Message Forwarding/Notification'},
 1776:                       subroutine => \&msgforwardchanger,
 1777:                       },
 1778:                     { action => 'verify_and_change_msgforward',
 1779:                       help   => 'Prefs_Messages',
 1780:                       breadcrumb => 
 1781:                           { href => '/adm/preferences?action=changemsgforward',
 1782:                             text => 'Change Message Forwarding/Notification'},
 1783:                       printmenu => 'no',
 1784:                       subroutine => \&verify_and_change_msgforward }));
 1785:     my $aboutmeaction=
 1786:         '/adm/'.$env{'user.domain'}.'/'.$env{'user.name'}.'/aboutme';
 1787:     push (@Options,{ action => 'none', 
 1788:                      linktext =>
 1789:                          q{Edit the 'About Me' Personal Information Screen},
 1790: 		     help => 'Prefs_About_Me',
 1791:                      href => $aboutmeaction});
 1792:     push (@Options,({ action => 'changecolors',
 1793:                       linktext => 'Change Color Scheme',
 1794:                       href => '/adm/preferences',
 1795:                       help => 'Change_Colors',
 1796:                       breadcrumb => 
 1797:                           { href => '/adm/preferences?action=changecolors',
 1798:                             text => 'Change Colors'},
 1799:                       subroutine => \&colorschanger,
 1800:                   },
 1801:                     { action => 'verify_and_change_colors',
 1802:                       breadcrumb => 
 1803:                           { href => '/adm/preferences?action=changecolors',
 1804:                             text => 'Change Colors'},
 1805:                       printmenu => 'yes',
 1806:                       subroutine => \&verify_and_change_colors,
 1807:                       }));
 1808:     push (@Options,({ action => 'changelanguages',
 1809:                       linktext => 'Change Language Preferences',
 1810:                       href => '/adm/preferences',
 1811: 		      help => 'Prefs_Language',
 1812:                       breadcrumb=>
 1813:                           { href => '/adm/preferences?action=changelanguages',
 1814:                             text => 'Change Language'},
 1815:                       subroutine =>  \&languagechanger,
 1816:                   },
 1817:                     { action => 'verify_and_change_languages',
 1818:                       breadcrumb=>
 1819:                           {href => '/adm/preferences?action=changelanguages',
 1820:                            text => 'Change Language'},
 1821:                       printmenu => 'yes',
 1822:                       subroutine=>\&verify_and_change_languages, }
 1823:                     ));
 1824:     push (@Options,({ action => 'changewysiwyg',
 1825:                       linktext => 'Change WYSIWYG Editor Preferences',
 1826:                       href => '/adm/preferences',
 1827:                       breadcrumb => 
 1828:                             { href => '/adm/preferences?action=changewysiwyg',
 1829:                               text => 'Change WYSIWYG Preferences'},
 1830:                       subroutine => \&wysiwygchanger,
 1831:                   },
 1832:                     { action => 'set_wysiwyg',
 1833:                       breadcrumb =>
 1834:                           { href => '/adm/preferences?action=changewysiwyg',
 1835:                             text => 'Change WYSIWYG Preferences'},
 1836:                       printmenu => 'yes',
 1837:                       subroutine => \&verify_and_change_wysiwyg, }
 1838:                     ));
 1839:     push (@Options,({ action => 'changediscussions',
 1840:                       linktext => 'Change Discussion Display Preferences',
 1841:                       href => '/adm/preferences',
 1842:                       help => 'Change_Discussion_Display',
 1843:                       breadcrumb => 
 1844:                             { href => '/adm/preferences?action=changediscussions',
 1845:                               text => 'Change Discussion Preferences'},
 1846:                       subroutine => \&discussionchanger,
 1847:                   },
 1848:                     { action => 'verify_and_change_discussion',
 1849:                       breadcrumb =>
 1850:                           { href => '/adm/preferences?action=changediscussions',
 1851:                             text => 'Change Discussion Preferences'},
 1852:                       printmenu => 'yes',
 1853:                       subroutine => \&verify_and_change_discussion, }
 1854:                     ));
 1855: 
 1856:     my $role = ($env{'user.adv'} ? 'Roles' : 'Course');
 1857:     push (@Options,({ action   => 'changerolespref',
 1858:                       linktext => 'Change '.$role.' Page Preferences',
 1859:                       href     => '/adm/preferences',
 1860:                       subroutine => \&rolesprefchanger,
 1861:                       breadcrumb =>
 1862:                           { href => '/adm/preferences?action=changerolespref',
 1863:                             text => 'Change '.$role.' Page Pref'},
 1864:                       },
 1865:                     { action   => 'verify_and_change_rolespref',
 1866:                       subroutine => \&verify_and_change_rolespref,
 1867:                       breadcrumb =>
 1868:                           { href => '/adm/preferences?action=changerolespref',
 1869:                             text => 'Change '.$role.' Page Preferences'},
 1870:                       printmenu => 'yes',
 1871:                       }));
 1872: 
 1873:     push (@Options,({ action   => 'changetexenginepref',
 1874:                       linktext => 'Change How Math Equations Are Displayed',
 1875:                       href     => '/adm/preferences',
 1876:                       subroutine => \&texenginechanger,
 1877:                       breadcrumb =>
 1878:                           { href => '/adm/preferences?action=changetexenginepref',
 1879:                             text => 'Change Math Pref'},
 1880:                       },
 1881:                     { action   => 'verify_and_change_texengine',
 1882:                       subroutine => \&verify_and_change_texengine,
 1883:                       breadcrumb =>
 1884:                           { href => '/adm/preferences?action=changetexenginepref',
 1885:                             text => 'Change Math Preferences'},
 1886:                       printmenu => 'yes',
 1887:                       }));
 1888: 
 1889:     if ($env{'environment.remote'} eq 'off') {
 1890: 	push (@Options,({ action => 'launch',
 1891: 			  linktext => 'Launch Remote Control',
 1892: 			  href => '/adm/remote?url=/adm/preferences',
 1893: 		      }));
 1894:     } else {
 1895: 	push (@Options,({ action => 'collapse',
 1896: 			  linktext => 'Collapse Remote Control',
 1897: 			  href => '/adm/remote?url=/adm/preferences',
 1898: 		      }));
 1899:     }
 1900: 
 1901:     push (@Options,({ action   => 'changeicons',
 1902:                       linktext => 'Change How Menus are Displayed',
 1903:                       href     => '/adm/preferences',
 1904:                       subroutine => \&iconchanger,
 1905:                       breadcrumb =>
 1906:                           { href => '/adm/preferences?action=changeicons',
 1907:                             text => 'Change Main Menu'},
 1908:                       },
 1909:                     { action   => 'verify_and_change_icons',
 1910:                       subroutine => \&verify_and_change_icons,
 1911:                       breadcrumb =>
 1912:                           { href => '/adm/preferences?action=changeicons',
 1913:                             text => 'Change Main Menu'},
 1914:                       printmenu => 'yes',
 1915:                       }));
 1916: 
 1917:     push (@Options,({ action   => 'changeclicker',
 1918:                       linktext => 'Register Response Devices ("Clickers")',
 1919:                       href     => '/adm/preferences',
 1920:                       subroutine => \&clickerchanger,
 1921:                       breadcrumb =>
 1922:                           { href => '/adm/preferences?action=changeclicker',
 1923:                             text => 'Register Clicker'},
 1924:                       },
 1925:                     { action   => 'verify_and_change_clicker',
 1926:                       subroutine => \&verify_and_change_clicker,
 1927:                       breadcrumb =>
 1928:                           { href => '/adm/preferences?action=changeclicker',
 1929:                             text => 'Register Clicker'},
 1930:                       printmenu => 'yes',
 1931:                       }));
 1932:     my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au']);
 1933:     if (keys(%author_roles) > 0) {
 1934:       push (@Options,({ action   => 'changedomcoord',
 1935:                         linktext => 'Restrict Domain Coordinator Access',
 1936:                         href     => '/adm/preferences',
 1937:                         subroutine => \&domcoordchanger,
 1938:                         breadcrumb =>
 1939:                             { href => '/adm/preferences?action=changedomcoord',
 1940:                               text => 'Restrict Domain Coordinator Access'},
 1941:                       },
 1942:                       { action   => 'verify_and_change_domcoord',
 1943:                         subroutine => \&verify_and_change_domcoord,
 1944:                         breadcrumb =>
 1945:                             { href => '/adm/preferences?action=changedomcoord',
 1946:                               text => 'Restrict Domain Coordinator Access'},
 1947:                         printmenu => 'yes',
 1948:                       }));
 1949:     }
 1950: 
 1951:     push (@Options,({ action   => 'lockwarning',
 1952:                       subroutine => \&lockwarning,
 1953:                       breadcrumb =>
 1954:                           { href => '/adm/preferences?action=lockwarning',
 1955:                             text => 'Lock Warnings'},
 1956:                       },
 1957:                     { action   => 'verify_and_change_locks',
 1958:                       subroutine => \&verify_and_change_lockwarning,
 1959:                       breadcrumb =>
 1960:                           { href => '/adm/preferences?action=lockwarning',
 1961:                             text => 'Lockwarnings'},
 1962:                       printmenu => 'yes',
 1963:                       }));
 1964: 
 1965: 
 1966:     if (&Apache::lonnet::allowed('whn',$env{'request.course.id'})
 1967: 	|| &Apache::lonnet::allowed('whn',$env{'request.course.id'}.'/'
 1968: 				    .$env{'request.course.sec'})) {
 1969:         push (@Options,({ action => 'changecourseinit',
 1970:                           linktext => 'Change Course Initialization Preference',
 1971:                           href => '/adm/preferences',
 1972:                           subroutine => \&coursedisplaychanger,
 1973:                           breadcrumb =>
 1974:                               { href => '/adm/preferences?action=changecourseinit',
 1975:                                 text => 'Change Course Init. Pref.'},
 1976:                           },
 1977:                         { action => 'verify_and_change_coursepage',
 1978:                           breadcrumb =>
 1979:                           { href => '/adm/preferences?action=changecourseinit',                               text => 'Change Course Initialization Preference'},
 1980:                         printmenu => 'yes',
 1981:                         subroutine => \&verify_and_change_coursepage,
 1982:                        }));
 1983:     }
 1984: 
 1985:     if ($env{'user.name'} =~ /^(albertel|fox|foxr|kortemey|korte|raeburn)$/) {
 1986:         push (@Options,({ action => 'debugtoggle',
 1987:                           printmenu => 'yes',
 1988:                           subroutine => \&toggle_debug,
 1989:                           }));
 1990:     }
 1991: 
 1992:     $r->print(&Apache::loncommon::start_page('Change Preferences'));
 1993: 
 1994:     my $call = undef;
 1995:     my $help = undef;
 1996:     my $printmenu = 'yes';
 1997:     foreach my $option (@Options) {
 1998:         if ($option->{'action'} eq $env{'form.action'}) {
 1999:             $call = $option->{'subroutine'};
 2000:             $printmenu = $option->{'printmenu'};
 2001:             if (exists($option->{'breadcrumb'})) {
 2002:                 &Apache::lonhtmlcommon::add_breadcrumb
 2003:                     ($option->{'breadcrumb'});
 2004:             }
 2005: 	    $help=$option->{'help'};
 2006:         }
 2007:     }
 2008:     $r->print(&Apache::lonhtmlcommon::breadcrumbs('Change Preferences',$help));
 2009:     my $error;
 2010:     if (defined($call)) {
 2011:         $error = $call->($r);
 2012:     }
 2013:     if ( ( ($printmenu eq 'yes')
 2014: 	   || ($printmenu eq 'not_on_error' && !$error) )
 2015: 	 && (!$env{'form.returnurl'})) {
 2016:         my $optionlist = '<table cellpadding="5">';
 2017:         if ($env{'user.name'} =~ 
 2018:                          /^(albertel|kortemey|fox|foxr|korte|hallmat3|turtle|raeburn)$/
 2019:             ) {
 2020:             push (@Options,({ action => 'debugtoggle',
 2021:                               linktext => 'Toggle Debug Messages',
 2022:                               text => 'Current Debug status is -'.
 2023:                                   $env{'user.debug'}.'-.',
 2024:                               href => '/adm/preferences',
 2025:                               printmenu => 'yes',
 2026:                               subroutine => \&toggle_debug,
 2027:                               }));
 2028:         }
 2029:         foreach my $option(@Options) {
 2030:             my $optiontext = '';
 2031:             if (exists($option->{'href'})) {
 2032: 		$option->{'href_args'}{'action'}=$option->{'action'};
 2033: 		$optiontext .= 
 2034:                     '<a href="'.&add_get_param($option->{'href'},
 2035: 					       $option->{'href_args'}).'">'.
 2036:                     &mt($option->{'linktext'}).'</a>';
 2037:             }
 2038:             if (exists($option->{'text'})) {
 2039:                 $optiontext .= ' '.&mt($option->{'text'});
 2040:             }
 2041:             if ($optiontext ne '') {
 2042:                 $optiontext = '<font size="+1">'.$optiontext.'</font>'; 
 2043:                 my $helplink = '&nbsp;';
 2044:                 if (exists($option->{'help'})) {
 2045:                     $helplink = &Apache::loncommon::help_open_topic
 2046:                                                     ($option->{'help'});
 2047:                 }
 2048:                 $optionlist .= '<tr>'.
 2049:                     '<td>'.$helplink.'</td>'.
 2050:                     '<td>'.$optiontext.'</td>'.
 2051:                     '</tr>';
 2052:             }
 2053:         }
 2054:         $optionlist .= '</table>';
 2055:         $r->print($optionlist);
 2056:     } elsif ($env{'form.returnurl'}) {
 2057: 	$r->print('<br /><a href="'.$env{'form.returnurl'}.'"><font size="+1">'.
 2058: 		  &mt('Return').'</font></a>');
 2059:     }
 2060:     $r->print(&Apache::loncommon::end_page());
 2061:     return OK;
 2062: }
 2063: 
 2064: sub toggle_debug {
 2065:     if ($env{'user.debug'}) {
 2066:         &Apache::lonnet::delenv('user\.debug');
 2067:     } else {
 2068:         &Apache::lonnet::appenv({'user.debug' => 1});
 2069:     }
 2070: }
 2071: 
 2072: 1;
 2073: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>