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

raeburn raeburn at source.lon-capa.org
Thu Nov 17 08:12:40 EST 2022


raeburn		Thu Nov 17 13:12:40 2022 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm 
  Log:
  - Domin config for which DCs should be notified of role requests for users in
    domain for whom roles assigned in other domains require DC authorization.
  
  
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.416 loncom/interface/domainprefs.pm:1.417
--- loncom/interface/domainprefs.pm:1.416	Fri Nov 11 02:30:19 2022
+++ loncom/interface/domainprefs.pm	Thu Nov 17 13:12:40 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.416 2022/11/11 02:30:19 raeburn Exp $
+# $Id: domainprefs.pm,v 1.417 2022/11/17 13:12:40 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -7714,7 +7714,9 @@
     my ($position,$dom,$settings,$rowtotal) = @_;
     my ($datatable,$css_class,$numinrow, at items,%names,$othertitle,$usertypes,$types);
     my $itemcount = 0;
-    unless ($position eq 'top') {
+    if ($position eq 'top') {
+        $numinrow = 2;
+    } else {
         @items = ('domain','author','course','community');
         %names = &Apache::lonlocal::texthash (
                      domain => 'Assigned domain role(s)',
@@ -7739,6 +7741,7 @@
                 auto   => 'Unrestricted',
                 instdom => 'Other domain shares institution/provider',
                 extdom => 'Other domain has different institution/provider',
+                notify => 'Receive notification of role requests requiring DC authorization',
             );
             my %names = &Apache::lonlocal::texthash (
                 domain => 'Domain role',
@@ -7790,6 +7793,28 @@
                 $datatable .= '</td></tr>';
                 $itemcount ++;
             }
+            $css_class = $itemcount%2?' class="LC_odd_row"':'';
+            $datatable .= '<tr'.$css_class.'><td>'.$titles{'notify'}.'</td>'.
+                          '<td class="LC_left_item">';
+            if ((@instdoms > 1) || (keys(%by_location) > 0)) {
+                my %curr;
+                if (ref($settings) eq 'HASH') {
+                    if ($settings->{'notify'} ne '') {
+                        map {$curr{$_}=1;} split(/,/,$settings->{'notify'});
+                    }
+                }
+                $css_class = $itemcount%2?' class="LC_odd_row"':'';
+                my ($numdc,$table,$rows) = &active_dc_picker($dom,$numinrow,'checkbox',
+                                                             'privacy_notify',%curr);
+                if ($numdc > 0) {
+                    $datatable .= $table;
+                } else {
+                    $datatable .= &mt('There are no active Domain Coordinators');
+                }
+            } else {
+                $datatable .= &mt('Nothing to set here, as there are no other domains');
+            }
+            $datatable .='</td></tr>';
         } elsif ($position eq 'middle') {
             if ((@instdoms > 1) || (keys(%by_location) > 0)) {
                 if ((ref($types) eq 'ARRAY') && (ref($usertypes) eq 'HASH')) {
@@ -17969,6 +17994,7 @@
                   user     => 'User authorizes',
                   domain   => 'Domain Coordinator authorizes',
                   auto     => 'Unrestricted',
+                  notify   => 'Receive notification of role requests requiring DC authorization',
     );
     my %fieldnames = &Apache::lonlocal::texthash (
                         id => 'Student/Employee ID',
@@ -18086,6 +18112,18 @@
                 }
             }
         }
+        my %domcoords = &Apache::lonnet::get_active_domroles($dom,['dc']);
+        my %notify;
+        foreach my $possdc (&Apache::loncommon::get_env_multiple('form.privacy_notify')) {
+            if (exists($domcoords{$possdc})) {
+                $notify{$possdc} = 1;
+            }
+        }
+        my $notify = join(',',sort(keys(%notify)));
+        if ($current{'notify'} ne $notify) {
+            $changes{'notify'} = 1;
+        }
+        $privacyhash{'notify'} = $notify;
     }
     my %confighash = (
                         privacy => \%privacyhash,
@@ -18094,7 +18132,7 @@
     if ($putresult eq 'ok') {
         if (keys(%changes) > 0) {
             $resulttext = &mt('Changes made: ').'<ul>';
-            foreach my $key ('approval','othdom','priv','unpriv') {
+            foreach my $key ('approval','notify','othdom','priv','unpriv') {
                 if ($changes{$key}) {
                     $resulttext .= '<li>'.$titles{$key}.':<ul>';
                     if ($key eq 'approval') {
@@ -18112,6 +18150,15 @@
                             }
                             $resulttext .= '</ul></li>';
                         }
+                    } elsif ($key eq 'notify') {
+                        if ($privacyhash{$key}) {
+                            foreach my $dc (split(/,/,$privacyhash{$key})) {
+                                my ($dcname,$dcdom) = split(/:/,$dc);
+                                $resulttext .= '<li>'.&Apache::loncommon::plainname($dcname,$dcdom).'</li>';
+                            }
+                        } else {
+                            $resulttext .= '<li>'.&mt('No DCs to notify').'</li>';
+                        }
                     } elsif ($key eq 'othdom') {
                         my @statuses;
                         if (ref($types) eq 'ARRAY') {




More information about the LON-CAPA-cvs mailing list