Diff for /loncom/interface/domainprefs.pm between versions 1.102.2.16 and 1.103

version 1.102.2.16, 2011/02/07 21:39:45 version 1.103, 2009/08/20 20:13:06
Line 105  affiliate type (and also default, and _L Line 105  affiliate type (and also default, and _L
 (official, unofficial and community).  In each case the radio buttons allow the   (official, unofficial and community).  In each case the radio buttons allow the 
 selection of one of four values:  selection of one of four values:
   
 0, approval, validate, autolimit=N (where N is blank, or a positive integer).  0, approve, validate, autolimit=N (where N is blank, or a positive integer).
 which have the following effects:  which have the following effects:
   
 0  0
Line 116  which have the following effects: Line 116  which have the following effects:
   
 =back  =back
   
 approval   approve 
   
 =over   =over 
   
Line 199  sub handler { Line 199  sub handler {
     }      }
     my %domconfig =      my %domconfig =
       &Apache::lonnet::get_dom('configuration',['login','rolecolors',        &Apache::lonnet::get_dom('configuration',['login','rolecolors',
                 'quotas','autoenroll','autoupdate','autocreate',                  'quotas','autoenroll','autoupdate','directorysrch',
                 'directorysrch','usercreation','usermodification',                  'usercreation','usermodification','contacts','defaults',
                 'contacts','defaults','scantron','coursecategories',                  'scantron','coursecategories','serverstatuses',
                 'serverstatuses','requestcourses'],$dom);                  'requestcourses'],$dom);
     my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',      my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
                        'autoupdate','autocreate','directorysrch','contacts',                         'autoupdate','directorysrch','contacts',
                        'usercreation','usermodification','scantron',                         'usercreation','usermodification','scantron',
                        'requestcourses','coursecategories','serverstatuses');                         'requestcourses','coursecategories','serverstatuses');
     my %prefs = (      my %prefs = (
Line 233  sub handler { Line 233  sub handler {
                                   col2 => 'Value'}],                                    col2 => 'Value'}],
                     },                      },
         'quotas' =>           'quotas' => 
                     { text => 'User blogs, personal information pages, portfolios',                      { text => 'User blogs, personal information pages and portfolios',
                       help => 'Domain_Configuration_Quotas',                        help => 'Domain_Configuration_Quotas',
                       header => [{col1 => 'User affiliation',                        header => [{col1 => 'User affiliation',
                                   col2 => 'Available tools',                                    col2 => 'Available tools',
Line 250  sub handler { Line 250  sub handler {
                      help => 'Domain_Configuration_Auto_Updates',                       help => 'Domain_Configuration_Auto_Updates',
                      header => [{col1 => 'Setting',                       header => [{col1 => 'Setting',
                                  col2 => 'Value',},                                   col2 => 'Value',},
                                 {col1 => 'Setting',  
                                  col2 => 'Affiliation'},  
                                 {col1 => 'User population',                                  {col1 => 'User population',
                                  col2 => 'Updateable user data'}],                                   col2 => 'Updataeable user data'}],
                   },  
         'autocreate' =>   
                   {  text => 'Auto-course creation settings',  
                      help => 'Domain_Configuration_Auto_Creation',  
                      header => [{col1 => 'Configuration Setting',  
                                  col2 => 'Value',}],  
                   },                    },
         'directorysrch' =>           'directorysrch' => 
                   { text => 'Institutional directory searches',                    { text => 'Institutional directory searches',
Line 310  sub handler { Line 302  sub handler {
                               col2 => 'Value'}],                                col2 => 'Value'}],
                  },                   },
         'coursecategories' =>          'coursecategories' =>
                   { text => 'Cataloging of courses/communities',                    { text => 'Cataloging of courses',
                     help => 'Domain_Configuration_Cataloging_Courses',                      help => 'Domain_Configuration_Cataloging_Courses',
                     header => [{col1 => 'Category settings',                      header => [{col1 => 'Category settings',
                                 col2 => '',},                                  col2 => '',},
Line 326  sub handler { Line 318  sub handler {
                               col3 => 'Specific IPs',                                col3 => 'Specific IPs',
                             }],                              }],
                  },                   },
         'coursedefaults' =>  
                  {text => 'Course/Community defaults',  
                   help => 'Domain_Configuration_Course_Defaults',  
                   header => [{col1 => 'Setting',  
                               col2 => 'Value',}],  
                  },  
     );      );
     my %servers = &dom_servers($dom);  
     if (keys(%servers) > 1) {  
         $prefs{'login'}  = { text   => 'Log-in page options',  
                              help   => 'Domain_Configuration_Login_Page',  
                             header => [{col1 => 'Log-in Service',  
                                         col2 => 'Server Setting',},  
                                        {col1 => 'Log-in Page Items',  
                                         col2 => ''}],  
                            };  
     }  
     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');
     &Apache::lonhtmlcommon::add_breadcrumb      &Apache::lonhtmlcommon::add_breadcrumb
     ({href=>"javascript:changePage(document.$phase,'pickactions')",      ({href=>"javascript:changePage(document.$phase,'pickactions')",
       text=>"Settings to display/modify"});        text=>"Pick functionality"});
     my $confname = $dom.'-domainconfig';      my $confname = $dom.'-domainconfig';
     if ($phase eq 'process') {      if ($phase eq 'process') {
         &Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,\@roles);          &Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,\@roles);
Line 410  sub process_changes { Line 386  sub process_changes {
         $output = &modify_autoenroll($dom,%domconfig);          $output = &modify_autoenroll($dom,%domconfig);
     } elsif ($action eq 'autoupdate') {      } elsif ($action eq 'autoupdate') {
         $output = &modify_autoupdate($dom,%domconfig);          $output = &modify_autoupdate($dom,%domconfig);
     } elsif ($action eq 'autocreate') {  
         $output = &modify_autocreate($dom,%domconfig);  
     } elsif ($action eq 'directorysrch') {      } elsif ($action eq 'directorysrch') {
         $output = &modify_directorysrch($dom,%domconfig);          $output = &modify_directorysrch($dom,%domconfig);
     } elsif ($action eq 'usercreation') {      } elsif ($action eq 'usercreation') {
Line 449  sub print_config_box { Line 423  sub print_config_box {
            &Apache::loncommon::help_open_topic($item->{'help'}).'</span></th>'."\n".             &Apache::loncommon::help_open_topic($item->{'help'}).'</span></th>'."\n".
           '</tr>';            '</tr>';
     $rowtotal ++;      $rowtotal ++;
     my $numheaders = 1;      if (($action eq 'autoupdate') || ($action eq 'rolecolors') || 
     if (ref($item->{'header'}) eq 'ARRAY') {          ($action eq 'usercreation') || ($action eq 'usermodification') ||
         $numheaders = scalar(@{$item->{'header'}});          ($action eq 'coursecategories') || ($action eq 'requestcourses')) {
     }  
     if ($numheaders > 1) {  
         my $colspan = '';          my $colspan = '';
         if (($action eq 'rolecolors') || ($action eq 'coursecategories')) {          if (($action eq 'rolecolors') || ($action eq 'coursecategories')) {
             $colspan = ' colspan="2"';              $colspan = ' colspan="2"';
Line 475  sub print_config_box { Line 447  sub print_config_box {
             $output .= &print_usermodification('top',$dom,$settings,\$rowtotal);              $output .= &print_usermodification('top',$dom,$settings,\$rowtotal);
         } elsif ($action eq 'coursecategories') {          } elsif ($action eq 'coursecategories') {
             $output .= &print_coursecategories('top',$dom,$item,$settings,\$rowtotal);              $output .= &print_coursecategories('top',$dom,$item,$settings,\$rowtotal);
         } elsif ($action eq 'login') {  
             $output .= &print_login('top',$dom,$confname,$phase,$settings,\$rowtotal);  
             $colspan = ' colspan="2"';  
         } elsif ($action eq 'requestcourses') {          } elsif ($action eq 'requestcourses') {
             $output .= &print_quotas($dom,$settings,\$rowtotal,$action);              $output .= &print_quotas($dom,$settings,\$rowtotal,$action);
         } else {          } else {
Line 497  sub print_config_box { Line 466  sub print_config_box {
              </tr>';               </tr>';
             $rowtotal ++;              $rowtotal ++;
         if ($action eq 'autoupdate') {          if ($action eq 'autoupdate') {
             $output .= &print_autoupdate('middle',$dom,$settings,\$rowtotal).'              $output .= &print_autoupdate('bottom',$dom,$settings,\$rowtotal);
            </table>  
           </td>  
          </tr>  
          <tr>  
            <td>  
             <table class="LC_nested">  
              <tr class="LC_info_row">  
               <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td>  
               <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>      </tr>'.  
             &print_autoupdate('bottom',$dom,$settings,\$rowtotal);  
             $rowtotal ++;  
         } elsif ($action eq 'usercreation') {          } elsif ($action eq 'usercreation') {
             $output .= &print_usercreation('middle',$dom,$settings,\$rowtotal).'              $output .= &print_usercreation('middle',$dom,$settings,\$rowtotal).'
            </table>             </table>
Line 532  sub print_config_box { Line 490  sub print_config_box {
             <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.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
               <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td></tr>'.                <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>      </tr>'.
   
                        &print_usermodification('bottom',$dom,$settings,\$rowtotal);                         &print_usermodification('bottom',$dom,$settings,\$rowtotal);
             $rowtotal ++;              $rowtotal ++;
         } elsif ($action eq 'coursecategories') {          } elsif ($action eq 'coursecategories') {
             $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);              $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);
         } elsif ($action eq 'login') {  
             $output .= &print_login('bottom',$dom,$confname,$phase,$settings,\$rowtotal);  
         } elsif ($action eq 'requestcourses') {          } elsif ($action eq 'requestcourses') {
             $output .= &print_courserequestmail($dom,$settings,\$rowtotal);              $output .= &print_courserequestmail($dom,$settings,\$rowtotal);
         } else {          } else {
Line 609  sub print_config_box { Line 566  sub print_config_box {
         $output .= '</tr>';          $output .= '</tr>';
         $rowtotal ++;          $rowtotal ++;
         if ($action eq 'login') {          if ($action eq 'login') {
             $output .= &print_login('bottom',$dom,$confname,$phase,$settings,              $output .= &print_login($dom,$confname,$phase,$settings,\$rowtotal);
                                     \$rowtotal);  
         } elsif ($action eq 'quotas') {          } elsif ($action eq 'quotas') {
             $output .= &print_quotas($dom,$settings,\$rowtotal,$action);              $output .= &print_quotas($dom,$settings,\$rowtotal,$action);
         } elsif ($action eq 'autoenroll') {          } elsif ($action eq 'autoenroll') {
             $output .= &print_autoenroll($dom,$settings,\$rowtotal);              $output .= &print_autoenroll($dom,$settings,\$rowtotal);
         } elsif ($action eq 'autocreate') {  
             $output .= &print_autocreate($dom,$settings,\$rowtotal);  
         } elsif ($action eq 'directorysrch') {          } elsif ($action eq 'directorysrch') {
             $output .= &print_directorysrch($dom,$settings,\$rowtotal);              $output .= &print_directorysrch($dom,$settings,\$rowtotal);
         } elsif ($action eq 'contacts') {          } elsif ($action eq 'contacts') {
Line 638  sub print_config_box { Line 592  sub print_config_box {
 }  }
   
 sub print_login {  sub print_login {
     my ($position,$dom,$confname,$phase,$settings,$rowtotal) = @_;      my ($dom,$confname,$phase,$settings,$rowtotal) = @_;
     my ($css_class,$datatable);  
     my %choices = &login_choices();      my %choices = &login_choices();
   
     if ($position eq 'top') {  
         my %servers = &dom_servers($dom);  
         my $choice = $choices{'disallowlogin'};  
         $css_class = ' class="LC_odd_row"';  
         $datatable .= '<tr'.$css_class.'><td>'.$choice.'</td>'.  
                       '<td align="right"><table><tr><th>'.$choices{'hostid'}.'</th>'.  
                       '<th>'.$choices{'server'}.'</th>'.  
                       '<th>'.$choices{'serverpath'}.'</th>'.  
                       '<th>'.$choices{'custompath'}.'</th>'.  
                       '<th><span class="LC_nobreak">'.$choices{'exempt'}.'</span></th></tr>'."\n";  
         my %disallowed;  
         if (ref($settings) eq 'HASH') {  
             if (ref($settings->{'loginvia'}) eq 'HASH') {  
                %disallowed = %{$settings->{'loginvia'}};  
             }  
         }  
         foreach my $lonhost (sort(keys(%servers))) {  
             my $direct = 'selected="selected"';  
             if (ref($disallowed{$lonhost}) eq 'HASH') {  
                 if ($disallowed{$lonhost}{'server'} ne '') {  
                     $direct = '';  
                 }  
             }  
             $datatable .= '<tr><td>'.$servers{$lonhost}.'</td>'.  
                           '<td><select name="'.$lonhost.'_server">'.  
                           '<option value=""'.$direct.'>'.$choices{'directlogin'}.  
                           '</option>';  
             foreach my $hostid (keys(%servers)) {  
                 next if ($servers{$hostid} eq $servers{$lonhost});  
                 my $selected = '';  
                 if (ref($disallowed{$lonhost}) eq 'HASH') {  
                     if ($hostid eq $disallowed{$lonhost}{'server'}) {  
                         $selected = 'selected="selected"';  
                     }  
                 }  
                 $datatable .= '<option value="'.$hostid.'"'.$selected.'>'.  
                               $servers{$hostid}.'</option>';  
             }  
             $datatable .= '</select></td>'.  
                           '<td><select name="'.$lonhost.'_serverpath">';  
             foreach my $path ('','/','/adm/login','/adm/roles','custom') {  
                 my $pathname = $path;  
                 if ($path eq 'custom') {  
                     $pathname = &mt('Custom Path').' ->';  
                 }  
                 my $selected = '';  
                 if (ref($disallowed{$lonhost}) eq 'HASH') {  
                     if ($path eq $disallowed{$lonhost}{'serverpath'}) {  
                         $selected = 'selected="selected"';  
                     }  
                 } elsif ($path eq '') {  
                     $selected = 'selected="selected"';  
                 }  
                 $datatable .= '<option value="'.$path.'"'.$selected.'>'.$pathname.'</option>';  
             }  
             $datatable .= '</select></td>';  
             my ($custom,$exempt);  
             if (ref($disallowed{$lonhost}) eq 'HASH') {  
                 $custom = $disallowed{$lonhost}{'custompath'};  
                 $exempt = $disallowed{$lonhost}{'exempt'};  
             }  
             $datatable .= '<td><input type="text" name="'.$lonhost.'_custompath" size="6" value="'.$custom.'" /></td>'.  
                           '<td><input type="text" name="'.$lonhost.'_exempt" size="8" value="'.$exempt.'" /></td>'.  
                           '</tr>';  
         }  
         $datatable .= '</table></td></tr>';  
         return $datatable;  
     }  
   
     my %defaultchecked = (       my %defaultchecked = ( 
                            'coursecatalog' => 'on',                             'coursecatalog' => 'on',
                            'adminmail'     => 'off',                             'adminmail'     => 'off',
Line 824  sub print_login { Line 707  sub print_login {
                                                   domlogo => 'Domain Logo',                                                    domlogo => 'Domain Logo',
                                                   login => 'Login box');                                                    login => 'Login box');
     my $itemcount = 1;      my $itemcount = 1;
       my ($css_class,$datatable);
     foreach my $item (@toggles) {      foreach my $item (@toggles) {
         $css_class = $itemcount%2?' class="LC_odd_row"':'';          $css_class = $itemcount%2?' class="LC_odd_row"':'';
         $datatable .=            $datatable .=  
Line 844  sub print_login { Line 728  sub print_login {
 sub login_choices {  sub login_choices {
     my %choices =      my %choices =
         &Apache::lonlocal::texthash (          &Apache::lonlocal::texthash (
             coursecatalog => 'Display Course/Community Catalog link?',              coursecatalog => 'Display Course Catalog link?',
             adminmail => "Display Administrator's E-mail Address?",              adminmail => "Display Administrator's E-mail Address?",
             disallowlogin => "Login page requests redirected",  
             hostid        => "Server",  
             server        => "Redirect to:",  
             serverpath    => "Path",  
             custompath    => "Custom",  
             exempt        => "Exempt IP(s)",  
             directlogin   => "No redirect",  
             newuser   => "Link to create a user account",              newuser   => "Link to create a user account",
             img => "Header",              img => "Header",
             logo => "Main Logo",              logo => "Main Logo",
Line 886  sub print_rolecolors { Line 763  sub print_rolecolors {
     my %defaults = (      my %defaults = (
                    img => $defaultdesign{$role.'.img'},                     img => $defaultdesign{$role.'.img'},
                    font => $defaultdesign{$role.'.font'},                     font => $defaultdesign{$role.'.font'},
      fontmenu => $defaultdesign{$role.'.fontmenu'},
                    );                     );
     foreach my $item (@bgs) {      foreach my $item (@bgs) {
         $defaults{'bgs'}{$item} = $defaultdesign{$role.'.'.$item};          $defaults{'bgs'}{$item} = $defaultdesign{$role.'.'.$item};
Line 903  sub print_rolecolors { Line 781  sub print_rolecolors {
                 $designs{'font'} = $settings->{$role}->{'font'};                  $designs{'font'} = $settings->{$role}->{'font'};
                 $is_custom{'font'} = 1;                  $is_custom{'font'} = 1;
             }              }
               if ($settings->{$role}->{'fontmenu'} ne '') {
                   $designs{'fontmenu'} = $settings->{$role}->{'fontmenu'};
                   $is_custom{'fontmenu'} = 1;
               }
             foreach my $item (@bgs) {              foreach my $item (@bgs) {
                 if ($settings->{$role}->{$item} ne '') {                  if ($settings->{$role}->{$item} ne '') {
                     $designs{'bgs'}{$item} = $settings->{$role}->{$item};                      $designs{'bgs'}{$item} = $settings->{$role}->{$item};
Line 921  sub print_rolecolors { Line 803  sub print_rolecolors {
             $designs{img} = $designhash{$dom.'.'.$role.'.img'};              $designs{img} = $designhash{$dom.'.'.$role.'.img'};
             $is_custom{'img'} = 1;              $is_custom{'img'} = 1;
         }          }
           if ($designhash{$dom.'.'.$role.'.fontmenu'} ne '') {
               $designs{fontmenu} = $designhash{$dom.'.'.$role.'.fontmenu'};
               $is_custom{'fontmenu'} = 1; 
           }
         if ($designhash{$dom.'.'.$role.'.font'} ne '') {          if ($designhash{$dom.'.'.$role.'.font'} ne '') {
             $designs{font} = $designhash{$dom.'.'.$role.'.font'};              $designs{font} = $designhash{$dom.'.'.$role.'.font'};
             $is_custom{'font'} = 1;              $is_custom{'font'} = 1;
Line 949  sub display_color_options { Line 835  sub display_color_options {
     my ($dom,$confname,$phase,$role,$itemcount,$choices,$is_custom,$defaults,$designs,      my ($dom,$confname,$phase,$role,$itemcount,$choices,$is_custom,$defaults,$designs,
         $images,$bgs,$links,$alt_text,$rowtotal,$logintext,$loginheader) = @_;          $images,$bgs,$links,$alt_text,$rowtotal,$logintext,$loginheader) = @_;
     my $css_class = $itemcount%2?' class="LC_odd_row"':'';      my $css_class = $itemcount%2?' class="LC_odd_row"':'';
     my $datatable = '<tr'.$css_class.'>'.      my $datatable = '<tr>'.
         '<td>'.$choices->{'font'}.'</td>';          '<td>'.$choices->{'font'}.'</td>';
     if (!$is_custom->{'font'}) {      if (!$is_custom->{'font'}) {
         $datatable .=  '<td>'.&mt('Default in use:').'&nbsp;<span id="css_default_'.$role.'_font" style="color: '.$defaults->{'font'}.';">'.$defaults->{'font'}.'</span></td>';          $datatable .=  '<td>'.&mt('Default in use:').'&nbsp;<span id="css_default_'.$role.'_font" style="color: '.$defaults->{'font'}.';">'.$defaults->{'font'}.'</span></td>';
Line 963  sub display_color_options { Line 849  sub display_color_options {
                   '&nbsp;<span id="css_'.$role.'_font" style="background-color: '.                    '&nbsp;<span id="css_'.$role.'_font" style="background-color: '.
                   $designs->{'font'}.';">&nbsp;&nbsp;&nbsp;</span>'.                    $designs->{'font'}.';">&nbsp;&nbsp;&nbsp;</span>'.
                   '</span></td></tr>';                    '</span></td></tr>';
       $datatable .= '<tr'.$css_class.'>'.
           '<td>'.$choices->{'fontmenu'}.'</td>';
       if (!$is_custom->{'fontmenu'}) {
           $datatable .=  '<td>'.&mt('Default in use:').'&nbsp;<span id="css_default_'.$role.'_font" style="color: '.$defaults->{'fontmenu'}.';">'.$defaults->{'fontmenu'}.'</span></td>';
       } else {
           $datatable .= '<td>&nbsp;</td>';
       }
       $fontlink = &color_pick($phase,$role,'fontmenu',$choices->{'fontmenu'},$designs->{'fontmenu'});
       $datatable .= '<td><span class="LC_nobreak">'.
                     '<input type="text" size="10" name="'.$role.'_fontmenu"'.
                     ' value="'.$designs->{'fontmenu'}.'" />&nbsp;'.$fontlink.
                     '&nbsp;<span id="css_'.$role.'_fontmenu" style="background-color: '.
                     $designs->{'fontmenu'}.';">&nbsp;&nbsp;&nbsp;</span>'.
                     '</span></td></tr>';
     my $switchserver = &check_switchserver($dom,$confname);      my $switchserver = &check_switchserver($dom,$confname);
     foreach my $img (@{$images}) {      foreach my $img (@{$images}) {
  $itemcount ++;   $itemcount ++;
Line 1249  sub print_quotas { Line 1149  sub print_quotas {
     my ($css_class,%titles);      my ($css_class,%titles);
     if ($context eq 'requestcourses') {      if ($context eq 'requestcourses') {
         @usertools = ('official','unofficial','community');          @usertools = ('official','unofficial','community');
         @options =('norequest','approval','validate','autolimit');          @options =('norequest','approve','autolimit','validate');
         %validations = &Apache::lonnet::auto_courserequest_checks($dom);          %validations = &Apache::lonnet::auto_courserequest_checks($dom);
         %titles = &courserequest_titles();          %titles = &courserequest_titles();
     } else {      } else {
Line 1318  sub print_quotas { Line 1218  sub print_quotas {
                             $cell{$item} .= '<span class="LC_nobreak"><label>'.                              $cell{$item} .= '<span class="LC_nobreak"><label>'.
                                   '<input type="radio" name="crsreq_'.$item.                                    '<input type="radio" name="crsreq_'.$item.
                                   '_'.$type.'" value="'.$val.'"'.$checked.' />'.                                    '_'.$type.'" value="'.$val.'"'.$checked.' />'.
                                   $titles{$option}.'</label>';                                    $titles{$option}.'</label>&nbsp;';
                             if ($option eq 'autolimit') {                              if ($option eq 'autolimit') {
                                 $cell{$item} .= '&nbsp;<input type="text" name="crsreq_'.                                  $cell{$item} .= '<input type="text" name="crsreq_'.
                                                 $item.'_limit_'.$type.'" size="1" '.                                                  $item.'_limit_'.$type.'" size="1" '.
                                                 'value="'.$currlimit.'" />';                                                  'value="'.$currlimit.'" />';
                             }                              }
                             $cell{$item} .= '</span> ';                              $cell{$item} .= '</span>&nbsp; ';
                             if ($option eq 'autolimit') {                              if ($option eq 'autolimit') {
                                 $cell{$item} .= $titles{'unlimited'};                                  $cell{$item} .= $titles{'unlimited'}
                             }                              }
                         }                          }
                     } else {                      } else {
Line 1349  sub print_quotas { Line 1249  sub print_quotas {
                 if ($context eq 'requestcourses') {                  if ($context eq 'requestcourses') {
                     $datatable .= '</tr><tr>';                      $datatable .= '</tr><tr>';
                     foreach my $item (@usertools) {                      foreach my $item (@usertools) {
                         $datatable .= '<td style="vertical-align: top;">'.$cell{$item}.'</td>';                            $datatable .= '<td>'.$cell{$item}.'</td>';  
                     }                      }
                     $datatable .= '</tr></table>';                      $datatable .= '</tr></table>';
                 }                  }
Line 1426  sub print_quotas { Line 1326  sub print_quotas {
                                   '_default" value="'.$val.'"'.$checked.' />'.                                    '_default" value="'.$val.'"'.$checked.' />'.
                                   $titles{$option}.'</label>';                                    $titles{$option}.'</label>';
                 if ($option eq 'autolimit') {                  if ($option eq 'autolimit') {
                     $defcell{$item} .= '&nbsp;<input type="text" name="crsreq_'.                      $defcell{$item} .= '<input type="text" name="crsreq_'.
                                        $item.'_limit_default" size="1" '.                                         $item.'_limit_default" size="1" '.
                                        'value="'.$currlimit.'" />';                                         'value="'.$currlimit.'" />';
                 }                  }
                 $defcell{$item} .= '</span> ';                  $defcell{$item} .= '</span>&nbsp; ';
                 if ($option eq 'autolimit') {  
                     $defcell{$item} .= $titles{'unlimited'};  
                 }  
             }              }
         } else {          } else {
             my $checked = 'checked="checked" ';              my $checked = 'checked="checked" ';
Line 1455  sub print_quotas { Line 1352  sub print_quotas {
     if ($context eq 'requestcourses') {      if ($context eq 'requestcourses') {
         $datatable .= '</tr><tr>';          $datatable .= '</tr><tr>';
         foreach my $item (@usertools) {          foreach my $item (@usertools) {
             $datatable .= '<td style="vertical-align: top;">'.$defcell{$item}.'</td>';              $datatable .= '<td>'.$defcell{$item}.'</td>';
         }          }
         $datatable .= '</tr></table>';          $datatable .= '</tr></table>';
     }      }
Line 1469  sub print_quotas { Line 1366  sub print_quotas {
     $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>'.&mt('LON-CAPA Advanced Users').' ';                    '<td>'.&mt('LON-CAPA Advanced Users').
                     ' <span class="LC_nobreak">('.
                     &mt('overrides affiliation').')</span></td>'.
                     '<td class="LC_left_item" colspan="2">';
     if ($context eq 'requestcourses') {      if ($context eq 'requestcourses') {
         $datatable .= &mt('(overrides affiliation, if set)').          $datatable .= '<table><tr>';
                       '</td>'.  
                       '<td class="LC_left_item">'.  
                       '<table><tr>';  
     } else {      } else {
         $datatable .= &mt('(overrides affiliation, if checked)').          $datatable .= '<br />';
                       '</td>'.  
                       '<td class="LC_left_item" colspan="2">'.  
                       '<br />';  
     }      }
     my %advcell;      my %advcell;
     foreach my $item (@usertools) {      foreach my $item (@usertools) {
Line 1493  sub print_quotas { Line 1387  sub print_quotas {
                     }                      }
                 }                  }
             }              }
               if (!$curroption) {
                   $curroption = 'norequest';
               }
             $datatable .= '<th>'.$titles{$item}.'</th>';              $datatable .= '<th>'.$titles{$item}.'</th>';
             my $checked = '';  
             if ($curroption eq '') {  
                 $checked = ' checked="checked"';  
             }  
             $advcell{$item} .= '<span class="LC_nobreak"><label>'.  
                                '<input type="radio" name="crsreq_'.$item.  
                                '__LC_adv" value=""'.$checked.' />'.  
                                &mt('No override set').'</label></span>&nbsp; ';  
             foreach my $option (@options) {              foreach my $option (@options) {
                 my $val = $option;                  my $val = $option;
                 if ($option eq 'norequest') {                  if ($option eq 'norequest') {
Line 1517  sub print_quotas { Line 1406  sub print_quotas {
                     next if (!$canvalidate);                      next if (!$canvalidate);
                 }                  }
                 my $checked = '';                  my $checked = '';
                 if ($val eq $curroption) {                  if ($option eq $curroption) {
                     $checked = ' checked="checked"';                      $checked = ' checked="checked"';
                 } elsif ($option eq 'autolimit') {                  } elsif ($option eq 'autolimit') {
                     if ($curroption =~ /^autolimit/) {                      if ($curroption =~ /^autolimit/) {
Line 1529  sub print_quotas { Line 1418  sub print_quotas {
                                   '__LC_adv" value="'.$val.'"'.$checked.' />'.                                    '__LC_adv" value="'.$val.'"'.$checked.' />'.
                                   $titles{$option}.'</label>';                                    $titles{$option}.'</label>';
                 if ($option eq 'autolimit') {                  if ($option eq 'autolimit') {
                     $advcell{$item} .= '&nbsp;<input type="text" name="crsreq_'.                      $advcell{$item} .= '<input type="text" name="crsreq_'.
                                        $item.'_limit__LC_adv" size="1" '.                                         $item.'_limit__LC_adv" size="1" '.
                                        'value="'.$currlimit.'" />';                                         'value="'.$currlimit.'" />';
                 }                  }
                 $advcell{$item} .= '</span> ';                  $advcell{$item} .= '</span>&nbsp; ';
                 if ($option eq 'autolimit') {  
                     $advcell{$item} .= $titles{'unlimited'};  
                 }  
             }              }
         } else {          } else {
             my $checked = 'checked="checked" ';              my $checked = 'checked="checked" ';
Line 1558  sub print_quotas { Line 1444  sub print_quotas {
     if ($context eq 'requestcourses') {      if ($context eq 'requestcourses') {
         $datatable .= '</tr><tr>';          $datatable .= '</tr><tr>';
         foreach my $item (@usertools) {          foreach my $item (@usertools) {
             $datatable .= '<td style="vertical-align: top;">'.$advcell{$item}.'</td>';              $datatable .= '<td>'.$advcell{$item}.'</td>';
         }          }
         $datatable .= '</tr></table>';          $datatable .= '</tr></table>';
     }      }
Line 1569  sub print_quotas { Line 1455  sub print_quotas {
   
 sub print_courserequestmail {  sub print_courserequestmail {
     my ($dom,$settings,$rowtotal) = @_;      my ($dom,$settings,$rowtotal) = @_;
     my ($now,$datatable,%dompersonnel,@domcoord,@currapproval,$rows);      my ($now,$datatable,%dompersonnel,@domcoord,@currapprove,$rows);
     $now = time;      $now = time;
     $rows = 0;      $rows = 0;
     %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc'],$now,$now);      %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc'],$now,$now);
Line 1584  sub print_courserequestmail { Line 1470  sub print_courserequestmail {
     if (ref($settings) eq 'HASH') {      if (ref($settings) eq 'HASH') {
         if (ref($settings->{'notify'}) eq 'HASH') {          if (ref($settings->{'notify'}) eq 'HASH') {
             if ($settings->{'notify'}{'approval'} ne '') {              if ($settings->{'notify'}{'approval'} ne '') {
                @currapproval = split(',',$settings->{'notify'}{'approval'});                 @currapprove = split(',',$settings->{'notify'}{'approval'});
             }              }
         }          }
     }      }
     if (@currapproval) {      if (@currapprove) {
         foreach my $dc (@currapproval) {          foreach my $dc (@currapprove) {
             unless (grep(/^\Q$dc\E$/,@domcoord)) {              unless (grep(/^\Q$dc\E$/,@domcoord)) {
                 push(@domcoord,$dc);                  push(@domcoord,$dc);
             }              }
Line 1615  sub print_courserequestmail { Line 1501  sub print_courserequestmail {
                 $rows ++;                  $rows ++;
             }              }
             my $check = ' ';              my $check = ' ';
             if (grep(/^\Q$domcoord[$i]\E$/,@currapproval)) {              if (grep(/^\Q$domcoord[$i]\E$/,@currapprove)) {
                 $check = ' checked="checked" ';                  $check = ' checked="checked" ';
             }              }
             my ($uname,$udom) = split(':',$domcoord[$i]);              my ($uname,$udom) = split(':',$domcoord[$i]);
Line 1648  sub print_courserequestmail { Line 1534  sub print_courserequestmail {
 sub print_autoenroll {  sub print_autoenroll {
     my ($dom,$settings,$rowtotal) = @_;      my ($dom,$settings,$rowtotal) = @_;
     my $autorun = &Apache::lonnet::auto_run(undef,$dom),      my $autorun = &Apache::lonnet::auto_run(undef,$dom),
     my ($defdom,$runon,$runoff,$coownerson,$coownersoff);      my ($defdom,$runon,$runoff);
     if (ref($settings) eq 'HASH') {      if (ref($settings) eq 'HASH') {
         if (exists($settings->{'run'})) {          if (exists($settings->{'run'})) {
             if ($settings->{'run'} eq '0') {              if ($settings->{'run'} eq '0') {
Line 1667  sub print_autoenroll { Line 1553  sub print_autoenroll {
                 $runon = ' ';                  $runon = ' ';
             }              }
         }          }
         if (exists($settings->{'co-owners'})) {  
             if ($settings->{'co-owners'} eq '0') {  
                 $coownersoff = ' checked="checked" ';  
                 $coownerson = ' ';  
             } else {  
                 $coownerson = ' checked="checked" ';  
                 $coownersoff = ' ';  
             }  
         } else {  
             $coownersoff = ' checked="checked" ';  
             $coownerson = ' ';  
         }  
         if (exists($settings->{'sender_domain'})) {          if (exists($settings->{'sender_domain'})) {
             $defdom = $settings->{'sender_domain'};              $defdom = $settings->{'sender_domain'};
         }          }
Line 1709  sub print_autoenroll { Line 1583  sub print_autoenroll {
                   &mt('username').':&nbsp;'.                    &mt('username').':&nbsp;'.
                   '<input type="text" name="sender_uname" value="'.                    '<input type="text" name="sender_uname" value="'.
                   $notif_sender.'" size="10" />&nbsp;&nbsp;'.&mt('domain').                    $notif_sender.'" size="10" />&nbsp;&nbsp;'.&mt('domain').
                   ':&nbsp;'.$domform.'</span></td></tr>'.                    ':&nbsp;'.$domform.'</span></td></tr>';
                   '<tr class="LC_odd_row">'.      $$rowtotal += 2;
                   '<td>'.&mt('Automatically assign co-ownership').'</td>'.  
                   '<td class="LC_right_item"><span class="LC_nobreak"><label>'.  
                   '<input type="radio" name="autoassign_coowners"'.  
                   $coownerson.' value="1" />'.&mt('Yes').'</label>&nbsp;'.  
                   '<label><input type="radio" name="autoassign_coowners"'.  
                   $coownersoff.' value="0" />'.&mt('No').'</label></span></td>'.  
                   '</tr>';  
     $$rowtotal += 3;  
     return $datatable;      return $datatable;
 }  }
   
Line 1760  sub print_autoupdate { Line 1626  sub print_autoupdate {
                   $classlistsoff.'value="0" />'.&mt('No').'</label></span></td>'.                    $classlistsoff.'value="0" />'.&mt('No').'</label></span></td>'.
                   '</tr>';                    '</tr>';
         $$rowtotal += 2;          $$rowtotal += 2;
     } elsif ($position eq 'middle') {  
         my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);  
         my $numinrow = 3;  
         my $locknamesettings;  
         $datatable .= &insttypes_row($settings,$types,$usertypes,  
                                      $dom,$numinrow,$othertitle,  
                                     'lockablenames');  
         $$rowtotal ++;  
     } else {      } else {
         my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);          my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
         my @fields = ('lastname','firstname','middlename','generation',          my @fields = ('lastname','firstname','middlename','gen',
                       'permanentemail','id');                        'permanentemail','id');
         my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();          my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
         my $numrows = 0;          my $numrows = 0;
Line 1791  sub print_autoupdate { Line 1649  sub print_autoupdate {
     return $datatable;      return $datatable;
 }  }
   
 sub print_autocreate {  
     my ($dom,$settings,$rowtotal) = @_;  
     my (%createon,%createoff);  
     my $curr_dc;  
     my @types = ('xml','req');  
     if (ref($settings) eq 'HASH') {  
         foreach my $item (@types) {  
             $createoff{$item} = ' checked="checked" ';  
             $createon{$item} = ' ';  
             if (exists($settings->{$item})) {  
                 if ($settings->{$item}) {  
                     $createon{$item} = ' checked="checked" ';  
                     $createoff{$item} = ' ';  
                 }  
             }  
         }  
         $curr_dc = $settings->{'xmldc'};  
     } else {  
         foreach my $item (@types) {  
             $createoff{$item} = ' checked="checked" ';  
             $createon{$item} = ' ';  
         }  
     }  
     $$rowtotal += 2;  
     my $datatable='<tr class="LC_odd_row">'.  
                   '<td>'.&mt('Create pending official courses from XML files').'</td>'.  
                   '<td class="LC_right_item"><span class="LC_nobreak"><label>'.  
                   '<input type="radio" name="autocreate_xml"'.  
                   $createon{'xml'}.' value="1" />'.&mt('Yes').'</label>&nbsp;'.  
                   '<label><input type="radio" name="autocreate_xml"'.  
                   $createoff{'xml'}.' value="0" />'.&mt('No').'</label></span>';  
     my ($numdc,$dctable) = &active_dc_picker($dom,$curr_dc);  
     if ($numdc > 1) {  
         $datatable .= '</td><tr><td>'.  
                       &mt('XML files processed as: (choose Dom. Coord.)').  
                       '</td><td class="LC_left_item">'.$dctable.'</td></tr>'.  
                       '<tr class="LC_odd_row">';  
         $$rowtotal ++ ;  
     } else {  
         $datatable .= '</td></tr><tr>';  
     }  
     $datatable .= '<td>'.&mt('Create pending requests for official courses (if validated)').'</td>'.  
                   '<td class="LC_right_item"><span class="LC_nobreak"><label>'.  
                   '<input type="radio" name="autocreate_req"'.  
                   $createon{'req'}.' value="1" />'.&mt('Yes').'</label>&nbsp;'.  
                   '<label><input type="radio" name="autocreate_req"'.  
                   $createoff{'req'}.' value="0" />'.&mt('No').'</label></span></td>'.  
                   '</tr>';  
     return $datatable;  
 }  
   
 sub print_directorysrch {  sub print_directorysrch {
     my ($dom,$settings,$rowtotal) = @_;      my ($dom,$settings,$rowtotal) = @_;
     my $srchon = ' ';      my $srchon = ' ';
Line 1959  sub print_contacts { Line 1766  sub print_contacts {
     my ($dom,$settings,$rowtotal) = @_;      my ($dom,$settings,$rowtotal) = @_;
     my $datatable;      my $datatable;
     my @contacts = ('adminemail','supportemail');      my @contacts = ('adminemail','supportemail');
     my (%checked,%to,%otheremails,%bccemails);      my (%checked,%to,%otheremails);
     my @mailings = ('errormail','packagesmail','lonstatusmail','helpdeskmail',      my @mailings = ('errormail','packagesmail','lonstatusmail','helpdeskmail',
                     'requestsmail');                      'requestsmail');
     foreach my $type (@mailings) {      foreach my $type (@mailings) {
         $otheremails{$type} = '';          $otheremails{$type} = '';
     }      }
     $bccemails{'helpdeskmail'} = '';  
     if (ref($settings) eq 'HASH') {      if (ref($settings) eq 'HASH') {
         foreach my $item (@contacts) {          foreach my $item (@contacts) {
             if (exists($settings->{$item})) {              if (exists($settings->{$item})) {
Line 1981  sub print_contacts { Line 1787  sub print_contacts {
                         }                          }
                     }                      }
                     $otheremails{$type} = $settings->{$type}{'others'};                      $otheremails{$type} = $settings->{$type}{'others'};
                     if ($type eq 'helpdeskmail') {  
                         $bccemails{$type} = $settings->{$type}{'bcc'};  
                     }  
                 }                  }
             } elsif ($type eq 'lonstatusmail') {              } elsif ($type eq 'lonstatusmail') {
                 $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" ';                  $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" ';
Line 2027  sub print_contacts { Line 1830  sub print_contacts {
         }          }
         $datatable .= '</span><br />'.&mt('Others').':&nbsp;&nbsp;'.          $datatable .= '</span><br />'.&mt('Others').':&nbsp;&nbsp;'.
                       '<input type="text" name="'.$type.'_others" '.                        '<input type="text" name="'.$type.'_others" '.
                       'value="'.$otheremails{$type}.'"  />';                        'value="'.$otheremails{$type}.'"  />'.
         if ($type eq 'helpdeskmail') {                        '</td></tr>'."\n";
             $datatable .= '<br />'.&mt('Bcc:').('&nbsp;'x6).  
                           '<input type="text" name="'.$type.'_bcc" '.  
                           'value="'.$bccemails{$type}.'"  />';  
         }  
         $datatable .= '</td></tr>'."\n";  
     }      }
     $$rowtotal += $rownum;      $$rowtotal += $rownum;
     return $datatable;      return $datatable;
 }  }
   
 sub radiobutton_prefs {  
     my ($settings,$toggles,$defaultchecked,$choices,$itemcount) = @_;  
     return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') &&  
                    (ref($choices) eq 'HASH'));  
   
     my (%checkedon,%checkedoff,$datatable,$css_class);  
   
     foreach my $item (@{$toggles}) {  
         if ($defaultchecked->{$item} eq 'on') {  
             $checkedon{$item} = ' checked="checked" ';  
             $checkedoff{$item} = ' ';  
         } elsif ($defaultchecked->{$item} eq 'off') {  
             $checkedoff{$item} = ' checked="checked" ';  
             $checkedon{$item} = ' ';  
         }  
     }  
     if (ref($settings) eq 'HASH') {  
         foreach my $item (@{$toggles}) {  
             if ($settings->{$item} eq '1') {  
                 $checkedon{$item} =  ' checked="checked" ';  
                 $checkedoff{$item} = ' ';  
             } elsif ($settings->{$item} eq '0') {  
                 $checkedoff{$item} =  ' checked="checked" ';  
                 $checkedon{$item} = ' ';  
             }  
         }  
     }  
     foreach my $item (@{$toggles}) {  
         $css_class = $itemcount%2?' class="LC_odd_row"':'';  
         $datatable .=  
             '<tr'.$css_class.'><td><span class="LC_nobreak">'.$choices->{$item}.  
             '</span></td>'.  
             '<td class="LC_right_item"><span class="LC_nobreak">'.  
             '<label><input type="radio" name="'.  
             $item.'" '.$checkedon{$item}.' value="1" />'.&mt('Yes').  
             '</label>&nbsp;<label><input type="radio" name="'.$item.'" '.  
             $checkedoff{$item}.' value="0" />'.&mt('No').'</label>'.  
             '</span></td>'.  
             '</tr>';  
         $itemcount ++;  
     }  
     return ($datatable,$itemcount);  
 }  
   
 sub print_coursedefaults {  
     my ($dom,$settings,$rowtotal) = @_;  
     my ($css_class,$datatable);  
     my $itemcount = 1;  
     my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles);  
     %choices =  
         &Apache::lonlocal::texthash (  
             canuse_pdfforms => 'Course/Community users can create/upload PDF forms',  
     );  
     %defaultchecked = ('canuse_pdfforms' => 'off');  
     @toggles = ('canuse_pdfforms',);  
     ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,  
                                                  \%choices,$itemcount);  
     $$rowtotal += $itemcount;  
     return $datatable;  
 }  
   
 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',
Line 2135  sub courserequest_titles { Line 1872  sub courserequest_titles {
                                    unofficial => 'Unofficial',                                     unofficial => 'Unofficial',
                                    community  => 'Communities',                                     community  => 'Communities',
                                    norequest  => 'Not allowed',                                     norequest  => 'Not allowed',
                                    approval   => 'Approval by Dom. Coord.',                                     approve    => 'Approval by Dom. Coord.',
                                    validate   => 'With validation',                                     validate   => 'With validation',
                                    autolimit  => 'Numerical limit',                                     autolimit  => 'Numerical limit',
                                    unlimited  => '(blank for unlimited)',                                     unlimited  => '(blank for unlimited)',
Line 2145  sub courserequest_titles { Line 1882  sub courserequest_titles {
   
 sub courserequest_conditions {  sub courserequest_conditions {
     my %conditions = &Apache::lonlocal::texthash (      my %conditions = &Apache::lonlocal::texthash (
        approval   => '(Processing of request subject to approval by Domain Coordinator).',         approve    => '(Processing of request subject to approval by Domain Coordinator).',
        validate   => '(Processing of request subject to instittutional validation).',         validate   => '(Processing of request subject to instittutional validation).',
                  );                   );
     return %conditions;      return %conditions;
Line 2641  sub print_scantronformat { Line 2378  sub print_scantronformat {
                       '<span class="LC_nobreak">';                        '<span class="LC_nobreak">';
         if ($scantronurl) {          if ($scantronurl) {
             $datatable .= '<a href="'.$scantronurl.'" target="_blank">'.              $datatable .= '<a href="'.$scantronurl.'" target="_blank">'.
                           &mt('Default bubblesheet format file').'</a>';                            &mt('Default scantron format file').'</a>';
         } else {          } else {
             $datatable = &mt('File unavailable for display');              $datatable = &mt('File unavailable for display');
         }          }
Line 2668  sub print_scantronformat { Line 2405  sub print_scantronformat {
         } elsif ($scantronurl) {          } elsif ($scantronurl) {
             $datatable .= '<td><span class="LC_nobreak">'.              $datatable .= '<td><span class="LC_nobreak">'.
                           '<a href="'.$scantronurl.'" target="_blank">'.                            '<a href="'.$scantronurl.'" target="_blank">'.
                           &mt('Custom bubblesheet format file').'</a><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></span></td>'.                            '" value="1" />'.&mt('Delete?').'</label></span></td>'.
                           '<td><span class="LC_nobreak">&nbsp;'.                            '<td><span class="LC_nobreak">&nbsp;'.
Line 2697  sub legacy_scantronformat { Line 2434  sub legacy_scantronformat {
             &publishlogo($r,'copy',$legacyfile,$dom,$confname,'scantron',              &publishlogo($r,'copy',$legacyfile,$dom,$confname,'scantron',
                          '','',$newfile);                           '','',$newfile);
         if ($result ne 'ok') {          if ($result ne 'ok') {
             $error = &mt("An error occurred publishing the [_1] bubblesheet format file in RES space. Error was: [_2].",$newfile,$result);              $error = &mt("An error occurred publishing the [_1] scantron format file in RES space. Error was: [_2].",$newfile,$result);
         }          }
     }      }
     return ($url,$error);      return ($url,$error);
Line 2711  sub print_coursecategories { Line 2448  sub print_coursecategories {
         my $toggle_cats_dom = ' checked="checked" ';          my $toggle_cats_dom = ' checked="checked" ';
         my $can_cat_crs = ' ';          my $can_cat_crs = ' ';
         my $can_cat_dom = ' checked="checked" ';          my $can_cat_dom = ' checked="checked" ';
         my $toggle_catscomm_comm = ' ';  
         my $toggle_catscomm_dom = ' checked="checked" ';  
         my $can_catcomm_comm = ' ';  
         my $can_catcomm_dom = ' checked="checked" ';  
   
         if (ref($settings) eq 'HASH') {          if (ref($settings) eq 'HASH') {
             if ($settings->{'togglecats'} eq 'crs') {              if ($settings->{'togglecats'} eq 'crs') {
                 $toggle_cats_crs = $toggle_cats_dom;                  $toggle_cats_crs = $toggle_cats_dom;
Line 2725  sub print_coursecategories { Line 2457  sub print_coursecategories {
                 $can_cat_crs = $can_cat_dom;                  $can_cat_crs = $can_cat_dom;
                 $can_cat_dom = ' ';                  $can_cat_dom = ' ';
             }              }
             if ($settings->{'togglecatscomm'} eq 'comm') {  
                 $toggle_catscomm_comm = $toggle_catscomm_dom;  
                 $toggle_catscomm_dom = ' ';  
             }  
             if ($settings->{'categorizecomm'} eq 'comm') {  
                 $can_catcomm_comm = $can_catcomm_dom;  
                 $can_catcomm_dom = ' ';  
             }  
         }          }
         my %title = &Apache::lonlocal::texthash (          my %title = &Apache::lonlocal::texthash (
                      togglecats     => 'Show/Hide a course in catalog',                       togglecats => 'Show/Hide a course in the catalog',
                      togglecatscomm => 'Show/Hide a community in catalog',                       categorize    => 'Assign a category to a course',
                      categorize     => 'Assign a category to a course',  
                      categorizecomm => 'Assign a category to a community',  
                     );                      );
         my %level = &Apache::lonlocal::texthash (          my %level = &Apache::lonlocal::texthash (
                      dom => 'Set in Domain',                       dom => 'Set in "Modify Course" (Domain)',
                      crs => 'Set in Course',                          crs => 'Set in "Modify Parameters" (Course)',   
                      comm => 'Set in Community',  
                     );                      );
         $datatable = '<tr class="LC_odd_row">'.          $datatable = '<tr class="LC_odd_row">'.
                   '<td>'.$title{'togglecats'}.'</td>'.                    '<td>'.$title{'togglecats'}.'</td>'.
Line 2759  sub print_coursecategories { Line 2480  sub print_coursecategories {
                   $can_cat_dom.' value="dom" />'.$level{'dom'}.'</label>&nbsp;'.                    $can_cat_dom.' value="dom" />'.$level{'dom'}.'</label>&nbsp;'.
                   '<label><input type="radio" name="categorize"'.                    '<label><input type="radio" name="categorize"'.
                   $can_cat_crs.'value="crs" />'.$level{'crs'}.'</label></span></td>'.                    $can_cat_crs.'value="crs" />'.$level{'crs'}.'</label></span></td>'.
                   '</tr><tr class="LC_odd_row">'.  
                   '<td>'.$title{'togglecatscomm'}.'</td>'.  
                   '<td class="LC_right_item"><span class="LC_nobreak"><label>'.  
                   '<input type="radio" name="togglecatscomm"'.  
                   $toggle_catscomm_dom.' value="dom" />'.$level{'dom'}.'</label>&nbsp;'.  
                   '<label><input type="radio" name="togglecatscomm"'.  
                   $toggle_catscomm_comm.' value="comm" />'.$level{'comm'}.'</label></span></td>'.  
                   '</tr><tr>'.  
                   '<td>'.$title{'categorizecomm'}.'</td>'.  
                   '<td class="LC_right_item"><span class="LC_nobreak">'.  
                   '<label><input type="radio" name="categorizecomm"'.  
                   $can_catcomm_dom.' value="dom" />'.$level{'dom'}.'</label>&nbsp;'.  
                   '<label><input type="radio" name="categorizecomm"'.  
                   $can_catcomm_comm.'value="comm" />'.$level{'comm'}.'</label></span></td>'.  
                   '</tr>';                    '</tr>';
         $$rowtotal += 4;          $$rowtotal += 2;
     } else {      } else {
         my $css_class;          my $css_class;
         my $itemcount = 1;          my $itemcount = 1;
Line 2796  sub print_coursecategories { Line 2503  sub print_coursecategories {
                 if (ref($cats[0]) eq 'ARRAY') {                  if (ref($cats[0]) eq 'ARRAY') {
                     my $numtop = @{$cats[0]};                      my $numtop = @{$cats[0]};
                     my $maxnum = $numtop;                      my $maxnum = $numtop;
                     my %default_names = (                      if ((!grep(/^instcode$/,@{$cats[0]})) || ($cathash->{'instcode::0'} eq '')) {
                           instcode    => &mt('Official courses'),  
                           communities => &mt('Communities'),  
                     );  
   
                     if ((!grep(/^instcode$/,@{$cats[0]})) ||  
                         ($cathash->{'instcode::0'} eq '') ||  
                         (!grep(/^communities$/,@{$cats[0]})) ||  
                         ($cathash->{'communities::0'} eq '')) {  
                         $maxnum ++;                          $maxnum ++;
                     }                      }
                     my $lastidx;                      my $lastidx;
Line 2825  sub print_coursecategories { Line 2524  sub print_coursecategories {
                             $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';                              $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
                         }                          }
                         $datatable .= '</select></td><td>';                          $datatable .= '</select></td><td>';
                         if ($parent eq 'instcode' || $parent eq 'communities') {                          if ($parent eq 'instcode') {
                             $datatable .=  '<span class="LC_nobreak">'                              $datatable .=  '<span class="LC_nobreak">'.&mt('Official courses')
                                            .$default_names{$parent}.'</span>';                                             .'</span><br /><span class="LC_nobreak">('
                             if ($parent eq 'instcode') {                                             .&mt('with institutional codes').')</span></td>'
                                 $datatable .= '<br /><span class="LC_nobreak">('                                             .'<td'.$colattrib.'><span class="LC_nobreak"><label><input type="radio" name="instcode" value="1" checked="checked" />'
                                               .&mt('with institutional codes')                                              .&mt('Display').'</label>&nbsp;'
                                               .')</span></td><td'.$colattrib.'>';                                              .'<label><input type="radio" name="instcode" value="0" />'
                             } else {                                              .&mt('Do not display').'</label></span></td>';
                                 $datatable .= '<table><tr><td>';  
                             }  
                             $datatable .= '<span class="LC_nobreak">'  
                                           .'<label><input type="radio" name="'  
                                           .$parent.'" value="1" checked="checked" />'  
                                           .&mt('Display').'</label>';  
                             if ($parent eq 'instcode') {  
                                 $datatable .= '&nbsp;';  
                             } else {  
                                 $datatable .= '</span></td></tr><tr><td>'  
                                               .'<span class="LC_nobreak">';  
                             }  
                             $datatable .= '<label><input type="radio" name="'  
                                           .$parent.'" value="0" />'  
                                           .&mt('Do not display').'</label></span>';  
                             if ($parent eq 'communities') {  
                                 $datatable .= '</td></tr></table>';  
                             }  
                             $datatable .= '</td>';  
                         } else {                          } else {
                             $datatable .= $parent                              $datatable .= $parent
                                           .'&nbsp;<label><input type="checkbox" name="deletecategory" '                                            .'&nbsp;<label><input type="checkbox" name="deletecategory" '
Line 2879  sub print_coursecategories { Line 2559  sub print_coursecategories {
                                   .'<input type="text" size="20" name="addcategory_name" value="" /></td>'                                    .'<input type="text" size="20" name="addcategory_name" value="" /></td>'
                                   .'</tr>'."\n";                                    .'</tr>'."\n";
                     $itemcount ++;                      $itemcount ++;
                     foreach my $default ('instcode','communities') {                      if ((!grep(/^instcode$/,@{$cats[0]})) || ($cathash->{'instcode::0'} eq '')) {
                         if ((!grep(/^\Q$default\E$/,@{$cats[0]})) || ($cathash->{$default.'::0'} eq '')) {                          $css_class = $itemcount%2?' class="LC_odd_row"':'';
                             $css_class = $itemcount%2?' class="LC_odd_row"':'';                          my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','instcode_pos','$lastidx'".');"';
                             my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','$default"."_pos','$lastidx'".');"';                          $datatable .= '<tr><td colspan="'.$maxdepth.'" class="LC_row_separator"></td></tr><tr '.$css_class.'><td>'.
                             $datatable .= '<tr><td colspan="'.$maxdepth.'" class="LC_row_separator"></td></tr><tr '.$css_class.'><td>'.                                        '<span class="LC_nobreak"><select name="instcode_pos"'.$chgstr.'>';
                                           '<span class="LC_nobreak"><select name="'.$default.'_pos"'.$chgstr.'>';                          for (my $k=0; $k<=$maxnum; $k++) {
                             for (my $k=0; $k<=$maxnum; $k++) {                              my $vpos = $k+1;
                                 my $vpos = $k+1;                              my $selstr;
                                 my $selstr;                              if ($k == $maxnum) {
                                 if ($k == $maxnum) {                                  $selstr = ' selected="selected" ';
                                     $selstr = ' selected="selected" ';  
                                 }  
                                 $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';  
                             }                              }
                             $datatable .= '</select></span></td>'.                              $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
                                           '<td><span class="LC_nobreak">'.  
                                           $default_names{$default}.'</span>';  
                             if ($default eq 'instcode') {  
                                 $datatable .= '<br /><span class="LC_nobreak">('  
                                               .&mt('with institutional codes').')</span>';  
                             }  
                             $datatable .= '</td>'  
                                           .'<td><span class="LC_nobreak"><label><input type="radio" name="'.$default.'" value="1" />'  
                                           .&mt('Display').'</label>&nbsp;'  
                                           .'<label><input type="radio" name="'.$default.'" value="0" checked="checked"/>'  
                                           .&mt('Do not display').'</label></span></td></tr>';  
                         }                          }
                           $datatable .= '</select></span></td><td><span class="LC_nobreak">'
                                         .&mt('Official courses').'</span>'.'<br /><span class="LC_nobreak">('
                                         .&mt('with institutional codes').')</span></td>'
                                         .'<td><span class="LC_nobreak"><label><input type="radio" name="instcode" value="1" />'
                                         .&mt('Display').'</label>&nbsp;'
                                         .'<label><input type="radio" name="instcode" value="0" checked="checked"/>'
                                         .&mt('Do not display').'</label></span></td></tr>';
                     }                      }
                 }                  }
             } else {              } else {
Line 2969  sub print_serverstatuses { Line 2642  sub print_serverstatuses {
 sub serverstatus_pages {  sub serverstatus_pages {
     return ('userstatus','lonstatus','loncron','server-status','codeversions',      return ('userstatus','lonstatus','loncron','server-status','codeversions',
             'clusterstatus','metadata_keywords','metadata_harvest',              'clusterstatus','metadata_keywords','metadata_harvest',
             'takeoffline','takeonline','showenv','toggledebug');              'takeoffline','takeonline','showenv');
 }  }
   
 sub coursecategories_javascript {  sub coursecategories_javascript {
Line 2994  sub coursecategories_javascript { Line 2667  sub coursecategories_javascript {
         $jstext  = '    var categories = Array(1);'."\n".          $jstext  = '    var categories = Array(1);'."\n".
                    '    categories[0] = Array("instcode_pos");'."\n";                      '    categories[0] = Array("instcode_pos");'."\n"; 
     }      }
     my $instcode_reserved = &mt('The name: "instcode" is a reserved category');  
     my $communities_reserved = &mt('The name: "communities" is a reserved category');  
     my $choose_again = '\\n'.&mt('Please use a different name for the new top level category');  
     $output = <<"ENDSCRIPT";      $output = <<"ENDSCRIPT";
 <script type="text/javascript">  <script type="text/javascript">
 // <![CDATA[  
 function reorderCats(form,parent,item,idx) {  function reorderCats(form,parent,item,idx) {
     var changedVal;      var changedVal;
 $jstext  $jstext
Line 3056  $jstext Line 2725  $jstext
     }      }
     return;      return;
 }  }
   
 function categoryCheck(form) {  
     if (form.elements['addcategory_name'].value == 'instcode') {  
         alert('$instcode_reserved\\n$choose_again');  
         return false;  
     }  
     if (form.elements['addcategory_name'].value == 'communities') {  
         alert('$communities_reserved\\n$choose_again');  
         return false;  
     }  
     return true;  
 }  
   
 // ]]>  
 </script>  </script>
   
 ENDSCRIPT  ENDSCRIPT
Line 3078  ENDSCRIPT Line 2733  ENDSCRIPT
   
 sub initialize_categories {  sub initialize_categories {
     my ($itemcount) = @_;      my ($itemcount) = @_;
     my ($datatable,$css_class,$chgstr);      my $datatable;
     my %default_names = (      my $css_class = $itemcount%2?' class="LC_odd_row"':'';
                       instcode    => 'Official courses (with institutional codes)',      my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','instcode_pos','0'".');"';
                       communities => 'Communities',  
                         );      $datatable = '<tr '.$css_class.'><td><span class="LC_nobreak">'
     my $select0 = ' selected="selected"';                   .'<select name="instcode_pos"><option value="0" selected="selected">1</option>'
     my $select1 = '';                   .'<option value="1">2</option></select>&nbsp;'
     foreach my $default ('instcode','communities') {                   .&mt('Official courses (with institutional codes)')
         $css_class = $itemcount%2?' class="LC_odd_row"':'';                   .'</span></td><td><span class="LC_nobreak">'
         $chgstr = ' onchange="javascript:reorderCats(this.form,'."'',$default"."_pos','0'".');"';                   .'<label><input type="radio" name="instcode" value="1" checked="checked" />'
         if ($default eq 'communities') {                   .&mt('Display').'</label>&nbsp;<label>'
             $select1 = $select0;                   .'<input type="radio" name="instcode" value="0" />'.&mt('Do not display')
             $select0 = '';  
         }  
         $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'  
                      .'<select name="'.$default.'_pos">'  
                      .'<option value="0"'.$select0.'>1</option>'  
                      .'<option value="1"'.$select1.'>2</option>'  
                      .'<option value="2">3</option></select>&nbsp;'  
                      .$default_names{$default}  
                      .'</span></td><td><span class="LC_nobreak">'  
                      .'<label><input type="radio" name="'.$default.'" value="1" checked="checked" />'  
                      .&mt('Display').'</label>&nbsp;<label>'  
                      .'<input type="radio" name="'.$default.'" value="0" />'.&mt('Do not display')  
                  .'</label></span></td></tr>';                   .'</label></span></td></tr>';
         $itemcount ++;      $itemcount ++;
     }  
     $css_class = $itemcount%2?' class="LC_odd_row"':'';      $css_class = $itemcount%2?' class="LC_odd_row"':'';
     $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','addcategory_pos','0'".');"';      $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','addcategory_pos','0'".');"';
     $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'      $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'
                   .'<select name="addcategory_pos"'.$chgstr.'>'                    .'<select name="addcategory_pos"'.$chgstr.'><option value="0">1</option>'
                   .'<option value="0">1</option>'                    .'<option value="1" selected="selected">2</option></select>&nbsp;'
                   .'<option value="1">2</option>'  
                   .'<option value="2" selected="selected">3</option></select>&nbsp;'  
                   .&mt('Add category').'</td><td>'.&mt('Name:')                    .&mt('Add category').'</td><td>'.&mt('Name:')
                   .'&nbsp;<input type="text" size="20" name="addcategory_name" value="" /></td></tr>';                    .'&nbsp;<input type="text" size="20" name="addcategory_name" value="" /></td></tr>';
     return $datatable;      return $datatable;
Line 3277  sub insttypes_row { Line 2917  sub insttypes_row {
     my %lt = &Apache::lonlocal::texthash (      my %lt = &Apache::lonlocal::texthash (
                       cansearch => 'Users allowed to search',                        cansearch => 'Users allowed to search',
                       statustocreate => 'Institutional affiliation(s) able to create own account (login/SSO)',                        statustocreate => 'Institutional affiliation(s) able to create own account (login/SSO)',
                       lockablenames => 'User preference to lock name',  
              );               );
     my $showdom;      my $showdom;
     if ($context eq 'cansearch') {      if ($context eq 'cansearch') {
Line 3314  sub insttypes_row { Line 2953  sub insttypes_row {
                            $usertypes->{$types->[$i]}.'</label></span></td>';                             $usertypes->{$types->[$i]}.'</label></span></td>';
             }              }
         }          }
          
         $rem = @{$types}%($numinrow);          $rem = @{$types}%($numinrow);
     }      }
     my $colsleft = $numinrow - $rem;      my $colsleft = $numinrow - $rem;
     if (($rem == 0) && (@{$types} > 0)) {  
         $output .= '<tr>';  
     }  
     if ($colsleft > 1) {      if ($colsleft > 1) {
         $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">';          $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">';
     } else {      } else {
Line 3421  sub modify_login { Line 3058  sub modify_login {
                   newuser => 'Link for visitors to create a user account',                    newuser => 'Link for visitors to create a user account',
                   loginheader => 'Log-in box header');                    loginheader => 'Log-in box header');
     my @offon = ('off','on');      my @offon = ('off','on');
     my %curr_loginvia;  
     if (ref($domconfig{login}) eq 'HASH') {  
         if (ref($domconfig{login}{loginvia}) eq 'HASH') {  
             foreach my $lonhost (keys(%{$domconfig{login}{loginvia}})) {  
                 $curr_loginvia{$lonhost} = $domconfig{login}{loginvia}{$lonhost};  
             }  
         }  
     }  
     my %loginhash;      my %loginhash;
     ($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],      ($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
                                            \%domconfig,\%loginhash);                                             \%domconfig,\%loginhash);
Line 3441  sub modify_login { Line 3070  sub modify_login {
         $colchgtext = &display_colorchgs($dom,\%colchanges,['login'],          $colchgtext = &display_colorchgs($dom,\%colchanges,['login'],
                                          \%loginhash);                                           \%loginhash);
     }      }
   
     my %servers = &dom_servers($dom);  
     my @loginvia_attribs = ('serverpath','custompath','exempt');  
     if (keys(%servers) > 1) {  
         foreach my $lonhost (keys(%servers)) {  
             next if ($env{'form.'.$lonhost.'_server'} eq $lonhost);  
             if (ref($curr_loginvia{$lonhost}) eq 'HASH') {  
                 if ($env{'form.'.$lonhost.'_server'} eq $curr_loginvia{$lonhost}{'server'}) {  
                     $loginhash{login}{loginvia}{$lonhost}{'server'} = $curr_loginvia{$lonhost}{'server'};  
                 } elsif ($curr_loginvia{$lonhost}{'server'} ne '') {  
                     if (defined($servers{$env{'form.'.$lonhost.'_server'}})) {  
                         $loginhash{login}{loginvia}{$lonhost}{'server'} = $env{'form.'.$lonhost.'_server'};  
                         $changes{'loginvia'}{$lonhost} = 1;  
                     } else {  
                         $loginhash{login}{loginvia}{$lonhost}{'server'} = '';  
                         $changes{'loginvia'}{$lonhost} = 1;  
                     }  
                 } else {  
                     if (defined($servers{$env{'form.'.$lonhost.'_server'}})) {  
                         $loginhash{login}{loginvia}{$lonhost}{'server'} = $env{'form.'.$lonhost.'_server'};  
                         $changes{'loginvia'}{$lonhost} = 1;  
                     }  
                 }  
                 if ($loginhash{login}{loginvia}{$lonhost}{'server'} eq '') {  
                     foreach my $item (@loginvia_attribs) {  
                         $loginhash{login}{loginvia}{$lonhost}{$item} = '';  
                     }  
                 } else {  
                     foreach my $item (@loginvia_attribs) {  
                         my $new = $env{'form.'.$lonhost.'_'.$item};  
                         if (($item eq 'serverpath') && ($new eq 'custom')) {  
                             $env{'form.'.$lonhost.'_custompath'} =~ s/\s+//g;  
                             if ($env{'form.'.$lonhost.'_custompath'} eq '') {  
                                 $new = '/';  
                             }  
                         }  
                         if (($item eq 'custompath') &&  
                             ($env{'form.'.$lonhost.'_serverpath'} ne 'custom')) {  
                             $new = '';  
                         }  
                         if ($new ne $curr_loginvia{$lonhost}{$item}) {  
                             $changes{'loginvia'}{$lonhost} = 1;  
                         }  
                         if ($item eq 'exempt') {  
                             $new =~ s/^\s+//;  
                             $new =~ s/\s+$//;  
                             my @poss_ips = split(/\s*[,:]\s*/,$new);  
                             my @okips;  
                             foreach my $ip (@poss_ips) {  
                                 if ($ip =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) {  
                                     if (($1 <= 255) && ($2 <= 255) && ($3 <= 255) && ($4 <= 255)) {  
                                         push(@okips,$ip);  
                                     }  
                                 }  
                             }  
                             if (@okips > 0) {  
                                 $new = join(',',@okips);  
                             } else {  
                                 $new = '';  
                             }  
                         }  
   
                         $loginhash{login}{loginvia}{$lonhost}{$item} = $new;  
                     }  
                 }  
             } else {  
                 if (defined($servers{$env{'form.'.$lonhost.'_server'}})) {  
                     $loginhash{login}{loginvia}{$lonhost}{'server'} = $env{'form.'.$lonhost.'_server'};  
                     $changes{'loginvia'}{$lonhost} = 1;  
                     foreach my $item (@loginvia_attribs) {  
                         my $new = $env{'form.'.$lonhost.'_'.$item};  
                         if (($item eq 'serverpath') && ($new eq 'custom')) {  
                             if ($env{'form.'.$lonhost.'_custompath'} eq '') {  
                                 $new = '/';  
                             }  
                         }  
                         if (($item eq 'custompath') &&  
                             ($env{'form.'.$lonhost.'_serverpath'} ne 'custom')) {  
                             $new = '';  
                         }  
                         $loginhash{login}{loginvia}{$lonhost}{$item} = $new;  
                     }  
                 }  
             }  
         }  
     }  
   
     my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,      my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
                                              $dom);                                               $dom);
     if ($putresult eq 'ok') {      if ($putresult eq 'ok') {
Line 3574  sub modify_login { Line 3116  sub modify_login {
             foreach my $item (sort(keys(%changes))) {              foreach my $item (sort(keys(%changes))) {
                 if ($item eq 'loginheader') {                  if ($item eq 'loginheader') {
                     $resulttext .= '<li>'.&mt("$title{$item} set to $env{'form.loginheader'}").'</li>';                      $resulttext .= '<li>'.&mt("$title{$item} set to $env{'form.loginheader'}").'</li>';
                 } elsif ($item eq 'loginvia') {  
                     if (ref($changes{$item}) eq 'HASH') {  
                         $resulttext .= '<li>'.&mt('Log-in page availability:').'<ul>';  
                         foreach my $lonhost (sort(keys(%{$changes{$item}}))) {  
                             if (defined($servers{$loginhash{login}{loginvia}{$lonhost}{'server'}})) {  
                                 if (ref($loginhash{login}{loginvia}{$lonhost}) eq 'HASH') {  
                                     my $protocol = $Apache::lonnet::protocol{$env{'form.'.$lonhost.'_server'}};  
                                     $protocol = 'http' if ($protocol ne 'https');  
                                     my $target = $protocol.'://'.$servers{$env{'form.'.$lonhost.'_server'}};  
   
                                     if ($loginhash{login}{loginvia}{$lonhost}{'serverpath'} eq 'custom') {  
                                         $target .= $loginhash{login}{loginvia}{$lonhost}{'custompath'};  
                                     } else {  
                                         $target .= $loginhash{login}{loginvia}{$lonhost}{'serverpath'};  
                                     }  
                                     $resulttext .= '<li>'.&mt('Server: [_1] log-in page redirects to [_2].',$servers{$lonhost},'<a href="'.$target.'">'.$target.'</a>');  
                                     if ($loginhash{login}{loginvia}{$lonhost}{'exempt'} ne '') {  
                                         $resulttext .= '&nbsp;'.&mt('No redirection for clients from following IPs:').'&nbsp;'.$loginhash{login}{loginvia}{$lonhost}{'exempt'};  
                                     }  
                                     $resulttext .= '</li>';  
                                 } else {  
                                     $resulttext .= '<li>'.&mt('Server: [_1] has standard log-in page.',$lonhost).'</li>';  
                                 }  
                             } else {  
                                 $resulttext .= '<li>'.&mt('Server: [_1] has standard log-in page.',$servers{$lonhost}).'</li>';  
                             }  
                         }  
                         $resulttext .= '</ul></li>';  
                     }  
                 } else {                  } else {
                     $resulttext .= '<li>'.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'</li>';                      $resulttext .= '<li>'.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'</li>';
                 }                  }
Line 3630  sub color_font_choices { Line 3143  sub color_font_choices {
             links => "Link colors",              links => "Link colors",
             images => "Images",              images => "Images",
             font => "Font color",              font => "Font color",
               fontmenu => "Font Menu",
             pgbg => "Page",              pgbg => "Page",
             tabbg => "Header",              tabbg => "Header",
             sidebg => "Border",              sidebg => "Border",
Line 3696  sub modify_colors { Line 3210  sub modify_colors {
             @bgs = ('pgbg','tabbg','sidebg');               @bgs = ('pgbg','tabbg','sidebg'); 
         }          }
         $confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};          $confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
    $confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'};
         foreach my $item (@bgs,@links,@logintext) {          foreach my $item (@bgs,@links,@logintext) {
             $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};              $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
         }          }
Line 3809  sub modify_colors { Line 3324  sub modify_colors {
                         $changes{$role}{'font'} = 1;                          $changes{$role}{'font'} = 1;
                     }                      }
                 }                  }
                   if ($domconfig->{$role}{'fontmenu'} ne '') {
                       if ($confhash->{$role}{'fontmenu'} ne $domconfig->{$role}{'fontmenu'}) {
                           $changes{$role}{'fontmenu'} = 1;
                       }
                   } else {
                       if ($confhash->{$role}{'fontmenu'}) {
                           $changes{$role}{'fontmenu'} = 1;
                       }
                   }
                 foreach my $item (@bgs) {                  foreach my $item (@bgs) {
                     if ($domconfig->{$role}{$item} ne '') {                      if ($domconfig->{$role}{$item} ne '') {
                         if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {                          if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
Line 4249  sub modify_quotas { Line 3773  sub modify_quotas {
     }      }
     if ($context eq 'requestcourses') {      if ($context eq 'requestcourses') {
         @usertools = ('official','unofficial','community');          @usertools = ('official','unofficial','community');
         @options =('norequest','approval','validate','autolimit');          @options =('norequest','approve','autolimit','validate');
         %validations = &Apache::lonnet::auto_courserequest_checks($dom);          %validations = &Apache::lonnet::auto_courserequest_checks($dom);
         %titles = &courserequest_titles();          %titles = &courserequest_titles();
         $toolregexp = join('|',@usertools);          $toolregexp = join('|',@usertools);
Line 4304  sub modify_quotas { Line 3828  sub modify_quotas {
     }      }
     foreach my $item (@usertools) {      foreach my $item (@usertools) {
         foreach my $type (@{$types},'default','_LC_adv') {          foreach my $type (@{$types},'default','_LC_adv') {
             my $unset;  
             if ($context eq 'requestcourses') {              if ($context eq 'requestcourses') {
                 $unset = '0';  
                 if ($type eq '_LC_adv') {  
                     $unset = '';  
                 }  
                 if ($confhash{$item}{$type} eq 'autolimit') {                  if ($confhash{$item}{$type} eq 'autolimit') {
                     $confhash{$item}{$type} .= '=';                      $confhash{$item}{$type} .= '=';
                     unless ($limithash{$item}{$type} =~ /\D/) {                      unless ($limithash{$item}{$type} =~ /\D/) {
Line 4330  sub modify_quotas { Line 3849  sub modify_quotas {
                     }                      }
                 } else {                  } else {
                     if ($context eq 'requestcourses') {                      if ($context eq 'requestcourses') {
                         if ($confhash{$item}{$type} ne $unset) {                          if ($confhash{$item}{$type} ne 'norequest') {
                             $changes{$item}{$type} = 1;                              $changes{$item}{$type} = 1;
                         }                          }
                     } else {                      } else {
Line 4341  sub modify_quotas { Line 3860  sub modify_quotas {
                 }                  }
             } else {              } else {
                 if ($context eq 'requestcourses') {                  if ($context eq 'requestcourses') {
                     if ($confhash{$item}{$type} ne $unset) {                      if ($confhash{$item}{$type} eq 'norequest') {
                         $changes{$item}{$type} = 1;                          $changes{$item}{$type} = 1;
                     }                      }
                 } else {                  } else {
Line 4433  sub modify_quotas { Line 3952  sub modify_quotas {
                                                           $env{'user.domain'},                                                            $env{'user.domain'},
                                                           $item,'reload',$context);                                                            $item,'reload',$context);
                     if ($context eq 'requestcourses') {                      if ($context eq 'requestcourses') {
                         if ($env{'environment.canrequest.'.$item} ne $newacc) {                          if ($env{'environment.crsrequest.'.$item} ne $newacc) {
                             $newenv{'environment.canrequest.'.$item} = $newacc;                              $newenv{'environment.crsrequest.'.$item} = $newacc;
                         }                          }
                     } else {                      } else {
                         if ($env{'environment.availabletools.'.$item} ne $newacc) {                           if ($env{'environment.availabletools.'.$item} ne $newacc) { 
Line 4467  sub modify_quotas { Line 3986  sub modify_quotas {
                                     $resulttext .= '<li>'.&mt('Set to be available to [_1]',$typetitle).'</li>';                                      $resulttext .= '<li>'.&mt('Set to be available to [_1]',$typetitle).'</li>';
                                 }                                  }
                             } else {                              } else {
                                 if ($type eq '_LC_adv') {                                  $resulttext .= '<li>'.&mt('Set to be unavailable to [_1]',$typetitle).'</li>';
                                     if ($confhash{$item}{$type} eq '0') {  
                                         $resulttext .= '<li>'.&mt('Set to be unavailable to [_1]',$typetitle).'</li>';  
                                     } else {   
                                         $resulttext .= '<li>'.&mt('No override set for [_1]',$typetitle).'</li>';  
                                     }  
                                 } else {  
                                     $resulttext .= '<li>'.&mt('Set to be unavailable to [_1]',$typetitle).'</li>';  
                                 }  
                             }                              }
                         }                          }
                     }                      }
Line 4524  sub modify_autoenroll { Line 4035  sub modify_autoenroll {
     }      }
     my $autorun = &Apache::lonnet::auto_run(undef,$dom),      my $autorun = &Apache::lonnet::auto_run(undef,$dom),
     my %title = ( run => 'Auto-enrollment active',      my %title = ( run => 'Auto-enrollment active',
                   sender => 'Sender for notification messages',                    sender => 'Sender for notification messages');
                   coowners => 'Automatic assignment of co-ownership to instructors of record (institutional data)');  
     my @offon = ('off','on');      my @offon = ('off','on');
     my $sender_uname = $env{'form.sender_uname'};      my $sender_uname = $env{'form.sender_uname'};
     my $sender_domain = $env{'form.sender_domain'};      my $sender_domain = $env{'form.sender_domain'};
Line 4534  sub modify_autoenroll { Line 4044  sub modify_autoenroll {
     } elsif ($sender_uname eq '') {      } elsif ($sender_uname eq '') {
         $sender_domain = '';          $sender_domain = '';
     }      }
     my $coowners = $env{'form.autoassign_coowners'};  
     my %autoenrollhash =  (      my %autoenrollhash =  (
                        autoenroll => { run => $env{'form.autoenroll_run'},                         autoenroll => { run => $env{'form.autoenroll_run'},
                                        sender_uname => $sender_uname,                                         sender_uname => $sender_uname,
                                        sender_domain => $sender_domain,                                         sender_domain => $sender_domain,
                                        'co-owners' => $coowners,  
                                 }                                  }
                      );                       );
     my $putresult = &Apache::lonnet::put_dom('configuration',\%autoenrollhash,      my $putresult = &Apache::lonnet::put_dom('configuration',\%autoenrollhash,
Line 4560  sub modify_autoenroll { Line 4069  sub modify_autoenroll {
         if ($currautoenroll{'sender_domain'} ne $sender_domain) {          if ($currautoenroll{'sender_domain'} ne $sender_domain) {
             $changes{'sender'} = 1;              $changes{'sender'} = 1;
         }          }
         if ($currautoenroll{'co-owners'} ne '') {  
             if ($currautoenroll{'co-owners'} ne $coowners) {  
                 $changes{'coowners'} = 1;  
             }  
         } elsif ($coowners) {  
             $changes{'coowners'} = 1;  
         }  
         if (keys(%changes) > 0) {          if (keys(%changes) > 0) {
             $resulttext = &mt('Changes made:').'<ul>';              $resulttext = &mt('Changes made:').'<ul>';
             if ($changes{'run'}) {              if ($changes{'run'}) {
Line 4579  sub modify_autoenroll { Line 4081  sub modify_autoenroll {
                     $resulttext .= '<li>'.&mt("$title{'sender'} set to [_1]",$sender_uname.':'.$sender_domain).'</li>';                      $resulttext .= '<li>'.&mt("$title{'sender'} set to [_1]",$sender_uname.':'.$sender_domain).'</li>';
                 }                  }
             }              }
             if ($changes{'coowners'}) {  
                 $resulttext .= '<li>'.&mt("$title{'coowners'} set to $offon[$env{'form.autoassign_coowners'}]").'</li>';  
                 &Apache::loncommon::devalidate_domconfig_cache($dom);  
             }  
             $resulttext .= '</ul>';              $resulttext .= '</ul>';
         } else {          } else {
             $resulttext = &mt('No changes made to auto-enrollment settings');              $resulttext = &mt('No changes made to auto-enrollment settings');
Line 4614  sub modify_autoupdate { Line 4112  sub modify_autoupdate {
                         lastname => 'Last Name',                          lastname => 'Last Name',
                         firstname => 'First Name',                          firstname => 'First Name',
                         middlename => 'Middle Name',                          middlename => 'Middle Name',
                         generation => 'Generation',                          gen => 'Generation',
                       );                        );
     $othertitle = &mt('All users');      my $othertitle = &mt('All users');
     if (keys(%{$usertypes}) >  0) {      if (keys(%{$usertypes}) >  0) {
         $othertitle = &mt('Other users');          $othertitle = &mt('Other users');
     }      }
     foreach my $key (keys(%env)) {      foreach my $key (keys(%env)) {
         if ($key =~ /^form\.updateable_(.+)_([^_]+)$/) {          if ($key =~ /^form\.updateable_(.+)_([^_]+)$/) {
             my ($usertype,$item) = ($1,$2);              push(@{$fields{$1}},$2);
             if (grep(/^\Q$item\E$/,keys(%fieldtitles))) {  
                 if ($usertype eq 'default') {  
                     push(@{$fields{$1}},$2);  
                 } elsif (ref($types) eq 'ARRAY') {  
                     if (grep(/^\Q$usertype\E$/,@{$types})) {  
                         push(@{$fields{$1}},$2);  
                     }  
                 }  
             }  
         }  
     }  
     my @lockablenames = &Apache::loncommon::get_env_multiple('form.lockablenames');  
     @lockablenames = sort(@lockablenames);  
     if (ref($currautoupdate{'lockablenames'}) eq 'ARRAY') {  
         my @changed = &Apache::loncommon::compare_arrays($currautoupdate{'lockablenames'},\@lockablenames);  
         if (@changed) {  
             $changes{'lockablenames'} = 1;  
         }  
     } else {  
         if (@lockablenames) {  
             $changes{'lockablenames'} = 1;  
         }          }
     }      }
     my %updatehash = (      my %updatehash = (
                       autoupdate => { run => $env{'form.autoupdate_run'},                        autoupdate => { run => $env{'form.autoupdate_run'},
                                       classlists => $env{'form.classlists'},                                        classlists => $env{'form.classlists'},
                                       fields => {%fields},                                        fields => {%fields},
                                       lockablenames => \@lockablenames,  
                                     }                                      }
                      );                       );
     foreach my $key (keys(%currautoupdate)) {      foreach my $key (keys(%currautoupdate)) {
Line 4668  sub modify_autoupdate { Line 4144  sub modify_autoupdate {
                         foreach my $type (@{$currautoupdate{$key}{$item}}) {                          foreach my $type (@{$currautoupdate{$key}{$item}}) {
                             if (!exists($fields{$item})) {                              if (!exists($fields{$item})) {
                                 $change = 1;                                  $change = 1;
                                 last;  
                             } elsif (ref($fields{$item}) eq 'ARRAY') {                              } elsif (ref($fields{$item}) eq 'ARRAY') {
                                 if (!grep(/^\Q$type\E$/,@{$fields{$item}})) {                                  if (!grep(/^\Q$type\E$/,@{$fields{$item}})) {
                                     $change = 1;                                      $change = 1;
                                     last;  
                                 }                                  }
                             }                              }
                         }                          }
Line 4682  sub modify_autoupdate { Line 4156  sub modify_autoupdate {
                     }                       } 
                 }                  }
             }              }
         } elsif ($key eq 'lockablenames') {  
             if (ref($currautoupdate{$key}) eq 'ARRAY') {  
                 my @changed = &Apache::loncommon::compare_arrays($currautoupdate{'lockablenames'},\@lockablenames);  
                 if (@changed) {  
                     $changes{'lockablenames'} = 1;  
                 }  
             } else {  
                 if (@lockablenames) {  
                     $changes{'lockablenames'} = 1;  
                 }  
             }  
         }  
     }  
     unless (grep(/^\Qlockablenames\E$/,keys(%currautoupdate))) {  
         if (@lockablenames) {  
             $changes{'lockablenames'} = 1;  
         }          }
     }      }
     foreach my $item (@{$types},'default') {      foreach my $item (@{$types},'default') {
         if (defined($fields{$item})) {          if (defined($fields{$item})) {
             if (ref($currautoupdate{'fields'}) eq 'HASH') {              if (ref($currautoupdate{'fields'}) eq 'HASH') {
                 if (ref($currautoupdate{'fields'}{$item}) eq 'ARRAY') {                  if (!exists($currautoupdate{'fields'}{$item})) {
                     my $change = 0;  
                     if (ref($fields{$item}) eq 'ARRAY') {  
                         foreach my $type (@{$fields{$item}}) {  
                             if (!grep(/^\Q$type\E$/,@{$currautoupdate{'fields'}{$item}})) {  
                                 $change = 1;  
                                 last;  
                             }  
                         }  
                     }  
                     if ($change) {  
                         push(@{$changes{'fields'}},$item);  
                     }  
                 } else {  
                     push(@{$changes{'fields'}},$item);                      push(@{$changes{'fields'}},$item);
                 }                  }
             } else {              } else {
Line 4730  sub modify_autoupdate { Line 4175  sub modify_autoupdate {
         if (keys(%changes) > 0) {          if (keys(%changes) > 0) {
             $resulttext = &mt('Changes made:').'<ul>';              $resulttext = &mt('Changes made:').'<ul>';
             foreach my $key (sort(keys(%changes))) {              foreach my $key (sort(keys(%changes))) {
                 if ($key eq 'lockablenames') {                  if (ref($changes{$key}) eq 'ARRAY') {
                     $resulttext .= '<li>';  
                     if (@lockablenames) {  
                         $usertypes->{'default'} = $othertitle;  
                         $resulttext .= &mt("User preference to disable replacement of user's name with institutional data (by auto-update), available for the following affiliations:").' '.  
                                    join(', ', map { $usertypes->{$_}; } @lockablenames).'</li>';  
                     } else {  
                         $resulttext .= &mt("User preference to disable replacement of user's name with institutional data (by auto-update) is unavailable.");  
                     }  
                     $resulttext .= '</li>';  
                 } elsif (ref($changes{$key}) eq 'ARRAY') {  
                     foreach my $item (@{$changes{$key}}) {                      foreach my $item (@{$changes{$key}}) {
                         my @newvalues;                          my @newvalues;
                         foreach my $type (@{$fields{$item}}) {                          foreach my $type (@{$fields{$item}}) {
Line 4779  sub modify_autoupdate { Line 4214  sub modify_autoupdate {
     return $resulttext;      return $resulttext;
 }  }
   
 sub modify_autocreate {  
     my ($dom,%domconfig) = @_;  
     my ($resulttext,%changes,%currautocreate,%newvals,%autocreatehash);  
     if (ref($domconfig{'autocreate'}) eq 'HASH') {  
         foreach my $key (keys(%{$domconfig{'autocreate'}})) {  
             $currautocreate{$key} = $domconfig{'autocreate'}{$key};  
         }  
     }  
     my %title= ( xml => 'Auto-creation of courses in XML course description files',  
                  req => 'Auto-creation of validated requests for official courses',  
                  xmldc => 'Identity of course creator of courses from XML files',  
                );  
     my @types = ('xml','req');  
     foreach my $item (@types) {  
         $newvals{$item} = $env{'form.autocreate_'.$item};  
         $newvals{$item} =~ s/\D//g;  
         $newvals{$item} = 0 if ($newvals{$item} eq '');  
     }  
     $newvals{'xmldc'} = $env{'form.autocreate_xmldc'};  
     my %domcoords = &get_active_dcs($dom);  
     unless (exists($domcoords{$newvals{'xmldc'}})) {  
         $newvals{'xmldc'} = '';  
     }  
     %autocreatehash =  (  
                         autocreate => { xml => $newvals{'xml'},  
                                         req => $newvals{'req'},  
                                       }  
                        );  
     if ($newvals{'xmldc'} ne '') {  
         $autocreatehash{'autocreate'}{'xmldc'} = $newvals{'xmldc'};  
     }  
     my $putresult = &Apache::lonnet::put_dom('configuration',\%autocreatehash,  
                                              $dom);  
     if ($putresult eq 'ok') {  
         my @items = @types;  
         if ($newvals{'xml'}) {  
             push(@items,'xmldc');  
         }  
         foreach my $item (@items) {  
             if (exists($currautocreate{$item})) {  
                 if ($currautocreate{$item} ne $newvals{$item}) {  
                     $changes{$item} = 1;  
                 }  
             } elsif ($newvals{$item}) {  
                 $changes{$item} = 1;  
             }  
         }  
         if (keys(%changes) > 0) {  
             my @offon = ('off','on');  
             $resulttext = &mt('Changes made:').'<ul>';  
             foreach my $item (@types) {  
                 if ($changes{$item}) {  
                     my $newtxt = $offon[$newvals{$item}];  
                     $resulttext .= '<li>'.&mt("$title{$item} set to [_1]$newtxt [_2]",'<b>','</b>').'</li>';  
                 }  
             }  
             if ($changes{'xmldc'}) {  
                 my ($dcname,$dcdom) = split(':',$newvals{'xmldc'});  
                 my $newtxt = &Apache::loncommon::plainname($dcname,$dcdom);  
                 $resulttext .= '<li>'.&mt("$title{'xmldc'} set to [_1]$newtxt [_2]",'<b>','</b>').'</li>';  
             }  
             $resulttext .= '</ul>';  
         } else {  
             $resulttext = &mt('No changes made to auto-creation settings');  
         }  
     } else {  
         $resulttext = '<span class="LC_error">'.  
             &mt('An error occurred: [_1]',$putresult).'</span>';  
     }  
     return $resulttext;  
 }  
   
 sub modify_directorysrch {  sub modify_directorysrch {
     my ($dom,%domconfig) = @_;      my ($dom,%domconfig) = @_;
     my ($resulttext,%changes);      my ($resulttext,%changes);
Line 5033  sub modify_contacts { Line 4396  sub modify_contacts {
             $currsetting{$key} = $domconfig{'contacts'}{$key};              $currsetting{$key} = $domconfig{'contacts'}{$key};
         }          }
     }      }
     my (%others,%to,%bcc);      my (%others,%to);
     my @contacts = ('supportemail','adminemail');      my @contacts = ('supportemail','adminemail');
     my @mailings = ('errormail','packagesmail','helpdeskmail','lonstatusmail',      my @mailings = ('errormail','packagesmail','helpdeskmail','lonstatusmail',
                     'requestsmail');                      'requestsmail');
Line 5049  sub modify_contacts { Line 4412  sub modify_contacts {
         }            }  
         $others{$type} = $env{'form.'.$type.'_others'};          $others{$type} = $env{'form.'.$type.'_others'};
         $contacts_hash{contacts}{$type}{'others'} = $others{$type};          $contacts_hash{contacts}{$type}{'others'} = $others{$type};
         if ($type eq 'helpdeskmail') {  
             $bcc{$type} = $env{'form.'.$type.'_bcc'};  
             $contacts_hash{contacts}{$type}{'bcc'} = $bcc{$type};  
         }  
     }      }
     foreach my $item (@contacts) {      foreach my $item (@contacts) {
         $to{$item} = $env{'form.'.$item};          $to{$item} = $env{'form.'.$item};
Line 5077  sub modify_contacts { Line 4436  sub modify_contacts {
             if ($others{$type} ne $currsetting{$type}{'others'}) {              if ($others{$type} ne $currsetting{$type}{'others'}) {
                 push(@{$changes{$type}},'others');                  push(@{$changes{$type}},'others');
             }              }
             if ($type eq 'helpdeskmail') {  
                 if ($bcc{$type} ne $currsetting{$type}{'bcc'}) {  
                     push(@{$changes{$type}},'bcc');  
                 }  
             }  
         }          }
     } else {      } else {
         my %default;          my %default;
Line 5104  sub modify_contacts { Line 4458  sub modify_contacts {
             }              }
             if ($others{$type} ne '') {              if ($others{$type} ne '') {
                 push(@{$changes{$type}},'others');                  push(@{$changes{$type}},'others');
             }              } 
             if ($type eq 'helpdeskmail') {  
                 if ($bcc{$type} ne '') {  
                     push(@{$changes{$type}},'bcc');  
                 }  
             }  
         }          }
     }      }
     my $putresult = &Apache::lonnet::put_dom('configuration',\%contacts_hash,      my $putresult = &Apache::lonnet::put_dom('configuration',\%contacts_hash,
Line 5137  sub modify_contacts { Line 4486  sub modify_contacts {
                         push(@text,$others{$type});                          push(@text,$others{$type});
                     }                      }
                     $resulttext .= '<span class="LC_cusr_emph">'.                      $resulttext .= '<span class="LC_cusr_emph">'.
                                    join(', ',@text).'</span>';                                     join(', ',@text).'</span></li>';
                     if ($type eq 'helpdeskmail') {  
                         if ($bcc{$type} ne '') {  
                             $resulttext .= '&nbsp;'.&mt('with Bcc to').': <span class="LC_cusr_emph">'.$bcc{$type}.'</span>';  
                         }  
                     }  
                     $resulttext .= '</li>';  
                 }                  }
             }              }
             $resulttext .= '</ul>';              $resulttext .= '</ul>';
Line 5625  sub modify_usermodification { Line 4968  sub modify_usermodification {
                             }                              }
                             my @modifiable;                              my @modifiable;
                             if ($context eq 'selfcreate') {                              if ($context eq 'selfcreate') {
                                 $resulttext .= '<li><span class="LC_cusr_emph">'.&mt('Self-creation of account by users with status: [_1]',$rolename).'</span> - '.&mt('modifiable fields (if institutional data blank): ');                                  $resulttext .= '<li><span class="LC_cusr_emph">'.&mt('Self-creation of account by users with status: [_1]  ',$rolename).'</span> - '.&mt('modifiable fields (if institutional data blank): ');
                             } else {                              } else {
                                 $resulttext .= '<li><span class="LC_cusr_emph">'.&mt('Target user with [_1] role',$rolename).'</span> - '.&mt('modifiable fields: ');                                  $resulttext .= '<li><span class="LC_cusr_emph">'.&mt('Target user with [_1] role',$rolename).'</span> - '.&mt('modifiable fields: ');
                             }                              }
Line 5769  sub modify_scantron { Line 5112  sub modify_scantron {
         my $error;          my $error;
         if ($configuserok eq 'ok') {          if ($configuserok eq 'ok') {
             if ($switchserver) {              if ($switchserver) {
                 $error = &mt("Upload of bubblesheet format file is not permitted to this server: [_1]",$switchserver);                  $error = &mt("Upload of scantron format file is not permitted to this server: [_1]",$switchserver);
             } else {              } else {
                 if ($author_ok eq 'ok') {                  if ($author_ok eq 'ok') {
                     my ($result,$scantronurl) =                      my ($result,$scantronurl) =
Line 5809  sub modify_scantron { Line 5152  sub modify_scantron {
                 if (ref($confhash{'scantron'}) eq 'HASH') {                  if (ref($confhash{'scantron'}) eq 'HASH') {
                     $resulttext = &mt('Changes made:').'<ul>';                      $resulttext = &mt('Changes made:').'<ul>';
                     if ($confhash{'scantron'}{'scantronformat'} eq '') {                      if ($confhash{'scantron'}{'scantronformat'} eq '') {
                         $resulttext .= '<li>'.&mt('[_1] bubblesheet format file removed; [_2] file will be used for courses in this domain.',$custom,$default).'</li>';                          $resulttext .= '<li>'.&mt('[_1] scantron format file removed; [_2] file will be used for courses in this domain.',$custom,$default).'</li>';
                     } else {                      } else {
                         $resulttext .= '<li>'.&mt('Custom bubblesheet format file ([_1]) uploaded for use with courses in this domain.',$custom).'</li>';                          $resulttext .= '<li>'.&mt('Custom scantron format file ([_1]) uploaded for use with courses in this domain.',$custom).'</li>';
                     }                      }
                     $resulttext .= '</ul>';                      $resulttext .= '</ul>';
                 } else {                  } else {
                     $resulttext = &mt('Changes made to bubblesheet format file.');                      $resulttext = &mt('Changes made to scantron format file.');
                 }                  }
                 $resulttext .= '</ul>';                  $resulttext .= '</ul>';
                 &Apache::loncommon::devalidate_domconfig_cache($dom);                  &Apache::loncommon::devalidate_domconfig_cache($dom);
             } else {              } else {
                 $resulttext = &mt('No changes made to bubblesheet format file');                  $resulttext = &mt('No changes made to scantron format file');
             }              }
         } else {          } else {
             $resulttext = '<span class="LC_error">'.              $resulttext = '<span class="LC_error">'.
                 &mt('An error occurred: [_1]',$putresult).'</span>';                  &mt('An error occurred: [_1]',$putresult).'</span>';
         }          }
     } else {      } else {
         $resulttext = &mt('No changes made to bubblesheet format file');           $resulttext = &mt('No changes made to scantron format file'); 
     }      }
     if ($errors) {      if ($errors) {
         $resulttext .= &mt('The following errors occurred: ').'<ul>'.          $resulttext .= &mt('The following errors occurred: ').'<ul>'.
Line 5851  sub modify_coursecategories { Line 5194  sub modify_coursecategories {
             $changes{'categorize'} = 1;              $changes{'categorize'} = 1;
             $domconfig{'coursecategories'}{'categorize'} = $env{'form.categorize'};              $domconfig{'coursecategories'}{'categorize'} = $env{'form.categorize'};
         }          }
         if ($domconfig{'coursecategories'}{'togglecatscomm'} ne $env{'form.togglecatscomm'}) {  
             $changes{'togglecatscomm'} = 1;  
             $domconfig{'coursecategories'}{'togglecatscomm'} = $env{'form.togglecatscomm'};  
         }  
         if ($domconfig{'coursecategories'}{'categorizecomm'} ne $env{'form.categorizecomm'}) {  
             $changes{'categorizecomm'} = 1;  
             $domconfig{'coursecategories'}{'categorizecomm'} = $env{'form.categorizecomm'};  
         }  
     } else {      } else {
         $changes{'togglecats'} = 1;          $changes{'togglecats'} = 1;
         $changes{'categorize'} = 1;          $changes{'categorize'} = 1;
         $changes{'togglecatscomm'} = 1;  
         $changes{'categorizecomm'} = 1;  
         $domconfig{'coursecategories'} = {          $domconfig{'coursecategories'} = {
                                              togglecats => $env{'form.togglecats'},                                               togglecats => $env{'form.togglecats'},
                                              categorize => $env{'form.categorize'},                                               categorize => $env{'form.categorize'},
                                              togglecatscomm => $env{'form.togglecatscomm'},  
                                              categorizecomm => $env{'form.categorizecomm'},  
                                          };                                           };
     }      }
     if (ref($cathash) eq 'HASH') {      if (ref($cathash) eq 'HASH') {
         if (($domconfig{'coursecategories'}{'cats'}{'instcode::0'} ne '')  && ($env{'form.instcode'} == 0)) {          if (($domconfig{'coursecategories'}{'cats'}{'instcode::0'} ne '')  && ($env{'form.instcode'} == 0)) {
             push (@deletecategory,'instcode::0');              push (@deletecategory,'instcode::0');
         }          }
         if (($domconfig{'coursecategories'}{'cats'}{'communities::0'} ne '')  && ($env{'form.communities'} == 0)) {  
             push(@deletecategory,'communities::0');  
         }  
     }      }
     my (@predelcats,@predeltrails,%predelallitems,%sort_by_deltrail);      my (@predelcats,@predeltrails,%predelallitems,%sort_by_deltrail);
     if (ref($cathash) eq 'HASH') {      if (ref($cathash) eq 'HASH') {
Line 5927  sub modify_coursecategories { Line 5255  sub modify_coursecategories {
             $adds{$newitem} = 1;              $adds{$newitem} = 1;
         }          }
     }      }
     if ($env{'form.communities'} eq '1') {  
         if (ref($cathash) eq 'HASH') {  
             my $newitem = 'communities::0';  
             if ($cathash->{$newitem} eq '') {  
                 $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.communities_pos'};  
                 $adds{$newitem} = 1;  
             }  
         } else {  
             my $newitem = 'communities::0';  
             $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.communities_pos'};  
             $adds{$newitem} = 1;  
         }  
     }  
     if ($env{'form.addcategory_name'} ne '') {      if ($env{'form.addcategory_name'} ne '') {
         if (($env{'form.addcategory_name'} ne 'instcode') &&          my $newitem = &escape($env{'form.addcategory_name'}).'::0';
             ($env{'form.addcategory_name'} ne 'communities')) {          $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos'};
             my $newitem = &escape($env{'form.addcategory_name'}).'::0';          $adds{$newitem} = 1;
             $domconfig{'coursecategories'}{'cats'}{$newitem} = $env{'form.addcategory_pos'};  
             $adds{$newitem} = 1;  
         }  
     }      }
     my $putresult;      my $putresult;
     if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {      if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
Line 5983  sub modify_coursecategories { Line 5295  sub modify_coursecategories {
         $putresult = &Apache::lonnet::put_dom('configuration',\%domconfig,$dom);          $putresult = &Apache::lonnet::put_dom('configuration',\%domconfig,$dom);
         if ($putresult eq 'ok') {          if ($putresult eq 'ok') {
             my %title = (              my %title = (
                          togglecats     => 'Show/Hide a course in catalog',                           togglecats  => 'Show/Hide a course in the catalog',
                          categorize     => 'Assign a category to a course',                           categorize     => 'Category assigned to course',
                          togglecatscomm => 'Show/Hide a community in catalog',  
                          categorizecomm => 'Assign a category to a community',  
                         );                          );
             my %level = (              my %level = (
                          dom  => 'set in Domain ("Modify Course/Community")',                           dom => 'set from "Modify Course" (Domain)',
                          crs  => 'set in Course ("Course Configuration")',                           crs => 'set from "Parameters" (Course)',
                          comm => 'set in Community ("Community Configuration")',  
                         );                          );
             $resulttext = &mt('Changes made:').'<ul>';              $resulttext = &mt('Changes made:').'<ul>';
             if ($changes{'togglecats'}) {              if ($changes{'togglecats'}) {
Line 6000  sub modify_coursecategories { Line 5309  sub modify_coursecategories {
             if ($changes{'categorize'}) {              if ($changes{'categorize'}) {
                 $resulttext .= '<li>'.&mt("$title{'categorize'} $level{$env{'form.categorize'}}").'</li>';                  $resulttext .= '<li>'.&mt("$title{'categorize'} $level{$env{'form.categorize'}}").'</li>';
             }              }
             if ($changes{'togglecatscomm'}) {  
                 $resulttext .= '<li>'.&mt("$title{'togglecatscomm'} $level{$env{'form.togglecatscomm'}}").'</li>';  
             }  
             if ($changes{'categorizecomm'}) {  
                 $resulttext .= '<li>'.&mt("$title{'categorizecomm'} $level{$env{'form.categorizecomm'}}").'</li>';  
             }  
             if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {              if ((keys(%deletions) > 0) || (keys(%reorderings) > 0) || (keys(%adds) > 0)) {
                 my $cathash;                  my $cathash;
                 if (ref($domconfig{'coursecategories'}) eq 'HASH') {                  if (ref($domconfig{'coursecategories'}) eq 'HASH') {
Line 6055  sub modify_coursecategories { Line 5358  sub modify_coursecategories {
                           &mt('An error occurred: [_1]',$putresult).'</span>';                            &mt('An error occurred: [_1]',$putresult).'</span>';
         }          }
     } else {      } else {
         $resulttext = &mt('No changes made to course and community categories');          $resulttext = &mt('No changes made to course categories');
     }      }
     return $resulttext;      return $resulttext;
 }  }
Line 6112  sub modify_serverstatuses { Line 5415  sub modify_serverstatuses {
     my %serverstatushash =  (      my %serverstatushash =  (
                                 serverstatuses => \%newserverstatus,                                  serverstatuses => \%newserverstatus,
                             );                              );
       my %changes;
     foreach my $type (@pages) {      foreach my $type (@pages) {
         foreach my $setting ('namedusers','machines') {          foreach my $setting ('namedusers','machines') {
             my (@current,@new);              my (@current,@new);
Line 6184  sub modify_serverstatuses { Line 5488  sub modify_serverstatuses {
     return $resulttext;      return $resulttext;
 }  }
   
 sub modify_coursedefaults {  
     my ($dom,%domconfig) = @_;  
     my ($resulttext,$errors,%changes,%defaultshash);  
     my %defaultchecked = ('canuse_pdfforms' => 'off');  
     my @offon = ('off','on');  
     my @toggles = ('canuse_pdfforms');  
   
     $defaultshash{'coursedefaults'} = {};  
   
     if (ref($domconfig{'coursedefaults'}) ne 'HASH') {  
         if ($domconfig{'coursedefaults'} eq '') {  
             $domconfig{'coursedefaults'} = {};  
         }  
     }  
   
     if (ref($domconfig{'coursedefaults'}) eq 'HASH') {  
         foreach my $item (@toggles) {  
             if ($defaultchecked{$item} eq 'on') {  
                 if (($domconfig{'coursedefaults'}{$item} eq '') &&  
                     ($env{'form.'.$item} eq '0')) {  
                     $changes{$item} = 1;  
                 } elsif ($domconfig{'coursdefaults'}{$item} ne $env{'form.'.$item}) {  
                     $changes{$item} = 1;  
                 }  
             } elsif ($defaultchecked{$item} eq 'off') {  
                 if (($domconfig{'coursedefaults'}{$item} eq '') &&  
                     ($env{'form.'.$item} eq '1')) {  
                     $changes{$item} = 1;  
                 } elsif ($domconfig{'coursedefaults'}{$item} ne $env{'form.'.$item}) {  
                     $changes{$item} = 1;  
                 }  
             }  
             $defaultshash{'coursedefaults'}{$item} = $env{'form.'.$item};  
         }  
     }  
     my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,  
                                              $dom);  
     if ($putresult eq 'ok') {  
         if (keys(%changes) > 0) {  
             if ($changes{'canuse_pdfforms'}) {  
                 my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);  
                 $domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'};  
                 my $cachetime = 24*60*60;  
                 &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);  
             }  
             $resulttext = &mt('Changes made:').'<ul>';  
             foreach my $item (sort(keys(%changes))) {  
                 if ($item eq 'canuse_pdfforms') {  
                     if ($env{'form.'.$item} eq '1') {  
                         $resulttext .= '<li>'.&mt("Course/Community users can create/upload PDF forms set to 'on'").'</li>';  
                     } else {  
                         $resulttext .= '<li>'.&mt('Course/Community users can create/upload PDF forms set to "off"').'</li>';  
                     }  
                 }  
             }  
             $resulttext .= '</ul>';  
         } else {  
             $resulttext = &mt('No changes made to course defaults');  
         }  
     } else {  
         $resulttext = '<span class="LC_error">'.  
             &mt('An error occurred: [_1]',$putresult).'</span>';  
     }  
     return $resulttext;  
 }  
   
 sub recurse_check {  sub recurse_check {
     my ($chkcats,$categories,$depth,$name) = @_;      my ($chkcats,$categories,$depth,$name) = @_;
     if (ref($chkcats->[$depth]{$name}) eq 'ARRAY') {      if (ref($chkcats->[$depth]{$name}) eq 'ARRAY') {
Line 6290  sub recurse_cat_deletes { Line 5528  sub recurse_cat_deletes {
     return;      return;
 }  }
   
 sub dom_servers {  
     my ($dom) = @_;  
     my (%uniqservers,%servers);  
     my $primaryserver = &Apache::lonnet::hostname(&Apache::lonnet::domain($dom,'primary'));  
     my @machinedoms = &Apache::lonnet::machine_domains($primaryserver);  
     foreach my $mdom (@machinedoms) {  
         my %currservers = %servers;  
         my %server = &Apache::lonnet::get_servers($mdom);  
         %servers = (%currservers,%server);  
     }  
     my %by_hostname;  
     foreach my $id (keys(%servers)) {  
         push(@{$by_hostname{$servers{$id}}},$id);  
     }  
     foreach my $hostname (sort(keys(%by_hostname))) {  
         if (@{$by_hostname{$hostname}} > 1) {  
             my $match = 0;  
             foreach my $id (@{$by_hostname{$hostname}}) {  
                 if (&Apache::lonnet::host_domain($id) eq $dom) {  
                     $uniqservers{$id} = $hostname;  
                     $match = 1;  
                 }  
             }  
             unless ($match) {  
                 $uniqservers{$by_hostname{$hostname}[0]} = $hostname;  
             }  
         } else {  
             $uniqservers{$by_hostname{$hostname}[0]} = $hostname;  
         }  
     }  
     return %uniqservers;  
 }  
   
 sub get_active_dcs {  
     my ($dom) = @_;  
     my %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc']);  
     my %domcoords;  
     my $numdcs = 0;  
     my $now = time;  
     foreach my $server (keys(%dompersonnel)) {  
         foreach my $user (sort(keys(%{$dompersonnel{$server}}))) {  
             my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,$user);  
             my ($end,$start) = split(':',$dompersonnel{$server}{$user});  
             if (($end eq '') || ($end == 0) || ($end > $now)) {  
                 if ($start <= $now) {  
                     $domcoords{$uname.':'.$udom} = $dompersonnel{$server}{$user};  
                 }  
             }  
         }  
     }  
     return %domcoords;  
 }  
   
 sub active_dc_picker {  
     my ($dom,$curr_dc) = @_;  
     my %domcoords = &get_active_dcs($dom);  
     my @dcs = sort(keys(%domcoords));  
     my $numdcs = scalar(@dcs);  
     my $datatable;  
     my $numinrow = 2;  
     if ($numdcs > 1) {  
         $datatable = '<table>';  
         for (my $i=0; $i<@dcs; $i++) {  
             my $rem = $i%($numinrow);  
             if ($rem == 0) {  
                 if ($i > 0) {  
                     $datatable .= '</tr>';  
                 }  
                 $datatable .= '<tr>';  
             }  
             my $check = ' ';  
             if ($curr_dc eq '') {  
                 if (!$i) {  
                     $check = ' checked="checked" ';  
                 }  
             } elsif ($dcs[$i] eq $curr_dc) {  
                 $check = ' checked="checked" ';  
             }  
             if ($i == @dcs - 1) {  
                 my $colsleft = $numinrow - $rem;  
                 if ($colsleft > 1) {  
                     $datatable .= '<td colspan="'.$colsleft.'">';  
                 } else {  
                     $datatable .= '<td>';  
                 }  
             } else {  
                 $datatable .= '<td>';  
             }  
             my ($dcname,$dcdom) = split(':',$dcs[$i]);  
             $datatable .= '<span class="LC_nobreak"><label>'.  
                           '<input type="radio" name="autocreate_xmldc"'.  
                           ' value="'.$dcs[$i].'"'.$check.'/>'.  
                           &Apache::loncommon::plainname($dcname,$dcdom).  
                           '</label></span></td>';  
         }  
         $datatable .= '</tr></table>';  
     } elsif (@dcs) {  
         $datatable .= '<input type="hidden" name="autocreate_dc" value="'.  
                       $dcs[0].'" />';  
     }  
     return ($numdcs,$datatable);  
 }  
   
 1;  1;

Removed from v.1.102.2.16  
changed lines
  Added in v.1.103


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