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

version 1.385, 2021/09/01 00:21:52 version 1.391, 2021/11/22 23:40:59
Line 297  sub handler { Line 297  sub handler {
                                  {col1 => 'Log-in Help',                                   {col1 => 'Log-in Help',
                                   col2 => 'Value'},                                    col2 => 'Value'},
                                  {col1 => 'Custom HTML in document head',                                   {col1 => 'Custom HTML in document head',
                                   col2 => 'Value'}],                                    col2 => 'Value'},
                                    {col1 => 'SSO',
                                     col2 => 'Dual login: SSO and non-SSO options'},
                                   ],
                       print => \&print_login,                        print => \&print_login,
                       modify => \&modify_login,                        modify => \&modify_login,
                     },                      },
Line 632  sub handler { Line 635  sub handler {
                                        {col1 => 'Log-in Help',                                         {col1 => 'Log-in Help',
                                         col2 => 'Value'},                                          col2 => 'Value'},
                                        {col1 => 'Custom HTML in document head',                                         {col1 => 'Custom HTML in document head',
                                         col2 => 'Value'}],                                          col2 => 'Value'},
                                          {col1 => 'SSO',
                                           col2 => 'Dual login: SSO and non-SSO options'},
                                         ],
                             print => \&print_login,                              print => \&print_login,
                             modify => \&modify_login,                              modify => \&modify_login,
                            };                             };
Line 859  sub print_config_box { Line 865  sub print_config_box {
         $output .= &wafproxy_javascript($dom);          $output .= &wafproxy_javascript($dom);
     } elsif ($action eq 'autoupdate') {      } elsif ($action eq 'autoupdate') {
         $output .= &autoupdate_javascript();          $output .= &autoupdate_javascript();
       } elsif ($action eq 'login') {
           $output .= &saml_javascript();
     }      }
     $output .=      $output .=
          '<table class="LC_nested_outer">           '<table class="LC_nested_outer">
Line 878  sub print_config_box { Line 886  sub print_config_box {
         my $leftnobr = '';          my $leftnobr = '';
         if (($action eq 'rolecolors') || ($action eq 'defaults') ||          if (($action eq 'rolecolors') || ($action eq 'defaults') ||
             ($action eq 'directorysrch') ||              ($action eq 'directorysrch') ||
             (($action eq 'login') && ($numheaders < 4))) {              (($action eq 'login') && ($numheaders < 5))) {
             $colspan = ' colspan="2"';              $colspan = ' colspan="2"';
         }          }
         if ($action eq 'usersessions') {          if ($action eq 'usersessions') {
Line 909  sub print_config_box { Line 917  sub print_config_box {
         } elsif ($action eq 'scantron') {          } elsif ($action eq 'scantron') {
             $output .= $item->{'print'}->($r,'top',$dom,$confname,$settings,\$rowtotal);              $output .= $item->{'print'}->($r,'top',$dom,$confname,$settings,\$rowtotal);
         } elsif ($action eq 'login') {          } elsif ($action eq 'login') {
             if ($numheaders == 4) {              if ($numheaders == 5) {
                 $colspan = ' colspan="2"';                  $colspan = ' colspan="2"';
                 $output .= &print_login('service',$dom,$confname,$phase,$settings,\$rowtotal);                  $output .= &print_login('service',$dom,$confname,$phase,$settings,\$rowtotal);
             } else {              } else {
Line 1050  sub print_config_box { Line 1058  sub print_config_box {
               <td class="LC_right_item"'.$colspan.'>'.&mt($item->{'header'}->[3]->{'col2'}).'</td></tr>'.                <td class="LC_right_item"'.$colspan.'>'.&mt($item->{'header'}->[3]->{'col2'}).'</td></tr>'.
                            $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);                             $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
         } elsif ($action eq 'login') {          } elsif ($action eq 'login') {
             if ($numheaders == 4) {              if ($numheaders == 5) {
                 $output .= &print_login('page',$dom,$confname,$phase,$settings,\$rowtotal).'                  $output .= &print_login('page',$dom,$confname,$phase,$settings,\$rowtotal).'
            </table>             </table>
           </td>            </td>
Line 1074  sub print_config_box { Line 1082  sub print_config_box {
            <td>             <td>
             <table class="LC_nested">              <table class="LC_nested">
              <tr class="LC_info_row">';               <tr class="LC_info_row">';
             if ($numheaders == 4) {              if ($numheaders == 5) {
                 $output .= '                  $output .= '
               <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[3]->{'col1'}).'</td>                <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[3]->{'col1'}).'</td>
               <td class="LC_right_item"'.$colspan.'>'.&mt($item->{'header'}->[3]->{'col2'}).'</td>                <td class="LC_right_item"'.$colspan.'>'.&mt($item->{'header'}->[3]->{'col2'}).'</td>
Line 1086  sub print_config_box { Line 1094  sub print_config_box {
              </tr>';               </tr>';
             }              }
             $rowtotal ++;              $rowtotal ++;
             $output .= &print_login('headtag',$dom,$confname,$phase,$settings,\$rowtotal);              $output .= &print_login('headtag',$dom,$confname,$phase,$settings,\$rowtotal).'
              </table>
             </td>
            </tr>
            <tr>
              <td>
               <table class="LC_nested">
                <tr class="LC_info_row">';
               if ($numheaders == 5) {
                   $output .= '
                 <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[4]->{'col1'}).'</td>
                 <td class="LC_right_item"'.$colspan.'>'.&mt($item->{'header'}->[4]->{'col2'}).'</td>
                </tr>';
               } else {
                   $output .= '
                 <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[3]->{'col1'}).'</td>
                 <td class="LC_right_item"'.$colspan.'>'.&mt($item->{'header'}->[3]->{'col2'}).'</td>
                </tr>';
               }
               $rowtotal ++;
               $output .= &print_login('saml',$dom,$confname,$phase,$settings,\$rowtotal);
         } elsif ($action eq 'requestcourses') {          } elsif ($action eq 'requestcourses') {
             $output .= &print_requestmail($dom,$action,$settings,\$rowtotal);              $output .= &print_requestmail($dom,$action,$settings,\$rowtotal);
             $rowtotal ++;              $rowtotal ++;
Line 1221  sub print_config_box { Line 1249  sub print_config_box {
   
 sub print_login {  sub print_login {
     my ($caller,$dom,$confname,$phase,$settings,$rowtotal) = @_;      my ($caller,$dom,$confname,$phase,$settings,$rowtotal) = @_;
     my ($css_class,$datatable);      my ($css_class,$datatable,$switchserver,%lt);
     my %choices = &login_choices();      my %choices = &login_choices();
       if (($caller eq 'help') || ($caller eq 'headtag') || ($caller eq 'saml')) {
           %lt = &login_file_options();
           $switchserver = &check_switchserver($dom,$confname);
       }
     if ($caller eq 'service') {      if ($caller eq 'service') {
         my %servers = &Apache::lonnet::internet_dom_servers($dom);          my %servers = &Apache::lonnet::internet_dom_servers($dom);
         my $choice = $choices{'disallowlogin'};          my $choice = $choices{'disallowlogin'};
Line 1417  sub print_login { Line 1448  sub print_login {
         $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal,\@logintext);          $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>';
     } elsif ($caller eq 'help') {      } elsif ($caller eq 'help') {
         my ($defaulturl,$defaulttype,%url,%type,%lt,%langchoices);          my ($defaulturl,$defaulttype,%url,%type,%langchoices);
         my $switchserver = &check_switchserver($dom,$confname);  
         my $itemcount = 1;          my $itemcount = 1;
         $defaulturl = '/adm/loginproblems.html';          $defaulturl = '/adm/loginproblems.html';
         $defaulttype = 'default';          $defaulttype = 'default';
         %lt = &Apache::lonlocal::texthash (  
                      del     => 'Delete?',  
                      rep     => 'Replace:',  
                      upl     => 'Upload:',  
                      default => 'Default',  
                      custom  => 'Custom',  
                                              );  
         %langchoices = &Apache::lonlocal::texthash(&get_languages_hash());          %langchoices = &Apache::lonlocal::texthash(&get_languages_hash());
         my @currlangs;          my @currlangs;
         if (ref($settings) eq 'HASH') {          if (ref($settings) eq 'HASH') {
Line 1525  sub print_login { Line 1548  sub print_login {
                 }                  }
             }              }
         }          }
         my %lt = &Apache::lonlocal::texthash(  
                                                del  => 'Delete?',  
                                                rep  => 'Replace:',  
                                                upl  => 'Upload:',  
                                                curr => 'View contents',  
                                                none => 'None',  
         );  
         my $switchserver = &check_switchserver($dom,$confname);  
         foreach my $lonhost (sort(keys(%domservers))) {          foreach my $lonhost (sort(keys(%domservers))) {
             my $exempt = &check_exempt_addresses($currexempt{$lonhost});              my $exempt = &check_exempt_addresses($currexempt{$lonhost});
             $datatable .= '<tr><td>'.$domservers{$lonhost}.'</td>';              $datatable .= '<tr><td>'.$domservers{$lonhost}.'</td>';
Line 1556  sub print_login { Line 1571  sub print_login {
             $datatable .= '</td><td><input type="text" name="loginheadtagexempt_'.$lonhost.'" value="'.$exempt.'" /></td></tr>';              $datatable .= '</td><td><input type="text" name="loginheadtagexempt_'.$lonhost.'" value="'.$exempt.'" /></td></tr>';
         }          }
         $datatable .= '</table></td></tr>';          $datatable .= '</table></td></tr>';
       } elsif ($caller eq 'saml') {
           my %domservers = &Apache::lonnet::get_servers($dom);
           $datatable .= '<tr><td colspan="3" style="text-align: left">'.
                         '<table><tr><th>'.$choices{'hostid'}.'</th>'.
                         '<th>'.$choices{'samllanding'}.'</th>'.
                         '<th>'.$choices{'samloptions'}.'</th></tr>'."\n";
           my (%saml,%samltext,%samlimg,%samlalt,%samlurl,%samltitle,%samlnotsso,%styleon,%styleoff);
           foreach my $lonhost (keys(%domservers)) {
               $samlurl{$lonhost} = '/adm/sso';
               $styleon{$lonhost} = 'display:none';
               $styleoff{$lonhost} = '';
           }
           if (ref($settings->{'saml'}) eq 'HASH') {
               foreach my $lonhost (keys(%{$settings->{'saml'}})) {
                   if (ref($settings->{'saml'}{$lonhost}) eq 'HASH') {
                       $saml{$lonhost} = 1;
                       $samltext{$lonhost} = $settings->{'saml'}{$lonhost}{'text'};
                       $samlimg{$lonhost} = $settings->{'saml'}{$lonhost}{'img'};
                       $samlalt{$lonhost} = $settings->{'saml'}{$lonhost}{'alt'};
                       $samlurl{$lonhost} = $settings->{'saml'}{$lonhost}{'url'};
                       $samltitle{$lonhost} = $settings->{'saml'}{$lonhost}{'title'};
                       $samlnotsso{$lonhost} = $settings->{'saml'}{$lonhost}{'notsso'};
                       $styleon{$lonhost} = '';
                       $styleoff{$lonhost} = 'display:none';
                   } else {
                       $styleon{$lonhost} = 'display:none';
                       $styleoff{$lonhost} = '';
                   }
               }
           }
           my $itemcount = 1;
           foreach my $lonhost (sort(keys(%domservers))) {
               my $samlon = ' ';
               my $samloff = ' checked="checked" ';
               if ($saml{$lonhost}) {
                   $samlon = $samloff;
                   $samloff = ' ';
               }
               my $css_class = $itemcount%2?' class="LC_odd_row"':'';
               $datatable .= '<tr'.$css_class.'><td><span class="LC_nobreak">'.$domservers{$lonhost}.'</span></td>'.
                             '<td><span class="LC_nobreak"><label><input type="radio" name="saml_'.$lonhost.'"'.$samloff.
                             'onclick="toggleSamlOptions(this.form,'."'$lonhost'".');" value="0" />'.
                             &mt('No').'</label>'.('&nbsp;'x2).
                             '<label><input type="radio" name="saml_'.$lonhost.'"'.$samlon.
                             'onclick="toggleSamlOptions(this.form,'."'$lonhost'".');" value="1" />'.
                             &mt('Yes').'</label></span></td>'.
                             '<td id="samloptionson_'.$lonhost.'" style="'.$styleon{$lonhost}.'" width="100%">'.
                             '<table><tr><th colspan="5" align="center">'.&mt('SSO').'</th><th align="center">'.
                             '<span class="LC_nobreak">'.&mt('Non-SSO').'</span></th></tr>'.
                             '<tr><th>'.&mt('Text').'</th><th>'.&mt('Image').'</th>'.
                             '<th>'.&mt('Alt Text').'</th><th>'.&mt('URL').'</th>'.
                             '<th>'.&mt('Tool Tip').'</th><th>'.&mt('Text').'</th></tr>'.
                             '<tr'.$css_class.'><td><input type="text" name="saml_text_'.$lonhost.'" size="8" value="'.
                             $samltext{$lonhost}.'" /></td><td>';
               if ($samlimg{$lonhost}) {
                   $datatable .= '<img src="'.$samlimg{$lonhost}.'" /><br />'.
                                 '<span class="LC_nobreak"><label>'.
                                 '<input type="checkbox" name="saml_img_del" value="'.$lonhost.'" />'.
                                 $lt{'del'}.'</label>&nbsp;'.$lt{'rep'}.'</span>';
               } else {
                   $datatable .= $lt{'upl'};
               }
               $datatable .='<br />';
               if ($switchserver) {
                   $datatable .= &mt('Upload to library server: [_1]',$switchserver);
               } else {
                   $datatable .= '<input type="file" name="saml_img_'.$lonhost.'" />';
               }
               $datatable .= '</td>'.
                             '<td><input type="text" name="saml_alt_'.$lonhost.'" size="20" '.
                             'value="'.$samlalt{$lonhost}.'" /></td>'.
                             '<td><input type="text" name="saml_url_'.$lonhost.'" size="8" '.
                             'value="'.$samlurl{$lonhost}.'" /></td>'.
                             '<td><textarea name="saml_title_'.$lonhost.'" rows="3" cols="15">'.
                             $samltitle{$lonhost}.'</textarea></td>'.
                             '<td><input type="text" name="saml_notsso_'.$lonhost.'" size="8" '.
                             'value="'.$samlnotsso{$lonhost}.'" /></td></tr>'.
                             '</table></td>'.
                             '<td id="samloptionsoff_'.$lonhost.'" style="'.$styleoff{$lonhost}.'" width="100%">&nbsp;</td></tr>';
              $itemcount ++;
           }
           $datatable .= '</table></td></tr>';
     }      }
     return $datatable;      return $datatable;
 }  }
Line 1592  sub login_choices { Line 1689  sub login_choices {
             headtag       => "Custom markup",              headtag       => "Custom markup",
             action        => "Action",              action        => "Action",
             current       => "Current",              current       => "Current",
               samllanding   => "Dual login?",
               samloptions   => "Options",
         );          );
     return %choices;      return %choices;
 }  }
   
   sub login_file_options {
         return &Apache::lonlocal::texthash(
                                              del     => 'Delete?',
                                              rep     => 'Replace:',
                                              upl     => 'Upload:',
                                              curr    => 'View contents',
                                              default => 'Default',
                                              custom  => 'Custom',
                                              none    => 'None',
         );
   }
   
 sub print_rolecolors {  sub print_rolecolors {
     my ($phase,$role,$dom,$confname,$settings,$rowtotal) = @_;      my ($phase,$role,$dom,$confname,$settings,$rowtotal) = @_;
     my %choices = &color_font_choices();      my %choices = &color_font_choices();
Line 3066  sub lti_javascript { Line 3177  sub lti_javascript {
         return $togglejs;          return $togglejs;
     }      }
     my (%ordered,$total,%jstext);      my (%ordered,$total,%jstext);
     $total = 0;      $total = scalar(keys(%{$settings}));
     foreach my $item (keys(%{$settings})) {      foreach my $item (keys(%{$settings})) {
         if (ref($settings->{$item}) eq 'HASH') {          if (ref($settings->{$item}) eq 'HASH') {
             my $num = $settings->{$item}{'order'};              my $num = $settings->{$item}{'order'};
               if ($num eq '') {
                   $num = $total - 1;
               }
             $ordered{$num} = $item;              $ordered{$num} = $item;
         }          }
     }      }
     $total = scalar(keys(%{$settings}));  
     my @jsarray = ();      my @jsarray = ();
     foreach my $item (sort {$a <=> $b } (keys(%ordered))) {      foreach my $item (sort {$a <=> $b } (keys(%ordered))) {
         push(@jsarray,$ordered{$item});          push(@jsarray,$ordered{$item});
Line 3136  sub lti_toggle_js { Line 3249  sub lti_toggle_js {
                             localauth => 'Local auth argument',                              localauth => 'Local auth argument',
                             krb       => 'Kerberos domain',                              krb       => 'Kerberos domain',
                          );                           );
       my $crsincalert = &mt('"User\'s identity sent" needs to be set to "Yes" first,[_1] before setting "Course\'s identity sent" to "Yes"',"\n");
       &js_escape(\$crsincalert);
     return <<"ENDSCRIPT";      return <<"ENDSCRIPT";
 <script type="text/javascript">  <script type="text/javascript">
 // <![CDATA[  // <![CDATA[
   
 function toggleLTI(form,setting,item) {  function toggleLTI(form,setting,item) {
     if (setting == 'requser') {      if ((setting == 'requser') || (setting == 'crsinc')) {
         var fieldsets = document.getElementsByClassName('ltioption_'+item);          var usrfieldsets = document.getElementsByClassName('ltioption_usr_'+item);
         if (fieldsets.length) {          var setvis = '';
             var radioname = 'lti_'+setting+'_'+item;          var radioname = 'lti_requser_'+item;
           var num = form.elements[radioname].length;
           if (num) {
               for (var i=0; i<num; i++) {
                   if (form.elements[radioname][i].checked) {
                       if (form.elements[radioname][i].value == '1') {
                           setvis = 1;
                           break;
                       }
                   }
               }
           }
           if (usrfieldsets.length) {
               for (var j=0; j<usrfieldsets.length; j++) {
                   if (setvis) {
                       usrfieldsets[j].style.display = 'block';
                   } else {
                       usrfieldsets[j].style.display = 'none';
                   }
               }
           }
           var crsfieldsets = document.getElementsByClassName('ltioption_crs_'+item);
           if (crsfieldsets.length) {
               radioname = 'lti_crsinc_'+item;
             var num = form.elements[radioname].length;              var num = form.elements[radioname].length;
             if (num) {              if (num) {
                 var setvis = '';                  var crsvis = '';
                 for (var i=0; i<num; i++) {                  for (var i=0; i<num; i++) {
                     if (form.elements[radioname][i].checked) {                      if (form.elements[radioname][i].checked) {
                         if (form.elements[radioname][i].value == '1') {                          if (form.elements[radioname][i].value == '1') {
                            setvis = 1;                              if (setvis == '') {
                            break;                                  if (setting == 'crsinc'){
                                       alert("$crsincalert");
                                       form.elements[radioname][0].checked = true;
                                   }
                               } else {
                                   crsvis = 1;
                               }
                               break;
                         }                          }
                     }                      }
                 }                  }
                 for (var j=0; j<fieldsets.length; j++) {                  setvis = crsvis;
                     if (setvis) {              }
                         fieldsets[j].style.display = 'block';              for (var j=0; j<crsfieldsets.length; j++) {
                     } else {                  if (setvis) {
                         fieldsets[j].style.display = 'none';                      crsfieldsets[j].style.display = 'block';
                     }                  } else {
                       crsfieldsets[j].style.display = 'none';
                 }                  }
             }              }
         }          }
Line 3348  function toggleLastActiveDays(form) { Line 3494  function toggleLastActiveDays(form) {
 ENDSCRIPT  ENDSCRIPT
 }  }
   
   sub saml_javascript {
       return <<"ENDSCRIPT";
   <script type="text/javascript">
   // <![CDATA[
   function toggleSamlOptions(form,hostid) { 
       var radioname = 'saml_'+hostid;
       var tablecellon = 'samloptionson_'+hostid;
       var tablecelloff = 'samloptionsoff_'+hostid;
       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(tablecellon)) {
                           document.getElementById(tablecellon).style.display='';
                       }
                       if (document.getElementById(tablecelloff)) {
                           document.getElementById(tablecelloff).style.display='none';
                       }
                       setvis = 1;
                   }
                   break;
               }
           }
           if (!setvis) {
               if (document.getElementById(tablecellon)) {
                   document.getElementById(tablecellon).style.display='none';
               }
               if (document.getElementById(tablecelloff)) {
                   document.getElementById(tablecelloff).style.display='';
               }
           }
       }
       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 5784  sub print_lti { Line 5972  sub print_lti {
         foreach my $item (keys(%{$settings})) {          foreach my $item (keys(%{$settings})) {
             if (ref($settings->{$item}) eq 'HASH') {              if (ref($settings->{$item}) eq 'HASH') {
                 my $num = $settings->{$item}{'order'};                  my $num = $settings->{$item}{'order'};
                   if ($num eq '') {
                       $num = scalar(keys(%{$settings}));
                   }
                 $ordered{$num} = $item;                  $ordered{$num} = $item;
             }              }
         }          }
Line 5796  sub print_lti { Line 5987  sub print_lti {
         for (my $i=0; $i<@items; $i++) {          for (my $i=0; $i<@items; $i++) {
             $css_class = $itemcount%2?' class="LC_odd_row"':'';              $css_class = $itemcount%2?' class="LC_odd_row"':'';
             my $item = $ordered{$items[$i]};              my $item = $ordered{$items[$i]};
             my ($key,$secret,$lifetime,$consumer,$requser,$current);              my ($key,$secret,$lifetime,$consumer,$requser,$crsinc,$current);
             if (ref($settings->{$item}) eq 'HASH') {              if (ref($settings->{$item}) eq 'HASH') {
                 $key = $settings->{$item}->{'key'};                  $key = $settings->{$item}->{'key'};
                 $secret = $settings->{$item}->{'secret'};                  $secret = $settings->{$item}->{'secret'};
                 $lifetime = $settings->{$item}->{'lifetime'};                  $lifetime = $settings->{$item}->{'lifetime'};
                 $consumer = $settings->{$item}->{'consumer'};                  $consumer = $settings->{$item}->{'consumer'};
                 $requser = $settings->{$item}->{'requser'};                  $requser = $settings->{$item}->{'requser'};
                   $crsinc = $settings->{$item}->{'crsinc'};
                 $current = $settings->{$item};                  $current = $settings->{$item};
             }              }
             my $onclickrequser = ' onclick="toggleLTI(this.form,'."'requser','$i'".');"';              my $onclickrequser = ' onclick="toggleLTI(this.form,'."'requser','$i'".');"';
Line 5814  sub print_lti { Line 6006  sub print_lti {
                 $checkedrequser{'no'} = $checkedrequser{'yes'};                  $checkedrequser{'no'} = $checkedrequser{'yes'};
                 $checkedrequser{'yes'} = '';                  $checkedrequser{'yes'} = '';
             }              }
               my $onclickcrsinc = ' onclick="toggleLTI(this.form,'."'crsinc','$i'".');"';
               my %checkedcrsinc = (
                                         yes => ' checked="checked"',
                                         no  => '',
                                      );
               if (!$crsinc) {
                   $checkedcrsinc{'no'} = $checkedcrsinc{'yes'};
                   $checkedcrsinc{'yes'} = '';
               }
             my $chgstr = ' onchange="javascript:reorderLTI(this.form,'."'lti_pos_".$item."'".');"';              my $chgstr = ' onchange="javascript:reorderLTI(this.form,'."'lti_pos_".$item."'".');"';
             $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'              $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'
                          .'<select name="lti_pos_'.$item.'"'.$chgstr.'>';                           .'<select name="lti_pos_'.$item.'"'.$chgstr.'>';
Line 5843  sub print_lti { Line 6044  sub print_lti {
                  '<label><input type="radio" name="lti_requser_'.$i.'" value="1"'.$onclickrequser.$checkedrequser{yes}.' />'.&mt('Yes').'</label>&nbsp;'."\n".                   '<label><input type="radio" name="lti_requser_'.$i.'" value="1"'.$onclickrequser.$checkedrequser{yes}.' />'.&mt('Yes').'</label>&nbsp;'."\n".
                  '<label><input type="radio" name="lti_requser_'.$i.'" value="0"'.$onclickrequser.$checkedrequser{no}.' />'.&mt('No').'</label></span>'."\n".                   '<label><input type="radio" name="lti_requser_'.$i.'" value="0"'.$onclickrequser.$checkedrequser{no}.' />'.&mt('No').'</label></span>'."\n".
                 '<br /><br />'.                  '<br /><br />'.
                   '<span class="LC_nobreak">'.$lt{'crsinc'}.':'.
                   '<label><input type="radio" name="lti_crsinc_'.$i.'" value="1"'.$onclickcrsinc.$checkedcrsinc{yes}.' />'.&mt('Yes').'</label>&nbsp;'."\n".
                   '<label><input type="radio" name="lti_crsinc_'.$i.'" value="0"'.$onclickcrsinc.$checkedcrsinc{no}.' />'.&mt('No').'</label></span>'."\n".
                   ('&nbsp;'x4).
                 '<span class="LC_nobreak">'.$lt{'key'}.                  '<span class="LC_nobreak">'.$lt{'key'}.
                 ':<input type="text" size="25" name="lti_key_'.$i.'" value="'.$key.'" /></span> '.                  ':<input type="text" size="25" name="lti_key_'.$i.'" value="'.$key.'" /></span> '.
                 ('&nbsp;'x2).                  ('&nbsp;'x2).
Line 5883  sub print_lti { Line 6088  sub print_lti {
                   '<label><input type="radio" name="lti_requser_add" value="1" onclick="toggleLTI(this.form,'."'requser','add'".');" checked="checked" />'.&mt('Yes').'</label>&nbsp;'."\n".                    '<label><input type="radio" name="lti_requser_add" value="1" onclick="toggleLTI(this.form,'."'requser','add'".');" checked="checked" />'.&mt('Yes').'</label>&nbsp;'."\n".
                   '<label><input type="radio" name="lti_requser_add" value="0" onclick="toggleLTI(this.form,'."'requser','add'".');" />'.&mt('No').'</label></span>'."\n".                    '<label><input type="radio" name="lti_requser_add" value="0" onclick="toggleLTI(this.form,'."'requser','add'".');" />'.&mt('No').'</label></span>'."\n".
                   '<br /><br />'.                    '<br /><br />'.
                     '<span class="LC_nobreak">'.$lt{'crsinc'}.':'.
                     '<label><input type="radio" name="lti_crsinc_add" value="1" onclick="toggleLTI(this.form,'."'crsinc','add'".');" checked="checked" />'.&mt('Yes').'</label>&nbsp;'."\n".
                     '<label><input type="radio" name="lti_crsinc_add" value="0" onclick="toggleLTI(this.form,'."'crsinc','add'".');" />'.&mt('No').'</label></span>'."\n".
                     ('&nbsp;'x4).
                   '<span class="LC_nobreak">'.$lt{'key'}.':<input type="text" size="25" name="lti_key_add" value="" /></span> '."\n".                    '<span class="LC_nobreak">'.$lt{'key'}.':<input type="text" size="25" name="lti_key_add" value="" /></span> '."\n".
                   ('&nbsp;'x2).                    ('&nbsp;'x2).
                   '<span class="LC_nobreak">'.$lt{'secret'}.':<input type="password" size="20" name="lti_secret_add" value="" />'.                    '<span class="LC_nobreak">'.$lt{'secret'}.':<input type="password" size="20" name="lti_secret_add" value="" />'.
Line 5903  sub lti_names { Line 6112  sub lti_names {
                                           'consumer'  => 'Consumer',                                            'consumer'  => 'Consumer',
                                           'secret'    => 'Secret',                                            'secret'    => 'Secret',
                                           'requser'   => "User's identity sent",                                            'requser'   => "User's identity sent",
                                             'crsinc'    => "Course's identity sent",
                                           'email'     => 'Email address',                                            'email'     => 'Email address',
                                           'sourcedid' => 'User ID',                                            'sourcedid' => 'User ID',
                                           'other'     => 'Other',                                            'other'     => 'Other',
Line 5937  sub lti_options { Line 6147  sub lti_options {
     my $callbacksty = 'none';      my $callbacksty = 'none';
     my $passbacksty = 'none';      my $passbacksty = 'none';
     my $optionsty = 'block';      my $optionsty = 'block';
       my $crssty = 'block';
     my $lcauthparm;      my $lcauthparm;
     my $lcauthparmstyle = 'display:none';      my $lcauthparmstyle = 'display:none';
     my $lcauthparmtext;      my $lcauthparmtext;
Line 5947  sub lti_options { Line 6158  sub lti_options {
     if (ref($current) eq 'HASH') {      if (ref($current) eq 'HASH') {
         if (!$current->{'requser'}) {          if (!$current->{'requser'}) {
             $optionsty = 'none';              $optionsty = 'none';
               $crssty = 'none';
           } elsif (!$current->{'crsinc'}) {
               $crssty = 'none';
         }          }
         if (($current->{'mapuser'} ne '') && ($current->{'mapuser'} ne 'lis_person_sourcedid')) {          if (($current->{'mapuser'} ne '') && ($current->{'mapuser'} ne 'lis_person_sourcedid')) {
             $checked{'mapuser'}{'sourcedid'} = '';              $checked{'mapuser'}{'sourcedid'} = '';
Line 6079  sub lti_options { Line 6293  sub lti_options {
     my $onclicksecsrc = ' onclick="toggleLTI(this.form,'."'secsrc','$num'".')"';      my $onclicksecsrc = ' onclick="toggleLTI(this.form,'."'secsrc','$num'".')"';
     my $onclicklcauth = ' onclick="toggleLTI(this.form,'."'lcauth','$num'".')"';      my $onclicklcauth = ' onclick="toggleLTI(this.form,'."'lcauth','$num'".')"';
     my $onclickmenu = ' onclick="toggleLTI(this.form,'."'lcmenu','$num'".');"';      my $onclickmenu = ' onclick="toggleLTI(this.form,'."'lcmenu','$num'".');"';
     my $output = '<fieldset class="ltioption_'.$num.'" style="display:'.$optionsty.'"><legend>'.&mt('Mapping users').'</legend>'.      my $output = '<fieldset class="ltioption_usr_'.$num.'" style="display:'.$optionsty.'"><legend>'.&mt('Logout options').'</legend>'.
                    '<div class="LC_floatleft"><span class="LC_nobreak">'.&mt('Callback on logout').':&nbsp;'.
                    '<label><input type="radio" name="lti_callback_'.$num.'" value="0"'.
                    $checked{'callback'}{'N'}.$onclickcallback.' />'.&mt('No').'</label>'.('&nbsp;'x2).
                    '<label><input type="radio" name="lti_callback_'.$num.'" value="1"'.
                    $checked{'callback'}{'Y'}.$onclickcallback.' />'.&mt('Yes').'</label></span></div>'.
                    '<div class="LC_floatleft" style="display:'.$callbacksty.';" id="lti_callbackfield_'.$num.'">'.
                    '<span class="LC_nobreak">'.&mt('Parameter').': '.
                    '<input type="text" name="lti_callbackparam_'.$num.'" value="'.$callback.'" /></span>'.
                    '</div><div style="padding:0;clear:both;margin:0;border:0"></div></fieldset>'.
                    '<fieldset class="ltioption_usr_'.$num.'" style="display:'.$optionsty.'"><legend>'.&mt('Mapping users').'</legend>'.
                  '<div class="LC_floatleft"><span class="LC_nobreak">'.&mt('LON-CAPA username').':&nbsp;';                   '<div class="LC_floatleft"><span class="LC_nobreak">'.&mt('LON-CAPA username').':&nbsp;';
     foreach my $option ('sourcedid','email','other') {      foreach my $option ('sourcedid','email','other') {
         $output .= '<label><input type="radio" name="lti_mapuser_'.$num.'" value="'.$option.'"'.          $output .= '<label><input type="radio" name="lti_mapuser_'.$num.'" value="'.$option.'"'.
Line 6090  sub lti_options { Line 6314  sub lti_options {
                '<div class="LC_floatleft" style="display:'.$userfieldsty.';" id="lti_userfield_'.$num.'">'.                 '<div class="LC_floatleft" style="display:'.$userfieldsty.';" id="lti_userfield_'.$num.'">'.
                '<input type="text" name="lti_customuser_'.$num.'" '.                 '<input type="text" name="lti_customuser_'.$num.'" '.
                'value="'.$userfield.'" /></div></fieldset>'.                 'value="'.$userfield.'" /></div></fieldset>'.
                '<fieldset class="ltioption_'.$num.'" style="display:'.$optionsty.'"><legend>'.&mt('Mapping course roles').'</legend><table><tr>';                 '<fieldset class="ltioption_usr_'.$num.'" style="display:'.$optionsty.'"><legend>'.&mt('Roles which may create user accounts').'</legend>';
     foreach my $ltirole (@lticourseroles) {  
         my ($selected,$selectnone);  
         if ($rolemaps{$ltirole} eq '') {  
             $selectnone = ' selected="selected"';  
         }  
         $output .= '<td style="text-align: center">'.$ltirole.'<br />'.  
                    '<select name="lti_maprole_'.$ltirole.'_'.$num.'">'.  
                    '<option value=""'.$selectnone.'>'.&mt('Select').'</option>';  
         foreach my $role (@courseroles) {  
             unless ($selectnone) {  
                 if ($rolemaps{$ltirole} eq $role) {  
                     $selected = ' selected="selected"';  
                 } else {  
                     $selected = '';  
                 }  
             }  
             $output .= '<option value="'.$role.'"'.$selected.'>'.  
                        &Apache::lonnet::plaintext($role,'Course').  
                        '</option>';  
         }  
         $output .= '</select></td>';  
     }  
     $output .= '</tr></table></fieldset>'.  
                '<fieldset class="ltioption_'.$num.'" style="display:'.$optionsty.'"><legend>'.&mt('Roles which may create user accounts').'</legend>';  
     foreach my $ltirole (@ltiroles) {      foreach my $ltirole (@ltiroles) {
         $output .= '<span class="LC_nobreak"><label><input type="checkbox" name="lti_makeuser_'.$num.'" value="'.$ltirole.'"'.          $output .= '<span class="LC_nobreak"><label><input type="checkbox" name="lti_makeuser_'.$num.'" value="'.$ltirole.'"'.
                    $checked{'makeuser'}{$ltirole}.' />'.$ltirole.'</label>&nbsp;</span> ';                          $checked{'makeuser'}{$ltirole}.' />'.$ltirole.'</label>&nbsp;</span> ';     
     }      }
     $output .= '</fieldset>'.      $output .= '</fieldset>'.
                '<fieldset class="ltioption_'.$num.'" style="display:'.$optionsty.'"><legend>'.&mt('New user accounts created for LTI users').'</legend>'.                 '<fieldset class="ltioption_usr_'.$num.'" style="display:'.$optionsty.'"><legend>'.&mt('New user accounts created for LTI users').'</legend>'.
                '<table>'.                 '<table>'.
                &modifiable_userdata_row('lti','instdata_'.$num,$current,$numinrow,$itemcount).                 &modifiable_userdata_row('lti','instdata_'.$num,$current,$numinrow,$itemcount).
                '</table>'.                 '</table>'.
Line 6143  sub lti_options { Line 6343  sub lti_options {
                '<span id="lti_lcauth_parmtext_'.$num.'">'.$lcauthparmtext.'</span>'.                 '<span id="lti_lcauth_parmtext_'.$num.'">'.$lcauthparmtext.'</span>'.
                '<input type="text" name="lti_lcauthparm_'.$num.'" value="" /></span></td></tr>'.                 '<input type="text" name="lti_lcauthparm_'.$num.'" value="" /></span></td></tr>'.
                '</table></fieldset>'.                 '</table></fieldset>'.
                '<fieldset class="ltioption_'.$num.'" style="display:'.$optionsty.'"><legend>'.&mt('Mapping courses').'</legend>'.                 '<fieldset class="ltioption_usr_'.$num.'" style="display:'.$optionsty.'"><legend>'.
                  &mt('LON-CAPA menu items (Course Coordinator can override)').'</legend>'.
                  '<div class="LC_floatleft"><span class="LC_nobreak">'.$lt{'topmenu'}.':&nbsp;'.
                  '<label><input type="radio" name="lti_topmenu_'.$num.'" value="0"'.
                  $checked{'topmenu'}{'N'}.$onclickmenu.' />'.&mt('No').'</label>'.('&nbsp;'x2).
                  '<label><input type="radio" name="lti_topmenu_'.$num.'" value="1"'.
                  $checked{'topmenu'}{'Y'}.$onclickmenu.' />'.&mt('Yes').'</label></span></div>'.
                  '<div style="padding:0;clear:both;margin:0;border:0"></div>'.
                  '<div class="LC_floatleft"><span class="LC_nobreak">'.$lt{'inlinemenu'}.':&nbsp;'.
                  '<label><input type="radio" name="lti_inlinemenu_'.$num.'" value="0"'.
                  $checked{'inlinemenu'}{'N'}.$onclickmenu.' />'.&mt('No').'</label>'.('&nbsp;'x2).
                  '<label><input type="radio" name="lti_inlinemenu_'.$num.'" value="1"'.
                  $checked{'inlinemenu'}{'Y'}.$onclickmenu.' />'.&mt('Yes').'</label></span></div>';
        $output .='<div style="padding:0;clear:both;margin:0;border:0"></div>'.
                  '<div class="LC_floatleft" style="display:'.$menusty.';" id="lti_menufield_'.$num.'">'.
                  '<span class="LC_nobreak">'.&mt('Menu items').':&nbsp;';
       foreach my $type ('fullname','coursetitle','role','logout','grades') {
           $output .= '<label><input type="checkbox" name="lti_menuitem_'.$num.'" value="'.$type.'"'.
                      $checked{'menuitem'}{$type}.' />'.$menutitles{$type}.'</label>'.
                      ('&nbsp;'x2);
       }
       $output .= '</span></div></fieldset>'.
                  '<fieldset class="ltioption_crs_'.$num.'" style="display:'.$crssty.'"><legend>'.&mt('Mapping courses').'</legend>'.
                '<div class="LC_floatleft"><span class="LC_nobreak">'.                 '<div class="LC_floatleft"><span class="LC_nobreak">'.
                &mt('Unique course identifier').':&nbsp;';                 &mt('Unique course identifier').':&nbsp;';
     foreach my $option ('course_offering_sourcedid','context_id','other') {      foreach my $option ('course_offering_sourcedid','context_id','other') {
Line 6161  sub lti_options { Line 6383  sub lti_options {
                    ('&nbsp;'x2);                     ('&nbsp;'x2);
     }      }
     $output .= '</span></fieldset>'.      $output .= '</span></fieldset>'.
                '<fieldset class="ltioption_'.$num.'" style="display:'.$optionsty.'"><legend>'.&mt('Creating courses').'</legend>'.                 '<fieldset class="ltioption_crs_'.$num.'" style="display:'.$crssty.'"><legend>'.&mt('Mapping course roles').'</legend><table><tr>';
       foreach my $ltirole (@lticourseroles) {
           my ($selected,$selectnone);
           if ($rolemaps{$ltirole} eq '') {
               $selectnone = ' selected="selected"';
           }
           $output .= '<td style="text-align: center">'.$ltirole.'<br />'.
                      '<select name="lti_maprole_'.$ltirole.'_'.$num.'">'.
                      '<option value=""'.$selectnone.'>'.&mt('Select').'</option>';
           foreach my $role (@courseroles) {
               unless ($selectnone) {
                   if ($rolemaps{$ltirole} eq $role) {
                       $selected = ' selected="selected"';
                   } else {
                       $selected = '';
                   }
               }
               $output .= '<option value="'.$role.'"'.$selected.'>'.
                          &Apache::lonnet::plaintext($role,'Course').
                          '</option>';
           }
           $output .= '</select></td>';
       }
       $output .= '</tr></table></fieldset>'.
                  '<fieldset class="ltioption_crs_'.$num.'" style="display:'.$crssty.'"><legend>'.&mt('Creating courses').'</legend>'.
                '<span class="LC_nobreak">'.&mt('Course created (if absent) on Instructor access').':&nbsp;'.                 '<span class="LC_nobreak">'.&mt('Course created (if absent) on Instructor access').':&nbsp;'.
                '<label><input type="radio" name="lti_makecrs_'.$num.'" value="0"'.                 '<label><input type="radio" name="lti_makecrs_'.$num.'" value="0"'.
                $checked{'makecrs'}{'N'}.' />'.&mt('No').'</label>'.('&nbsp;'x2).                 $checked{'makecrs'}{'N'}.' />'.&mt('No').'</label>'.('&nbsp;'x2).
                '<label><input type="radio" name="lti_makecrs_'.$num.'" value="1"'.                 '<label><input type="radio" name="lti_makecrs_'.$num.'" value="1"'.
                $checked{'makecrs'}{'Y'}.' />'.&mt('Yes').'</label></span>'.                 $checked{'makecrs'}{'Y'}.' />'.&mt('Yes').'</label></span>'.
                '</fieldset>'.                 '</fieldset>'.
                '<fieldset class="ltioption_'.$num.'" style="display:'.$optionsty.'"><legend>'.&mt('Roles which may self-enroll').'</legend>';                 '<fieldset class="ltioption_crs_'.$num.'" style="display:'.$crssty.'"><legend>'.&mt('Roles which may self-enroll').'</legend>';
     foreach my $lticrsrole (@lticourseroles) {      foreach my $lticrsrole (@lticourseroles) {
         $output .= '<span class="LC_nobreak"><label><input type="checkbox" name="lti_selfenroll_'.$num.'" value="'.$lticrsrole.'"'.          $output .= '<span class="LC_nobreak"><label><input type="checkbox" name="lti_selfenroll_'.$num.'" value="'.$lticrsrole.'"'.
                    $checked{'selfenroll'}{$lticrsrole}.' />'.$lticrsrole.'</label>&nbsp;</span> ';                     $checked{'selfenroll'}{$lticrsrole}.' />'.$lticrsrole.'</label>&nbsp;</span> ';
     }      }
     $output .= '</fieldset>'.      $output .= '</fieldset>'.
                '<fieldset class="ltioption_'.$num.'" style="display:'.$optionsty.'"><legend>'.&mt('Course options').'</legend>'.                 '<fieldset class="ltioption_crs_'.$num.'" style="display:'.$crssty.'"><legend>'.&mt('Course options').'</legend>'.
                '<div class="LC_floatleft"><span class="LC_nobreak">'.&mt('Assign users to sections').':&nbsp;'.                 '<div class="LC_floatleft"><span class="LC_nobreak">'.&mt('Assign users to sections').':&nbsp;'.
                '<label><input type="radio" name="lti_crssec_'.$num.'" value="0"'.                 '<label><input type="radio" name="lti_crssec_'.$num.'" value="0"'.
                $checked{'crssec'}{'N'}.$onclicksec.' />'.&mt('No').'</label>'.('&nbsp;'x2).                 $checked{'crssec'}{'N'}.$onclicksec.' />'.&mt('No').'</label>'.('&nbsp;'x2).
Line 6226  sub lti_options { Line 6472  sub lti_options {
                &mt('Outcomes Service (1.1)').'</label>'.('&nbsp;'x2).                 &mt('Outcomes Service (1.1)').'</label>'.('&nbsp;'x2).
                '<label><input type="radio" name="lti_passbackformat_'.$num.'" value="1.0"'.$pb1p0chk.'/>'.                 '<label><input type="radio" name="lti_passbackformat_'.$num.'" value="1.0"'.$pb1p0chk.'/>'.
                &mt('Outcomes Extension (1.0)').'</label></span></div>'.                 &mt('Outcomes Extension (1.0)').'</label></span></div>'.
                '<div style="padding:0;clear:both;margin:0;border:0"></div>'.                 '<div style="padding:0;clear:both;margin:0;border:0"></div></fieldset>';
                '<div class="LC_floatleft"><span class="LC_nobreak">'.&mt('Callback on logout').':&nbsp;'.  
                '<label><input type="radio" name="lti_callback_'.$num.'" value="0"'.  
                $checked{'callback'}{'N'}.$onclickcallback.' />'.&mt('No').'</label>'.('&nbsp;'x2).  
                '<label><input type="radio" name="lti_callback_'.$num.'" value="1"'.  
                $checked{'callback'}{'Y'}.$onclickcallback.' />'.&mt('Yes').'</label></span></div>'.  
                '<div class="LC_floatleft" style="display:'.$callbacksty.';" id="lti_callbackfield_'.$num.'">'.  
                '<span class="LC_nobreak">'.&mt('Parameter').': '.  
                '<input type="text" name="lti_callbackparam_'.$num.'" value="'.$callback.'" /></span>'.  
                '</div><div style="padding:0;clear:both;margin:0;border:0"></div></fieldset>'.  
                '<fieldset class="ltioption_'.$num.'" style="display:'.$optionsty.'"><legend>'.&mt('Course defaults (Course Coordinator can override)').'</legend>'.  
                '<div class="LC_floatleft"><span class="LC_nobreak">'.$lt{'topmenu'}.':&nbsp;'.  
                '<label><input type="radio" name="lti_topmenu_'.$num.'" value="0"'.  
                $checked{'topmenu'}{'N'}.$onclickmenu.' />'.&mt('No').'</label>'.('&nbsp;'x2).  
                '<label><input type="radio" name="lti_topmenu_'.$num.'" value="1"'.  
                $checked{'topmenu'}{'Y'}.$onclickmenu.' />'.&mt('Yes').'</label></span></div>'.  
                '<div style="padding:0;clear:both;margin:0;border:0"></div>'.  
                '<div class="LC_floatleft"><span class="LC_nobreak">'.$lt{'inlinemenu'}.':&nbsp;'.  
                '<label><input type="radio" name="lti_inlinemenu_'.$num.'" value="0"'.  
                $checked{'inlinemenu'}{'N'}.$onclickmenu.' />'.&mt('No').'</label>'.('&nbsp;'x2).  
                '<label><input type="radio" name="lti_inlinemenu_'.$num.'" value="1"'.  
                $checked{'inlinemenu'}{'Y'}.$onclickmenu.' />'.&mt('Yes').'</label></span></div>';  
      $output .='<div style="padding:0;clear:both;margin:0;border:0"></div>'.   
                '<div class="LC_floatleft" style="display:'.$menusty.';" id="lti_menufield_'.$num.'">'.  
                '<span class="LC_nobreak">'.&mt('Menu items').':&nbsp;';  
     foreach my $type ('fullname','coursetitle','role','logout','grades') {  
         $output .= '<label><input type="checkbox" name="lti_menuitem_'.$num.'" value="'.$type.'"'.  
                    $checked{'menuitem'}{$type}.' />'.$menutitles{$type}.'</label>'.  
                    ('&nbsp;'x2);  
     }  
     $output .= '</span></div></fieldset>';      $output .= '</span></div></fieldset>';
 #        '<fieldset><legend>'.&mt('Assigning author roles').'</legend>';  #        '<fieldset><legend>'.&mt('Assigning author roles').'</legend>';
 #  #
Line 7365  sub print_wafproxy { Line 7582  sub print_wafproxy {
     my $itemcount = 0;      my $itemcount = 0;
     my $datatable;      my $datatable;
     my %servers = &Apache::lonnet::internet_dom_servers($dom);      my %servers = &Apache::lonnet::internet_dom_servers($dom);
     my (%othercontrol,%otherdoms,%aliases,%values,$setdom,$showdom);      my (%othercontrol,%otherdoms,%aliases,%saml,%values,$setdom,$showdom);
     my %lt = &wafproxy_titles();      my %lt = &wafproxy_titles();
     foreach my $server (sort(keys(%servers))) {      foreach my $server (sort(keys(%servers))) {
         my $serverhome = &Apache::lonnet::get_server_homeID($servers{$server});          my $serverhome = &Apache::lonnet::get_server_homeID($servers{$server});
Line 7390  sub print_wafproxy { Line 7607  sub print_wafproxy {
                             $showdom = 1;                              $showdom = 1;
                         }                          }
                     }                      }
                       if (ref($settings->{'saml'}) eq 'HASH') {
                           $saml{$dom} = $settings->{'saml'};
                       }
                 }                  }
             }              }
         }          }
Line 7409  sub print_wafproxy { Line 7629  sub print_wafproxy {
             my %config = &Apache::lonnet::get_dom('configuration',['wafproxy'],$domain);              my %config = &Apache::lonnet::get_dom('configuration',['wafproxy'],$domain);
             if (ref($config{'wafproxy'}) eq 'HASH') {              if (ref($config{'wafproxy'}) eq 'HASH') {
                 $aliases{$domain} = $config{'wafproxy'}{'alias'};                  $aliases{$domain} = $config{'wafproxy'}{'alias'};
                   if (exists($config{'wafproxy'}{'saml'})) { 
                       $saml{$domain} = $config{'wafproxy'}{'saml'};
                   }
                 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{'wafproxy'}{$item};
                 }                  }
Line 7427  sub print_wafproxy { Line 7650  sub print_wafproxy {
                             '<i>'.&Apache::lonnet::hostname($server).'</i></td><td>&nbsp;</td>';                              '<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,$forsaml);
                 if (ref($aliases{$dom_in_effect}) eq 'HASH') {                  if (ref($aliases{$dom_in_effect}) eq 'HASH') {
                     $current = $aliases{$dom_in_effect}{$server};                      $current = $aliases{$dom_in_effect}{$server};
                 }                  }
                   if (ref($saml{$dom_in_effect}) eq 'HASH') {
                       if ($saml{$dom_in_effect}{$server}) {
                           $forsaml = 1;
                       }
                   }
                 $aliasrows .= '<td class="LC_left_item" style="vertical-align: baseline;">'.                  $aliasrows .= '<td class="LC_left_item" style="vertical-align: baseline;">'.
                               &mt('Alias').':&nbsp';                                &mt('Alias').':&nbsp';
                 if ($current) {                  if ($current) {
                     $aliasrows .= $current;                      $aliasrows .= $current;
                       if ($forsaml) {
                            $aliasrows .= '&nbsp;('.&mt('also for Shibboleth').')';
                       }
                 } else {                  } else {
                     $aliasrows .= &mt('None');                      $aliasrows .= &mt('None');
                 }                  }
Line 7443  sub print_wafproxy { Line 7674  sub print_wafproxy {
                                   '<b>'.$dom_in_effect.'</b>').')</span></td>';                                    '<b>'.$dom_in_effect.'</b>').')</span></td>';
             } else {              } else {
                 $dom_in_effect = $dom;                  $dom_in_effect = $dom;
                 my $current;                  my ($current,$samlon,$samloff);
                   $samloff = ' checked="checked"';
                 if (ref($aliases{$dom}) eq 'HASH') {                  if (ref($aliases{$dom}) eq 'HASH') {
                     if ($aliases{$dom}{$server}) {                      if ($aliases{$dom}{$server}) {
                         $current = $aliases{$dom}{$server};                          $current = $aliases{$dom}{$server};
                     }                      }
                 }                  }
                   if (ref($saml{$dom}) eq 'HASH') {
                       if ($saml{$dom}{$server}) {
                           $samlon = $samloff;
                           undef($samloff);
                       }
                   }
                 $aliasrows .= '<td class="LC_left_item" style="vertical-align: baseline;">'.                  $aliasrows .= '<td class="LC_left_item" style="vertical-align: baseline;">'.
                               &mt('Alias').':&nbsp;'.                                &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" />'.
                                 ('&nbsp;'x2).'<span class="LC_nobreak">'.
                                 &mt('Alias used for Shibboleth').':&nbsp;<label>'.
                                 '<input type="radio" value="0"'.$samloff.' name="wafproxy_alias_saml_'.$server.'" />'.
                                 &mt('No').'</label>&nbsp;<label>'. 
                                 '<input type="radio" value="1"'.$samlon.' name="wafproxy_alias_saml_'.$server.'" />'.
                                 &mt('Yes').'</label></span>'.
                                 '</td>'; 
             }              }
             $aliasrows .= '</tr>';              $aliasrows .= '</tr>';
             $aliasinfo{$dom_in_effect} .= $aliasrows;              $aliasinfo{$dom_in_effect} .= $aliasrows;
Line 11251  sub usertype_update_row { Line 11496  sub usertype_update_row {
 sub modify_login {  sub modify_login {
     my ($r,$dom,$confname,$lastactref,%domconfig) = @_;      my ($r,$dom,$confname,$lastactref,%domconfig) = @_;
     my ($resulttext,$errors,$colchgtext,%changes,%colchanges,%newfile,%newurl,      my ($resulttext,$errors,$colchgtext,%changes,%colchanges,%newfile,%newurl,
         %curr_loginvia,%loginhash,@currlangs,@newlangs,$addedfile,%title,@offon);          %curr_loginvia,%loginhash,@currlangs,@newlangs,$addedfile,%title,@offon,
           %currsaml,%saml,%samltext,%samlimg,%samlalt,%samlurl,%samltitle,%samlnotsso);
     %title = ( coursecatalog => 'Display course catalog',      %title = ( coursecatalog => 'Display course catalog',
                adminmail => 'Display administrator E-mail address',                 adminmail => 'Display administrator E-mail address',
                helpdesk  => 'Display "Contact Helpdesk" link',                 helpdesk  => 'Display "Contact Helpdesk" link',
                newuser => 'Link for visitors to create a user account',                 newuser => 'Link for visitors to create a user account',
                loginheader => 'Log-in box header');                 loginheader => 'Log-in box header',
                  saml => 'Dual SSO and non-SSO login');
     @offon = ('off','on');      @offon = ('off','on');
     if (ref($domconfig{login}) eq 'HASH') {      if (ref($domconfig{login}) eq 'HASH') {
         if (ref($domconfig{login}{loginvia}) eq 'HASH') {          if (ref($domconfig{login}{loginvia}) eq 'HASH') {
Line 11264  sub modify_login { Line 11511  sub modify_login {
                 $curr_loginvia{$lonhost} = $domconfig{login}{loginvia}{$lonhost};                  $curr_loginvia{$lonhost} = $domconfig{login}{loginvia}{$lonhost};
             }              }
         }          }
           if (ref($domconfig{login}{'saml'}) eq 'HASH') {
               foreach my $lonhost (keys(%{$domconfig{login}{'saml'}})) {
                   if (ref($domconfig{login}{'saml'}{$lonhost}) eq 'HASH') {
                       $currsaml{$lonhost} = $domconfig{login}{'saml'}{$lonhost};
                       $saml{$lonhost} = 1;
                       $samltext{$lonhost} = $domconfig{login}{'saml'}{$lonhost}{'text'};
                       $samlurl{$lonhost} = $domconfig{login}{'saml'}{$lonhost}{'url'};
                       $samlalt{$lonhost} = $domconfig{login}{'saml'}{$lonhost}{'alt'};
                       $samlimg{$lonhost} = $domconfig{login}{'saml'}{$lonhost}{'img'};
                       $samltitle{$lonhost} = $domconfig{login}{'saml'}{$lonhost}{'title'};
                       $samlnotsso{$lonhost} = $domconfig{login}{'saml'}{$lonhost}{'notsso'};
                   }
               }
           }
     }      }
     ($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],      ($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
                                            \%domconfig,\%loginhash);                                             \%domconfig,\%loginhash);
Line 11510  sub modify_login { Line 11771  sub modify_login {
             $errors .= '<li><span class="LC_error">'.$error.'</span></li>';              $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
         }          }
     }      }
       my @delsamlimg = &Apache::loncommon::get_env_multiple('form.saml_img_del');
       my @newsamlimgs;
       foreach my $lonhost (keys(%domservers)) {
           if ($env{'form.saml_'.$lonhost}) {
               if ($env{'form.saml_img_'.$lonhost.'.filename'}) {
                   push(@newsamlimgs,$lonhost);
               }
               foreach my $item ('text','alt','url','title','notsso') {
                   $env{'form.saml_'.$item.'_'.$lonhost} =~ s/^\s+|\s+$//g;
               }
               if ($saml{$lonhost}) {
                   if (grep(/^\Q$lonhost\E$/,@delsamlimg)) {
   #FIXME Need to obsolete published image
                       delete($currsaml{$lonhost}{'img'});
                       $changes{'saml'}{$lonhost} = 1;
                   }
                   if ($env{'form.saml_alt_'.$lonhost} ne $samlalt{$lonhost}) {
                       $changes{'saml'}{$lonhost} = 1;
                   }
                   if ($env{'form.saml_text_'.$lonhost} ne $samltext{$lonhost}) {
                       $changes{'saml'}{$lonhost} = 1;
                   }
                   if ($env{'form.saml_url_'.$lonhost} ne $samlurl{$lonhost}) {
                       $changes{'saml'}{$lonhost} = 1;
                   }
                   if ($env{'form.saml_title_'.$lonhost} ne $samltitle{$lonhost}) {
                       $changes{'saml'}{$lonhost} = 1;
                   }
                   if ($env{'form.saml_notsso_'.$lonhost} ne $samlnotsso{$lonhost}) {
                       $changes{'saml'}{$lonhost} = 1;
                   }
               } else {
                   $changes{'saml'}{$lonhost} = 1;
               }
               foreach my $item ('text','alt','url','title','notsso') {
                   $currsaml{$lonhost}{$item} = $env{'form.saml_'.$item.'_'.$lonhost};
               }
           } else {
               if ($saml{$lonhost}) {  
                   $changes{'saml'}{$lonhost} = 1;
                   delete($currsaml{$lonhost});
               }
           }
       }
       foreach my $posshost (keys(%currsaml)) {
           unless (exists($domservers{$posshost})) { 
               delete($currsaml{$posshost}); 
           }
       }
       %{$loginhash{'login'}{'saml'}} = %currsaml;
       if (@newsamlimgs) {
           my $error;
           my ($configuserok,$author_ok,$switchserver) = &config_check($dom,$confname,$servadm);
           if ($configuserok eq 'ok') {
               if ($switchserver) {
                   $error = &mt("Upload of SSO Button Image is not permitted to this server: [_1].",$switchserver);
               } elsif ($author_ok eq 'ok') {
                   foreach my $lonhost (@newsamlimgs) {
                       my $formelem = 'saml_img_'.$lonhost;
                       my ($result,$imgurl) = &publishlogo($r,'upload',$formelem,$dom,$confname,
                                                           "login/saml/$lonhost",'','',
                                                           $env{'form.saml_img_'.$lonhost.'.filename'});
                       if ($result eq 'ok') {
                           $currsaml{$lonhost}{'img'} = $imgurl;
                           $loginhash{'login'}{'saml'}{$lonhost}{'img'} = $imgurl;
                           $changes{'saml'}{$lonhost} = 1;
                       } else {
                           my $puberror = &mt("Upload of SSO button image failed for [_1] because an error occurred publishing the file in RES space. Error was: [_2].",
                                              $lonhost,$result);
                           $errors .= '<li><span class="LC_error">'.$puberror.'</span></li>';
                       }
                   }
               } else {
                   $error = &mt("Upload of SSO button image file(s) failed because an author role could not be assigned to a Domain Configuration user ([_1]) in domain: [_2].  Error was: [_3].",$confname,$dom,$author_ok);
               }
           } else {
               $error = &mt("Upload of SSO button image file(s) failed because a Domain Configuration user ([_1]) could not be created in domain: [_2].  Error was: [_3].",$confname,$dom,$configuserok);
           }
           if ($error) {
               &Apache::lonnet::logthis($error);
               $errors .= '<li><span class="LC_error">'.$error.'</span></li>';
           }
       }
     &process_captcha('login',\%changes,$loginhash{'login'},$domconfig{'login'});      &process_captcha('login',\%changes,$loginhash{'login'},$domconfig{'login'});
   
     my $defaulthelpfile = '/adm/loginproblems.html';      my $defaulthelpfile = '/adm/loginproblems.html';
Line 11550  sub modify_login { Line 11894  sub modify_login {
         }          }
         if (keys(%changes) > 0 || $colchgtext) {          if (keys(%changes) > 0 || $colchgtext) {
             &Apache::loncommon::devalidate_domconfig_cache($dom);              &Apache::loncommon::devalidate_domconfig_cache($dom);
               if (exists($changes{'saml'})) {
                   my $hostid_in_use;
                   my @hosts = &Apache::lonnet::current_machine_ids();
                   if (@hosts > 1) {
                       foreach my $hostid (@hosts) {
                           if (&Apache::lonnet::host_domain($hostid) eq $dom) {
                               $hostid_in_use = $hostid;
                               last;
                           }
                       }
                   } else {
                       $hostid_in_use = $r->dir_config('lonHostID');
                   }
                   if (($hostid_in_use) &&
                       (&Apache::lonnet::host_domain($hostid_in_use) eq $dom)) {
                       &Apache::lonnet::devalidate_cache_new('samllanding',$hostid_in_use);
                   }
                   if (ref($lastactref) eq 'HASH') {
                       if (ref($changes{'saml'}) eq 'HASH') {
                           my %updates;
                           map { $updates{$_} = 1; } keys(%{$changes{'saml'}});
                           $lastactref->{'samllanding'} = \%updates;
                       }
                   }
               }
             if (ref($lastactref) eq 'HASH') {              if (ref($lastactref) eq 'HASH') {
                 $lastactref->{'domainconfig'} = 1;                  $lastactref->{'domainconfig'} = 1;
             }              }
Line 11629  sub modify_login { Line 11998  sub modify_login {
                             }                              }
                         }                          }
                     }                      }
                   } elsif ($item eq 'saml') {
                       if (ref($changes{$item}) eq 'HASH') {
                           my %notlt = (
                                          text   => 'Text for log-in by SSO',
                                          img    => 'SSO button image',
                                          alt    => 'Alt text for button image',
                                          url    => 'SSO URL',
                                          title  => 'Tooltip for SSO link',
                                          notsso => 'Text for non-SSO log-in',
                                       );
                           foreach my $lonhost (sort(keys(%{$changes{$item}}))) {
                               if (ref($currsaml{$lonhost}) eq 'HASH') {
                                   $resulttext .= '<li>'.&mt("$title{$item} in use for [_1]","<b>$lonhost</b>").
                                                  '<ul>';
                                   foreach my $key ('text','img','alt','url','title','notsso') {
                                       if ($currsaml{$lonhost}{$key} eq '') {
                                           $resulttext .= '<li>'.&mt("$notlt{$key} not in use").'</li>';
                                       } else {
                                           my $value = "'$currsaml{$lonhost}{$key}'";
                                           if ($key eq 'img') {
                                               $value = '<img src="'.$currsaml{$lonhost}{$key}.'" />';
                                           }
                                           $resulttext .= '<li>'.&mt("$notlt{$key} set to: [_1]",
                                                                     $value).'</li>';
                                       }
                                   }
                                   $resulttext .= '</ul></li>';
                               } else {
                                   $resulttext .= '<li>'.&mt("$title{$item} not in use for [_1]",$lonhost).'</li>';
                               }
                           }
                       }
                 } elsif ($item eq 'captcha') {                  } elsif ($item eq 'captcha') {
                     if (ref($loginhash{'login'}) eq 'HASH') {                      if (ref($loginhash{'login'}) eq 'HASH') {
                         my $chgtxt;                          my $chgtxt;
Line 14410  sub modify_lti { Line 14811  sub modify_lti {
             map { $deletions{$_} = 1; } @todelete;              map { $deletions{$_} = 1; } @todelete;
         }          }
         my $maxnum = $env{'form.lti_maxnum'};          my $maxnum = $env{'form.lti_maxnum'};
         for (my $i=0; $i<=$maxnum; $i++) {          for (my $i=0; $i<$maxnum; $i++) {
             my $itemid = $env{'form.lti_id_'.$i};              my $itemid = $env{'form.lti_id_'.$i};
             $itemid =~ s/\D+//g;              $itemid =~ s/\D+//g;
             if (ref($domconfig{$action}{$itemid}) eq 'HASH') {              if (ref($domconfig{$action}{$itemid}) eq 'HASH') {
                 if ($deletions{$itemid}) {                  if ($deletions{$itemid}) {
                     $changes{$itemid} = $domconfig{$action}{$itemid}{'consumer'};                      $changes{$itemid} = $domconfig{$action}{$itemid}{'consumer'};
                 } else {                  } else {
                    push(@items,$i);                      push(@items,$i);
                    $itemids{$i} = $itemid;                      $itemids{$i} = $itemid;
                 }                  }
             }              }
         }          }
Line 14426  sub modify_lti { Line 14827  sub modify_lti {
     foreach my $idx (@items) {      foreach my $idx (@items) {
         my $itemid = $itemids{$idx};          my $itemid = $itemids{$idx};
         next unless ($itemid);          next unless ($itemid);
         my $position = $env{'form.lti_pos_'.$idx};          my $position = $env{'form.lti_pos_'.$itemid};
         $position =~ s/\D+//g;          $position =~ s/\D+//g;
         if ($position ne '') {          if ($position ne '') {
             $allpos[$position] = $itemid;              $allpos[$position] = $itemid;
         }          }
         foreach my $item ('consumer','key','secret','lifetime','requser') {          foreach my $item ('consumer','key','secret','lifetime','requser','crsinc') {
             my $formitem = 'form.lti_'.$item.'_'.$idx;              my $formitem = 'form.lti_'.$item.'_'.$idx;
             $env{$formitem} =~ s/(`)/'/g;              $env{$formitem} =~ s/(`)/'/g;
             if ($item eq 'lifetime') {              if ($item eq 'lifetime') {
Line 14464  sub modify_lti { Line 14865  sub modify_lti {
                 $mapuser =~ s/^\s+|\s+$//g;                   $mapuser =~ s/^\s+|\s+$//g; 
                 $confhash{$itemid}{'mapuser'} = $mapuser;                   $confhash{$itemid}{'mapuser'} = $mapuser; 
             }              }
             foreach my $ltirole (@lticourseroles) {  
                 my $possrole = $env{'form.lti_maprole_'.$ltirole.'_'.$idx};  
                 if (grep(/^\Q$possrole\E$/,@courseroles)) {  
                     $confhash{$itemid}{'maproles'}{$ltirole} = $possrole;  
                 }  
             }  
             my @possmakeuser = &Apache::loncommon::get_env_multiple('form.lti_makeuser_'.$idx);              my @possmakeuser = &Apache::loncommon::get_env_multiple('form.lti_makeuser_'.$idx);
             my @makeuser;              my @makeuser;
             foreach my $ltirole (sort(@possmakeuser)) {              foreach my $ltirole (sort(@possmakeuser)) {
Line 14502  sub modify_lti { Line 14897  sub modify_lti {
                     }                      }
                 }                  }
             }              }
             if (($env{'form.lti_mapcrs_'.$idx} eq 'course_offering_sourcedid') ||  
                 ($env{'form.lti_mapcrs_'.$idx} eq 'context_id'))  {  
                 $confhash{$itemid}{'mapcrs'} = $env{'form.lti_mapcrs_'.$idx};  
             } elsif ($env{'form.lti_mapcrs_'.$idx} eq 'other') {  
                 my $mapcrs = $env{'form.lti_mapcrsfield_'.$idx};   
                 $mapcrs =~ s/(`)/'/g;  
                 $mapcrs =~ s/^\s+|\s+$//g;  
                 $confhash{$itemid}{'mapcrs'} = $mapcrs;  
             }  
             my @posstypes = &Apache::loncommon::get_env_multiple('form.lti_mapcrstype_'.$idx);  
             my @crstypes;  
             foreach my $type (sort(@posstypes)) {  
                 if ($posscrstype{$type}) {  
                     push(@crstypes,$type);  
                 }  
             }  
             $confhash{$itemid}{'mapcrstype'} = \@crstypes;  
             if ($env{'form.lti_makecrs_'.$idx}) {  
                 $confhash{$itemid}{'makecrs'} = 1;  
             }  
             my @possenroll = &Apache::loncommon::get_env_multiple('form.lti_selfenroll_'.$idx);  
             my @selfenroll;  
             foreach my $type (sort(@possenroll)) {  
                 if ($posslticrs{$type}) {  
                     push(@selfenroll,$type);  
                 }  
             }  
             $confhash{$itemid}{'selfenroll'} = \@selfenroll;  
             if ($env{'form.lti_crssec_'.$idx}) {  
                 if ($env{'form.lti_crssecsrc_'.$idx} eq 'course_section_sourcedid') {  
                     $confhash{$itemid}{'section'} = $env{'form.lti_crssecsrc_'.$idx};  
                 } elsif ($env{'form.lti_crssecsrc_'.$idx} eq 'other') {  
                     my $section = $env{'form.lti_customsection_'.$idx};  
                     $section =~ s/(`)/'/g;  
                     $section =~ s/^\s+|\s+$//g;  
                     if ($section ne '') {  
                         $confhash{$itemid}{'section'} = $section;  
                     }  
                 }  
             }  
             if ($env{'form.lti_callback_'.$idx}) {              if ($env{'form.lti_callback_'.$idx}) {
                 if ($env{'form.lti_callbackparam_'.$idx}) {                  if ($env{'form.lti_callbackparam_'.$idx}) {
                     my $callback = $env{'form.lti_callbackparam_'.$idx};                      my $callback = $env{'form.lti_callbackparam_'.$idx};
Line 14549  sub modify_lti { Line 14904  sub modify_lti {
                     $confhash{$itemid}{'callback'} = $callback;                      $confhash{$itemid}{'callback'} = $callback;
                 }                  }
             }              }
             foreach my $field ('passback','roster','topmenu','inlinemenu') {              foreach my $field ('topmenu','inlinemenu') {
                 if ($env{'form.lti_'.$field.'_'.$idx}) {                  if ($env{'form.lti_'.$field.'_'.$idx}) {
                     $confhash{$itemid}{$field} = 1;                      $confhash{$itemid}{$field} = 1;
                 }                  }
             }              }
             if ($env{'form.lti_passback_'.$idx}) {  
                 if ($env{'form.lti_passbackformat_'.$idx} eq '1.0') {  
                     $confhash{$itemid}{'passbackformat'} = '1.0';  
                 } else {  
                     $confhash{$itemid}{'passbackformat'} = '1.1';  
                 }  
             }  
             if ($env{'form.lti_topmenu_'.$idx} || $env{'form.lti_inlinemenu_'.$idx}) {              if ($env{'form.lti_topmenu_'.$idx} || $env{'form.lti_inlinemenu_'.$idx}) {
                 $confhash{$itemid}{lcmenu} = [];                  $confhash{$itemid}{lcmenu} = [];
                 my @possmenu = &Apache::loncommon::get_env_multiple('form.lti_menuitem_'.$idx);                  my @possmenu = &Apache::loncommon::get_env_multiple('form.lti_menuitem_'.$idx);
Line 14573  sub modify_lti { Line 14921  sub modify_lti {
                     }                      }
                 }                  }
             }              }
             unless (($idx eq 'add') || ($changes{$itemid})) {              if ($confhash{$itemid}{'crsinc'}) {
                 foreach my $field ('mapuser','mapcrs','makecrs','section','passback','roster','lcauth','lcauthparm','topmenu','inlinemenu','callback') {                  if (($env{'form.lti_mapcrs_'.$idx} eq 'course_offering_sourcedid') ||
                     if ($domconfig{$action}{$itemid}{$field} ne $confhash{$itemid}{$field}) {                      ($env{'form.lti_mapcrs_'.$idx} eq 'context_id'))  {
                         $changes{$itemid} = 1;                      $confhash{$itemid}{'mapcrs'} = $env{'form.lti_mapcrs_'.$idx};
                   } elsif ($env{'form.lti_mapcrs_'.$idx} eq 'other') {
                       my $mapcrs = $env{'form.lti_mapcrsfield_'.$idx}; 
                       $mapcrs =~ s/(`)/'/g;
                       $mapcrs =~ s/^\s+|\s+$//g;
                       $confhash{$itemid}{'mapcrs'} = $mapcrs;
                   }
                   my @posstypes = &Apache::loncommon::get_env_multiple('form.lti_mapcrstype_'.$idx);
                   my @crstypes;
                   foreach my $type (sort(@posstypes)) {
                       if ($posscrstype{$type}) {
                           push(@crstypes,$type);
                       }
                   }
                   $confhash{$itemid}{'mapcrstype'} = \@crstypes;
                   if ($env{'form.lti_makecrs_'.$idx}) {
                       $confhash{$itemid}{'makecrs'} = 1;
                   }
                   foreach my $ltirole (@lticourseroles) {
                       my $possrole = $env{'form.lti_maprole_'.$ltirole.'_'.$idx};
                       if (grep(/^\Q$possrole\E$/,@courseroles)) {
                           $confhash{$itemid}{'maproles'}{$ltirole} = $possrole;
                       }
                   }
                   my @possenroll = &Apache::loncommon::get_env_multiple('form.lti_selfenroll_'.$idx);
                   my @selfenroll;
                   foreach my $type (sort(@possenroll)) {
                       if ($posslticrs{$type}) {
                           push(@selfenroll,$type);
                       }
                   }
                   $confhash{$itemid}{'selfenroll'} = \@selfenroll;
                   if ($env{'form.lti_crssec_'.$idx}) {
                       if ($env{'form.lti_crssecsrc_'.$idx} eq 'course_section_sourcedid') {
                           $confhash{$itemid}{'section'} = $env{'form.lti_crssecsrc_'.$idx};
                       } elsif ($env{'form.lti_crssecsrc_'.$idx} eq 'other') {
                           my $section = $env{'form.lti_customsection_'.$idx};
                           $section =~ s/(`)/'/g;
                           $section =~ s/^\s+|\s+$//g;
                           if ($section ne '') {
                               $confhash{$itemid}{'section'} = $section;
                           }
                     }                      }
                 }                  }
                 unless ($changes{$itemid}) {                  foreach my $field ('passback','roster') {
                     if ($domconfig{$action}{$itemid}{'passback'} eq $confhash{$itemid}{'passback'}) {                      if ($env{'form.lti_'.$field.'_'.$idx}) {
                         if ($domconfig{$action}{$itemid}{'passbackformat'} ne $confhash{$itemid}{'passbackformat'}) {                          $confhash{$itemid}{$field} = 1;
                       }
                   }
                   if ($env{'form.lti_passback_'.$idx}) {
                       if ($env{'form.lti_passbackformat_'.$idx} eq '1.0') {
                           $confhash{$itemid}{'passbackformat'} = '1.0';
                       } else {
                           $confhash{$itemid}{'passbackformat'} = '1.1';
                       }
                   }
               }
               unless (($idx eq 'add') || ($changes{$itemid})) {
                   if ($confhash{$itemid}{'crsinc'}) {
                       foreach my $field ('mapcrs','makecrs','section','passback','roster') {
                           if ($domconfig{$action}{$itemid}{$field} ne $confhash{$itemid}{$field}) {
                             $changes{$itemid} = 1;                              $changes{$itemid} = 1;
                         }                          }
                     }                      }
                 }  
                 foreach my $field ('makeuser','mapcrstype','selfenroll','instdata','lcmenu') {  
                     unless ($changes{$itemid}) {                      unless ($changes{$itemid}) {
                         if (ref($domconfig{$action}{$itemid}{$field}) eq 'ARRAY') {                          if ($domconfig{$action}{$itemid}{'passback'} eq $confhash{$itemid}{'passback'}) {
                             if (ref($confhash{$itemid}{$field}) eq 'ARRAY') {                              if ($domconfig{$action}{$itemid}{'passbackformat'} ne $confhash{$itemid}{'passbackformat'}) {
                                 my @diffs = &Apache::loncommon::compare_arrays($domconfig{$action}{$itemid}{$field},  
                                                                                $confhash{$itemid}{$field});  
                                 if (@diffs) {  
                                     $changes{$itemid} = 1;  
                                 }  
                             } elsif (@{$domconfig{$action}{$itemid}{$field}} > 0) {  
                                 $changes{$itemid} = 1;  
                             }  
                         } elsif (ref($confhash{$itemid}{$field}) eq 'ARRAY') {  
                             if (@{$confhash{$itemid}{$field}} > 0) {  
                                 $changes{$itemid} = 1;                                  $changes{$itemid} = 1;
                             }                              }
                         }                          }
                     }                      }
                 }                      foreach my $field ('mapcrstype','selfenroll') {
                 unless ($changes{$itemid}) {                          unless ($changes{$itemid}) {
                     if (ref($domconfig{$action}{$itemid}{'maproles'}) eq 'HASH') {                              if (ref($domconfig{$action}{$itemid}{$field}) eq 'ARRAY') {
                         if (ref($confhash{$itemid}{'maproles'}) eq 'HASH') {                                  if (ref($confhash{$itemid}{$field}) eq 'ARRAY') {
                             foreach my $ltirole (keys(%{$domconfig{$action}{$itemid}{'maproles'}})) {                                      my @diffs = &Apache::loncommon::compare_arrays($domconfig{$action}{$itemid}{$field},
                                 if ($domconfig{$action}{$itemid}{'maproles'}{$ltirole} ne                                                                                      $confhash{$itemid}{$field});
                                     $confhash{$itemid}{'maproles'}{$ltirole}) {                                      if (@diffs) {
                                           $changes{$itemid} = 1;
                                       }
                                   } elsif (@{$domconfig{$action}{$itemid}{$field}} > 0) {
                                       $changes{$itemid} = 1;
                                   }
                               } elsif (ref($confhash{$itemid}{$field}) eq 'ARRAY') {
                                   if (@{$confhash{$itemid}{$field}} > 0) {
                                     $changes{$itemid} = 1;                                      $changes{$itemid} = 1;
                                     last;  
                                 }                                  }
                             }                              }
                             unless ($changes{$itemid}) {                          }
                                 foreach my $ltirole (keys(%{$confhash{$itemid}{'maproles'}})) {                      }
                                     if ($confhash{$itemid}{'maproles'}{$ltirole} ne                       unless ($changes{$itemid}) {
                                         $domconfig{$action}{$itemid}{'maproles'}{$ltirole}) {                          if (ref($domconfig{$action}{$itemid}{'maproles'}) eq 'HASH') {
                               if (ref($confhash{$itemid}{'maproles'}) eq 'HASH') {
                                   foreach my $ltirole (keys(%{$domconfig{$action}{$itemid}{'maproles'}})) {
                                       if ($domconfig{$action}{$itemid}{'maproles'}{$ltirole} ne 
                                           $confhash{$itemid}{'maproles'}{$ltirole}) {
                                         $changes{$itemid} = 1;                                          $changes{$itemid} = 1;
                                         last;                                          last;
                                     }                                      }
                                 }                                  }
                                   unless ($changes{$itemid}) {
                                       foreach my $ltirole (keys(%{$confhash{$itemid}{'maproles'}})) {
                                           if ($confhash{$itemid}{'maproles'}{$ltirole} ne 
                                               $domconfig{$action}{$itemid}{'maproles'}{$ltirole}) {
                                               $changes{$itemid} = 1;
                                               last;
                                           }
                                       }
                                   }
                               } elsif (keys(%{$domconfig{$action}{$itemid}{'maproles'}}) > 0) {
                                   $changes{$itemid} = 1;
                             }                              }
                         } elsif (keys(%{$domconfig{$action}{$itemid}{'maproles'}}) > 0) {                          } elsif (ref($confhash{$itemid}{'maproles'}) eq 'HASH') {
                               unless ($changes{$itemid}) {
                                   if (keys(%{$confhash{$itemid}{'maproles'}}) > 0) {
                                       $changes{$itemid} = 1;
                                   }
                               }
                           }
                       }
                   }
                   unless ($changes{$itemid}) {
                       foreach my $field ('mapuser','lcauth','lcauthparm','topmenu','inlinemenu','callback') {
                           if ($domconfig{$action}{$itemid}{$field} ne $confhash{$itemid}{$field}) {
                             $changes{$itemid} = 1;                              $changes{$itemid} = 1;
                         }                          }
                     } elsif (ref($confhash{$itemid}{'maproles'}) eq 'HASH') {                      }
                         unless ($changes{$itemid}) {                      unless ($changes{$itemid}) {
                             if (keys(%{$confhash{$itemid}{'maproles'}}) > 0) {                          foreach my $field ('makeuser','lcmenu') {
                                 $changes{$itemid} = 1;                              if (ref($domconfig{$action}{$itemid}{$field}) eq 'ARRAY') {
                                   if (ref($confhash{$itemid}{$field}) eq 'ARRAY') {
                                       my @diffs = &Apache::loncommon::compare_arrays($domconfig{$action}{$itemid}{$field},
                                                                                      $confhash{$itemid}{$field});
                                       if (@diffs) {
                                           $changes{$itemid} = 1;
                                       }
                                   } elsif (@{$domconfig{$action}{$itemid}{$field}} > 0) {
                                       $changes{$itemid} = 1;
                                   }
                               } elsif (ref($confhash{$itemid}{$field}) eq 'ARRAY') {
                                   if (@{$confhash{$itemid}{$field}} > 0) {
                                       $changes{$itemid} = 1;
                                   }
                             }                              }
                         }                          }
                     }                      }
Line 14689  sub modify_lti { Line 15125  sub modify_lti {
                 if (ref($confhash{$itemid}) ne 'HASH') {                  if (ref($confhash{$itemid}) ne 'HASH') {
                     $resulttext .= '<li>'.&mt('Deleted: [_1]',$changes{$itemid}).'</li>';                      $resulttext .= '<li>'.&mt('Deleted: [_1]',$changes{$itemid}).'</li>';
                 } else {                  } else {
                     $resulttext .= '<li><b>'.$confhash{$itemid}{'consumer'}.'</b></li><ul>';                      $resulttext .= '<li><b>'.$confhash{$itemid}{'consumer'}.'</b><ul>';
                     my $position = $pos + 1;                      my $position = $pos + 1;
                     $resulttext .= '<li>'.&mt('Order: [_1]',$position).'</li>';                      $resulttext .= '<li>'.&mt('Order: [_1]',$position).'</li>';
                     foreach my $item ('version','lifetime') {                      foreach my $item ('version','lifetime') {
Line 14706  sub modify_lti { Line 15142  sub modify_lti {
                         $resulttext .= ('*'x$num).'</li>';                          $resulttext .= ('*'x$num).'</li>';
                     }                      }
                     if ($confhash{$itemid}{'requser'}) {                      if ($confhash{$itemid}{'requser'}) {
                           if ($confhash{$itemid}{'callback'}) {
                               $resulttext .= '<li>'.&mt('Callback setting').': '.$confhash{$itemid}{'callback'}.'</li>';
                           } else {
                               $resulttext .= '<li>'.&mt('No callback to logout LON-CAPA session when user logs out of Comsumer').'</li>';
                           }
                         if ($confhash{$itemid}{'mapuser'}) {                          if ($confhash{$itemid}{'mapuser'}) {
                             my $shownmapuser;                              my $shownmapuser;
                             if ($confhash{$itemid}{'mapuser'} eq 'lis_person_sourcedid') {                              if ($confhash{$itemid}{'mapuser'} eq 'lis_person_sourcedid') {
Line 14717  sub modify_lti { Line 15158  sub modify_lti {
                             }                              }
                             $resulttext .= '<li>'.&mt('LON-CAPA username').': '.$shownmapuser.'</li>';                              $resulttext .= '<li>'.&mt('LON-CAPA username').': '.$shownmapuser.'</li>';
                         }                          }
                         if (ref($confhash{$itemid}{'maproles'}) eq 'HASH') {  
                             my $rolemaps;  
                             foreach my $role (@ltiroles) {  
                                 if ($confhash{$itemid}{'maproles'}{$role}) {  
                                     $rolemaps .= ('&nbsp;'x2).$role.'='.  
                                                  &Apache::lonnet::plaintext($confhash{$itemid}{'maproles'}{$role},  
                                                                             'Course').',';  
                                 }  
                             }  
                             if ($rolemaps) {  
                                 $rolemaps =~ s/,$//;  
                                 $resulttext .= '<li>'.&mt('Role mapping:').$rolemaps.'</li>';  
                             }  
                         }  
                         if (ref($confhash{$itemid}{'makeuser'}) eq 'ARRAY') {                          if (ref($confhash{$itemid}{'makeuser'}) eq 'ARRAY') {
                             if (@{$confhash{$itemid}{'makeuser'}} > 0) {                               if (@{$confhash{$itemid}{'makeuser'}} > 0) { 
                                 $resulttext .= '<li>'.&mt('Following roles may create user accounts: [_1]',                                  $resulttext .= '<li>'.&mt('Following roles may create user accounts: [_1]',
Line 14763  sub modify_lti { Line 15190  sub modify_lti {
                                 $resulttext .= '<li>'.&mt('No institutional data used when creating a new user.').'</li>';                                  $resulttext .= '<li>'.&mt('No institutional data used when creating a new user.').'</li>';
                             }                              }
                         }                          }
                         if ($confhash{$itemid}{'mapcrs'}) {                          foreach my $item ('topmenu','inlinemenu') {
                             $resulttext .= '<li>'.&mt('Unique course identifier').': '.$confhash{$itemid}{'mapcrs'}.'</li>';  
                         }  
                         if (ref($confhash{$itemid}{'mapcrstype'}) eq 'ARRAY') {  
                             if (@{$confhash{$itemid}{'mapcrstype'}} > 0) {  
                                 $resulttext .= '<li>'.&mt('Mapping for the following LON-CAPA course types: [_1]',  
                                                join(', ',map { $coursetypetitles{$_}; } @coursetypes)).  
                                                '</li>';  
                             } else {  
                                 $resulttext .= '<li>'.&mt('No mapping to LON-CAPA courses').'</li>';  
                             }  
                         }  
                         if ($confhash{$itemid}{'makecrs'}) {  
                             $resulttext .= '<li>'.&mt('Instructor may create course (if absent).').'</li>';  
                         } else {  
                             $resulttext .= '<li>'.&mt('Instructor may not create course (if absent).').'</li>';  
                         }  
                         if (ref($confhash{$itemid}{'selfenroll'}) eq 'ARRAY') {  
                             if (@{$confhash{$itemid}{'selfenroll'}} > 0) {  
                                 $resulttext .= '<li>'.&mt('Self-enrollment for following roles: [_1]',  
                                                           join(', ',@{$confhash{$itemid}{'selfenroll'}})).  
                                                '</li>';  
                             } else {  
                                 $resulttext .= '<li>'.&mt('Self-enrollment not permitted').'</li>';  
                             }  
                         }  
                         if ($confhash{$itemid}{'section'}) {  
                             if ($confhash{$itemid}{'section'} eq 'course_section_sourcedid') {  
                                 $resulttext .= '<li>'.&mt('User section from standard field:').  
                                                      ' (course_section_sourcedid)'.'</li>';    
                             } else {  
                                 $resulttext .= '<li>'.&mt('User section from:').' '.  
                                                       $confhash{$itemid}{'section'}.'</li>';  
                             }  
                         } else {  
                             $resulttext .= '<li>'.&mt('No section assignment').'</li>';  
                         }  
                         if ($confhash{$itemid}{'callback'}) {  
                             $resulttext .= '<li>'.&mt('Callback setting').': '.$confhash{$itemid}{'callback'}.'</li>';  
                         } else {  
                             $resulttext .= '<li>'.&mt('No callback to logout LON-CAPA session when user logs out of Comsumer');  
                         }  
                         foreach my $item ('passback','roster','topmenu','inlinemenu') {  
                             $resulttext .= '<li>'.$lt{$item}.':&nbsp;';                              $resulttext .= '<li>'.$lt{$item}.':&nbsp;';
                             if ($confhash{$itemid}{$item}) {                              if ($confhash{$itemid}{$item}) {
                                 $resulttext .= &mt('Yes');                                  $resulttext .= &mt('Yes');
                                 if ($item eq 'passback') {  
                                     if ($confhash{$itemid}{'passbackformat'} eq '1.0') {  
                                         $resulttext .= '&nbsp;('.&mt('Outcomes Extension (1.0)').')';  
                                     } elsif ($confhash{$itemid}{'passbackformat'} eq '1.1') {  
                                         $resulttext .= '&nbsp;('.&mt('Outcomes Service (1.1)').')';  
                                     }  
                                 }  
                             } else {                              } else {
                                 $resulttext .= &mt('No');                                  $resulttext .= &mt('No');
                             }                              }
Line 14824  sub modify_lti { Line 15202  sub modify_lti {
                         if (ref($confhash{$itemid}{'lcmenu'}) eq 'ARRAY') {                          if (ref($confhash{$itemid}{'lcmenu'}) eq 'ARRAY') {
                             if (@{$confhash{$itemid}{'lcmenu'}} > 0) {                              if (@{$confhash{$itemid}{'lcmenu'}} > 0) {
                                 $resulttext .= '<li>'.&mt('Menu items:').' '.                                  $resulttext .= '<li>'.&mt('Menu items:').' '.
                                                join(', ', map { $menutitles{$_}; } (@{$confhash{$itemid}{'lcmenu'}})).'</li>';                                                  join(', ', map { $menutitles{$_}; } (@{$confhash{$itemid}{'lcmenu'}})).'</li>';
                               } else {
                                   $resulttext .= '<li>'.&mt('No menu items displayed in header or online menu').'</li>';
                               }
                           }
                           if ($confhash{$itemid}{'crsinc'}) {
                               if (ref($confhash{$itemid}{'maproles'}) eq 'HASH') {
                                   my $rolemaps;
                                   foreach my $role (@ltiroles) {
                                       if ($confhash{$itemid}{'maproles'}{$role}) {
                                           $rolemaps .= ('&nbsp;'x2).$role.'='.
                                                        &Apache::lonnet::plaintext($confhash{$itemid}{'maproles'}{$role},
                                                                                   'Course').',';
                                       }
                                   }
                                   if ($rolemaps) {
                                       $rolemaps =~ s/,$//;
                                       $resulttext .= '<li>'.&mt('Role mapping:').$rolemaps.'</li>';
                                   }
                               }
                               if ($confhash{$itemid}{'mapcrs'}) {
                                   $resulttext .= '<li>'.&mt('Unique course identifier').': '.$confhash{$itemid}{'mapcrs'}.'</li>';
                               }
                               if (ref($confhash{$itemid}{'mapcrstype'}) eq 'ARRAY') {
                                   if (@{$confhash{$itemid}{'mapcrstype'}} > 0) {
                                       $resulttext .= '<li>'.&mt('Mapping for the following LON-CAPA course types: [_1]',
                                                      join(', ',map { $coursetypetitles{$_}; } @coursetypes)).
                                                      '</li>';
                                   } else {
                                       $resulttext .= '<li>'.&mt('No mapping to LON-CAPA courses').'</li>';
                                   }
                               }
                               if ($confhash{$itemid}{'makecrs'}) {
                                   $resulttext .= '<li>'.&mt('Instructor may create course (if absent).').'</li>';
                             } else {                              } else {
                                 $resulttext .= '<li>'.&mt('No menu items displayed in header or online menu').'</li>';                                   $resulttext .= '<li>'.&mt('Instructor may not create course (if absent).').'</li>';
                               }
                               if (ref($confhash{$itemid}{'selfenroll'}) eq 'ARRAY') {
                                   if (@{$confhash{$itemid}{'selfenroll'}} > 0) {
                                       $resulttext .= '<li>'.&mt('Self-enrollment for following roles: [_1]',
                                                                 join(', ',@{$confhash{$itemid}{'selfenroll'}})).
                                                      '</li>';
                                   } else {
                                       $resulttext .= '<li>'.&mt('Self-enrollment not permitted').'</li>';
                                   }
                               }
                               if ($confhash{$itemid}{'section'}) {
                                   if ($confhash{$itemid}{'section'} eq 'course_section_sourcedid') {
                                       $resulttext .= '<li>'.&mt('User section from standard field:').
                                                            ' (course_section_sourcedid)'.'</li>';  
                                   } else {
                                       $resulttext .= '<li>'.&mt('User section from:').' '.
                                                             $confhash{$itemid}{'section'}.'</li>';
                                   }
                               } else {
                                   $resulttext .= '<li>'.&mt('No section assignment').'</li>';
                               }
                               foreach my $item ('passback','roster','topmenu','inlinemenu') {
                                   $resulttext .= '<li>'.$lt{$item}.':&nbsp;';
                                   if ($confhash{$itemid}{$item}) {
                                       $resulttext .= &mt('Yes');
                                       if ($item eq 'passback') {
                                           if ($confhash{$itemid}{'passbackformat'} eq '1.0') {
                                               $resulttext .= '&nbsp;('.&mt('Outcomes Extension (1.0)').')';
                                           } elsif ($confhash{$itemid}{'passbackformat'} eq '1.1') {
                                               $resulttext .= '&nbsp;('.&mt('Outcomes Service (1.1)').')';
                                           }
                                       }
                                   } else {
                                       $resulttext .= &mt('No');
                                   }
                                   $resulttext .= '</li>';
                               }
                               if (ref($confhash{$itemid}{'lcmenu'}) eq 'ARRAY') {
                                   if (@{$confhash{$itemid}{'lcmenu'}} > 0) {
                                       $resulttext .= '<li>'.&mt('Menu items:').' '.
                                                      join(', ', map { $menutitles{$_}; } (@{$confhash{$itemid}{'lcmenu'}})).'</li>'; 
                                   } else {
                                       $resulttext .= '<li>'.&mt('No menu items displayed in header or online menu').'</li>'; 
                                   }
                             }                              }
                         }                          }
                     }                      }
Line 19930  sub modify_selfenrollment { Line 20385  sub modify_selfenrollment {
 sub modify_wafproxy {  sub modify_wafproxy {
     my ($dom,$action,$lastactref,%domconfig) = @_;      my ($dom,$action,$lastactref,%domconfig) = @_;
     my %servers = &Apache::lonnet::internet_dom_servers($dom);      my %servers = &Apache::lonnet::internet_dom_servers($dom);
     my (%othercontrol,%canset,%values,%curralias,%currvalue,@warnings,%wafproxy,      my (%othercontrol,%canset,%values,%curralias,%currsaml,%currvalue,@warnings,
         %changes,%expirecache);          %wafproxy,%changes,%expirecache,%expiresaml);
     foreach my $server (sort(keys(%servers))) {      foreach my $server (sort(keys(%servers))) {
         my $serverhome = &Apache::lonnet::get_server_homeID($servers{$server});          my $serverhome = &Apache::lonnet::get_server_homeID($servers{$server});
         if ($serverhome eq $server) {          if ($serverhome eq $server) {
Line 19946  sub modify_wafproxy { Line 20401  sub modify_wafproxy {
         if (ref($domconfig{'wafproxy'}{'alias'}) eq 'HASH') {          if (ref($domconfig{'wafproxy'}{'alias'}) eq 'HASH') {
             %curralias = %{$domconfig{'wafproxy'}{'alias'}};              %curralias = %{$domconfig{'wafproxy'}{'alias'}};
         }          }
           if (ref($domconfig{'wafproxy'}{'saml'}) eq 'HASH') {
               %currsaml = %{$domconfig{'wafproxy'}{'saml'}};
           }
         foreach my $item ('remoteip','ipheader','trusted','vpnint','vpnext','sslopt') {          foreach my $item ('remoteip','ipheader','trusted','vpnint','vpnext','sslopt') {
             $currvalue{$item} = $domconfig{'wafproxy'}{$item};              $currvalue{$item} = $domconfig{'wafproxy'}{$item};
         }          }
Line 19953  sub modify_wafproxy { Line 20411  sub modify_wafproxy {
     my $output;      my $output;
     if (keys(%canset)) {      if (keys(%canset)) {
         %{$wafproxy{'alias'}} = ();          %{$wafproxy{'alias'}} = ();
           %{$wafproxy{'saml'}} = ();
         foreach my $key (sort(keys(%canset))) {          foreach my $key (sort(keys(%canset))) {
             if ($env{'form.wafproxy_'.$dom}) {              if ($env{'form.wafproxy_'.$dom}) {
                 $wafproxy{'alias'}{$key} = $env{'form.wafproxy_alias_'.$key};                  $wafproxy{'alias'}{$key} = $env{'form.wafproxy_alias_'.$key};
Line 19960  sub modify_wafproxy { Line 20419  sub modify_wafproxy {
                 if ($wafproxy{'alias'}{$key} ne $curralias{$key}) {                  if ($wafproxy{'alias'}{$key} ne $curralias{$key}) {
                     $changes{'alias'} = 1;                      $changes{'alias'} = 1;
                 }                  }
                   if ($env{'form.wafproxy_alias_saml_'.$key}) {
                       $wafproxy{'saml'}{$key} = 1;
                   }
                   if ($wafproxy{'saml'}{$key} ne $currsaml{$key}) {
                       $changes{'saml'} = 1;
                   }
             } else {              } else {
                 $wafproxy{'alias'}{$key} = '';                  $wafproxy{'alias'}{$key} = '';
                   $wafproxy{'saml'}{$key} = '';
                 if ($curralias{$key}) {                  if ($curralias{$key}) {
                     $changes{'alias'} = 1;                      $changes{'alias'} = 1;
                 }                  }
                   if ($currsaml{$key}) {
                       $changes{'saml'} = 1;
                   }
             }              }
             if ($wafproxy{'alias'}{$key} eq '') {              if ($wafproxy{'alias'}{$key} eq '') {
                 if ($curralias{$key}) {                  if ($curralias{$key}) {
Line 19972  sub modify_wafproxy { Line 20441  sub modify_wafproxy {
                 }                  }
                 delete($wafproxy{'alias'}{$key});                  delete($wafproxy{'alias'}{$key});
             }              }
               if ($wafproxy{'saml'}{$key} eq '') {
                   if ($currsaml{$key}) {
                       $expiresaml{$key} = 1;
                   }
                   delete($wafproxy{'saml'}{$key});
               }
         }          }
         unless (keys(%{$wafproxy{'alias'}})) {          unless (keys(%{$wafproxy{'alias'}})) {
             delete($wafproxy{'alias'});              delete($wafproxy{'alias'});
         }          }
         # Localization for values in %warn occus in &mt() calls separately.          unless (keys(%{$wafproxy{'saml'}})) {
               delete($wafproxy{'saml'});
           }
           # Localization for values in %warn occurs in &mt() calls separately.
         my %warn = (          my %warn = (
                      trusted => 'trusted IP range(s)',                       trusted => 'trusted IP range(s)',
                      vpnint => 'internal IP range(s) for VPN sessions(s)',                       vpnint => 'internal IP range(s) for VPN sessions(s)',
Line 20044  sub modify_wafproxy { Line 20522  sub modify_wafproxy {
     } else {      } else {
         if (keys(%curralias)) {          if (keys(%curralias)) {
             $changes{'alias'} = 1;              $changes{'alias'} = 1;
           }
           if (keys(%currsaml)) {
               $changes{'saml'} = 1;
         }           } 
         if (keys(%currvalue)) {          if (keys(%currvalue)) {
             foreach my $key (keys(%currvalue)) {              foreach my $key (keys(%currvalue)) {
Line 20096  sub modify_wafproxy { Line 20577  sub modify_wafproxy {
                     $lastactref->{'proxyalias'} = \%updates;                      $lastactref->{'proxyalias'} = \%updates;
                 }                  }
             }              }
               if ((exists($wafproxy{'saml'})) || (keys(%expiresaml))) {
                   my %samlupdates = %expiresaml;
                   foreach my $key (keys(%expiresaml)) {
                       &Apache::lonnet::devalidate_cache_new('proxysaml',$key);
                   }
                   if (ref($wafproxy{'saml'}) eq 'HASH') {
                       my $cachetime = 24*60*60;
                       foreach my $key (keys(%{$wafproxy{'saml'}})) {
                           $samlupdates{$key} = 1;
                           &Apache::lonnet::do_cache_new('proxysaml',$key,$wafproxy{'saml'}{$key},
                                                         $cachetime);
                       }
                   }
                   if (ref($lastactref) eq 'HASH') {
                       $lastactref->{'proxysaml'} = \%samlupdates;
                   }
               }
             $output = &mt('Changes were made to Web Application Firewall/Reverse Proxy').'<ul>';              $output = &mt('Changes were made to Web Application Firewall/Reverse Proxy').'<ul>';
             foreach my $item ('alias','remoteip','ipheader','trusted','vpnint','vpnext','sslopt') {              foreach my $item ('alias','remoteip','ipheader','trusted','vpnint','vpnext','sslopt') {
                 if ($changes{$item}) {                  if ($changes{$item}) {
Line 20119  sub modify_wafproxy { Line 20617  sub modify_wafproxy {
                         unless ($numaliased) {                          unless ($numaliased) {
                             $output .= '<li>'.&mt('Aliases deleted for hostnames').'</li>';                              $output .= '<li>'.&mt('Aliases deleted for hostnames').'</li>';
                         }                          }
                       } elsif ($item eq 'saml') {
                           my $shown; 
                           if (ref($wafproxy{'saml'}) eq 'HASH') {
                               if (keys(%{$wafproxy{'saml'}})) {
                                   $shown = join(', ',sort(keys(%{$wafproxy{'saml'}})));
                               }
                           }
                           if ($shown) {
                               $output .= '<li>'.&mt('Alias used by Shibboleth for: [_1]',
                                                     $shown).'</li>';
                           } else {
                               $output .= '<li>'.&mt('No alias used for Shibboleth').'</li>';
                           }
                     } else {                      } else {
                         if ($item eq 'remoteip') {                          if ($item eq 'remoteip') {
                             my %ip_methods = &remoteip_methods();                              my %ip_methods = &remoteip_methods();
Line 21131  sub modify_loadbalancing { Line 21642  sub modify_loadbalancing {
                             }                              }
                         }                          }
                         if ($changes{'curr'}{$balancer}{'cookie'}) {                          if ($changes{'curr'}{$balancer}{'cookie'}) {
                             $resulttext .= '<li>'.&mt('Load Balancer: [_1] -- cookie use enabled',                              if ($currcookies{$balancer}) {
                                                       $balancer).'</li>';                                   $resulttext .= '<li>'.&mt('Load Balancer: [_1] -- cookie use disabled',
                                                             $balancer).'</li>';
                               } else {
                                   $resulttext .= '<li>'.&mt('Load Balancer: [_1] -- cookie use enabled',
                                                             $balancer).'</li>';
                               }
                         }                          }
                     }                      }
                 }                  }
Line 21912  sub devalidate_remote_domconfs { Line 22428  sub devalidate_remote_domconfs {
     my %thismachine;      my %thismachine;
     map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();      map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
     my @posscached = ('domainconfig','domdefaults','ltitools','usersessions',      my @posscached = ('domainconfig','domdefaults','ltitools','usersessions',
                       'directorysrch','passwdconf','cats','proxyalias');                        'directorysrch','passwdconf','cats','proxyalias','proxysaml');
       my %cache_by_lonhost;
       if (exists($cachekeys->{'samllanding'})) {
           if (ref($cachekeys->{'samllanding'}) eq 'HASH') {
               my %landing = %{$cachekeys->{'samllanding'}};
               my %domservers = &Apache::lonnet::get_servers($dom);
               if (keys(%domservers)) {
                   foreach my $server (keys(%domservers)) {
                       my @cached;
                       next if ($thismachine{$server});
                       if ($landing{$server}) {
                           push(@cached,&escape('samllanding').':'.&escape($server));
                       }
                       if (@cached) {
                           $cache_by_lonhost{$server} = \@cached;
                       }
                   }
               }
           }
       }
     if (keys(%servers)) {      if (keys(%servers)) {
         foreach my $server (keys(%servers)) {          foreach my $server (keys(%servers)) {
             next if ($thismachine{$server});              next if ($thismachine{$server});
             my @cached;              my @cached;
             foreach my $name (@posscached) {              foreach my $name (@posscached) {
                 if ($cachekeys->{$name}) {                  if ($cachekeys->{$name}) {
                     if ($name eq 'proxyalias') {                      if (($name eq 'proxyalias') || ($name eq 'proxysaml')) {
                         if (ref($cachekeys->{$name}) eq 'HASH') {                            if (ref($cachekeys->{$name}) eq 'HASH') {
                             foreach my $key (keys(%{$cachekeys->{$name}})) {                              foreach my $key (keys(%{$cachekeys->{$name}})) {
                                 push(@cached,&escape($name).':'.&escape($key));                                  push(@cached,&escape($name).':'.&escape($key));
                             }                              }
Line 21930  sub devalidate_remote_domconfs { Line 22465  sub devalidate_remote_domconfs {
                     }                      }
                 }                  }
             }              }
               if ((exists($cache_by_lonhost{$server})) &&
                   (ref($cache_by_lonhost{$server}) eq 'ARRAY')) {
                   push(@cached,@{$cache_by_lonhost{$server}});
               }
             if (@cached) {              if (@cached) {
                 &Apache::lonnet::remote_devalidate_cache($server,\@cached);                  &Apache::lonnet::remote_devalidate_cache($server,\@cached);
             }              }

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


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