Diff for /loncom/interface/domainprefs.pm between versions 1.164 and 1.166

version 1.164, 2012/08/21 21:12:08 version 1.166, 2012/08/25 21:48:12
Line 353  sub handler { Line 353  sub handler {
         'helpsettings' =>          'helpsettings' =>
                  {text   => 'Help page settings',                   {text   => 'Help page settings',
                   help   => 'Domain_Configuration_Help_Settings',                    help   => 'Domain_Configuration_Help_Settings',
                   header => [{col1 => 'Authenticated Help Settings',                    header => [{col1 => 'Help Settings (logged-in users)',
                               col2 => ''},                                col2 => 'Value'},
                              {col1 => 'Unauthenticated Help Settings',                               {col1 => 'Help Settings (before log-in)',
                               col2 => ''}],                                col2 => 'Value'}],
                  },                   },
         'coursedefaults' =>           'coursedefaults' => 
                  {text => 'Course/Community defaults',                   {text => 'Course/Community defaults',
Line 410  sub handler { Line 410  sub handler {
     if ($phase eq 'process') {      if ($phase eq 'process') {
         &Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,\@roles);          &Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,\@roles);
     } elsif ($phase eq 'display') {      } elsif ($phase eq 'display') {
         my $js;          my $js = &recaptcha_js();
         if (keys(%servers) > 1) {          if (keys(%servers) > 1) {
             my ($othertitle,$usertypes,$types) =              my ($othertitle,$usertypes,$types) =
                 &Apache::loncommon::sorted_inst_types($dom);                  &Apache::loncommon::sorted_inst_types($dom);
Line 533  sub print_config_box { Line 533  sub print_config_box {
     if ($numheaders > 1) {      if ($numheaders > 1) {
         my $colspan = '';          my $colspan = '';
         my $rightcolspan = '';          my $rightcolspan = '';
         if (($action eq 'rolecolors') || ($action eq 'coursecategories') || ($action eq 'helpsettings')) {          if (($action eq 'rolecolors') || ($action eq 'coursecategories')) {
             $colspan = ' colspan="2"';              $colspan = ' colspan="2"';
         }          }
         if ($action eq 'usersessions') {          if ($action eq 'usersessions') {
Line 2263  sub print_contacts { Line 2263  sub print_contacts {
 }  }
   
 sub print_helpsettings {  sub print_helpsettings {
       my ($position,$dom,$confname,$settings,$rowtotal) = @_;
       my ($css_class,$datatable,$itemcount);
       my $switchserver = &check_switchserver($dom,$confname);
       $itemcount = 1;
       if ($position eq 'top') {
           my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles,$align);
           $choices{'submitbugs'} = &mt('Display link to: [_1]?',
                                        &Apache::loncommon::modal_link('http://bugs.loncapa.org',
                                        &mt('LON-CAPA bug tracker'),600,500));
           %defaultchecked = ('submitbugs' => 'on');
           @toggles = ('submitbugs',);
           $align = 'LC_left_item';
   
  my ($position,$dom,$confname,$settings,$rowtotal) = @_;          ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
  my ($css_class,$datatable);                                                       \%choices,$itemcount);
       } else {
  my $switchserver = &check_switchserver($dom,$confname);          $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
           $datatable .= '<tr'.$css_class.'>';
  my $itemcount = 1;          my $url = '/adm/loginproblems.html'; 
           my $type = 'default';
  if ($position eq 'top') {          my %lt = &Apache::lonlocal::texthash (
                        del     => 'Delete?',
  my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles);                       rep     => 'Replace:',
                        upl     => 'Upload:',
  %choices =                       default => 'Default',
  &Apache::lonlocal::texthash (                       custom  => 'Custom', 
  submitbugs => 'Display &quot;Submit a bug&quot; link?',                                               ); 
  );          if (ref($settings) eq 'HASH') {
               if (ref($settings->{'loginhelpurl'}) eq 'HASH') {
  %defaultchecked = ('submitbugs' => 'on');  
               } elsif ($settings->{'loginhelpurl'} ne '') {
  @toggles = ('submitbugs',);                  $type = 'custom';
                   $url = $settings->{'loginhelpurl'}.'?inhibitmenu=yes';
  foreach my $item (@toggles) {              }
  if ($defaultchecked{$item} eq 'on') {           }
  $checkedon{$item} = ' checked="checked" ';          $datatable .= '<td class="LC_left_item"><span class="LC_nobreak">'.
  $checkedoff{$item} = ' ';                        &mt('Log-in help page currently in use: [_1]',
  } elsif ($defaultchecked{$item} eq 'off') {                            &Apache::loncommon::modal_link($url,$lt{$type},600,500)).
  $checkedoff{$item} = ' checked="checked" ';                        '</span></td>'."\n".
  $checkedon{$item} = ' ';                        '<td class="LC_left_item">';
  }          if ($type eq 'custom') {
  }              $datatable .= '<span class="LC_nobreak"><label>'.
                             '<input type="checkbox" name="loginhelpurl_del" value="1" />'.$lt{'del'}. 
  if (ref($settings) eq 'HASH') {                            '</label>&nbsp;'.$lt{'rep'}.'</span>';
  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 {          } else {
         $datatable .= &mt('Upload Custom Login Page Help File:');              $datatable .= $lt{'upl'};
             $datatable .='<input type="file" name="loginhelpurl" />';  
         }          }
         $datatable .= '</span></td></tr>';          $datatable .='<br />';
                   if ($switchserver) {
      }              $datatable .= &mt('Upload to library server: [_1]',$switchserver);
                } else {
      return $datatable;              $datatable .= '<input type="file" name="loginhelpurl" />';
           } 
           $datatable .= '</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') &&
                    (ref($choices) eq 'HASH'));                     (ref($choices) eq 'HASH'));
   
     my (%checkedon,%checkedoff,$datatable,$css_class);      my (%checkedon,%checkedoff,$datatable,$css_class,$cell_colspan);
   
     foreach my $item (@{$toggles}) {      foreach my $item (@{$toggles}) {
         if ($defaultchecked->{$item} eq 'on') {          if ($defaultchecked->{$item} eq 'on') {
Line 3266  sub print_usercreation { Line 3231  sub print_usercreation {
         }          }
         my ($othertitle,$usertypes,$types) =          my ($othertitle,$usertypes,$types) =
             &Apache::loncommon::sorted_inst_types($dom);              &Apache::loncommon::sorted_inst_types($dom);
           my $createsettings;
           if (ref($settings) eq 'HASH') {
               $createsettings = $settings->{cancreate};
           }
         if (ref($usertypes) eq 'HASH') {          if (ref($usertypes) eq 'HASH') {
             if (keys(%{$usertypes}) > 0) {              if (keys(%{$usertypes}) > 0) {
                 my $createsettings;  
                 if (ref($settings) eq 'HASH') {  
                     $createsettings = $settings->{cancreate};  
                 }  
                 $datatable .= &insttypes_row($createsettings,$types,$usertypes,                  $datatable .= &insttypes_row($createsettings,$types,$usertypes,
                                              $dom,$numinrow,$othertitle,                                               $dom,$numinrow,$othertitle,
                                              'statustocreate');                                               'statustocreate');
                 $$rowtotal ++;                  $$rowtotal ++;
             }              }
         }          }
           $datatable .= &captcha_choice('cancreate',$createsettings);
     } else {      } else {
         my @contexts = ('author','course','domain');          my @contexts = ('author','course','domain');
         my @authtypes = ('int','krb4','krb5','loc');          my @authtypes = ('int','krb4','krb5','loc');
Line 3329  sub print_usercreation { Line 3295  sub print_usercreation {
     return $datatable;      return $datatable;
 }  }
   
   sub captcha_choice {
       my ($context,$settings) = @_;
       my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext);
       my %lt = &captcha_phrases();
       $keyentry = 'hidden';
       if ($context eq 'cancreate') {
           $rowname = &mt('CAPTCHA validation (e-mail as username)');
       } elsif ($context eq 'help') {
           $rowname =  &mt('CAPTCHA validation');
       }
       if (ref($settings) eq 'HASH') {
           if ($settings->{'captcha'}) {
               $checked{$settings->{'captcha'}} = ' checked="checked"';
           } else {
               $checked{'original'} = ' checked="checked"';
           }
           if ($settings->{'captcha'} eq 'recaptcha') {
               $pubtext = $lt{'pub'};
               $privtext = $lt{'priv'};
               $keyentry = 'text';
           }
           if (ref($settings->{'recaptchakeys'}) eq 'HASH') {
               $currpub = $settings->{'recaptchakeys'}{'public'};
               $currpriv = $settings->{'recaptchakeys'}{'private'};
           }
       } else {
           $checked{'original'} = ' checked="checked"';
       }
       my $output = '<tr class="LC_odd_row">'.
                    '<td class="LC_left_item">'.$rowname.'</td><td class="LC_right_item" colspan="2">'."\n".
                    '<table><tr><td>'."\n";
       foreach my $option ('original','recaptcha','notused') {
           $output .= '<span class="LC_nobreak"><label><input type="radio" name="'.$context.'_captcha" value="'.
                      $option.'" '.$checked{$option}.' onchange="javascript:updateCaptcha('."this,'$context'".');" />'.
                      $lt{$option}.'</label></span>';
           unless ($option eq 'notused') {
               $output .= ('&nbsp;'x2)."\n";
           }
       }
   #
   # Note: If reCAPTCHA is to be used for LON-CAPA servers in a domain, a domain coordinator should visit:
   # https://www.google.com/recaptcha and generate a Public and Private key. For domains with multiple
   # servers a single key pair will be used for all servers, so the internet domain (e.g., yourcollege.edu) 
   # specified for use with the key should be broad enough to accommodate all servers in the LON-CAPA domain.
   #  
       $output .= '</td></tr>'."\n".
                  '<tr><td>'."\n".
                  '<span class="LC_nobreak"><span id="'.$context.'_recaptchapubtxt">'.$pubtext.'</span>&nbsp;'."\n".
                  '<input type="'.$keyentry.'" id="'.$context.'_recaptchapub" name="'.$context.'_recaptchapub" value="'.
                  $currpub.'" size="40" /></span><br />'."\n".
                  '<span class="LC_nobreak"><span id="'.$context.'_recaptchaprivtxt">'.$privtext.'</span>&nbsp;'."\n".
                  '<input type="'.$keyentry.'" id="'.$context.'_recaptchapriv" name="'.$context.'_recaptchapriv" value="'.
                  $currpriv.'" size="40" /></span></td></tr></table>'."\n".
                  '</td></tr>';
       return $output;
   }
   
 sub user_formats_row {  sub user_formats_row {
     my ($type,$settings,$rules,$ruleorder,$numinrow,$rowcount) = @_;      my ($type,$settings,$rules,$ruleorder,$numinrow,$rowcount) = @_;
     my $output;      my $output;
Line 4293  sub insttypes_row { Line 4316  sub insttypes_row {
     if ($context eq 'cansearch') {      if ($context eq 'cansearch') {
         $showdom = ' ('.$dom.')';          $showdom = ' ('.$dom.')';
     }      }
       my $class = 'LC_left_item';
       if ($context eq 'statustocreate') {
           $class = 'LC_right_item';
       }
     my $output =  '<tr class="LC_odd_row">'.      my $output =  '<tr class="LC_odd_row">'.
                   '<td>'.$lt{$context}.$showdom.                    '<td>'.$lt{$context}.$showdom.
                   '</td><td class="LC_left_item" colspan="2"><table>';                    '</td><td class="'.$class.'" colspan="2"><table>';
     my $rem;      my $rem;
     if (ref($types) eq 'ARRAY') {      if (ref($types) eq 'ARRAY') {
         for (my $i=0; $i<@{$types}; $i++) {          for (my $i=0; $i<@{$types}; $i++) {
Line 6317  sub modify_usercreation { Line 6344  sub modify_usercreation {
         }          }
         push(@contexts,'statustocreate');          push(@contexts,'statustocreate');
     }      }
       &process_captcha('cancreate',\%changes,\%cancreate,\%curr_usercreation);
     if (ref($curr_usercreation{'cancreate'}) eq 'HASH') {      if (ref($curr_usercreation{'cancreate'}) eq 'HASH') {
         foreach my $item (@contexts) {          foreach my $item (@contexts) {
             if (($item eq 'selfcreate') || ($item eq 'statustocreate')) {              if (($item eq 'selfcreate') || ($item eq 'statustocreate')) {
Line 6499  sub modify_usercreation { Line 6527  sub modify_usercreation {
                 my %lt = &usercreation_types();                  my %lt = &usercreation_types();
                 foreach my $type (@{$changes{'cancreate'}}) {                  foreach my $type (@{$changes{'cancreate'}}) {
                     my $chgtext;                      my $chgtext;
                     unless ($type eq 'statustocreate') {                      unless (($type eq 'statustocreate') || ($type eq 'captcha') || ($type eq 'recaptchakeys')) {
                         $chgtext = $lt{$type}.', ';                          $chgtext = $lt{$type}.', ';
                     }                      }
                     if ($type eq 'selfcreate') {                      if ($type eq 'selfcreate') {
Line 6558  sub modify_usercreation { Line 6586  sub modify_usercreation {
                                 }                                  }
                             }                              }
                         }                          }
                       } elsif ($type eq 'captcha') {
                           if ($cancreate{$type} eq 'notused') {
                               $chgtext .= &mt('No CAPTCHA validation in use for self-creation screen.');
                           } else {
                               my %captchas = &captcha_phrases();
                               if ($captchas{$cancreate{$type}}) {
                                   $chgtext .= &mt("Validation for self-creation screen set to $captchas{$cancreate{$type}}.");
                               } else {
                                   $chgtext .= &mt('Validation for self-creation screen set to unknown type.'); 
                               }
                           }
                       } elsif ($type eq 'recaptchakeys') {
                           my ($privkey,$pubkey);
                           if (ref($cancreate{$type}) eq 'HASH') {
                               $pubkey = $cancreate{$type}{'public'};
                               $privkey = $cancreate{$type}{'private'};
                           }
                           $chgtext .= &mt('ReCAPTCHA keys changes').'<ul>';
                           if (!$pubkey) {
                               $chgtext .= '<li>'.&mt('Public key deleted').'</li>';
                           } else {
                               $chgtext .= '<li>'.&mt('Public key set to [_1]',$pubkey).'</li>';
                           }
                           if (!$privkey) {
                               $chgtext .= '<li>'.&mt('Private key deleted').'</li>';
                           } else {
                               $chgtext .= '<li>'.&mt('Private key set to [_1]',$pubkey).'</li>';
                           }
                           $chgtext .= '</ul>';
                     } else {                      } else {
                         if ($cancreate{$type} eq 'none') {                          if ($cancreate{$type} eq 'none') {
                             $chgtext .= &mt('creation of new users is not permitted, except by a Domain Coordinator.');                              $chgtext .= &mt('creation of new users is not permitted, except by a Domain Coordinator.');
Line 6657  sub modify_usercreation { Line 6714  sub modify_usercreation {
     return $resulttext;      return $resulttext;
 }  }
   
   sub process_captcha {
       my ($container,$changes,$newsettings,$current) = @_;
       return unless ((ref($changes) eq 'HASH') && (ref($newsettings) eq 'HASH') || (ref($current) eq 'HASH'));
       $newsettings->{'captcha'} = $env{'form.'.$container.'_captcha'};
       unless ($newsettings->{'captcha'} eq 'recaptcha' || $newsettings->{'captcha'} eq 'notused') {
           $newsettings->{'captcha'} = 'original';
       }
       if ($current->{'captcha'} ne $newsettings->{'captcha'}) {
           if (ref($changes->{'cancreate'}) eq 'ARRAY') {
               push(@{$changes->{'cancreate'}},'captcha');
           } elsif (!defined($changes->{'cancreate'})) {
               $changes->{'cancreate'} = ['captcha'];
           }
       }
       my ($newpub,$newpriv,$currpub,$currpriv);
       if ($newsettings->{'captcha'} eq 'recaptcha') {
           $newpub = $env{'form.'.$container.'_recaptchapub'};
           $newpriv = $env{'form.'.$container.'_recaptchapriv'};
       }
       $newsettings->{'recaptchakeys'} = {
                                            public  => $newpub,
                                            private => $newpriv,
                                         };
       if (ref($current->{'recaptchakeys'}) eq 'HASH') {
           $currpub = $current->{'recaptchakeys'}{'public'};
           $currpriv = $current->{'recaptchakeys'}{'private'};
       }
       if (($newpub ne $currpub) || ($newpriv ne $currpriv)) {
           if (ref($changes->{'cancreate'}) eq 'ARRAY') {
               push(@{$changes->{'cancreate'}},'recaptchakeys');
           } elsif (!defined($changes->{'cancreate'})) {
               $changes->{'cancreate'} = ['recaptchakeys'];
           }
       }
       return;
   }
   
 sub modify_usermodification {  sub modify_usermodification {
     my ($dom,%domconfig) = @_;      my ($dom,%domconfig) = @_;
     my ($resulttext,%curr_usermodification,%changes);      my ($resulttext,%curr_usermodification,%changes);
Line 7313  sub modify_serverstatuses { Line 7407  sub modify_serverstatuses {
   
 sub modify_helpsettings {  sub modify_helpsettings {
     my ($r,$dom,$confname,%domconfig) = @_;      my ($r,$dom,$confname,%domconfig) = @_;
   my ($resulttext,$errors,%changes,%helphash);      my ($resulttext,$errors,%changes,%helphash);
        my $customhelpfile = $env{'form.loginhelpurl.filename'};
   my $customhelpfile  = $env{'form.loginhelpurl.filename'};      my $defaulthelpfile = '/adm/loginproblems.html';
     my $defaulthelpfile = 'defaulthelp.html';      my $defaulttext = &mt('Default in use');
   my $servadm = $r->dir_config('lonAdmEMail');      my $servadm = $r->dir_config('lonAdmEMail');
     my ($configuserok,$author_ok,$switchserver) =       my ($configuserok,$author_ok,$switchserver) = &config_check($dom,$confname,$servadm);
         &config_check($dom,$confname,$servadm);      my %defaultchecked = ('submitbugs' => 'on');
        my @offon = ('off','on');
   my %defaultchecked = ('submitbugs' => 'on');      my %title = (
   my @offon = ('off','on');                      submitbugs    => 'Display link for users to submit a bug', 
     my %title = ( submitbugs     => 'Display link for users to submit a bug',                       loginhelpurl  => 'Unauthenticated login help page set to custom file'
      loginhelpurl  => 'Unauthenticated login help page set to custom file');                  );
        
     my @toggles = ('submitbugs');      my @toggles = ('submitbugs');
   
     $helphash{'helpsettings'} = {};      $helphash{'helpsettings'} = {};
       
     if (ref($domconfig{'helpsettings'}) ne 'HASH') {      if (ref($domconfig{'helpsettings'}) ne 'HASH') {
         if ($domconfig{'helpsettings'} eq '') {          if ($domconfig{'helpsettings'} eq '') {
             $domconfig{'helpsettings'} = {};              $domconfig{'helpsettings'} = {};
         }          }
     }      }
       
     if (ref($domconfig{'helpsettings'}) eq 'HASH') {      if (ref($domconfig{'helpsettings'}) eq 'HASH') {
      
         foreach my $item (@toggles) {          foreach my $item (@toggles) {
                      if ($defaultchecked{$item} eq 'on') { 
  if ($defaultchecked{$item} eq 'on') {                   if ($domconfig{'helpsettings'}{$item} eq '') {
  if (($domconfig{'helpsettings'}{$item} eq '') &&                      if ($env{'form.'.$item} eq '0') {
  ($env{'form.'.$item} eq '0')) {                          $changes{$item} = 1;
  $changes{$item} = 1;                      }
  } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {                  } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
  $changes{$item} = 1;                      $changes{$item} = 1;
  }                  }
  } elsif ($defaultchecked{$item} eq 'off') {              } elsif ($defaultchecked{$item} eq 'off') {
  if (($domconfig{'helpsettings'}{$item} eq '') &&                  if ($domconfig{'helpsettings'}{$item} eq '') {
  ($env{'form.'.$item} eq '1')) {                      if ($env{'form.'.$item} eq '1') {
  $changes{$item} = 1;                          $changes{$item} = 1;
  } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {                      }
  $changes{$item} = 1;                  } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
  }                      $changes{$item} = 1;
  }                  }
  $helphash{'helpsettings'}{$item} = $env{'form.'.$item};              }
  }              if (($env{'form.'.$item} eq '0') || ($env{'form.'.$item} eq '1')) { 
                   $helphash{'helpsettings'}{$item} = $env{'form.'.$item};
  if ($customhelpfile ne '') {              }
  my $error;          }
  if ($configuserok eq 'ok') {          if ($customhelpfile ne '') {
  if ($switchserver) {              my $error;
  $error = &mt("Upload of custom help file is not permitted to this server: [_1]",$switchserver);              if ($configuserok eq 'ok') {
  } else {                  if ($switchserver) {
  if ($author_ok eq 'ok') {                      $error = &mt("Upload of custom help file is not permitted to this server: [_1]",$switchserver);
  my ($result,$loginhelpurl) =                  } else {
  &publishlogo($r,'upload','loginhelpurl',$dom,                      if ($author_ok eq 'ok') {
  $confname,'help','','',$customhelpfile);                          my ($result,$loginhelpurl) = &publishlogo($r,'upload','loginhelpurl',$dom,
  if ($result eq 'ok') {                                                                    $confname,'help','','',$customhelpfile);
  $helphash{'helpsettings'}{'loginhelpurl'} = $loginhelpurl;                          if ($result eq 'ok') {
  $changes{'loginhelpurl'} = 1;                              $helphash{'helpsettings'}{'loginhelpurl'} = $loginhelpurl;
  } else {                              $changes{'loginhelpurl'} = 1;
  $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 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 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);              } 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);              if ($error) {
  $errors .= '<li><span class="LC_error">'.$error.'</span></li>';                  &Apache::lonnet::logthis($error);
  }                  $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
  }              }
           }
         if ($domconfig{'helpsettings'}{'loginhelpurl'} ne '') {          if ($domconfig{'helpsettings'}{'loginhelpurl'} ne '') {
             if ($env{'form.loginhelpurl_del'}) {              if ($env{'form.loginhelpurl_del'}) {
                 $helphash{'helpsettings'}{'loginhelpurl'} = '';                  $helphash{'helpsettings'}{'loginhelpurl'} = '';
Line 7394  sub modify_helpsettings { Line 7483  sub modify_helpsettings {
             }              }
         }          }
     }      }
       
       
     my $putresult;      my $putresult;
       
     if (keys(%changes) > 0) {      if (keys(%changes) > 0) {
     $putresult = &Apache::lonnet::put_dom('configuration',\%helphash,$dom);          $putresult = &Apache::lonnet::put_dom('configuration',\%helphash,$dom);
     } else {      } else {
     $putresult = 'ok';          $putresult = 'ok';
     }      }
                                                
     if ($putresult eq 'ok') {      if ($putresult eq 'ok') {
         if (keys(%changes) > 0) {          if (keys(%changes) > 0) {
  $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 'submitbugs') {                  if ($item eq 'submitbugs') {
  $resulttext .= '<li>'.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'</li>';                      $resulttext .= '<li>'.&mt('Display link to: [_1] set to "'.$offon[$env{'form.'.$item}].'".',
  }                                                &Apache::loncommon::modal_link('http://bugs.loncapa.org',
  if ($item eq 'loginhelpurl') {                                                &mt('LON-CAPA bug tracker'),600,500)).'</li>';
  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>';                  if ($item eq 'loginhelpurl') {
                     } else {                      if ($helphash{'helpsettings'}{'loginhelpurl'} eq '') {
                         $resulttext .= '<li>'.&mt("$title{$item} [_1]",$customhelpfile).'</li>';                          $resulttext .= '<li>'.&mt('custom log-in help file removed.').'&nbsp;'.
                     }                                                &Apache::loncommon::modal_link($defaulthelpfile,
  }                                                $defaulttext,600,500).'</li>';
  }                      } else {
  $resulttext .= '</ul>';                          $resulttext .= '<li>'.&Apache::loncommon::modal_link(
  } else {                                                    $helphash{'helpsettings'}{'loginhelpurl'}.
  $resulttext = &mt('No changes made to help settings');                                                    '?inhibitmenu=yes',
  }                                                    &mt('custom log-in help file'),600,500).
                                          '</li>';
                       }
                   }
               }
               $resulttext .= '</ul>';
           } else {
               $resulttext = &mt('No changes made to help settings');
           }
     } else {      } else {
         $resulttext = '<span class="LC_error">'.          $errors .= '<li><span class="LC_error">'.&mt('An error occurred storing the settings: [_1]',
     &mt('An error occurred: [_1]',$putresult).'</span>';                                                       $putresult).'</span></li>';
     }      }
     if ($errors) {      if ($errors) {
         $resulttext .= &mt('The following errors occurred: ').'<ul>'.          $resulttext .= &mt('The following errors occurred: ').'<ul>'.
Line 8422  END Line 8515  END
   
 }  }
   
   sub recaptcha_js {
       my %lt = &captcha_phrases();
       return <<"END";
   
   <script type="text/javascript">
   // <![CDATA[
   
   function updateCaptcha(caller,context) {
       var privitem;
       var pubitem;
       var privtext;
       var pubtext;
       if (document.getElementById(context+'_recaptchapub')) {
           pubitem = document.getElementById(context+'_recaptchapub');
       } else {
           return;
       }
       if (document.getElementById(context+'_recaptchapriv')) {
           privitem = document.getElementById(context+'_recaptchapriv');
       } else {
           return;
       }
       if (document.getElementById(context+'_recaptchapubtxt')) {
           pubtext = document.getElementById(context+'_recaptchapubtxt');
       } else {
           return;
       }
       if (document.getElementById(context+'_recaptchaprivtxt')) {
           privtext = document.getElementById(context+'_recaptchaprivtxt');
       } else {
           return;
       }
       if (caller.checked) {
           if (caller.value == 'recaptcha') {
               pubitem.type = 'text';
               privitem.type = 'text';
               pubitem.size = '40';
               privitem.size = '40';
               pubtext.innerHTML = "$lt{'pub'}";
               privtext.innerHTML = "$lt{'priv'}";
           } else {
               pubitem.type = 'hidden';
               privitem.type = 'hidden';
               pubtext.innerHTML = '';
               privtext.innerHTML = '';
           }
       }
       return;
   }
   
   // ]]>
   </script>
   
   END
   
   }
   
   sub captcha_phrases {
       return &Apache::lonlocal::texthash (
                    priv => 'Private key',
                    pub  => 'Public key',
                    original  => 'original (CAPTCHA)',
                    recaptcha => 'successor (ReCAPTCHA)',
                    notused   => 'unused',
       );
   }
   
 1;  1;

Removed from v.1.164  
changed lines
  Added in v.1.166


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