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

raeburn raeburn@source.lon-capa.org
Tue, 11 Aug 2009 23:24:29 -0000


This is a MIME encoded message

--raeburn1250033069
Content-Type: text/plain

raeburn		Tue Aug 11 23:24:29 2009 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm 
  Log:
  - Configure which active Domain Coordinators receive a notification when a course request is made which requires approval. (Will also be notified when a DC approves or rejects the request).
  - Configure e-mail addresses to receive e-mail when a course request is made which requires approval.
  
  
--raeburn1250033069
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20090811232429.txt"

Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.101 loncom/interface/domainprefs.pm:1.102
--- loncom/interface/domainprefs.pm:1.101	Sat Aug  8 00:36:00 2009
+++ loncom/interface/domainprefs.pm	Tue Aug 11 23:24:29 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.101 2009/08/08 00:36:00 raeburn Exp $
+# $Id: domainprefs.pm,v 1.102 2009/08/11 23:24:29 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -297,7 +297,9 @@
                  {text => 'Request creation of courses',
                   help => 'Domain_Configuration_Request_Courses',
                   header => [{col1 => 'User affiliation',
-                              col2 => 'Availability/Processing of requests',}],
+                              col2 => 'Availability/Processing of requests',},
+                             {col1 => 'Setting',
+                              col2 => 'Value'}],
                  },
         'coursecategories' =>
                   { text => 'Cataloging of courses',
@@ -423,7 +425,7 @@
     $rowtotal ++;
     if (($action eq 'autoupdate') || ($action eq 'rolecolors') || 
         ($action eq 'usercreation') || ($action eq 'usermodification') ||
-        ($action eq 'coursecategories')) {
+        ($action eq 'coursecategories') || ($action eq 'requestcourses')) {
         my $colspan = '';
         if (($action eq 'rolecolors') || ($action eq 'coursecategories')) {
             $colspan = ' colspan="2"';
@@ -445,6 +447,8 @@
             $output .= &print_usermodification('top',$dom,$settings,\$rowtotal);
         } elsif ($action eq 'coursecategories') {
             $output .= &print_coursecategories('top',$dom,$item,$settings,\$rowtotal);
+        } elsif ($action eq 'requestcourses') {
+            $output .= &print_quotas($dom,$settings,\$rowtotal,$action);
         } else {
             $output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
         }
@@ -492,6 +496,8 @@
             $rowtotal ++;
         } elsif ($action eq 'coursecategories') {
             $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);
+        } elsif ($action eq 'requestcourses') {
+            $output .= &print_courserequestmail($dom,$settings,\$rowtotal);
         } else {
             $output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
            </table>
@@ -575,8 +581,6 @@
             $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
         } elsif ($action eq 'serverstatuses') {
             $output .= &print_serverstatuses($dom,$settings,\$rowtotal);
-        } elsif ($action eq 'requestcourses') {
-            $output .= &print_quotas($dom,$settings,\$rowtotal,$action);
         }
     }
     $output .= '
@@ -1446,6 +1450,84 @@
     return $datatable;
 }
 
+sub print_courserequestmail {
+    my ($dom,$settings,$rowtotal) = @_;
+    my ($now,$datatable,%dompersonnel,@domcoord,@currapprove,$rows);
+    $now = time;
+    $rows = 0;
+    %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc'],$now,$now);
+    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);
+            }
+        }
+    }
+    if (ref($settings) eq 'HASH') {
+        if (ref($settings->{'notify'}) eq 'HASH') {
+            if ($settings->{'notify'}{'approval'} ne '') {
+               @currapprove = split(',',$settings->{'notify'}{'approval'});
+            }
+        }
+    }
+    if (@currapprove) {
+        foreach my $dc (@currapprove) {
+            unless (grep(/^\Q$dc\E$/,@domcoord)) {
+                push(@domcoord,$dc);
+            }
+        }
+    }
+    @domcoord = sort(@domcoord);
+    my $numinrow = 4;
+    my $numdc = @domcoord;
+    my $css_class = 'class="LC_odd_row"';
+    $datatable = '<tr'.$css_class.'>'.
+                 ' <td>'.&mt('Receive notification of course requests requiring approval.').
+                 ' </td>'.
+                 ' <td class="LC_left_item">';
+    if (@domcoord > 0) {
+        $datatable .= '<table>';
+        for (my $i=0; $i<$numdc; $i++) {
+            my $rem = $i%($numinrow);
+            if ($rem == 0) {
+                if ($i > 0) {
+                    $datatable .= '</tr>';
+                }
+                $datatable .= '<tr>';
+                $rows ++;
+            }
+            my $check = ' ';
+            if (grep(/^\Q$domcoord[$i]\E$/,@currapprove)) {
+                $check = ' checked="checked" ';
+            }
+            my ($uname,$udom) = split(':',$domcoord[$i]);
+            my $fullname = &Apache::loncommon::plainname($uname,$udom);
+            if ($i == $numdc-1) {
+                my $colsleft = $numinrow-$rem;
+                if ($colsleft > 1) {
+                    $datatable .= '<td colspan="'.$colsleft.'" class="LC_left_item">';
+                } else {
+                    $datatable .= '<td class="LC_left_item">';
+                }
+            } else {
+                $datatable .= '<td class="LC_left_item">';
+            }
+            $datatable .= '<span class="LC_nobreak"><label>'.
+                          '<input type="checkbox" name="reqapprovalnotify" '.
+                          'value="'.$domcoord[$i].'"'.$check.'/>'.
+                          $fullname.'</label></span></td>';
+        }
+        $datatable .= '</tr></table>';
+    } else {
+        $datatable .= &mt('There are no active Domain Coordinators');
+        $rows ++;
+    }
+    $datatable .='</td></tr>';
+    $$rowtotal += $rows;
+    return $datatable;
+}
+
 sub print_autoenroll {
     my ($dom,$settings,$rowtotal) = @_;
     my $autorun = &Apache::lonnet::auto_run(undef,$dom),
@@ -1682,7 +1764,8 @@
     my $datatable;
     my @contacts = ('adminemail','supportemail');
     my (%checked,%to,%otheremails);
-    my @mailings = ('errormail','packagesmail','lonstatusmail','helpdeskmail');
+    my @mailings = ('errormail','packagesmail','lonstatusmail','helpdeskmail',
+                    'requestsmail');
     foreach my $type (@mailings) {
         $otheremails{$type} = '';
     }
@@ -1713,6 +1796,7 @@
         $checked{'packagesmail'}{'adminemail'} = ' checked="checked" ';
         $checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" ';
         $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" '; 
+        $checked{'requestsmail'}{'adminemail'} = ' checked="checked" ';
     }
     my ($titles,$short_titles) = &contact_titles();
     my $rownum = 0;
@@ -1758,6 +1842,7 @@
                    'packagesmail' => 'Package update alerts to be e-mailed to',
                    'helpdeskmail' => 'Helpdesk requests to be e-mailed to',
                    'lonstatusmail' => 'E-mail from nightly status check (warnings/errors)',
+                   'requestsmail' => 'E-mail from course requests requiring approval',
                  );
     my %short_titles = &Apache::lonlocal::texthash (
                            adminemail   => 'Admin E-mail address',
@@ -3715,7 +3800,26 @@
             }
         }
     }
-    unless ($context eq 'requestcourses') {
+    if ($context eq 'requestcourses') {
+        my @approvalnotify = &Apache::loncommon::get_env_multiple('form.reqapprovalnotify');
+        @approvalnotify = sort(@approvalnotify);
+        $confhash{'notify'}{'approval'} = join(',',@approvalnotify);
+        if (ref($domconfig{$action}) eq 'HASH') {
+            if (ref($domconfig{$action}{'notify'}) eq 'HASH') {
+                if ($domconfig{$action}{'notify'}{'approval'} ne $confhash{'notify'}{'approval'}) {
+                    $changes{'notify'}{'approval'} = 1;
+                }
+            } else {
+                if ($domconfig{$action}{'notify'}{'approval'}) {
+                    $changes{'notify'}{'approval'} = 1;
+                }
+            }
+        } else {
+            if ($domconfig{$action}{'notify'}{'approval'}) {
+                $changes{'notify'}{'approval'} = 1;
+            }
+        }
+    } else {
         $confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'};
     }
     foreach my $item (@usertools) {
@@ -3885,6 +3989,19 @@
                     $resulttext .= '</ul></li>';
                 }
             }
+            if ($action eq 'requestcourses') {
+                if (ref($changes{'notify'}) eq 'HASH') {
+                    if ($changes{'notify'}{'approval'}) {
+                        if (ref($confhash{'notify'}) eq 'HASH') {
+                            if ($confhash{'notify'}{'approval'}) {
+                                $resulttext .= '<li>'.&mt('Notification of requests requiring approval will be sent to: ').$confhash{'notify'}{'approval'}.'</li>';
+                            } else {
+                                $resulttext .= '<li>'.&mt('No Domain Coordinators will receive notification of course requests requiring approval.').'</li>';
+                            }
+                        }
+                    }
+                }
+            }
             $resulttext .= '</ul>';
             if (keys(%newenv)) {
                 &Apache::lonnet::appenv(\%newenv);
@@ -4277,7 +4394,8 @@
     }
     my (%others,%to);
     my @contacts = ('supportemail','adminemail');
-    my @mailings = ('errormail','packagesmail','helpdeskmail','lonstatusmail');
+    my @mailings = ('errormail','packagesmail','helpdeskmail','lonstatusmail',
+                    'requestsmail');
     foreach my $type (@mailings) {
         @{$newsetting{$type}} = 
             &Apache::loncommon::get_env_multiple('form.'.$type);
@@ -4323,6 +4441,7 @@
         $default{'packagesmail'} = 'adminemail';
         $default{'helpdeskmail'} = 'supportemail';
         $default{'lonstatusmail'} = 'adminemail';
+        $default{'requestsmail'} = 'adminemail';
         foreach my $item (@contacts) {
            if ($to{$item} ne $default{$item}) {
               $changes{$item} = 1;

--raeburn1250033069--