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

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

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