Diff for /loncom/interface/domainprefs.pm between versions 1.160.6.39 and 1.231

version 1.160.6.39, 2014/04/16 13:33:14 version 1.231, 2014/03/29 20:35:21
Line 2 Line 2
 # Handler to set domain-wide configuration settings  # Handler to set domain-wide configuration settings
 #  #
 # $Id$  # $Id$
 ##  #
 # Copyright Michigan State University Board of Trustees  # Copyright Michigan State University Board of Trustees
 #  #
 # This file is part of the LearningOnline Network with CAPA (LON-CAPA).  # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
Line 164  use Apache::lonhtmlcommon(); Line 164  use Apache::lonhtmlcommon();
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonmsg();  use Apache::lonmsg();
 use Apache::lonconfigsettings;  use Apache::lonconfigsettings;
 use Apache::lonuserutils();  
 use Apache::loncoursequeueadmin();  
 use LONCAPA qw(:DEFAULT :match);  use LONCAPA qw(:DEFAULT :match);
 use LONCAPA::Enrollment;  use LONCAPA::Enrollment;
 use LONCAPA::lonauthcgi();  use LONCAPA::lonauthcgi();
Line 213  sub handler { Line 211  sub handler {
                 'quotas','autoenroll','autoupdate','autocreate',                  'quotas','autoenroll','autoupdate','autocreate',
                 'directorysrch','usercreation','usermodification',                  'directorysrch','usercreation','usermodification',
                 'contacts','defaults','scantron','coursecategories',                  'contacts','defaults','scantron','coursecategories',
                 'serverstatuses','requestcourses','coursedefaults',                  'serverstatuses','requestcourses','helpsettings',
                 'usersessions','loadbalancing','requestauthor',                  'coursedefaults','usersessions','loadbalancing',
                 'selfenrollment'],$dom);                  'requestauthor','selfenrollment'],$dom);
     my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',      my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
                        'autoupdate','autocreate','directorysrch','contacts',                         'autoupdate','autocreate','directorysrch','contacts',
                        'usercreation','selfcreation','usermodification','scantron',                         'usercreation','selfcreation','usermodification','scantron',
                        'requestcourses','requestauthor','coursecategories',                         'requestcourses','requestauthor','coursecategories',
                        'serverstatuses','coursedefaults','selfenrollment',                         'serverstatuses','helpsettings',
                        'usersessions');                         'coursedefaults','selfenrollment','usersessions');
     my %existing;      my %existing;
     if (ref($domconfig{'loadbalancing'}) eq 'HASH') {      if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
         %existing = %{$domconfig{'loadbalancing'}};          %existing = %{$domconfig{'loadbalancing'}};
Line 366  sub handler { Line 364  sub handler {
                              {col1 => 'Setting',                               {col1 => 'Setting',
                               col2 => 'Value'},                                col2 => 'Value'},
                              {col1 => 'Available textbooks',                               {col1 => 'Available textbooks',
                               col2 => ''},                                col2 => ''}],
                              {col1 => 'Validation (not official courses)',  
                               col2 => 'Value'},],  
                   print => \&print_quotas,                    print => \&print_quotas,
                   modify => \&modify_quotas,                    modify => \&modify_quotas,
                  },                   },
Line 403  sub handler { Line 399  sub handler {
                   print => \&print_serverstatuses,                    print => \&print_serverstatuses,
                   modify => \&modify_serverstatuses,                    modify => \&modify_serverstatuses,
                  },                   },
           'helpsettings' =>
                    {text   => 'Help page settings',
                     help   => 'Domain_Configuration_Help_Settings',
                     header => [{col1 => 'Help Settings (logged-in users)',
                                 col2 => 'Value'}],
                     print  => \&print_helpsettings,
                     modify => \&modify_helpsettings,
                    },
         'coursedefaults' =>           'coursedefaults' => 
                  {text => 'Course/Community defaults',                   {text => 'Course/Community defaults',
                   help => 'Domain_Configuration_Course_Defaults',                    help => 'Domain_Configuration_Course_Defaults',
Line 425  sub handler { Line 429  sub handler {
                   print => \&print_selfenrollment,                    print => \&print_selfenrollment,
                   modify => \&modify_selfenrollment,                    modify => \&modify_selfenrollment,
                  },                   },
           'privacy' => 
                    {text   => 'User Privacy',
                     help   => 'Domain_Configuration_User_Privacy',
                     header => [{col1 => 'Setting',
                                 col2 => 'Value',}],
                     print => \&print_privacy,
                     modify => \&modify_privacy,
                    },
         'usersessions' =>          'usersessions' =>
                  {text  => 'User session hosting/offloading',                   {text  => 'User session hosting/offloading',
                   help  => 'Domain_Configuration_User_Sessions',                    help  => 'Domain_Configuration_User_Sessions',
Line 609  sub process_changes { Line 621  sub process_changes {
         $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig);          $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig);
     } elsif ($action eq 'requestauthor') {      } elsif ($action eq 'requestauthor') {
         $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig);          $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig);
       } elsif ($action eq 'helpsettings') {
           $output = &modify_helpsettings($r,$dom,$confname,%domconfig);
     } elsif ($action eq 'coursedefaults') {      } elsif ($action eq 'coursedefaults') {
         $output = &modify_coursedefaults($dom,$lastactref,%domconfig);          $output = &modify_coursedefaults($dom,$lastactref,%domconfig);
     } elsif ($action eq 'selfenrollment') {      } elsif ($action eq 'selfenrollment') {
Line 660  sub print_config_box { Line 674  sub print_config_box {
              </tr>';               </tr>';
         $rowtotal ++;          $rowtotal ++;
         if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') ||          if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') ||
             ($action eq 'usermodification') || ($action eq 'selfenrollment') ||              ($action eq 'usermodification') || ($action eq 'coursedefaults') ||
             ($action eq 'usersessions')) {              ($action eq 'selfenrollment') || ($action eq 'usersessions')) {
             $output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal);              $output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal);
         } elsif ($action eq 'coursecategories') {          } elsif ($action eq 'coursecategories') {
             $output .= $item->{'print'}->('top',$dom,$item,$settings,\$rowtotal);              $output .= $item->{'print'}->('top',$dom,$item,$settings,\$rowtotal);
Line 738  sub print_config_box { Line 752  sub print_config_box {
              <tr class="LC_info_row">               <tr class="LC_info_row">
               <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td>                <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_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') {          } elsif ($action eq 'requestauthor') {
             $output .= &print_requestmail($dom,$action,$settings,\$rowtotal);              $output .= &print_requestmail($dom,$action,$settings,\$rowtotal);
         } elsif ($action eq 'rolecolors') {          } elsif ($action eq 'rolecolors') {
Line 1468  sub display_color_options { Line 1471  sub display_color_options {
     $datatable .= '<td class="LC_right_item">'.      $datatable .= '<td class="LC_right_item">'.
                   '<table border="0"><tr>';                    '<table border="0"><tr>';
     foreach my $item (@{$links}) {      foreach my $item (@{$links}) {
  my $color = $designs->{'links'}{$item} ? $designs->{'links'}{$item} : $defaults->{'links'}{$item};   my $color = $designs->{'link'}{$item} ? $designs->{'link'}{$item} : $defaults->{'links'}{$item};
         $datatable .= '<td align="center">'.$choices->{$item}."\n";          $datatable .= '<td align="center">'.$choices->{$item}."\n";
         if ($designs->{'links'}{$item}) {          if ($designs->{'links'}{$item}) {
             $datatable.='&nbsp;';              $datatable.='&nbsp;';
Line 2836  sub print_selfenrollment { Line 2839  sub print_selfenrollment {
     my $itemcount = 1;      my $itemcount = 1;
     my @types = ('official','unofficial','community','textbook');      my @types = ('official','unofficial','community','textbook');
     if (($position eq 'top') || ($position eq 'middle')) {      if (($position eq 'top') || ($position eq 'middle')) {
         my ($rowsref,$titlesref) = &Apache::lonuserutils::get_selfenroll_titles();          my ($rowsref,$titlesref) = &get_selfenroll_titles();
         my %descs = &Apache::lonuserutils::selfenroll_default_descs();          my %descs = &selfenroll_default_descs();
         my @rows;          my @rows;
         my $key;          my $key;
         if ($position eq 'top') {          if ($position eq 'top') {
Line 2970  sub print_selfenrollment { Line 2973  sub print_selfenrollment {
             $datatable .= '</table></td></tr>';              $datatable .= '</table></td></tr>';
         }          }
     } elsif ($position eq 'bottom') {      } elsif ($position eq 'bottom') {
         $datatable .= &print_validation_rows('selfenroll',$dom,$settings,\$itemcount);          my ($itemsref,$namesref,$fieldsref) = &selfenroll_validation_types();
     }          my %currvalidation;
     $$rowtotal += $itemcount;          if (ref($settings) eq 'HASH') {
     return $datatable;              if (ref($settings->{'validation'}) eq 'HASH') {
 }                  %currvalidation = %{$settings->{'validation'}}; 
               }
 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}) {
     my $datatable;              $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
     my $itemcount = 0;              $datatable .= '<tr'.$css_class.'><td><span class="LC_nobreak">'.
     foreach my $item (@{$itemsref}) {                            $namesref->{$item}.
         my $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';                            '</span></td>'.
         $datatable .= '<tr'.$css_class.'><td><span class="LC_nobreak">'.                            '<td class="LC_left_item">';
                       $namesref->{$item}.              if (($item eq 'url') || ($item eq 'button')) {
                       '</span></td>'.                  $datatable .= '<span class="LC_nobreak">'.
                       '<td class="LC_left_item">';                                '<input type="text" name="selfenroll_validation_'.$item.'"'.
         if (($item eq 'url') || ($item eq 'button')) {                                ' value="'.$currvalidation{$item}.'" size="50" /></span>';
             $datatable .= '<span class="LC_nobreak">'.              } elsif ($item eq 'fields') {
                           '<input type="text" name="'.$caller.'_validation_'.$item.'"'.                  my @currfields;
                           ' value="'.$currvalidation{$item}.'" size="50" /></span>';                  if (ref($currvalidation{$item}) eq 'ARRAY') {
         } elsif ($item eq 'fields') {                      @currfields = @{$currvalidation{$item}};
             my @currfields;                  }
             if (ref($currvalidation{$item}) eq 'ARRAY') {                  foreach my $field (@{$fieldsref}) {
                 @currfields = @{$currvalidation{$item}};                      my $check = '';
             }                      if (grep(/^\Q$field\E$/,@currfields)) {
             foreach my $field (@{$fieldsref}) {                          $check = ' checked="checked"';
                 my $check = '';                      }
                 if (grep(/^\Q$field\E$/,@currfields)) {                      $datatable .= '<span class="LC_nobreak"><label>'.
                     $check = ' checked="checked"';                                    '<input type="checkbox" name="selfenroll_validation_fields"'.
                 }                                    ' value="'.$field.'"'.$check.' />'.$field.
                 $datatable .= '<span class="LC_nobreak"><label>'.                                    '</label></span> ';
                               '<input type="checkbox" name="'.$caller.'_validation_fields"'.                  }
                               ' value="'.$field.'"'.$check.' />'.$field.              } elsif ($item eq 'markup') {
                               '</label></span> ';                  $datatable .= '<textarea name="selfenroll_validation_markup" cols="50" rows="5" wrap="soft">'.
             }                                $currvalidation{$item}. 
         } elsif ($item eq 'markup') {  
             $datatable .= '<textarea name="'.$caller.'_validation_markup" cols="50" rows="5" wrap="soft">'.  
                            $currvalidation{$item}.  
                               '</textarea>';                                '</textarea>';
         }              }
         $datatable .= '</td></tr>'."\n";              $datatable .= '</td></tr>'."\n";
         if (ref($rowtotal)) {  
             $itemcount ++;              $itemcount ++;
         }          }
     }      }
     if ($caller eq 'requestcourses') {      $$rowtotal += $itemcount;
         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;      return $datatable;
 }  }
   
   sub get_selfenroll_titles {
       my @row = ('types','registered','enroll_dates','access_dates','section',
                  'approval','limit');
       my %lt = &Apache::lonlocal::texthash (
                   types        => 'Users allowed to self-enroll',
                   registered   => 'Registration status (official courses)' ,
                   enroll_dates => 'Dates self-enrollment available',
                   access_dates => 'Access dates for self-enrolling users',
                   section      => 'Self-enrolling users section',
                   approval     => 'Processing of requests',
                   limit        => 'Enrollment limit',
                );
       return (\@row,\%lt);
   }
   
   sub selfenroll_default_descs {
       my %desc = (
                    types => {
                               dom => &mt('Course domain'),
                               all => &mt('Any domain'),
                               ''  => &mt('None'),
                             },
                    limit => {
                               none         => &mt('No limit'),
                               allstudents  => &mt('Limit by total students'),
                               selfenrolled => &mt('Limit by total self-enrolled'),
                             },
                    approval => {
                                   '0' => &mt('Processed automatically'),
                                   '1' => &mt('Queued for approval'),
                                   '2' => &mt('Queued, pending validation'),
                                },
                    registered => {
                                    0 => 'No registration required',
                                    1 => 'Registered students only',
                                  },
                  );
       return %desc;
   }
   
   sub selfenroll_validation_types {
       my @items = ('url','fields','button','markup');
       my %names =  &Apache::lonlocal::texthash (
               url      => 'Web address of validation server/script',
               fields   => 'Form fields to send to validator',
               button   => 'Text for validation button',
               markup   => 'Validation description (HTML)',
       );
       my @fields = ('username','domain','uniquecode','course','token');
       return (\@items,\%names,\@fields);
   }  
   
 sub print_usersessions {  sub print_usersessions {
     my ($position,$dom,$settings,$rowtotal) = @_;      my ($position,$dom,$settings,$rowtotal) = @_;
     my ($css_class,$datatable,%checked,%choices);      my ($css_class,$datatable,%checked,%choices);
Line 5802  sub modify_colors { Line 5820  sub modify_colors {
         }          }
         if ($role eq 'login') {          if ($role eq 'login') {
             foreach my $item (@logintext) {              foreach my $item (@logintext) {
                 $env{'form.'.$role.'_'.$item} = lc($env{'form.'.$role.'_'.$item});                  unless ($env{'form.'.$role.'_'.$item} eq  $defaults{'logintext'}{$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};                      $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
                 }                  }
             }              }
         } else {          } else {
             $env{'form.'.$role.'_fontmenu'} = lc($env{'form.'.$role.'_fontmenu'});              unless($env{'form.'.$role.'_fontmenu'} eq $defaults{'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'};                  $confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'};
             }              }
         }          }
         foreach my $item (@bgs) {          foreach my $item (@bgs) {
             $env{'form.'.$role.'_'.$item} = lc($env{'form.'.$role.'_'.$item});              unless ($env{'form.'.$role.'_'.$item} eq $defaults{'bgs'}{$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};                  $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
             }              }
         }          }
         foreach my $item (@links) {          foreach my $item (@links) {
             $env{'form.'.$role.'_'.$item} = lc($env{'form.'.$role.'_'.$item});              unless ($env{'form.'.$role.'_'.$item} eq  $defaults{'links'}{$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};                  $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
             }              }
         }          }
Line 6455  sub modify_quotas { Line 6457  sub modify_quotas {
     my ($r,$dom,$action,$lastactref,%domconfig) = @_;      my ($r,$dom,$action,$lastactref,%domconfig) = @_;
     my ($context,@usertools,@options,%validations,%titles,%confhash,%toolshash,      my ($context,@usertools,@options,%validations,%titles,%confhash,%toolshash,
         %limithash,$toolregexp,%conditions,$resulttext,%changes,$confname,$configuserok,          %limithash,$toolregexp,%conditions,$resulttext,%changes,$confname,$configuserok,
         $author_ok,$switchserver,$errors,$validationitemsref,$validationnamesref,          $author_ok,$switchserver,$errors);
         $validationfieldsref);  
     if ($action eq 'quotas') {      if ($action eq 'quotas') {
         $context = 'tools';           $context = 'tools'; 
     } else {      } else {
Line 6472  sub modify_quotas { Line 6473  sub modify_quotas {
         $confname = $dom.'-domainconfig';          $confname = $dom.'-domainconfig';
         my $servadm = $r->dir_config('lonAdmEMail');          my $servadm = $r->dir_config('lonAdmEMail');
         ($configuserok,$author_ok,$switchserver) = &config_check($dom,$confname,$servadm);          ($configuserok,$author_ok,$switchserver) = &config_check($dom,$confname,$servadm);
         ($validationitemsref,$validationnamesref,$validationfieldsref) =   
             &Apache::loncoursequeueadmin::requestcourses_validation_types();  
     } elsif ($context eq 'requestauthor') {      } elsif ($context eq 'requestauthor') {
         @usertools = ('author');          @usertools = ('author');
         %titles = &authorrequest_titles();          %titles = &authorrequest_titles();
Line 6541  sub modify_quotas { Line 6540  sub modify_quotas {
                                '</span></li>';                                 '</span></li>';
                 }                  }
             }              }
   
         }          }
         if (ref($domconfig{$action}) eq 'HASH') {          if (ref($domconfig{$action}) eq 'HASH') {
             if (ref($domconfig{$action}{'notify'}) eq 'HASH') {              if (ref($domconfig{$action}{'notify'}) eq 'HASH') {
Line 6648  sub modify_quotas { Line 6646  sub modify_quotas {
                 }                  }
                 if ($env{'form.addbook_image.filename'} ne '') {                  if ($env{'form.addbook_image.filename'} ne '') {
                     my ($cdom,$cnum) = split(/_/,$newbook);                      my ($cdom,$cnum) = split(/_/,$newbook);
                     my ($imageurl,$error) =                      my ($imageurl,$error) = 
                         &process_textbook_image($r,$dom,$confname,'addbook_image',$cdom,$cnum,$configuserok,                          &process_textbook_image($r,$dom,$confname,'addbook_image',$cdom,$cnum,$configuserok,
                                                 $switchserver,$author_ok);                                                  $switchserver,$author_ok);
                     if ($imageurl) {                      if ($imageurl) {
Line 6678  sub modify_quotas { Line 6676  sub modify_quotas {
                     }                      }
                 }                  }
             }              }
             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 {      } else {
         $confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'};          $confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'};
Line 7065  sub modify_quotas { Line 6991  sub modify_quotas {
                     }                      }
                     $resulttext .= '</ul></li>';                      $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>';              $resulttext .= '</ul>';
             if (keys(%newenv)) {              if (keys(%newenv)) {
Line 9504  sub modify_selfenrollment { Line 9410  sub modify_selfenrollment {
     my ($resulttext,$errors,%changes,%selfenrollhash,%ordered);      my ($resulttext,$errors,%changes,%selfenrollhash,%ordered);
     my @types = ('official','unofficial','community','textbook');      my @types = ('official','unofficial','community','textbook');
     my %titles = &tool_titles();      my %titles = &tool_titles();
     my %descs = &Apache::lonuserutils::selfenroll_default_descs();      my %descs = &selfenroll_default_descs();
     ($ordered{'admin'},my $titlesref) = &Apache::lonuserutils::get_selfenroll_titles();      ($ordered{'admin'},my $titlesref) = &get_selfenroll_titles();
     $ordered{'default'} = ['types','registered','approval','limit'];      $ordered{'default'} = ['types','registered','approval','limit'];
   
     my (%roles,%shown,%toplevel);      my (%roles,%shown,%toplevel);
Line 9521  sub modify_selfenrollment { Line 9427  sub modify_selfenrollment {
                   default    => 'Default settings',                    default    => 'Default settings',
                   validation => 'Validation of self-enrollment requests',                    validation => 'Validation of self-enrollment requests',
                 );                  );
     my ($itemsref,$namesref,$fieldsref) = &Apache::lonuserutils::selfenroll_validation_types();      my ($itemsref,$namesref,$fieldsref) = &selfenroll_validation_types();
   
     if (ref($ordered{'admin'}) eq 'ARRAY') {      if (ref($ordered{'admin'}) eq 'ARRAY') {
         foreach my $item (@{$ordered{'admin'}}) {          foreach my $item (@{$ordered{'admin'}}) {
Line 9671  sub modify_selfenrollment { Line 9577  sub modify_selfenrollment {
                                 $roles{'1'} = &mt('Course personnel');                                  $roles{'1'} = &mt('Course personnel');
                             }                              }
                             if (ref($changes{$key}{$type}) eq 'ARRAY') {                              if (ref($changes{$key}{$type}) eq 'ARRAY') {
                                 if (ref($selfenrollhash{$key}{$type}) eq 'HASH') {  
                                     if ($key eq 'admin') {  
                                         my @mgrdc = ();  
                                         if (ref($ordered{$key}) eq 'ARRAY') {  
                                             foreach my $item (@{$ordered{'admin'}}) {  
                                                 if (ref($selfenrollhash{$key}{$type}) eq 'HASH') {   
                                                     if ($selfenrollhash{$key}{$type}{$item} eq '0') {  
                                                         push(@mgrdc,$item);  
                                                     }  
                                                 }  
                                             }  
                                             if (@mgrdc) {  
                                                 $domdefaults{$type.'selfenrolladmdc'} = join(',',@mgrdc);  
                                             } else {  
                                                 delete($domdefaults{$type.'selfenrolladmdc'});  
                                             }  
                                         }  
                                     } else {  
                                         if (ref($ordered{$key}) eq 'ARRAY') {  
                                             foreach my $item (@{$ordered{$key}}) {  
                                                 if (grep(/^\Q$item\E$/,@{$changes{$key}{$type}})) {  
                                                     $domdefaults{$type.'selfenroll'.$item} =  
                                                         $selfenrollhash{$key}{$type}{$item};  
                                                 }  
                                             }  
                                         }  
                                     }  
                                 }  
                                 $resulttext .= '<li>'.$titles{$type}.'<ul>';                                  $resulttext .= '<li>'.$titles{$type}.'<ul>';
                                 foreach my $item (@{$ordered{$key}}) {                                  foreach my $item (@{$ordered{$key}}) {
                                     if (grep(/^\Q$item\E$/,@{$changes{$key}{$type}})) {                                      if (grep(/^\Q$item\E$/,@{$changes{$key}{$type}})) {
Line 9719  sub modify_selfenrollment { Line 9597  sub modify_selfenrollment {
                         $resulttext .= '</ul></li>';                           $resulttext .= '</ul></li>'; 
                     }                      }
                 }                  }
                 if ((exists($changes{'admin'})) || (exists($changes{'default'}))) {  
                     my $cachetime = 24*60*60;  
                     &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);  
                     if (ref($lastactref) eq 'HASH') {  
                         $lastactref->{'domdefaults'} = 1;  
                     }  
                 }  
             }              }
             $resulttext .= '</ul>';              $resulttext .= '</ul>';
         } else {          } else {
Line 10270  sub get_active_dcs { Line 10141  sub get_active_dcs {
   
 sub active_dc_picker {  sub active_dc_picker {
     my ($dom,$numinrow,$inputtype,$name,%currhash) = @_;      my ($dom,$numinrow,$inputtype,$name,%currhash) = @_;
     my %domcoords = &get_active_dcs($dom);      my %domcoords = &get_active_dcs($dom); 
     my @domcoord = keys(%domcoords);      my @domcoord = keys(%domcoords);
     if (keys(%currhash)) {      if (keys(%currhash)) {
         foreach my $dc (keys(%currhash)) {          foreach my $dc (keys(%currhash)) {

Removed from v.1.160.6.39  
changed lines
  Added in v.1.231


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>