Diff for /loncom/interface/domainprefs.pm between versions 1.102.2.15 and 1.138.2.11

version 1.102.2.15, 2010/08/20 04:03:56 version 1.138.2.11, 2011/10/10 17:57:33
Line 140  autolimit Line 140  autolimit
   
 =over  =over
     
 - course requests will be processed autoatically up to a limit of  - course requests will be processed automatically up to a limit of
 N requests for the course type for the particular requestor.  N requests for the course type for the particular requestor.
 If N is undefined, there is no limit to the number of course requests  If N is undefined, there is no limit to the number of course requests
 which a course owner may submit and have processed automatically.   which a course owner may submit and have processed automatically. 
Line 171  use Locale::Language; Line 171  use Locale::Language;
 use DateTime::TimeZone;  use DateTime::TimeZone;
 use DateTime::Locale;  use DateTime::Locale;
   
   my $registered_cleanup;
   my $modified_urls;
   
 sub handler {  sub handler {
     my $r=shift;      my $r=shift;
     if ($r->header_only) {      if ($r->header_only) {
Line 190  sub handler { Line 193  sub handler {
         "/adm/domainprefs:mau:0:0:Cannot modify domain settings";          "/adm/domainprefs:mau:0:0:Cannot modify domain settings";
         return HTTP_NOT_ACCEPTABLE;          return HTTP_NOT_ACCEPTABLE;
     }      }
   
       $registered_cleanup=0;
       @{$modified_urls}=();
   
     &Apache::lonhtmlcommon::clear_breadcrumbs();      &Apache::lonhtmlcommon::clear_breadcrumbs();
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['phase','actions']);                                              ['phase','actions']);
Line 202  sub handler { Line 209  sub handler {
                 'quotas','autoenroll','autoupdate','autocreate',                  'quotas','autoenroll','autoupdate','autocreate',
                 'directorysrch','usercreation','usermodification',                  'directorysrch','usercreation','usermodification',
                 'contacts','defaults','scantron','coursecategories',                  'contacts','defaults','scantron','coursecategories',
                 'serverstatuses','requestcourses'],$dom);                  'serverstatuses','requestcourses','coursedefaults',
                   'usersessions'],$dom);
     my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',      my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
                        'autoupdate','autocreate','directorysrch','contacts',                         'autoupdate','autocreate','directorysrch','contacts',
                        'usercreation','usermodification','scantron',                         'usercreation','usermodification','scantron',
                        'requestcourses','coursecategories','serverstatuses');                         'requestcourses','coursecategories','serverstatuses',
                          'coursedefaults','usersessions');
     my %prefs = (      my %prefs = (
         'rolecolors' =>          'rolecolors' =>
                    { text => 'Default color schemes',                     { text => 'Default color schemes',
Line 220  sub handler { Line 229  sub handler {
                                 {col1 => 'Administrator Settings',                                  {col1 => 'Administrator Settings',
                                  col2 => '',}],                                   col2 => '',}],
                     },                      },
         'login' =>            'login' =>
                     { text => 'Log-in page options',                      { text => 'Log-in page options',
                       help => 'Domain_Configuration_Login_Page',                        help => 'Domain_Configuration_Login_Page',
                       header => [{col1 => 'Item',                        header => [{col1 => 'Item',
                                   col2 => '',}],                                    col2 => '',}],
                     },                      },
   
         'defaults' =>           'defaults' => 
                     { text => 'Default authentication/language/timezone',                      { text => 'Default authentication/language/timezone/portal',
                       help => 'Domain_Configuration_LangTZAuth',                        help => 'Domain_Configuration_LangTZAuth',
                       header => [{col1 => 'Setting',                        header => [{col1 => 'Setting',
                                   col2 => 'Value'}],                                    col2 => 'Value'}],
Line 256  sub handler { Line 266  sub handler {
                                  col2 => 'Updateable user data'}],                                   col2 => 'Updateable user data'}],
                   },                    },
         'autocreate' =>           'autocreate' => 
                   {  text => 'Auto-course creation settings',                    { text => 'Auto-course creation settings',
                      help => 'Domain_Configuration_Auto_Creation',                       help => 'Domain_Configuration_Auto_Creation',
                      header => [{col1 => 'Configuration Setting',                       header => [{col1 => 'Configuration Setting',
                                  col2 => 'Value',}],                                   col2 => 'Value',}],
Line 326  sub handler { Line 336  sub handler {
                               col3 => 'Specific IPs',                                col3 => 'Specific IPs',
                             }],                              }],
                  },                   },
           'helpsettings' =>
                    {text   => 'Help page settings',
                     help   => 'Domain_Configuration_Help_Settings',
                     header => [{col1 => 'Authenticated Help Settings',
                                 col2 => ''},
                                {col1 => 'Unauthenticated Help Settings',
                                 col2 => ''}],
                    },
         'coursedefaults' =>          'coursedefaults' =>
                  {text => 'Course/Community defaults',                   {text => 'Course/Community defaults',
                   help => 'Domain_Configuration_Course_Defaults',                    help => 'Domain_Configuration_Course_Defaults',
                     header => [{col1 => 'Defaults which can be overridden for each course by a DC',
                                 col2 => 'Value',}],
                    },
           'privacy' => 
                    {text   => 'User Privacy',
                     help   => 'Domain_Configuration_User_Privacy',
                   header => [{col1 => 'Setting',                    header => [{col1 => 'Setting',
                               col2 => 'Value',}],                                col2 => 'Value',}],
                  },                   },
            'usersessions' =>
                    {text  => 'User session hosting',
                     help  => 'Domain_Configuration_User_Sessions',
                     header => [{col1 => 'Hosting of users from other domains',
                                 col2 => 'Rules'},
                                {col1 => "Hosting domain's own users elsewhere",
                                 col2 => 'Rules'}],
                    },
     );      );
     my %servers = &dom_servers($dom);      my %servers = &dom_servers($dom);
     if (keys(%servers) > 1) {      if (keys(%servers) > 1) {
Line 430  sub process_changes { Line 462  sub process_changes {
         $output = &modify_serverstatuses($dom,%domconfig);          $output = &modify_serverstatuses($dom,%domconfig);
     } elsif ($action eq 'requestcourses') {      } elsif ($action eq 'requestcourses') {
         $output = &modify_quotas($dom,$action,%domconfig);          $output = &modify_quotas($dom,$action,%domconfig);
       } elsif ($action eq 'coursedefaults') {
           $output = &modify_coursedefaults($dom,%domconfig);
       } elsif ($action eq 'usersessions') {
           $output = &modify_usersessions($dom,%domconfig);
     }      }
     return $output;      return $output;
 }  }
Line 455  sub print_config_box { Line 491  sub print_config_box {
     }      }
     if ($numheaders > 1) {      if ($numheaders > 1) {
         my $colspan = '';          my $colspan = '';
         if (($action eq 'rolecolors') || ($action eq 'coursecategories')) {          if (($action eq 'rolecolors') || ($action eq 'coursecategories') || ($action eq 'helpsettings')) {
             $colspan = ' colspan="2"';              $colspan = ' colspan="2"';
         }          }
         $output .= '          $output .= '
Line 480  sub print_config_box { Line 516  sub print_config_box {
             $colspan = ' colspan="2"';              $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 {          } elsif ($action eq 'helpsettings') {
               $output .= &print_helpsettings('top',$dom,$confname,$settings,\$rowtotal);
           } elsif ($action eq 'usersessions') {
               $output .= &print_usersessions('top',$dom,$settings,\$rowtotal);
           } elsif ($action eq 'rolecolors') {
             $output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);              $output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
         }          }
         $output .= '          $output .= '
Line 532  sub print_config_box { Line 572  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') {
Line 541  sub print_config_box { Line 581  sub print_config_box {
             $output .= &print_login('bottom',$dom,$confname,$phase,$settings,\$rowtotal);              $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 {          } elsif ($action eq 'helpsettings') {
               $output .= &print_helpsettings('bottom',$dom,$confname,$settings,\$rowtotal);
           } elsif ($action eq 'usersessions') {
               $output .= &print_usersessions('bottom',$dom,$settings,\$rowtotal);
           } elsif ($action eq 'rolecolors') {
             $output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'              $output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
            </table>             </table>
           </td>            </td>
Line 627  sub print_config_box { Line 671  sub print_config_box {
             $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);              $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
         } elsif ($action eq 'serverstatuses') {          } elsif ($action eq 'serverstatuses') {
             $output .= &print_serverstatuses($dom,$settings,\$rowtotal);              $output .= &print_serverstatuses($dom,$settings,\$rowtotal);
           } elsif ($action eq 'coursedefaults') {
               $output .= &print_coursedefaults('bottom',$dom,$settings,\$rowtotal);
         }          }
     }      }
     $output .= '      $output .= '
Line 727  sub print_login { Line 773  sub print_login {
             $checkedon{$item} = ' ';              $checkedon{$item} = ' ';
         }          }
     }      }
     my $loginheader = 'image';  
     my @images = ('img','logo','domlogo','login');      my @images = ('img','logo','domlogo','login');
     my @logintext = ('textcol','bgcol');      my @logintext = ('textcol','bgcol');
     my @bgs = ('pgbg','mainbg','sidebg');      my @bgs = ('pgbg','mainbg','sidebg');
Line 776  sub print_login { Line 821  sub print_login {
                 $is_custom{$item} = 1;                  $is_custom{$item} = 1;
             }              }
         }          }
         if ($settings->{'loginheader'} ne '') {  
             $loginheader = $settings->{'loginheader'};  
         }  
         if ($settings->{'font'} ne '') {          if ($settings->{'font'} ne '') {
             $designs{'font'} = $settings->{'font'};              $designs{'font'} = $settings->{'font'};
             $is_custom{'font'} = 1;              $is_custom{'font'} = 1;
Line 824  sub print_login { Line 866  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 837  sub print_login { Line 878  sub print_login {
             '</tr>';              '</tr>';
         $itemcount ++;          $itemcount ++;
     }      }
     $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal,\@logintext,$loginheader);      $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal,\@logintext);
     $datatable .= '</tr></table></td></tr>';      $datatable .= '</tr></table></td></tr>';
     return $datatable;      return $datatable;
 }  }
Line 846  sub login_choices { Line 887  sub login_choices {
     my %choices =      my %choices =
         &Apache::lonlocal::texthash (          &Apache::lonlocal::texthash (
             coursecatalog => 'Display Course/Community Catalog link?',              coursecatalog => 'Display Course/Community Catalog link?',
             adminmail => "Display Administrator's E-mail Address?",              adminmail     => "Display Administrator's E-mail Address?",
             disallowlogin => "Login page requests redirected",              disallowlogin => "Login page requests redirected",
             hostid        => "Server",              hostid        => "Server",
             server        => "Redirect to:",              server        => "Redirect to:",
             serverpath    => "Path",              serverpath    => "Path",
             custompath    => "Custom",              custompath    => "Custom", 
             exempt        => "Exempt IP(s)",              exempt        => "Exempt IP(s)",
             directlogin   => "No redirect",              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",
             domlogo => "Domain Logo",              domlogo       => "Domain Logo",
             login => "Log-in Header",               login         => "Log-in Header", 
             textcol => "Text color",              textcol       => "Text color",
             bgcol   => "Box color",              bgcol         => "Box color",
             bgs => "Background colors",              bgs           => "Background colors",
             links => "Link colors",              links         => "Link colors",
             font => "Font color",              font          => "Font color",
             pgbg => "Header",              pgbg          => "Header",
             mainbg => "Page",              mainbg        => "Page",
             sidebg => "Login box",              sidebg        => "Login box",
             link => "Link",              link          => "Link",
             alink => "Active link",              alink         => "Active link",
             vlink => "Visited link",              vlink         => "Visited link",
         );          );
     return %choices;      return %choices;
 }  }
Line 887  sub print_rolecolors { Line 928  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 904  sub print_rolecolors { Line 946  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 922  sub print_rolecolors { Line 968  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 948  sub print_rolecolors { Line 998  sub print_rolecolors {
   
 sub display_color_options {  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) = @_;
     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'.$css_class.'>'.
         '<td>'.$choices->{'font'}.'</td>';          '<td>'.$choices->{'font'}.'</td>';
Line 964  sub display_color_options { Line 1014  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>';
       unless ($role eq 'login') { 
           $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 974  sub display_color_options { Line 1040  sub display_color_options {
         if ($role eq 'login') {          if ($role eq 'login') {
             if ($img eq 'login') {              if ($img eq 'login') {
                 $login_hdr_pick =                  $login_hdr_pick =
                     &login_header_options($img,$role,$defaults,$is_custom,$choices,                      &login_header_options($img,$role,$defaults,$is_custom,$choices);
                                           $loginheader);  
                 $logincolors =                  $logincolors =
                     &login_text_colors($img,$role,$logintext,$phase,$choices,                      &login_text_colors($img,$role,$logintext,$phase,$choices,
                                             $designs);                                              $designs);
Line 1052  sub display_color_options { Line 1117  sub display_color_options {
                 }                  }
                 $datatable .= '<td>';                  $datatable .= '<td>';
                 if ($img eq 'login') {                  if ($img eq 'login') {
                     $datatable .= $login_hdr_pick;                          $datatable .= $login_hdr_pick;
                 }                  } 
                 $datatable .= &image_changes($is_custom->{$img},$alt_text->{$img},$img_import,                  $datatable .= &image_changes($is_custom->{$img},$alt_text->{$img},$img_import,
                                              $showfile,$fullsize,$role,$img,$imgfile,$logincolors);                                               $showfile,$fullsize,$role,$img,$imgfile,$logincolors);
             } else {              } else {
Line 1067  sub display_color_options { Line 1132  sub display_color_options {
         if ($switchserver) {          if ($switchserver) {
             $datatable .= &mt('Upload to library server: [_1]',$switchserver);              $datatable .= &mt('Upload to library server: [_1]',$switchserver);
         } else {          } else {
             $datatable .='&nbsp;<input type="file" name="'.$role.'_'.$img.'" />';              if ($img ne 'login') { # suppress file selection for Log-in header
                   $datatable .='&nbsp;<input type="file" name="'.$role.'_'.$img.'" />';
               }
         }          }
         $datatable .= '</td></tr>';          $datatable .= '</td></tr>';
     }      }
Line 1156  sub logo_display_options { Line 1223  sub logo_display_options {
 }  }
   
 sub login_header_options  {  sub login_header_options  {
     my ($img,$role,$defaults,$is_custom,$choices,$loginheader) = @_;      my ($img,$role,$defaults,$is_custom,$choices) = @_;
     my $image_checked = ' checked="checked" ';      my $output = '';
     my $text_checked = ' ';  
     if ($loginheader eq 'text') {  
         $image_checked = ' ';  
         $text_checked = ' checked="checked" ';  
     }  
     my $output = '<span class="LC_nobreak"><label><input type="radio" name="'.  
               'loginheader" value="image" '.$image_checked.'/>'.  
               &mt('use image').'</label>&nbsp;&nbsp;&nbsp;'.  
               '<label><input type="radio" name="loginheader" value="text"'.  
               $text_checked.'/>'.&mt('use text').'</label><br />'."\n";  
     if ((!$is_custom->{'textcol'}) || (!$is_custom->{'bgcol'})) {      if ((!$is_custom->{'textcol'}) || (!$is_custom->{'bgcol'})) {
         $output .= &mt('Text default(s)').':<br />';          $output .= &mt('Text default(s):').'<br />';
         if (!$is_custom->{'textcol'}) {          if (!$is_custom->{'textcol'}) {
             $output .= $choices->{'textcol'}.':&nbsp;'.$defaults->{'logintext'}{'textcol'}.              $output .= $choices->{'textcol'}.':&nbsp;'.$defaults->{'logintext'}{'textcol'}.
                        '&nbsp;&nbsp;&nbsp;';                         '&nbsp;&nbsp;&nbsp;';
Line 1205  sub login_text_colors { Line 1262  sub login_text_colors {
 sub image_changes {  sub image_changes {
     my ($is_custom,$alt_text,$img_import,$showfile,$fullsize,$role,$img,$imgfile,$logincolors) = @_;      my ($is_custom,$alt_text,$img_import,$showfile,$fullsize,$role,$img,$imgfile,$logincolors) = @_;
     my $output;      my $output;
     if (!$is_custom) {      if ($img eq 'login') {
               # suppress image for Log-in header
       } elsif (!$is_custom) {
         if ($img ne 'domlogo') {          if ($img ne 'domlogo') {
             $output .= &mt('Default image:').'<br />';              $output .= &mt('Default image:').'<br />';
         } else {          } else {
             $output .= &mt('Default in use:').'<br />';              $output .= &mt('Default in use:').'<br />';
         }          }
     }      }
     if ($img_import) {      if ($img eq 'login') { # suppress image for Log-in header
         $output .= '<input type="hidden" name="'.$role.'_import_'.$img.'" value="'.$imgfile.'" />';          $output .= '<td>'.$logincolors;
     }  
     $output .= '<a href="'.$fullsize.'" target="_blank"><img src="'.  
                $showfile.'" alt="'.$alt_text.'" border="0" /></a></td>';  
     if ($is_custom) {  
         $output .= '<td>'.$logincolors.'<span class="LC_nobreak"><label>'.  
                    '<input type="checkbox" name="'.  
                    $role.'_del_'.$img.'" value="1" />'.&mt('Delete?').  
                    '</label>&nbsp;'.&mt('Replace:').'</span><br />';  
     } else {      } else {
         $output .= '<td valign="bottom">'.$logincolors.&mt('Upload:').'<br />';          if ($img_import) {
               $output .= '<input type="hidden" name="'.$role.'_import_'.$img.'" value="'.$imgfile.'" />';
           }
           $output .= '<a href="'.$fullsize.'" target="_blank"><img src="'.
                      $showfile.'" alt="'.$alt_text.'" border="0" /></a></td>';
           if ($is_custom) {
               $output .= '<td>'.$logincolors.'<span class="LC_nobreak"><label>'.
                          '<input type="checkbox" name="'.
                          $role.'_del_'.$img.'" value="1" />'.&mt('Delete?').
                          '</label>&nbsp;'.&mt('Replace:').'</span><br />';
           } else {
               $output .= '<td valign="bottom">'.$logincolors.&mt('Upload:').'<br />';
           }
     }      }
     return $output;      return $output;
 }  }
Line 1350  sub print_quotas { Line 1413  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 style="vertical-align: top">'.$cell{$item}.'</td>';  
                     }                      }
                     $datatable .= '</tr></table>';                      $datatable .= '</tr></table>';
                 }                  }
Line 1456  sub print_quotas { Line 1519  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 style="vertical-align: top">'.$defcell{$item}.'</td>';
         }          }
         $datatable .= '</tr></table>';          $datatable .= '</tr></table>';
     }      }
Line 1559  sub print_quotas { Line 1622  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 style="vertical-align: top">'.$advcell{$item}.'</td>';
         }          }
         $datatable .= '</tr></table>';          $datatable .= '</tr></table>';
     }      }
Line 1822  sub print_autocreate { Line 1885  sub print_autocreate {
                   '<input type="radio" name="autocreate_xml"'.                    '<input type="radio" name="autocreate_xml"'.
                   $createon{'xml'}.' value="1" />'.&mt('Yes').'</label>&nbsp;'.                    $createon{'xml'}.' value="1" />'.&mt('Yes').'</label>&nbsp;'.
                   '<label><input type="radio" name="autocreate_xml"'.                    '<label><input type="radio" name="autocreate_xml"'.
                   $createoff{'xml'}.' value="0" />'.&mt('No').'</label></span>';                    $createoff{'xml'}.' value="0" />'.&mt('No').'</label></span>'.
                     '</td></tr><tr>'.
                     '<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>';
     my ($numdc,$dctable) = &active_dc_picker($dom,$curr_dc);      my ($numdc,$dctable) = &active_dc_picker($dom,$curr_dc);
     if ($numdc > 1) {      if ($numdc > 1) {
         $datatable .= '</td><tr><td>'.          $datatable .= '</td></tr><tr class="LC_odd_row"><td>'.
                       &mt('XML files processed as: (choose Dom. Coord.)').                        &mt('Course creation processed as: (choose Dom. Coord.)'). 
                       '</td><td class="LC_left_item">'.$dctable.'</td></tr>'.                        '</td><td class="LC_left_item">'.$dctable.'</td></tr>';
                       '<tr class="LC_odd_row">';  
         $$rowtotal ++ ;          $$rowtotal ++ ;
     } else {      } else {
         $datatable .= '</td></tr><tr>';          $datatable .= $dctable.'</td></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;      return $datatable;
 }  }
   
Line 2040  sub print_contacts { Line 2102  sub print_contacts {
     return $datatable;      return $datatable;
 }  }
   
   sub print_helpsettings {
   
    my ($position,$dom,$confname,$settings,$rowtotal) = @_;
    my ($css_class,$datatable);
   
    my $switchserver = &check_switchserver($dom,$confname);
   
    my $itemcount = 1;
   
    if ($position eq 'top') {
   
    my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles);
   
    %choices =
    &Apache::lonlocal::texthash (
    submitbugs => 'Display &quot;Submit a bug&quot; link?',
    );
   
    %defaultchecked = ('submitbugs' => 'on');
   
    @toggles = ('submitbugs',);
   
    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><span class="LC_nobreak">&nbsp;</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 ++;
    }
        
        } else {
        
         $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
        
         $datatable .= '<tr'.$css_class.'>';
        
         if (ref($settings) eq 'HASH') {
    if ($settings->{'loginhelpurl'} ne '') {
    my($directory, $filename) = $settings->{'loginhelpurl'} =~ m/(.*\/)(.*)$/;
    $datatable .= '<td width="33%"><span class="LC_left_item"><label><a href="'.$settings->{'loginhelpurl'}.'" target="_blank">'.&mt('Custom Login Page Help File In Use').'</a></label></span></td>';
    $datatable .= '<td width="33%"><span class="LC_right_item"><label><input type="checkbox" name="loginhelpurl_del" value="1" />'.&mt('Delete?').'</label></span></td>'
    } else {
    $datatable .= '<td width="33%"><span class="LC_left_item"><label>'.&mt('Default Login Page Help File In Use').'</label></span></td>';
    $datatable .= '<td width="33%"><span class="LC_right_item">&nbsp;</span></td>';
    }
    } else {
    $datatable .= '<td><span class="LC_left_item">&nbsp;</span></td>';
    $datatable .= '<td><span class="LC_right_item">&nbsp;</span></td>';
    }
      
         $datatable .= '<td width="33%"><span class="LC_right_item">';
         if ($switchserver) {
               $datatable .= &mt('Upload to library server: [_1]',$switchserver);
           } else {
           $datatable .= &mt('Upload Custom Login Page Help File:');
               $datatable .='<input type="file" name="loginhelpurl" />';
           }
           $datatable .= '</span></td></tr>';
           
        }
        
        return $datatable;
   
   }
   
   
 sub radiobutton_prefs {  sub radiobutton_prefs {
     my ($settings,$toggles,$defaultchecked,$choices,$itemcount) = @_;      my ($settings,$toggles,$defaultchecked,$choices,$itemcount) = @_;
     return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') &&      return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') &&
Line 2085  sub radiobutton_prefs { Line 2241  sub radiobutton_prefs {
 }  }
   
 sub print_coursedefaults {  sub print_coursedefaults {
     my ($dom,$settings,$rowtotal) = @_;      my ($position,$dom,$settings,$rowtotal) = @_;
     my ($css_class,$datatable);      my ($css_class,$datatable);
     my $itemcount = 1;      my $itemcount = 1;
     my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles);      if ($position eq 'top') {
     %choices =          my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles);
         &Apache::lonlocal::texthash (          %choices =
             canuse_pdfforms => 'Course/Community users can create/upload PDF forms',              &Apache::lonlocal::texthash (
     );                  canuse_pdfforms => 'Course/Community users can create/upload PDF forms',
     %defaultchecked = ('canuse_pdfforms' => 'off');          );
     @toggles = ('canuse_pdfforms',);          %defaultchecked = ('canuse_pdfforms' => 'off');
     ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,          @toggles = ('canuse_pdfforms',);
           ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
                                                  \%choices,$itemcount);                                                   \%choices,$itemcount);
           $$rowtotal += $itemcount;
       } else {
           $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
           my %choices =
               &Apache::lonlocal::texthash (
                   anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys',
           );
           my $currdefresponder;
           if (ref($settings) eq 'HASH') {
               $currdefresponder = $settings->{'anonsurvey_threshold'};
           }
           if (!$currdefresponder) {
               $currdefresponder = 10;
           } elsif ($currdefresponder < 1) {
               $currdefresponder = 1;
           }
           $datatable .=
                  '<tr'.$css_class.'><td><span class="LC_nobreak">'.$choices{'anonsurvey_threshold'}.
                   '</span></td>'.
                   '<td class="LC_right_item"><span class="LC_nobreak">'.
                   '<input type="text" name="anonsurvey_threshold"'.
                   ' value="'.$currdefresponder.'" size="5" /></span>'.
                   '</td></tr>';
       }
       return $datatable;
   }
   
   sub print_usersessions {
       my ($position,$dom,$settings,$rowtotal) = @_;
       my ($css_class,$datatable,%checked,%choices);
       my (%by_ip,%by_location,@intdoms);
       &build_location_hashes(\@intdoms,\%by_ip,\%by_location);
       if (keys(%by_location) == 0) {
           if ($position eq 'top') {
               $datatable .= '<tr'.$css_class.'><td colspan="2">'.
                             &mt('Nothing to set here, as the cluster to which this domain belongs only contains this institution.');
           }
       }
       my %lt = &usersession_titles();
       my $itemcount = 1;
       my $numinrow = 5;
       my $prefix;
       my @types;
       if ($position eq 'top') {
           $prefix = 'hosted';
           @types = ('excludedomain','includedomain');
       } else {
           $prefix = 'remote';
           @types = ('version','excludedomain','includedomain');
       }
       my (%current,%checkedon,%checkedoff);
       my @lcversions = &Apache::lonnet::all_loncaparevs();
       my @locations = sort(keys(%by_location));
       foreach my $type (@types) {
           $checkedon{$type} = '';
           $checkedoff{$type} = ' checked="checked"';
       }
       if (ref($settings) eq 'HASH') {
           if (ref($settings->{$prefix}) eq 'HASH') {
               foreach my $key (keys(%{$settings->{$prefix}})) {
                   $current{$key} = $settings->{$prefix}{$key};
                   if ($key eq 'version') {
                       if ($current{$key} ne '') {
                           $checkedon{$key} = ' checked="checked"';
                           $checkedoff{$key} = '';
                       }
                   } elsif (ref($current{$key}) eq 'ARRAY') {
                       $checkedon{$key} = ' checked="checked"';
                       $checkedoff{$key} = '';
                   }
               }
           }
       }
       foreach my $type (@types) {
           next if ($type ne 'version' && !@locations);
           $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
           $datatable .= '<tr'.$css_class.'>
                          <td><span class="LC_nobreak">'.$lt{$type}.'</span><br />
                              <span class="LC_nobreak">&nbsp;
                              <label><input type="radio" name="'.$prefix.'_'.$type.'_inuse" '.$checkedoff{$type}.' value="0" />'.&mt('Not in use').'</label>&nbsp;
                              <label><input type="radio" name="'.$prefix.'_'.$type.'_inuse" '.$checkedon{$type}.' value="1" />'.&mt('In use').'</label></span></td><td>';
           if ($type eq 'version') {
               my $selector = '<select name="'.$prefix.'_version">';
               foreach my $version (@lcversions) {
                   my $selected = '';
                   if ($current{'version'} eq $version) {
                       $selected = ' selected="selected"';
                   }
                   $selector .= ' <option value="'.$version.'"'.
                                $selected.'>'.$version.'</option>';
               }
               $selector .= '</select> ';
               $datatable .= &mt('remote server must be version: [_1] or later',$selector);
           } else {
               $datatable.= '<div><input type="button" value="'.&mt('check all').'" '.
                            'onclick="javascript:checkAll(document.display.'.$prefix.'_'.$type.')"'.
                            ' />'.('&nbsp;'x2).
                            '<input type="button" value="'.&mt('uncheck all').'" '.
                            'onclick="javascript:uncheckAll(document.display.'.$prefix.'_'.$type.')" />'.
                            "\n".
                            '</div><div><table>';
               my $rem;
               for (my $i=0; $i<@locations; $i++) {
                   my ($showloc,$value,$checkedtype);
                   if (ref($by_location{$locations[$i]}) eq 'ARRAY') {
                       my $ip = $by_location{$locations[$i]}->[0];
                       if (ref($by_ip{$ip}) eq 'ARRAY') {
                           $value = join(':',@{$by_ip{$ip}});
                           $showloc = join(', ',@{$by_ip{$ip}});
                           if (ref($current{$type}) eq 'ARRAY') {
                               foreach my $loc (@{$by_ip{$ip}}) {  
                                   if (grep(/^\Q$loc\E$/,@{$current{$type}})) {
                                       $checkedtype = ' checked="checked"';
                                       last;
                                   }
                               }
                           }
                       }
                   }
                   $rem = $i%($numinrow);
                   if ($rem == 0) {
                       if ($i > 0) {
                           $datatable .= '</tr>';
                       }
                       $datatable .= '<tr>';
                   }
                   $datatable .= '<td class="LC_left_item">'.
                                 '<span class="LC_nobreak"><label>'.
                                 '<input type="checkbox" name="'.$prefix.'_'.$type.
                                 '" value="'.$value.'"'.$checkedtype.' />'.$showloc.
                                 '</label></span></td>';
               }
               $rem = @locations%($numinrow);
               my $colsleft = $numinrow - $rem;
               if ($colsleft > 1 ) {
                   $datatable .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
                                 '&nbsp;</td>';
               } elsif ($colsleft == 1) {
                   $datatable .= '<td class="LC_left_item">&nbsp;</td>';
               }
               $datatable .= '</tr></table>';
           }
           $datatable .= '</td></tr>';
           $itemcount ++;
       }
     $$rowtotal += $itemcount;      $$rowtotal += $itemcount;
     return $datatable;      return $datatable;
 }  }
   
   sub build_location_hashes {
       my ($intdoms,$by_ip,$by_location) = @_;
       return unless((ref($intdoms) eq 'ARRAY') && (ref($by_ip) eq 'HASH') &&
                     (ref($by_location) eq 'HASH')); 
       my %iphost = &Apache::lonnet::get_iphost();
       my $primary_id = &Apache::lonnet::domain($env{'request.role.domain'},'primary');
       my $primary_ip = &Apache::lonnet::get_host_ip($primary_id);
       if (ref($iphost{$primary_ip}) eq 'ARRAY') {
           foreach my $id (@{$iphost{$primary_ip}}) {
               my $intdom = &Apache::lonnet::internet_dom($id);
               unless(grep(/^\Q$intdom\E$/,@{$intdoms})) {
                   push(@{$intdoms},$intdom);
               }
           }
       }
       foreach my $ip (keys(%iphost)) {
           if (ref($iphost{$ip}) eq 'ARRAY') {
               foreach my $id (@{$iphost{$ip}}) {
                   my $location = &Apache::lonnet::internet_dom($id);
                   if ($location) {
                       next if (grep(/^\Q$location\E$/,@{$intdoms}));
                       if (ref($by_ip->{$ip}) eq 'ARRAY') {
                           unless(grep(/^\Q$location\E$/,@{$by_ip->{$ip}})) {
                               push(@{$by_ip->{$ip}},$location);
                           }
                       } else {
                           $by_ip->{$ip} = [$location];
                       }
                   }
               }
           }
       }
       foreach my $ip (sort(keys(%{$by_ip}))) {
           if (ref($by_ip->{$ip}) eq 'ARRAY') {
               @{$by_ip->{$ip}} = sort(@{$by_ip->{$ip}});
               my $first = $by_ip->{$ip}->[0];
               if (ref($by_location->{$first}) eq 'ARRAY') {
                   unless (grep(/^\Q$ip\E$/,@{$by_location->{$first}})) {
                       push(@{$by_location->{$first}},$ip);
                   }
               } else {
                   $by_location->{$first} = [$ip];
               }
           }
       }
       return;
   }
   
 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 2146  sub courserequest_titles { Line 2496  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).',         approval    => '(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 2472  sub print_usermodification { Line 2822  sub print_usermodification {
 sub print_defaults {  sub print_defaults {
     my ($dom,$rowtotal) = @_;      my ($dom,$rowtotal) = @_;
     my @items = ('auth_def','auth_arg_def','lang_def','timezone_def',      my @items = ('auth_def','auth_arg_def','lang_def','timezone_def',
                  'datelocale_def');                   'datelocale_def','portal_def');
     my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);      my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
     my $titles = &defaults_titles();      my $titles = &defaults_titles($dom);
     my $rownum = 0;      my $rownum = 0;
     my ($datatable,$css_class);      my ($datatable,$css_class);
     foreach my $item (@items) {      foreach my $item (@items) {
Line 2511  sub print_defaults { Line 2861  sub print_defaults {
             my $includeempty = 1;              my $includeempty = 1;
             $datatable .= &Apache::loncommon::select_datelocale($item,$domdefaults{$item},undef,$includeempty);              $datatable .= &Apache::loncommon::select_datelocale($item,$domdefaults{$item},undef,$includeempty);
         } else {          } else {
               my $size;
               if ($item eq 'portal_def') {
                   $size = ' size="25"';
               }
             $datatable .= '<input type="text" name="'.$item.'" value="'.              $datatable .= '<input type="text" name="'.$item.'" value="'.
                           $domdefaults{$item}.'" />';                            $domdefaults{$item}.'"'.$size.' />';
         }          }
         $datatable .= '</td></tr>';          $datatable .= '</td></tr>';
         $rownum ++;          $rownum ++;
Line 2522  sub print_defaults { Line 2876  sub print_defaults {
 }  }
   
 sub defaults_titles {  sub defaults_titles {
       my ($dom) = @_;
     my %titles = &Apache::lonlocal::texthash (      my %titles = &Apache::lonlocal::texthash (
                    'auth_def'      => 'Default authentication type',                     'auth_def'      => 'Default authentication type',
                    'auth_arg_def'  => 'Default authentication argument',                     'auth_arg_def'  => 'Default authentication argument',
                    'lang_def'      => 'Default language',                     'lang_def'      => 'Default language',
                    'timezone_def'  => 'Default timezone',                     'timezone_def'  => 'Default timezone',
                    'datelocale_def' => 'Default locale for dates',                     'datelocale_def' => 'Default locale for dates',
                      'portal_def'     => 'Portal/Default URL',
                  );                   );
       if ($dom) {
           my $uprimary_id = &Apache::lonnet::domain($dom,'primary');
           my $uint_dom = &Apache::lonnet::internet_dom($uprimary_id);
           my $protocol = $Apache::lonnet::protocol{$uprimary_id};
           $protocol = 'http' if ($protocol ne 'https');
           if ($uint_dom) {
               $titles{'portal_def'} .= ' '.&mt('(for example: [_1])',$protocol.'://loncapa.'.
                                            $uint_dom);
           }
       }
     return (\%titles);      return (\%titles);
 }  }
   
Line 2742  sub print_coursecategories { Line 3108  sub print_coursecategories {
                      categorizecomm => 'Assign a category to a community',                       categorizecomm => 'Assign a category to a community',
                     );                      );
         my %level = &Apache::lonlocal::texthash (          my %level = &Apache::lonlocal::texthash (
                      dom => 'Set in Domain',                       dom  => 'Set in Domain',
                      crs => 'Set in Course',                          crs  => 'Set in Course',
                      comm => 'Set in Community',                       comm => 'Set in Community',
                     );                      );
         $datatable = '<tr class="LC_odd_row">'.          $datatable = '<tr class="LC_odd_row">'.
Line 2802  sub print_coursecategories { Line 3168  sub print_coursecategories {
                           communities => &mt('Communities'),                            communities => &mt('Communities'),
                     );                      );
   
                     if ((!grep(/^instcode$/,@{$cats[0]})) ||                      if ((!grep(/^instcode$/,@{$cats[0]})) || 
                         ($cathash->{'instcode::0'} eq '') ||                          ($cathash->{'instcode::0'} eq '') ||
                         (!grep(/^communities$/,@{$cats[0]})) ||                          (!grep(/^communities$/,@{$cats[0]})) || 
                         ($cathash->{'communities::0'} eq '')) {                          ($cathash->{'communities::0'} eq '')) {
                         $maxnum ++;                          $maxnum ++;
                     }                      }
Line 2898  sub print_coursecategories { Line 3264  sub print_coursecategories {
                                           '<td><span class="LC_nobreak">'.                                            '<td><span class="LC_nobreak">'.
                                           $default_names{$default}.'</span>';                                            $default_names{$default}.'</span>';
                             if ($default eq 'instcode') {                              if ($default eq 'instcode') {
                                 $datatable .= '<br /><span class="LC_nobreak">('                                  $datatable .= '<br /><span class="LC_nobreak">(' 
                                               .&mt('with institutional codes').')</span>';                                                .&mt('with institutional codes').')</span>';
                             }                              }
                             $datatable .= '</td>'                              $datatable .= '</td>'
Line 2997  sub coursecategories_javascript { Line 3363  sub coursecategories_javascript {
     }      }
     my $instcode_reserved = &mt('The name: "instcode" is a reserved category');      my $instcode_reserved = &mt('The name: "instcode" is a reserved category');
     my $communities_reserved = &mt('The name: "communities" 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');      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[  // <![CDATA[
Line 3478  sub modify_login { Line 3844  sub modify_login {
                                 $new = '/';                                  $new = '/';
                             }                              }
                         }                          }
                         if (($item eq 'custompath') &&                          if (($item eq 'custompath') && 
                             ($env{'form.'.$lonhost.'_serverpath'} ne 'custom')) {                              ($env{'form.'.$lonhost.'_serverpath'} ne 'custom')) {
                             $new = '';                              $new = '';
                         }                          }
Line 3493  sub modify_login { Line 3859  sub modify_login {
                             foreach my $ip (@poss_ips) {                              foreach my $ip (@poss_ips) {
                                 if ($ip =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) {                                  if ($ip =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) {
                                     if (($1 <= 255) && ($2 <= 255) && ($3 <= 255) && ($4 <= 255)) {                                      if (($1 <= 255) && ($2 <= 255) && ($3 <= 255) && ($4 <= 255)) {
                                         push(@okips,$ip);                                          push(@okips,$ip); 
                                     }                                      }
                                 }                                  }
                             }                              }
                             if (@okips > 0) {                              if (@okips > 0) {
                                 $new = join(',',@okips);                                  $new = join(',',@okips); 
                             } else {                              } else {
                                 $new = '';                                  $new = ''; 
                             }                              }
                         }                          }
   
Line 3518  sub modify_login { Line 3884  sub modify_login {
                                 $new = '/';                                  $new = '/';
                             }                              }
                         }                          }
                         if (($item eq 'custompath') &&                          if (($item eq 'custompath') && 
                             ($env{'form.'.$lonhost.'_serverpath'} ne 'custom')) {                              ($env{'form.'.$lonhost.'_serverpath'} ne 'custom')) {
                             $new = '';                              $new = '';
                         }                          }
Line 3560  sub modify_login { Line 3926  sub modify_login {
                     }                      }
                 }                  }
             }              }
             if (($domconfig{'login'}{'loginheader'} eq 'text') &&   
                 ($env{'form.loginheader'} eq 'image')) {  
                 $changes{'loginheader'} = 1;  
             } elsif (($domconfig{'login'}{'loginheader'} eq '' ||  
                       $domconfig{'login'}{'loginheader'} eq 'image') &&  
                      ($env{'form.loginheader'} eq 'text')) {  
                 $changes{'loginheader'} = 1;  
             }  
         }          }
         if (keys(%changes) > 0 || $colchgtext) {          if (keys(%changes) > 0 || $colchgtext) {
             &Apache::loncommon::devalidate_domconfig_cache($dom);              &Apache::loncommon::devalidate_domconfig_cache($dom);
             $resulttext = &mt('Changes made:').'<ul>';              $resulttext = &mt('Changes made:').'<ul>';
             foreach my $item (sort(keys(%changes))) {              foreach my $item (sort(keys(%changes))) {
                 if ($item eq 'loginheader') {                  if ($item eq 'loginvia') {
                     $resulttext .= '<li>'.&mt("$title{$item} set to $env{'form.loginheader'}").'</li>';  
                 } elsif ($item eq 'loginvia') {  
                     if (ref($changes{$item}) eq 'HASH') {                      if (ref($changes{$item}) eq 'HASH') {
                         $resulttext .= '<li>'.&mt('Log-in page availability:').'<ul>';                          $resulttext .= '<li>'.&mt('Log-in page availability:').'<ul>';
                         foreach my $lonhost (sort(keys(%{$changes{$item}}))) {                          foreach my $lonhost (sort(keys(%{$changes{$item}}))) {
Line 3588  sub modify_login { Line 3944  sub modify_login {
                                     if ($loginhash{login}{loginvia}{$lonhost}{'serverpath'} eq 'custom') {                                      if ($loginhash{login}{loginvia}{$lonhost}{'serverpath'} eq 'custom') {
                                         $target .= $loginhash{login}{loginvia}{$lonhost}{'custompath'};                                          $target .= $loginhash{login}{loginvia}{$lonhost}{'custompath'};
                                     } else {                                      } else {
                                         $target .= $loginhash{login}{loginvia}{$lonhost}{'serverpath'};                                          $target .= $loginhash{login}{loginvia}{$lonhost}{'serverpath'}; 
                                     }                                      }
                                     $resulttext .= '<li>'.&mt('Server: [_1] log-in page redirects to [_2].',$servers{$lonhost},'<a href="'.$target.'">'.$target.'</a>');                                      $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 '') {                                      if ($loginhash{login}{loginvia}{$lonhost}{'exempt'} ne '') {
Line 3631  sub color_font_choices { Line 3987  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 3688  sub modify_colors { Line 4045  sub modify_colors {
             @logintext = ('textcol','bgcol');              @logintext = ('textcol','bgcol');
         } else {          } else {
             %choices = &color_font_choices();              %choices = &color_font_choices();
               $confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'};
         }          }
         if ($role eq 'login') {          if ($role eq 'login') {
             @images = ('img','logo','domlogo','login');              @images = ('img','logo','domlogo','login');
Line 3810  sub modify_colors { Line 4168  sub modify_colors {
                         $changes{$role}{'font'} = 1;                          $changes{$role}{'font'} = 1;
                     }                      }
                 }                  }
                   if ($role ne 'login') {
                       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 4113  $env{'user.name'}.':'.$env{'user.domain' Line 4482  $env{'user.name'}.':'.$env{'user.domain'
             if (copy($source,$copyfile)) {              if (copy($source,$copyfile)) {
                 print $logfile "\nCopied original source to ".$copyfile."\n";                  print $logfile "\nCopied original source to ".$copyfile."\n";
                 $output = 'ok';                  $output = 'ok';
                 &write_metadata($dom,$confname,$formname,$targetdir,$file,$logfile);  
                 $logourl = '/res/'.$dom.'/'.$confname.'/'.$fname;                  $logourl = '/res/'.$dom.'/'.$confname.'/'.$fname;
                   push(@{$modified_urls},[$copyfile,$source]);
                   my $metaoutput =
                       &write_metadata($dom,$confname,$formname,$targetdir,$file,$logfile);
                   unless ($registered_cleanup) {
                       my $handlers = $r->get_handlers('PerlCleanupHandler');
                       $r->set_handlers('PerlCleanupHandler' => [\&notifysubscribed,@{$handlers}]);
                       $registered_cleanup=1;
                   }
             } else {              } else {
                 print $logfile "\nUnable to write ".$copyfile.':'.$!."\n";                  print $logfile "\nUnable to write ".$copyfile.':'.$!."\n";
                 $output = &mt('Failed to copy file to RES space').", $!";                  $output = &mt('Failed to copy file to RES space').", $!";
Line 4132  $env{'user.name'}.':'.$env{'user.domain' Line 4508  $env{'user.name'}.':'.$env{'user.domain'
                             my $copyfile=$targetdir.'/tn-'.$file;                              my $copyfile=$targetdir.'/tn-'.$file;
                             if (copy($outfile,$copyfile)) {                              if (copy($outfile,$copyfile)) {
                                 print $logfile "\nCopied source to ".$copyfile."\n";                                  print $logfile "\nCopied source to ".$copyfile."\n";
                                 &write_metadata($dom,$confname,$formname,                                  my $thumb_metaoutput =
                                                 $targetdir,'tn-'.$file,$logfile);                                      &write_metadata($dom,$confname,$formname,
                                                       $targetdir,'tn-'.$file,$logfile);
                                   push(@{$modified_urls},[$copyfile,$outfile]);
                                   unless ($registered_cleanup) {
                                       my $handlers = $r->get_handlers('PerlCleanupHandler');
                                       $r->set_handlers('PerlCleanupHandler' => [\&notifysubscribed,@{$handlers}]);
                                       $registered_cleanup=1;
                                   }
                             } else {                              } else {
                                 print $logfile "\nUnable to write ".$copyfile.                                  print $logfile "\nUnable to write ".$copyfile.
                                                ':'.$!."\n";                                                 ':'.$!."\n";
Line 4198  sub write_metadata { Line 4581  sub write_metadata {
     {      {
         print $logfile "\nWrite metadata file for ".$targetdir.'/'.$file;          print $logfile "\nWrite metadata file for ".$targetdir.'/'.$file;
         my $mfh;          my $mfh;
         unless (open($mfh,'>'.$targetdir.'/'.$file.'.meta')) {          if (open($mfh,'>'.$targetdir.'/'.$file.'.meta')) {
               foreach (sort keys %metadatafields) {
                   unless ($_=~/\./) {
                       my $unikey=$_;
                       $unikey=~/^([A-Za-z]+)/;
                       my $tag=$1;
                       $tag=~tr/A-Z/a-z/;
                       print $mfh "\n\<$tag";
                       foreach (split(/\,/,$metadatakeys{$unikey})) {
                           my $value=$metadatafields{$unikey.'.'.$_};
                           $value=~s/\"/\'\'/g;
                           print $mfh ' '.$_.'="'.$value.'"';
                       }
                       print $mfh '>'.
                           &HTML::Entities::encode($metadatafields{$unikey},'<>&"')
                               .'</'.$tag.'>';
                   }
               }
               $output = 'ok';
               print $logfile "\nWrote metadata";
               close($mfh);
           } else {
               print $logfile "\nFailed to open metadata file";
             $output = &mt('Could not write metadata');              $output = &mt('Could not write metadata');
         }          }
         foreach (sort keys %metadatafields) {  
             unless ($_=~/\./) {  
                 my $unikey=$_;  
                 $unikey=~/^([A-Za-z]+)/;  
                 my $tag=$1;  
                 $tag=~tr/A-Z/a-z/;  
                 print $mfh "\n\<$tag";  
                 foreach (split(/\,/,$metadatakeys{$unikey})) {  
                     my $value=$metadatafields{$unikey.'.'.$_};  
                     $value=~s/\"/\'\'/g;  
                     print $mfh ' '.$_.'="'.$value.'"';  
                 }  
                 print $mfh '>'.  
                     &HTML::Entities::encode($metadatafields{$unikey},'<>&"')  
                         .'</'.$tag.'>';  
             }  
         }  
         $output = 'ok';  
         print $logfile "\nWrote metadata";  
         close($mfh);  
     }      }
       return $output;
   }
   
   sub notifysubscribed {
       foreach my $targetsource (@{$modified_urls}){
           next unless (ref($targetsource) eq 'ARRAY');
           my ($target,$source)=@{$targetsource};
           if ($source ne '') {
               if (open(my $logfh,'>>'.$source.'.log')) {
                   print $logfh "\nCleanup phase: Notifications\n";
                   my @subscribed=&subscribed_hosts($target);
                   foreach my $subhost (@subscribed) {
                       print $logfh "\nNotifying host ".$subhost.':';
                       my $reply=&Apache::lonnet::critical('update:'.$target,$subhost);
                       print $logfh $reply;
                   }
                   my @subscribedmeta=&subscribed_hosts("$target.meta");
                   foreach my $subhost (@subscribedmeta) {
                       print $logfh "\nNotifying host for metadata only ".$subhost.':';
                       my $reply=&Apache::lonnet::critical('update:'.$target.'.meta',
                                                           $subhost);
                       print $logfh $reply;
                   }
                   print $logfh "\n============ Done ============\n";
                   close(logfh);
               }
           }
       }
       return OK;
   }
   
   sub subscribed_hosts {
       my ($target) = @_;
       my @subscribed;
       if (open(my $fh,"<$target.subscription")) {
           while (my $subline=<$fh>) {
               if ($subline =~ /^($match_lonid):/) {
                   my $host = $1;
                   if ($host ne $Apache::lonnet::perlvar{'lonHostID'}) {
                       unless (grep(/^\Q$host\E$/,@subscribed)) {
                           push(@subscribed,$host);
                       }
                   }
               }
           }
       }
       return @subscribed;
 }  }
   
 sub check_switchserver {  sub check_switchserver {
Line 4291  sub modify_quotas { Line 4723  sub modify_quotas {
                     $changes{'notify'}{'approval'} = 1;                      $changes{'notify'}{'approval'} = 1;
                 }                  }
             } else {              } else {
                 if ($domconfig{$action}{'notify'}{'approval'}) {                  if ($confhash{'notify'}{'approval'}) {
                     $changes{'notify'}{'approval'} = 1;                      $changes{'notify'}{'approval'} = 1;
                 }                  }
             }              }
         } else {          } else {
             if ($domconfig{$action}{'notify'}{'approval'}) {              if ($confhash{'notify'}{'approval'}) {
                 $changes{'notify'}{'approval'} = 1;                  $changes{'notify'}{'approval'} = 1;
             }              }
         }          }
Line 4305  sub modify_quotas { Line 4737  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;              my $unset; 
             if ($context eq 'requestcourses') {              if ($context eq 'requestcourses') {
                 $unset = '0';                  $unset = '0';
                 if ($type eq '_LC_adv') {                  if ($type eq '_LC_adv') {
Line 4537  sub modify_autoenroll { Line 4969  sub modify_autoenroll {
     }      }
     my $coowners = $env{'form.autoassign_coowners'};      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,                                         'co-owners' => $coowners,
                                 }                                  }
                      );                       );
Line 4567  sub modify_autoenroll { Line 4999  sub modify_autoenroll {
             }              }
         } elsif ($coowners) {          } elsif ($coowners) {
             $changes{'coowners'} = 1;              $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 4617  sub modify_autoupdate { Line 5049  sub modify_autoupdate {
                         middlename => 'Middle Name',                          middlename => 'Middle Name',
                         generation => 'Generation',                          generation => 'Generation',
                       );                        );
     my $othertitle = &mt('All users');      $othertitle = &mt('All users');
     if (keys(%{$usertypes}) >  0) {      if (keys(%{$usertypes}) >  0) {
         $othertitle = &mt('Other users');          $othertitle = &mt('Other users');
     }      }
Line 4625  sub modify_autoupdate { Line 5057  sub modify_autoupdate {
         if ($key =~ /^form\.updateable_(.+)_([^_]+)$/) {          if ($key =~ /^form\.updateable_(.+)_([^_]+)$/) {
             my ($usertype,$item) = ($1,$2);              my ($usertype,$item) = ($1,$2);
             if (grep(/^\Q$item\E$/,keys(%fieldtitles))) {              if (grep(/^\Q$item\E$/,keys(%fieldtitles))) {
                 if ($usertype eq 'default') {                  if ($usertype eq 'default') {   
                     push(@{$fields{$1}},$2);                      push(@{$fields{$1}},$2);
                 } elsif (ref($types) eq 'ARRAY') {                  } elsif (ref($types) eq 'ARRAY') {
                     if (grep(/^\Q$usertype\E$/,@{$types})) {                      if (grep(/^\Q$usertype\E$/,@{$types})) {
Line 4802  sub modify_autocreate { Line 5234  sub modify_autocreate {
     my %domcoords = &get_active_dcs($dom);      my %domcoords = &get_active_dcs($dom);
     unless (exists($domcoords{$newvals{'xmldc'}})) {      unless (exists($domcoords{$newvals{'xmldc'}})) {
         $newvals{'xmldc'} = '';          $newvals{'xmldc'} = '';
     }      } 
     %autocreatehash =  (      %autocreatehash =  (
                         autocreate => { xml => $newvals{'xml'},                          autocreate => { xml => $newvals{'xml'},
                                         req => $newvals{'req'},                                          req => $newvals{'req'},
Line 4828  sub modify_autocreate { Line 5260  sub modify_autocreate {
             }              }
         }          }
         if (keys(%changes) > 0) {          if (keys(%changes) > 0) {
             my @offon = ('off','on');              my @offon = ('off','on'); 
             $resulttext = &mt('Changes made:').'<ul>';              $resulttext = &mt('Changes made:').'<ul>';
             foreach my $item (@types) {              foreach my $item (@types) {
                 if ($changes{$item}) {                  if ($changes{$item}) {
Line 4839  sub modify_autocreate { Line 5271  sub modify_autocreate {
             if ($changes{'xmldc'}) {              if ($changes{'xmldc'}) {
                 my ($dcname,$dcdom) = split(':',$newvals{'xmldc'});                  my ($dcname,$dcdom) = split(':',$newvals{'xmldc'});
                 my $newtxt = &Apache::loncommon::plainname($dcname,$dcdom);                  my $newtxt = &Apache::loncommon::plainname($dcname,$dcdom);
                 $resulttext .= '<li>'.&mt("$title{'xmldc'} set to [_1]$newtxt [_2]",'<b>','</b>').'</li>';                  $resulttext .= '<li>'.&mt("$title{'xmldc'} set to [_1]$newtxt [_2]",'<b>','</b>').'</li>'; 
             }              }
             $resulttext .= '</ul>';              $resulttext .= '</ul>';
         } else {          } else {
Line 5078  sub modify_contacts { Line 5510  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 ($type eq 'helpdeskmail') {   
                 if ($bcc{$type} ne $currsetting{$type}{'bcc'}) {                  if ($bcc{$type} ne $currsetting{$type}{'bcc'}) {
                     push(@{$changes{$type}},'bcc');                      push(@{$changes{$type}},'bcc'); 
                 }                  }
             }              }
         }          }
Line 5661  sub modify_defaults { Line 6093  sub modify_defaults {
     my ($dom,$r) = @_;      my ($dom,$r) = @_;
     my ($resulttext,$mailmsgtxt,%newvalues,%changes,@errors);      my ($resulttext,$mailmsgtxt,%newvalues,%changes,@errors);
     my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);      my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
     my @items = ('auth_def','auth_arg_def','lang_def','timezone_def','datelocale_def');      my @items = ('auth_def','auth_arg_def','lang_def','timezone_def','datelocale_def','portal_def');
     my @authtypes = ('internal','krb4','krb5','localauth');      my @authtypes = ('internal','krb4','krb5','localauth');
     foreach my $item (@items) {      foreach my $item (@items) {
         $newvalues{$item} = $env{'form.'.$item};          $newvalues{$item} = $env{'form.'.$item};
Line 5697  sub modify_defaults { Line 6129  sub modify_defaults {
                     push(@errors,$item);                      push(@errors,$item);
                 }                  }
             }              }
           } elsif ($item eq 'portal_def') {
               if ($newvalues{$item} ne '') {
                   unless ($newvalues{$item} =~ /^https?\:\/\/(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])\/?$/) {
                       push(@errors,$item);
                   }
               }
         }          }
         if (grep(/^\Q$item\E$/,@errors)) {          if (grep(/^\Q$item\E$/,@errors)) {
             $newvalues{$item} = $domdefaults{$item};              $newvalues{$item} = $domdefaults{$item};
Line 6113  sub modify_serverstatuses { Line 6551  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 6186  sub modify_serverstatuses { Line 6623  sub modify_serverstatuses {
     return $resulttext;      return $resulttext;
 }  }
   
   sub modify_helpsettings {
       my ($r,$dom,$confname,%domconfig) = @_;
     my ($resulttext,$errors,%changes,%helphash);
    
     my $customhelpfile  = $env{'form.loginhelpurl.filename'};
       my $defaulthelpfile = 'defaulthelp.html';
     my $servadm = $r->dir_config('lonAdmEMail');
       my ($configuserok,$author_ok,$switchserver) = 
           &config_check($dom,$confname,$servadm);
    
     my %defaultchecked = ('submitbugs' => 'on');
     my @offon = ('off','on');
       my %title = ( submitbugs     => 'Display link for users to submit a bug', 
        loginhelpurl  => 'Unauthenticated login help page set to custom file');
        
       my @toggles = ('submitbugs');
   
       $helphash{'helpsettings'} = {};
       
       if (ref($domconfig{'helpsettings'}) ne 'HASH') {
           if ($domconfig{'helpsettings'} eq '') {
               $domconfig{'helpsettings'} = {};
           }
       }
       
       if (ref($domconfig{'helpsettings'}) eq 'HASH') {
      
           foreach my $item (@toggles) {
          
    if ($defaultchecked{$item} eq 'on') { 
    if (($domconfig{'helpsettings'}{$item} eq '') &&
    ($env{'form.'.$item} eq '0')) {
    $changes{$item} = 1;
    } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
    $changes{$item} = 1;
    }
    } elsif ($defaultchecked{$item} eq 'off') {
    if (($domconfig{'helpsettings'}{$item} eq '') &&
    ($env{'form.'.$item} eq '1')) {
    $changes{$item} = 1;
    } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
    $changes{$item} = 1;
    }
    }
    $helphash{'helpsettings'}{$item} = $env{'form.'.$item};
    }
   
    if ($customhelpfile ne '') {
    my $error;
    if ($configuserok eq 'ok') {
    if ($switchserver) {
    $error = &mt("Upload of custom help file is not permitted to this server: [_1]",$switchserver);
    } else {
    if ($author_ok eq 'ok') {
    my ($result,$loginhelpurl) =
    &publishlogo($r,'upload','loginhelpurl',$dom,
    $confname,'help','','',$customhelpfile);
    if ($result eq 'ok') {
    $helphash{'helpsettings'}{'loginhelpurl'} = $loginhelpurl;
    $changes{'loginhelpurl'} = 1;
    } else {
    $error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$customhelpfile,$result);
    }
    } else {
    $error = &mt("Upload of [_1] failed because an author role could not be assigned to a Domain Configuration user ([_2]) in domain: [_3].  Error was: [_4].",$customhelpfile,$confname,$dom,$author_ok);
    }
    }
    } else {
    $error = &mt("Upload of [_1] failed because a Domain Configuration user ([_2]) could not be created in domain: [_3].  Error was: [_4].",$customhelpfile,$confname,$dom,$configuserok);
    }
    if ($error) {
    &Apache::lonnet::logthis($error);
    $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
    }
    }
   
           if ($domconfig{'helpsettings'}{'loginhelpurl'} ne '') {
               if ($env{'form.loginhelpurl_del'}) {
                   $helphash{'helpsettings'}{'loginhelpurl'} = '';
                   $changes{'loginhelpurl'} = 1;
               }
           }
       }
       
       
       my $putresult;
       
       if (keys(%changes) > 0) {
       $putresult = &Apache::lonnet::put_dom('configuration',\%helphash,$dom);
       } else {
       $putresult = 'ok';
       }
                                                
       if ($putresult eq 'ok') {
           if (keys(%changes) > 0) {
    $resulttext = &mt('Changes made:').'<ul>';
    foreach my $item (sort(keys(%changes))) {
    if ($item eq 'submitbugs') {
    $resulttext .= '<li>'.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'</li>';
    }
    if ($item eq 'loginhelpurl') {
    if ($helphash{'helpsettings'}{'loginhelpurl'} eq '') {
                           $resulttext .= '<li>'.&mt('[_1] help file removed; [_2] file will be used for the unathorized help page in this domain.',$customhelpfile,$defaulthelpfile).'</li>';
                       } else {
                           $resulttext .= '<li>'.&mt("$title{$item} [_1]",$customhelpfile).'</li>';
                       }
    }
    }
    $resulttext .= '</ul>';
    } else {
    $resulttext = &mt('No changes made to help settings');
    }
       } else {
           $resulttext = '<span class="LC_error">'.
       &mt('An error occurred: [_1]',$putresult).'</span>';
       }
       if ($errors) {
           $resulttext .= &mt('The following errors occurred: ').'<ul>'.
                          $errors.'</ul>';
       }
       return $resulttext;
   }
   
 sub modify_coursedefaults {  sub modify_coursedefaults {
     my ($dom,%domconfig) = @_;      my ($dom,%domconfig) = @_;
     my ($resulttext,$errors,%changes,%defaultshash);      my ($resulttext,$errors,%changes,%defaultshash);
     my %defaultchecked = ('canuse_pdfforms' => 'off');      my %defaultchecked = ('canuse_pdfforms' => 'off');
     my @offon = ('off','on');      my @offon = ('off','on');
     my @toggles = ('canuse_pdfforms');      my @toggles = ();
   
     $defaultshash{'coursedefaults'} = {};      $defaultshash{'coursedefaults'} = {};
   
Line 6220  sub modify_coursedefaults { Line 6780  sub modify_coursedefaults {
             }              }
             $defaultshash{'coursedefaults'}{$item} = $env{'form.'.$item};              $defaultshash{'coursedefaults'}{$item} = $env{'form.'.$item};
         }          }
           my $currdefresponder = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
           my $newdefresponder = $env{'form.anonsurvey_threshold'};
           $newdefresponder =~ s/\D//g;
           if ($newdefresponder eq '' || $newdefresponder < 1) {
               $newdefresponder = 1;
           }
           $defaultshash{'coursedefaults'}{'anonsurvey_threshold'} = $newdefresponder;
           if ($currdefresponder ne $newdefresponder) {
               unless ($currdefresponder eq '' && $newdefresponder == 10) {
                   $changes{'anonsurvey_threshold'} = 1;
               }
           }
     }      }
     my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,      my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
                                              $dom);                                               $dom);
Line 6239  sub modify_coursedefaults { Line 6811  sub modify_coursedefaults {
                     } else {                      } else {
                         $resulttext .= '<li>'.&mt('Course/Community users can create/upload PDF forms set to "off"').'</li>';                          $resulttext .= '<li>'.&mt('Course/Community users can create/upload PDF forms set to "off"').'</li>';
                     }                      }
                   } elsif ($item eq 'anonsurvey_threshold') {
                           $resulttext .= '<li>'.&mt('Responder count required for display of anonymous survey submissions set to [_1].',$defaultshash{'coursedefaults'}{'anonsurvey_threshold'}).'</li>';
                 }                  }
             }              }
             $resulttext .= '</ul>';              $resulttext .= '</ul>';
Line 6252  sub modify_coursedefaults { Line 6826  sub modify_coursedefaults {
     return $resulttext;      return $resulttext;
 }  }
   
   sub modify_usersessions {
       my ($dom,%domconfig) = @_;
       my @types = ('version','excludedomain','includedomain');
       my @prefixes = ('remote','hosted');
       my @lcversions = &Apache::lonnet::all_loncaparevs();
       my (%by_ip,%by_location,@intdoms);
       &build_location_hashes(\@intdoms,\%by_ip,\%by_location);
       my @locations = sort(keys(%by_location));
       my (%defaultshash,%changes);
       foreach my $prefix (@prefixes) {
           $defaultshash{'usersessions'}{$prefix} = {};
       }
       my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
       my $resulttext;
       my %iphost = &Apache::lonnet::get_iphost();
       foreach my $prefix (@prefixes) {
           foreach my $type (@types) {
               my $inuse = $env{'form.'.$prefix.'_'.$type.'_inuse'};
               if ($type eq 'version') {
                   my $value = $env{'form.'.$prefix.'_'.$type};
                   my $okvalue;
                   if ($value ne '') {
                       if (grep(/^\Q$value\E$/,@lcversions)) {
                           $okvalue = $value;
                       }
                   }
                   if (ref($domconfig{'usersessions'}) eq 'HASH') {
                       if (ref($domconfig{'usersessions'}{$prefix}) eq 'HASH') {
                           if ($domconfig{'usersessions'}{$prefix}{$type} ne '') {
                               if ($inuse == 0) {
                                   $changes{$prefix}{$type} = 1;
                               } else {
                                   if ($okvalue ne $domconfig{'usersessions'}{$prefix}{$type}) {
                                       $changes{$prefix}{$type} = 1;
                                   }
                                   if ($okvalue ne '') {
                                       $defaultshash{'usersessions'}{$prefix}{$type} = $okvalue;
                                   } 
                               }
                           } else {
                               if (($inuse == 1) && ($okvalue ne '')) {
                                   $defaultshash{'usersessions'}{$prefix}{$type} = $okvalue;
                                   $changes{$prefix}{$type} = 1;
                               }
                           }
                       } else {
                           if (($inuse == 1) && ($okvalue ne '')) {
                               $defaultshash{'usersessions'}{$prefix}{$type} = $okvalue;
                               $changes{$prefix}{$type} = 1;
                           }
                       }
                   } else {
                       if (($inuse == 1) && ($okvalue ne '')) {
                           $defaultshash{'usersessions'}{$prefix}{$type} = $okvalue;
                           $changes{$prefix}{$type} = 1;
                       }
                   }
               } else {
                   my @vals = &Apache::loncommon::get_env_multiple('form.'.$prefix.'_'.$type);
                   my @okvals;
                   foreach my $val (@vals) {
                       if ($val =~ /:/) {
                           my @items = split(/:/,$val);
                           foreach my $item (@items) {
                               if (ref($by_location{$item}) eq 'ARRAY') {
                                   push(@okvals,$item);
                               }
                           }
                       } else {
                           if (ref($by_location{$val}) eq 'ARRAY') {
                               push(@okvals,$val);
                           }
                       }
                   }
                   @okvals = sort(@okvals);
                   if (ref($domconfig{'usersessions'}) eq 'HASH') {
                       if (ref($domconfig{'usersessions'}{$prefix}) eq 'HASH') {
                           if (ref($domconfig{'usersessions'}{$prefix}{$type}) eq 'ARRAY') {
                               if ($inuse == 0) {
                                   $changes{$prefix}{$type} = 1; 
                               } else {
                                   $defaultshash{'usersessions'}{$prefix}{$type} = \@okvals;
                                   my @changed = &Apache::loncommon::compare_arrays($domconfig{'usersessions'}{$prefix}{$type},$defaultshash{'usersessions'}{$prefix}{$type});
                                   if (@changed > 0) {
                                       $changes{$prefix}{$type} = 1;
                                   }
                               }
                           } else {
                               if ($inuse == 1) {
                                   $defaultshash{'usersessions'}{$prefix}{$type} = \@okvals;
                                   $changes{$prefix}{$type} = 1;
                               }
                           } 
                       } else {
                           if ($inuse == 1) {
                               $defaultshash{'usersessions'}{$prefix}{$type} = \@okvals;
                               $changes{$prefix}{$type} = 1;
                           }
                       }
                   } else {
                       if ($inuse == 1) {
                           $defaultshash{'usersessions'}{$prefix}{$type} = \@okvals;
                           $changes{$prefix}{$type} = 1;
                       }
                   }
               }
           }
       }
       if (keys(%changes) > 0) {
           my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
                                                    $dom);
           if ($putresult eq 'ok') {
               if (ref($defaultshash{'usersessions'}) eq 'HASH') {
                   if (ref($defaultshash{'usersessions'}{'remote'}) eq 'HASH') {
                       $domdefaults{'remotesessions'} = $defaultshash{'usersessions'}{'remote'};
                   }
                   if (ref($defaultshash{'usersessions'}{'hosted'}) eq 'HASH') {
                       $domdefaults{'hostedsessions'} = $defaultshash{'usersessions'}{'hosted'};
                   }
               }
               my $cachetime = 24*60*60;
               &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
               my %lt = &usersession_titles();
               $resulttext = &mt('Changes made:').'<ul>';
               foreach my $prefix (@prefixes) {
                   if (ref($changes{$prefix}) eq 'HASH') {
                       $resulttext .= '<li>'.$lt{$prefix}.'<ul>';
                       foreach my $type (@types) {
                           if (defined($changes{$prefix}{$type})) {
                               my $newvalue;
                               if (ref($defaultshash{'usersessions'}) eq 'HASH') {
                                   if (ref($defaultshash{'usersessions'}{$prefix})) {
                                       if ($type eq 'version') {
                                           $newvalue = $defaultshash{'usersessions'}{$prefix}{$type};
                                       } elsif (ref($defaultshash{'usersessions'}{$prefix}{$type}) eq 'ARRAY') {
                                           if (@{$defaultshash{'usersessions'}{$prefix}{$type}} > 0) {
                                               $newvalue = join(', ',@{$defaultshash{'usersessions'}{$prefix}{$type}});
                                           }
                                       }
                                   }
                               }
                               if ($newvalue eq '') {
                                   if ($type eq 'version') {
                                       $resulttext .= '<li>'.&mt('[_1] set to: off',$lt{$type}).'</li>';
                                   } else {
                                       $resulttext .= '<li>'.&mt('[_1] set to: none',$lt{$type}).'</li>';
                                   }
                               } else {
                                   if ($type eq 'version') {
                                       $newvalue .= ' '.&mt('(or later)'); 
                                   } 
                                   $resulttext .= '<li>'.&mt('[_1] set to: [_2].',$lt{$type},$newvalue).'</li>'; 
                               }
                           }
                       }
                       $resulttext .= '</ul>';
                   }
               }
               $resulttext .= '</ul>';
           } else {
               $resulttext = '<span class="LC_error">'.
                             &mt('An error occurred: [_1]',$putresult).'</span>';
           }
       } else {
           $resulttext =  &mt('No changes made to settings for user session hosting.');
       }
       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 6347  sub get_active_dcs { Line 7090  sub get_active_dcs {
   
 sub active_dc_picker {  sub active_dc_picker {
     my ($dom,$curr_dc) = @_;      my ($dom,$curr_dc) = @_;
     my %domcoords = &get_active_dcs($dom);      my %domcoords = &get_active_dcs($dom); 
     my @dcs = sort(keys(%domcoords));      my @dcs = sort(keys(%domcoords));
     my $numdcs = scalar(@dcs);      my $numdcs = scalar(@dcs); 
     my $datatable;      my $datatable;
     my $numinrow = 2;      my $numinrow = 2;
     if ($numdcs > 1) {      if ($numdcs > 1) {
Line 6364  sub active_dc_picker { Line 7107  sub active_dc_picker {
             }              }
             my $check = ' ';              my $check = ' ';
             if ($curr_dc eq '') {              if ($curr_dc eq '') {
                 if (!$i) {                  if (!$i) { 
                     $check = ' checked="checked" ';                      $check = ' checked="checked" ';
                 }                  }
             } elsif ($dcs[$i] eq $curr_dc) {              } elsif ($dcs[$i] eq $curr_dc) {
Line 6395  sub active_dc_picker { Line 7138  sub active_dc_picker {
     return ($numdcs,$datatable);      return ($numdcs,$datatable);
 }  }
   
   sub usersession_titles {
       return &Apache::lonlocal::texthash(
                  hosted => 'Hosting of sessions for users from other domains on servers in this domain',
   
                  remote => 'Hosting of sessions for users in this domain on servers in other domains',
                  version => 'LON-CAPA version requirement',
                  excludedomain => 'Allow all, but exclude specific domains',
                  includedomain => 'Deny all, but include specific domains',
              );
   }
   
 1;  1;

Removed from v.1.102.2.15  
changed lines
  Added in v.1.138.2.11


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