File:  [LON-CAPA] / loncom / interface / lonpreferences.pm
Revision 1.19: download - view: text, annotated - select for diffs
Sat Apr 19 01:34:22 2003 UTC (21 years, 1 month ago) by www
Branches: MAIN
CVS tags: HEAD
Change color scheme - not working yet.

    1: # The LearningOnline Network
    2: # Preferences
    3: #
    4: # $Id: lonpreferences.pm,v 1.19 2003/04/19 01:34:22 www Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: # (Internal Server Error Handler
   29: #
   30: # (Login Screen
   31: # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
   32: # 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer)
   33: #
   34: # 3/1/1 Gerd Kortemeyer)
   35: #
   36: # 3/1 Gerd Kortemeyer
   37: #
   38: # 2/13/02 2/14 2/15 Matthew Hall
   39: #
   40: # This package uses the "londes.js" javascript code. 
   41: #
   42: # TODOs that have to be completed:
   43: #    interface with lonnet to change the password
   44:  
   45: package Apache::lonpreferences;
   46: 
   47: use strict;
   48: use Apache::Constants qw(:common);
   49: use Apache::File;
   50: use Crypt::DES;
   51: use DynaLoader; # for Crypt::DES version
   52: use Apache::loncommon();
   53: 
   54: #
   55: # Write lonnet::passwd to do the call below.
   56: # Use:
   57: #   my $answer=reply("encrypt:passwd:$udom:$uname:$upass",$tryserver);
   58: #
   59: ##################################################
   60: #          password associated functions         #
   61: ##################################################
   62: sub des_keys {
   63:     # Make a new key for DES encryption.
   64:     # Each key has two parts which are returned seperately.
   65:     # Please note:  Each key must be passed through the &hex function
   66:     # before it is output to the web browser.  The hex versions cannot
   67:     # be used to decrypt.
   68:     my @hexstr=('0','1','2','3','4','5','6','7',
   69:                 '8','9','a','b','c','d','e','f');
   70:     my $lkey='';
   71:     for (0..7) {
   72:         $lkey.=$hexstr[rand(15)];
   73:     }
   74:     my $ukey='';
   75:     for (0..7) {
   76:         $ukey.=$hexstr[rand(15)];
   77:     }
   78:     return ($lkey,$ukey);
   79: }
   80: 
   81: sub des_decrypt {
   82:     my ($key,$cyphertext) = @_;
   83:     my $keybin=pack("H16",$key);
   84:     my $cypher;
   85:     if ($Crypt::DES::VERSION>=2.03) {
   86:         $cypher=new Crypt::DES $keybin;
   87:     } else {
   88:         $cypher=new DES $keybin;
   89:     }
   90:     my $plaintext=
   91: 	$cypher->decrypt(unpack("a8",pack("H16",substr($cyphertext,0,16))));
   92:     $plaintext.=
   93: 	$cypher->decrypt(unpack("a8",pack("H16",substr($cyphertext,16,16))));
   94:     $plaintext=substr($plaintext,1,ord(substr($plaintext,0,1)) );
   95:     return $plaintext;
   96: }
   97: 
   98: ################################################################
   99: #                       Handler subroutines                    #
  100: ################################################################
  101: 
  102: ################################################################
  103: #         Anonymous Discussion Name Change Subroutines         #
  104: ################################################################
  105: sub screennamechanger {
  106:     my $r = shift;
  107:     my $user       = $ENV{'user.name'};
  108:     my $domain     = $ENV{'user.domain'};
  109:     my %userenv = &Apache::lonnet::get
  110:         ('environment',['screenname','nickname']);
  111:     my $screenname=$userenv{'screenname'};
  112:     my $nickname=$userenv{'nickname'};
  113:     my $bodytag=&Apache::loncommon::bodytag(
  114:               'Change Your Nickname and Anonymous Screen Name');
  115:     $r->print(<<ENDSCREEN);
  116: <html>
  117: $bodytag
  118: 
  119: <form name="server" action="/adm/preferences" method="post">
  120: <input type="hidden" name="action" value="verify_and_change_screenname" />
  121: <br />New screenname (shown if you post anonymously):
  122: <input type="text" size="20" value="$screenname" name="screenname" />
  123: <br />New nickname (shown if you post non-anonymously):
  124: <input type="text" size="20" value="$nickname" name="nickname" />
  125: <input type="submit" value="Change" />
  126: </form>
  127: </body>
  128: </html>
  129: ENDSCREEN
  130: }
  131: 
  132: sub verify_and_change_screenname {
  133:     my $r = shift;
  134:     my $user       = $ENV{'user.name'};
  135:     my $domain     = $ENV{'user.domain'};
  136: # Screenname
  137:     my $newscreen  = $ENV{'form.screenname'};
  138:     $newscreen=~s/[^ \w]//g;
  139:     my $message='';
  140:     if ($newscreen) {
  141:         &Apache::lonnet::put('environment',{'screenname' => $newscreen});
  142:         &Apache::lonnet::appenv('environment.screenname' => $newscreen);
  143:         $message='Set new screenname to '.$newscreen;
  144:     } else {
  145:         &Apache::lonnet::del('environment',['screenname']);
  146:         &Apache::lonnet::delenv('environment\.screenname');
  147:         $message='Reset screenname';
  148:     }
  149: # Nickname
  150:     $message.='<br />';
  151:     $newscreen  = $ENV{'form.nickname'};
  152:     $newscreen=~s/[^ \w]//g;
  153:     if ($newscreen) {
  154:         &Apache::lonnet::put('environment',{'nickname' => $newscreen});
  155:         &Apache::lonnet::appenv('environment.nickname' => $newscreen);
  156:         $message.='Set new nickname to '.$newscreen;
  157:     } else {
  158:         &Apache::lonnet::del('environment',['nickname']);
  159:         &Apache::lonnet::delenv('environment\.nickname');
  160:         $message.='Reset nickname';
  161:     }
  162: 
  163:     my $bodytag=&Apache::loncommon::bodytag(
  164:                     'Change Your Nickname and Anonymous Screen Name');
  165:     $r->print(<<ENDVCSCREEN);
  166: <html>
  167: $bodytag
  168: </p>
  169: $message
  170: </body></html>
  171: ENDVCSCREEN
  172: }
  173: 
  174: ################################################################
  175: #         Colors                                               #
  176: ################################################################
  177: 
  178: sub colorschanger {
  179:     my $r = shift;
  180:     my $bodytag=&Apache::loncommon::bodytag(
  181:                     'Change Color Scheme for Current Role Type');
  182: # figure out colors
  183:     my $function='student';
  184:     if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
  185: 	$function='coordinator';
  186:     }
  187:     if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
  188: 	$function='admin';
  189:     }
  190:     if (($ENV{'request.role'}=~/^(au|ca)/) ||
  191: 	($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) {
  192: 	$function='author';
  193:     }
  194:     my $domain=&Apache::loncommon::determinedomain();
  195:     my %colortypes=('pgbg'  => 'Page Background',
  196:                     'tabbg' => 'Header Background',
  197:                     'sidebg'=> 'Header Border',
  198:                     'font'  => 'Font',
  199:                     'link'  => 'Un-Visited Link',
  200:                     'vlink' => 'Visited Link',
  201:                     'alink' => 'Active Link');
  202:     my $chtable='';
  203:     foreach my $item (keys %colortypes) {
  204:        my $curcol=&Apache::loncommon::designparm($function.'.'.$item,$domain);
  205:        $chtable.='<tr><td>'.$colortypes{$item}.'</td><td bgcolor="'.$curcol.
  206:         '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td><input name="'.$item.
  207:         '" size="8" value="'.$curcol.
  208: '" /></td><td><a href="javascript:pjump('."'color','".$colortypes{$item}.
  209: "','".$curcol."','"
  210: 	    .$item."','".$item."','psub'".');">Select</a></td></tr>';
  211:     }
  212:     $r->print(<<ENDCOL);
  213: <html>
  214: <script>
  215: 
  216:     function pclose() {
  217:         parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
  218:                  "height=350,width=350,scrollbars=no,menubar=no");
  219:         parmwin.close();
  220:     }
  221: 
  222:     function pjump(type,dis,value,marker,ret,call) {
  223:         parmwin=window.open("/adm/rat/parameter.html?type="+escape(type)
  224:                  +"&value="+escape(value)+"&marker="+escape(marker)
  225:                  +"&return="+escape(ret)
  226:                  +"&call="+escape(call)+"&name="+escape(dis),"LONCAPAparms",
  227:                  "height=350,width=350,scrollbars=no,menubar=no");
  228: 
  229:     }
  230: 
  231:     function psub() {
  232:         pclose();
  233:         if (document.parmform.pres_marker.value!='') {
  234:             document.parmform.action+='#'+document.parmform.pres_marker.value;
  235:             var typedef=new Array();
  236:             typedef=document.parmform.pres_type.value.split('_');
  237:            if (document.parmform.pres_type.value!='') {
  238:             if (typedef[0]=='date') {
  239:                 eval('document.parmform.recent_'+
  240:                      document.parmform.pres_type.value+
  241: 		     '.value=document.parmform.pres_value.value;');
  242:             } else {
  243:                 eval('document.parmform.recent_'+typedef[0]+
  244: 		     '.value=document.parmform.pres_value.value;');
  245:             }
  246: 	   }
  247:             document.parmform.submit();
  248:         } else {
  249:             document.parmform.pres_value.value='';
  250:             document.parmform.pres_marker.value='';
  251:         }
  252:     }
  253: 
  254: 
  255: </script>
  256: $bodytag
  257: 
  258: <form name="server" action="/adm/preferences" method="post">
  259: <input type="hidden" name="action" value="verify_and_change_colors" />
  260: <table border="2">
  261: $chtable
  262: </table>
  263: <input type="submit" value="Change" />
  264: </form>
  265: </body>
  266: </html>
  267: ENDCOL
  268: }
  269: 
  270: sub verify_and_change_colors {
  271:     my $r = shift;
  272: # figure out colors
  273:     my $function='student';
  274:     if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
  275: 	$function='coordinator';
  276:     }
  277:     if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
  278: 	$function='admin';
  279:     }
  280:     if (($ENV{'request.role'}=~/^(au|ca)/) ||
  281: 	($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) {
  282: 	$function='author';
  283:     }
  284:     my $domain=&Apache::loncommon::determinedomain();
  285:     my %colortypes=('pgbg'  => 'Page Background',
  286:                     'tabbg' => 'Header Background',
  287:                     'sidebg'=> 'Header Border',
  288:                     'font'  => 'Font',
  289:                     'link'  => 'Un-Visited Link',
  290:                     'vlink' => 'Visited Link',
  291:                     'alink' => 'Active Link');
  292: 
  293:     my $message='';
  294: #    my $newscreen='';
  295: #    $newscreen=~s/\,$//;
  296: #    if ($newscreen) {
  297: #        &Apache::lonnet::put('environment',{'msgforward' => $newscreen});
  298: #        &Apache::lonnet::appenv('environment.msgforward' => $newscreen);
  299: #        $message.='Set new message forwarding to '.$newscreen.'<br />';
  300: #    } else {
  301: #        &Apache::lonnet::del('environment',['msgforward']);
  302: #        &Apache::lonnet::delenv('environment\.msgforward');
  303: #        $message.='Reset message forwarding<br />';
  304: #    }
  305: 
  306:     my $bodytag=&Apache::loncommon::bodytag(
  307:                            'Change Color Scheme for Current Role Type');
  308:     $r->print(<<ENDVCCOL);
  309: <html>
  310: $bodytag
  311: </p>
  312: $message
  313: </body></html>
  314: ENDVCCOL
  315: }
  316: 
  317: ######################################################
  318: #            password handler subroutines            #
  319: ######################################################
  320: sub passwordchanger {
  321:     # This function is a bit of a mess....
  322:     # Passwords are encrypted using londes.js (DES encryption)
  323:     my $r = shift;
  324:     my $errormessage = shift;
  325:     $errormessage = ($errormessage || '');
  326:     my $user       = $ENV{'user.name'};
  327:     my $domain     = $ENV{'user.domain'};
  328:     my $homeserver = $ENV{'user.home'};
  329:     my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
  330:     # Check for authentication types that allow changing of the password.
  331:     return if ($currentauth !~ /^(unix|internal):/);
  332:     #
  333:     # Generate keys
  334:     my ($lkey_cpass ,$ukey_cpass ) = &des_keys();
  335:     my ($lkey_npass1,$ukey_npass1) = &des_keys();
  336:     my ($lkey_npass2,$ukey_npass2) = &des_keys();
  337:     # Store the keys in the log files
  338:     my $lonhost = $r->dir_config('lonHostID');
  339:     my $logtoken=Apache::lonnet::reply('tmpput:'
  340: 				       .$ukey_cpass  . $lkey_cpass .'&'
  341: 				       .$ukey_npass1 . $lkey_npass1.'&'
  342: 				       .$ukey_npass2 . $lkey_npass2,
  343: 				       $lonhost);
  344:     # Hexify the keys for output as javascript variables
  345:     $ukey_cpass = hex($ukey_cpass);
  346:     $lkey_cpass = hex($lkey_cpass);
  347:     $ukey_npass1= hex($ukey_npass1);
  348:     $lkey_npass1= hex($lkey_npass1);
  349:     $ukey_npass2= hex($ukey_npass2);
  350:     $lkey_npass2= hex($lkey_npass2);
  351:     # Output javascript to deal with passwords
  352:     # Output DES javascript
  353:     $r->print("<html><head>");
  354:     {
  355: 	my $include = $r->dir_config('lonIncludes');
  356: 	my $jsh=Apache::File->new($include."/londes.js");
  357: 	$r->print(<$jsh>);
  358:     }
  359:     my $bodytag=&Apache::loncommon::bodytag('Change Password','',
  360:                                          'onLoad="init();"');
  361:     $r->print(<<ENDFORM);
  362: </head>
  363: $bodytag
  364: 
  365: <script language="JavaScript">
  366: 
  367:     function send() {
  368:         uextkey=this.document.client.elements.ukey_cpass.value;
  369:         lextkey=this.document.client.elements.lkey_cpass.value;
  370:         initkeys();
  371: 
  372:         this.document.server.elements.currentpass.value
  373:             =crypted(this.document.client.elements.currentpass.value);
  374: 
  375:         uextkey=this.document.client.elements.ukey_npass1.value;
  376:         lextkey=this.document.client.elements.lkey_npass1.value;
  377:         initkeys();
  378:         this.document.server.elements.newpass_1.value
  379:             =crypted(this.document.client.elements.newpass_1.value);
  380: 
  381:         uextkey=this.document.client.elements.ukey_npass2.value;
  382:         lextkey=this.document.client.elements.lkey_npass2.value;
  383:         initkeys();
  384:         this.document.server.elements.newpass_2.value
  385:             =crypted(this.document.client.elements.newpass_2.value);
  386: 
  387:         this.document.server.submit();
  388:     }
  389: 
  390: </script>
  391: $errormessage
  392: 
  393: <p>
  394: <!-- We seperate the forms into 'server' and 'client' in order to
  395:      ensure that unencrypted passwords will not be sent out by a
  396:      crappy browser -->
  397: 
  398: <form name="server" action="/adm/preferences" method="post">
  399: <input type="hidden" name="logtoken"    value="$logtoken" />
  400: <input type="hidden" name="action"      value="verify_and_change_pass" />
  401: <input type="hidden" name="currentpass" value="" />
  402: <input type="hidden" name="newpass_1"   value="" />
  403: <input type="hidden" name="newpass_2"   value="" />
  404: </form>
  405: 
  406: <form name="client" >
  407: <table>
  408: <tr><td align="right"> Current password:                      </td>
  409:     <td><input type="password" name="currentpass" size="10"/> </td></tr>
  410: <tr><td align="right"> New password:                          </td>
  411:     <td><input type="password" name="newpass_1" size="10"  /> </td></tr>
  412: <tr><td align="right"> Confirm password:                      </td>
  413:     <td><input type="password" name="newpass_2" size="10"  /> </td></tr>
  414: <tr><td colspan="2" align="center">
  415:     <input type="button" value="Change Password" onClick="send();">
  416: </table>
  417: <input type="hidden" name="ukey_cpass"  value="$ukey_cpass" />
  418: <input type="hidden" name="lkey_cpass"  value="$lkey_cpass" />
  419: <input type="hidden" name="ukey_npass1" value="$ukey_npass1" />
  420: <input type="hidden" name="lkey_npass1" value="$lkey_npass1" />
  421: <input type="hidden" name="ukey_npass2" value="$ukey_npass2" />
  422: <input type="hidden" name="lkey_npass2" value="$lkey_npass2" />
  423: </form>
  424: </p>
  425: ENDFORM
  426:     #
  427:     return;
  428: }
  429: 
  430: sub verify_and_change_password {
  431:     my $r = shift;
  432:     my $user       = $ENV{'user.name'};
  433:     my $domain     = $ENV{'user.domain'};
  434:     my $homeserver = $ENV{'user.home'};
  435:     my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
  436:     # Check for authentication types that allow changing of the password.
  437:     return if ($currentauth !~ /^(unix|internal):/);
  438:     #
  439:     $r->print(<<ENDHEADER);
  440: <html>
  441: <head>
  442: <title>LON-CAPA Preferences:  Change password for $user</title>
  443: </head>
  444: ENDHEADER
  445:     #
  446:     my $currentpass = $ENV{'form.currentpass'}; 
  447:     my $newpass1    = $ENV{'form.newpass_1'}; 
  448:     my $newpass2    = $ENV{'form.newpass_2'};
  449:     my $logtoken    = $ENV{'form.logtoken'};
  450:     # Check for empty data 
  451:     unless (defined($currentpass) && 
  452: 	    defined($newpass1)    && 
  453: 	    defined($newpass2)    ){
  454: 	&passwordchanger($r,"<p>\n<font color='#ff0000'>ERROR</font>".
  455: 			 "Password data was blank.\n</p>");
  456: 	return;
  457:     }
  458:     # Get the keys
  459:     my $lonhost = $r->dir_config('lonHostID');
  460:     my $tmpinfo = Apache::lonnet::reply('tmpget:'.$logtoken,$lonhost);
  461:     if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost')) {
  462:         # I do not a have a better idea about how to handle this
  463: 	$r->print(<<ENDERROR);
  464: <p>
  465: <font color="#ff0000">ERROR:</font> Unable to retrieve stored token for
  466: password decryption.  Please log out and try again.
  467: </p>
  468: ENDERROR
  469:         # Probably should log an error here
  470:         return;
  471:     }
  472:     my ($ckey,$n1key,$n2key)=split(/&/,$tmpinfo);
  473:     # 
  474:     $currentpass = &des_decrypt($ckey ,$currentpass);
  475:     $newpass1    = &des_decrypt($n1key,$newpass1);
  476:     $newpass2    = &des_decrypt($n2key,$newpass2);
  477:     # 
  478:     if ($newpass1 ne $newpass2) {
  479: 	&passwordchanger($r,
  480: 			 '<font color="#ff0000">ERROR:</font>'.
  481: 			 'The new passwords you entered do not match.  '.
  482: 			 'Please try again.');
  483: 	return;
  484:     }
  485:     if (length($newpass1) < 7) {
  486: 	&passwordchanger($r,
  487: 			 '<font color="#ff0000">ERROR:</font>'.
  488: 			 'Passwords must be a minimum of 7 characters long.  '.
  489: 			 'Please try again.');
  490: 	return;
  491:     }
  492:     #
  493:     # Check for bad characters
  494:     my $badpassword = 0;
  495:     foreach (split(//,$newpass1)) {
  496: 	$badpassword = 1 if ((ord($_)<32)||(ord($_)>126));
  497:     }
  498:     if ($badpassword) {
  499: 	# I can't figure out how to enter bad characters on my browser.
  500: 	&passwordchanger($r,<<ENDERROR);
  501: <font color="#ff0000">ERROR:</font>
  502: The password you entered contained illegal characters.<br />
  503: Valid characters are: space and <br />
  504: <pre>
  505: !&quot;\#$%&amp;\'()*+,-./0123456789:;&lt;=&gt;?\@
  506: ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}~
  507: </pre>
  508: ENDERROR
  509:     }
  510:     # 
  511:     # Change the password (finally)
  512:     my $result = &Apache::lonnet::changepass
  513: 	($user,$domain,$currentpass,$newpass1,$homeserver);
  514:     # Inform the user the password has (not?) been changed
  515:     if ($result =~ /^ok$/) {
  516: 	$r->print(<<"ENDTEXT");
  517: <h2>The password for $user was successfully changed</h2>
  518: ENDTEXT
  519:     } else {
  520: 	# error error: run in circles, scream and shout
  521:         $r->print(<<ENDERROR);
  522: <h2><font color="#ff0000">The password for $user was not changed</font></h2>
  523: Please make sure your old password was entered correctly.
  524: ENDERROR
  525:     }
  526:     return;
  527: }
  528: 
  529: ######################################################
  530: #            other handler subroutines               #
  531: ######################################################
  532: 
  533: ################################################################
  534: #                          Main handler                        #
  535: ################################################################
  536: sub handler {
  537:     my $r = shift;
  538:     my $user = $ENV{'user.name'};
  539:     my $domain = $ENV{'user.domain'};
  540:     $r->content_type('text/html');
  541:     # Some pages contain DES keys and should not be cached.
  542:     &Apache::loncommon::no_cache($r);
  543:     $r->send_http_header;
  544:     return OK if $r->header_only;
  545:     #
  546:     if ($ENV{'form.action'} eq 'changepass') {
  547: 	&passwordchanger($r);
  548:     } elsif ($ENV{'form.action'} eq 'verify_and_change_pass') {
  549: 	&verify_and_change_password($r);
  550:     } elsif ($ENV{'form.action'} eq 'changescreenname') {
  551:         &screennamechanger($r);
  552:     } elsif ($ENV{'form.action'} eq 'verify_and_change_screenname') {
  553:         &verify_and_change_screenname($r);
  554:     } elsif ($ENV{'form.action'} eq 'changemsgforward') {
  555:         &msgforwardchanger($r);
  556:     } elsif ($ENV{'form.action'} eq 'verify_and_change_msgforward') {
  557:         &verify_and_change_msgforward($r);
  558:     } elsif ($ENV{'form.action'} eq 'changecolors') {
  559:         &colorschanger($r);
  560:     } elsif ($ENV{'form.action'} eq 'verify_and_change_colors') {
  561:         &verify_and_change_colors($r);
  562:     } elsif ($ENV{'form.action'} eq 'debugtoggle') {
  563: 	if ($ENV{'user.name'} eq 'albertel' ) {
  564: 	    if ($ENV{'user.debug'}) {
  565: 		&Apache::lonnet::delenv('user\.debug');
  566: 	    } else {
  567: 		&Apache::lonnet::appenv('user.debug' => 1);
  568: 	    }
  569: 	}
  570:     } else {
  571: 	$r->print(<<ENDHEADER);
  572: <html>
  573: <head>
  574: <title>LON-CAPA Preferences</title>
  575: </head>
  576: ENDHEADER
  577:         $r->print(&Apache::loncommon::bodytag('Change Your Preferences'));
  578: 	# Determine current authentication method
  579: 	my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
  580: 	if ($currentauth =~ /^(unix|internal):/) {
  581: 	    $r->print(<<ENDPASSWORDFORM);
  582: <form name="client" action="/adm/preferences" method="post">
  583: <input type="hidden" name="action" value="changepass" />
  584: <input type="submit" value="Change password" />
  585: </form>
  586: ENDPASSWORDFORM
  587:         }
  588: # Change screen name
  589: 	    $r->print(<<ENDSCREENNAMEFORM);
  590: <form name="client" action="/adm/preferences" method="post">
  591: <input type="hidden" name="action" value="changescreenname" />
  592: <input type="submit" 
  593: value="Change nickname and anonymous discussion screen name" />
  594: </form>
  595: ENDSCREENNAMEFORM
  596: 	    $r->print(<<ENDMSGFORWARDFORM);
  597: <form name="client" action="/adm/preferences" method="post">
  598: <input type="hidden" name="action" value="changemsgforward" />
  599: <input type="submit" value="Change message forwarding and notification addresses" />
  600: </form>
  601: ENDMSGFORWARDFORM
  602: # The "about me" page
  603: 	my $aboutmeaction=
  604: 	    '/adm/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/aboutme';
  605: 	$r->print(<<ENDABOUTME);
  606: <form name="client" action="$aboutmeaction" method="post">
  607: <input type="hidden" name="action" value="changescreenname" />
  608: <input type="submit" value="Edit the 'About Me' personal information screen" />
  609: </form>
  610: ENDABOUTME
  611: 	    $r->print(<<ENDCOLORFORM);
  612: <form name="client" action="/adm/preferences" method="post">
  613: <input type="hidden" name="action" value="changecolors" />
  614: <input type="submit" value="Change color scheme" />
  615: </form>
  616: ENDCOLORFORM
  617: 
  618: 	if ($ENV{'user.name'} eq 'albertel') {
  619: 	    $r->print(<<ENDDEBUG);
  620: <form name="client" action="/adm/preferences" method="post">
  621: <input type="hidden" name="action" value="debugtoggle" />
  622: <input type="submit" value="Toggle Debug" />
  623: Current Debug status is -$ENV{'user.debug'}-.
  624: </form>
  625: ENDDEBUG
  626: 	}
  627: 	# Other preference setting code should be added here
  628:     }
  629:     $r->print(<<ENDFOOTER);
  630: </body>
  631: </html>
  632: ENDFOOTER
  633:     return OK;
  634: }
  635: 
  636: 1;
  637: __END__

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