Annotation of loncom/interface/lonpreferences.pm, revision 1.91

1.1       www         1: # The LearningOnline Network
                      2: # Preferences
                      3: #
1.91    ! albertel    4: # $Id: lonpreferences.pm,v 1.90 2006/06/14 19:13:11 albertel Exp $
1.2       albertel    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: #
1.3       matthew    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:  
1.1       www        33: package Apache::lonpreferences;
                     34: 
                     35: use strict;
1.86      albertel   36: use LONCAPA;
1.1       www        37: use Apache::Constants qw(:common);
1.3       matthew    38: use Apache::File;
                     39: use Crypt::DES;
                     40: use DynaLoader; # for Crypt::DES version
1.4       matthew    41: use Apache::loncommon();
1.23      matthew    42: use Apache::lonhtmlcommon();
1.32      www        43: use Apache::lonlocal;
1.59      albertel   44: use Apache::lonnet;
1.3       matthew    45: 
                     46: #
                     47: # Write lonnet::passwd to do the call below.
                     48: # Use:
                     49: #   my $answer=reply("encrypt:passwd:$udom:$uname:$upass",$tryserver);
                     50: #
                     51: ##################################################
                     52: #          password associated functions         #
                     53: ##################################################
                     54: sub des_keys {
1.4       matthew    55:     # Make a new key for DES encryption.
1.36      www        56:     # Each key has two parts which are returned separately.
1.4       matthew    57:     # Please note:  Each key must be passed through the &hex function
                     58:     # before it is output to the web browser.  The hex versions cannot
                     59:     # be used to decrypt.
1.3       matthew    60:     my @hexstr=('0','1','2','3','4','5','6','7',
                     61:                 '8','9','a','b','c','d','e','f');
                     62:     my $lkey='';
                     63:     for (0..7) {
                     64:         $lkey.=$hexstr[rand(15)];
                     65:     }
                     66:     my $ukey='';
                     67:     for (0..7) {
                     68:         $ukey.=$hexstr[rand(15)];
                     69:     }
                     70:     return ($lkey,$ukey);
                     71: }
                     72: 
                     73: sub des_decrypt {
                     74:     my ($key,$cyphertext) = @_;
                     75:     my $keybin=pack("H16",$key);
                     76:     my $cypher;
                     77:     if ($Crypt::DES::VERSION>=2.03) {
                     78:         $cypher=new Crypt::DES $keybin;
                     79:     } else {
                     80:         $cypher=new DES $keybin;
                     81:     }
                     82:     my $plaintext=
                     83: 	$cypher->decrypt(unpack("a8",pack("H16",substr($cyphertext,0,16))));
                     84:     $plaintext.=
                     85: 	$cypher->decrypt(unpack("a8",pack("H16",substr($cyphertext,16,16))));
1.4       matthew    86:     $plaintext=substr($plaintext,1,ord(substr($plaintext,0,1)) );
1.3       matthew    87:     return $plaintext;
                     88: }
                     89: 
1.4       matthew    90: ################################################################
                     91: #                       Handler subroutines                    #
                     92: ################################################################
1.9       matthew    93: 
                     94: ################################################################
1.28      www        95: #         Language Change Subroutines                          #
                     96: ################################################################
1.44      www        97: 
                     98: sub wysiwygchanger {
                     99:     my $r = shift;
                    100:     my %userenv = &Apache::lonnet::get
                    101:         ('environment',['wysiwygeditor']);
1.78      albertel  102:     my $onselect='checked="checked"';
1.44      www       103:     my $offselect='';
1.77      albertel  104:     if ($userenv{'wysiwygeditor'} eq 'on') {
1.44      www       105: 	$onselect='';
1.78      albertel  106: 	$offselect='checked="checked"';
1.44      www       107:     }
                    108:     my $switchoff=&mt('Disable WYSIWYG editor');
                    109:     my $switchon=&mt('Enable WYSIWYG editor');
                    110:     $r->print(<<ENDLSCREEN);
1.88      albertel  111: <form name="prefs" action="/adm/preferences" method="post">
1.44      www       112: <input type="hidden" name="action" value="set_wysiwyg" />
                    113: <br />
1.65      albertel  114: <label><input type="radio" name="wysiwyg" value="off" $onselect /> $switchoff</label><br />
                    115: <label><input type="radio" name="wysiwyg" value="on" $offselect /> $switchon</label>
1.44      www       116: ENDLSCREEN
                    117:     $r->print('<br /><input type="submit" value="'.&mt('Change').'" />');
                    118: }
                    119: 
                    120: 
                    121: sub verify_and_change_wysiwyg {
                    122:     my $r = shift;
1.59      albertel  123:     my $newsetting=$env{'form.wysiwyg'};
1.44      www       124:     &Apache::lonnet::put('environment',{'wysiwygeditor' => $newsetting});
                    125:     &Apache::lonnet::appenv('environment.wysiwygeditor' => $newsetting);
                    126:     $r->print('<p>'.&mt('Setting WYSIWYG editor to:').' '.&mt($newsetting).'</p>');
                    127: }
                    128: 
                    129: ################################################################
                    130: #         Language Change Subroutines                          #
                    131: ################################################################
1.28      www       132: sub languagechanger {
                    133:     my $r = shift;
1.59      albertel  134:     my $user       = $env{'user.name'};
                    135:     my $domain     = $env{'user.domain'};
1.28      www       136:     my %userenv = &Apache::lonnet::get
1.32      www       137:         ('environment',['languages']);
1.29      www       138:     my $language=$userenv{'languages'};
1.32      www       139: 
1.33      www       140:     my $pref=&mt('Preferred language');
                    141:     my %langchoices=('' => 'No language preference');
                    142:     foreach (&Apache::loncommon::languageids()) {
                    143: 	if (&Apache::loncommon::supportedlanguagecode($_)) {
                    144: 	    $langchoices{&Apache::loncommon::supportedlanguagecode($_)}
                    145: 	               = &Apache::loncommon::plainlanguagedescription($_);
                    146: 	}
                    147:     }
                    148:     my $selectionbox=&Apache::loncommon::select_form($language,'language',
                    149: 						     %langchoices);
1.28      www       150:     $r->print(<<ENDLSCREEN);
1.88      albertel  151: <form name="prefs" action="/adm/preferences" method="post">
1.28      www       152: <input type="hidden" name="action" value="verify_and_change_languages" />
1.33      www       153: <br />$pref: $selectionbox
1.28      www       154: ENDLSCREEN
1.35      matthew   155:     $r->print('<br /><input type="submit" value="'.&mt('Change').'" />');
1.28      www       156: }
                    157: 
                    158: 
                    159: sub verify_and_change_languages {
                    160:     my $r = shift;
1.59      albertel  161:     my $user       = $env{'user.name'};
                    162:     my $domain     = $env{'user.domain'};
1.28      www       163: # Screenname
1.59      albertel  164:     my $newlanguage  = $env{'form.language'};
1.28      www       165:     $newlanguage=~s/[^\-\w]//g;
                    166:     my $message='';
                    167:     if ($newlanguage) {
1.29      www       168:         &Apache::lonnet::put('environment',{'languages' => $newlanguage});
                    169:         &Apache::lonnet::appenv('environment.languages' => $newlanguage);
                    170:         $message='Set new preferred languages to '.$newlanguage;
1.28      www       171:     } else {
1.29      www       172:         &Apache::lonnet::del('environment',['languages']);
                    173:         &Apache::lonnet::delenv('environment\.languages');
1.28      www       174:         $message='Reset preferred language';
                    175:     }
                    176:     $r->print(<<ENDVCSCREEN);
                    177: $message
                    178: ENDVCSCREEN
                    179: }
                    180: 
1.50      albertel  181: ################################################################
1.54      albertel  182: #         Tex Engine Change Subroutines                        #
                    183: ################################################################
                    184: sub texenginechanger {
                    185:     my $r = shift;
1.59      albertel  186:     my $user       = $env{'user.name'};
                    187:     my $domain     = $env{'user.domain'};
1.54      albertel  188:     my %userenv = &Apache::lonnet::get('environment',['texengine']);
                    189:     my $texengine=$userenv{'texengine'};
                    190: 
                    191:     my $pref=&mt('Preferred method to display Math');
1.69      albertel  192:     my %mathchoices=('' => 'Default',
1.54      albertel  193: 		     'tth' => 'TeX to HTML',
1.64      albertel  194: 		     #'ttm' => 'TeX to MathML',
1.54      albertel  195: 		     'jsMath' => 'jsMath',
1.57      albertel  196: 		     'mimetex' => 'Convert to Images'
1.54      albertel  197:                      );
                    198:     my $selectionbox=&Apache::loncommon::select_form($texengine,'texengine',
                    199: 						     %mathchoices);
1.67      albertel  200:     my $jsMath_start=&Apache::lontexconvert::jsMath_header();
1.54      albertel  201:     my $change=&mt('Change');
                    202:     $r->print(<<ENDLSCREEN);
1.67      albertel  203: <br />
                    204: 
1.88      albertel  205: <form name="prefs" action="/adm/preferences" method="post">
1.54      albertel  206: <input type="hidden" name="action" value="verify_and_change_texengine" />
                    207: <p>$pref: $selectionbox</p>
                    208: <p><input type="submit" value="$change" /></p>
                    209: </form>
                    210: Examples:
1.67      albertel  211: <p> TeX to HTML <br /> 
1.79      albertel  212: <iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=tth" width="400" hieght="200"></iframe>
1.67      albertel  213: </p>
1.54      albertel  214: <p>jsMath <br /> 
1.67      albertel  215: $jsMath_start
1.57      albertel  216: <script type="text/javascript">
1.54      albertel  217: if (jsMath.nofonts == 1) {
                    218:     document.writeln
                    219:         ('<center><div style="padding: 10; border-style: solid; border-width:3;'
                    220: 	 +' border-color: #DD0000; background-color: #FFF8F8; width: 75%; text-align: left">'
                    221: 	 +'<small><font color="#AA0000"><b>Warning:</b> '
                    222: 	 +'It looks like you don\\\'t have the TeX math fonts installed. '
                    223: 	 +'The jsMath example on this page may not look right without them. '
                    224: 	 +'The <a href="http://www.math.union.edu/locate/jsMath/" target="_blank"> '
                    225: 	 +'jsMath Home Page</a> has information on how to download the '
                    226: 	 +'needed fonts.  In the meantime, jsMath will do the best it can '
                    227: 	 +'with the fonts you have, but it may not be pretty and some equations '
                    228: 	 +'may not be rendered correctly. '
                    229: 	 +'</font></small></div></center>');
                    230: }
                    231: </script>
1.79      albertel  232: <iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=jsMath" width="400" hieght="200"></iframe>
1.54      albertel  233: 
1.67      albertel  234: </p>
                    235: <p> Convert to Images <br />
                    236: <br />
1.79      albertel  237: <iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=mimetex" width="400" hieght="200"></iframe>
1.67      albertel  238: </p>
1.54      albertel  239: ENDLSCREEN
1.59      albertel  240:     if ($env{'environment.texengine'} ne 'jsMath') {
1.55      albertel  241: 	$r->print('<script type="text/javascript">jsMath.Process()</script>');
                    242:     }
1.54      albertel  243: }
                    244: 
                    245: 
                    246: sub verify_and_change_texengine {
                    247:     my $r = shift;
1.59      albertel  248:     my $user       = $env{'user.name'};
                    249:     my $domain     = $env{'user.domain'};
1.54      albertel  250: # Screenname
1.59      albertel  251:     my $newtexengine  = $env{'form.texengine'};
1.54      albertel  252:     $newtexengine=~s/[^\-\w]//g;
1.56      albertel  253:     if ($newtexengine eq 'ttm') {
                    254: 	&Apache::lonnet::appenv('browser.mathml' => 1);
                    255:     } else {
1.59      albertel  256: 	if ($env{'environment.texengine'} eq 'ttm') {
1.56      albertel  257: 	    &Apache::lonnet::appenv('browser.mathml' => 0);
                    258: 	}
                    259:     }
1.54      albertel  260:     my $message='';
                    261:     if ($newtexengine) {
                    262:         &Apache::lonnet::put('environment',{'texengine' => $newtexengine});
                    263:         &Apache::lonnet::appenv('environment.texengine' => $newtexengine);
                    264:         $message='Set new preferred math display to '.$newtexengine;
                    265:     } else {
                    266:         &Apache::lonnet::del('environment',['texengine']);
                    267:         &Apache::lonnet::delenv('environment\.texengine');
                    268:         $message='Reset preferred math display.';
                    269:     }
1.56      albertel  270: 
                    271: 
1.54      albertel  272:     $r->print(<<ENDVCSCREEN);
                    273: $message
                    274: ENDVCSCREEN
                    275: }
                    276: 
                    277: ################################################################
1.50      albertel  278: #         Roles Page Preference Change Subroutines         #
                    279: ################################################################
                    280: sub rolesprefchanger {
                    281:     my $r = shift;
1.59      albertel  282:     my $user       = $env{'user.name'};
                    283:     my $domain     = $env{'user.domain'};
1.50      albertel  284:     my %userenv = &Apache::lonnet::get
                    285:         ('environment',['recentroles','recentrolesn']);
                    286:     my $hotlist_flag=$userenv{'recentroles'};
                    287:     my $hotlist_n=$userenv{'recentrolesn'};
                    288:     my $checked;
                    289:     if ($hotlist_flag) {
                    290: 	$checked = 'checked="checked"';
                    291:     }
                    292:     
                    293:     if (!$hotlist_n) { $hotlist_n=3; }
                    294:     my $options;
                    295:     for (my $i=1; $i<10; $i++) {
                    296: 	my $select;
                    297: 	if ($hotlist_n == $i) { $select = 'selected="selected"'; }
                    298: 	$options .= "<option $select>$i</option>\n";
                    299:     }
                    300: 
1.89      albertel  301: # Get list of recent roles and display with checkbox in front
                    302:     my $roles_check_list = '';
                    303:     my $role_key='';
                    304:     if ($env{'environment.recentroles'}) {
                    305:         my %recent_roles =
                    306:                &Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'});
1.91    ! albertel  307:         my %frozen_roles =
        !           308:                &Apache::lonhtmlcommon::get_recent_frozen('roles',$env{'environment.recentrolesn'});
1.89      albertel  309:         
                    310:         $roles_check_list .=
                    311: 	    &Apache::loncommon::start_data_table().
                    312: 	    &Apache::loncommon::start_data_table_header_row().
                    313: 	    "<th>".&mt('Freeze Role')."</th>".
                    314: 	    "<th>".&mt('Role')."</td>".
                    315: 	    &Apache::loncommon::end_data_table_header_row().
                    316: 	    "\n";
                    317: 	my $count;
                    318:         foreach $role_key (sort(keys(%recent_roles))) {
                    319:             my $checked = "";
                    320:             my $value = $recent_roles{$role_key};
1.91    ! albertel  321:             if ($frozen_roles{$role_key}) {
1.89      albertel  322:                 $checked = "checked=\"checked\"";
                    323:             }
                    324: # get course information
                    325:             my ($role,$rest) = split(/\./, $role_key);
                    326:             my $trole = &Apache::lonnet::plaintext($role);
                    327:             my ($tdomain,$other,$tsection)=
                    328:                     split(/\//,Apache::lonnet::declutter($rest));
                    329:             my $tother = '-';
                    330:             if ($role =~ /cc|st|in|ta/ ) {
                    331:                my %newhash=&Apache::lonnet::coursedescription($tdomain."_".$other);
                    332:                $tother = " - ".$newhash{'description'};
                    333:             } elsif ($role =~ /dc/) {
                    334:                $tother = "";
                    335:             } else {
                    336:                $tother = " - $other";
                    337:             }
                    338: 
                    339:             my $section="";
                    340: 	    if ($tsection) {
                    341:                $section = " - Section/Group: $tsection";
                    342:             }
                    343: 	    $count++;
                    344:             $roles_check_list .=
                    345: 		&Apache::loncommon::start_data_table_row().
                    346: 		'<td class="LC_table_cell_checkbox">'.
                    347: 		"<input type=\"checkbox\" $checked name=\"freezeroles\"".
                    348: 		" id=\"freezeroles$count\" value=\"$role_key\" /></td>".
                    349: 		"<td><label for=\"freezeroles$count\">".
                    350: 		"$trole - $tdomain $tother $section</label></td>".
                    351: 		&Apache::loncommon::end_data_table_row(). "\n";
                    352:         }
                    353:         $roles_check_list .= "</table>\n";
                    354:     }
                    355: 
                    356:     $r->print('
                    357: <p>'.&mt('Some LON-CAPA users have a long list of roles. The Recent Roles Hotlist feature keeps track of the last N roles which have been visited and places a table of these at the top of the roles page. People with very few roles should leave this feature disabled.').'
1.50      albertel  358: </p>
1.89      albertel  359: <form name="prefs" action="/adm/preferences" method="POST">
1.50      albertel  360: <input type="hidden" name="action" value="verify_and_change_rolespref" />
1.89      albertel  361: <br /><label>'.&mt('Enable Recent Roles Hotlist:').'
                    362: <input type="checkbox" '.$checked.' name="recentroles" value="true" /></label>
                    363: <br />'.&mt('Number of roles in Hotlist:').'
1.50      albertel  364: <select name="recentrolesn" size="1">
1.89      albertel  365: '.$options.'
1.50      albertel  366: </select>
1.89      albertel  367: <p>'.&mt('This list below can be used to <q>freeze</q> roles on your screen. Those marked as frozen will not be removed from the list, even if they have not been used recently.').'
                    368: </p>
                    369: '.$roles_check_list.'
1.50      albertel  370: <br />
1.89      albertel  371: <input type="submit" value="'.&mt('Change').'" />
                    372: </form>');
1.50      albertel  373: }
                    374: 
                    375: sub verify_and_change_rolespref {
                    376:     my $r = shift;
1.59      albertel  377:     my $user       = $env{'user.name'};
                    378:     my $domain     = $env{'user.domain'};
1.50      albertel  379: # Recent Roles Hotlist Flag
1.59      albertel  380:     my $hotlist_flag  = $env{'form.recentroles'};
                    381:     my $hotlist_n  = $env{'form.recentrolesn'};
1.89      albertel  382:     my $message='<hr />';
1.50      albertel  383:     if ($hotlist_flag) {
                    384:         &Apache::lonnet::put('environment',{'recentroles' => $hotlist_flag});
                    385:         &Apache::lonnet::appenv('environment.recentroles' => $hotlist_flag);
1.89      albertel  386:         $message=&mt('Recent Roles Hotlist is Enabled');
1.50      albertel  387:     } else {
                    388:         &Apache::lonnet::del('environment',['recentroles']);
                    389:         &Apache::lonnet::delenv('environment\.recentroles');
1.89      albertel  390:         $message=&mt('Recent Roles Hotlist is Disabled');
1.50      albertel  391:     }
                    392:     if ($hotlist_n) {
                    393:         &Apache::lonnet::put('environment',{'recentrolesn' => $hotlist_n});
                    394:         &Apache::lonnet::appenv('environment.recentrolesn' => $hotlist_n);
                    395:         if ($hotlist_flag) {
1.90      albertel  396:             $message.="<br />".
                    397: 		&mt('Display [_1] Most Recent Roles',$hotlist_n)."\n";
1.89      albertel  398:         }
                    399:     }
                    400: 
                    401: # Get list of froze roles and list of recent roles
                    402:     my @freeze_list = &Apache::loncommon::get_env_multiple('form.freezeroles');
                    403:     my %freeze = ();
                    404:     foreach my $key (@freeze_list) {
1.91    ! albertel  405:         $freeze{$key}='1';
1.89      albertel  406:     }
                    407:     
                    408:     my %recent_roles =
                    409:         &Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'});
1.91    ! albertel  410:     my %frozen_roles =
        !           411:         &Apache::lonhtmlcommon::get_recent_frozen('roles',$env{'environment.recentrolesn'});
1.89      albertel  412: 
                    413: # Unset any roles that were previously frozen but aren't in list
                    414: 
                    415:     foreach my $role_key (sort(keys(%recent_roles))) {
1.91    ! albertel  416:         if (($frozen_roles{$role_key}) && (!exists($freeze{$role_key}))) {
1.89      albertel  417: 	    $message .= "<br />".&mt('Unfreezing Role: [_1]',$role_key)."\n";
1.91    ! albertel  418: 	    &Apache::lonhtmlcommon::store_recent('roles',$role_key,' ',0);
1.89      albertel  419:         }
                    420:     }
                    421: 
                    422: # Freeze selected roles
                    423:     foreach my $role_key (@freeze_list) {
1.91    ! albertel  424:         if (!$frozen_roles{$role_key}) {
        !           425:              $message .= "<br />".&mt('Freezing Role: [_1]',$role_key)."\n";
1.89      albertel  426:              &Apache::lonhtmlcommon::store_recent('roles',
1.91    ! albertel  427:                                           $role_key,' ',1);
1.50      albertel  428:         }
                    429:     }
1.89      albertel  430:     $message .= "<hr /><br />\n";
1.50      albertel  431: 
                    432:     $r->print(<<ENDRPSCREEN);
                    433: $message
                    434: ENDRPSCREEN
                    435: }
                    436: 
                    437: 
1.28      www       438: 
                    439: ################################################################
1.9       matthew   440: #         Anonymous Discussion Name Change Subroutines         #
                    441: ################################################################
1.5       www       442: sub screennamechanger {
                    443:     my $r = shift;
1.59      albertel  444:     my $user       = $env{'user.name'};
                    445:     my $domain     = $env{'user.domain'};
1.14      www       446:     my %userenv = &Apache::lonnet::get
                    447:         ('environment',['screenname','nickname']);
1.6       www       448:     my $screenname=$userenv{'screenname'};
1.14      www       449:     my $nickname=$userenv{'nickname'};
1.5       www       450:     $r->print(<<ENDSCREEN);
1.88      albertel  451: <form name="prefs" action="/adm/preferences" method="post">
1.6       www       452: <input type="hidden" name="action" value="verify_and_change_screenname" />
1.14      www       453: <br />New screenname (shown if you post anonymously):
1.6       www       454: <input type="text" size="20" value="$screenname" name="screenname" />
1.14      www       455: <br />New nickname (shown if you post non-anonymously):
                    456: <input type="text" size="20" value="$nickname" name="nickname" />
1.6       www       457: <input type="submit" value="Change" />
                    458: </form>
1.5       www       459: ENDSCREEN
                    460: }
1.6       www       461: 
                    462: sub verify_and_change_screenname {
                    463:     my $r = shift;
1.59      albertel  464:     my $user       = $env{'user.name'};
                    465:     my $domain     = $env{'user.domain'};
1.14      www       466: # Screenname
1.59      albertel  467:     my $newscreen  = $env{'form.screenname'};
1.14      www       468:     $newscreen=~s/[^ \w]//g;
1.6       www       469:     my $message='';
                    470:     if ($newscreen) {
1.7       www       471:         &Apache::lonnet::put('environment',{'screenname' => $newscreen});
                    472:         &Apache::lonnet::appenv('environment.screenname' => $newscreen);
1.6       www       473:         $message='Set new screenname to '.$newscreen;
                    474:     } else {
                    475:         &Apache::lonnet::del('environment',['screenname']);
1.7       www       476:         &Apache::lonnet::delenv('environment\.screenname');
1.6       www       477:         $message='Reset screenname';
                    478:     }
1.14      www       479: # Nickname
                    480:     $message.='<br />';
1.59      albertel  481:     $newscreen  = $env{'form.nickname'};
1.14      www       482:     $newscreen=~s/[^ \w]//g;
                    483:     if ($newscreen) {
                    484:         &Apache::lonnet::put('environment',{'nickname' => $newscreen});
                    485:         &Apache::lonnet::appenv('environment.nickname' => $newscreen);
                    486:         $message.='Set new nickname to '.$newscreen;
                    487:     } else {
                    488:         &Apache::lonnet::del('environment',['nickname']);
                    489:         &Apache::lonnet::delenv('environment\.nickname');
                    490:         $message.='Reset nickname';
                    491:     }
1.68      www       492:     &Apache::lonnet::devalidate_cache_new('namescache',$user.':'.$domain);
1.6       www       493:     $r->print(<<ENDVCSCREEN);
                    494: $message
                    495: ENDVCSCREEN
1.20      www       496: }
                    497: 
                    498: ################################################################
                    499: #         Message Forward                                      #
                    500: ################################################################
                    501: 
                    502: sub msgforwardchanger {
                    503:     my $r = shift;
1.59      albertel  504:     my $user       = $env{'user.name'};
                    505:     my $domain     = $env{'user.domain'};
1.26      www       506:     my %userenv = &Apache::lonnet::get('environment',['msgforward','notification','critnotification']);
1.20      www       507:     my $msgforward=$userenv{'msgforward'};
                    508:     my $notification=$userenv{'notification'};
                    509:     my $critnotification=$userenv{'critnotification'};
1.25      bowersj2  510:     my $forwardingHelp = Apache::loncommon::help_open_topic("Prefs_Forwarding",
                    511: 							    "What are forwarding ".
                    512: 							    "and notification ".
                    513: 							    "addresses");
1.27      bowersj2  514:     my $criticalMessageHelp = Apache::loncommon::help_open_topic("Course_Critical_Message",
                    515: 								 "What are critical messages");
                    516: 
1.20      www       517:     $r->print(<<ENDMSG);
1.25      bowersj2  518: $forwardingHelp <br />
1.88      albertel  519: <form name="prefs" action="/adm/preferences" method="post">
1.20      www       520: <input type="hidden" name="action" value="verify_and_change_msgforward" />
                    521: New Forwarding Address(es) (<tt>user:domain,user:domain,...</tt>):
                    522: <input type="text" size="40" value="$msgforward" name="msgforward" /><hr />
                    523: New Message Notification Email Address(es) (<tt>joe\@doe.com,jane\@doe.edu,...</tt>):
                    524: <input type="text" size="40" value="$notification" name="notification" /><hr />
                    525: New Critical Message Notification Email Address(es) (<tt>joe\@doe.com,jane\@doe.edu,...</tt>):
1.27      bowersj2  526: <input type="text" size="40" value="$critnotification" name="critnotification" />$criticalMessageHelp<hr />
1.20      www       527: <input type="submit" value="Change" />
                    528: </form>
                    529: ENDMSG
                    530: }
                    531: 
                    532: sub verify_and_change_msgforward {
                    533:     my $r = shift;
1.59      albertel  534:     my $user       = $env{'user.name'};
                    535:     my $domain     = $env{'user.domain'};
1.20      www       536:     my $newscreen  = '';
                    537:     my $message='';
1.59      albertel  538:     foreach (split(/\,/,$env{'form.msgforward'})) {
1.20      www       539: 	my ($msuser,$msdomain)=split(/[\@\:]/,$_);
                    540:         $msuser=~s/\W//g;
                    541:         $msdomain=~s/\W//g;
                    542:         if (($msuser) && ($msdomain)) {
                    543: 	    if (&Apache::lonnet::homeserver($msuser,$msdomain) ne 'no_host') {
                    544:                $newscreen.=$msuser.':'.$msdomain.',';
                    545: 	   } else {
                    546:                $message.='No such user: '.$msuser.':'.$msdomain.'<br>';
                    547:            }
                    548:         }
                    549:     }
                    550:     $newscreen=~s/\,$//;
                    551:     if ($newscreen) {
                    552:         &Apache::lonnet::put('environment',{'msgforward' => $newscreen});
                    553:         &Apache::lonnet::appenv('environment.msgforward' => $newscreen);
                    554:         $message.='Set new message forwarding to '.$newscreen.'<br />';
                    555:     } else {
                    556:         &Apache::lonnet::del('environment',['msgforward']);
                    557:         &Apache::lonnet::delenv('environment\.msgforward');
                    558:         $message.='Reset message forwarding<br />';
                    559:     }
1.59      albertel  560:     my $notification=$env{'form.notification'};
1.20      www       561:     $notification=~s/\s//gs;
                    562:     if ($notification) {
                    563:         &Apache::lonnet::put('environment',{'notification' => $notification});
                    564:         &Apache::lonnet::appenv('environment.notification' => $notification);
                    565:         $message.='Set message notification address to '.$notification.'<br />';
                    566:     } else {
                    567:         &Apache::lonnet::del('environment',['notification']);
                    568:         &Apache::lonnet::delenv('environment\.notification');
                    569:         $message.='Reset message notification<br />';
                    570:     }
1.59      albertel  571:     my $critnotification=$env{'form.critnotification'};
1.20      www       572:     $critnotification=~s/\s//gs;
                    573:     if ($critnotification) {
                    574:         &Apache::lonnet::put('environment',{'critnotification' => $critnotification});
                    575:         &Apache::lonnet::appenv('environment.critnotification' => $critnotification);
                    576:         $message.='Set critical message notification address to '.$critnotification;
                    577:     } else {
                    578:         &Apache::lonnet::del('environment',['critnotification']);
                    579:         &Apache::lonnet::delenv('environment\.critnotification');
                    580:         $message.='Reset critical message notification<br />';
                    581:     }
                    582:     $r->print(<<ENDVCMSG);
                    583: $message
                    584: ENDVCMSG
1.6       www       585: }
                    586: 
1.12      www       587: ################################################################
1.19      www       588: #         Colors                                               #
1.12      www       589: ################################################################
                    590: 
1.19      www       591: sub colorschanger {
1.12      www       592:     my $r = shift;
1.19      www       593: # figure out colors
1.80      albertel  594:     my $function=&Apache::loncommon::get_users_function();
1.19      www       595:     my $domain=&Apache::loncommon::determinedomain();
                    596:     my %colortypes=('pgbg'  => 'Page Background',
                    597:                     'tabbg' => 'Header Background',
                    598:                     'sidebg'=> 'Header Border',
                    599:                     'font'  => 'Font',
                    600:                     'link'  => 'Un-Visited Link',
                    601:                     'vlink' => 'Visited Link',
                    602:                     'alink' => 'Active Link');
1.82      albertel  603:     my $start_data_table = &Apache::loncommon::start_data_table();
1.19      www       604:     my $chtable='';
1.22      matthew   605:     foreach my $item (sort(keys(%colortypes))) {
1.19      www       606:        my $curcol=&Apache::loncommon::designparm($function.'.'.$item,$domain);
1.82      albertel  607:        $chtable.=&Apache::loncommon::start_data_table_row().
1.83      albertel  608: 	   '<td>'.$colortypes{$item}.'</td><td style="background: '.$curcol.
1.19      www       609:         '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td><input name="'.$item.
1.21      www       610:         '" size="10" value="'.$curcol.
                    611: '" /></td><td><a href="javascript:pjump('."'color_custom','".$colortypes{$item}.
1.19      www       612: "','".$curcol."','"
1.82      albertel  613: 	    .$item."','parmform.pres','psub'".');">Select</a></td>'.
1.83      albertel  614: 	    &Apache::loncommon::end_data_table_row()."\n";
1.19      www       615:     }
1.82      albertel  616:     my $end_data_table = &Apache::loncommon::end_data_table();
1.23      matthew   617:     my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.19      www       618:     $r->print(<<ENDCOL);
1.82      albertel  619: <script type="text/javascript">
1.19      www       620: 
                    621:     function pclose() {
                    622:         parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
                    623:                  "height=350,width=350,scrollbars=no,menubar=no");
                    624:         parmwin.close();
                    625:     }
                    626: 
1.23      matthew   627:     $pjump_def
1.19      www       628: 
                    629:     function psub() {
                    630:         pclose();
                    631:         if (document.parmform.pres_marker.value!='') {
1.21      www       632:             if (document.parmform.pres_type.value!='') {
1.77      albertel  633:                 eval('document.prefs.'+
1.21      www       634:                      document.parmform.pres_marker.value+
1.19      www       635: 		     '.value=document.parmform.pres_value.value;');
1.21      www       636: 	    }
1.19      www       637:         } else {
                    638:             document.parmform.pres_value.value='';
                    639:             document.parmform.pres_marker.value='';
                    640:         }
                    641:     }
                    642: 
                    643: 
                    644: </script>
1.21      www       645: <form name="parmform">
                    646: <input type="hidden" name="pres_marker" />
                    647: <input type="hidden" name="pres_type" />
                    648: <input type="hidden" name="pres_value" />
                    649: </form>
1.88      albertel  650: <form name="prefs" action="/adm/preferences" method="post">
1.19      www       651: <input type="hidden" name="action" value="verify_and_change_colors" />
1.82      albertel  652: $start_data_table
1.19      www       653: $chtable
1.82      albertel  654: $end_data_table
1.19      www       655: </table>
1.21      www       656: <input type="submit" value="Change Custom Colors" />
                    657: <input type="submit" name="resetall" value="Reset All Colors to Default" />
1.12      www       658: </form>
1.19      www       659: ENDCOL
1.12      www       660: }
                    661: 
1.19      www       662: sub verify_and_change_colors {
1.12      www       663:     my $r = shift;
1.19      www       664: # figure out colors
1.80      albertel  665:     my $function=&Apache::loncommon::get_users_function();
1.19      www       666:     my $domain=&Apache::loncommon::determinedomain();
                    667:     my %colortypes=('pgbg'  => 'Page Background',
                    668:                     'tabbg' => 'Header Background',
                    669:                     'sidebg'=> 'Header Border',
                    670:                     'font'  => 'Font',
                    671:                     'link'  => 'Un-Visited Link',
                    672:                     'vlink' => 'Visited Link',
                    673:                     'alink' => 'Active Link');
                    674: 
1.12      www       675:     my $message='';
1.21      www       676:     foreach my $item (keys %colortypes) {
1.59      albertel  677:         my $color=$env{'form.'.$item};
1.21      www       678:         my $entry='color.'.$function.'.'.$item;
1.59      albertel  679: 	if (($color=~/^\#[0-9A-Fa-f]{6}$/) && (!$env{'form.resetall'})) {
1.21      www       680: 	    &Apache::lonnet::put('environment',{$entry => $color});
                    681: 	    &Apache::lonnet::appenv('environment.'.$entry => $color);
                    682: 	    $message.='Set '.$colortypes{$item}.' to '.$color.'<br />';
                    683: 	} else {
                    684: 	    &Apache::lonnet::del('environment',[$entry]);
                    685: 	    &Apache::lonnet::delenv('environment\.'.$entry);
                    686: 	    $message.='Reset '.$colortypes{$item}.'<br />';
                    687: 	}
                    688:     }
1.84      albertel  689:     my $now = time;
                    690:     &Apache::lonnet::put('environment',{'color.timestamp' => $now});
                    691:     &Apache::lonnet::appenv('environment.color.timestamp' => $now);
                    692: 
1.19      www       693:     $r->print(<<ENDVCCOL);
1.12      www       694: $message
1.88      albertel  695: <form name="client" action="/adm/preferences" method="post">
1.21      www       696: <input type="hidden" name="action" value="changecolors" />
                    697: </form>
1.19      www       698: ENDVCCOL
1.12      www       699: }
                    700: 
1.4       matthew   701: ######################################################
                    702: #            password handler subroutines            #
                    703: ######################################################
1.3       matthew   704: sub passwordchanger {
1.4       matthew   705:     # This function is a bit of a mess....
1.3       matthew   706:     # Passwords are encrypted using londes.js (DES encryption)
                    707:     my $r = shift;
1.4       matthew   708:     my $errormessage = shift;
                    709:     $errormessage = ($errormessage || '');
1.59      albertel  710:     my $user       = $env{'user.name'};
                    711:     my $domain     = $env{'user.domain'};
                    712:     my $homeserver = $env{'user.home'};
1.3       matthew   713:     my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
                    714:     # Check for authentication types that allow changing of the password.
                    715:     return if ($currentauth !~ /^(unix|internal):/);
                    716:     #
                    717:     # Generate keys
                    718:     my ($lkey_cpass ,$ukey_cpass ) = &des_keys();
                    719:     my ($lkey_npass1,$ukey_npass1) = &des_keys();
                    720:     my ($lkey_npass2,$ukey_npass2) = &des_keys();
1.4       matthew   721:     # Store the keys in the log files
1.3       matthew   722:     my $lonhost = $r->dir_config('lonHostID');
                    723:     my $logtoken=Apache::lonnet::reply('tmpput:'
                    724: 				       .$ukey_cpass  . $lkey_cpass .'&'
                    725: 				       .$ukey_npass1 . $lkey_npass1.'&'
                    726: 				       .$ukey_npass2 . $lkey_npass2,
                    727: 				       $lonhost);
1.4       matthew   728:     # Hexify the keys for output as javascript variables
1.3       matthew   729:     $ukey_cpass = hex($ukey_cpass);
                    730:     $lkey_cpass = hex($lkey_cpass);
                    731:     $ukey_npass1= hex($ukey_npass1);
                    732:     $lkey_npass1= hex($lkey_npass1);
                    733:     $ukey_npass2= hex($ukey_npass2);
                    734:     $lkey_npass2= hex($lkey_npass2);
                    735:     # Output javascript to deal with passwords
1.4       matthew   736:     # Output DES javascript
1.3       matthew   737:     {
                    738: 	my $include = $r->dir_config('lonIncludes');
                    739: 	my $jsh=Apache::File->new($include."/londes.js");
                    740: 	$r->print(<$jsh>);
                    741:     }
                    742:     $r->print(<<ENDFORM);
                    743: <script language="JavaScript">
                    744: 
                    745:     function send() {
                    746:         uextkey=this.document.client.elements.ukey_cpass.value;
                    747:         lextkey=this.document.client.elements.lkey_cpass.value;
                    748:         initkeys();
                    749: 
1.52      raeburn   750:         this.document.pserver.elements.currentpass.value
1.3       matthew   751:             =crypted(this.document.client.elements.currentpass.value);
                    752: 
                    753:         uextkey=this.document.client.elements.ukey_npass1.value;
                    754:         lextkey=this.document.client.elements.lkey_npass1.value;
                    755:         initkeys();
1.52      raeburn   756:         this.document.pserver.elements.newpass_1.value
1.3       matthew   757:             =crypted(this.document.client.elements.newpass_1.value);
                    758: 
                    759:         uextkey=this.document.client.elements.ukey_npass2.value;
                    760:         lextkey=this.document.client.elements.lkey_npass2.value;
                    761:         initkeys();
1.52      raeburn   762:         this.document.pserver.elements.newpass_2.value
1.3       matthew   763:             =crypted(this.document.client.elements.newpass_2.value);
                    764: 
1.52      raeburn   765:         this.document.pserver.submit();
1.3       matthew   766:     }
                    767: 
                    768: </script>
1.4       matthew   769: $errormessage
1.10      www       770: 
1.3       matthew   771: <p>
1.36      www       772: <!-- We separate the forms into 'server' and 'client' in order to
1.3       matthew   773:      ensure that unencrypted passwords will not be sent out by a
                    774:      crappy browser -->
                    775: 
1.88      albertel  776: <form name="pserver" action="/adm/preferences" method="post">
1.3       matthew   777: <input type="hidden" name="logtoken"    value="$logtoken" />
                    778: <input type="hidden" name="action"      value="verify_and_change_pass" />
                    779: <input type="hidden" name="currentpass" value="" />
1.4       matthew   780: <input type="hidden" name="newpass_1"   value="" />
                    781: <input type="hidden" name="newpass_2"   value="" />
1.3       matthew   782: </form>
                    783: 
                    784: <form name="client" >
                    785: <table>
1.4       matthew   786: <tr><td align="right"> Current password:                      </td>
                    787:     <td><input type="password" name="currentpass" size="10"/> </td></tr>
                    788: <tr><td align="right"> New password:                          </td>
                    789:     <td><input type="password" name="newpass_1" size="10"  /> </td></tr>
                    790: <tr><td align="right"> Confirm password:                      </td>
                    791:     <td><input type="password" name="newpass_2" size="10"  /> </td></tr>
1.3       matthew   792: <tr><td colspan="2" align="center">
                    793:     <input type="button" value="Change Password" onClick="send();">
                    794: </table>
1.4       matthew   795: <input type="hidden" name="ukey_cpass"  value="$ukey_cpass" />
                    796: <input type="hidden" name="lkey_cpass"  value="$lkey_cpass" />
1.3       matthew   797: <input type="hidden" name="ukey_npass1" value="$ukey_npass1" />
                    798: <input type="hidden" name="lkey_npass1" value="$lkey_npass1" />
                    799: <input type="hidden" name="ukey_npass2" value="$ukey_npass2" />
                    800: <input type="hidden" name="lkey_npass2" value="$lkey_npass2" />
                    801: </form>
                    802: </p>
                    803: ENDFORM
                    804:     #
                    805:     return;
                    806: }
                    807: 
                    808: sub verify_and_change_password {
                    809:     my $r = shift;
1.59      albertel  810:     my $user       = $env{'user.name'};
                    811:     my $domain     = $env{'user.domain'};
                    812:     my $homeserver = $env{'user.home'};
1.3       matthew   813:     my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
1.4       matthew   814:     # Check for authentication types that allow changing of the password.
                    815:     return if ($currentauth !~ /^(unix|internal):/);
1.3       matthew   816:     #
1.59      albertel  817:     my $currentpass = $env{'form.currentpass'}; 
                    818:     my $newpass1    = $env{'form.newpass_1'}; 
                    819:     my $newpass2    = $env{'form.newpass_2'};
                    820:     my $logtoken    = $env{'form.logtoken'};
1.3       matthew   821:     # Check for empty data 
1.4       matthew   822:     unless (defined($currentpass) && 
                    823: 	    defined($newpass1)    && 
                    824: 	    defined($newpass2)    ){
                    825: 	&passwordchanger($r,"<p>\n<font color='#ff0000'>ERROR</font>".
                    826: 			 "Password data was blank.\n</p>");
1.3       matthew   827: 	return;
                    828:     }
1.16      albertel  829:     # Get the keys
                    830:     my $lonhost = $r->dir_config('lonHostID');
1.3       matthew   831:     my $tmpinfo = Apache::lonnet::reply('tmpget:'.$logtoken,$lonhost);
                    832:     if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost')) {
1.4       matthew   833:         # I do not a have a better idea about how to handle this
1.3       matthew   834: 	$r->print(<<ENDERROR);
                    835: <p>
                    836: <font color="#ff0000">ERROR:</font> Unable to retrieve stored token for
1.4       matthew   837: password decryption.  Please log out and try again.
1.3       matthew   838: </p>
                    839: ENDERROR
1.4       matthew   840:         # Probably should log an error here
1.75      albertel  841:         return 1;
1.3       matthew   842:     }
                    843:     my ($ckey,$n1key,$n2key)=split(/&/,$tmpinfo);
1.4       matthew   844:     # 
1.17      matthew   845:     $currentpass = &des_decrypt($ckey ,$currentpass);
                    846:     $newpass1    = &des_decrypt($n1key,$newpass1);
                    847:     $newpass2    = &des_decrypt($n2key,$newpass2);
1.4       matthew   848:     # 
1.3       matthew   849:     if ($newpass1 ne $newpass2) {
1.4       matthew   850: 	&passwordchanger($r,
                    851: 			 '<font color="#ff0000">ERROR:</font>'.
                    852: 			 'The new passwords you entered do not match.  '.
                    853: 			 'Please try again.');
1.75      albertel  854: 	return 1;
1.4       matthew   855:     }
                    856:     if (length($newpass1) < 7) {
                    857: 	&passwordchanger($r,
                    858: 			 '<font color="#ff0000">ERROR:</font>'.
                    859: 			 'Passwords must be a minimum of 7 characters long.  '.
                    860: 			 'Please try again.');
1.75      albertel  861: 	return 1;
1.3       matthew   862:     }
1.4       matthew   863:     #
                    864:     # Check for bad characters
                    865:     my $badpassword = 0;
                    866:     foreach (split(//,$newpass1)) {
                    867: 	$badpassword = 1 if ((ord($_)<32)||(ord($_)>126));
                    868:     }
                    869:     if ($badpassword) {
                    870: 	# I can't figure out how to enter bad characters on my browser.
                    871: 	&passwordchanger($r,<<ENDERROR);
                    872: <font color="#ff0000">ERROR:</font>
                    873: The password you entered contained illegal characters.<br />
                    874: Valid characters are: space and <br />
                    875: <pre>
                    876: !&quot;\#$%&amp;\'()*+,-./0123456789:;&lt;=&gt;?\@
                    877: ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}~
                    878: </pre>
                    879: ENDERROR
                    880:     }
                    881:     # 
                    882:     # Change the password (finally)
                    883:     my $result = &Apache::lonnet::changepass
                    884: 	($user,$domain,$currentpass,$newpass1,$homeserver);
                    885:     # Inform the user the password has (not?) been changed
                    886:     if ($result =~ /^ok$/) {
                    887: 	$r->print(<<"ENDTEXT");
1.9       matthew   888: <h2>The password for $user was successfully changed</h2>
1.4       matthew   889: ENDTEXT
                    890:     } else {
                    891: 	# error error: run in circles, scream and shout
                    892:         $r->print(<<ENDERROR);
1.9       matthew   893: <h2><font color="#ff0000">The password for $user was not changed</font></h2>
1.8       matthew   894: Please make sure your old password was entered correctly.
1.4       matthew   895: ENDERROR
1.75      albertel  896:         return 1;
1.4       matthew   897:     }
                    898:     return;
1.3       matthew   899: }
                    900: 
1.42      raeburn   901: ################################################################
                    902: #            discussion display subroutines 
                    903: ################################################################
                    904: sub discussionchanger {
                    905:     my $r = shift;
1.59      albertel  906:     my $user       = $env{'user.name'};
                    907:     my $domain     = $env{'user.domain'};
1.42      raeburn   908:     my %userenv = &Apache::lonnet::get
1.43      raeburn   909:         ('environment',['discdisplay','discmarkread']);
                    910:     my $discdisp = 'allposts';
                    911:     my $discmark = 'onmark';
                    912: 
                    913:     if (defined($userenv{'discdisplay'})) {
                    914:         unless ($userenv{'discdisplay'} eq '') { 
                    915:             $discdisp = $userenv{'discdisplay'};
                    916:         }
                    917:     }
                    918:     if (defined($userenv{'discmarkread'})) {
                    919:         unless ($userenv{'discdisplay'} eq '') { 
                    920:             $discmark = $userenv{'discmarkread'};
                    921:         }
                    922:     }
                    923: 
                    924:     my $newdisp = 'unread';
                    925:     my $newmark = 'ondisp';
                    926: 
                    927:     my $function = &Apache::loncommon::get_users_function();
                    928:     my $color = &Apache::loncommon::designparm($function.'.tabbg',
1.59      albertel  929:                                                     $env{'user.domain'});
1.43      raeburn   930:     my %lt = &Apache::lonlocal::texthash(
                    931:         'pref' => 'Display Preference',
                    932:         'curr' => 'Current setting ',
                    933:         'actn' => 'Action',
                    934:         'sdpf' => 'Set display preferences for discussion posts for both bulletin boards and individual resources in all your courses.',
                    935:         'prca' => 'Preferences can be set that determine',
                    936:         'whpo' => 'Which posts are displayed when you display a bulletin board or resource, and',
                    937:         'unwh' => 'Under what circumstances posts are identfied as "New"',
                    938:         'allposts' => 'All posts',
                    939:         'unread' => 'New posts only',
                    940:         'ondisp' => 'Once displayed',
                    941:         'onmark' => 'Once marked as read',
                    942:         'disa' => 'Posts displayed?',
                    943:         'npmr' => 'New posts cease to be identified as "New"?',
                    944:         'thde'  => 'The preferences you set here can be overridden within each individual discussion.',
                    945:         'chgt' => 'Change to '
                    946:     );
                    947:     my $dispchange = $lt{'unread'};
                    948:     my $markchange = $lt{'ondisp'};
                    949:     my $currdisp = $lt{'allposts'};
                    950:     my $currmark = $lt{'onmark'};
                    951: 
                    952:     if ($discdisp eq 'unread') {
                    953:         $dispchange = $lt{'allposts'};
                    954:         $currdisp = $lt{'unread'};
                    955:         $newdisp = 'allposts';
                    956:     }
                    957: 
                    958:     if ($discmark eq 'ondisp') {
                    959:         $markchange = $lt{'onmark'};
                    960:         $currmark = $lt{'ondisp'};
                    961:         $newmark = 'onmark';
1.42      raeburn   962:     }
1.43      raeburn   963:     
                    964:     $r->print(<<"END");
1.88      albertel  965: <form name="prefs" action="/adm/preferences" method="post">
1.42      raeburn   966: <input type="hidden" name="action" value="verify_and_change_discussion" />
                    967: <br />
1.87      albertel  968: $lt{'sdpf'}<br /> $lt{'prca'}  <ol><li>$lt{'whpo'}</li><li>$lt{'unwh'}</li></ol> 
1.43      raeburn   969: <br />
                    970: <br />
1.82      albertel  971: END
                    972:     $r->print(&Apache::loncommon::start_data_table());
                    973:     $r->print(<<"END");
                    974:        <tr>
                    975:         <th>$lt{'pref'}</th>
                    976:         <th>$lt{'curr'}</th>
                    977:         <th>$lt{'actn'}?</th>
1.43      raeburn   978:        </tr>
1.82      albertel  979: END
                    980:     $r->print(&Apache::loncommon::start_data_table_row());
                    981:     $r->print(<<"END");
1.43      raeburn   982:        <td>$lt{'disa'}</td>
                    983:        <td>$lt{$discdisp}</td>
1.82      albertel  984:        <td><label><input type="checkbox" name="discdisp" /><input type="hidden" name="newdisp" value="$newdisp" />&nbsp;$lt{'chgt'} "$dispchange"</label></td>
                    985: END
                    986:     $r->print(&Apache::loncommon::end_data_table_row().
                    987: 	      &Apache::loncommon::start_data_table_row());
                    988:     $r->print(<<"END");
1.43      raeburn   989:        <td>$lt{'npmr'}</td>
                    990:        <td>$lt{$discmark}</td>
1.82      albertel  991:        <td><label><input type="checkbox" name="discmark" /><input type="hidden" name="newmark" value="$newmark" />&nbsp;$lt{'chgt'} "$markchange"</label></td>
1.43      raeburn   992:       </tr>
1.82      albertel  993: END
                    994:     $r->print(&Apache::loncommon::end_data_table_row().
                    995: 	      &Apache::loncommon::end_data_table());
                    996:     $r->print(<<"END");
1.43      raeburn   997: <br />
                    998: <br />
                    999: <input type="submit" name="sub" value="Store Changes" />
                   1000: <br />
                   1001: <br />
                   1002: Note: $lt{'thde'}
                   1003: </form>
                   1004: END
1.42      raeburn  1005: }
                   1006:                                                                                                                 
                   1007: sub verify_and_change_discussion {
                   1008:     my $r = shift;
1.59      albertel 1009:     my $user     = $env{'user.name'};
                   1010:     my $domain   = $env{'user.domain'};
1.42      raeburn  1011:     my $message='';
1.59      albertel 1012:     if (defined($env{'form.discdisp'}) ) {
                   1013:         my $newdisp  = $env{'form.newdisp'};
1.43      raeburn  1014:         if ($newdisp eq 'unread') {
1.87      albertel 1015:             $message .='In discussions: only new posts will be displayed.<br />';
1.43      raeburn  1016:             &Apache::lonnet::put('environment',{'discdisplay' => $newdisp});
                   1017:             &Apache::lonnet::appenv('environment.discdisplay' => $newdisp);
                   1018:         } else {
1.87      albertel 1019:             $message .= 'In discussions: all posts will be displayed.<br />';
1.43      raeburn  1020:             &Apache::lonnet::del('environment',['discdisplay']);
                   1021:             &Apache::lonnet::delenv('environment\.discdisplay');
                   1022:         }
                   1023:     }
1.59      albertel 1024:     if (defined($env{'form.discmark'}) ) {
                   1025:         my $newmark = $env{'form.newmark'};
1.43      raeburn  1026:         if ($newmark eq 'ondisp') {
1.87      albertel 1027:            $message.='In discussions: new posts will be cease to be identified as "new" after display.<br />';
1.43      raeburn  1028:             &Apache::lonnet::put('environment',{'discmarkread' => $newmark});
                   1029:             &Apache::lonnet::appenv('environment.discmarkread' => $newmark);
                   1030:         } else {
1.87      albertel 1031:             $message.='In discussions: posts will be identified as "new" until marked as read by the reader.<br />';
1.43      raeburn  1032:             &Apache::lonnet::del('environment',['discmarkread']);
                   1033:             &Apache::lonnet::delenv('environment\.discmarkread');
                   1034:         }
1.42      raeburn  1035:     }
                   1036:     $r->print(<<ENDVCSCREEN);
                   1037: $message
                   1038: ENDVCSCREEN
                   1039: }
                   1040: 
1.63      raeburn  1041: ################################################################
                   1042: # Subroutines for page display on course access (Course Coordinators)
                   1043: ################################################################
                   1044: sub coursedisplaychanger {
                   1045:     my $r = shift;
                   1046:     my $user       = $env{'user.name'};
                   1047:     my $domain     = $env{'user.domain'};
1.66      albertel 1048:     my %userenv = &Apache::lonnet::get('environment',['course_init_display']);
1.71      raeburn  1049:     my $currvalue = 'whatsnew';
1.73      albertel 1050:     my $firstselect = '';
                   1051:     my $whatsnewselect = 'checked="checked"';
1.71      raeburn  1052:     if (exists($userenv{'course_init_display'})) {
                   1053:         if ($userenv{'course_init_display'} eq 'firstres') {
                   1054:             $currvalue = 'firstres';
1.73      albertel 1055:             $firstselect = 'checked="checked"';
                   1056: 	    $whatsnewselect = '';
1.71      raeburn  1057:         }
1.63      raeburn  1058:     }
1.71      raeburn  1059:     my %pagenames = (
                   1060:                        firstres => 'First resource',
                   1061:                        whatsnew => "What's new page",
                   1062:                     );
1.70      raeburn  1063:     my $whatsnew_off=&mt('Display the [_1] in the course.','<b>first resource</b>');
                   1064:     my $whatsnew_on=&mt('Display the "[_1]" page - a summary of items in the course which require attention.',"<b>What's New</b>");
1.63      raeburn  1065: 
1.71      raeburn  1066:     $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 />');
1.63      raeburn  1067:     $r->print(<<ENDLSCREEN);
1.88      albertel 1068: <form name="prefs" action="/adm/preferences" method="post">
1.63      raeburn  1069: <input type="hidden" name="action" value="verify_and_change_coursepage" />
1.72      albertel 1070: <br />
1.65      albertel 1071: <label><input type="radio" name="newdisp" value="firstres" $firstselect /> $whatsnew_off</label><br />
1.70      raeburn  1072: <label><input type="radio" name="newdisp" value="whatsnew" $whatsnewselect /> $whatsnew_on</label><input type="hidden" name="refpage" value="$env{'form.refpage'}" />
1.63      raeburn  1073: ENDLSCREEN
1.70      raeburn  1074:     $r->print('<br /><br /><input type="submit" value="'.&mt('Change').'" />
1.63      raeburn  1075: </form>');
                   1076: }
                   1077: 
                   1078: sub verify_and_change_coursepage {
                   1079:     my $r = shift;
                   1080:     my $message='';
                   1081:     my %lt = &Apache::lonlocal::texthash(
1.70      raeburn  1082:         'defs' => 'Default now set',
1.71      raeburn  1083:         'when' => 'when you select a course role from the roles screen',
1.63      raeburn  1084:         'ywbt' => 'you will be taken to the start of the course.',
                   1085:         'apwb' => 'a page will be displayed that lists items in the course that may require action from you.',
                   1086:         'gtts' => 'Go to the start of the course',
1.70      raeburn  1087:         'dasp' => "Display the What's New page listing course action items", 
1.63      raeburn  1088:     );
                   1089:     my $newdisp  = $env{'form.newdisp'};
1.70      raeburn  1090:     $message = '<b>'.$lt{'defs'}.'</b>: '.$lt{'when'}.', ';
1.63      raeburn  1091:     if ($newdisp eq 'firstres') {
1.87      albertel 1092:         $message .= $lt{'ywbt'}.'<br />';
1.63      raeburn  1093:         &Apache::lonnet::put('environment',{'course_init_display' => $newdisp});
                   1094:         &Apache::lonnet::appenv('environment.course_init_display' => $newdisp);
                   1095:     } else {
1.87      albertel 1096:         $message .= $lt{'apwb'}.'<br />';
1.63      raeburn  1097:         &Apache::lonnet::del('environment',['course_init_display']);
                   1098:         &Apache::lonnet::delenv('environment\.course_init_display');
                   1099:     }
1.70      raeburn  1100:     my $refpage = $env{'form.refpage'};
1.63      raeburn  1101:     if (($env{'request.course.fn'}) && ($env{'request.course.id'})) {
                   1102:         if ($newdisp eq 'firstres') {
                   1103:             my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
                   1104:             my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; 
                   1105:             my ($furl,$ferr)=
                   1106:                 &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
                   1107:             $message .= '<br /><font size="+1"><a href="'.$furl.'">'.$lt{'gtts'}.' <i>'.&mt('now').'</i></a></font>';
                   1108:         } else {
1.70      raeburn  1109:             $message .= '<br /><font size="+1"><a href="/adm/whatsnew?refpage='.
                   1110:                         $refpage.'">'.$lt{'dasp'}.'</a></font>';
1.63      raeburn  1111:         }
                   1112:     }
                   1113:     $r->print(<<ENDVCSCREEN);
                   1114: $message
                   1115: <br /><br />
                   1116: ENDVCSCREEN
                   1117: }
                   1118: 
                   1119: 
1.4       matthew  1120: ######################################################
                   1121: #            other handler subroutines               #
                   1122: ######################################################
                   1123: 
1.3       matthew  1124: ################################################################
                   1125: #                          Main handler                        #
                   1126: ################################################################
1.1       www      1127: sub handler {
                   1128:     my $r = shift;
1.59      albertel 1129:     my $user = $env{'user.name'};
                   1130:     my $domain = $env{'user.domain'};
1.31      www      1131:     &Apache::loncommon::content_type($r,'text/html');
1.4       matthew  1132:     # Some pages contain DES keys and should not be cached.
                   1133:     &Apache::loncommon::no_cache($r);
1.1       www      1134:     $r->send_http_header;
                   1135:     return OK if $r->header_only;
1.9       matthew  1136:     #
1.35      matthew  1137:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.70      raeburn  1138:                                    ['action','wysiwyg','returnurl','refpage']);
1.35      matthew  1139:     #
                   1140:     &Apache::lonhtmlcommon::clear_breadcrumbs();
                   1141:     &Apache::lonhtmlcommon::add_breadcrumb
                   1142:         ({href => '/adm/preferences',
                   1143:           text => 'Set User Preferences'});
                   1144: 
                   1145:     my @Options;
                   1146:     # Determine current authentication method
                   1147:     my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
                   1148:     if ($currentauth =~ /^(unix|internal):/) {
                   1149:         push (@Options,({ action   => 'changepass',
1.40      www      1150:                           linktext => 'Change Password',
1.35      matthew  1151:                           href     => '/adm/preferences',
                   1152:                           help     => 'Change_Password',
                   1153:                           subroutine => \&passwordchanger,
                   1154:                           breadcrumb => 
                   1155:                               { href => '/adm/preferences?action=changepass',
                   1156:                                 text => 'Change Password'},
                   1157:                           },
                   1158:                         { action => 'verify_and_change_pass',
                   1159:                           subroutine => \&verify_and_change_password,
                   1160:                           breadcrumb => 
                   1161:                               { href =>'/adm/preferences?action=changepass',
                   1162:                                 text => 'Change Password'},
1.75      albertel 1163:                           printmenu => 'not_on_error',
1.35      matthew  1164:                           }));
                   1165:     }
                   1166:     push (@Options,({ action   => 'changescreenname',
                   1167:                       linktext => 'Change Screen Name',
                   1168:                       href     => '/adm/preferences',
                   1169:                       help     => 'Prefs_Screen_Name_Nickname',
                   1170:                       subroutine => \&screennamechanger,
                   1171:                       breadcrumb => 
                   1172:                           { href => '/adm/preferences?action=changescreenname',
                   1173:                             text => 'Change Screen Name'},
                   1174:                       },
                   1175:                     { action   => 'verify_and_change_screenname',
                   1176:                       subroutine => \&verify_and_change_screenname,
                   1177:                       breadcrumb => 
                   1178:                           { href => '/adm/preferences?action=changescreenname',
                   1179:                             text => 'Change Screen Name'},
                   1180:                       printmenu => 'yes',
                   1181:                       }));
                   1182: 
                   1183:     push (@Options,({ action   => 'changemsgforward',
1.49      albertel 1184:                       linktext => 'Change Message Forwarding and Notification Addresses',
1.35      matthew  1185:                       href     => '/adm/preferences',
                   1186:                       help     => 'Prefs_Forwarding',
                   1187:                       breadcrumb => 
                   1188:                           { href => '/adm/preferences?action=changemsgforward',
                   1189:                             text => 'Change Message Forwarding'},
                   1190:                       subroutine => \&msgforwardchanger,
                   1191:                       },
                   1192:                     { action => 'verify_and_change_msgforward',
                   1193:                       breadcrumb => 
                   1194:                           { href => '/adm/preferences?action=changemsgforward',
                   1195:                             text => 'Change Message Forwarding'},
                   1196:                       printmenu => 'yes',
                   1197:                       subroutine => \&verify_and_change_msgforward }));
                   1198:     my $aboutmeaction=
1.59      albertel 1199:         '/adm/'.$env{'user.domain'}.'/'.$env{'user.name'}.'/aboutme';
1.35      matthew  1200:     push (@Options,{ action => 'none', 
                   1201:                      linktext =>
1.41      www      1202:                          q{Edit the 'About Me' Personal Information Screen},
1.45      www      1203: 		     help => 'Prefs_About_Me',
1.35      matthew  1204:                      href => $aboutmeaction});
                   1205:     push (@Options,({ action => 'changecolors',
                   1206:                       linktext => 'Change Color Scheme',
                   1207:                       href => '/adm/preferences',
                   1208:                       help => 'Change_Colors',
                   1209:                       breadcrumb => 
                   1210:                           { href => '/adm/preferences?action=changecolors',
                   1211:                             text => 'Change Colors'},
                   1212:                       subroutine => \&colorschanger,
                   1213:                   },
                   1214:                     { action => 'verify_and_change_colors',
                   1215:                       breadcrumb => 
                   1216:                           { href => '/adm/preferences?action=changecolors',
                   1217:                             text => 'Change Colors'},
                   1218:                       printmenu => 'yes',
                   1219:                       subroutine => \&verify_and_change_colors,
                   1220:                       }));
                   1221:     push (@Options,({ action => 'changelanguages',
1.39      www      1222:                       linktext => 'Change Language Preferences',
1.35      matthew  1223:                       href => '/adm/preferences',
1.45      www      1224: 		      help => 'Prefs_Language',
1.35      matthew  1225:                       breadcrumb=>
                   1226:                           { href => '/adm/preferences?action=changelanguages',
                   1227:                             text => 'Change Language'},
                   1228:                       subroutine =>  \&languagechanger,
                   1229:                   },
                   1230:                     { action => 'verify_and_change_languages',
                   1231:                       breadcrumb=>
                   1232:                           {href => '/adm/preferences?action=changelanguages',
                   1233:                            text => 'Change Language'},
                   1234:                       printmenu => 'yes',
                   1235:                       subroutine=>\&verify_and_change_languages, }
                   1236:                     ));
1.44      www      1237:     push (@Options,({ action => 'changewysiwyg',
                   1238:                       linktext => 'Change WYSIWYG Editor Preferences',
                   1239:                       href => '/adm/preferences',
                   1240:                       breadcrumb => 
                   1241:                             { href => '/adm/preferences?action=changewysiwyg',
                   1242:                               text => 'Change WYSIWYG Preferences'},
                   1243:                       subroutine => \&wysiwygchanger,
                   1244:                   },
                   1245:                     { action => 'set_wysiwyg',
                   1246:                       breadcrumb =>
                   1247:                           { href => '/adm/preferences?action=changewysiwyg',
                   1248:                             text => 'Change WYSIWYG Preferences'},
                   1249:                       printmenu => 'yes',
                   1250:                       subroutine => \&verify_and_change_wysiwyg, }
                   1251:                     ));
1.42      raeburn  1252:     push (@Options,({ action => 'changediscussions',
                   1253:                       linktext => 'Change Discussion Display Preferences',
                   1254:                       href => '/adm/preferences',
1.46      raeburn  1255:                       help => 'Change_Discussion_Display',
1.42      raeburn  1256:                       breadcrumb => 
                   1257:                             { href => '/adm/preferences?action=changediscussions',
1.43      raeburn  1258:                               text => 'Change Discussion Preferences'},
1.42      raeburn  1259:                       subroutine => \&discussionchanger,
                   1260:                   },
                   1261:                     { action => 'verify_and_change_discussion',
                   1262:                       breadcrumb =>
                   1263:                           { href => '/adm/preferences?action=changediscussions',
1.43      raeburn  1264:                             text => 'Change Discussion Preferences'},
1.42      raeburn  1265:                       printmenu => 'yes',
                   1266:                       subroutine => \&verify_and_change_discussion, }
                   1267:                     ));
                   1268:                        
1.50      albertel 1269:     push (@Options,({ action   => 'changerolespref',
                   1270:                       linktext => 'Change Roles Page Preferences',
                   1271:                       href     => '/adm/preferences',
                   1272:                       subroutine => \&rolesprefchanger,
                   1273:                       breadcrumb =>
                   1274:                           { href => '/adm/preferences?action=changerolespref',
                   1275:                             text => 'Change Roles Pref'},
                   1276:                       },
                   1277:                     { action   => 'verify_and_change_rolespref',
                   1278:                       subroutine => \&verify_and_change_rolespref,
                   1279:                       breadcrumb =>
                   1280:                           { href => '/adm/preferences?action=changerolespref',
                   1281:                             text => 'Change Roles Preferences'},
                   1282:                       printmenu => 'yes',
                   1283:                       }));
                   1284: 
1.54      albertel 1285:     push (@Options,({ action   => 'changetexenginepref',
                   1286:                       linktext => 'Change How Math Equations Are Displayed',
                   1287:                       href     => '/adm/preferences',
                   1288:                       subroutine => \&texenginechanger,
                   1289:                       breadcrumb =>
                   1290:                           { href => '/adm/preferences?action=changetexenginepref',
                   1291:                             text => 'Change Math Pref'},
                   1292:                       },
                   1293:                     { action   => 'verify_and_change_texengine',
                   1294:                       subroutine => \&verify_and_change_texengine,
                   1295:                       breadcrumb =>
                   1296:                           { href => '/adm/preferences?action=changetexenginepref',
                   1297:                             text => 'Change Math Preferences'},
                   1298:                       printmenu => 'yes',
                   1299:                       }));
1.85      albertel 1300: 
                   1301:     if ($env{'environment.remote'} eq 'off') {
                   1302: 	push (@Options,({ action => 'launch',
                   1303: 			  linktext => 'Launch Remote Control',
                   1304: 			  href => '/adm/remote?url=/adm/preferences',
                   1305: 		      }));
                   1306:     } else {
                   1307: 	push (@Options,({ action => 'collapse',
                   1308: 			  linktext => 'Collapse Remote Control',
                   1309: 			  href => '/adm/remote?url=/adm/preferences',
                   1310: 		      }));
                   1311:     }
                   1312: 
1.74      albertel 1313:     if (&Apache::lonnet::allowed('whn',$env{'request.course.id'})
                   1314: 	|| &Apache::lonnet::allowed('whn',$env{'request.course.id'}.'/'
                   1315: 				    .$env{'request.course.sec'})) {
1.63      raeburn  1316:         push (@Options,({ action => 'changecourseinit',
                   1317:                           linktext => 'Change Course Initialization Preference',
                   1318:                           href => '/adm/preferences',
                   1319:                           subroutine => \&coursedisplaychanger,
                   1320:                           breadcrumb =>
                   1321:                               { href => '/adm/preferences?action=changecourseinit',
                   1322:                                 text => 'Change Course Init. Pref.'},
                   1323:                           },
                   1324:                         { action => 'verify_and_change_coursepage',
                   1325:                           breadcrumb =>
                   1326:                           { href => '/adm/preferences?action=changecourseinit',                               text => 'Change Course Initialization Preference'},
                   1327:                         printmenu => 'yes',
                   1328:                         subroutine => \&verify_and_change_coursepage,
                   1329:                        }));
                   1330:     }
1.50      albertel 1331: 
1.62      raeburn  1332:     if ($env{'user.name'} =~ /^(albertel|fox|foxr|koretemey|korte|hallmat3|turtle|raeburn)$/) {
1.35      matthew  1333:         push (@Options,({ action => 'debugtoggle',
                   1334:                           printmenu => 'yes',
                   1335:                           subroutine => \&toggle_debug,
                   1336:                           }));
                   1337:     }
1.76      albertel 1338: 
                   1339:     $r->print(&Apache::loncommon::start_page('Change Preferences'));
                   1340: 
1.35      matthew  1341:     my $call = undef;
1.48      albertel 1342:     my $help = undef;
1.35      matthew  1343:     my $printmenu = 'yes';
                   1344:     foreach my $option (@Options) {
1.59      albertel 1345:         if ($option->{'action'} eq $env{'form.action'}) {
1.35      matthew  1346:             $call = $option->{'subroutine'};
                   1347:             $printmenu = $option->{'printmenu'};
                   1348:             if (exists($option->{'breadcrumb'})) {
                   1349:                 &Apache::lonhtmlcommon::add_breadcrumb
                   1350:                     ($option->{'breadcrumb'});
                   1351:             }
1.48      albertel 1352: 	    $help=$option->{'help'};
1.35      matthew  1353:         }
                   1354:     }
1.81      albertel 1355:     $r->print(&Apache::lonhtmlcommon::breadcrumbs('Change Preferences',$help));
1.75      albertel 1356:     my $error;
1.35      matthew  1357:     if (defined($call)) {
1.75      albertel 1358:         $error = $call->($r);
1.35      matthew  1359:     }
1.75      albertel 1360:     if ( ( ($printmenu eq 'yes')
                   1361: 	   || ($printmenu eq 'not_on_error' && !$error) )
                   1362: 	 && (!$env{'form.returnurl'})) {
1.35      matthew  1363:         my $optionlist = '<table cellpadding="5">';
1.59      albertel 1364:         if ($env{'user.name'} =~ 
1.62      raeburn  1365:                          /^(albertel|kortemey|fox|foxr|korte|hallmat3|turtle|raeburn)$/
1.35      matthew  1366:             ) {
                   1367:             push (@Options,({ action => 'debugtoggle',
                   1368:                               linktext => 'Toggle Debug Messages',
                   1369:                               text => 'Current Debug status is -'.
1.59      albertel 1370:                                   $env{'user.debug'}.'-.',
1.35      matthew  1371:                               href => '/adm/preferences',
                   1372:                               printmenu => 'yes',
                   1373:                               subroutine => \&toggle_debug,
                   1374:                               }));
                   1375:         }
                   1376:         foreach my $option(@Options) {
                   1377:             my $optiontext = '';
                   1378:             if (exists($option->{'href'})) {
1.85      albertel 1379: 		$option->{'href_args'}{'action'}=$option->{'action'};
                   1380: 		$optiontext .= 
                   1381:                     '<a href="'.&add_get_param($option->{'href'},
                   1382: 					       $option->{'href_args'}).'">'.
1.47      albertel 1383:                     &mt($option->{'linktext'}).'</a>';
1.35      matthew  1384:             }
                   1385:             if (exists($option->{'text'})) {
1.47      albertel 1386:                 $optiontext .= ' '.&mt($option->{'text'});
1.35      matthew  1387:             }
                   1388:             if ($optiontext ne '') {
                   1389:                 $optiontext = '<font size="+1">'.$optiontext.'</font>'; 
                   1390:                 my $helplink = '&nbsp;';
                   1391:                 if (exists($option->{'help'})) {
                   1392:                     $helplink = &Apache::loncommon::help_open_topic
                   1393:                                                     ($option->{'help'});
                   1394:                 }
                   1395:                 $optionlist .= '<tr>'.
                   1396:                     '<td>'.$helplink.'</td>'.
                   1397:                     '<td>'.$optiontext.'</td>'.
                   1398:                     '</tr>';
                   1399:             }
1.13      www      1400:         }
1.35      matthew  1401:         $optionlist .= '</table>';
                   1402:         $r->print($optionlist);
1.59      albertel 1403:     } elsif ($env{'form.returnurl'}) {
                   1404: 	$r->print('<br /><a href="'.$env{'form.returnurl'}.'"><font size="+1">'.
1.44      www      1405: 		  &mt('Return').'</font></a>');
1.3       matthew  1406:     }
1.76      albertel 1407:     $r->print(&Apache::loncommon::end_page());
1.1       www      1408:     return OK;
1.35      matthew  1409: }
                   1410: 
                   1411: sub toggle_debug {
1.59      albertel 1412:     if ($env{'user.debug'}) {
1.35      matthew  1413:         &Apache::lonnet::delenv('user\.debug');
                   1414:     } else {
                   1415:         &Apache::lonnet::appenv('user.debug' => 1);
                   1416:     }
1.13      www      1417: }
1.1       www      1418: 
                   1419: 1;
                   1420: __END__

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