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

www lon-capa-cvs@mail.lon-capa.org
Fri, 13 Sep 2002 19:32:09 -0000


www		Fri Sep 13 15:32:09 2002 EDT

  Modified files:              
    /loncom/interface	lonchatfetch.pm loncommon.pm lonpreferences.pm 
  Log:
  Addition of nicknames (part)
  
  
Index: loncom/interface/lonchatfetch.pm
diff -u loncom/interface/lonchatfetch.pm:1.4 loncom/interface/lonchatfetch.pm:1.5
--- loncom/interface/lonchatfetch.pm:1.4	Mon Sep  9 17:01:58 2002
+++ loncom/interface/lonchatfetch.pm	Fri Sep 13 15:32:09 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Chat Fetching
 #
-# $Id: lonchatfetch.pm,v 1.4 2002/09/09 21:01:58 www Exp $
+# $Id: lonchatfetch.pm,v 1.5 2002/09/13 19:32:09 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -79,9 +79,15 @@
             $contrib=~s/\n/ /g;
             $contrib=~s/\'/\&\#39\;/g;
             my $sender='';
-            unless (($anon) && (!$seeid)) {
+            if ($seeid) {
                $sender=&Apache::loncommon::plainname($snum,$sdom);
-	        if ($anon) { $sender.=' [Anon]' };
+               my $nick=&Apache::loncommon::nickname($snum,$sdom);
+               if (($nick) && ($nick ne $sender)) {
+		   $sender.=' '.$nick;
+               }
+	       if ($anon) { $sender.=' [Anon]' };
+            } elsif (!$anon) {
+               $sender=&Apache::loncommon::nickname($snum,$sdom);
             } else {
 		$sender=&Apache::loncommon::screenname($snum,$sdom);
                 unless ($sender) { $sender="Anonymous"; }
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.65 loncom/interface/loncommon.pm:1.66
--- loncom/interface/loncommon.pm:1.65	Mon Sep  9 07:50:07 2002
+++ loncom/interface/loncommon.pm	Fri Sep 13 15:32:09 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.65 2002/09/09 11:50:07 matthew Exp $
+# $Id: loncommon.pm,v 1.66 2002/09/13 19:32:09 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -973,6 +973,26 @@
     $name=~s/\s+/ /g;
     return $name;
 }
+
+# -------------------------------------------------------------------- Nickname
+
+
+sub nickname {
+    my ($uname,$udom)=@_;
+    my %names=&Apache::lonnet::get('environment',
+  ['nickname','firstname','middlename','lastname','generation'],$udom,$uname);
+    my $name=$names{'nickname'};
+    if ($name) {
+       $name='"'.$name.'"'; 
+    } else {
+       $name=$names{'firstname'}.' '.$names{'middlename'}.' '.
+	     $names{'lastname'}.' '.$names{'generation'};
+       $name=~s/\s+$//;
+       $name=~s/\s+/ /g;
+    }
+    return $name;
+}
+
 
 # ------------------------------------------------------------------ Screenname
 
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.13 loncom/interface/lonpreferences.pm:1.14
--- loncom/interface/lonpreferences.pm:1.13	Wed Sep 11 14:26:41 2002
+++ loncom/interface/lonpreferences.pm	Fri Sep 13 15:32:09 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Preferences
 #
-# $Id: lonpreferences.pm,v 1.13 2002/09/11 18:26:41 www Exp $
+# $Id: lonpreferences.pm,v 1.14 2002/09/13 19:32:09 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -106,18 +106,22 @@
     my $r = shift;
     my $user       = $ENV{'user.name'};
     my $domain     = $ENV{'user.domain'};
-    my %userenv = &Apache::lonnet::get('environment',['screenname']);
+    my %userenv = &Apache::lonnet::get
+        ('environment',['screenname','nickname']);
     my $screenname=$userenv{'screenname'};
+    my $nickname=$userenv{'nickname'};
     my $bodytag=&Apache::loncommon::bodytag(
-                                         'Change Your Anonymous Screen Name');
+              'Change Your Nickname and Anonymous Screen Name');
     $r->print(<<ENDSCREEN);
 <html>
 $bodytag
 
 <form name="server" action="/adm/preferences" method="post">
 <input type="hidden" name="action" value="verify_and_change_screenname" />
-New screenname:
+<br />New screenname (shown if you post anonymously):
 <input type="text" size="20" value="$screenname" name="screenname" />
+<br />New nickname (shown if you post non-anonymously):
+<input type="text" size="20" value="$nickname" name="nickname" />
 <input type="submit" value="Change" />
 </form>
 </body>
@@ -129,8 +133,9 @@
     my $r = shift;
     my $user       = $ENV{'user.name'};
     my $domain     = $ENV{'user.domain'};
+# Screenname
     my $newscreen  = $ENV{'form.screenname'};
-    $newscreen=~s/\W//g;
+    $newscreen=~s/[^ \w]//g;
     my $message='';
     if ($newscreen) {
         &Apache::lonnet::put('environment',{'screenname' => $newscreen});
@@ -141,8 +146,22 @@
         &Apache::lonnet::delenv('environment\.screenname');
         $message='Reset screenname';
     }
+# Nickname
+    $message.='<br />';
+    my $newscreen  = $ENV{'form.nickname'};
+    $newscreen=~s/[^ \w]//g;
+    if ($newscreen) {
+        &Apache::lonnet::put('environment',{'nickname' => $newscreen});
+        &Apache::lonnet::appenv('environment.nickname' => $newscreen);
+        $message.='Set new nickname to '.$newscreen;
+    } else {
+        &Apache::lonnet::del('environment',['nickname']);
+        &Apache::lonnet::delenv('environment\.nickname');
+        $message.='Reset nickname';
+    }
+
     my $bodytag=&Apache::loncommon::bodytag(
-                                         'Change Your Anonymous Screen Name');
+                    'Change Your Nickname and Anonymous Screen Name');
     $r->print(<<ENDVCSCREEN);
 <html>
 $bodytag
@@ -472,22 +491,23 @@
 	if ($currentauth =~ /^(unix|internal):/) {
 	    $r->print(<<ENDPASSWORDFORM);
 <form name="client" action="/adm/preferences" method="post">
-<input type="hidden" name="action" value="changepass">
-<input type="submit" value="Change password">
+<input type="hidden" name="action" value="changepass" />
+<input type="submit" value="Change password" />
 </form>
 ENDPASSWORDFORM
         }
 # Change screen name
 	    $r->print(<<ENDSCREENNAMEFORM);
 <form name="client" action="/adm/preferences" method="post">
-<input type="hidden" name="action" value="changescreenname">
-<input type="submit" value="Change anonymous discussion screen name">
+<input type="hidden" name="action" value="changescreenname" />
+<input type="submit" 
+value="Change nickname and 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">
+<input type="hidden" name="action" value="changemsgforward" />
+<input type="submit" value="Change message forwarding address" />
 </form>
 ENDMSGFORWARDFORM
 # The "about me" page
@@ -495,8 +515,8 @@
         '/adm/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/aboutme';
 	    $r->print(<<ENDABOUTME);
 <form name="client" action="$aboutmeaction" method="post">
-<input type="hidden" name="action" value="changescreenname">
-<input type="submit" value="Edit the 'About Me' Personal Information Screen">
+<input type="hidden" name="action" value="changescreenname" />
+<input type="submit" value="Edit the 'About Me' Personal Information Screen" />
 </form>
 ENDABOUTME
             # Other preference setting code should be added here