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

raeburn raeburn@source.lon-capa.org
Mon, 08 Mar 2010 14:36:25 -0000


raeburn		Mon Mar  8 14:36:25 2010 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm 
  Log:
  - Co-owners.
     - Additional on/off configuration item for auto-enroll: co-owners.
       used to activate auto-assignment of institutionally-validated
       co-owners for official courses when a CC role is added, or a 
       CC role is revoked.
     - Default is "off".
  
  
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.128 loncom/interface/domainprefs.pm:1.129
--- loncom/interface/domainprefs.pm:1.128	Wed Mar  3 16:43:41 2010
+++ loncom/interface/domainprefs.pm	Mon Mar  8 14:36:24 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.128 2010/03/03 16:43:41 raeburn Exp $
+# $Id: domainprefs.pm,v 1.129 2010/03/08 14:36:24 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1692,7 +1692,7 @@
 sub print_autoenroll {
     my ($dom,$settings,$rowtotal) = @_;
     my $autorun = &Apache::lonnet::auto_run(undef,$dom),
-    my ($defdom,$runon,$runoff);
+    my ($defdom,$runon,$runoff,$coownerson,$coownersoff);
     if (ref($settings) eq 'HASH') {
         if (exists($settings->{'run'})) {
             if ($settings->{'run'} eq '0') {
@@ -1711,6 +1711,18 @@
                 $runon = ' ';
             }
         }
+        if (exists($settings->{'co-owners'})) {
+            if ($settings->{'co-owners'} eq '0') {
+                $coownersoff = ' checked="checked" ';
+                $coownerson = ' ';
+            } else {
+                $coownerson = ' checked="checked" ';
+                $coownersoff = ' ';
+            }
+        } else {
+            $coownersoff = ' checked="checked" ';
+            $coownerson = ' ';
+        }
         if (exists($settings->{'sender_domain'})) {
             $defdom = $settings->{'sender_domain'};
         }
@@ -1741,8 +1753,16 @@
                   &mt('username').': '.
                   '<input type="text" name="sender_uname" value="'.
                   $notif_sender.'" size="10" />&nbsp;&nbsp;'.&mt('domain').
-                  ':&nbsp;'.$domform.'</span></td></tr>';
-    $$rowtotal += 2;
+                  ':&nbsp;'.$domform.'</span></td></tr>'.
+                  '<tr class="LC_odd_row">'.
+                  '<td>'.&mt('Automatically assign co-ownership').'</td>'.
+                  '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
+                  '<input type="radio" name="autoassign_coowners"'.
+                  $coownerson.' value="1" />'.&mt('Yes').'</label>&nbsp;'.
+                  '<label><input type="radio" name="autoassign_coowners"'.
+                  $coownersoff.' value="0" />'.&mt('No').'</label></span></td>'.
+                  '</tr>';
+    $$rowtotal += 3;
     return $datatable;
 }
 
@@ -4635,7 +4655,8 @@
     }
     my $autorun = &Apache::lonnet::auto_run(undef,$dom),
     my %title = ( run => 'Auto-enrollment active',
-                  sender => 'Sender for notification messages');
+                  sender => 'Sender for notification messages',
+                  coowners => 'Automatic assignment of co-ownership to instructors of record (institutional data)');
     my @offon = ('off','on');
     my $sender_uname = $env{'form.sender_uname'};
     my $sender_domain = $env{'form.sender_domain'};
@@ -4644,11 +4665,12 @@
     } elsif ($sender_uname eq '') {
         $sender_domain = '';
     }
+    my $coowners = $env{'form.autoassign_coowners'};
     my %autoenrollhash =  (
-                       autoenroll => { run => $env{'form.autoenroll_run'},
-                                       sender_uname => $sender_uname,
-                                       sender_domain => $sender_domain,
-
+                       autoenroll => { 'run' => $env{'form.autoenroll_run'},
+                                       'sender_uname' => $sender_uname,
+                                       'sender_domain' => $sender_domain,
+                                       'co-owners' => $coowners,
                                 }
                      );
     my $putresult = &Apache::lonnet::put_dom('configuration',\%autoenrollhash,
@@ -4669,6 +4691,13 @@
         if ($currautoenroll{'sender_domain'} ne $sender_domain) {
             $changes{'sender'} = 1;
         }
+        if ($currautoenroll{'co-owners'} ne '') {
+            if ($currautoenroll{'co-owners'} ne $coowners) {
+                $changes{'coowners'} = 1;
+            }
+        } elsif ($coowners) {
+            $changes{'coowners'} = 1;
+        }      
         if (keys(%changes) > 0) {
             $resulttext = &mt('Changes made:').'<ul>';
             if ($changes{'run'}) {
@@ -4681,6 +4710,10 @@
                     $resulttext .= '<li>'.&mt("$title{'sender'} set to [_1]",$sender_uname.':'.$sender_domain).'</li>';
                 }
             }
+            if ($changes{'coowners'}) {
+                $resulttext .= '<li>'.&mt("$title{'coowners'} set to $offon[$env{'form.autoassign_coowners'}]").'</li>';
+                &Apache::loncommon::devalidate_domconfig_cache($dom);
+            }
             $resulttext .= '</ul>';
         } else {
             $resulttext = &mt('No changes made to auto-enrollment settings');