Diff for /loncom/interface/domainprefs.pm between versions 1.115 and 1.119

version 1.115, 2009/10/21 14:06:11 version 1.119, 2009/11/16 04:03:05
Line 202  sub handler { Line 202  sub handler {
                 'quotas','autoenroll','autoupdate','directorysrch',                  'quotas','autoenroll','autoupdate','directorysrch',
                 'usercreation','usermodification','contacts','defaults',                  'usercreation','usermodification','contacts','defaults',
                 'scantron','coursecategories','serverstatuses',                  'scantron','coursecategories','serverstatuses',
                 'requestcourses'],$dom);                  'requestcourses','helpsettings'],$dom);
     my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',      my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
                        'autoupdate','directorysrch','contacts',                         'autoupdate','directorysrch','contacts',
                        'usercreation','usermodification','scantron',                         'usercreation','usermodification','scantron',
                        'requestcourses','coursecategories','serverstatuses');                         'requestcourses','coursecategories','serverstatuses','helpsettings');
     my %prefs = (      my %prefs = (
         'rolecolors' =>          'rolecolors' =>
                    { text => 'Default color schemes',                     { text => 'Default color schemes',
Line 319  sub handler { Line 319  sub handler {
                               col3 => 'Specific IPs',                                col3 => 'Specific IPs',
                             }],                              }],
                  },                   },
           'helpsettings' =>
                    {text   => 'Help page settings',
                     help   => 'Domain_Configuration_Help_Settings',
                     header => [{col1 => 'Setting',
                                 col2 => 'Value',}],
                    },
     );      );
     my %servers = &Apache::lonnet::get_servers($dom);      my %servers = &dom_servers($dom);
     if (keys(%servers) > 1) {      if (keys(%servers) > 1) {
         $prefs{'login'}  = { text   => 'Log-in page options',          $prefs{'login'}  = { text   => 'Log-in page options',
                              help   => 'Domain_Configuration_Login_Page',                               help   => 'Domain_Configuration_Login_Page',
Line 415  sub process_changes { Line 421  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 'helpsettings') {
           $output = &modify_helpsettings($dom,%domconfig);
     }      }
     return $output;      return $output;
 }  }
Line 465  sub print_config_box { Line 473  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);
           } elsif ($action eq 'helpsettings') {
               $output .= &print_helpsettings($dom,$settings,\$rowtotal);
         } else {          } else {
             $output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);              $output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
         }          }
Line 600  sub print_config_box { Line 610  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 'helpsettings') {
           $output .= &print_helpsettings($dom,$settings,\$rowtotal);
       }
     }      }
     $output .= '      $output .= '
    </table>     </table>
Line 617  sub print_login { Line 629  sub print_login {
     my $itemcount = 1;      my $itemcount = 1;
   
     if ($position eq 'top') {      if ($position eq 'top') {
         my %servers = &Apache::lonnet::get_servers($dom);          my %servers = &dom_servers($dom);
         my $choice = $choices{'disallowlogin'};          my $choice = $choices{'disallowlogin'};
         $css_class = ' class="LC_odd_row"';          $css_class = ' class="LC_odd_row"';
         $datatable .= '<tr'.$css_class.'><td>'.$choices{'disallowlogin'}.'</td>'.          $datatable .= '<tr'.$css_class.'><td>'.$choices{'disallowlogin'}.'</td>'.
Line 657  sub print_login { Line 669  sub print_login {
                            'coursecatalog' => 'on',                             'coursecatalog' => 'on',
                            'adminmail'     => 'off',                             'adminmail'     => 'off',
                            'newuser'       => 'off',                             'newuser'       => 'off',
                            'submitbugs'   => 'on',  
                          );                           );
     my @toggles = ('coursecatalog','adminmail','newuser','submitbugs');      my @toggles = ('coursecatalog','adminmail','newuser');
     my (%checkedon,%checkedoff);      my (%checkedon,%checkedoff);
     foreach my $item (@toggles) {      foreach my $item (@toggles) {
         if ($defaultchecked{$item} eq 'on') {           if ($defaultchecked{$item} eq 'on') { 
Line 788  sub print_login { Line 799  sub print_login {
 sub login_choices {  sub login_choices {
     my %choices =      my %choices =
         &Apache::lonlocal::texthash (          &Apache::lonlocal::texthash (
             coursecatalog => 'Display Course 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",
             submitbugs    => "Display &quot;Submit Bug&quot; link?",  
             hostid        => "Server",              hostid        => "Server",
             serverurl     => "Redirect to log-in via:",              serverurl     => "Redirect to log-in via:",
             directlogin   => "No redirect",              directlogin   => "No redirect",
Line 1918  sub print_contacts { Line 1928  sub print_contacts {
     return $datatable;      return $datatable;
 }  }
   
   sub print_helpsettings {
   
    my ($dom,$settings,$rowtotal) = @_;
    my ($css_class,$datatable);
    my $itemcount = 1;
    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 class="LC_right_item"><span class="LC_nobreak">'.
               '<label><input type="radio" name="'.
               $item.'" '.$checkedon{$item}.' value="1" />'.&mt('Yes').
               '</label>&nbsp;<label><input type="radio" name="'.$item.'" '.
               $checkedoff{$item}.' value="0" />'.&mt('No').'</label>'.
               '</span></td>'.
               '</tr>';
           $itemcount ++;
        }
        return $datatable;
   
   }
   
 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 3139  sub modify_login { Line 3205  sub modify_login {
     my %title = ( coursecatalog => 'Display course catalog',      my %title = ( coursecatalog => 'Display course catalog',
                   adminmail => 'Display administrator E-mail address',                    adminmail => 'Display administrator E-mail address',
                   newuser => 'Link for visitors to create a user account',                    newuser => 'Link for visitors to create a user account',
                   submitbugs => 'Link for users to submit a bug',  
                   loginheader => 'Log-in box header');                    loginheader => 'Log-in box header');
     my @offon = ('off','on');      my @offon = ('off','on');
     my %curr_loginvia;      my %curr_loginvia;
Line 3153  sub modify_login { Line 3218  sub modify_login {
     my %loginhash;      my %loginhash;
     ($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],      ($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
                                            \%domconfig,\%loginhash);                                             \%domconfig,\%loginhash);
     my @toggles = ('coursecatalog','adminmail','newuser','submitbugs');      my @toggles = ('coursecatalog','adminmail','newuser');
     foreach my $item (@toggles) {      foreach my $item (@toggles) {
         $loginhash{login}{$item} = $env{'form.'.$item};          $loginhash{login}{$item} = $env{'form.'.$item};
     }      }
Line 3163  sub modify_login { Line 3228  sub modify_login {
                                          \%loginhash);                                           \%loginhash);
     }      }
   
     my %servers = &Apache::lonnet::get_servers($dom);      my %servers = &dom_servers($dom);
     if (keys(%servers) > 1) {      if (keys(%servers) > 1) {
         foreach my $lonhost (keys(%servers)) {          foreach my $lonhost (keys(%servers)) {
             next if ($env{'form.'.$lonhost.'_serverurl'} eq $curr_loginvia{$lonhost});  
             next if ($env{'form.'.$lonhost.'_serverurl'} eq $lonhost);              next if ($env{'form.'.$lonhost.'_serverurl'} eq $lonhost);
               if ($env{'form.'.$lonhost.'_serverurl'} eq $curr_loginvia{$lonhost}) {
                   $loginhash{login}{loginvia}{$lonhost} = $curr_loginvia{$lonhost};                next;
               }
             if ($curr_loginvia{$lonhost} ne '') {              if ($curr_loginvia{$lonhost} ne '') {
                 $loginhash{login}{loginvia}{$lonhost} = $env{'form.'.$lonhost.'_serverurl'};                  $loginhash{login}{loginvia}{$lonhost} = $env{'form.'.$lonhost.'_serverurl'};
                 $changes{'loginvia'}{$lonhost} = 1;                  $changes{'loginvia'}{$lonhost} = 1;
Line 3179  sub modify_login { Line 3246  sub modify_login {
             }              }
         }          }
     }      }
       
     my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,      my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
                                              $dom);                                               $dom);
     if ($putresult eq 'ok') {      if ($putresult eq 'ok') {
         my @toggles = ('coursecatalog','adminmail','newuser','submitbugs');          my @toggles = ('coursecatalog','adminmail','newuser');
         my %defaultchecked = (          my %defaultchecked = (
                     'coursecatalog' => 'on',                      'coursecatalog' => 'on',
                     'adminmail'     => 'off',                      'adminmail'     => 'off',
                     'newuser'       => 'off',                      'newuser'       => 'off',
                     'submitbugs' => 'on',  
         );          );
         if (ref($domconfig{'login'}) eq 'HASH') {          if (ref($domconfig{'login'}) eq 'HASH') {
             foreach my $item (@toggles) {              foreach my $item (@toggles) {
Line 5626  sub modify_serverstatuses { Line 5692  sub modify_serverstatuses {
     return $resulttext;      return $resulttext;
 }  }
   
   sub modify_helpsettings {
       my ($dom,%domconfig) = @_;
     my ($resulttext,$errors,%changes,%helphash);
    
     my %defaultchecked = ('submitbugs' => 'on');
     my @offon = ('off','on');
       my %title = ( submitbugs => 'Display link for users to submit a bug');
       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};
    }  
       }
       
       my $putresult = &Apache::lonnet::put_dom('configuration',\%helphash,
                                                $dom);
                                                
       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>';
    }
    }
    $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 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 5666  sub recurse_cat_deletes { Line 5798  sub recurse_cat_deletes {
     return;      return;
 }  }
   
   sub dom_servers {
       my ($dom) = @_;
       my (%uniqservers,%servers);
       my $primaryserver = &Apache::lonnet::hostname(&Apache::lonnet::domain($dom,'primary'));
       my @machinedoms = &Apache::lonnet::machine_domains($primaryserver);
       foreach my $mdom (@machinedoms) {
           my %currservers = %servers;
           my %server = &Apache::lonnet::get_servers($mdom);
           %servers = (%currservers,%server);
       }
       my %by_hostname;
       foreach my $id (keys(%servers)) {
           push(@{$by_hostname{$servers{$id}}},$id);
       }
       foreach my $hostname (sort(keys(%by_hostname))) {
           if (@{$by_hostname{$hostname}} > 1) {
               my $match = 0;
               foreach my $id (@{$by_hostname{$hostname}}) {
                   if (&Apache::lonnet::host_domain($id) eq $dom) {
                       $uniqservers{$id} = $hostname;
                       $match = 1;
                   }
               }
               unless ($match) {
                   $uniqservers{$by_hostname{$hostname}[0]} = $hostname;
               }
           } else {
               $uniqservers{$by_hostname{$hostname}[0]} = $hostname;
           }
       }
       return %uniqservers;
   }
   
 1;  1;

Removed from v.1.115  
changed lines
  Added in v.1.119


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