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

raeburn raeburn at source.lon-capa.org
Wed Apr 16 09:33:15 EDT 2014


raeburn		Wed Apr 16 13:33:15 2014 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	domainprefs.pm 
  Log:
  - For 2.11
    - Backport 1.235.
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.160.6.38 loncom/interface/domainprefs.pm:1.160.6.39
--- loncom/interface/domainprefs.pm:1.160.6.38	Sun Apr  6 00:25:26 2014
+++ loncom/interface/domainprefs.pm	Wed Apr 16 13:33:14 2014
@@ -1,8 +1,8 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.160.6.38 2014/04/06 00:25:26 raeburn Exp $
-#
+# $Id: domainprefs.pm,v 1.160.6.39 2014/04/16 13:33:14 raeburn Exp $
+##
 # Copyright Michigan State University Board of Trustees
 #
 # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
@@ -165,6 +165,7 @@
 use Apache::lonmsg();
 use Apache::lonconfigsettings;
 use Apache::lonuserutils();
+use Apache::loncoursequeueadmin();
 use LONCAPA qw(:DEFAULT :match);
 use LONCAPA::Enrollment;
 use LONCAPA::lonauthcgi();
@@ -365,7 +366,9 @@
                              {col1 => 'Setting',
                               col2 => 'Value'},
                              {col1 => 'Available textbooks',
-                              col2 => ''}],
+                              col2 => ''},
+                             {col1 => 'Validation (not official courses)',
+                              col2 => 'Value'},],
                   print => \&print_quotas,
                   modify => \&modify_quotas,
                  },
@@ -400,7 +403,7 @@
                   print => \&print_serverstatuses,
                   modify => \&modify_serverstatuses,
                  },
-        'coursedefaults' =>
+        'coursedefaults' => 
                  {text => 'Course/Community defaults',
                   help => 'Domain_Configuration_Course_Defaults',
                   header => [{col1 => 'Defaults which can be overridden in each course by a CC',
@@ -410,7 +413,7 @@
                   print => \&print_coursedefaults,
                   modify => \&modify_coursedefaults,
                  },
-        'selfenrollment' =>
+        'selfenrollment' => 
                  {text   => 'Self-enrollment in Course/Community',
                   help   => 'Domain_Configuration_Selfenrollment',
                   header => [{col1 => 'Configuration Rights',
@@ -735,7 +738,18 @@
              <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_textbookcourses($dom,$settings,\$rowtotal);
+                       &print_textbookcourses($dom,$settings,\$rowtotal).'
+            </table>
+           </td>
+          </tr>
+          <tr>
+           <td>
+            <table class="LC_nested">
+             <tr class="LC_info_row">
+              <td class="LC_left_item"'.$colspan.' valign="top">'.&mt($item->{'header'}->[3]->{'col1'}).'</td>
+              <td class="LC_right_item" valign="top">'.&mt($item->{'header'}->[3]->{'col2'}).'</td>
+             </tr>'.
+            &print_validation_rows('requestcourses',$dom,$settings,\$rowtotal);
         } elsif ($action eq 'requestauthor') {
             $output .= &print_requestmail($dom,$action,$settings,\$rowtotal);
         } elsif ($action eq 'rolecolors') {
@@ -1454,7 +1468,7 @@
     $datatable .= '<td class="LC_right_item">'.
                   '<table border="0"><tr>';
     foreach my $item (@{$links}) {
-	my $color = $designs->{'link'}{$item} ? $designs->{'link'}{$item} : $defaults->{'links'}{$item};
+	my $color = $designs->{'links'}{$item} ? $designs->{'links'}{$item} : $defaults->{'links'}{$item};
         $datatable .= '<td align="center">'.$choices->{$item}."\n";
         if ($designs->{'links'}{$item}) {
             $datatable.=' ';
@@ -2956,48 +2970,85 @@
             $datatable .= '</table></td></tr>';
         }
     } elsif ($position eq 'bottom') {
-        my ($itemsref,$namesref,$fieldsref) = &Apache::lonuserutils::selfenroll_validation_types();
-        my %currvalidation;
-        if (ref($settings) eq 'HASH') {
-            if (ref($settings->{'validation'}) eq 'HASH') {
-                %currvalidation = %{$settings->{'validation'}}; 
-            }
+        $datatable .= &print_validation_rows('selfenroll',$dom,$settings,\$itemcount);
+    }
+    $$rowtotal += $itemcount;
+    return $datatable;
+}
+
+sub print_validation_rows {
+    my ($caller,$dom,$settings,$rowtotal) = @_;
+    my ($itemsref,$namesref,$fieldsref);
+    if ($caller eq 'selfenroll') { 
+        ($itemsref,$namesref,$fieldsref) = &Apache::lonuserutils::selfenroll_validation_types();
+    } elsif ($caller eq 'requestcourses') {
+        ($itemsref,$namesref,$fieldsref) = &Apache::loncoursequeueadmin::requestcourses_validation_types();
+    }
+    my %currvalidation;
+    if (ref($settings) eq 'HASH') {
+        if (ref($settings->{'validation'}) eq 'HASH') {
+            %currvalidation = %{$settings->{'validation'}};
         }
-        foreach my $item (@{$itemsref}) {
-            $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
-            $datatable .= '<tr'.$css_class.'><td><span class="LC_nobreak">'.
-                          $namesref->{$item}.
-                          '</span></td>'.
-                          '<td class="LC_left_item">';
-            if (($item eq 'url') || ($item eq 'button')) {
-                $datatable .= '<span class="LC_nobreak">'.
-                              '<input type="text" name="selfenroll_validation_'.$item.'"'.
-                              ' value="'.$currvalidation{$item}.'" size="50" /></span>';
-            } elsif ($item eq 'fields') {
-                my @currfields;
-                if (ref($currvalidation{$item}) eq 'ARRAY') {
-                    @currfields = @{$currvalidation{$item}};
-                }
-                foreach my $field (@{$fieldsref}) {
-                    my $check = '';
-                    if (grep(/^\Q$field\E$/, at currfields)) {
-                        $check = ' checked="checked"';
-                    }
-                    $datatable .= '<span class="LC_nobreak"><label>'.
-                                  '<input type="checkbox" name="selfenroll_validation_fields"'.
-                                  ' value="'.$field.'"'.$check.' />'.$field.
-                                  '</label></span> ';
-                }
-            } elsif ($item eq 'markup') {
-                $datatable .= '<textarea name="selfenroll_validation_markup" cols="50" rows="5" wrap="soft">'.
-                              $currvalidation{$item}. 
+    }
+    my $datatable;
+    my $itemcount = 0;
+    foreach my $item (@{$itemsref}) {
+        my $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+        $datatable .= '<tr'.$css_class.'><td><span class="LC_nobreak">'.
+                      $namesref->{$item}.
+                      '</span></td>'.
+                      '<td class="LC_left_item">';
+        if (($item eq 'url') || ($item eq 'button')) {
+            $datatable .= '<span class="LC_nobreak">'.
+                          '<input type="text" name="'.$caller.'_validation_'.$item.'"'.
+                          ' value="'.$currvalidation{$item}.'" size="50" /></span>';
+        } elsif ($item eq 'fields') {
+            my @currfields;
+            if (ref($currvalidation{$item}) eq 'ARRAY') {
+                @currfields = @{$currvalidation{$item}};
+            }
+            foreach my $field (@{$fieldsref}) {
+                my $check = '';
+                if (grep(/^\Q$field\E$/, at currfields)) {
+                    $check = ' checked="checked"';
+                }
+                $datatable .= '<span class="LC_nobreak"><label>'.
+                              '<input type="checkbox" name="'.$caller.'_validation_fields"'.
+                              ' value="'.$field.'"'.$check.' />'.$field.
+                              '</label></span> ';
+            }
+        } elsif ($item eq 'markup') {
+            $datatable .= '<textarea name="'.$caller.'_validation_markup" cols="50" rows="5" wrap="soft">'.
+                           $currvalidation{$item}.
                               '</textarea>';
-            }
-            $datatable .= '</td></tr>'."\n";
+        }
+        $datatable .= '</td></tr>'."\n";
+        if (ref($rowtotal)) {
             $itemcount ++;
         }
     }
-    $$rowtotal += $itemcount;
+    if ($caller eq 'requestcourses') {
+        my %currhash;
+        if (ref($settings->{'validation'}) eq 'HASH') {
+            if ($settings->{'validation'}{'dc'} ne '') {
+                $currhash{$settings->{'validation'}{'dc'}} = 1;
+            }
+        }
+        my $numinrow = 2;
+        my ($numdc,$dctable,$rows) = &active_dc_picker($dom,$numinrow,'radio',
+                                                       'validationdc',%currhash);
+        if ($numdc > 1) {
+            $datatable .= '</td></tr><tr class="LC_odd_row"><td>'.
+                          &mt('Course creation processed as: (choose Dom. Coord.)').
+                          '</td><td class="LC_left_item">'.$dctable.'</td></tr>';
+        } else {
+            $datatable .= $dctable.'</td></tr>';
+        }
+        $itemcount ++;
+    }
+    if (ref($rowtotal)) {
+        $$rowtotal += $itemcount;
+    }
     return $datatable;
 }
 
@@ -3983,7 +4034,7 @@
         ($datatable,$itemcount) = &radiobutton_prefs(\%radiohash,\@toggles,\%defaultchecked,
                                                      \%choices,$itemcount,$onclick);
         $$rowtotal += $itemcount;
-
+        
         my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
 
         if (ref($usertypes) eq 'HASH') {
@@ -5086,7 +5137,7 @@
                     if ($statustype) {
                         if (ref($settings->{$context}->{$role}->{$statustype}) eq 'HASH') {
                             $hashref = $settings->{$context}->{$role}->{$statustype};
-                            if (ref($hashref) eq 'HASH') {
+                            if (ref($hashref) eq 'HASH') { 
                                 foreach my $field (@fields) {
                                     if ($hashref->{$field}) {
                                         $checks{$field} = $hashref->{$field};
@@ -5107,7 +5158,7 @@
             }
         }
     }
-
+     
     for (my $i=0; $i<@fields; $i++) {
         my $rem = $i%($numinrow);
         if ($rem == 0) {
@@ -5123,7 +5174,7 @@
             } else {
                 if ($role eq 'st') {
                     if (ref($settings) ne 'HASH') {
-                        $check = ' checked="checked" ';
+                        $check = ' checked="checked" '; 
                     }
                 }
             }
@@ -5751,22 +5802,38 @@
         }
         if ($role eq 'login') {
             foreach my $item (@logintext) {
-                unless ($env{'form.'.$role.'_'.$item} eq  $defaults{'logintext'}{$item}) {
+                $env{'form.'.$role.'_'.$item} = lc($env{'form.'.$role.'_'.$item});
+                if ($env{'form.'.$role.'_'.$item} =~ /^\w+/) {
+                    $env{'form.'.$role.'_'.$item} = '#'.$env{'form.'.$role.'_'.$item};
+                }
+                unless ($env{'form.'.$role.'_'.$item} eq lc($defaults{'logintext'}{$item})) {
                     $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
                 }
             }
         } else {
-            unless($env{'form.'.$role.'_fontmenu'} eq $defaults{'fontmenu'}) {
+            $env{'form.'.$role.'_fontmenu'} = lc($env{'form.'.$role.'_fontmenu'});
+            if ($env{'form.'.$role.'_fontmenu'} =~ /^\w+/) {
+                $env{'form.'.$role.'_fontmenu'} = '#'.$env{'form.'.$role.'_fontmenu'};
+            }
+            unless($env{'form.'.$role.'_fontmenu'} eq lc($defaults{'fontmenu'})) {
                 $confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'};
             }
         }
         foreach my $item (@bgs) {
-            unless ($env{'form.'.$role.'_'.$item} eq $defaults{'bgs'}{$item} ) {
+            $env{'form.'.$role.'_'.$item} = lc($env{'form.'.$role.'_'.$item});
+            if ($env{'form.'.$role.'_'.$item} =~ /^\w+/) {
+                $env{'form.'.$role.'_'.$item} = '#'.$env{'form.'.$role.'_'.$item};
+            }
+            unless ($env{'form.'.$role.'_'.$item} eq lc($defaults{'bgs'}{$item})) {
                 $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
             }
         }
         foreach my $item (@links) {
-            unless ($env{'form.'.$role.'_'.$item} eq  $defaults{'links'}{$item}) {
+            $env{'form.'.$role.'_'.$item} = lc($env{'form.'.$role.'_'.$item});
+            if ($env{'form.'.$role.'_'.$item} =~ /^\w+/) {
+                $env{'form.'.$role.'_'.$item} = '#'.$env{'form.'.$role.'_'.$item};
+            }
+            unless ($env{'form.'.$role.'_'.$item} eq lc($defaults{'links'}{$item})) {
                 $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
             }
         }
@@ -6388,7 +6455,8 @@
     my ($r,$dom,$action,$lastactref,%domconfig) = @_;
     my ($context, at usertools, at options,%validations,%titles,%confhash,%toolshash,
         %limithash,$toolregexp,%conditions,$resulttext,%changes,$confname,$configuserok,
-        $author_ok,$switchserver,$errors);
+        $author_ok,$switchserver,$errors,$validationitemsref,$validationnamesref,
+        $validationfieldsref);
     if ($action eq 'quotas') {
         $context = 'tools'; 
     } else {
@@ -6404,6 +6472,8 @@
         $confname = $dom.'-domainconfig';
         my $servadm = $r->dir_config('lonAdmEMail');
         ($configuserok,$author_ok,$switchserver) = &config_check($dom,$confname,$servadm);
+        ($validationitemsref,$validationnamesref,$validationfieldsref) = 
+            &Apache::loncoursequeueadmin::requestcourses_validation_types();
     } elsif ($context eq 'requestauthor') {
         @usertools = ('author');
         %titles = &authorrequest_titles();
@@ -6471,6 +6541,7 @@
                                '</span></li>';
                 }
             }
+
         }
         if (ref($domconfig{$action}) eq 'HASH') {
             if (ref($domconfig{$action}{'notify'}) eq 'HASH') {
@@ -6577,7 +6648,7 @@
                 }
                 if ($env{'form.addbook_image.filename'} ne '') {
                     my ($cdom,$cnum) = split(/_/,$newbook);
-                    my ($imageurl,$error) = 
+                    my ($imageurl,$error) =
                         &process_textbook_image($r,$dom,$confname,'addbook_image',$cdom,$cnum,$configuserok,
                                                 $switchserver,$author_ok);
                     if ($imageurl) {
@@ -6607,6 +6678,78 @@
                     }
                 }
             }
+            if (ref($validationitemsref) eq 'ARRAY') {
+                foreach my $item (@{$validationitemsref}) {
+                    if ($item eq 'fields') {
+                        my @changed;
+                        @{$confhash{'validation'}{$item}} = &Apache::loncommon::get_env_multiple('form.requestcourses_validation_'.$item);
+                        if (@{$confhash{'validation'}{$item}} > 0) {
+                            @{$confhash{'validation'}{$item}} = sort(@{$confhash{'validation'}{$item}});
+                        }
+                        if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
+                            if (ref($domconfig{'requestcourses'}{'validation'}{$item}) eq 'ARRAY') {
+                                @changed = &Apache::loncommon::compare_arrays($confhash{'validation'}{$item},
+                                                                              $domconfig{'requestcourses'}{'validation'}{$item});
+                            } else {
+                                @changed = @{$confhash{'validation'}{$item}};
+                            }
+                        } else {
+                            @changed = @{$confhash{'validation'}{$item}};
+                        }
+                        if (@changed) {
+                            if ($confhash{'validation'}{$item}) {
+                                $changes{'validation'}{$item} = join(', ',@{$confhash{'validation'}{$item}});
+                            } else {
+                                $changes{'validation'}{$item} = &mt('None');
+                            }
+                        }
+                    } else {
+                        $confhash{'validation'}{$item} = $env{'form.requestcourses_validation_'.$item};
+                        if ($item eq 'markup') {
+                            if ($env{'form.requestcourses_validation_'.$item}) {
+                                $env{'form.requestcourses_validation_'.$item} =~ s/[\n\r\f]+/\s/gs;
+                            }
+                        }
+                        if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
+                            if ($domconfig{'requestcourses'}{'validation'}{$item} ne $confhash{'validation'}{$item}) {
+                                $changes{'validation'}{$item} = $confhash{'validation'}{$item};
+                            }
+                        } else {
+                            if ($confhash{'validation'}{$item} ne '') {
+                                $changes{'validation'}{$item} = $confhash{'validation'}{$item};
+                            }
+                        }
+                    }
+                }
+            }
+            if ($env{'form.validationdc'}) {
+                my $newval = $env{'form.validationdc'};
+                my %domcoords = &get_active_dcs($dom);
+                if (exists($domcoords{$newval})) {
+                    $confhash{'validation'}{'dc'} = $newval;
+                }
+            }
+            if (ref($confhash{'validation'}) eq 'HASH') {
+                if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
+                    if ($domconfig{'requestcourses'}{'validation'}{'dc'}) {
+                        unless ($confhash{'validation'}{'dc'} eq $domconfig{'requestcourses'}{'validation'}{'dc'}) {
+                            if ($confhash{'validation'}{'dc'} eq '') {
+                                $changes{'validation'}{'dc'} = &mt('None');
+                            } else {
+                                $changes{'validation'}{'dc'} = $confhash{'validation'}{'dc'};
+                            }
+                        }
+                    } elsif ($confhash{'validation'}{'dc'} ne '') {
+                        $changes{'validation'}{'dc'} = $confhash{'validation'}{'dc'};
+                    }
+                } elsif ($confhash{'validation'}{'dc'} ne '') {
+                    $changes{'validation'}{'dc'} = $confhash{'validation'}{'dc'};
+                }
+            } elsif (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
+                if ($domconfig{'requestcourses'}{'validation'}{'dc'}) {
+                    $changes{'validation'}{'dc'} = &mt('None');
+                }
+            }
         }
     } else {
         $confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'};
@@ -6922,6 +7065,26 @@
                     }
                     $resulttext .= '</ul></li>';
                 }
+                if (ref($changes{'validation'}) eq 'HASH') {
+                    if ((ref($validationitemsref) eq 'ARRAY') && (ref($validationnamesref) eq 'HASH')) {
+                        $resulttext .= '<li>'.&mt('Validation of courses/communities updated').'<ul>';
+                        foreach my $item (@{$validationitemsref}) {
+                            if (exists($changes{'validation'}{$item})) {
+                                if ($item eq 'markup') {
+                                    $resulttext .= '<li>'.&mt('[_1] set to: [_2]',$validationnamesref->{$item},
+                                                              '<br /><pre>'.$changes{'validation'}{$item}.'</pre>').'</li>';
+                                } else {
+                                    $resulttext .= '<li>'.&mt('[_1] set to: [_2]',$validationnamesref->{$item},
+                                                              '<b>'.$changes{'validation'}{$item}.'</b>').'</li>';
+                                }
+                            }
+                        }
+                        if (exists($changes{'validation'}{'dc'})) {
+                            $resulttext .= '<li>'.&mt('Validated course requests identified as processed by: [_1]',
+                                                     '<b>'.$changes{'validation'}{'dc'}.'</b>').'</li>';
+                        }
+                    }
+                }
             }
             $resulttext .= '</ul>';
             if (keys(%newenv)) {
@@ -10107,7 +10270,7 @@
 
 sub active_dc_picker {
     my ($dom,$numinrow,$inputtype,$name,%currhash) = @_;
-    my %domcoords = &get_active_dcs($dom); 
+    my %domcoords = &get_active_dcs($dom);
     my @domcoord = keys(%domcoords);
     if (keys(%currhash)) {
         foreach my $dc (keys(%currhash)) {


More information about the LON-CAPA-cvs mailing list