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

raeburn raeburn@source.lon-capa.org
Wed, 30 Sep 2009 21:47:07 -0000


raeburn		Wed Sep 30 21:47:07 2009 EDT

  Modified files:              
    /loncom/interface	resetpw.pm 
  Log:
  - When a user initiates the reset password process for an internally 
    authenticated account, the e-mail address entered in the web form
    can now be any of: permanentemail, critnotification or notification.
    - The earlier enforced precedence order:
       permanentemail > critnotification > notification  is eliminated.
    - The e-mail check now supports multiple notification addresses for a single type.
  
  
Index: loncom/interface/resetpw.pm
diff -u loncom/interface/resetpw.pm:1.17 loncom/interface/resetpw.pm:1.18
--- loncom/interface/resetpw.pm:1.17	Wed Apr 29 16:57:29 2009
+++ loncom/interface/resetpw.pm	Wed Sep 30 21:47:07 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Allow access to password changing via a token sent to user's e-mail. 
 #
-# $Id: resetpw.pm,v 1.17 2009/04/29 16:57:29 bisitz Exp $
+# $Id: resetpw.pm,v 1.18 2009/09/30 21:47:07 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -76,18 +76,26 @@
                 my %userinfo = 
 		    &Apache::lonnet::get('environment',\@emailtypes,
 					 $udom,$uname);
-                my $email = '';
-                my $emailtarget;
+                my @allemails;
                 foreach my $type (@emailtypes) {
-                    $email = $userinfo{$type};
-                    if ($email =~ /[^\@]+\@[^\@]+/) {
-                        $emailtarget = $type; 
-                        last;
+                    my $email = $userinfo{$type};
+                    my @items;
+                    if ($email =~ /,/) {
+                        @items = split(',',$userinfo{$type});
+                    } else {
+                        @items = ($email);
+                    }
+                    foreach my $item (@items) {
+                        if ($item =~ /^[^\@]+\@[^\@]+\.[^\@\.]+$/) {
+                            unless(grep(/^\Q$item\E$/,@allemails)) { 
+                                push(@allemails,$item);
+                            }
+                        }
                     }
                 }
-                if ($email =~ /^[^\@]+\@[^\@]+\.[^\@\.]+$/) {
-                    if ($useremail eq $email) {
-                        $output = &send_token($uname,$udom,$email,$server,
+                if (@allemails > 0) {
+                    if (grep(/^\Q$useremail\E$/,@allemails)) {
+                        $output = &send_token($uname,$udom,$useremail,$server,
                                               $domdesc,$contact_name,
                                               $contact_email);
                     } else {