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

raeburn raeburn@source.lon-capa.org
Sun, 23 Aug 2009 12:40:51 -0000


This is a MIME encoded message

--raeburn1251031251
Content-Type: text/plain

raeburn		Sun Aug 23 12:40:51 2009 EDT

  Modified files:              (Branch: version_2_9_X)
    /loncom/interface	domainprefs.pm 
  Log:
  - Backport 1.103, 1.104, 1.105, 1.106, 1.108.
  
  
--raeburn1251031251
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20090823124051.txt"

Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.102.2.1 loncom/interface/domainprefs.pm:1.102.2.2
--- loncom/interface/domainprefs.pm:1.102.2.1	Thu Aug 13 20:38:45 2009
+++ loncom/interface/domainprefs.pm	Sun Aug 23 12:40:50 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.102.2.1 2009/08/13 20:38:45 raeburn Exp $
+# $Id: domainprefs.pm,v 1.102.2.2 2009/08/23 12:40:50 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -105,7 +105,7 @@
 (official, unofficial and community).  In each case the radio buttons allow the 
 selection of one of four values:
 
-0, approve, validate, autolimit=N (where N is blank, or a positive integer).
+0, approval, validate, autolimit=N (where N is blank, or a positive integer).
 which have the following effects:
 
 0
@@ -116,7 +116,7 @@
 
 =back
 
-approve 
+approval 
 
 =over 
 
@@ -1126,7 +1126,7 @@
     my ($css_class,%titles);
     if ($context eq 'requestcourses') {
         @usertools = ('official','unofficial','community');
-        @options =('norequest','approve','autolimit','validate');
+        @options =('norequest','approval','autolimit','validate');
         %validations = &Apache::lonnet::auto_courserequest_checks($dom);
         %titles = &courserequest_titles();
     } else {
@@ -1199,7 +1199,10 @@
                             if ($option eq 'autolimit') {
                                 $cell{$item} .= '<input type="text" name="crsreq_'.
                                                 $item.'_limit_'.$type.'" size="1" '.
-                                                'value="'.$currlimit.'" />'; 
+                                                'value="'.$currlimit.'" />';
+                            }
+                            if ($option eq 'autolimit') {
+                                $cell{$item} .= $titles{'unlimited'};
                             }
                             $cell{$item} .= '</span>&nbsp; ';
                         }
@@ -1223,7 +1226,7 @@
                 if ($context eq 'requestcourses') {
                     $datatable .= '</tr><tr>';
                     foreach my $item (@usertools) {
-                        $datatable .= '<td>'.$cell{$item}.'</td>';  
+                        $datatable .= '<td style="vertical-align: top;">'.$cell{$item}.'</td>';  
                     }
                     $datatable .= '</tr></table>';
                 }
@@ -1305,6 +1308,9 @@
                                        'value="'.$currlimit.'" />';
                 }
                 $defcell{$item} .= '</span>&nbsp; ';
+                if ($option eq 'autolimit') {
+                    $defcell{$item} .= $titles{'unlimited'};
+                }
             }
         } else {
             my $checked = 'checked="checked" ';
@@ -1326,7 +1332,7 @@
     if ($context eq 'requestcourses') {
         $datatable .= '</tr><tr>';
         foreach my $item (@usertools) {
-            $datatable .= '<td>'.$defcell{$item}.'</td>';
+            $datatable .= '<td style="vertical-align: top;">'.$defcell{$item}.'</td>';
         }
         $datatable .= '</tr></table>';
     }
@@ -1340,10 +1346,13 @@
     $typecount ++;
     $css_class = $typecount%2?' class="LC_odd_row"':'';
     $datatable .= '<tr'.$css_class.'>'.
-                  '<td>'.&mt('LON-CAPA Advanced Users').
-                  ' <span class="LC_nobreak">('.
-                  &mt('overrides affiliation').')</span></td>'.
-                  '<td class="LC_left_item" colspan="2">';
+                  '<td>'.&mt('LON-CAPA Advanced Users').' ';
+    if ($context eq 'requestcourses') {
+        $datatable .= &mt('(overrides affiliation, if set)');
+    } else {
+        $datatable .= &mt('(overrides affiliation, if checked)');
+    }
+    $datatable .= '</td>'.
     if ($context eq 'requestcourses') {
         $datatable .= '<table><tr>';
     } else {
@@ -1365,6 +1374,14 @@
                 $curroption = 'norequest';
             }
             $datatable .= '<th>'.$titles{$item}.'</th>';
+            my $checked = '';
+            if ($curroption eq '') {
+                $checked = ' checked="checked"';
+            }
+            $advcell{$item} .= '<span class="LC_nobreak"><label>'.
+                               '<input type="radio" name="crsreq_'.$item.
+                               '__LC_adv" value=""'.$checked.' />'.
+                               &mt('No override set').'</label></span>&nbsp; ';
             foreach my $option (@options) {
                 my $val = $option;
                 if ($option eq 'norequest') {
@@ -1380,7 +1397,7 @@
                     next if (!$canvalidate);
                 }
                 my $checked = '';
-                if ($option eq $curroption) {
+                if ($val eq $curroption) {
                     $checked = ' checked="checked"';
                 } elsif ($option eq 'autolimit') {
                     if ($curroption =~ /^autolimit/) {
@@ -1397,6 +1414,9 @@
                                        'value="'.$currlimit.'" />';
                 }
                 $advcell{$item} .= '</span>&nbsp; ';
+                if ($option eq 'autolimit') {
+                    $advcell{$item} .= $titles{'unlimited'};
+                }
             }
         } else {
             my $checked = 'checked="checked" ';
@@ -1418,7 +1438,7 @@
     if ($context eq 'requestcourses') {
         $datatable .= '</tr><tr>';
         foreach my $item (@usertools) {
-            $datatable .= '<td>'.$advcell{$item}.'</td>';
+            $datatable .= '<td style="vertical-align: top;">'.$advcell{$item}.'</td>';
         }
         $datatable .= '</tr></table>';
     }
@@ -1429,7 +1449,7 @@
 
 sub print_courserequestmail {
     my ($dom,$settings,$rowtotal) = @_;
-    my ($now,$datatable,%dompersonnel,@domcoord,@currapprove,$rows);
+    my ($now,$datatable,%dompersonnel,@domcoord,@currapproval,$rows);
     $now = time;
     $rows = 0;
     %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc'],$now,$now);
@@ -1444,12 +1464,12 @@
     if (ref($settings) eq 'HASH') {
         if (ref($settings->{'notify'}) eq 'HASH') {
             if ($settings->{'notify'}{'approval'} ne '') {
-               @currapprove = split(',',$settings->{'notify'}{'approval'});
+               @currapproval = split(',',$settings->{'notify'}{'approval'});
             }
         }
     }
-    if (@currapprove) {
-        foreach my $dc (@currapprove) {
+    if (@currapproval) {
+        foreach my $dc (@currapproval) {
             unless (grep(/^\Q$dc\E$/,@domcoord)) {
                 push(@domcoord,$dc);
             }
@@ -1475,7 +1495,7 @@
                 $rows ++;
             }
             my $check = ' ';
-            if (grep(/^\Q$domcoord[$i]\E$/,@currapprove)) {
+            if (grep(/^\Q$domcoord[$i]\E$/,@currapproval)) {
                 $check = ' checked="checked" ';
             }
             my ($uname,$udom) = split(':',$domcoord[$i]);
@@ -1846,16 +1866,17 @@
                                    unofficial => 'Unofficial',
                                    community  => 'Communities',
                                    norequest  => 'Not allowed',
-                                   approve    => 'Approval by Dom. Coord.',
+                                   approval   => 'Approval by Dom. Coord.',
                                    validate   => 'With validation',
                                    autolimit  => 'Numerical limit',
+                                   unlimited  => '(blank for unlimited)',
                  );
     return %titles;
 }
 
 sub courserequest_conditions {
     my %conditions = &Apache::lonlocal::texthash (
-       approve    => '(Processing of request subject to approval by Domain Coordinator).',
+       approval   => '(Processing of request subject to approval by Domain Coordinator).',
        validate   => '(Processing of request subject to instittutional validation).',
                  );
     return %conditions;
@@ -3735,7 +3756,7 @@
     }
     if ($context eq 'requestcourses') {
         @usertools = ('official','unofficial','community');
-        @options =('norequest','approve','autolimit','validate');
+        @options =('norequest','approval','autolimit','validate');
         %validations = &Apache::lonnet::auto_courserequest_checks($dom);
         %titles = &courserequest_titles();
         $toolregexp = join('|',@usertools);
@@ -3790,7 +3811,12 @@
     }
     foreach my $item (@usertools) {
         foreach my $type (@{$types},'default','_LC_adv') {
+            my $unset;
             if ($context eq 'requestcourses') {
+                $unset = '0';
+                if ($type eq '_LC_adv') {
+                    $unset = '';
+                }
                 if ($confhash{$item}{$type} eq 'autolimit') {
                     $confhash{$item}{$type} .= '=';
                     unless ($limithash{$item}{$type} =~ /\D/) {
@@ -3811,7 +3837,7 @@
                     }
                 } else {
                     if ($context eq 'requestcourses') {
-                        if ($confhash{$item}{$type} ne 'norequest') {
+                        if ($confhash{$item}{$type} ne $unset) {
                             $changes{$item}{$type} = 1;
                         }
                     } else {
@@ -3822,7 +3848,7 @@
                 }
             } else {
                 if ($context eq 'requestcourses') {
-                    if ($confhash{$item}{$type} eq 'norequest') {
+                    if ($confhash{$item}{$type} ne $unset) {
                         $changes{$item}{$type} = 1;
                     }
                 } else {
@@ -3914,8 +3940,8 @@
                                                           $env{'user.domain'},
                                                           $item,'reload',$context);
                     if ($context eq 'requestcourses') {
-                        if ($env{'environment.crsrequest.'.$item} ne $newacc) {
-                            $newenv{'environment.crsrequest.'.$item} = $newacc;
+                        if ($env{'environment.canrequest.'.$item} ne $newacc) {
+                            $newenv{'environment.canrequest.'.$item} = $newacc;
                         }
                     } else {
                         if ($env{'environment.availabletools.'.$item} ne $newacc) { 
@@ -3948,7 +3974,15 @@
                                     $resulttext .= '<li>'.&mt('Set to be available to [_1]',$typetitle).'</li>';
                                 }
                             } else {
-                                $resulttext .= '<li>'.&mt('Set to be unavailable to [_1]',$typetitle).'</li>';
+                                if ($type eq '_LC_adv') {
+                                    if ($confhash{$item}{$type} eq '0') {
+                                        $resulttext .= '<li>'.&mt('Set to be unavailable to [_1]',$typetitle).'</li>';
+                                    } else { 
+                                        $resulttext .= '<li>'.&mt('No override set for [_1]',$typetitle).'</li>';
+                                    }
+                                } else {
+                                    $resulttext .= '<li>'.&mt('Set to be unavailable to [_1]',$typetitle).'</li>';
+                                }
                             }
                         }
                     }
@@ -4496,6 +4530,8 @@
         if (@{$types} > 0) {
             @{$cancreate{'statustocreate'}} = 
                 &Apache::loncommon::get_env_multiple('form.statustocreate');
+        } else {
+            @{$cancreate{'statustocreate'}} = ();
         }
         push(@contexts,'statustocreate');
     }
@@ -4504,9 +4540,11 @@
             if (($item eq 'selfcreate') || ($item eq 'statustocreate')) {
                 if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') {
                     foreach my $curr (@{$curr_usercreation{'cancreate'}{$item}}) {
-                        if (!grep(/^$curr$/,@{$cancreate{$item}})) {
-                            if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
-                                push(@{$changes{'cancreate'}},$item);
+                        if (ref($cancreate{$item}) eq 'ARRAY') {
+                            if (!grep(/^$curr$/,@{$cancreate{$item}})) {
+                                if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
+                                    push(@{$changes{'cancreate'}},$item);
+                                }
                             }
                         }
                     }
@@ -4975,8 +5013,10 @@
             if ($newvalues{$item} ne '') {
                 if ($newvalues{$item} =~ /^(\w+)/) {
                     my $langcode = $1;
-                    if (code2language($langcode) eq '') {
-                        push(@errors,$item);
+                    if ($langcode ne 'x_chef') {
+                        if (code2language($langcode) eq '') {
+                            push(@errors,$item);
+                        }
                     }
                 } else {
                     push(@errors,$item);

--raeburn1251031251--