Diff for /loncom/interface/domainprefs.pm between versions 1.64 and 1.76.2.4

version 1.64, 2008/07/19 02:28:44 version 1.76.2.4, 2008/12/25 02:22:08
Line 37  use Apache::loncommon(); Line 37  use Apache::loncommon();
 use Apache::lonhtmlcommon();  use Apache::lonhtmlcommon();
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonmsg();  use Apache::lonmsg();
 use LONCAPA;  use LONCAPA qw(:DEFAULT :match);
 use LONCAPA::Enrollment;  use LONCAPA::Enrollment;
   use LONCAPA::lonauthcgi();
 use File::Copy;  use File::Copy;
 use Locale::Language;  use Locale::Language;
 use DateTime::TimeZone;  use DateTime::TimeZone;
   use DateTime::Locale;
   
 sub handler {  sub handler {
     my $r=shift;      my $r=shift;
Line 72  sub handler { Line 74  sub handler {
       &Apache::lonnet::get_dom('configuration',['login','rolecolors',        &Apache::lonnet::get_dom('configuration',['login','rolecolors',
                 'quotas','autoenroll','autoupdate','directorysrch',                  'quotas','autoenroll','autoupdate','directorysrch',
                 'usercreation','usermodification','contacts','defaults',                  'usercreation','usermodification','contacts','defaults',
                 'scantron','coursecategories'],$dom);                  'scantron','coursecategories','serverstatuses'],$dom);
     my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',      my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
                        'autoupdate','directorysrch','contacts',                         'autoupdate','directorysrch','contacts',
                        'usercreation','usermodification','scantron',                         'usercreation','usermodification','scantron',
                        'coursecategories');                         'coursecategories','serverstatuses');
     my %prefs = (      my %prefs = (
         'rolecolors' =>          'rolecolors' =>
                    { text => 'Default color schemes',                     { text => 'Default color schemes',
                      help => 'Default_Color_Schemes',                       help => 'Domain_Configuration_Color_Schemes',
                      header => [{col1 => 'Student Settings',                       header => [{col1 => 'Student Settings',
                                  col2 => '',},                                   col2 => '',},
                                 {col1 => 'Coordinator Settings',                                  {col1 => 'Coordinator Settings',
Line 92  sub handler { Line 94  sub handler {
                     },                      },
         'login' =>            'login' =>  
                     { text => 'Log-in page options',                      { text => 'Log-in page options',
                       help => 'Domain_Log-in_Page',                        help => 'Domain_Configuration_Login_Page',
                       header => [{col1 => 'Item',                        header => [{col1 => 'Item',
                                   col2 => '',}],                                    col2 => '',}],
                     },                      },
         'defaults' =>           'defaults' => 
                     { text => 'Default authentication/language/timezone',                      { text => 'Default authentication/language/timezone',
                       help => '',                        help => 'Domain_Configuration_LangTZAuth',
                       header => [{col1 => 'Setting',                        header => [{col1 => 'Setting',
                                   col2 => 'Value'}],                                    col2 => 'Value'}],
                     },                      },
         'quotas' =>           'quotas' => 
                     { text => 'Default quotas for user portfolios',                      { text => 'User blogs, home pages and portfolios',
                       help => 'Default_User_Quota',                        help => 'Domain_Configuration_Quotas',
                       header => [{col1 => 'User type',                        header => [{col1 => 'User type',
                                   col2 => 'Default quota'}],                                    col2 => 'Available tools',
                                     col3 => 'Portfolio quota',}],
                     },                      },
         'autoenroll' =>          'autoenroll' =>
                    { text => 'Auto-enrollment settings',                     { text => 'Auto-enrollment settings',
                      help => 'Domain_Auto_Enrollment',                       help => 'Domain_Configuration_Auto_Enrollment',
                      header => [{col1 => 'Configuration setting',                       header => [{col1 => 'Configuration setting',
                                  col2 => 'Value(s)'}],                                   col2 => 'Value(s)'}],
                    },                     },
         'autoupdate' =>           'autoupdate' => 
                    { text => 'Auto-update settings',                     { text => 'Auto-update settings',
                      help => 'Domain_Auto_Update',                       help => 'Domain_Configuration_Auto_Updates',
                      header => [{col1 => 'Setting',                       header => [{col1 => 'Setting',
                                  col2 => 'Value',},                                   col2 => 'Value',},
                                 {col1 => 'User population',                                  {col1 => 'User population',
Line 124  sub handler { Line 127  sub handler {
                   },                    },
         'directorysrch' =>           'directorysrch' => 
                   { text => 'Institutional directory searches',                    { text => 'Institutional directory searches',
                     help => 'Domain_Directory_Search',                      help => 'Domain_Configuration_InstDirectory_Search',
                     header => [{col1 => 'Setting',                      header => [{col1 => 'Setting',
                                 col2 => 'Value',}],                                  col2 => 'Value',}],
                   },                    },
         'contacts' =>          'contacts' =>
                   { text => 'Contact Information',                    { text => 'Contact Information',
                     help => 'Domain_Contact_Information',                      help => 'Domain_Configuration_Contact_Info',
                     header => [{col1 => 'Setting',                      header => [{col1 => 'Setting',
                                 col2 => 'Value',}],                                  col2 => 'Value',}],
                   },                    },
   
         'usercreation' =>           'usercreation' => 
                   { text => 'User creation',                    { text => 'User creation',
                     help => 'Domain_User_Creation',                      help => 'Domain_Configuration_User_Creation',
                     header => [{col1 => 'Format rule type',                      header => [{col1 => 'Format rule type',
                                 col2 => 'Format rules in force'},                                  col2 => 'Format rules in force'},
                                {col1 => 'User account creation',                                 {col1 => 'User account creation',
Line 145  sub handler { Line 148  sub handler {
                                {col1 => 'Context',                                 {col1 => 'Context',
                                 col2 => 'Assignable authentication types'}],                                  col2 => 'Assignable authentication types'}],
                   },                    },
         'usermodification' =>           'usermodification' =>
                   { text => 'User modification',                    { text => 'User modification',
                     help => 'Domain_User_Modification',                      help => 'Domain_Configuration_User_Modification',
                     header => [{col1 => 'Target user has role',                      header => [{col1 => 'Target user has role',
                                 col2 => 'User information updateable in author context'},                                  col2 => 'User information updateable in author context'},
                                {col1 => 'Target user has role',                                 {col1 => 'Target user has role',
Line 155  sub handler { Line 158  sub handler {
                                {col1 => "Status of user",                                 {col1 => "Status of user",
                                 col2 => 'Information settable when self-creating account (if directory data blank)'}],                                  col2 => 'Information settable when self-creating account (if directory data blank)'}],
                   },                    },
         'scantron' =>           'scantron' =>
                   { text => 'Scantron format file',                    { text => 'Scantron format file',
                     help => 'Domain_Scantron_Formats',                      help => 'Domain_Configuration_Scantron_Format',
                     header => [ {col1 => 'Item',                      header => [ {col1 => 'Item',
                                  col2 => '',                                   col2 => '',
                               }],                                }],
                   },                    },
         'coursecategories' =>           'coursecategories' =>
                   { text => 'Cataloging of courses',                    { text => 'Cataloging of courses',
                     help => 'Domain_Course_Catalog',                      help => 'Domain_Configuration_Cataloging_Courses',
                     header => [{col1 => 'Category settings',                        header => [{col1 => 'Category settings',
                                 col2 => '',},                                  col2 => '',},
                                {col1 => 'Categories',                                 {col1 => 'Categories',
                                 col2 => '',                                  col2 => '',
                                }],                                 }],
                   }                    },
           'serverstatuses' =>
                    {text   => 'Access to Server Status Pages',
                     help   => 'Domain_Configuration_Server_Status',
                     header => [{col1 => 'Status Page',
                                 col2 => 'Other named users',
                                 col3 => 'Specific IPs',
                               }],
                    },
     );      );
     my @roles = ('student','coordinator','author','admin');      my @roles = ('student','coordinator','author','admin');
     my @actions = &Apache::loncommon::get_env_multiple('form.actions');      my @actions = &Apache::loncommon::get_env_multiple('form.actions');
Line 260  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 319  sub handler { Line 330  sub handler {
         }          }
         $count = 0;          $count = 0;
         foreach my $item (@prefs_order) {          foreach my $item (@prefs_order) {
             $r->print('<h4><label><input type="checkbox" name="actions" value="'.$item.'" />&nbsp;'.&mt($prefs{$item}->{'text'}).'</label></h4>');              $r->print('<h4>'.
                         &Apache::loncommon::help_open_topic($prefs{$item}->{'help'}).
                         '<label><input type="checkbox" name="actions" value="'.$item.
                         '" />&nbsp;'.&mt($prefs{$item}->{'text'}).'</label></h4>');
             $count ++;              $count ++;
             if ((!$seconddiv) && ($count >= $midpoint)) {              if ((!$seconddiv) && ($count >= $midpoint)) {
                 $r->print('</div>'."\n".'<div class="LC_left_float">'."\n");                  $r->print('</div>'."\n".'<div class="LC_left_float">'."\n");
Line 368  sub process_changes { Line 382  sub process_changes {
         $output = &modify_scantron($r,$dom,$confname,%domconfig);          $output = &modify_scantron($r,$dom,$confname,%domconfig);
     } elsif ($action eq 'coursecategories') {      } elsif ($action eq 'coursecategories') {
         $output = &modify_coursecategories($dom,%domconfig);          $output = &modify_coursecategories($dom,%domconfig);
       } elsif ($action eq 'serverstatuses') {
           $output = &modify_serverstatuses($dom,%domconfig);
     }      }
     return $output;      return $output;
 }  }
Line 382  sub print_config_box { Line 398  sub print_config_box {
     $output .=       $output .= 
          '<table class="LC_nested_outer">           '<table class="LC_nested_outer">
           <tr>            <tr>
            <th align="left"><span class="LC_nobreak">'.&mt($item->{text}).             <th align="left" valign="middle"><span class="LC_nobreak">'.
            '&nbsp;</span></th></tr>';             &mt($item->{text}).'&nbsp;'.
 #              &Apache::loncommon::help_open_topic($item->{'help'}).'</span></th>'."\n".
 # FIXME - put the help link back in when the help files exist            '</tr>';
 #           <th>'.&mt($item->{text}).'&nbsp;'.  
 #           &Apache::loncommon::help_open_topic($item->{'help'}).'</th>  
 #          </tr>');  
     $rowtotal ++;      $rowtotal ++;
     if (($action eq 'autoupdate') || ($action eq 'rolecolors') ||       if (($action eq 'autoupdate') || ($action eq 'rolecolors') || 
         ($action eq 'usercreation') || ($action eq 'usermodification') ||          ($action eq 'usercreation') || ($action eq 'usermodification') ||
Line 405  sub print_config_box { Line 418  sub print_config_box {
               <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[0]->{'col1'}).'</td>                <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[0]->{'col1'}).'</td>
               <td class="LC_right_item">'.&mt($item->{'header'}->[0]->{'col2'}).'</td>                <td class="LC_right_item">'.&mt($item->{'header'}->[0]->{'col2'}).'</td>
              </tr>';               </tr>';
              $rowtotal ++;          $rowtotal ++;
         if ($action eq 'autoupdate') {          if ($action eq 'autoupdate') {
             $output .= &print_autoupdate('top',$dom,$settings,\$rowtotal);              $output .= &print_autoupdate('top',$dom,$settings,\$rowtotal);
         } elsif ($action eq 'usercreation') {          } elsif ($action eq 'usercreation') {
Line 470  sub print_config_box { Line 483  sub print_config_box {
            <td>             <td>
             <table class="LC_nested">              <table class="LC_nested">
              <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.' valign="top">'.
               <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>                 &mt($item->{'header'}->[2]->{'col1'}).'</td>
                 <td class="LC_right_item" valign="top">'.
                  &mt($item->{'header'}->[2]->{'col2'}).'</td>
              </tr>'.               </tr>'.
             &print_rolecolors($phase,'author',$dom,$confname,$settings,\$rowtotal).'              &print_rolecolors($phase,'author',$dom,$confname,$settings,\$rowtotal).'
            </table>             </table>
Line 496  sub print_config_box { Line 511  sub print_config_box {
         if (($action eq 'login') || ($action eq 'directorysrch')) {          if (($action eq 'login') || ($action eq 'directorysrch')) {
             $output .= '                $output .= '  
               <td class="LC_left_item" colspan="2">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';                <td class="LC_left_item" colspan="2">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
           } elsif ($action eq 'serverstatuses') {
               $output .= '
                 <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}).
                 '<br />('.&mt('Automatic access for Dom. Coords.').')</td>';
   
         } else {          } else {
             $output .= '              $output .= '
               <td class="LC_left_item">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';                <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
         }          }
         $output .= '          if (defined($item->{'header'}->[0]->{'col3'})) {
               <td class="LC_right_item">'.&mt($item->{'header'}->[0]->{'col2'}).'</td>              $output .= '<td class="LC_left_item" valign="top">'.
              </tr>';                         &mt($item->{'header'}->[0]->{'col2'});
               if ($action eq 'serverstatuses') {
                   $output .= '<br />(<tt>'.&mt('user1:domain1,user2:domain2 etc.').'</tt>)';
               } 
           } else {
               $output .= '<td class="LC_right_item" valign="top">'.
                          &mt($item->{'header'}->[0]->{'col2'});
           }
           $output .= '</td>';
           if ($item->{'header'}->[0]->{'col3'}) {
               $output .= '<td class="LC_right_item" valign="top">'.
                          &mt($item->{'header'}->[0]->{'col3'});
               if ($action eq 'serverstatuses') {
                   $output .= '<br />(<tt>'.&mt('IP1,IP2 etc.').'</tt>)';
               }
               $output .= '</td>';
           }
           $output .= '</tr>';
         $rowtotal ++;          $rowtotal ++;
         if ($action eq 'login') {          if ($action eq 'login') {
             $output .= &print_login($dom,$confname,$phase,$settings,\$rowtotal);              $output .= &print_login($dom,$confname,$phase,$settings,\$rowtotal);
Line 518  sub print_config_box { Line 555  sub print_config_box {
             $output .= &print_defaults($dom,\$rowtotal);              $output .= &print_defaults($dom,\$rowtotal);
         } elsif ($action eq 'scantron') {          } elsif ($action eq 'scantron') {
             $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);              $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
           } elsif ($action eq 'serverstatuses') {
               $output .= &print_serverstatuses($dom,$settings,\$rowtotal);
         }          }
     }      }
     $output .= '      $output .= '
Line 661  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 682  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 879  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 981  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 1032  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 1083  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 1165  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 1189  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 .= '('.&mt('overrides affiliation').')</td></tr>';
     $$rowtotal += $typecount;      $$rowtotal += $typecount;
     return $datatable;      return $datatable;
 }  }
Line 1465  sub print_contacts { Line 1603  sub print_contacts {
     my $rownum = 0;      my $rownum = 0;
     my $css_class;      my $css_class;
     foreach my $item (@contacts) {      foreach my $item (@contacts) {
         if ($rownum%2) {          $rownum ++;
             $css_class = '';          $css_class = $rownum%2?' class="LC_odd_row"':'';
         } else {  
             $css_class = ' class="LC_odd_row" ';  
         }  
         $datatable .= '<tr'.$css_class.'>'.           $datatable .= '<tr'.$css_class.'>'. 
                   '<td><span class="LC_nobreak">'.$titles->{$item}.                    '<td><span class="LC_nobreak">'.$titles->{$item}.
                   '</span></td><td class="LC_right_item">'.                    '</span></td><td class="LC_right_item">'.
                   '<input type="text" name="'.$item.'" value="'.                    '<input type="text" name="'.$item.'" value="'.
                   $to{$item}.'" /></td></tr>';                    $to{$item}.'" /></td></tr>';
         $rownum ++;  
     }      }
     foreach my $type (@mailings) {      foreach my $type (@mailings) {
         if ($rownum%2) {          $rownum ++;
             $css_class = '';          $css_class = $rownum%2?' class="LC_odd_row"':'';
         } else {  
             $css_class = ' class="LC_odd_row" ';  
         }  
         $datatable .= '<tr'.$css_class.'>'.          $datatable .= '<tr'.$css_class.'>'.
                       '<td><span class="LC_nobreak">'.                        '<td><span class="LC_nobreak">'.
                       $titles->{$type}.': </span></td>'.                        $titles->{$type}.': </span></td>'.
Line 1499  sub print_contacts { Line 1630  sub print_contacts {
                       '<input type="text" name="'.$type.'_others" '.                        '<input type="text" name="'.$type.'_others" '.
                       'value="'.$otheremails{$type}.'"  />'.                        'value="'.$otheremails{$type}.'"  />'.
                       '</td></tr>'."\n";                        '</td></tr>'."\n";
         $rownum ++;  
     }      }
     $$rowtotal += $rownum;      $$rowtotal += $rownum;
     return $datatable;      return $datatable;
Line 1508  sub print_contacts { Line 1638  sub print_contacts {
 sub contact_titles {  sub contact_titles {
     my %titles = &Apache::lonlocal::texthash (      my %titles = &Apache::lonlocal::texthash (
                    'supportemail' => 'Support E-mail address',                     'supportemail' => 'Support E-mail address',
                    'adminemail'    => 'Default Server Admin E-mail address',                     'adminemail'   => 'Default Server Admin E-mail address',
                    'errormail'    => 'Error reports to be e-mailed to',                     'errormail'    => 'Error reports to be e-mailed to',
                    'packagesmail' => 'Package update alerts to be e-mailed to',                     'packagesmail' => 'Package update alerts to be e-mailed to',
                    'helpdeskmail' => 'Helpdesk requests to be e-mailed to'                     'helpdeskmail' => 'Helpdesk requests to be e-mailed to'
Line 1520  sub contact_titles { Line 1650  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 1823  sub print_usermodification { Line 1962  sub print_usermodification {
   
 sub print_defaults {  sub print_defaults {
     my ($dom,$rowtotal) = @_;      my ($dom,$rowtotal) = @_;
     my @items = ('auth_def','auth_arg_def','lang_def','timezone_def');      my @items = ('auth_def','auth_arg_def','lang_def','timezone_def',
                    'datelocale_def');
     my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);      my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
     my $titles = &defaults_titles();      my $titles = &defaults_titles();
     my $rownum = 0;      my $rownum = 0;
Line 1858  sub print_defaults { Line 1998  sub print_defaults {
         } elsif ($item eq 'timezone_def') {          } elsif ($item eq 'timezone_def') {
             my $includeempty = 1;              my $includeempty = 1;
             $datatable .= &Apache::loncommon::select_timezone($item,$domdefaults{$item},undef,$includeempty);              $datatable .= &Apache::loncommon::select_timezone($item,$domdefaults{$item},undef,$includeempty);
           } elsif ($item eq 'datelocale_def') {
               my $includeempty = 1;
               $datatable .= &Apache::loncommon::select_datelocale($item,$domdefaults{$item},undef,$includeempty);
         } else {          } else {
             $datatable .= '<input type="text" name="'.$item.'" value="'.              $datatable .= '<input type="text" name="'.$item.'" value="'.
                           $domdefaults{$item}.'" />';                            $domdefaults{$item}.'" />';
Line 1875  sub defaults_titles { Line 2018  sub defaults_titles {
                    'auth_arg_def'  => 'Default authentication argument',                     'auth_arg_def'  => 'Default authentication argument',
                    'lang_def'      => 'Default language',                     'lang_def'      => 'Default language',
                    'timezone_def'  => 'Default timezone',                     'timezone_def'  => 'Default timezone',
                      'datelocale_def' => 'Default locale for dates',
                  );                   );
     return (\%titles);      return (\%titles);
 }  }
Line 1985  sub print_scantronformat { Line 2129  sub print_scantronformat {
     $css_class = $itemcount%2?' class="LC_odd_row"':'';      $css_class = $itemcount%2?' class="LC_odd_row"':'';
     $datatable .= '<tr'.$css_class.'>';      $datatable .= '<tr'.$css_class.'>';
     if (!$is_custom) {      if (!$is_custom) {
         $datatable .= '<td>'.&mt('Default in use:').'<br />';          $datatable .= '<td>'.&mt('Default in use:').'<br />'.
                         '<span class="LC_nobreak">';
         if ($scantronurl) {          if ($scantronurl) {
             $datatable .= '<a href="'.$scantronurl.'" target="_blank">'.              $datatable .= '<a href="'.$scantronurl.'" target="_blank">'.
                           &mt('Default scantron format file').'</a>';                            &mt('Default scantron format file').'</a>';
         } else {          } else {
             $datatable = &mt('File unavailable for display');              $datatable = &mt('File unavailable for display');
         }          }
         $datatable .= '</td>';          $datatable .= '</span></td>';
         if (keys(%error) == 0) {           if (keys(%error) == 0) { 
             $datatable .= '<td valign="bottom">';              $datatable .= '<td valign="bottom">';
             if (!$switchserver) {              if (!$switchserver) {
Line 2013  sub print_scantronformat { Line 2158  sub print_scantronformat {
             }               } 
             $datatable .= '<td>'.$errorstr.'</td><td>&nbsp;';              $datatable .= '<td>'.$errorstr.'</td><td>&nbsp;';
         } elsif ($scantronurl) {          } elsif ($scantronurl) {
             $datatable .= '<td><a href="'.$scantronurl.'" target="_blank">'              $datatable .= '<td><span class="LC_nobreak">'.
                           .&mt('Custom scantron format file').'</a>'                            '<a href="'.$scantronurl.'" target="_blank">'.
                           .'<span class="LC_nobreak"><label>'                            &mt('Custom scantron format file').'</a><label>'.
                           .'<input type="checkbox" name="scantronformat_del"'                            '<input type="checkbox" name="scantronformat_del"'.
                           .'" value="1" />'.&mt('Delete?').'</label></td>'                            '" value="1" />'.&mt('Delete?').'</label></span></td>'.
                           .'<td>'.&mt('Replace:').'</span><br />';                            '<td><span class="LC_nobreak">&nbsp;'.
                             &mt('Replace:').'</span><br />';
         }          }
     }      }
     if (keys(%error) == 0) {      if (keys(%error) == 0) {
         if ($switchserver) {          if ($switchserver) {
             $datatable .= &mt('Upload to library server: [_1]',$switchserver);              $datatable .= &mt('Upload to library server: [_1]',$switchserver);
         } else {          } else {
             $datatable .='&nbsp;<input type="file" name="scantronformat" />';              $datatable .='<span class="LC_nobreak">&nbsp;'.
                            '<input type="file" name="scantronformat" /></span>';
         }          }
     }      }
     $datatable .= '</td></tr>';      $datatable .= '</td></tr>';
Line 2201  sub print_coursecategories { Line 2348  sub print_coursecategories {
     return $datatable;      return $datatable;
 }  }
   
   sub print_serverstatuses {
       my ($dom,$settings,$rowtotal) = @_;
       my $datatable;
       my @pages = &serverstatus_pages();
       my (%namedaccess,%machineaccess);
       foreach my $type (@pages) {
           $namedaccess{$type} = '';
           $machineaccess{$type}= '';
       }
       if (ref($settings) eq 'HASH') {
           foreach my $type (@pages) {
               if (exists($settings->{$type})) {
                   if (ref($settings->{$type}) eq 'HASH') {
                       foreach my $key (keys(%{$settings->{$type}})) {
                           if ($key eq 'namedusers') {
                               $namedaccess{$type} = $settings->{$type}->{$key};
                           } elsif ($key eq 'machines') {
                               $machineaccess{$type} = $settings->{$type}->{$key};
                           }
                       }
                   }
               }
           }
       }
       my $titles= &LONCAPA::lonauthcgi::serverstatus_titles();
       my $rownum = 0;
       my $css_class;
       foreach my $type (@pages) {
           $rownum ++;
           $css_class = $rownum%2?' class="LC_odd_row"':'';
           $datatable .= '<tr'.$css_class.'>'.
                         '<td><span class="LC_nobreak">'.
                         $titles->{$type}.'</span></td>'.
                         '<td class="LC_left_item">'.
                         '<input type="text" name="'.$type.'_namedusers" '.
                         'value="'.$namedaccess{$type}.'" size="30" /></td>'.
                         '<td class="LC_right_item">'.
                         '<span class="LC_nobreak">'.
                         '<input type="text" name="'.$type.'_machines" '.
                         'value="'.$machineaccess{$type}.'" size="10" />'.
                         '</td></tr>'."\n";
       }
       $$rowtotal += $rownum;
       return $datatable;
   }
   
   sub serverstatus_pages {
       return ('userstatus','lonstatus','loncron','server-status','codeversions',
               'clusterstatus','metadata_keywords','metadata_harvest',
               'takeoffline','takeonline','showenv');
   }
   
 sub coursecategories_javascript {  sub coursecategories_javascript {
     my ($settings) = @_;      my ($settings) = @_;
     my ($output,$jstext,$cathash);      my ($output,$jstext,$cathash);
Line 2759  sub modify_colors { Line 2958  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 2833  sub modify_colors { Line 3039  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 2925  sub default_change_checker { Line 3143  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 2956  sub display_colorchgs { Line 3179  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 3275  END Line 3504  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;
                   }
             }              }
         }          }
     }      }
     foreach my $key (keys(%formhash)) {      if (ref($domconfig{'quotas'}) eq 'HASH') {
         if ($formhash{$key} ne '') {          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};
                   }
               }
           }
       }
       if (ref($confhash{'defaultquota'}) eq 'HASH') {
           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 4248  sub modify_defaults { Line 4568  sub modify_defaults {
     my ($dom,$r) = @_;      my ($dom,$r) = @_;
     my ($resulttext,$mailmsgtxt,%newvalues,%changes,@errors);      my ($resulttext,$mailmsgtxt,%newvalues,%changes,@errors);
     my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);      my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
     my @items = ('auth_def','auth_arg_def','lang_def','timezone_def');      my @items = ('auth_def','auth_arg_def','lang_def','timezone_def','datelocale_def');
     my @authtypes = ('internal','krb4','krb5','localauth');      my @authtypes = ('internal','krb4','krb5','localauth');
     foreach my $item (@items) {      foreach my $item (@items) {
         $newvalues{$item} = $env{'form.'.$item};          $newvalues{$item} = $env{'form.'.$item};
Line 4275  sub modify_defaults { Line 4595  sub modify_defaults {
                     push(@errors,$item);                         push(@errors,$item);   
                 }                  }
             }              }
           } elsif ($item eq 'datelocale_def') {
               if ($newvalues{$item} ne '') {
                   my @datelocale_ids = DateTime::Locale->ids();
                   if (!grep(/^\Q$newvalues{$item}\E$/,@datelocale_ids)) {
                       push(@errors,$item);
                   }
               }
         }          }
         if (grep(/^\Q$item\E$/,@errors)) {          if (grep(/^\Q$item\E$/,@errors)) {
             $newvalues{$item} = $domdefaults{$item};              $newvalues{$item} = $domdefaults{$item};
         } 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'},  
                                      }  
                        );  
     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 4317  sub modify_defaults { Line 4641  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'}) {  
                 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 4600  sub modify_coursecategories { Line 4923  sub modify_coursecategories {
     }      }
     return $resulttext;      return $resulttext;
 }  }
   
   sub modify_serverstatuses {
       my ($dom,%domconfig) = @_;
       my ($resulttext,%changes,%currserverstatus,%newserverstatus);
       if (ref($domconfig{'serverstatuses'}) eq 'HASH') {
           %currserverstatus = %{$domconfig{'serverstatuses'}};
       }
       my @pages = &serverstatus_pages();
       foreach my $type (@pages) {
           $newserverstatus{$type}{'namedusers'} = '';
           $newserverstatus{$type}{'machines'} = '';
           if (defined($env{'form.'.$type.'_namedusers'})) {
               my @users = split(/,/,$env{'form.'.$type.'_namedusers'});
               my @okusers;
               foreach my $user (@users) {
                   my ($uname,$udom) = split(/:/,$user);
                   if (($udom =~ /^$match_domain$/) &&   
                       (&Apache::lonnet::domain($udom)) &&
                       ($uname =~ /^$match_username$/)) {
                       if (!grep(/^\Q$user\E/,@okusers)) {
                           push(@okusers,$user);
                       }
                   }
               }
               if (@okusers > 0) {
                    @okusers = sort(@okusers);
                    $newserverstatus{$type}{'namedusers'} = join(',',@okusers);
               }
           }
           if (defined($env{'form.'.$type.'_machines'})) {
               my @machines = split(/,/,$env{'form.'.$type.'_machines'});
               my @okmachines;
               foreach my $ip (@machines) {
                   my @parts = split(/\./,$ip);
                   next if (@parts < 4);
                   my $badip = 0;
                   for (my $i=0; $i<4; $i++) {
                       if (!(($parts[$i] >= 0) && ($parts[$i] <= 255))) {
                           $badip = 1;
                           last;
                       }
                   }
                   if (!$badip) {
                       push(@okmachines,$ip);     
                   }
               }
               @okmachines = sort(@okmachines);
               $newserverstatus{$type}{'machines'} = join(',',@okmachines);
           }
       }
       my %serverstatushash =  (
                                   serverstatuses => \%newserverstatus,
                               );
       my $putresult = &Apache::lonnet::put_dom('configuration',\%serverstatushash,
                                                $dom);
       my %changes;
       foreach my $type (@pages) {
           if (ref($currserverstatus{$type}) eq 'HASH') {
               my @currnamed = split(/,/,$currserverstatus{$type}{'namedusers'});
               my @newusers = split(/,/,$newserverstatus{$type}{'namedusers'});
               foreach my $item (@currnamed) {
                   if (!grep(/^\Q$item\E$/,@newusers)) {
                       $changes{$type}{'namedusers'} = 1;
                       last;
                   }
               }
               foreach my $item (@newusers) {
                   if (!grep(/^\Q$item\E$/,@currnamed)) {
                       $changes{$type}{'namedusers'} = 1;
                       last;
                   }
               }
               my @currmachines = split(/,/,$currserverstatus{$type}{'machines'});
               my @newmachines = split(/,/,$newserverstatus{$type}{'machines'});
               foreach my $item (@currmachines) {
                   if (!grep(/^\Q$item\E$/,@newmachines)) {
                       $changes{$type}{'machines'} = 1;
                       last;
                   }
               }
               foreach my $item (@newmachines) {
                   if (!grep(/^\Q$item\E$/,@currmachines)) {
                       $changes{$type}{'machines'} = 1;
                       last;
                   }
               }
   
           }
       }
       if (keys(%changes) > 0) {
           my $titles= &LONCAPA::lonauthcgi::serverstatus_titles();
           my $putresult = &Apache::lonnet::put_dom('configuration',
                                                    \%serverstatushash,$dom);
           if ($putresult eq 'ok') {
               $resulttext .= &mt('Changes made:').'<ul>';
               foreach my $type (@pages) {
                   if (defined($changes{$type})) {
                       $resulttext .= '<li>'.$titles->{$type}.'<ul>';
                       if (defined($changes{$type}{'namedusers'})) {
                           if ($newserverstatus{$type}{'namedusers'} eq '') {
                               $resulttext .= '<li>'.&mt("Access terminated for all specific (named) users").'</li>'."\n";
                           } else {
                               $resulttext .= '<li>'.&mt("Access available for the following specified users: ").$newserverstatus{$type}{'namedusers'}.'</li>'."\n";
                           }
                       } elsif (defined($changes{$type}{'machines'})) {
                           if ($newserverstatus{$type}{'machines'} eq '') {
                               $resulttext .= '<li>'.&mt("Access terminated for all specific IP addresses").'</li>'."\n";
                           } else {
                               $resulttext .= '<li>'.&mt("Access available for the following specified IP addresses: ").$newserverstatus{$type}{'machines'}.'</li>'."\n";
                           }
   
                       }
                       $resulttext .= '</ul></li>';
                   }
               }
               $resulttext .= '</ul>';
           } else {
               $resulttext = '<span class="LC_error">'.
                             &mt('An error occurred saving access settings for server status pages: [_1].',$putresult).'</span>';
   
           }
       } else {
           $resulttext = &mt('No changes made to access to server status pages');
       }
       return $resulttext;
   }
   
 sub recurse_check {  sub recurse_check {
     my ($chkcats,$categories,$depth,$name) = @_;      my ($chkcats,$categories,$depth,$name) = @_;

Removed from v.1.64  
changed lines
  Added in v.1.76.2.4


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