[LON-CAPA-cvs] cvs: loncom /interface lonpreferences.pm
www
lon-capa-cvs@mail.lon-capa.org
Sat, 07 Sep 2002 03:44:14 -0000
www Fri Sep 6 23:44:14 2002 EDT
Modified files:
/loncom/interface lonpreferences.pm
Log:
Towards bug 707 - can set mail forwarding address now
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.11 loncom/interface/lonpreferences.pm:1.12
--- loncom/interface/lonpreferences.pm:1.11 Tue Aug 27 09:23:01 2002
+++ loncom/interface/lonpreferences.pm Fri Sep 6 23:44:14 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Preferences
#
-# $Id: lonpreferences.pm,v 1.11 2002/08/27 13:23:01 www Exp $
+# $Id: lonpreferences.pm,v 1.12 2002/09/07 03:44:14 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -152,6 +152,72 @@
ENDVCSCREEN
}
+################################################################
+# Message Forward #
+################################################################
+
+sub msgforwardchanger {
+ my $r = shift;
+ my $user = $ENV{'user.name'};
+ my $domain = $ENV{'user.domain'};
+ my %userenv = &Apache::lonnet::get('environment',['msgforward']);
+ my $msgforward=$userenv{'msgforward'};
+ my $bodytag=&Apache::loncommon::bodytag(
+ 'Change Your Message Forwarding');
+ $r->print(<<ENDMSG);
+<html>
+$bodytag
+
+<form name="server" action="/adm/preferences" method="post">
+<input type="hidden" name="action" value="verify_and_change_msgforward" />
+New Forwarding Address(es) (<tt>user:domain,user:domain,...</tt>):
+<input type="text" size="40" value="$msgforward" name="msgforward" />
+<input type="submit" value="Change" />
+</form>
+</body>
+</html>
+ENDMSG
+}
+
+sub verify_and_change_msgforward {
+ my $r = shift;
+ my $user = $ENV{'user.name'};
+ my $domain = $ENV{'user.domain'};
+ my $newscreen = '';
+ my $message='';
+ foreach (split(/\,/,$ENV{'form.msgforward'})) {
+ my ($msuser,$msdomain)=split(/[\@\:]/,$_);
+ $msuser=~s/\W//g;
+ $msdomain=~s/\W//g;
+ if (($msuser) && ($msdomain)) {
+ if (&Apache::lonnet::homeserver($msuser,$msdomain) ne 'no_host') {
+ $newscreen.=$msuser.':'.$msdomain.',';
+ } else {
+ $message.='No such user: '.$msuser.':'.$msdomain.'<br>';
+ }
+ }
+ }
+ $newscreen=~s/\,$//;
+ if ($newscreen) {
+ &Apache::lonnet::put('environment',{'msgforward' => $newscreen});
+ &Apache::lonnet::appenv('environment.msgforward' => $newscreen);
+ $message.='Set new message forwarding to '.$newscreen;
+ } else {
+ &Apache::lonnet::del('environment',['msgforward']);
+ &Apache::lonnet::delenv('environment\.msgforward');
+ $message.='Reset message forwarding';
+ }
+ my $bodytag=&Apache::loncommon::bodytag(
+ 'Change Your Message Forwarding');
+ $r->print(<<ENDVCMSG);
+<html>
+$bodytag
+</p>
+$message
+</body></html>
+ENDVCMSG
+}
+
######################################################
# password handler subroutines #
######################################################
@@ -389,6 +455,10 @@
&screennamechanger($r);
} elsif ($ENV{'form.action'} eq 'verify_and_change_screenname') {
&verify_and_change_screenname($r);
+ } elsif ($ENV{'form.action'} eq 'changemsgforward') {
+ &msgforwardchanger($r);
+ } elsif ($ENV{'form.action'} eq 'verify_and_change_msgforward') {
+ &verify_and_change_msgforward($r);
} else {
$r->print(<<ENDHEADER);
<html>
@@ -413,6 +483,12 @@
<input type="submit" value="Change anonymous discussion screen name">
</form>
ENDSCREENNAMEFORM
+ $r->print(<<ENDMSGFORWARDFORM);
+<form name="client" action="/adm/preferences" method="post">
+<input type="hidden" name="action" value="changemsgforward">
+<input type="submit" value="Change message forwarding address">
+</form>
+ENDMSGFORWARDFORM
# The "about me" page
my $aboutmeaction=
'/adm/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/aboutme';