1: # The LearningOnline Network
2: # Preferences
3: #
4: # $Id: lonpreferences.pm,v 1.25 2003/06/20 19:22:14 bowersj2 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: use Apache::lonhtmlcommon();
54:
55: #
56: # Write lonnet::passwd to do the call below.
57: # Use:
58: # my $answer=reply("encrypt:passwd:$udom:$uname:$upass",$tryserver);
59: #
60: ##################################################
61: # password associated functions #
62: ##################################################
63: sub des_keys {
64: # Make a new key for DES encryption.
65: # Each key has two parts which are returned seperately.
66: # Please note: Each key must be passed through the &hex function
67: # before it is output to the web browser. The hex versions cannot
68: # be used to decrypt.
69: my @hexstr=('0','1','2','3','4','5','6','7',
70: '8','9','a','b','c','d','e','f');
71: my $lkey='';
72: for (0..7) {
73: $lkey.=$hexstr[rand(15)];
74: }
75: my $ukey='';
76: for (0..7) {
77: $ukey.=$hexstr[rand(15)];
78: }
79: return ($lkey,$ukey);
80: }
81:
82: sub des_decrypt {
83: my ($key,$cyphertext) = @_;
84: my $keybin=pack("H16",$key);
85: my $cypher;
86: if ($Crypt::DES::VERSION>=2.03) {
87: $cypher=new Crypt::DES $keybin;
88: } else {
89: $cypher=new DES $keybin;
90: }
91: my $plaintext=
92: $cypher->decrypt(unpack("a8",pack("H16",substr($cyphertext,0,16))));
93: $plaintext.=
94: $cypher->decrypt(unpack("a8",pack("H16",substr($cyphertext,16,16))));
95: $plaintext=substr($plaintext,1,ord(substr($plaintext,0,1)) );
96: return $plaintext;
97: }
98:
99: ################################################################
100: # Handler subroutines #
101: ################################################################
102:
103: ################################################################
104: # Anonymous Discussion Name Change Subroutines #
105: ################################################################
106: sub screennamechanger {
107: my $r = shift;
108: my $user = $ENV{'user.name'};
109: my $domain = $ENV{'user.domain'};
110: my %userenv = &Apache::lonnet::get
111: ('environment',['screenname','nickname']);
112: my $screenname=$userenv{'screenname'};
113: my $nickname=$userenv{'nickname'};
114: my $bodytag=&Apache::loncommon::bodytag(
115: 'Change Your Nickname and Anonymous Screen Name');
116: $r->print(<<ENDSCREEN);
117: <html>
118: $bodytag
119:
120: <form name="server" action="/adm/preferences" method="post">
121: <input type="hidden" name="action" value="verify_and_change_screenname" />
122: <br />New screenname (shown if you post anonymously):
123: <input type="text" size="20" value="$screenname" name="screenname" />
124: <br />New nickname (shown if you post non-anonymously):
125: <input type="text" size="20" value="$nickname" name="nickname" />
126: <input type="submit" value="Change" />
127: </form>
128: </body>
129: </html>
130: ENDSCREEN
131: }
132:
133: sub verify_and_change_screenname {
134: my $r = shift;
135: my $user = $ENV{'user.name'};
136: my $domain = $ENV{'user.domain'};
137: # Screenname
138: my $newscreen = $ENV{'form.screenname'};
139: $newscreen=~s/[^ \w]//g;
140: my $message='';
141: if ($newscreen) {
142: &Apache::lonnet::put('environment',{'screenname' => $newscreen});
143: &Apache::lonnet::appenv('environment.screenname' => $newscreen);
144: $message='Set new screenname to '.$newscreen;
145: } else {
146: &Apache::lonnet::del('environment',['screenname']);
147: &Apache::lonnet::delenv('environment\.screenname');
148: $message='Reset screenname';
149: }
150: # Nickname
151: $message.='<br />';
152: $newscreen = $ENV{'form.nickname'};
153: $newscreen=~s/[^ \w]//g;
154: if ($newscreen) {
155: &Apache::lonnet::put('environment',{'nickname' => $newscreen});
156: &Apache::lonnet::appenv('environment.nickname' => $newscreen);
157: $message.='Set new nickname to '.$newscreen;
158: } else {
159: &Apache::lonnet::del('environment',['nickname']);
160: &Apache::lonnet::delenv('environment\.nickname');
161: $message.='Reset nickname';
162: }
163:
164: my $bodytag=&Apache::loncommon::bodytag(
165: 'Change Your Nickname and Anonymous Screen Name');
166: $r->print(<<ENDVCSCREEN);
167: <html>
168: $bodytag
169: </p>
170: $message
171: </body></html>
172: ENDVCSCREEN
173: }
174:
175: ################################################################
176: # Message Forward #
177: ################################################################
178:
179: sub msgforwardchanger {
180: my $r = shift;
181: my $user = $ENV{'user.name'};
182: my $domain = $ENV{'user.domain'};
183: my %userenv = &Apache::lonnet::get('environment',['msgforward']);
184: my $msgforward=$userenv{'msgforward'};
185: my $notification=$userenv{'notification'};
186: my $critnotification=$userenv{'critnotification'};
187: my $bodytag=&Apache::loncommon::bodytag(
188: 'Change Your Message Forwarding and Notification');
189: my $forwardingHelp = Apache::loncommon::help_open_topic("Prefs_Forwarding",
190: "What are forwarding ".
191: "and notification ".
192: "addresses");
193: $r->print(<<ENDMSG);
194: <html>
195: $bodytag
196: $forwardingHelp <br />
197: <form name="server" action="/adm/preferences" method="post">
198: <input type="hidden" name="action" value="verify_and_change_msgforward" />
199: New Forwarding Address(es) (<tt>user:domain,user:domain,...</tt>):
200: <input type="text" size="40" value="$msgforward" name="msgforward" /><hr />
201: New Message Notification Email Address(es) (<tt>joe\@doe.com,jane\@doe.edu,...</tt>):
202: <input type="text" size="40" value="$notification" name="notification" /><hr />
203: New Critical Message Notification Email Address(es) (<tt>joe\@doe.com,jane\@doe.edu,...</tt>):
204: <input type="text" size="40" value="$critnotification" name="critnotification" /><hr />
205: <input type="submit" value="Change" />
206: </form>
207: </body>
208: </html>
209: ENDMSG
210: }
211:
212: sub verify_and_change_msgforward {
213: my $r = shift;
214: my $user = $ENV{'user.name'};
215: my $domain = $ENV{'user.domain'};
216: my $newscreen = '';
217: my $message='';
218: foreach (split(/\,/,$ENV{'form.msgforward'})) {
219: my ($msuser,$msdomain)=split(/[\@\:]/,$_);
220: $msuser=~s/\W//g;
221: $msdomain=~s/\W//g;
222: if (($msuser) && ($msdomain)) {
223: if (&Apache::lonnet::homeserver($msuser,$msdomain) ne 'no_host') {
224: $newscreen.=$msuser.':'.$msdomain.',';
225: } else {
226: $message.='No such user: '.$msuser.':'.$msdomain.'<br>';
227: }
228: }
229: }
230: $newscreen=~s/\,$//;
231: if ($newscreen) {
232: &Apache::lonnet::put('environment',{'msgforward' => $newscreen});
233: &Apache::lonnet::appenv('environment.msgforward' => $newscreen);
234: $message.='Set new message forwarding to '.$newscreen.'<br />';
235: } else {
236: &Apache::lonnet::del('environment',['msgforward']);
237: &Apache::lonnet::delenv('environment\.msgforward');
238: $message.='Reset message forwarding<br />';
239: }
240: my $notification=$ENV{'form.notification'};
241: $notification=~s/\s//gs;
242: if ($notification) {
243: &Apache::lonnet::put('environment',{'notification' => $notification});
244: &Apache::lonnet::appenv('environment.notification' => $notification);
245: $message.='Set message notification address to '.$notification.'<br />';
246: } else {
247: &Apache::lonnet::del('environment',['notification']);
248: &Apache::lonnet::delenv('environment\.notification');
249: $message.='Reset message notification<br />';
250: }
251: my $critnotification=$ENV{'form.critnotification'};
252: $critnotification=~s/\s//gs;
253: if ($critnotification) {
254: &Apache::lonnet::put('environment',{'critnotification' => $critnotification});
255: &Apache::lonnet::appenv('environment.critnotification' => $critnotification);
256: $message.='Set critical message notification address to '.$critnotification;
257: } else {
258: &Apache::lonnet::del('environment',['critnotification']);
259: &Apache::lonnet::delenv('environment\.critnotification');
260: $message.='Reset critical message notification<br />';
261: }
262: my $bodytag=&Apache::loncommon::bodytag(
263: 'Change Your Message Forwarding and Notifications');
264: $r->print(<<ENDVCMSG);
265: <html>
266: $bodytag
267: </p>
268: $message
269: </body></html>
270: ENDVCMSG
271: }
272:
273: ################################################################
274: # Colors #
275: ################################################################
276:
277: sub colorschanger {
278: my $r = shift;
279: my $bodytag=&Apache::loncommon::bodytag(
280: 'Change Color Scheme for Current Role Type','',
281: 'onUnload="pclose();"');
282: # figure out colors
283: my $function='student';
284: if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
285: $function='coordinator';
286: }
287: if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
288: $function='admin';
289: }
290: if (($ENV{'request.role'}=~/^(au|ca)/) ||
291: ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) {
292: $function='author';
293: }
294: my $domain=&Apache::loncommon::determinedomain();
295: my %colortypes=('pgbg' => 'Page Background',
296: 'tabbg' => 'Header Background',
297: 'sidebg'=> 'Header Border',
298: 'font' => 'Font',
299: 'link' => 'Un-Visited Link',
300: 'vlink' => 'Visited Link',
301: 'alink' => 'Active Link');
302: my $chtable='';
303: foreach my $item (sort(keys(%colortypes))) {
304: my $curcol=&Apache::loncommon::designparm($function.'.'.$item,$domain);
305: $chtable.='<tr><td>'.$colortypes{$item}.'</td><td bgcolor="'.$curcol.
306: '"> </td><td><input name="'.$item.
307: '" size="10" value="'.$curcol.
308: '" /></td><td><a href="javascript:pjump('."'color_custom','".$colortypes{$item}.
309: "','".$curcol."','"
310: .$item."','parmform.pres','psub'".');">Select</a></td></tr>';
311: }
312: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
313: $r->print(<<ENDCOL);
314: <html>
315: <script>
316:
317: function pclose() {
318: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
319: "height=350,width=350,scrollbars=no,menubar=no");
320: parmwin.close();
321: }
322:
323: $pjump_def
324:
325: function psub() {
326: pclose();
327: if (document.parmform.pres_marker.value!='') {
328: if (document.parmform.pres_type.value!='') {
329: eval('document.server.'+
330: document.parmform.pres_marker.value+
331: '.value=document.parmform.pres_value.value;');
332: }
333: } else {
334: document.parmform.pres_value.value='';
335: document.parmform.pres_marker.value='';
336: }
337: }
338:
339:
340: </script>
341: $bodytag
342: <form name="parmform">
343: <input type="hidden" name="pres_marker" />
344: <input type="hidden" name="pres_type" />
345: <input type="hidden" name="pres_value" />
346: </form>
347: <form name="server" action="/adm/preferences" method="post">
348: <input type="hidden" name="action" value="verify_and_change_colors" />
349: <table border="2">
350: $chtable
351: </table>
352: <input type="submit" value="Change Custom Colors" />
353: <input type="submit" name="resetall" value="Reset All Colors to Default" />
354: </form>
355: </body>
356: </html>
357: ENDCOL
358: }
359:
360: sub verify_and_change_colors {
361: my $r = shift;
362: # figure out colors
363: my $function='student';
364: if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
365: $function='coordinator';
366: }
367: if ($ENV{'request.role'}=~/^(su|dc|ad|li)/) {
368: $function='admin';
369: }
370: if (($ENV{'request.role'}=~/^(au|ca)/) ||
371: ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) {
372: $function='author';
373: }
374: my $domain=&Apache::loncommon::determinedomain();
375: my %colortypes=('pgbg' => 'Page Background',
376: 'tabbg' => 'Header Background',
377: 'sidebg'=> 'Header Border',
378: 'font' => 'Font',
379: 'link' => 'Un-Visited Link',
380: 'vlink' => 'Visited Link',
381: 'alink' => 'Active Link');
382:
383: my $message='';
384: foreach my $item (keys %colortypes) {
385: my $color=$ENV{'form.'.$item};
386: my $entry='color.'.$function.'.'.$item;
387: if (($color=~/^\#[0-9A-Fa-f]{6}$/) && (!$ENV{'form.resetall'})) {
388: &Apache::lonnet::put('environment',{$entry => $color});
389: &Apache::lonnet::appenv('environment.'.$entry => $color);
390: $message.='Set '.$colortypes{$item}.' to '.$color.'<br />';
391: } else {
392: &Apache::lonnet::del('environment',[$entry]);
393: &Apache::lonnet::delenv('environment\.'.$entry);
394: $message.='Reset '.$colortypes{$item}.'<br />';
395: }
396: }
397: my $bodytag=&Apache::loncommon::bodytag(
398: 'Change Color Scheme for Current Role Type');
399: $r->print(<<ENDVCCOL);
400: <html>
401: $bodytag
402: </p>
403: $message
404: <form name="client" action="/adm/preferences" method="post">
405: <input type="hidden" name="action" value="changecolors" />
406: <input type="submit" value="Revise color scheme again" />
407: </form>
408: </body></html>
409: ENDVCCOL
410: }
411:
412: ######################################################
413: # password handler subroutines #
414: ######################################################
415: sub passwordchanger {
416: # This function is a bit of a mess....
417: # Passwords are encrypted using londes.js (DES encryption)
418: my $r = shift;
419: my $errormessage = shift;
420: $errormessage = ($errormessage || '');
421: my $user = $ENV{'user.name'};
422: my $domain = $ENV{'user.domain'};
423: my $homeserver = $ENV{'user.home'};
424: my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
425: # Check for authentication types that allow changing of the password.
426: return if ($currentauth !~ /^(unix|internal):/);
427: #
428: # Generate keys
429: my ($lkey_cpass ,$ukey_cpass ) = &des_keys();
430: my ($lkey_npass1,$ukey_npass1) = &des_keys();
431: my ($lkey_npass2,$ukey_npass2) = &des_keys();
432: # Store the keys in the log files
433: my $lonhost = $r->dir_config('lonHostID');
434: my $logtoken=Apache::lonnet::reply('tmpput:'
435: .$ukey_cpass . $lkey_cpass .'&'
436: .$ukey_npass1 . $lkey_npass1.'&'
437: .$ukey_npass2 . $lkey_npass2,
438: $lonhost);
439: # Hexify the keys for output as javascript variables
440: $ukey_cpass = hex($ukey_cpass);
441: $lkey_cpass = hex($lkey_cpass);
442: $ukey_npass1= hex($ukey_npass1);
443: $lkey_npass1= hex($lkey_npass1);
444: $ukey_npass2= hex($ukey_npass2);
445: $lkey_npass2= hex($lkey_npass2);
446: # Output javascript to deal with passwords
447: # Output DES javascript
448: $r->print("<html><head>");
449: {
450: my $include = $r->dir_config('lonIncludes');
451: my $jsh=Apache::File->new($include."/londes.js");
452: $r->print(<$jsh>);
453: }
454: my $bodytag=&Apache::loncommon::bodytag('Change Password','',
455: 'onLoad="init();"');
456: $r->print(<<ENDFORM);
457: </head>
458: $bodytag
459:
460: <script language="JavaScript">
461:
462: function send() {
463: uextkey=this.document.client.elements.ukey_cpass.value;
464: lextkey=this.document.client.elements.lkey_cpass.value;
465: initkeys();
466:
467: this.document.server.elements.currentpass.value
468: =crypted(this.document.client.elements.currentpass.value);
469:
470: uextkey=this.document.client.elements.ukey_npass1.value;
471: lextkey=this.document.client.elements.lkey_npass1.value;
472: initkeys();
473: this.document.server.elements.newpass_1.value
474: =crypted(this.document.client.elements.newpass_1.value);
475:
476: uextkey=this.document.client.elements.ukey_npass2.value;
477: lextkey=this.document.client.elements.lkey_npass2.value;
478: initkeys();
479: this.document.server.elements.newpass_2.value
480: =crypted(this.document.client.elements.newpass_2.value);
481:
482: this.document.server.submit();
483: }
484:
485: </script>
486: $errormessage
487:
488: <p>
489: <!-- We seperate the forms into 'server' and 'client' in order to
490: ensure that unencrypted passwords will not be sent out by a
491: crappy browser -->
492:
493: <form name="server" action="/adm/preferences" method="post">
494: <input type="hidden" name="logtoken" value="$logtoken" />
495: <input type="hidden" name="action" value="verify_and_change_pass" />
496: <input type="hidden" name="currentpass" value="" />
497: <input type="hidden" name="newpass_1" value="" />
498: <input type="hidden" name="newpass_2" value="" />
499: </form>
500:
501: <form name="client" >
502: <table>
503: <tr><td align="right"> Current password: </td>
504: <td><input type="password" name="currentpass" size="10"/> </td></tr>
505: <tr><td align="right"> New password: </td>
506: <td><input type="password" name="newpass_1" size="10" /> </td></tr>
507: <tr><td align="right"> Confirm password: </td>
508: <td><input type="password" name="newpass_2" size="10" /> </td></tr>
509: <tr><td colspan="2" align="center">
510: <input type="button" value="Change Password" onClick="send();">
511: </table>
512: <input type="hidden" name="ukey_cpass" value="$ukey_cpass" />
513: <input type="hidden" name="lkey_cpass" value="$lkey_cpass" />
514: <input type="hidden" name="ukey_npass1" value="$ukey_npass1" />
515: <input type="hidden" name="lkey_npass1" value="$lkey_npass1" />
516: <input type="hidden" name="ukey_npass2" value="$ukey_npass2" />
517: <input type="hidden" name="lkey_npass2" value="$lkey_npass2" />
518: </form>
519: </p>
520: ENDFORM
521: #
522: return;
523: }
524:
525: sub verify_and_change_password {
526: my $r = shift;
527: my $user = $ENV{'user.name'};
528: my $domain = $ENV{'user.domain'};
529: my $homeserver = $ENV{'user.home'};
530: my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
531: # Check for authentication types that allow changing of the password.
532: return if ($currentauth !~ /^(unix|internal):/);
533: #
534: $r->print(<<ENDHEADER);
535: <html>
536: <head>
537: <title>LON-CAPA Preferences: Change password for $user</title>
538: </head>
539: ENDHEADER
540: #
541: my $currentpass = $ENV{'form.currentpass'};
542: my $newpass1 = $ENV{'form.newpass_1'};
543: my $newpass2 = $ENV{'form.newpass_2'};
544: my $logtoken = $ENV{'form.logtoken'};
545: # Check for empty data
546: unless (defined($currentpass) &&
547: defined($newpass1) &&
548: defined($newpass2) ){
549: &passwordchanger($r,"<p>\n<font color='#ff0000'>ERROR</font>".
550: "Password data was blank.\n</p>");
551: return;
552: }
553: # Get the keys
554: my $lonhost = $r->dir_config('lonHostID');
555: my $tmpinfo = Apache::lonnet::reply('tmpget:'.$logtoken,$lonhost);
556: if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost')) {
557: # I do not a have a better idea about how to handle this
558: $r->print(<<ENDERROR);
559: <p>
560: <font color="#ff0000">ERROR:</font> Unable to retrieve stored token for
561: password decryption. Please log out and try again.
562: </p>
563: ENDERROR
564: # Probably should log an error here
565: return;
566: }
567: my ($ckey,$n1key,$n2key)=split(/&/,$tmpinfo);
568: #
569: $currentpass = &des_decrypt($ckey ,$currentpass);
570: $newpass1 = &des_decrypt($n1key,$newpass1);
571: $newpass2 = &des_decrypt($n2key,$newpass2);
572: #
573: if ($newpass1 ne $newpass2) {
574: &passwordchanger($r,
575: '<font color="#ff0000">ERROR:</font>'.
576: 'The new passwords you entered do not match. '.
577: 'Please try again.');
578: return;
579: }
580: if (length($newpass1) < 7) {
581: &passwordchanger($r,
582: '<font color="#ff0000">ERROR:</font>'.
583: 'Passwords must be a minimum of 7 characters long. '.
584: 'Please try again.');
585: return;
586: }
587: #
588: # Check for bad characters
589: my $badpassword = 0;
590: foreach (split(//,$newpass1)) {
591: $badpassword = 1 if ((ord($_)<32)||(ord($_)>126));
592: }
593: if ($badpassword) {
594: # I can't figure out how to enter bad characters on my browser.
595: &passwordchanger($r,<<ENDERROR);
596: <font color="#ff0000">ERROR:</font>
597: The password you entered contained illegal characters.<br />
598: Valid characters are: space and <br />
599: <pre>
600: !"\#$%&\'()*+,-./0123456789:;<=>?\@
601: ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}~
602: </pre>
603: ENDERROR
604: }
605: #
606: # Change the password (finally)
607: my $result = &Apache::lonnet::changepass
608: ($user,$domain,$currentpass,$newpass1,$homeserver);
609: # Inform the user the password has (not?) been changed
610: if ($result =~ /^ok$/) {
611: $r->print(<<"ENDTEXT");
612: <h2>The password for $user was successfully changed</h2>
613: ENDTEXT
614: } else {
615: # error error: run in circles, scream and shout
616: $r->print(<<ENDERROR);
617: <h2><font color="#ff0000">The password for $user was not changed</font></h2>
618: Please make sure your old password was entered correctly.
619: ENDERROR
620: }
621: return;
622: }
623:
624: ######################################################
625: # other handler subroutines #
626: ######################################################
627:
628: ################################################################
629: # Main handler #
630: ################################################################
631: sub handler {
632: my $r = shift;
633: my $user = $ENV{'user.name'};
634: my $domain = $ENV{'user.domain'};
635: $r->content_type('text/html');
636: # Some pages contain DES keys and should not be cached.
637: &Apache::loncommon::no_cache($r);
638: $r->send_http_header;
639: return OK if $r->header_only;
640: #
641: if ($ENV{'form.action'} eq 'changepass') {
642: &passwordchanger($r);
643: } elsif ($ENV{'form.action'} eq 'verify_and_change_pass') {
644: &verify_and_change_password($r);
645: } elsif ($ENV{'form.action'} eq 'changescreenname') {
646: &screennamechanger($r);
647: } elsif ($ENV{'form.action'} eq 'verify_and_change_screenname') {
648: &verify_and_change_screenname($r);
649: } elsif ($ENV{'form.action'} eq 'changemsgforward') {
650: &msgforwardchanger($r);
651: } elsif ($ENV{'form.action'} eq 'verify_and_change_msgforward') {
652: &verify_and_change_msgforward($r);
653: } elsif ($ENV{'form.action'} eq 'changecolors') {
654: &colorschanger($r);
655: } elsif ($ENV{'form.action'} eq 'verify_and_change_colors') {
656: &verify_and_change_colors($r);
657: } elsif ($ENV{'form.action'} eq 'debugtoggle') {
658: if (($ENV{'user.name'} eq 'albertel' ) ||
659: ($ENV{'user.name'} eq 'kortemey' ) ||
660: ($ENV{'user.name'} eq 'korte')) {
661: if ($ENV{'user.debug'}) {
662: &Apache::lonnet::delenv('user\.debug');
663: } else {
664: &Apache::lonnet::appenv('user.debug' => 1);
665: }
666: }
667: } else {
668: $r->print(<<ENDHEADER);
669: <html>
670: <head>
671: <title>LON-CAPA Preferences</title>
672: </head>
673: ENDHEADER
674: $r->print(&Apache::loncommon::bodytag('Change Your Preferences'));
675: # Determine current authentication method
676: my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
677: if ($currentauth =~ /^(unix|internal):/) {
678: $r->print(<<ENDPASSWORDFORM);
679: <form name="client" action="/adm/preferences" method="post">
680: <input type="hidden" name="action" value="changepass" />
681: <input type="submit" value="Change password" />
682: </form>
683: ENDPASSWORDFORM
684: }
685: # Change screen name
686: $r->print(<<ENDSCREENNAMEFORM);
687: <form name="client" action="/adm/preferences" method="post">
688: <input type="hidden" name="action" value="changescreenname" />
689: <input type="submit"
690: value="Change nickname and anonymous discussion screen name" />
691: </form>
692: ENDSCREENNAMEFORM
693: $r->print(<<ENDMSGFORWARDFORM);
694: <form name="client" action="/adm/preferences" method="post">
695: <input type="hidden" name="action" value="changemsgforward" />
696: <input type="submit" value="Change message forwarding and notification addresses" />
697: </form>
698: ENDMSGFORWARDFORM
699: # The "about me" page
700: my $aboutmeaction=
701: '/adm/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/aboutme';
702: $r->print(<<ENDABOUTME);
703: <form name="client" action="$aboutmeaction" method="post">
704: <input type="hidden" name="action" value="changescreenname" />
705: <input type="submit" value="Edit the 'About Me' personal information screen" />
706: </form>
707: ENDABOUTME
708: $r->print(<<ENDCOLORFORM);
709: <form name="client" action="/adm/preferences" method="post">
710: <input type="hidden" name="action" value="changecolors" />
711: <input type="submit" value="Change color scheme" />
712: </form>
713: ENDCOLORFORM
714:
715: if (($ENV{'user.name'} eq 'albertel' ) ||
716: ($ENV{'user.name'} eq 'kortemey' ) ||
717: ($ENV{'user.name'} eq 'korte')) {
718: $r->print(<<ENDDEBUG);
719: <form name="client" action="/adm/preferences" method="post">
720: <input type="hidden" name="action" value="debugtoggle" />
721: <input type="submit" value="Toggle Debug" />
722: Current Debug status is -$ENV{'user.debug'}-.
723: </form>
724: ENDDEBUG
725: }
726: # Other preference setting code should be added here
727: }
728: $r->print(<<ENDFOOTER);
729: </body>
730: </html>
731: ENDFOOTER
732: return OK;
733: }
734:
735: 1;
736: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>