Annotation of loncom/interface/lonpreferences.pm, revision 1.19
1.1 www 1: # The LearningOnline Network
2: # Preferences
3: #
1.19 ! www 4: # $Id: lonpreferences.pm,v 1.18 2003/04/01 22:21:45 www 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.1 www 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: #
1.3 matthew 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:
1.1 www 45: package Apache::lonpreferences;
46:
47: use strict;
48: use Apache::Constants qw(:common);
1.3 matthew 49: use Apache::File;
50: use Crypt::DES;
51: use DynaLoader; # for Crypt::DES version
1.4 matthew 52: use Apache::loncommon();
1.3 matthew 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 {
1.4 matthew 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.
1.3 matthew 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))));
1.4 matthew 94: $plaintext=substr($plaintext,1,ord(substr($plaintext,0,1)) );
1.3 matthew 95: return $plaintext;
96: }
97:
1.4 matthew 98: ################################################################
99: # Handler subroutines #
100: ################################################################
1.9 matthew 101:
102: ################################################################
103: # Anonymous Discussion Name Change Subroutines #
104: ################################################################
1.5 www 105: sub screennamechanger {
106: my $r = shift;
107: my $user = $ENV{'user.name'};
108: my $domain = $ENV{'user.domain'};
1.14 www 109: my %userenv = &Apache::lonnet::get
110: ('environment',['screenname','nickname']);
1.6 www 111: my $screenname=$userenv{'screenname'};
1.14 www 112: my $nickname=$userenv{'nickname'};
1.10 www 113: my $bodytag=&Apache::loncommon::bodytag(
1.14 www 114: 'Change Your Nickname and Anonymous Screen Name');
1.5 www 115: $r->print(<<ENDSCREEN);
116: <html>
1.10 www 117: $bodytag
118:
1.6 www 119: <form name="server" action="/adm/preferences" method="post">
120: <input type="hidden" name="action" value="verify_and_change_screenname" />
1.14 www 121: <br />New screenname (shown if you post anonymously):
1.6 www 122: <input type="text" size="20" value="$screenname" name="screenname" />
1.14 www 123: <br />New nickname (shown if you post non-anonymously):
124: <input type="text" size="20" value="$nickname" name="nickname" />
1.6 www 125: <input type="submit" value="Change" />
126: </form>
1.5 www 127: </body>
128: </html>
129: ENDSCREEN
130: }
1.6 www 131:
132: sub verify_and_change_screenname {
133: my $r = shift;
134: my $user = $ENV{'user.name'};
135: my $domain = $ENV{'user.domain'};
1.14 www 136: # Screenname
1.6 www 137: my $newscreen = $ENV{'form.screenname'};
1.14 www 138: $newscreen=~s/[^ \w]//g;
1.6 www 139: my $message='';
140: if ($newscreen) {
1.7 www 141: &Apache::lonnet::put('environment',{'screenname' => $newscreen});
142: &Apache::lonnet::appenv('environment.screenname' => $newscreen);
1.6 www 143: $message='Set new screenname to '.$newscreen;
144: } else {
145: &Apache::lonnet::del('environment',['screenname']);
1.7 www 146: &Apache::lonnet::delenv('environment\.screenname');
1.6 www 147: $message='Reset screenname';
148: }
1.14 www 149: # Nickname
150: $message.='<br />';
1.17 matthew 151: $newscreen = $ENV{'form.nickname'};
1.14 www 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:
1.10 www 163: my $bodytag=&Apache::loncommon::bodytag(
1.14 www 164: 'Change Your Nickname and Anonymous Screen Name');
1.6 www 165: $r->print(<<ENDVCSCREEN);
166: <html>
1.10 www 167: $bodytag
1.6 www 168: </p>
169: $message
170: </body></html>
171: ENDVCSCREEN
172: }
173:
1.12 www 174: ################################################################
1.19 ! www 175: # Colors #
1.12 www 176: ################################################################
177:
1.19 ! www 178: sub colorschanger {
1.12 www 179: my $r = shift;
180: my $bodytag=&Apache::loncommon::bodytag(
1.19 ! www 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: '"> </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);
1.12 www 213: <html>
1.19 ! www 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>
1.12 www 256: $bodytag
257:
258: <form name="server" action="/adm/preferences" method="post">
1.19 ! www 259: <input type="hidden" name="action" value="verify_and_change_colors" />
! 260: <table border="2">
! 261: $chtable
! 262: </table>
1.12 www 263: <input type="submit" value="Change" />
264: </form>
265: </body>
266: </html>
1.19 ! www 267: ENDCOL
1.12 www 268: }
269:
1.19 ! www 270: sub verify_and_change_colors {
1.12 www 271: my $r = shift;
1.19 ! www 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:
1.12 www 293: my $message='';
1.19 ! www 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:
1.12 www 306: my $bodytag=&Apache::loncommon::bodytag(
1.19 ! www 307: 'Change Color Scheme for Current Role Type');
! 308: $r->print(<<ENDVCCOL);
1.12 www 309: <html>
310: $bodytag
311: </p>
312: $message
313: </body></html>
1.19 ! www 314: ENDVCCOL
1.12 www 315: }
316:
1.4 matthew 317: ######################################################
318: # password handler subroutines #
319: ######################################################
1.3 matthew 320: sub passwordchanger {
1.4 matthew 321: # This function is a bit of a mess....
1.3 matthew 322: # Passwords are encrypted using londes.js (DES encryption)
323: my $r = shift;
1.4 matthew 324: my $errormessage = shift;
325: $errormessage = ($errormessage || '');
1.3 matthew 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();
1.4 matthew 337: # Store the keys in the log files
1.3 matthew 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);
1.4 matthew 344: # Hexify the keys for output as javascript variables
1.3 matthew 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
1.4 matthew 352: # Output DES javascript
1.9 matthew 353: $r->print("<html><head>");
1.3 matthew 354: {
355: my $include = $r->dir_config('lonIncludes');
356: my $jsh=Apache::File->new($include."/londes.js");
357: $r->print(<$jsh>);
358: }
1.10 www 359: my $bodytag=&Apache::loncommon::bodytag('Change Password','',
360: 'onLoad="init();"');
1.3 matthew 361: $r->print(<<ENDFORM);
1.9 matthew 362: </head>
1.10 www 363: $bodytag
1.1 www 364:
1.3 matthew 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>
1.4 matthew 391: $errormessage
1.10 www 392:
1.3 matthew 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="" />
1.4 matthew 402: <input type="hidden" name="newpass_1" value="" />
403: <input type="hidden" name="newpass_2" value="" />
1.3 matthew 404: </form>
405:
406: <form name="client" >
407: <table>
1.4 matthew 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>
1.3 matthew 414: <tr><td colspan="2" align="center">
415: <input type="button" value="Change Password" onClick="send();">
416: </table>
1.4 matthew 417: <input type="hidden" name="ukey_cpass" value="$ukey_cpass" />
418: <input type="hidden" name="lkey_cpass" value="$lkey_cpass" />
1.3 matthew 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);
1.4 matthew 436: # Check for authentication types that allow changing of the password.
437: return if ($currentauth !~ /^(unix|internal):/);
1.3 matthew 438: #
1.4 matthew 439: $r->print(<<ENDHEADER);
440: <html>
441: <head>
442: <title>LON-CAPA Preferences: Change password for $user</title>
443: </head>
444: ENDHEADER
1.3 matthew 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
1.4 matthew 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>");
1.3 matthew 456: return;
457: }
1.16 albertel 458: # Get the keys
459: my $lonhost = $r->dir_config('lonHostID');
1.3 matthew 460: my $tmpinfo = Apache::lonnet::reply('tmpget:'.$logtoken,$lonhost);
461: if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost')) {
1.4 matthew 462: # I do not a have a better idea about how to handle this
1.3 matthew 463: $r->print(<<ENDERROR);
464: <p>
465: <font color="#ff0000">ERROR:</font> Unable to retrieve stored token for
1.4 matthew 466: password decryption. Please log out and try again.
1.3 matthew 467: </p>
468: ENDERROR
1.4 matthew 469: # Probably should log an error here
1.3 matthew 470: return;
471: }
472: my ($ckey,$n1key,$n2key)=split(/&/,$tmpinfo);
1.4 matthew 473: #
1.17 matthew 474: $currentpass = &des_decrypt($ckey ,$currentpass);
475: $newpass1 = &des_decrypt($n1key,$newpass1);
476: $newpass2 = &des_decrypt($n2key,$newpass2);
1.4 matthew 477: #
1.3 matthew 478: if ($newpass1 ne $newpass2) {
1.4 matthew 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.');
1.3 matthew 490: return;
491: }
1.4 matthew 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: !"\#$%&\'()*+,-./0123456789:;<=>?\@
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");
1.9 matthew 517: <h2>The password for $user was successfully changed</h2>
1.4 matthew 518: ENDTEXT
519: } else {
520: # error error: run in circles, scream and shout
521: $r->print(<<ENDERROR);
1.9 matthew 522: <h2><font color="#ff0000">The password for $user was not changed</font></h2>
1.8 matthew 523: Please make sure your old password was entered correctly.
1.4 matthew 524: ENDERROR
525: }
526: return;
1.3 matthew 527: }
528:
1.4 matthew 529: ######################################################
530: # other handler subroutines #
531: ######################################################
532:
1.3 matthew 533: ################################################################
534: # Main handler #
535: ################################################################
1.1 www 536: sub handler {
537: my $r = shift;
1.3 matthew 538: my $user = $ENV{'user.name'};
539: my $domain = $ENV{'user.domain'};
1.1 www 540: $r->content_type('text/html');
1.4 matthew 541: # Some pages contain DES keys and should not be cached.
542: &Apache::loncommon::no_cache($r);
1.1 www 543: $r->send_http_header;
544: return OK if $r->header_only;
1.9 matthew 545: #
1.3 matthew 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);
1.5 www 550: } elsif ($ENV{'form.action'} eq 'changescreenname') {
551: &screennamechanger($r);
1.6 www 552: } elsif ($ENV{'form.action'} eq 'verify_and_change_screenname') {
553: &verify_and_change_screenname($r);
1.12 www 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);
1.19 ! www 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);
1.15 albertel 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: }
1.3 matthew 570: } else {
571: $r->print(<<ENDHEADER);
1.1 www 572: <html>
573: <head>
1.4 matthew 574: <title>LON-CAPA Preferences</title>
1.1 www 575: </head>
1.3 matthew 576: ENDHEADER
1.10 www 577: $r->print(&Apache::loncommon::bodytag('Change Your Preferences'));
1.3 matthew 578: # Determine current authentication method
579: my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
580: if ($currentauth =~ /^(unix|internal):/) {
1.4 matthew 581: $r->print(<<ENDPASSWORDFORM);
582: <form name="client" action="/adm/preferences" method="post">
1.14 www 583: <input type="hidden" name="action" value="changepass" />
584: <input type="submit" value="Change password" />
1.4 matthew 585: </form>
586: ENDPASSWORDFORM
1.13 www 587: }
1.5 www 588: # Change screen name
589: $r->print(<<ENDSCREENNAMEFORM);
590: <form name="client" action="/adm/preferences" method="post">
1.14 www 591: <input type="hidden" name="action" value="changescreenname" />
592: <input type="submit"
593: value="Change nickname and anonymous discussion screen name" />
1.5 www 594: </form>
595: ENDSCREENNAMEFORM
1.12 www 596: $r->print(<<ENDMSGFORWARDFORM);
597: <form name="client" action="/adm/preferences" method="post">
1.14 www 598: <input type="hidden" name="action" value="changemsgforward" />
1.18 www 599: <input type="submit" value="Change message forwarding and notification addresses" />
1.12 www 600: </form>
601: ENDMSGFORWARDFORM
1.11 www 602: # The "about me" page
1.15 albertel 603: my $aboutmeaction=
604: '/adm/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/aboutme';
605: $r->print(<<ENDABOUTME);
1.11 www 606: <form name="client" action="$aboutmeaction" method="post">
1.14 www 607: <input type="hidden" name="action" value="changescreenname" />
1.19 ! www 608: <input type="submit" value="Edit the 'About Me' personal information screen" />
1.11 www 609: </form>
610: ENDABOUTME
1.19 ! www 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:
1.15 albertel 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
1.3 matthew 628: }
629: $r->print(<<ENDFOOTER);
1.1 www 630: </body>
631: </html>
1.3 matthew 632: ENDFOOTER
1.1 www 633: return OK;
1.13 www 634: }
1.1 www 635:
636: 1;
637: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>