Diff for /loncom/interface/domainprefs.pm between versions 1.382 and 1.385

version 1.382, 2021/04/29 17:45:22 version 1.385, 2021/09/01 00:21:52
Line 223  sub handler { Line 223  sub handler {
                 'ltitools','ssl','trust','lti','privacy','passwords',                  'ltitools','ssl','trust','lti','privacy','passwords',
                 'proctoring','wafproxy'],$dom);                  'proctoring','wafproxy'],$dom);
     my %encconfig =      my %encconfig =
         &Apache::lonnet::get_dom('encconfig',['ltitools','lti','proctoring'],$dom);          &Apache::lonnet::get_dom('encconfig',['ltitools','lti','proctoring'],$dom,undef,1);
     if (ref($domconfig{'ltitools'}) eq 'HASH') {      if (ref($domconfig{'ltitools'}) eq 'HASH') {
         if (ref($encconfig{'ltitools'}) eq 'HASH') {          if (ref($encconfig{'ltitools'}) eq 'HASH') {
             foreach my $id (keys(%{$domconfig{'ltitools'}})) {              foreach my $id (keys(%{$domconfig{'ltitools'}})) {
Line 857  sub print_config_box { Line 857  sub print_config_box {
         $output .= &proctoring_javascript($settings);          $output .= &proctoring_javascript($settings);
     } elsif ($action eq 'wafproxy') {      } elsif ($action eq 'wafproxy') {
         $output .= &wafproxy_javascript($dom);          $output .= &wafproxy_javascript($dom);
       } elsif ($action eq 'autoupdate') {
           $output .= &autoupdate_javascript();
     }      }
     $output .=      $output .=
          '<table class="LC_nested_outer">           '<table class="LC_nested_outer">
Line 3311  function toggleLTI(form,setting,item) { Line 3313  function toggleLTI(form,setting,item) {
 ENDSCRIPT  ENDSCRIPT
 }  }
   
   sub autoupdate_javascript {
       return <<"ENDSCRIPT";
   <script type="text/javascript">
   // <![CDATA[
   function toggleLastActiveDays(form) {
       var radioname = 'lastactive';
       var divid = 'lastactive_div';
       var num = form.elements[radioname].length;
       if (num) {
           var setvis = '';
           for (var i=0; i<num; i++) {
               if (form.elements[radioname][i].checked) {
                   if (form.elements[radioname][i].value == '1') {
                       if (document.getElementById(divid)) {
                           document.getElementById(divid).style.display = 'inline-block';
                       }
                       setvis = 1;
                   }
                   break;
               }
           }
           if (!setvis) {
               if (document.getElementById(divid)) {
                   document.getElementById(divid).style.display = 'none';
               }
           }
       }
       return;
   }
   // ]]>
   </script>
   
   ENDSCRIPT
   }
   
 sub print_autoenroll {  sub print_autoenroll {
     my ($dom,$settings,$rowtotal) = @_;      my ($dom,$settings,$rowtotal) = @_;
     my $autorun = &Apache::lonnet::auto_run(undef,$dom),      my $autorun = &Apache::lonnet::auto_run(undef,$dom),
Line 3397  sub print_autoenroll { Line 3434  sub print_autoenroll {
   
 sub print_autoupdate {  sub print_autoupdate {
     my ($position,$dom,$settings,$rowtotal) = @_;      my ($position,$dom,$settings,$rowtotal) = @_;
     my $datatable;      my ($enable,$datatable);
     if ($position eq 'top') {      if ($position eq 'top') {
           my %choices = &Apache::lonlocal::texthash (
                             run        => 'Auto-update active?',
                             classlists => 'Update information in classlists?',
                             unexpired  => 'Skip updates for users without active or future roles?',
                             lastactive => 'Skip updates for inactive users?',
           );
           my $itemcount = 0;
         my $updateon = ' ';          my $updateon = ' ';
         my $updateoff = ' checked="checked" ';          my $updateoff = ' checked="checked" ';
         my $classlistson = ' ';  
         my $classlistsoff = ' checked="checked" ';  
         if (ref($settings) eq 'HASH') {          if (ref($settings) eq 'HASH') {
             if ($settings->{'run'} eq '1') {              if ($settings->{'run'} eq '1') {
                 $updateon = $updateoff;                  $updateon = $updateoff;
                 $updateoff = ' ';                  $updateoff = ' ';
             }              }
             if ($settings->{'classlists'} eq '1') {  
                 $classlistson = $classlistsoff;  
                 $classlistsoff = ' ';  
             }  
         }          }
         my %title = (          $enable = '<tr class="LC_odd_row">'.
                    run => 'Auto-update active?',                    '<td>'.$choices{'run'}.'</td>'.
                    classlists => 'Update information in classlists?',                    '<td class="LC_left_item"><span class="LC_nobreak"><label>'.
                     );  
         $datatable = '<tr class="LC_odd_row">'.   
                   '<td>'.&mt($title{'run'}).'</td>'.  
                   '<td class="LC_right_item"><span class="LC_nobreak"><label>'.  
                   '<input type="radio" name="autoupdate_run"'.                    '<input type="radio" name="autoupdate_run"'.
                   $updateon.' value="1" />'.&mt('Yes').'</label>&nbsp;'.                    $updateoff.' value="0" />'.&mt('No').'</label>&nbsp;'.
                   '<label><input type="radio" name="autoupdate_run"'.                    '<label><input type="radio" name="autoupdate_run"'.
                   $updateoff.'value="0" />'.&mt('No').'</label></span></td>'.                    $updateon.'value="1" />'.&mt('Yes').'</label></span></td>'.
                   '</tr><tr>'.  
                   '<td>'.&mt($title{'classlists'}).'</td>'.  
                   '<td class="LC_right_item"><span class="LC_nobreak">'.  
                   '<label><input type="radio" name="classlists"'.  
                   $classlistson.' value="1" />'.&mt('Yes').'</label>&nbsp;'.  
                   '<label><input type="radio" name="classlists"'.  
                   $classlistsoff.'value="0" />'.&mt('No').'</label></span></td>'.  
                   '</tr>';                    '</tr>';
         $$rowtotal += 2;          my @toggles = ('classlists','unexpired');
           my %defaultchecked = ('classlists' => 'off',
                                 'unexpired'  => 'off'
                                 );
           $$rowtotal ++;
           ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
                                                        \%choices,$itemcount,'','','left','no');
           $datatable = $enable.$datatable;
           $$rowtotal += $itemcount;
           my $lastactiveon = ' ';
           my $lastactiveoff = ' checked="checked" ';
           my $lastactivestyle = 'none';
           my $lastactivedays;
           my $onclick = ' onclick="javascript:toggleLastActiveDays(this.form);"';
           if (ref($settings) eq 'HASH') {
               if ($settings->{'lastactive'} =~ /^\d+$/) {
                   $lastactiveon = $lastactiveoff;
                   $lastactiveoff = ' ';
                   $lastactivestyle = 'inline-block';
                   $lastactivedays = $settings->{'lastactive'};
               }
           }
           my $css_class = $itemcount%2?' class="LC_odd_row"':'';
           $datatable .= '<tr'.$css_class.'>'.
                         '<td>'.$choices{'lastactive'}.'</td>'.
                         '<td class="LC_left_item"><span class="LC_nobreak"><label>'.
                         '<input type="radio" name="lastactive"'.
                         $lastactiveoff.'value="0"'.$onclick.' />'.&mt('No').'</label>'.
                         '&nbsp;<label>'.
                         '<input type="radio" name="lastactive"'.
                         $lastactiveon.' value="1"'.$onclick.' />'.&mt('Yes').'</label>'.
                         '<div id="lastactive_div" style="display:'.$lastactivestyle.';">'.
                         ':&nbsp;'.&mt('inactive = no activity in last [_1] days',
                             '<input type="text" size="5" name="lastactivedays" value="'.
                             $lastactivedays.'" />').
                         '</span></td>'.
                         '</tr>';
           $$rowtotal ++;
     } elsif ($position eq 'middle') {      } elsif ($position eq 'middle') {
         my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);          my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
         my $numinrow = 3;          my $numinrow = 3;
Line 4561  sub helpdeskroles_access { Line 4625  sub helpdeskroles_access {
   
 sub radiobutton_prefs {  sub radiobutton_prefs {
     my ($settings,$toggles,$defaultchecked,$choices,$itemcount,$onclick,      my ($settings,$toggles,$defaultchecked,$choices,$itemcount,$onclick,
         $additional,$align) = @_;          $additional,$align,$firstval) = @_;
     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'));
   
Line 4601  sub radiobutton_prefs { Line 4665  sub radiobutton_prefs {
         } else {          } else {
             $datatable .= '<td class="LC_right_item">';              $datatable .= '<td class="LC_right_item">';
         }          }
         $datatable .=          $datatable .= '<span class="LC_nobreak">';
             '<span class="LC_nobreak">'.          if ($firstval eq 'no') {
             '<label><input type="radio" name="'.              $datatable .=
             $item.'" '.$checkedon{$item}.' value="1"'.$onclick.' />'.&mt('Yes').                  '<label><input type="radio" name="'.
             '</label>&nbsp;<label><input type="radio" name="'.$item.'" '.                  $item.'" '.$checkedoff{$item}.' value="0"'.$onclick.' />'.&mt('No').
             $checkedoff{$item}.' value="0"'.$onclick.' />'.&mt('No').'</label>'.                  '</label>&nbsp;<label><input type="radio" name="'.$item.'" '.
             '</span>'.$additional.                  $checkedon{$item}.' value="1"'.$onclick.' />'.&mt('Yes').'</label>';
             '</td>'.          } else {
             '</tr>';              $datatable .=
                   '<label><input type="radio" name="'.
                   $item.'" '.$checkedon{$item}.' value="1"'.$onclick.' />'.&mt('Yes').
                   '</label>&nbsp;<label><input type="radio" name="'.$item.'" '.
                   $checkedoff{$item}.' value="0"'.$onclick.' />'.&mt('No').'</label>';
           }
           $datatable .= '</span>'.$additional.'</td></tr>';
         $itemcount ++;          $itemcount ++;
     }      }
     return ($datatable,$itemcount);      return ($datatable,$itemcount);
Line 7337  sub print_wafproxy { Line 7407  sub print_wafproxy {
         foreach my $domain (keys(%otherdoms)) {          foreach my $domain (keys(%otherdoms)) {
             %{$values{$domain}} = ();              %{$values{$domain}} = ();
             my %config = &Apache::lonnet::get_dom('configuration',['wafproxy'],$domain);              my %config = &Apache::lonnet::get_dom('configuration',['wafproxy'],$domain);
             if (ref($config{$domain}) eq 'HASH') {              if (ref($config{'wafproxy'}) eq 'HASH') {
                 if (ref($config{$domain}{'wafproxy'}) eq 'HASH') {                  $aliases{$domain} = $config{'wafproxy'}{'alias'};
                     $aliases{$domain} = $config{$domain}{'wafproxy'}{'alias'};                  foreach my $item ('remoteip','ipheader','trusted','vpnint','vpnext') {
                     foreach my $item ('remoteip','ipheader','trusted','vpnint','vpnext') {                      $values{$domain}{$item} = $config{'wafproxy'}{$item};
                         $values{$domain}{$item} = $config{$domain}{'wafproxy'}{$item};  
                     }  
                 }                  }
             }              }
         }          }
Line 7354  sub print_wafproxy { Line 7422  sub print_wafproxy {
             $itemcount ++;              $itemcount ++;
             my $dom_in_effect;              my $dom_in_effect;
             my $aliasrows = '<tr>'.              my $aliasrows = '<tr>'.
                             '<td class="LC_left_item">'.&mt('Hostname').':&nbsp;'.                              '<td class="LC_left_item" style="vertical-align: baseline;">'.
                             &Apache::lonnet::hostname($server).'</td>';                              &mt('Hostname').':&nbsp;'.
                               '<i>'.&Apache::lonnet::hostname($server).'</i></td><td>&nbsp;</td>';
             if ($othercontrol{$server}) {              if ($othercontrol{$server}) {
                 $dom_in_effect = $othercontrol{$server};                  $dom_in_effect = $othercontrol{$server};
                 my $current;                  my $current;
                 if (ref($aliases{$othercontrol{$server}}) eq 'HASH') {                  if (ref($aliases{$dom_in_effect}) eq 'HASH') {
                     $current = $aliases{$othercontrol{$server}{$server}};                      $current = $aliases{$dom_in_effect}{$server};
                 }                  }
                   $aliasrows .= '<td class="LC_left_item" style="vertical-align: baseline;">'.
                                 &mt('Alias').':&nbsp';
                 if ($current) {                  if ($current) {
                     $aliasrows .= $current;                      $aliasrows .= $current;
                 } else {                  } else {
                     $aliasrows .= &mt('None in effect');                      $aliasrows .= &mt('None');
                 }                  }
                 $aliasrows .= '<td class="LC_left_item"><span class="LC_small">('.                  $aliasrows .= '&nbsp;<span class="LC_small">('.
                               &mt('WAF/Reverse Proxy controlled by domain: [_1]',                                &mt('controlled by domain: [_1]',
                                   '<b>'.$othercontrol{$server}.'</b>').'</span></td>';                                    '<b>'.$dom_in_effect.'</b>').')</span></td>';
             } else {              } else {
                 $dom_in_effect = $dom;                  $dom_in_effect = $dom;
                 my $current;                  my $current;
Line 7378  sub print_wafproxy { Line 7449  sub print_wafproxy {
                         $current = $aliases{$dom}{$server};                          $current = $aliases{$dom}{$server};
                     }                      }
                 }                  }
                 $aliasrows .= '<td class="LC_left_item">'.&mt('WAF/Reverse Proxy Alias').':&nbsp;'.                  $aliasrows .= '<td class="LC_left_item" style="vertical-align: baseline;">'.
                                 &mt('Alias').':&nbsp;'.
                               '<input type="text" name="wafproxy_alias_'.$server.'" '.                                '<input type="text" name="wafproxy_alias_'.$server.'" '.
                               'value="'.$current.'" size="30" /></td>';                                'value="'.$current.'" size="30" /></td>';
             }              }
Line 7408  sub print_wafproxy { Line 7480  sub print_wafproxy {
                          '</table></td></tr>';                           '</table></td></tr>';
             $itemcount++;              $itemcount++;
         }          }
         if (keys(%othercontrol)) {          if (keys(%otherdoms)) {
             foreach my $key (sort(keys(%othercontrol))) {              foreach my $key (sort(keys(%otherdoms))) {
                 $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';                  $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
                 $datatable = '<tr'.$css_class.'>'.                  $datatable .= '<tr'.$css_class.'>'.
                              '<td class="LC_left_item">'.&mt('Domain: [_1]','<b>'.$key.'</b>').'</td>'.                                '<td class="LC_left_item">'.&mt('Domain: [_1]','<b>'.$key.'</b>').'</td>'.
                              '<td class="LC_left_item"><table>'.$aliasinfo{$key}.                                '<td class="LC_left_item"><table>'.$aliasinfo{$key}.
                              '</table></td></tr>';                                '</table></td></tr>';
                 $itemcount++;                  $itemcount++;
             }              }
         }          }
     } else {      } else {
           my %ip_methods = &remoteip_methods();
         if ($setdom) {          if ($setdom) {
             $itemcount ++;              $itemcount ++;
             $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';              $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
Line 7467  sub print_wafproxy { Line 7540  sub print_wafproxy {
                           '<tr>'.                            '<tr>'.
                           '<td valign="top">'.$lt{'remoteip'}.':&nbsp;'.                            '<td valign="top">'.$lt{'remoteip'}.':&nbsp;'.
                           '<select name="wafproxy_remoteip" id="wafproxy_remoteip" onchange="javascript:updateWAF();">';                            '<select name="wafproxy_remoteip" id="wafproxy_remoteip" onchange="javascript:updateWAF();">';
             my %ip_methods = &remoteip_methods();  
             foreach my $option ('m','h','n') {              foreach my $option ('m','h','n') {
                 my $sel;                  my $sel;
                 if ($option eq $curr_remotip) {                  if ($option eq $curr_remotip) {
Line 7515  sub print_wafproxy { Line 7587  sub print_wafproxy {
                 $itemcount ++;                  $itemcount ++;
                 $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';                  $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
                 $datatable .= '<tr'.$css_class.'>'.                  $datatable .= '<tr'.$css_class.'>'.
                               '<td class="LC_left_item">'.&mt('Domain: [_1]',$domain).'</td>'.                                '<td class="LC_left_item">'.&mt('Domain: [_1]','<b>'.$domain.'</b>').'</td>'.
                               '<td class="LC_left_item"><table>';                                '<td class="LC_left_item"><table>';
                 foreach my $item ('remoteip','ipheader','trusted','vpnint','vpnext','sslopt') {                  foreach my $item ('remoteip','ipheader','trusted','vpnint','vpnext','sslopt') {
                     my $showval = &mt('None');                      my $showval = &mt('None');
Line 7526  sub print_wafproxy { Line 7598  sub print_wafproxy {
                         $showval = $values{$domain}{$item};                          $showval = $values{$domain}{$item};
                         if ($item eq 'ssl') {                          if ($item eq 'ssl') {
                             $showval = $lt{'alltossl'};                              $showval = $lt{'alltossl'};
                           } elsif ($item eq 'remoteip') {
                               $showval = $ip_methods{$values{$domain}{$item}};
                         }                          }
                     }                      }
                     $datatable .= '<tr>'.                      $datatable .= '<tr>'.
Line 13523  sub modify_ltitools { Line 13597  sub modify_ltitools {
         my %ltienchash = (          my %ltienchash = (
                              $action => { %encconfig }                               $action => { %encconfig }
                          );                           );
         &Apache::lonnet::put_dom('encconfig',\%ltienchash,$dom);          &Apache::lonnet::put_dom('encconfig',\%ltienchash,$dom,undef,1);
         if (keys(%changes) > 0) {          if (keys(%changes) > 0) {
             my $cachetime = 24*60*60;              my $cachetime = 24*60*60;
             my %ltiall = %confhash;              my %ltiall = %confhash;
Line 14097  sub modify_proctoring { Line 14171  sub modify_proctoring {
         my %proc_enchash = (          my %proc_enchash = (
                              $action => { %encconfhash }                               $action => { %encconfhash }
                          );                           );
         &Apache::lonnet::put_dom('encconfig',\%proc_enchash,$dom);          &Apache::lonnet::put_dom('encconfig',\%proc_enchash,$dom,undef,1);
         if (keys(%changes) > 0) {          if (keys(%changes) > 0) {
             my $cachetime = 24*60*60;              my $cachetime = 24*60*60;
             my %procall = %confhash;              my %procall = %confhash;
Line 14589  sub modify_lti { Line 14663  sub modify_lti {
         my %ltienchash = (          my %ltienchash = (
                              $action => { %encconfig }                               $action => { %encconfig }
                          );                           );
         &Apache::lonnet::put_dom('encconfig',\%ltienchash,$dom);          &Apache::lonnet::put_dom('encconfig',\%ltienchash,$dom,undef,1);
         if (keys(%changes) > 0) {          if (keys(%changes) > 0) {
             my $cachetime = 24*60*60;              my $cachetime = 24*60*60;
             my %ltiall = %confhash;              my %ltiall = %confhash;
Line 14931  sub modify_autoupdate { Line 15005  sub modify_autoupdate {
     }      }
     my @offon = ('off','on');      my @offon = ('off','on');
     my %title = &Apache::lonlocal::texthash (      my %title = &Apache::lonlocal::texthash (
                    run => 'Auto-update:',                      run        => 'Auto-update:',
                    classlists => 'Updates to user information in classlists?'                      classlists => 'Updates to user information in classlists?',
                       unexpired  => 'Skip updates for users without active or future roles?',
                       lastactive => 'Skip updates for inactive users?',
                 );                  );
     my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);      my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
     my %fieldtitles = &Apache::lonlocal::texthash (      my %fieldtitles = &Apache::lonlocal::texthash (
Line 14976  sub modify_autoupdate { Line 15052  sub modify_autoupdate {
     my %updatehash = (      my %updatehash = (
                       autoupdate => { run => $env{'form.autoupdate_run'},                        autoupdate => { run => $env{'form.autoupdate_run'},
                                       classlists => $env{'form.classlists'},                                        classlists => $env{'form.classlists'},
                                         unexpired  => $env{'form.unexpired'},
                                       fields => {%fields},                                        fields => {%fields},
                                       lockablenames => \@lockablenames,                                        lockablenames => \@lockablenames,
                                     }                                      }
                      );                       );
       my $lastactivedays;
       if ($env{'form.lastactive'}) {
           $lastactivedays = $env{'form.lastactivedays'};
           $lastactivedays =~ s/^\s+|\s+$//g;
           unless ($lastactivedays =~ /^\d+$/) {
               undef($lastactivedays);
               $env{'form.lastactive'} = 0;
           }
       }
       $updatehash{'autoupdate'}{'lastactive'} = $lastactivedays;
     foreach my $key (keys(%currautoupdate)) {      foreach my $key (keys(%currautoupdate)) {
         if (($key eq 'run') || ($key eq 'classlists')) {          if (($key eq 'run') || ($key eq 'classlists') || ($key eq 'unexpired') || ($key eq 'lastactive')) {
             if (exists($updatehash{autoupdate}{$key})) {              if (exists($updatehash{autoupdate}{$key})) {
                 if ($currautoupdate{$key} ne $updatehash{autoupdate}{$key}) {                  if ($currautoupdate{$key} ne $updatehash{autoupdate}{$key}) {
                     $changes{$key} = 1;                      $changes{$key} = 1;
Line 15027  sub modify_autoupdate { Line 15114  sub modify_autoupdate {
             $changes{'lockablenames'} = 1;              $changes{'lockablenames'} = 1;
         }          }
     }      }
       unless (grep(/^unexpired$/,keys(%currautoupdate))) {
           if ($updatehash{'autoupdate'}{'unexpired'}) {
               $changes{'unexpired'} = 1;
           }
       }
       unless (grep(/^lastactive$/,keys(%currautoupdate))) {
           if ($updatehash{'autoupdate'}{'lastactive'} ne '') {
               $changes{'lastactive'} = 1;
           }
       }
     foreach my $item (@{$types},'default') {      foreach my $item (@{$types},'default') {
         if (defined($fields{$item})) {          if (defined($fields{$item})) {
             if (ref($currautoupdate{'fields'}) eq 'HASH') {              if (ref($currautoupdate{'fields'}) eq 'HASH') {
Line 15089  sub modify_autoupdate { Line 15186  sub modify_autoupdate {
                     my $newvalue;                      my $newvalue;
                     if ($key eq 'run') {                      if ($key eq 'run') {
                         $newvalue = $offon[$env{'form.autoupdate_run'}];                          $newvalue = $offon[$env{'form.autoupdate_run'}];
                       } elsif ($key eq 'lastactive') {
                           $newvalue = $offon[$env{'form.lastactive'}];
                           unless ($lastactivedays eq '') {
                               $newvalue .= '; '.&mt('inactive = no activity in last [quant,_1,day]',$lastactivedays);
                           }
                     } else {                      } else {
                         $newvalue = $offon[$env{'form.'.$key}];                          $newvalue = $offon[$env{'form.'.$key}];
                     }                      }

Removed from v.1.382  
changed lines
  Added in v.1.385


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