[LON-CAPA-cvs] cvs: loncom /interface londropadd.pm lonmsg.pm /lonnet/perl lonnet.pm

www lon-capa-cvs@mail.lon-capa.org
Mon, 31 Jan 2005 11:27:14 -0000


www		Mon Jan 31 06:27:14 2005 EDT

  Modified files:              
    /loncom/interface	londropadd.pm lonmsg.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  Saving my work towards aspects of bugs 1290 and 3442.
  
  
Index: loncom/interface/londropadd.pm
diff -u loncom/interface/londropadd.pm:1.123 loncom/interface/londropadd.pm:1.124
--- loncom/interface/londropadd.pm:1.123	Tue Jan 11 17:12:22 2005
+++ loncom/interface/londropadd.pm	Mon Jan 31 06:27:14 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to drop and add students in courses 
 #
-# $Id: londropadd.pm,v 1.123 2005/01/11 22:12:22 albertel Exp $
+# $Id: londropadd.pm,v 1.124 2005/01/31 11:27:14 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -770,7 +770,7 @@
                  $ENV{'form.clast'},$ENV{'form.cgen'},
                  $ENV{'form.csec'},$enddate,
                  $startdate,$ENV{'form.forceid'},
-                 $desiredhost);
+                 $desiredhost,$ENV{'form.emailaddress'});
             if ($login_result =~ /^ok/) {
                 $r->print($login_result);
                 $r->print("<p> ".&mt('If active, the new role will be available when the student next logs in to LON-CAPA.')."</p>");
@@ -983,6 +983,7 @@
                        'hs'   => "Home Server",
                        'pswd' => "Password",
 		       'psam' => "Please select an authentication mechanism",
+                       'mail' => "Email Address"
 					   );
         $user_data_html = <<END;
 <h3>$lt{'udf'} $username\@$domain</h3>
@@ -997,6 +998,8 @@
     <td><input type="text" name="cgen"    size="5"> </td></tr>
 <tr><th>$lt{'hs'}:</th>
     <td>$homeserver_form</td></tr>
+<tr><th>$lt{'mail'}:</th>
+    <td><input type="text" name="emailaddress" size="20" /></td></tr>
 </table>
 <h3>$lt{'pswd'}</h3>
 $lt{'psam'}
@@ -1019,6 +1022,7 @@
                        'mn'   => "Middle Name",
                        'ln'   => "Last Name",
                        'gen'  => "Generation",
+                       'mail' => "Email Address",
 					   );
         $user_data_html = <<END;
 <h3>$lt{'udf'} $username\@$domain</h3>
@@ -1040,6 +1044,10 @@
     <td>
     <input type="text" name="cgen" value="$uenv{'generation'}" size="5" />
     </td></tr>
+<tr><th>$lt{'mail'}:</th>
+    <td>
+    <input type="text" name="emailaddress" value="$uenv{'permanentemail'}" size="20" />
+    </td></tr>
 </table>
 END
     }
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.131 loncom/interface/lonmsg.pm:1.132
--- loncom/interface/lonmsg.pm:1.131	Sun Jan 30 18:32:29 2005
+++ loncom/interface/lonmsg.pm	Mon Jan 31 06:27:14 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging
 #
-# $Id: lonmsg.pm,v 1.131 2005/01/30 23:32:29 www Exp $
+# $Id: lonmsg.pm,v 1.132 2005/01/31 11:27:14 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -90,7 +90,7 @@
 
 Users can ask LON-CAPA to forward messages to conventional e-mail
 addresses on their B<PREF> screen, but generally, LON-CAPA messages
-are much more useful then traditional email can be made to be, even
+are much more useful than traditional email can be made to be, even
 with HTML support.
 
 Right now, this document will cover just how to send a message, since
@@ -356,7 +356,7 @@
 # ================================================== Critical message to a user
 
 sub user_crit_msg_raw {
-    my ($user,$domain,$subject,$message,$sendback)=@_;
+    my ($user,$domain,$subject,$message,$sendback,$toperm)=@_;
 # Check if allowed missing
     my $status='';
     my $msgid='undefined';
@@ -381,12 +381,17 @@
        $status='no_host';
     }
 # Notifications
-    my %userenv = &Apache::lonnet::get('environment',['critnotification'],
+    my %userenv = &Apache::lonnet::get('environment',['critnotification',
+                                                      'permanentemail'],
                                        $domain,$user);
     if ($userenv{'critnotification'}) {
       &sendnotification($userenv{'critnotification'},$user,$domain,$subject,1,
 			$text);
     }
+    if ($toperm && $userenv{'permanentemail'}) {
+      &sendnotification($userenv{'permanentemail'},$user,$domain,$subject,1,
+			$text);
+    }
 # Log this
     &Apache::lonnet::logthis(
       'Sending critical email '.$msgid.
@@ -456,7 +461,8 @@
 # ======================================================== Normal communication
 
 sub user_normal_msg_raw {
-    my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl)=@_;
+    my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl,
+	$toperm)=@_;
 # Check if allowed missing
     my $status='';
     my $msgid='undefined';
@@ -484,12 +490,17 @@
        $status='no_host';
     }
 # Notifications
-    my %userenv = &Apache::lonnet::get('environment',['notification'],
+    my %userenv = &Apache::lonnet::get('environment',['notification',
+                                                      'permanentemail'],
                                        $domain,$user);
     if ($userenv{'notification'}) {
 	&sendnotification($userenv{'notification'},$user,$domain,$subject,0,
 			  $text);
     }
+    if ($toperm && $userenv{'permanentemail'}) {
+      &sendnotification($userenv{'permanentemail'},$user,$domain,$subject,0,
+			$text);
+    }
     &Apache::lonnet::log($ENV{'user.domain'},$ENV{'user.name'},
                          $ENV{'user.home'},
       'Sending '.$msgid.' to '.$user.' at '.$domain.' with status: '.$status);
@@ -507,7 +518,8 @@
 =cut
 
 sub user_normal_msg {
-    my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl)=@_;
+    my ($user,$domain,$subject,$message,$citation,$baseurl,$attachmenturl,
+	$toperm)=@_;
     my $status='';
     my %userenv = &Apache::lonnet::get('environment',['msgforward'],
                                        $domain,$user);
@@ -517,11 +529,11 @@
 	 my ($forwuser,$forwdomain)=split(/\:/,$_);
          $status.=
 	  &user_normal_msg_raw($forwuser,$forwdomain,$subject,$message,
-			       $citation,$baseurl,$attachmenturl).' ';
+			       $citation,$baseurl,$attachmenturl,$toperm).' ';
        }
     } else { 
 	$status=&user_normal_msg_raw($user,$domain,$subject,$message,
-				     $citation,$baseurl,$attachmenturl);
+				     $citation,$baseurl,$attachmenturl,$toperm);
     }
     return $status;
 }
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.591 loncom/lonnet/perl/lonnet.pm:1.592
--- loncom/lonnet/perl/lonnet.pm:1.591	Fri Jan 28 04:26:57 2005
+++ loncom/lonnet/perl/lonnet.pm	Mon Jan 31 06:27:14 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.591 2005/01/28 09:26:57 albertel Exp $
+# $Id: lonnet.pm,v 1.592 2005/01/31 11:27:14 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3576,9 +3576,12 @@
     if (defined($middle)) { $names{'middlename'} = $middle; }
     if ($last)   { $names{'lastname'}   = $last; }
     if (defined($gene))   { $names{'generation'} = $gene; }
-    if ($email)  { $names{'notification'} = $email;
-                   $names{'critnotification'} = $email; }
-
+    if ($email) {
+       $email=~s/[^\w\@\.\-\,]//gs;
+       if ($email=~/\@/) { $names{'notification'} = $email;
+			   $names{'critnotification'} = $email;
+			   $names{'permanentemail'} = $email; }
+    }
     my $reply = &put('environment', \%names, $udom,$uname);
     if ($reply ne 'ok') { return 'error: '.$reply; }
     &logthis('Success modifying user '.$udom.', '.$uname.', '.$uid.', '.