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

foxr lon-capa-cvs@mail.lon-capa.org
Wed, 17 May 2006 09:46:02 -0000


foxr		Wed May 17 05:46:02 2006 EDT

  Modified files:              
    /loncom/interface	lonmsgdisplay.pm 
  Log:
  Use new student email display format... now need to do some cleanup.
  
  
Index: loncom/interface/lonmsgdisplay.pm
diff -u loncom/interface/lonmsgdisplay.pm:1.24 loncom/interface/lonmsgdisplay.pm:1.25
--- loncom/interface/lonmsgdisplay.pm:1.24	Thu May 11 16:05:03 2006
+++ loncom/interface/lonmsgdisplay.pm	Wed May 17 05:46:01 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging display
 #
-# $Id: lonmsgdisplay.pm,v 1.24 2006/05/11 20:05:03 raeburn Exp $
+# $Id: lonmsgdisplay.pm,v 1.25 2006/05/17 09:46:01 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -28,6 +28,7 @@
 
 
 package Apache::lonmsgdisplay;
+use     Apache::lonselstudent;
 
 =pod
 
@@ -259,6 +260,25 @@
 # ======================================================= Display a course list
 
 sub discourse {
+    my $result;
+    my ($course_personnel,
+	$current_members,
+	$expired_members,
+	$future_members) = &Apache::lonselstudent::get_people_in_class();
+    unshift @$current_members, (@$course_personnel);
+    my %defaultUsers;
+
+    $result = &Apache::lonselstudent::render_student_list($current_members,
+							  "compemail",
+							  "current",
+							  \%defaultUsers,
+							  1,"selectedusers",1);
+
+    return $result;
+}
+
+# --------------------------------- No longer needed ..old display course list.
+sub discourse_obsolete {
     my $r=shift;
     my ($classlist,$keylist) = &Apache::loncoursedata::get_classlist();
     my ($classgroups,$studentgroups) = 
@@ -978,6 +998,8 @@
     }
     if ($broadcast eq 'group') {
        &discourse($r);
+       my $studentsel = &discourse();
+       $r->print($studentsel);
     }
     $r->print('</form>'.
 	      &Apache::lonfeedback::generate_preview_button('compemail','message').
@@ -1733,13 +1755,26 @@
 	    &statuschange($msgid,'replied',$folder);
 	}
 
+	my $to = $env{'form.selectedusers.forminput'};
+	my $mode = $env{'form.sendmode'};
+
 	my %toaddr;
-	if ($env{'form.sendmode'} eq 'group') {
-	    foreach my $address (keys(%env)) {
-		if ($address=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {
-		    $toaddr{$1}='';
+	if ($to) {
+	    foreach my $dest (@$to) {
+		my ($user,$domain) = split /:/, $dest;
+		if (($user ne '') && ($domain ne '')) {
+		    my $address = $user.":".$domain; # How the code below expects it.
+		    $toaddr{$address} = '';
 		}
 	    }
+	}
+
+	if ($env{'form.sendmode'} eq 'group') {
+	     foreach my $address (keys(%env)) {
+	 	if ($address=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {
+	 	    $toaddr{$1}='';
+	 	}
+	    }
 	} elsif ($env{'form.sendmode'} eq 'upload') {
 	    foreach my $line (split(/[\n\r\f]+/,$env{'form.upfile'})) {
 		my ($rec,$txt)=split(/\s*\:\s*/,$line);
@@ -1749,12 +1784,16 @@
 		}
 	    }
 	} else {
-	    $toaddr{$env{'form.recuname'}.':'.$env{'form.recdomain'}}='';
+	    if (($env{'form.recuname'} ne '') && ($env{'form.recdomain'} ne '')) {
+		$toaddr{$env{'form.recuname'}.':'.$env{'form.recdomain'}}='';
+	    }
 	}
 	if ($env{'form.additionalrec'}) {
 	    foreach (split(/\,/,$env{'form.additionalrec'})) {
 		my ($auname,$audom)=split(/\@/,$_);
-		$toaddr{$auname.':'.$audom}='';
+		if (($auname ne "") && ($audom ne "")) {
+		    $toaddr{$auname.':'.$audom}='';
+		}
 	    }
 	}
 
@@ -1883,7 +1922,7 @@
 	}
     } else {
 	$r->print('<p><span class="LC_error">'.&mt('Could not deliver message').'</span> '.
-		  &mt('Please use the browser "Back" button and correct the recipient addresses').'</p>');
+		  &mt('Please use the browser "Back" button and correct the recipient addresses '."($sendstatus)").'</p>');
     }
 }