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

raeburn raeburn@source.lon-capa.org
Fri, 12 Mar 2010 15:01:36 -0000


raeburn		Fri Mar 12 15:01:36 2010 EDT

  Modified files:              
    /loncom/interface	domainprefs.pm 
  Log:
  - Wording change - fix typo: "Updataeable" -> "Updateable"
  - In &insttypes_row(), add a new row for default type, if all columns
    used in row for non-default types.
  - Additional setting for Auto-updates.
    - Can allow user's to opt out of automatic name changes via a user preference
      for specified institutional affiliations.  
  
  
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.130 loncom/interface/domainprefs.pm:1.131
--- loncom/interface/domainprefs.pm:1.130	Thu Mar 11 21:18:24 2010
+++ loncom/interface/domainprefs.pm	Fri Mar 12 15:01:36 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.130 2010/03/11 21:18:24 raeburn Exp $
+# $Id: domainprefs.pm,v 1.131 2010/03/12 15:01:36 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -253,8 +253,10 @@
                      help => 'Domain_Configuration_Auto_Updates',
                      header => [{col1 => 'Setting',
                                  col2 => 'Value',},
+                                {col1 => 'Setting',
+                                 col2 => 'Affiliation'},
                                 {col1 => 'User population',
-                                 col2 => 'Updataeable user data'}],
+                                 col2 => 'Updateable user data'}],
                   },
         'autocreate' => 
                   { text => 'Auto-course creation settings',
@@ -518,7 +520,18 @@
              </tr>';
             $rowtotal ++;
         if ($action eq 'autoupdate') {
-            $output .= &print_autoupdate('bottom',$dom,$settings,\$rowtotal);
+            $output .= &print_autoupdate('middle',$dom,$settings,\$rowtotal).'
+           </table>
+          </td>
+         </tr>
+         <tr>
+           <td>
+            <table class="LC_nested">
+             <tr class="LC_info_row">
+              <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
+              <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>      </tr>'.
+            &print_autoupdate('bottom',$dom,$settings,\$rowtotal);
+            $rowtotal ++;
         } elsif ($action eq 'usercreation') {
             $output .= &print_usercreation('middle',$dom,$settings,\$rowtotal).'
            </table>
@@ -543,7 +556,6 @@
              <tr class="LC_info_row">
               <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
               <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>      </tr>'.
-
                        &print_usermodification('bottom',$dom,$settings,\$rowtotal);
             $rowtotal ++;
         } elsif ($action eq 'coursecategories') {
@@ -1803,6 +1815,14 @@
                   $classlistsoff.'value="0" />'.&mt('No').'</label></span></td>'.
                   '</tr>';
         $$rowtotal += 2;
+    } elsif ($position eq 'middle') {
+        my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+        my $numinrow = 3;
+        my $locknamesettings;
+        $datatable .= &insttypes_row($settings,$types,$usertypes,
+                                     $dom,$numinrow,$othertitle,
+                                    'lockablenames');
+        $$rowtotal ++;
     } else {
         my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
         my @fields = ('lastname','firstname','middlename','gen',
@@ -3397,6 +3417,7 @@
     my %lt = &Apache::lonlocal::texthash (
                       cansearch => 'Users allowed to search',
                       statustocreate => 'Institutional affiliation(s) able to create own account (login/SSO)',
+                      lockablenames => 'User preference to lock name',
              );
     my $showdom;
     if ($context eq 'cansearch') {
@@ -3433,10 +3454,12 @@
                            $usertypes->{$types->[$i]}.'</label></span></td>';
             }
         }
-       
         $rem = @{$types}%($numinrow);
     }
     my $colsleft = $numinrow - $rem;
+    if (($rem == 0) && (@{$types} > 0)) {
+        $output .= '<tr>';
+    }
     if ($colsleft > 1) {
         $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">';
     } else {
@@ -4755,10 +4778,23 @@
             push(@{$fields{$1}},$2);
         }
     }
+    my @lockablenames = &Apache::loncommon::get_env_multiple('form.lockablenames');
+    @lockablenames = sort(@lockablenames);
+    if (ref($currautoupdate{'lockablenames'}) eq 'ARRAY') {
+        my @changed = &Apache::loncommon::compare_arrays($currautoupdate{'lockablenames'},\@lockablenames);
+        if (@changed) {
+            $changes{'lockablenames'} = 1;
+        }
+    } else {
+        if (@lockablenames) {
+            $changes{'lockablenames'} = 1;
+        }
+    }
     my %updatehash = (
                       autoupdate => { run => $env{'form.autoupdate_run'},
                                       classlists => $env{'form.classlists'},
                                       fields => {%fields},
+                                      lockablenames => \@lockablenames,
                                     }
                      );
     foreach my $key (keys(%currautoupdate)) {
@@ -4788,6 +4824,22 @@
                     } 
                 }
             }
+        } elsif ($key eq 'lockablenames') {
+            if (ref($currautoupdate{$key}) eq 'ARRAY') {
+                my @changed = &Apache::loncommon::compare_arrays($currautoupdate{'lockablenames'},\@lockablenames);
+                if (@changed) {
+                    $changes{'lockablenames'} = 1;
+                }
+            } else {
+                if (@lockablenames) {
+                    $changes{'lockablenames'} = 1;
+                }
+            }
+        }
+    }
+    unless (grep(/^\Qlockablenames\E$/,keys(%currautoupdate))) {
+        if (@lockablenames) {
+            $changes{'lockablenames'} = 1;
         }
     }
     foreach my $item (@{$types},'default') {
@@ -4807,7 +4859,17 @@
         if (keys(%changes) > 0) {
             $resulttext = &mt('Changes made:').'<ul>';
             foreach my $key (sort(keys(%changes))) {
-                if (ref($changes{$key}) eq 'ARRAY') {
+                if ($key eq 'lockablenames') {
+                    $resulttext .= '<li>';
+                    if (@lockablenames) {
+                        $usertypes->{'default'} = $othertitle;
+                        $resulttext .= &mt("User preference to disable replacement of user's name with institutional data (by auto-update), available for the following affiliations:").' '.
+                                   join(', ', map { $usertypes->{$_}; } @lockablenames).'</li>';
+                    } else {
+                        $resulttext .= &mt("User preference to disable replacement of user's name with institutional data (by auto-update) is unavailable.");
+                    }
+                    $resulttext .= '</li>';
+                } elsif (ref($changes{$key}) eq 'ARRAY') {
                     foreach my $item (@{$changes{$key}}) {
                         my @newvalues;
                         foreach my $type (@{$fields{$item}}) {