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

raeburn raeburn@source.lon-capa.org
Tue, 23 Mar 2010 20:06:04 -0000


This is a MIME encoded message

--raeburn1269374764
Content-Type: text/plain

raeburn		Tue Mar 23 20:06:04 2010 EDT

  Modified files:              (Branch: version_2_9_X)
    /loncom/interface	domainprefs.pm 
  Log:
  - Backport 1.130, 1.131, 1.132, 1.133.
  
  
--raeburn1269374764
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20100323200604.txt"

Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.102.2.11 loncom/interface/domainprefs.pm:1.102.2.12
--- loncom/interface/domainprefs.pm:1.102.2.11	Thu Mar 11 02:51:44 2010
+++ loncom/interface/domainprefs.pm	Tue Mar 23 20:06:04 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.102.2.11 2010/03/11 02:51:44 raeburn Exp $
+# $Id: domainprefs.pm,v 1.102.2.12 2010/03/23 20:06:04 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -234,7 +234,7 @@
                                   col2 => 'Value'}],
                     },
         'quotas' => 
-                    { text => 'User blogs, personal information pages and portfolios',
+                    { text => 'User blogs, personal information pages, portfolios',
                       help => 'Domain_Configuration_Quotas',
                       header => [{col1 => 'User affiliation',
                                   col2 => 'Available tools',
@@ -251,8 +251,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',
@@ -346,7 +348,7 @@
     my @actions = &Apache::loncommon::get_env_multiple('form.actions');
     &Apache::lonhtmlcommon::add_breadcrumb
     ({href=>"javascript:changePage(document.$phase,'pickactions')",
-      text=>"Pick functionality"});
+      text=>"Settings to display/modify"});
     my $confname = $dom.'-domainconfig';
     if ($phase eq 'process') {
         &Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,\@roles);
@@ -498,7 +500,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>
@@ -522,8 +535,7 @@
             <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>'.
-
+              <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td></tr>'.
                        &print_usermodification('bottom',$dom,$settings,\$rowtotal);
             $rowtotal ++;
         } elsif ($action eq 'coursecategories') {
@@ -1754,9 +1766,17 @@
                   $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',
+        my @fields = ('lastname','firstname','middlename','generation',
                       'permanentemail','id');
         my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
         my $numrows = 0;
@@ -2618,7 +2638,7 @@
                       '<span class="LC_nobreak">';
         if ($scantronurl) {
             $datatable .= '<a href="'.$scantronurl.'" target="_blank">'.
-                          &mt('Default scantron format file').'</a>';
+                          &mt('Default bubblesheet format file').'</a>';
         } else {
             $datatable = &mt('File unavailable for display');
         }
@@ -2645,7 +2665,7 @@
         } elsif ($scantronurl) {
             $datatable .= '<td><span class="LC_nobreak">'.
                           '<a href="'.$scantronurl.'" target="_blank">'.
-                          &mt('Custom scantron format file').'</a><label>'.
+                          &mt('Custom bubblesheet format file').'</a><label>'.
                           '<input type="checkbox" name="scantronformat_del"'.
                           '" value="1" />'.&mt('Delete?').'</label></span></td>'.
                           '<td><span class="LC_nobreak">&nbsp;'.
@@ -2674,7 +2694,7 @@
             &publishlogo($r,'copy',$legacyfile,$dom,$confname,'scantron',
                          '','',$newfile);
         if ($result ne 'ok') {
-            $error = &mt("An error occurred publishing the [_1] scantron format file in RES space. Error was: [_2].",$newfile,$result);
+            $error = &mt("An error occurred publishing the [_1] bubblesheet format file in RES space. Error was: [_2].",$newfile,$result);
         }
     }
     return ($url,$error);
@@ -3254,6 +3274,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') {
@@ -3290,10 +3311,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 {
@@ -4588,7 +4611,7 @@
                         lastname => 'Last Name',
                         firstname => 'First Name',
                         middlename => 'Middle Name',
-                        gen => 'Generation',
+                        generation => 'Generation',
                       );
     my $othertitle = &mt('All users');
     if (keys(%{$usertypes}) >  0) {
@@ -4596,13 +4619,35 @@
     }
     foreach my $key (keys(%env)) {
         if ($key =~ /^form\.updateable_(.+)_([^_]+)$/) {
-            push(@{$fields{$1}},$2);
+            my ($usertype,$item) = ($1,$2);
+            if (grep(/^\Q$item\E$/,keys(%fieldtitles))) {
+                if ($usertype eq 'default') {
+                    push(@{$fields{$1}},$2);
+                } elsif (ref($types) eq 'ARRAY') {
+                    if (grep(/^\Q$usertype\E$/,@{$types})) {
+                        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)) {
@@ -4620,9 +4665,11 @@
                         foreach my $type (@{$currautoupdate{$key}{$item}}) {
                             if (!exists($fields{$item})) {
                                 $change = 1;
+                                last;
                             } elsif (ref($fields{$item}) eq 'ARRAY') {
                                 if (!grep(/^\Q$type\E$/,@{$fields{$item}})) {
                                     $change = 1;
+                                    last;
                                 }
                             }
                         }
@@ -4632,12 +4679,41 @@
                     } 
                 }
             }
+        } 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') {
         if (defined($fields{$item})) {
             if (ref($currautoupdate{'fields'}) eq 'HASH') {
-                if (!exists($currautoupdate{'fields'}{$item})) {
+                if (ref($currautoupdate{'fields'}{$item}) eq 'ARRAY') {
+                    my $change = 0;
+                    if (ref($fields{$item}) eq 'ARRAY') {
+                        foreach my $type (@{$fields{$item}}) {
+                            if (!grep(/^\Q$type\E$/,@{$currautoupdate{'fields'}{$item}})) {
+                                $change = 1;
+                                last;
+                            }
+                        }
+                    }
+                    if ($change) {
+                        push(@{$changes{'fields'}},$item);
+                    }
+                } else {
                     push(@{$changes{'fields'}},$item);
                 }
             } else {
@@ -4651,7 +4727,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}}) {
@@ -5660,7 +5746,7 @@
         my $error;
         if ($configuserok eq 'ok') {
             if ($switchserver) {
-                $error = &mt("Upload of scantron format file is not permitted to this server: [_1]",$switchserver);
+                $error = &mt("Upload of bubblesheet format file is not permitted to this server: [_1]",$switchserver);
             } else {
                 if ($author_ok eq 'ok') {
                     my ($result,$scantronurl) =
@@ -5700,25 +5786,25 @@
                 if (ref($confhash{'scantron'}) eq 'HASH') {
                     $resulttext = &mt('Changes made:').'<ul>';
                     if ($confhash{'scantron'}{'scantronformat'} eq '') {
-                        $resulttext .= '<li>'.&mt('[_1] scantron format file removed; [_2] file will be used for courses in this domain.',$custom,$default).'</li>';
+                        $resulttext .= '<li>'.&mt('[_1] bubblesheet format file removed; [_2] file will be used for courses in this domain.',$custom,$default).'</li>';
                     } else {
-                        $resulttext .= '<li>'.&mt('Custom scantron format file ([_1]) uploaded for use with courses in this domain.',$custom).'</li>';
+                        $resulttext .= '<li>'.&mt('Custom bubblesheet format file ([_1]) uploaded for use with courses in this domain.',$custom).'</li>';
                     }
                     $resulttext .= '</ul>';
                 } else {
-                    $resulttext = &mt('Changes made to scantron format file.');
+                    $resulttext = &mt('Changes made to bubblesheet format file.');
                 }
                 $resulttext .= '</ul>';
                 &Apache::loncommon::devalidate_domconfig_cache($dom);
             } else {
-                $resulttext = &mt('No changes made to scantron format file');
+                $resulttext = &mt('No changes made to bubblesheet format file');
             }
         } else {
             $resulttext = '<span class="LC_error">'.
                 &mt('An error occurred: [_1]',$putresult).'</span>';
         }
     } else {
-        $resulttext = &mt('No changes made to scantron format file'); 
+        $resulttext = &mt('No changes made to bubblesheet format file'); 
     }
     if ($errors) {
         $resulttext .= &mt('The following errors occurred: ').'<ul>'.

--raeburn1269374764--