[LON-CAPA-cvs] cvs: loncom /interface lonpreferences.pm

www lon-capa-cvs@mail.lon-capa.org
Sat, 30 Mar 2002 23:27:00 -0000


www		Sat Mar 30 18:27:00 2002 EDT

  Modified files:              
    /loncom/interface	lonpreferences.pm 
  Log:
  Sets environment 'screenname'
  
  
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.5 loncom/interface/lonpreferences.pm:1.6
--- loncom/interface/lonpreferences.pm:1.5	Sat Mar 30 12:59:34 2002
+++ loncom/interface/lonpreferences.pm	Sat Mar 30 18:27:00 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Preferences
 #
-# $Id: lonpreferences.pm,v 1.5 2002/03/30 17:59:34 www Exp $
+# $Id: lonpreferences.pm,v 1.6 2002/03/30 23:27:00 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -105,6 +105,8 @@
     my $user       = $ENV{'user.name'};
     my $domain     = $ENV{'user.domain'};
     my $homeserver = $ENV{'user.home'};
+    my %userenv = &Apache::lonnet::get('environment',['screenname']);
+    my $screenname=$userenv{'screenname'};
     $r->print(<<ENDSCREEN);
 <html>
 <body bgcolor="#FFFFFF">
@@ -114,10 +116,48 @@
 <p>
 Change anonymous discussion screen name for $user
 </p>
+
+<form name="server" action="/adm/preferences" method="post">
+<input type="hidden" name="action" value="verify_and_change_screenname" />
+New screenname:
+<input type="text" size="20" value="$screenname" name="screenname" />
+<input type="submit" value="Change" />
+</form>
 </body>
 </html>
 ENDSCREEN
 }
+
+sub verify_and_change_screenname {
+    my $r = shift;
+    my $user       = $ENV{'user.name'};
+    my $domain     = $ENV{'user.domain'};
+    my $homeserver = $ENV{'user.home'};
+    my $newscreen  = $ENV{'form.screenname'};
+    $newscreen=~s/\W//g;
+    my $message='';
+    if ($newscreen) {
+	my %tmp;
+        $tmp{'screenname'}=$newscreen;
+        &Apache::lonnet::put('environment',\%tmp);
+        $message='Set new screenname to '.$newscreen;
+    } else {
+        &Apache::lonnet::del('environment',['screenname']);
+        $message='Reset screenname';
+    }
+    $r->print(<<ENDVCSCREEN);
+<html>
+<body bgcolor="#FFFFFF">
+<h1>Preferences for $user</h1>
+<h3>$user is a member of domain $domain</h3>
+<p>
+Change anonymous discussion screen name for $user
+</p>
+$message
+</body></html>
+ENDVCSCREEN
+}
+
 ######################################################
 #            password handler subroutines            #
 ######################################################
@@ -356,6 +396,8 @@
 	&verify_and_change_password($r);
     } elsif ($ENV{'form.action'} eq 'changescreenname') {
         &screennamechanger($r);
+    } elsif ($ENV{'form.action'} eq 'verify_and_change_screenname') {
+        &verify_and_change_screenname($r);
     } else {
 	$r->print(<<ENDHEADER);
 <html>