Diff for /loncom/interface/domainprefs.pm between versions 1.69 and 1.83

version 1.69, 2008/11/28 21:02:35 version 1.83, 2008/12/26 21:48:43
Line 39  use Apache::lonlocal; Line 39  use Apache::lonlocal;
 use Apache::lonmsg();  use Apache::lonmsg();
 use LONCAPA qw(:DEFAULT :match);  use LONCAPA qw(:DEFAULT :match);
 use LONCAPA::Enrollment;  use LONCAPA::Enrollment;
 use LONCAPA::loncgi();  use LONCAPA::lonauthcgi();
 use File::Copy;  use File::Copy;
 use Locale::Language;  use Locale::Language;
 use DateTime::TimeZone;  use DateTime::TimeZone;
Line 105  sub handler { Line 105  sub handler {
                                   col2 => 'Value'}],                                    col2 => 'Value'}],
                     },                      },
         'quotas' =>           'quotas' => 
                     { text => 'Default quotas for user portfolios',                      { text => 'User blogs, home pages and portfolios',
                       help => 'Domain_Configuration_Quotas',                        help => 'Domain_Configuration_Quotas',
                       header => [{col1 => 'User type',                        header => [{col1 => 'User affiliation',
                                   col2 => 'Default quota'}],                                    col2 => 'Available tools',
                                     col3 => 'Portfolio quota',}],
                     },                      },
         'autoenroll' =>          'autoenroll' =>
                    { text => 'Auto-enrollment settings',                     { text => 'Auto-enrollment settings',
Line 174  sub handler { Line 175  sub handler {
                                }],                                 }],
                   },                    },
         'serverstatuses' =>          'serverstatuses' =>
                  {text   => 'Access to Server Status Pages',                   {text   => 'Access to server status pages',
                   help   => 'Domain_Configuration_Server_Status',                    help   => 'Domain_Configuration_Server_Status',
                   header => [{col1 => 'Status Page',                    header => [{col1 => 'Status Page',
                               col2 => 'Other named users',                                col2 => 'Other named users',
Line 270  sub handler { Line 271  sub handler {
             $r->print('<input type="hidden" name="phase" value="" />'.              $r->print('<input type="hidden" name="phase" value="" />'.
                       '<input type="hidden" name="numcols" value="'.                        '<input type="hidden" name="numcols" value="'.
                       $env{'form.numcols'}.'" />'."\n".                        $env{'form.numcols'}.'" />'."\n".
                       '<span clas="LC_error">'.&mt('No settings chosen').                        '<span class="LC_error">'.&mt('No settings chosen').
                       '</span>');                        '</span>');
         }          }
         $r->print('</form>');          $r->print('</form>');
Line 519  sub print_config_box { Line 520  sub print_config_box {
             $output .= '              $output .= '
               <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';                <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
         }          }
         if ($action eq 'serverstatuses') {          if (defined($item->{'header'}->[0]->{'col3'})) {
              $output .= '<td class="LC_left_item" valign="top">'.              $output .= '<td class="LC_left_item" valign="top">'.
                         &mt($item->{'header'}->[0]->{'col2'}).                         &mt($item->{'header'}->[0]->{'col2'});
                         '<br />(<tt>'.&mt('user1:domain1,user2:domain2 etc.').'</tt>)';              if ($action eq 'serverstatuses') {
                   $output .= '<br />(<tt>'.&mt('user1:domain1,user2:domain2 etc.').'</tt>)';
               } 
         } else {          } else {
             $output .= '<td class="LC_right_item" valign="top">'.              $output .= '<td class="LC_right_item" valign="top">'.
                        &mt($item->{'header'}->[0]->{'col2'});                         &mt($item->{'header'}->[0]->{'col2'});
Line 697  sub print_login { Line 700  sub print_login {
                    );                     );
     foreach my $item (@images) {      foreach my $item (@images) {
         $defaults{$item} = $defaultdesign{'login.'.$item};          $defaults{$item} = $defaultdesign{'login.'.$item};
           $defaults{'showlogo'}{$item} = 1;
     }      }
     foreach my $item (@bgs) {      foreach my $item (@bgs) {
         $defaults{'bgs'}{$item} = $defaultdesign{'login.'.$item};          $defaults{'bgs'}{$item} = $defaultdesign{'login.'.$item};
Line 718  sub print_login { Line 722  sub print_login {
             }              }
         }          }
         foreach my $item (@images) {          foreach my $item (@images) {
             if ($settings->{$item} ne '') {              if (defined($settings->{$item})) {
                 $designs{$item} = $settings->{$item};                  $designs{$item} = $settings->{$item};
                 $is_custom{$item} = 1;                  $is_custom{$item} = 1;
             }              }
               if (defined($settings->{'showlogo'}{$item})) {
                   $designs{'showlogo'}{$item} = $settings->{'showlogo'}{$item};
               }
         }          }
         foreach my $item (@logintext) {          foreach my $item (@logintext) {
             if ($settings->{$item} ne '') {              if ($settings->{$item} ne '') {
Line 810  sub login_choices { Line 817  sub login_choices {
             bgs => "Background colors",              bgs => "Background colors",
             links => "Link colors",              links => "Link colors",
             font => "Font color",              font => "Font color",
             pgbg => "Page",              pgbg => "Header",
             mainbg => "Main panel",              mainbg => "Page",
             sidebg => "Side panel",              sidebg => "Login box",
             link => "Link",              link => "Link",
             alink => "Active link",              alink => "Active link",
             vlink => "Visited link",              vlink => "Visited link",
Line 915  sub display_color_options { Line 922  sub display_color_options {
  $itemcount ++;   $itemcount ++;
         $css_class = $itemcount%2?' class="LC_odd_row"':'';          $css_class = $itemcount%2?' class="LC_odd_row"':'';
         $datatable .= '<tr'.$css_class.'>'.          $datatable .= '<tr'.$css_class.'>'.
                       '<td>'.$choices->{$img}.'</td>';                        '<td>'.$choices->{$img};
         my ($imgfile,$img_import,$login_hdr_pick,$logincolors);          my ($imgfile,$img_import,$login_hdr_pick,$logincolors);
           if ($role eq 'login') {
               if ($img eq 'login') {
                   $login_hdr_pick =
                       &login_header_options($img,$role,$defaults,$is_custom,$choices,
                                             $loginheader);
                   $logincolors =
                       &login_text_colors($img,$role,$logintext,$phase,$choices,
                                               $designs);
               } elsif ($img ne 'domlogo') {
                   $datatable.= &logo_display_options($img,$defaults,$designs);
               }
           }
           $datatable .= '</td>';
         if ($designs->{$img} ne '') {          if ($designs->{$img} ne '') {
             $imgfile = $designs->{$img};              $imgfile = $designs->{$img};
     $img_import = ($imgfile =~ m{^/adm/});      $img_import = ($imgfile =~ m{^/adm/});
         } else {          } else {
             $imgfile = $defaults->{$img};              $imgfile = $defaults->{$img};
         }          }
         if ($img eq 'login') {  
             $login_hdr_pick = &login_header_options($img,$role,$defaults,$is_custom,$choices,  
                                                     $loginheader);  
             $logincolors =  
                 &login_text_colors($img,$role,$logintext,$phase,$choices,$designs);  
         }  
         if ($imgfile) {          if ($imgfile) {
             my ($showfile,$fullsize);              my ($showfile,$fullsize);
             if ($imgfile =~ m-^(/res/\Q$dom\E/\Q$confname\E/\Q$img\E)/([^/]+)$-) {              if ($imgfile =~ m-^(/res/\Q$dom\E/\Q$confname\E/\Q$img\E)/([^/]+)$-) {
Line 1017  sub display_color_options { Line 1031  sub display_color_options {
     my $bgs_def;      my $bgs_def;
     foreach my $item (@{$bgs}) {      foreach my $item (@{$bgs}) {
         if (!$is_custom->{$item}) {          if (!$is_custom->{$item}) {
             $bgs_def .= '<td>'.$choices->{$item}.'&nbsp;<span id="css_default_'.$role.'_'.$item.'" style="background-color: '.$defaults->{'bgs'}{$item}.';">&nbsp;&nbsp;&nbsp;</span><br />'.$defaults->{'bgs'}{$item}.'</td>';              $bgs_def .= '<td><span class="LC_nobreak">'.$choices->{$item}.'</span>&nbsp;<span id="css_default_'.$role.'_'.$item.'" style="background-color: '.$defaults->{'bgs'}{$item}.';">&nbsp;&nbsp;&nbsp;</span><br />'.$defaults->{'bgs'}{$item}.'</td>';
         }          }
     }      }
     if ($bgs_def) {      if ($bgs_def) {
Line 1068  sub display_color_options { Line 1082  sub display_color_options {
     return $datatable;      return $datatable;
 }  }
   
   sub logo_display_options {
       my ($img,$defaults,$designs) = @_;
       my $checkedon;
       if (ref($defaults) eq 'HASH') {
           if (ref($defaults->{'showlogo'}) eq 'HASH') {
               if ($defaults->{'showlogo'}{$img}) {
                   $checkedon = 'checked="checked" ';     
               }
           } 
       }
       if (ref($designs) eq 'HASH') {
           if (ref($designs->{'showlogo'}) eq 'HASH') {
               if (defined($designs->{'showlogo'}{$img})) {
                   if ($designs->{'showlogo'}{$img} == 0) {
                       $checkedon = '';
                   } elsif ($designs->{'showlogo'}{$img} == 1) {
                       $checkedon = 'checked="checked" ';
                   }
               }
           }
       }
       return '<br /><label>&nbsp;&nbsp;<input type="checkbox" name="'.
              'login_showlogo_'.$img.'" value="1" '.$checkedon.'/>'.
              &mt('show').'</label>'."\n";
   }
   
 sub login_header_options  {  sub login_header_options  {
     my ($img,$role,$defaults,$is_custom,$choices,$loginheader) = @_;      my ($img,$role,$defaults,$is_custom,$choices,$loginheader) = @_;
     my $image_checked = ' checked="checked" ';      my $image_checked = ' checked="checked" ';
Line 1119  sub image_changes { Line 1159  sub image_changes {
     my ($is_custom,$alt_text,$img_import,$showfile,$fullsize,$role,$img,$imgfile,$logincolors) = @_;      my ($is_custom,$alt_text,$img_import,$showfile,$fullsize,$role,$img,$imgfile,$logincolors) = @_;
     my $output;      my $output;
     if (!$is_custom) {      if (!$is_custom) {
         if ($img eq 'login') {          if ($img ne 'domlogo') {
             $output .= &mt('Default image:').'<br />';              $output .= &mt('Default image:').'<br />';
         } else {          } else {
             $output .= &mt('Default in use:').'<br />';              $output .= &mt('Default in use:').'<br />';
Line 1201  sub print_quotas { Line 1241  sub print_quotas {
     my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);      my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
     my $typecount = 0;      my $typecount = 0;
     my $css_class;      my $css_class;
       my @usertools = ('aboutme','blog','portfolio');
       my %titles = &tool_titles();
     if (ref($types) eq 'ARRAY') {      if (ref($types) eq 'ARRAY') {
         foreach my $type (@{$types}) {          foreach my $type (@{$types}) {
               my $currdefquota;
               if (ref($settings) eq 'HASH') {
                   if (ref($settings->{defaultquota}) eq 'HASH') {
                       $currdefquota = $settings->{defaultquota}->{$type}; 
                   } else {
                       $currdefquota = $settings->{$type};
                   }
               }
             if (defined($usertypes->{$type})) {              if (defined($usertypes->{$type})) {
                 $typecount ++;                  $typecount ++;
                 $css_class = $typecount%2?' class="LC_odd_row"':'';                  $css_class = $typecount%2?' class="LC_odd_row"':'';
                 $datatable .= '<tr'.$css_class.'>'.                   $datatable .= '<tr'.$css_class.'>'.
                               '<td>'.$usertypes->{$type}.'</td>'.                                '<td>'.$usertypes->{$type}.'</td>'.
                               '<td class="LC_right_item"><span class="LC_nobreak">'.                                '<td class="LC_left_item">';
                   foreach my $item (@usertools) {
                       my $checked = 'checked="checked" ';
                       if (ref($settings) eq 'HASH') {
                           if (ref($settings->{$item}) eq 'HASH') {
                               if ($settings->{$item}->{$type} == 0) {
                                   $checked = '';
                               }
                           }
                       }
                       $datatable .= '<span class="LC_nobreak"><label>'.
                                     '<input type="checkbox" name="tools_'.$item.
                                     '" value="'.$type.'" '.$checked.'/>'.$titles{$item}.
                                     '</label></span>&nbsp; ';
                   }
                   $datatable .= '</td><td class="LC_right_item"><span class="LC_nobreak">'.
                               '<input type="text" name="quota_'.$type.                                '<input type="text" name="quota_'.$type.
                               '" value="'.$settings->{$type}.                                '" value="'.$currdefquota.
                               '" size="5" /> Mb</span></td></tr>';                                '" size="5" /> Mb</span></td></tr>';
             }              }
         }          }
     }      }
     my $defaultquota = '20';      my $defaultquota = '20';
     if (ref($settings) eq 'HASH') {      if (ref($settings) eq 'HASH') {
         if (defined($settings->{'default'})) {          if (ref($settings->{'defaultquota'}) eq 'HASH') {
               $defaultquota = $settings->{'defaultquota'}->{'default'};
           } elsif (defined($settings->{'default'})) {
             $defaultquota = $settings->{'default'};              $defaultquota = $settings->{'default'};
         }          }
     }      }
Line 1225  sub print_quotas { Line 1292  sub print_quotas {
     $css_class = $typecount%2?' class="LC_odd_row"':'';      $css_class = $typecount%2?' class="LC_odd_row"':'';
     $datatable .= '<tr'.$css_class.'>'.      $datatable .= '<tr'.$css_class.'>'.
                   '<td>'.$othertitle.'</td>'.                    '<td>'.$othertitle.'</td>'.
                   '<td class="LC_right_item"><span class="LC_nobreak">'.                    '<td class="LC_left_item">';
       foreach my $item (@usertools) {
           my $checked = 'checked="checked" ';
           if (ref($settings) eq 'HASH') {
               if (ref($settings->{$item}) eq 'HASH') {
                   if ($settings->{$item}->{'default'} == 0) {
                       $checked = '';
                   }
               }
           }
           $datatable .= '<span class="LC_nobreak"><label>'.
                         '<input type="checkbox" name="tools_'.$item.
                         '" value="default" '.$checked.'/>'.$titles{$item}.
                         '</label></span>&nbsp; ';
       }
       $datatable .= '</td><td class="LC_right_item"><span class="LC_nobreak">'.
                   '<input type="text" name="defaultquota" value="'.                    '<input type="text" name="defaultquota" value="'.
                   $defaultquota.'" size="5" /> Mb</span></td></tr>';                    $defaultquota.'" size="5" /> Mb</span></td></tr>';
       $typecount ++;
       $css_class = $typecount%2?' class="LC_odd_row"':'';
       $datatable .= '<tr'.$css_class.'>'.
                     '<td><br/>'.&mt('LON-CAPA Advanced Users').'</td>'.
                     '<td class="LC_left_item" colspan="2"><br />';
       foreach my $item (@usertools) {
           my $checked = 'checked="checked" ';
           if (ref($settings) eq 'HASH') {
               if (ref($settings->{$item}) eq 'HASH') {
                   if ($settings->{$item}->{'_LC_adv'} == 0) {
                       $checked = '';
                   }
               }
           }
           $datatable .= '<span class="LC_nobreak"><label>'.
                         '<input type="checkbox" name="tools_'.$item.
                         '" value="_LC_adv" '.$checked.'/>'.$titles{$item}.
                         '</label></span>&nbsp; ';
       }
       $datatable .= '<span class="LC_nobreak">('.&mt('overrides affiliation').
                     ')</span</td></tr>';
     $$rowtotal += $typecount;      $$rowtotal += $typecount;
     return $datatable;      return $datatable;
 }  }
Line 1548  sub contact_titles { Line 1651  sub contact_titles {
     return (\%titles,\%short_titles);      return (\%titles,\%short_titles);
 }  }
   
   sub tool_titles {
       my %titles = &Apache::lonlocal::texthash (
                                                 aboutme   => 'Personal Home Page',
                                                 blog      => 'Blog',
                                                 portfolio => 'Portfolio',
                                                );
       return %titles;
   }
   
 sub print_usercreation {  sub print_usercreation {
     my ($position,$dom,$settings,$rowtotal) = @_;      my ($position,$dom,$settings,$rowtotal) = @_;
     my $numinrow = 4;      my $numinrow = 4;
Line 2261  sub print_serverstatuses { Line 2373  sub print_serverstatuses {
             }              }
         }          }
     }      }
     my $titles= &LONCAPA::loncgi::serverstatus_titles();      my $titles= &LONCAPA::lonauthcgi::serverstatus_titles();
     my $rownum = 0;      my $rownum = 0;
     my $css_class;      my $css_class;
     foreach my $type (@pages) {      foreach my $type (@pages) {
Line 2847  sub modify_colors { Line 2959  sub modify_colors {
             $domconfig->{$role} = {};              $domconfig->{$role} = {};
         }          }
         foreach my $img (@images) {          foreach my $img (@images) {
               if (($role eq 'login') && (($img eq 'img') || ($img eq 'logo'))) {  
                   if (defined($env{'form.login_showlogo_'.$img})) {
                       $confhash->{$role}{'showlogo'}{$img} = 1;
                   } else { 
                       $confhash->{$role}{'showlogo'}{$img} = 0;
                   }
               } 
     if ( ! $env{'form.'.$role.'_'.$img.'.filename'}       if ( ! $env{'form.'.$role.'_'.$img.'.filename'} 
  && !defined($domconfig->{$role}{$img})   && !defined($domconfig->{$role}{$img})
  && !$env{'form.'.$role.'_del_'.$img}   && !$env{'form.'.$role.'_del_'.$img}
Line 2921  sub modify_colors { Line 3040  sub modify_colors {
                             $changes{$role}{'images'}{$img} = 1;                              $changes{$role}{'images'}{$img} = 1;
                         }                           } 
                     }                      }
                 }                        if (($role eq 'login') && (($img eq 'logo') || ($img eq 'img'))) {
                           if (ref($domconfig->{'login'}{'showlogo'}) eq 'HASH') {
                               if ($confhash->{$role}{'showlogo'}{$img} ne 
                                   $domconfig->{$role}{'showlogo'}{$img}) {
                                   $changes{$role}{'showlogo'}{$img} = 1; 
                               }
                           } else {
                               if ($confhash->{$role}{'showlogo'}{$img} == 0) {
                                   $changes{$role}{'showlogo'}{$img} = 1;
                               }
                           }
                       }
                   }
                 if ($domconfig->{$role}{'font'} ne '') {                  if ($domconfig->{$role}{'font'} ne '') {
                     if ($confhash->{$role}{'font'} ne $domconfig->{$role}{'font'}) {                      if ($confhash->{$role}{'font'} ne $domconfig->{$role}{'font'}) {
                         $changes{$role}{'font'} = 1;                          $changes{$role}{'font'} = 1;
Line 3013  sub default_change_checker { Line 3144  sub default_change_checker {
             $confhash->{$role}{$img} = '';              $confhash->{$role}{$img} = '';
             $changes->{$role}{'images'}{$img} = 1;              $changes->{$role}{'images'}{$img} = 1;
         }          }
           if ($role eq 'login') {
               if ($confhash->{$role}{'showlogo'}{$img} == 0) {
                   $changes->{$role}{'showlogo'}{$img} = 1;
               }
           }
     }      }
     if ($confhash->{$role}{'font'}) {      if ($confhash->{$role}{'font'}) {
         $changes->{$role}{'font'} = 1;          $changes->{$role}{'font'} = 1;
Line 3044  sub display_colorchgs { Line 3180  sub display_colorchgs {
                         $resulttext .= '<li>'.&mt($choices{$key}).':<ul>';                          $resulttext .= '<li>'.&mt($choices{$key}).':<ul>';
                     }                      }
                     foreach my $item (sort(keys(%{$changes->{$role}{$key}}))) {                      foreach my $item (sort(keys(%{$changes->{$role}{$key}}))) {
                         if ($confhash->{$role}{$item} eq '') {                          if (($role eq 'login') && ($key eq 'showlogo')) {
                               if ($confhash->{$role}{$key}{$item}) {
                                   $resulttext .= '<li>'.&mt("$choices{$item} set to be displayed").'</li>';
                               } else {
                                   $resulttext .= '<li>'.&mt("$choices{$item} set to not be displayed").'</li>';
                               }
                           } elsif ($confhash->{$role}{$item} eq '') {
                             $resulttext .= '<li>'.&mt("$choices{$item} set to default").'</li>';                              $resulttext .= '<li>'.&mt("$choices{$item} set to default").'</li>';
                         } else {                          } else {
                             my $newitem = $confhash->{$role}{$item};                              my $newitem = $confhash->{$role}{$item};
Line 3363  END Line 3505  END
   
 sub modify_quotas {  sub modify_quotas {
     my ($dom,%domconfig) = @_;      my ($dom,%domconfig) = @_;
       my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
     my ($resulttext,%changes);      my ($resulttext,%changes);
     my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);      my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
     my %formhash;      my @usertools = ('aboutme','blog','portfolio');
       my %titles = &tool_titles();
       my (%confhash,%toolshash);
     foreach my $key (keys(%env)) {      foreach my $key (keys(%env)) {
         if ($key =~ /^form\.quota_(.+)$/) {          if ($key =~ /^form\.quota_(.+)$/) {
             $formhash{$1} = $env{$key};              $confhash{'defaultquota'}{$1} = $env{$key};
           } elsif ($key =~ /^form\.tools_(.+)$/) {
               @{$toolshash{$1}} = &Apache::loncommon::get_env_multiple($key);
         }          }
     }      }
     $formhash{'default'} = $env{'form.defaultquota'};      $confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'};
     if (ref($domconfig{'quotas'}) eq 'HASH') {      foreach my $item (@usertools) {
         foreach my $key (keys(%{$domconfig{'quotas'}})) {          foreach my $type (@{$types},'default','_LC_adv') {
             if (exists($formhash{$key})) {              if (grep(/^\Q$type\E$/,@{$toolshash{$item}})) {
                 if ($formhash{$key} ne $domconfig{'quotas'}{$key}) {                  $confhash{$item}{$type} = 1;
                     $changes{$key} = 1;              } else {
                   $confhash{$item}{$type} = 0;
               }
               if (ref($domconfig{'quotas'}) eq 'HASH') {
                   if (ref($domconfig{'quotas'}{$item}) eq 'HASH') {
                       if ($domconfig{'quotas'}{$item}{$type} ne $confhash{$item}{$type}) {
                           $changes{$item}{$type} = 1;
                       }
                   } else {
                       if (!$confhash{$item}{$type}) {
                           $changes{$item}{$type} = 1;
                       }
                 }                  }
             } else {              } else {
                 $formhash{$key} = $domconfig{'quotas'}{$key};                  if (!$confhash{$item}{$type}) {
                       $changes{$item}{$type} = 1;
                   }
               }
           }
       }
       if (ref($domconfig{'quotas'}) eq 'HASH') {
           if (ref($domconfig{'quotas'}{'defaultquota'}) eq 'HASH') {
               foreach my $key (keys(%{$domconfig{'quotas'}{'defaultquota'}})) {
                   if (exists($confhash{'defaultquota'}{$key})) {
                       if ($confhash{'defaultquota'}{$key} ne $domconfig{'quotas'}{'defaultquota'}{$key}) {
                           $changes{'defaultquota'}{$key} = 1;
                       }
                   } else {
                       $confhash{'defaultquota'}{$key} = $domconfig{'quotas'}{'defaultquota'}{$key};
                   }
               }
           } else {
               foreach my $key (keys(%{$domconfig{'quotas'}})) {
                   if (exists($confhash{'defaultquota'}{$key})) {
                       if ($confhash{'defaultquota'}{$key} ne $domconfig{'quotas'}{$key}) {
                           $changes{'defaultquota'}{$key} = 1;
                       }
                   } else {
                       $confhash{'defaultquota'}{$key} = $domconfig{'quotas'}{$key};
                   }
             }              }
         }          }
     }      }
     foreach my $key (keys(%formhash)) {      if (ref($confhash{'defaultquota'}) eq 'HASH') {
         if ($formhash{$key} ne '') {          foreach my $key (keys(%{$confhash{'defaultquota'}})) {
             if (ref($domconfig{'quotas'}) eq 'HASH') {              if (ref($domconfig{'quotas'}) eq 'HASH') {
                 if (!exists($domconfig{'quotas'}{$key})) {                  if (ref($domconfig{'quotas'}{'defaultquota'}) eq 'HASH') {
                     $changes{$key} = 1;                      if (!exists($domconfig{'quotas'}{'defaultquota'}{$key})) {
                           $changes{'defaultquota'}{$key} = 1;
                       }
                   } else {
                       if (!exists($domconfig{'quotas'}{$key})) {
                           $changes{'defaultquota'}{$key} = 1;
                       }
                 }                  }
             } else {              } else {
                 $changes{$key} = 1;                  $changes{'defaultquota'}{$key} = 1;
             }              }
         }          }
     }      }
   
       foreach my $key (keys(%confhash)) {
           $domdefaults{$key} = $confhash{$key};
       }
      
     my %quotahash = (      my %quotahash = (
                       quotas => {%formhash},                        quotas => { %confhash }
                     );                      );
     my $putresult = &Apache::lonnet::put_dom('configuration',\%quotahash,      my $putresult = &Apache::lonnet::put_dom('configuration',\%quotahash,
                                              $dom);                                               $dom);
     if ($putresult eq 'ok') {      if ($putresult eq 'ok') {
         if (keys(%changes) > 0) {          if (keys(%changes) > 0) {
               my $cachetime = 24*60*60;
               &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
   
             $resulttext = &mt('Changes made:').'<ul>';              $resulttext = &mt('Changes made:').'<ul>';
             foreach my $type (@{$types},'default') {              if (ref($changes{'defaultquota'}) eq 'HASH') {
                 if (defined($changes{$type})) {                   $resulttext .= '<li>'.&mt('Portfolio default quotas').'<ul>';
                     my $typetitle = $usertypes->{$type};                  foreach my $type (@{$types},'default') {
                     if ($type eq 'default') {                      if (defined($changes{'defaultquota'}{$type})) {
                         $typetitle = $othertitle;                          my $typetitle = $usertypes->{$type};
                           if ($type eq 'default') {
                               $typetitle = $othertitle;
                           }
                           $resulttext .= '<li>'.&mt('[_1] set to [_2] Mb',$typetitle,$confhash{'defaultquota'}{$type}).'</li>';
                       }
                   }
                   $resulttext .= '</ul></li>';
               }
               my %newenv;
               foreach my $item (@usertools) {
                   if (ref($changes{$item}) eq 'HASH') {
                       my $newacc = 
                           &Apache::lonnet::usertools_access($env{'user.name'},
                                                             $env{'user.domain'},
                                                             $item,'reload');
                       if ($env{'environment.availabletools.'.$item} ne $newacc) { 
                           $newenv{'environment.availabletools.'.$item} = $newacc;
                       }
                       $resulttext .= '<li>'.$titles{$item}.'<ul>';
                       foreach my $type (@{$types},'default','_LC_adv') {
                           if ($changes{$item}{$type}) {
                               my $typetitle = $usertypes->{$type};
                               if ($type eq 'default') {
                                   $typetitle = $othertitle;
                               } elsif ($type eq '_LC_adv') {
                                   $typetitle = 'LON-CAPA Advanced Users'; 
                               }
                               if ($confhash{$item}{$type}) {
                                   $resulttext .= '<li>'.&mt('Set to be available to [_1]',$typetitle).'</li>';
                               } else {
                                   $resulttext .= '<li>'.&mt('Set to be unavailable to [_1]',$typetitle).'</li>';
                               }
                           }
                     }                      }
                     $resulttext .= '<li>'.&mt('[_1] set to [_2] Mb',$typetitle,$formhash{$type}).'</li>';                      $resulttext .= '</ul></li>';
                 }                  }
             }              }
             $resulttext .= '</ul>';              $resulttext .= '</ul>';
               if (keys(%newenv)) {
                   &Apache::lonnet::appenv(\%newenv);
               }
         } else {          } else {
             $resulttext = &mt('No changes made to default quotas');              $resulttext = &mt('No changes made to availability of home pages, blogs, portfolios or default quotas');
         }          }
     } else {      } else {
         $resulttext = '<span class="LC_error">'.          $resulttext = '<span class="LC_error">'.
Line 4376  sub modify_defaults { Line 4609  sub modify_defaults {
         } elsif ($domdefaults{$item} ne $newvalues{$item}) {          } elsif ($domdefaults{$item} ne $newvalues{$item}) {
             $changes{$item} = 1;              $changes{$item} = 1;
         }          }
           $domdefaults{$item} = $newvalues{$item};
     }      }
     my %defaults_hash = (      my %defaults_hash = (
                          defaults => { auth_def => $newvalues{'auth_def'},                           defaults => \%newvalues,
                                        auth_arg_def => $newvalues{'auth_arg_def'},                          );
                                        lang_def => $newvalues{'lang_def'},  
                                        timezone_def => $newvalues{'timezone_def'},  
                                        datelocale_def => $newvalues{'datelocale_def'},  
                                      }  
                        );  
     my $title = &defaults_titles();      my $title = &defaults_titles();
     my $putresult = &Apache::lonnet::put_dom('configuration',\%defaults_hash,      my $putresult = &Apache::lonnet::put_dom('configuration',\%defaults_hash,
                                              $dom);                                               $dom);
Line 4413  sub modify_defaults { Line 4642  sub modify_defaults {
             $resulttext .= '</ul>';              $resulttext .= '</ul>';
             $mailmsgtext .= "\n";              $mailmsgtext .= "\n";
             my $cachetime = 24*60*60;              my $cachetime = 24*60*60;
             &Apache::lonnet::do_cache_new('domdefaults',$dom,              &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
                                           $defaults_hash{'defaults'},$cachetime);  
             if ($changes{'auth_def'} || $changes{'auth_arg_def'} || $changes{'lang_def'} || $changes{'datelocale_def'}) {              if ($changes{'auth_def'} || $changes{'auth_arg_def'} || $changes{'lang_def'} || $changes{'datelocale_def'}) {
                 my $sysmail = $r->dir_config('lonSysEMail');                  my $sysmail = $r->dir_config('lonSysEMail');
                 &Apache::lonmsg::sendemail($sysmail,"LON-CAPA Domain Settings Change - $dom",$mailmsgtext);                  &Apache::lonmsg::sendemail($sysmail,"LON-CAPA Domain Settings Change - $dom",$mailmsgtext);
Line 4749  sub modify_serverstatuses { Line 4977  sub modify_serverstatuses {
     my %serverstatushash =  (      my %serverstatushash =  (
                                 serverstatuses => \%newserverstatus,                                  serverstatuses => \%newserverstatus,
                             );                              );
     my $putresult = &Apache::lonnet::put_dom('configuration',\%serverstatushash,  
                                              $dom);  
     my %changes;      my %changes;
     foreach my $type (@pages) {      foreach my $type (@pages) {
         if (ref($currserverstatus{$type}) eq 'HASH') {          foreach my $setting ('namedusers','machines') {
             my @currnamed = split(/,/,$currserverstatus{$type}{'namedusers'});              my @current = ();
             my @newusers = split(/,/,$newserverstatus{$type}{'namedusers'});              if (ref($currserverstatus{$type}) eq 'HASH') {
             foreach my $item (@currnamed) {                  @current = split(/,/,$currserverstatus{$type}{$setting});
                 if (!grep(/^\Q$item\E$/,@newusers)) {              }
                     $changes{$type}{'namedusers'} = 1;              my @new = split(/,/,$newserverstatus{$type}{$setting});
                     last;              if (@current > 0) {
                 }                  if (@new > 0) {
             }                      foreach my $item (@current) {
             foreach my $item (@newusers) {                          if (!grep(/^\Q$item\E$/,@new)) {
                 if (!grep(/^\Q$item\E$/,@currnamed)) {                              $changes{$type}{$setting} = 1;
                     $changes{$type}{'namedusers'} = 1;                              last;
                     last;                          }
                 }                      }
             }                      if (!$changes{$type}{$setting}) {
             my @currmachines = split(/,/,$currserverstatus{$type}{'machines'});                          foreach my $item (@new) {
             my @newmachines = split(/,/,$newserverstatus{$type}{'machines'});                              if (!grep(/^\Q$item\E$/,@current)) {
             foreach my $item (@currmachines) {                                  $changes{$type}{$setting} = 1;
                 if (!grep(/^\Q$item\E$/,@newmachines)) {                                  last;
                     $changes{$type}{'machines'} = 1;                              }
                     last;                          }
                 }                      }
             }                  } else {
             foreach my $item (@newmachines) {                      $changes{$type}{$setting} = 1;
                 if (!grep(/^\Q$item\E$/,@currmachines)) {  
                     $changes{$type}{'machines'} = 1;  
                     last;  
                 }                  }
               } elsif (@new > 0) {
                   $changes{$type}{$setting} = 1;
             }              }
   
         }          }
     }      }
     if (keys(%changes) > 0) {      if (keys(%changes) > 0) {
         my $titles= &LONCAPA::loncgi::serverstatus_titles();          my $titles= &LONCAPA::lonauthcgi::serverstatus_titles();
         my $putresult = &Apache::lonnet::put_dom('configuration',          my $putresult = &Apache::lonnet::put_dom('configuration',
                                                  \%serverstatushash,$dom);                                                   \%serverstatushash,$dom);
         if ($putresult eq 'ok') {          if ($putresult eq 'ok') {

Removed from v.1.69  
changed lines
  Added in v.1.83


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