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

raeburn raeburn@source.lon-capa.org
Sat, 05 Sep 2009 17:20:59 -0000


raeburn		Sat Sep  5 17:20:59 2009 EDT

  Modified files:              
    /loncom/interface	lonpopulate.pm 
  Log:
  - Bug 6023.
    - Only include expired DCs in the list of DCs (shown exclusively to DCs)
      on the notify page, if they are currently included in the notification list 
      for the course.
  
  
Index: loncom/interface/lonpopulate.pm
diff -u loncom/interface/lonpopulate.pm:1.64 loncom/interface/lonpopulate.pm:1.65
--- loncom/interface/lonpopulate.pm:1.64	Fri Jul 17 22:24:08 2009
+++ loncom/interface/lonpopulate.pm	Sat Sep  5 17:20:58 2009
@@ -1,5 +1,5 @@
 # automated enrollment configuration handler
-# $Id: lonpopulate.pm,v 1.64 2009/07/17 22:24:08 droeschl Exp $
+# $Id: lonpopulate.pm,v 1.65 2009/09/05 17:20:58 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -508,8 +508,7 @@
   } elsif ($action eq "notify") {
       my $notifycount = 0;
       my @notified = split(/,/,$enrollvar{notifylist});
-      my @domcoord;
-      my @showdom;
+      my (@domcoord,@showdom,@olddomcoord,@futuredomcoord);
       for (my $i=0; $i<@notified; $i++) {
           if ($notified[$i] !~ /:/) {
               $notified[$i] =~ s/\@/:/;
@@ -522,12 +521,26 @@
       } else {
           $noteset = "OFF";
       }
+      my $now = time;
       my %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc']);
       foreach my $server (keys(%dompersonnel)) {
           foreach my $user (sort(keys(%{$dompersonnel{$server}}))) {
               my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,$user);
-              if (!grep(/^$uname:$udom$/,@domcoord)) {
-                  push(@domcoord,$uname.':'.$udom);
+              my ($end,$start) = split(':',$dompersonnel{$server}{$user});
+              if (($end eq '') || ($end == 0) || ($end > $now)) {
+                  if ($start > $now) {
+                      if (!grep(/^\Q$uname\E:\Q$udom\E$/,@futuredomcoord)) {
+                          push(@futuredomcoord,$uname.':'.$udom);
+                      }
+                  } else {
+                      if (!grep(/^\Q$uname\E:\Q$udom\E$/,@domcoord)) {
+                          push(@domcoord,$uname.':'.$udom);
+                      }
+                  }
+              } else {
+                  if (!grep(/^\Q$uname\E:\Q$udom\E$/,@olddomcoord)) {
+                      push(@olddomcoord,$uname.':'.$udom);
+                  }
               }
           }
       }
@@ -565,7 +578,6 @@
       my %pname;
       my %notifystate;
       my %status;
-      my $now = time;
       foreach my $person (sort(keys(%coursepersonnel))) {
           my $match = 0;
           my ($role,$user,$usec) = ($person =~ /^([^:]+):([^:]+:[^:]+):([^:]*)/);
@@ -601,6 +613,7 @@
                                   usnm => 'username:domain',
                                   coac => 'Course Access',
                                   curn => 'Current notification status',
+                                  doms => 'Domain Coordinator status',
                                   notf => 'Notification?',
                                   ntac => 'Notification active',
                                   ntin => 'Notification inactive',
@@ -630,7 +643,7 @@
       if (grep(/^$viewer$/,@domcoord)) {
           $showalldc = 1;
       }
-      foreach my $dc (@domcoord) {
+      foreach my $dc (@domcoord,@futuredomcoord) {
           if (!grep(/^$dc$/,@ccs)) {
               if (grep(/^$dc$/,@notified)) {
                   $notifystate{$dc} = 1;
@@ -645,6 +658,16 @@
               push(@showdom,$dc);
           }
       }
+      foreach my $olddc (@olddomcoord) {
+          if (grep(/^$olddc$/,@notified)) {
+              if (!grep(/^\Q$olddc\E$/,@ccs)) {
+                  $notifystate{$olddc} = 1;
+                  my ($dcname,$dcdom) = split(/:/,$olddc);
+                  $pname{$olddc} =  &Apache::loncommon::plainname($dcname,$dcdom);
+                  push(@showdom,$olddc);
+              }
+          }
+      }
       my $showdomnum = scalar(@showdom);
       if ($showdomnum) {
           $r->print("
@@ -662,8 +685,8 @@
              </tr>
              <tr>
               <td>");
-          $r->print(&notifier_tables('dc',\%lt,\@showdom,\%status,\%notifystate,
-                                     \%pname,\$notifyshow));
+          $r->print(&notifier_tables('dc',\%lt,\@showdom,\%status,\%notifystate,\%pname,
+                                     \$notifyshow,\@olddomcoord,\@futuredomcoord));
           $r->print("
              </td>
           </tr>");
@@ -1230,12 +1253,15 @@
 }
 
 sub notifier_tables {
-    my ($role,$lt,$users,$status,$notifystate,$pname,$notifyshow) = @_;
+    my ($role,$lt,$users,$status,$notifystate,$pname,$notifyshow,$olddomcoord,
+        $futuredomcoord) = @_;
     my $output = &Apache::loncommon::start_data_table();
     $output .= &Apache::loncommon::start_data_table_header_row();
     $output .= "<th>$$lt{name}</th>
                 <th>$$lt{usnm}</th>";
-    if ($role eq 'cc') {
+    if ($role eq 'dc') {
+        $output .= "<th>$$lt{doms}</th>";
+    } elsif ($role eq 'cc') {
         $output .= "<th>$$lt{coac}</th>";
     } 
     $output .=  "<th>$$lt{curn}</th>
@@ -1246,7 +1272,19 @@
         $output .= '<td>'.$$pname{$$users[$i]}.'</td>'.
                    '<td><input type="hidden" name="notifyname_'.$$notifyshow.
                    '" value="'.$$users[$i].'" />'.$$users[$i].'</td>';
-        if ($role eq 'cc') {
+        if ($role eq 'dc') {
+            $output .= '<td>';
+            if ((ref($olddomcoord) eq 'ARRAY') && (ref($futuredomcoord) eq 'ARRAY')) {
+                if (grep(/^\Q$users->[$i]\E$/,@{$olddomcoord})) {
+                    $output .= &mt('expired');
+                } elsif (grep(/^\Q$users->[$i]\E$/,@{$futuredomcoord})) {
+                    $output .= &mt('future');
+                } else {
+                    $output .= &mt('active');
+                }
+            }
+            $output .= '</td>';
+        } elsif ($role eq 'cc') {
             $output .= '<td>'.$$status{$$users[$i]}.'</td>';
         }
         $output .= '<td>';