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

raeburn lon-capa-cvs@mail.lon-capa.org
Mon, 28 Nov 2005 18:32:39 -0000


raeburn		Mon Nov 28 13:32:39 2005 EDT

  Modified files:              
    /loncom/interface	lonmsg.pm 
  Log:
  Bug 4333. Include course context in display of folder contents in COM. Can sort by course (description, NOT courseID).  Currently implemented for all folders. Could be restricted to just INBOX, as per bug request.      
  
  
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.156 loncom/interface/lonmsg.pm:1.157
--- loncom/interface/lonmsg.pm:1.156	Wed Nov 23 17:32:11 2005
+++ loncom/interface/lonmsg.pm	Mon Nov 28 13:32:39 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging
 #
-# $Id: lonmsg.pm,v 1.156 2005/11/23 22:32:11 raeburn Exp $
+# $Id: lonmsg.pm,v 1.157 2005/11/28 18:32:39 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -810,8 +810,9 @@
 	my $msgid=&Apache::lonnet::escape($_);
 	my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid)=
 	    &Apache::lonmsg::unpackmsgid($msgid,$folder);
+        my $description = &get_course_desc($fromcid);
 	my @temp1 = ($sendtime,$shortsubj,$fromname,$fromdomain,$status,
-		     $msgid);
+		     $msgid,$description);
         # Check whether message was sent during blocking period.
         if ($sendtime >= $startblock && ($sendtime <= $endblock && $endblock > 0) ) {
             my $escid = &Apache::lonnet::unescape($msgid);
@@ -847,6 +848,12 @@
     if ($env{'form.sortedby'} eq "revsubject"){
         @temp = sort  {lc($b->[1]) cmp lc($a->[1])} @temp;
     }
+    if ($env{'form.sortedby'} eq "course"){
+        @temp = sort  {lc($a->[6]) cmp lc($b->[6])} @temp;
+    }
+    if ($env{'form.sortedby'} eq "revcourse"){
+        @temp = sort  {lc($b->[6]) cmp lc($a->[6])} @temp;
+    }
     if ($env{'form.sortedby'} eq "status"){
         @temp = sort  {$a->[4] cmp $b->[4]} @temp;
     }
@@ -856,6 +863,18 @@
     return @temp;
 }
 
+sub get_course_desc {
+    my ($fromcid) = @_;
+    my $description; 
+    if (defined($env{'course.'.$fromcid.'.description'})) {
+       $description = $env{'course.'.$fromcid.'.description'};
+    } else {
+       my %courseinfo=&Apache::lonnet::coursedescription($fromcid);
+        $description = $courseinfo{'description'};
+    }
+    return $description;
+}
+
 # ======================================================== Display new messages
 
 
@@ -864,6 +883,7 @@
     my %lt=&Apache::lonlocal::texthash(
 				       'nm' => 'New Messages',
 				       'su' => 'Subject',
+                                       'co' => 'Course',
 				       'da' => 'Date',
 				       'us' => 'Username',
 				       'op' => 'Open',
@@ -885,6 +905,7 @@
         my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
 	    &Apache::lonmsg::unpackmsgid($_);
         if (defined($sendtime) && $sendtime!~/error/) {
+            my $description = &get_course_desc($fromcid);
             my $numsendtime = $sendtime;
             $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
             if ($status eq 'new') {
@@ -897,7 +918,8 @@
                         sendtime => $sendtime,
                         shortsub => &Apache::lonnet::unescape($shortsubj),
                         from     => $fromname,
-                        fromdom  => $fromdom 
+                        fromdom  => $fromdom,
+                        course   => $description 
                         }
                 }
             }
@@ -907,7 +929,7 @@
         $r->print(<<TABLEHEAD);
 <h2>$lt{'nm'}</h2>
 <table border=2><tr><th>&nbsp</th>
-<th>$lt{'da'}</th><th>$lt{'us'}</th><th>$lt{'do'}</th><th>$lt{'su'}</th></tr>
+<th>$lt{'da'}</th><th>$lt{'us'}</th><th>$lt{'do'}</th><th>$lt{'su'}</th><th>$lt{'co'}</th></tr>
 TABLEHEAD
         foreach my $msg (@newmsgs) {
             $r->print(<<"ENDLINK");
@@ -915,7 +937,7 @@
 onMouseOut="javascript:style.backgroundColor='#FFBB77'">
 <td><a href="/adm/email?dismode=new&display=$msg->{'msgid'}">$lt{'op'}</a></td>
 ENDLINK
-            foreach ('sendtime','from','fromdom','shortsub') {
+            foreach ('sendtime','from','fromdom','shortsub','course') {
                 $r->print("<td>$msg->{$_}</td>");
             }
             $r->print("</td></tr>");
@@ -1029,6 +1051,12 @@
     	$r->print('<a href = "?sortedby=revsubject'.$fsqs.'">'.&mt('Subject').'</a>');
     }
     $r->print('</th><th>');
+    if ($env{'form.sortedby'} eq "revcourse") {
+        $r->print('<a href = "?sortedby=course'.$fsqs.'">'.&mt('Course').'</a>');
+    } else {
+        $r->print('<a href = "?sortedby=revcourse'.$fsqs.'">'.&mt('Course').'</a>');
+    }
+    $r->print('</th><th>');
     if ($env{'form.sortedby'} eq "revstatus") {
 	$r->print('<a href = "?sortedby=status'.$fsqs.'">'.&mt('Status').'</a></th>');
     } else {
@@ -1036,7 +1064,7 @@
     }
     $r->print("</tr>\n");
     for (my $n=$firstdis;$n<=$lastdis;$n++) {
-	my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$origID)= @{$temp[$n]};
+	my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$origID,$description)= @{$temp[$n]};
 	if (($status ne 'deleted') && defined($sendtime) && $sendtime!~/error/) {
 	    if ($status eq 'new') {
 		$r->print('<tr bgcolor="#FFBB77" onMouseOver="javascript:style.backgroundColor=\'#DD9955\'"  onMouseOut="javascript:style.backgroundColor=\'#FFBB77\'">');
@@ -1054,7 +1082,7 @@
 		      '<td>'.&Apache::lonlocal::locallocaltime($sendtime).'</td><td>'.
 		      $fromname.'</td><td>'.$fromdomain.'</td><td>'.
 		      &Apache::lonnet::unescape($shortsubj).'</td><td>'.
-                      $status."</td></tr>\n");
+                      $description.'</td><td>'.$status.'</td></tr>'."\n");
 	} elsif ($status eq 'deleted') {
 # purge
 	    &movemsg(&Apache::lonnet::unescape($origID),$folder,'trash');