Diff for /loncom/interface/domainprefs.pm between versions 1.324 and 1.347

version 1.324, 2018/01/01 01:29:38 version 1.347, 2019/01/28 21:36:45
Line 104  $datatable  - HTML containing form eleme Line 104  $datatable  - HTML containing form eleme
   
 In the case of course requests, radio buttons are displayed for each institutional  In the case of course requests, radio buttons are displayed for each institutional
 affiliate type (and also default, and _LC_adv) for each of the course types   affiliate type (and also default, and _LC_adv) for each of the course types 
 (official, unofficial, community, textbook, and placement).    (official, unofficial, community, textbook, placement, and lti).  
 In each case the radio buttons allow the selection of one of four values:    In each case the radio buttons allow the selection of one of four values:  
   
 0, approval, validate, autolimit=N (where N is blank, or a positive integer).  0, approval, validate, autolimit=N (where N is blank, or a positive integer).
Line 352  sub handler { Line 352  sub handler {
                                 col2 => 'Value',},                                  col2 => 'Value',},
                                {col1 => 'Recipient(s) for notifications',                                 {col1 => 'Recipient(s) for notifications',
                                 col2 => 'Value',},                                  col2 => 'Value',},
                                  {col1 => 'Nightly status check e-mail',
                                   col2 => 'Settings',},
                                {col1 => 'Ask helpdesk form settings',                                 {col1 => 'Ask helpdesk form settings',
                                 col2 => 'Value',},],                                  col2 => 'Value',},],
                     print => \&print_contacts,                      print => \&print_contacts,
Line 392  sub handler { Line 394  sub handler {
                     modify => \&modify_usermodification,                      modify => \&modify_usermodification,
                   },                    },
         'scantron' =>          'scantron' =>
                   { text => 'Bubblesheet format file',                    { text => 'Bubblesheet format',
                     help => 'Domain_Configuration_Scantron_Format',                      help => 'Domain_Configuration_Scantron_Format',
                     header => [ {col1 => 'Item',                      header => [ {col1 => 'Bubblesheet format file',
                                  col2 => '',                                   col2 => ''},
                               }],                                  {col1 => 'Bubblesheet data upload formats',
                                    col2 => 'Settings'}],
                     print => \&print_scantron,                      print => \&print_scantron,
                     modify => \&modify_scantron,                      modify => \&modify_scantron,
                   },                    },
Line 625  END Line 628  END
         if (grep(/^contacts$/,@actions)) {          if (grep(/^contacts$/,@actions)) {
             $js .= &contacts_javascript();              $js .= &contacts_javascript();
         }          }
           if (grep(/^scantron$/,@actions)) {
               $js .= &scantron_javascript();
           }
         &Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,$js);          &Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,$js);
     } else {      } else {
 # check if domconfig user exists for the domain.  # check if domconfig user exists for the domain.
Line 781  sub print_config_box { Line 787  sub print_config_box {
         $output =          $output =
             &Apache::lonuserutils::custom_roledefs_js($context,$crstype,$formname,\%full,               &Apache::lonuserutils::custom_roledefs_js($context,$crstype,$formname,\%full, 
                                                       \@templateroles);                                                        \@templateroles);
       } elsif ($action eq 'ltitools') {
           $output .= &ltitools_javascript($settings);
       } elsif ($action eq 'lti') {
           $output .= &lti_javascript($settings);
     }      }
     $output .=      $output .=
          '<table class="LC_nested_outer">           '<table class="LC_nested_outer">
Line 822  sub print_config_box { Line 832  sub print_config_box {
             $output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal);              $output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal);
         } elsif ($action eq 'coursecategories') {          } elsif ($action eq 'coursecategories') {
             $output .= $item->{'print'}->('top',$dom,$item,$settings,\$rowtotal);              $output .= $item->{'print'}->('top',$dom,$item,$settings,\$rowtotal);
           } elsif ($action eq 'scantron') {
               $output .= $item->{'print'}->($r,'top',$dom,$confname,$settings,\$rowtotal);
         } elsif ($action eq 'login') {          } elsif ($action eq 'login') {
             if ($numheaders == 4) {              if ($numheaders == 4) {
                 $colspan = ' colspan="2"';                  $colspan = ' colspan="2"';
Line 900  sub print_config_box { Line 912  sub print_config_box {
              </tr>'."\n";               </tr>'."\n";
                 if ($action eq 'coursecategories') {                  if ($action eq 'coursecategories') {
                     $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);                      $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);
                   } elsif ($action eq 'contacts') {
                       $output .= $item->{'print'}->('lower',$dom,$settings,\$rowtotal).'
                </tr>
               </table>
              </td>
             </tr>
             <tr>
              <td>
               <table class="LC_nested">
                <tr class="LC_info_row">
                 <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>'.
                              $item->{'print'}->('bottom',$dom,$settings,\$rowtotal).'
               </table>
             </td>
            </tr>
            <tr>';
                 } else {                  } else {
                     $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);                      $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
                 }                  }
Line 909  sub print_config_box { Line 938  sub print_config_box {
                  ($action eq 'defaults') || ($action eq 'directorysrch') ||                   ($action eq 'defaults') || ($action eq 'directorysrch') ||
                  ($action eq 'helpsettings')) {                   ($action eq 'helpsettings')) {
             $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);              $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
           } elsif ($action eq 'scantron') {
               $output .= $item->{'print'}->($r,'bottom',$dom,$confname,$settings,\$rowtotal);
         } elsif ($action eq 'ssl') {          } elsif ($action eq 'ssl') {
             $output .= $item->{'print'}->('connto',$dom,$settings,\$rowtotal).'              $output .= $item->{'print'}->('connto',$dom,$settings,\$rowtotal).'
             </table>              </table>
Line 1090  sub print_config_box { Line 1121  sub print_config_box {
                  ($action eq 'serverstatuses') || ($action eq 'loadbalancing') ||                    ($action eq 'serverstatuses') || ($action eq 'loadbalancing') || 
                  ($action eq 'ltitools') || ($action eq 'lti')) {                   ($action eq 'ltitools') || ($action eq 'lti')) {
             $output .= $item->{'print'}->($dom,$settings,\$rowtotal);              $output .= $item->{'print'}->($dom,$settings,\$rowtotal);
         } elsif ($action eq 'scantron') {  
             $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);  
         }          }
     }      }
     $output .= '      $output .= '
Line 1436  sub print_login { Line 1465  sub print_login {
             } else {              } else {
                 $datatable .= '<input type="file" name="loginheadtag_'.$lonhost.'" />';                  $datatable .= '<input type="file" name="loginheadtag_'.$lonhost.'" />';
             }              }
             $datatable .= '</td><td><input type="textbox" 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>';
     }      }
Line 1596  sub display_color_options { Line 1625  sub display_color_options {
     my $datatable = '<tr'.$css_class.'>'.      my $datatable = '<tr'.$css_class.'>'.
         '<td>'.$choices->{'font'}.'</td>';          '<td>'.$choices->{'font'}.'</td>';
     if (!$is_custom->{'font'}) {      if (!$is_custom->{'font'}) {
         $datatable .=  '<td>'.&mt('Default in use:').'&nbsp;<span id="css_default_'.$role.'_font" style="color: '.$defaults->{'font'}.';">'.$defaults->{'font'}.'</span></td>';          $datatable .=  '<td>'.&mt('Default in use:').'&nbsp;<span class="css_default_'.$role.'_font" style="color: '.$defaults->{'font'}.';">'.$defaults->{'font'}.'</span></td>';
     } else {      } else {
         $datatable .= '<td>&nbsp;</td>';          $datatable .= '<td>&nbsp;</td>';
     }      }
Line 1605  sub display_color_options { Line 1634  sub display_color_options {
     $datatable .= '<td><span class="LC_nobreak">'.      $datatable .= '<td><span class="LC_nobreak">'.
                   '<input type="text" class="colorchooser" size="10" name="'.$role.'_font"'.                    '<input type="text" class="colorchooser" size="10" name="'.$role.'_font"'.
                   ' value="'.$current_color.'" />&nbsp;'.                    ' value="'.$current_color.'" />&nbsp;'.
                   '&nbsp;</td></tr>';                    '&nbsp;</span></td></tr>';
     unless ($role eq 'login') {       unless ($role eq 'login') { 
         $datatable .= '<tr'.$css_class.'>'.          $datatable .= '<tr'.$css_class.'>'.
                       '<td>'.$choices->{'fontmenu'}.'</td>';                        '<td>'.$choices->{'fontmenu'}.'</td>';
         if (!$is_custom->{'fontmenu'}) {          if (!$is_custom->{'fontmenu'}) {
             $datatable .=  '<td>'.&mt('Default in use:').'&nbsp;<span id="css_default_'.$role.'_font" style="color: '.$defaults->{'fontmenu'}.';">'.$defaults->{'fontmenu'}.'</span></td>';              $datatable .=  '<td>'.&mt('Default in use:').'&nbsp;<span class="css_default_'.$role.'_font" style="color: '.$defaults->{'fontmenu'}.';">'.$defaults->{'fontmenu'}.'</span></td>';
         } else {          } else {
             $datatable .= '<td>&nbsp;</td>';              $datatable .= '<td>&nbsp;</td>';
         }          }
Line 1620  sub display_color_options { Line 1649  sub display_color_options {
                       '<input class="colorchooser" type="text" size="10" name="'                        '<input class="colorchooser" type="text" size="10" name="'
       .$role.'_fontmenu"'.        .$role.'_fontmenu"'.
                       ' value="'.$current_color.'" />&nbsp;'.                        ' value="'.$current_color.'" />&nbsp;'.
                       '&nbsp;</td></tr>';                        '&nbsp;</span></td></tr>';
     }      }
     my $switchserver = &check_switchserver($dom,$confname);      my $switchserver = &check_switchserver($dom,$confname);
     foreach my $img (@{$images}) {      foreach my $img (@{$images}) {
Line 1738  sub display_color_options { Line 1767  sub display_color_options {
     my $bgs_def;      my $bgs_def;
     foreach my $item (@{$bgs}) {      foreach my $item (@{$bgs}) {
         if (!$is_custom->{$item}) {          if (!$is_custom->{$item}) {
             $bgs_def .= '<td><span class="LC_nobreak">'.$choices->{$item}.'</span>&nbsp;<span id="css_default_'.$role.'_'.$item.'" style="background-color: '.$defaults->{'bgs'}{$item}.';">&nbsp;&nbsp;&nbsp;</span><br />'.$defaults->{'bgs'}{$item}.'</td>';              $bgs_def .= '<td><span class="LC_nobreak">'.$choices->{$item}.'</span>&nbsp;<span class="css_default_'.$role.'_'.$item.'" style="background-color: '.$defaults->{'bgs'}{$item}.';">&nbsp;&nbsp;&nbsp;</span><br />'.$defaults->{'bgs'}{$item}.'</td>';
         }          }
     }      }
     if ($bgs_def) {      if ($bgs_def) {
Line 1766  sub display_color_options { Line 1795  sub display_color_options {
     my $links_def;      my $links_def;
     foreach my $item (@{$links}) {      foreach my $item (@{$links}) {
         if (!$is_custom->{$item}) {          if (!$is_custom->{$item}) {
             $links_def .= '<td>'.$choices->{$item}.'<br /><span id="css_default_'.$role.'_'.$item.'" style="color: '.$defaults->{'links'}{$item}.';">'.$defaults->{'links'}{$item}.'</span></td>';              $links_def .= '<td>'.$choices->{$item}.'<br /><span class="css_default_'.$role.'_'.$item.'" style="color: '.$defaults->{'links'}{$item}.';">'.$defaults->{'links'}{$item}.'</span></td>';
         }          }
     }      }
     if ($links_def) {      if ($links_def) {
Line 1852  sub image_changes { Line 1881  sub image_changes {
     my ($is_custom,$alt_text,$img_import,$showfile,$fullsize,$role,$img,$imgfile,$logincolors) = @_;      my ($is_custom,$alt_text,$img_import,$showfile,$fullsize,$role,$img,$imgfile,$logincolors) = @_;
     my $output;      my $output;
     if ($img eq 'login') {      if ($img eq 'login') {
             # suppress image for Log-in header          $output = '</td><td>'.$logincolors; # suppress image for Log-in header
     } elsif (!$is_custom) {      } elsif (!$is_custom) {
         if ($img ne 'domlogo') {          if ($img ne 'domlogo') {
             $output .= &mt('Default image:').'<br />';              $output = &mt('Default image:').'<br />';
         } else {          } else {
             $output .= &mt('Default in use:').'<br />';              $output = &mt('Default in use:').'<br />';
         }          }
     }      }
     if ($img eq 'login') { # suppress image for Log-in header      if ($img ne 'login') {
         $output .= '<td>'.$logincolors;  
     } else {  
         if ($img_import) {          if ($img_import) {
             $output .= '<input type="hidden" name="'.$role.'_import_'.$img.'" value="'.$imgfile.'" />';              $output .= '<input type="hidden" name="'.$role.'_import_'.$img.'" value="'.$imgfile.'" />';
         }          }
Line 1893  sub print_quotas { Line 1920  sub print_quotas {
     my $typecount = 0;      my $typecount = 0;
     my ($css_class,%titles);      my ($css_class,%titles);
     if ($context eq 'requestcourses') {      if ($context eq 'requestcourses') {
         @usertools = ('official','unofficial','community','textbook','placement');          @usertools = ('official','unofficial','community','textbook','placement','lti');
         @options =('norequest','approval','validate','autolimit');          @options =('norequest','approval','validate','autolimit');
         %validations = &Apache::lonnet::auto_courserequest_checks($dom);          %validations = &Apache::lonnet::auto_courserequest_checks($dom);
         %titles = &courserequest_titles();          %titles = &courserequest_titles();
Line 2357  sub print_studentcode { Line 2384  sub print_studentcode {
     my ($settings,$rowtotal) = @_;      my ($settings,$rowtotal) = @_;
     my $rownum = 0;       my $rownum = 0; 
     my ($output,%current);      my ($output,%current);
     my @crstypes = ('official','unofficial','community','textbook','placement');      my @crstypes = ('official','unofficial','community','textbook','placement','lti');
     if (ref($settings) eq 'HASH') {      if (ref($settings) eq 'HASH') {
         if (ref($settings->{'uniquecode'}) eq 'HASH') {          if (ref($settings->{'uniquecode'}) eq 'HASH') {
             foreach my $type (@crstypes) {              foreach my $type (@crstypes) {
Line 2484  sub print_textbookcourses { Line 2511  sub print_textbookcourses {
         $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';          $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
     }      }
     $datatable .= '</select>&nbsp;'."\n".      $datatable .= '</select>&nbsp;'."\n".
                   '<input type="checkbox" name="'.$type.'_addbook" value="1" />'.&mt('Add').'</td>'."\n".                    '<input type="checkbox" name="'.$type.'_addbook" value="1" />'.&mt('Add').'</span></td>'."\n".
                   '<td colspan="2">'.                    '<td colspan="2">'.
                   '<span class="LC_nobreak">'.&mt('Subject:').'<input type="text" size="15" name="'.$type.'_addbook_subject" value="" /></span> '."\n".                    '<span class="LC_nobreak">'.&mt('Subject:').'<input type="text" size="15" name="'.$type.'_addbook_subject" value="" /></span> '."\n".
                   ('&nbsp;'x2).                    ('&nbsp;'x2).
Line 2501  sub print_textbookcourses { Line 2528  sub print_textbookcourses {
         } else {          } else {
             $datatable .= '<input type="file" name="'.$type.'_addbook_image" value="" />';              $datatable .= '<input type="file" name="'.$type.'_addbook_image" value="" />';
         }          }
           $datatable .= '</span>'."\n";
     }      }
     $datatable .= '</span>'."\n".      $datatable .= '<span class="LC_nobreak">'.&mt('LON-CAPA course:').'&nbsp;'.
                   '<span class="LC_nobreak">'.&mt('LON-CAPA course:').'&nbsp;'.  
                   &Apache::loncommon::select_dom_form($env{'request.role.domain'},$type.'_addbook_cdom').                    &Apache::loncommon::select_dom_form($env{'request.role.domain'},$type.'_addbook_cdom').
                   '<input type="text" size="25" name="'.$type.'_addbook_cnum" value="" />'.                    '<input type="text" size="25" name="'.$type.'_addbook_cnum" value="" />'.
                   &Apache::loncommon::selectcourse_link                    &Apache::loncommon::selectcourse_link
                       ('display',$type.'_addbook_cnum',$type.'_addbook_cdom',undef,undef,undef,'Course');                        ('display',$type.'_addbook_cnum',$type.'_addbook_cdom',undef,undef,undef,'Course').
                   '</span></td>'."\n".                    '</span></td>'."\n".
                   '</tr>'."\n";                    '</tr>'."\n";
     $itemcount ++;      $itemcount ++;
Line 2806  ENDSCRIPT Line 2833  ENDSCRIPT
 }  }
   
 sub lti_toggle_js {  sub lti_toggle_js {
       my %lcauthparmtext = &Apache::lonlocal::texthash (
                               localauth => 'Local auth argument',
                               krb       => 'Kerberos domain',
                            );
     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 == 'user') || (setting == 'crs')) {      if (setting == 'requser') {
           var fieldsets = document.getElementsByClassName('ltioption_'+item);
           if (fieldsets.length) {
               var radioname = 'lti_'+setting+'_'+item;
               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') {
                              setvis = 1;
                              break;
                           }
                       }
                   }
                   for (var j=0; j<fieldsets.length; j++) { 
                       if (setvis) {
                           fieldsets[j].style.display = 'block';
                       } else {
                           fieldsets[j].style.display = 'none';
                       }
                   }
               }
           }
       } else if ((setting == 'user') || (setting == 'crs') || (setting == 'passback')) {
         var radioname = '';          var radioname = '';
         var divid = '';          var divid = '';
         if (setting == 'user') {          if (setting == 'user') {
             radioname = 'lti_mapuser_'+item;              radioname = 'lti_mapuser_'+item;
             divid = 'lti_userfield_'+item;              divid = 'lti_userfield_'+item;
         } else {          } else if (setting == 'crs') {
             radioname = 'lti_mapcrs_'+item;              radioname = 'lti_mapcrs_'+item;
             divid = 'lti_crsfield_'+item;              divid = 'lti_crsfield_'+item;
           } else {
               radioname = 'lti_passbackformat_'+item;
               divid =  'lti_passback_'+item;
         }          }
         var num = form.elements[radioname].length;          var num = form.elements[radioname].length;
         if (num) {          if (num) {
             var setvis = '';              var setvis = '';
             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 == 'other') {                     if (setting == 'passback') {
                        if (document.getElementById(divid)) {                         if (form.elements[radioname][i].value == '1') {
                            document.getElementById(divid).style.display = 'inline-block';                             if (document.getElementById(divid)) {
                                  document.getElementById(divid).style.display = 'inline-block';
                              }
                              setvis = 1;
                              break;
                          }
                      } else {
                          if (form.elements[radioname][i].value == 'other') {
                              if (document.getElementById(divid)) {
                                  document.getElementById(divid).style.display = 'inline-block';
                              }
                              setvis = 1;
                              break;
                        }                         }
                        setvis = 1;  
                        break;  
                    }                     }
                }                  } 
             }              }
Line 2883  function toggleLTI(form,setting,item) { Line 2951  function toggleLTI(form,setting,item) {
                 }                  }
             }              }
         }          }
       } else if (setting == 'lcauth') {
           var numauth = form.elements['lti_lcauth_'+item].length;
           if (numauth) {
               for (var i=0; i<numauth; i++) {
                   if (form.elements['lti_lcauth_'+item][i].checked) {
                       if (document.getElementById('lti_'+setting+'_parmrow_'+item)) {
                           if ((form.elements['lti_'+setting+'_'+item][i].value == 'internal') || (form.elements['lti_'+setting+'_'+item][i].value == 'lti')) {
                               document.getElementById('lti_'+setting+'_parmrow_'+item).style.display = 'none';
                           } else {
                               document.getElementById('lti_'+setting+'_parmrow_'+item).style.display = 'table-row';
                               if (document.getElementById('lti_'+setting+'_parmtext_'+item)) {
                                   if (form.elements['lti_'+setting+'_'+item][i].value == 'localauth') {
                                       document.getElementById('lti_'+setting+'_parmtext_'+item).innerHTML = "$lcauthparmtext{'localauth'}";
                                   } else {
                                       document.getElementById('lti_'+setting+'_parmtext_'+item).innerHTML = "$lcauthparmtext{'krb'}";
                                   }
                               }
                           }
                       }
                   }
               }
           }
       } else if (setting == 'lcmenu') {
           var menus = new Array('lti_topmenu_'+item,'lti_inlinemenu_'+item);
           var divid = 'lti_menufield_'+item;
           var setvis = '';
           for (var i=0; i<menus.length; i++) {
               var radioname = menus[i];  
               var num = form.elements[radioname].length;
               if (num) {
                   for (var j=0; j<num; j++) {
                       if (form.elements[radioname][j].checked) {
                           if (form.elements[radioname][j].value == '1') {
                               if (document.getElementById(divid)) {
                                   document.getElementById(divid).style.display = 'inline-block';
                               }
                               setvis = 1;
                               break;
                           }
                       }
                   }
               }
               if (setvis == 1) {
                   break;
               }
           }
           if (!setvis) {
               if (document.getElementById(divid)) {
                   document.getElementById(divid).style.display = 'none';
               }
           }
     }      }
     return;      return;
 }  }
Line 2971  sub print_autoenroll { Line 3090  sub print_autoenroll {
                   '<td>'.&mt('Failsafe for no drops when institutional data missing').'</td>'.                    '<td>'.&mt('Failsafe for no drops when institutional data missing').'</td>'.
                   '<td class="LC_right_item"><span class="LC_nobreak">'.                    '<td class="LC_right_item"><span class="LC_nobreak">'.
                   '<input type="text" name="autoenroll_failsafe"'.                    '<input type="text" name="autoenroll_failsafe"'.
                   ' value="'.$failsafe.'" size="4" /></td></tr>';                    ' value="'.$failsafe.'" size="4" /></span></td></tr>';
     $$rowtotal += 4;      $$rowtotal += 4;
     return $datatable;      return $datatable;
 }  }
Line 3253  sub print_contacts { Line 3372  sub print_contacts {
     my $datatable;      my $datatable;
     my @contacts = ('adminemail','supportemail');      my @contacts = ('adminemail','supportemail');
     my (%checked,%to,%otheremails,%bccemails,%includestr,%includeloc,%currfield,      my (%checked,%to,%otheremails,%bccemails,%includestr,%includeloc,%currfield,
         $maxsize,$fields,$fieldtitles,$fieldoptions,$possoptions,@mailings);          $maxsize,$fields,$fieldtitles,$fieldoptions,$possoptions,@mailings,%lonstatus);
     if ($position eq 'top') {      if ($position eq 'top') {
         if (ref($settings) eq 'HASH') {          if (ref($settings) eq 'HASH') {
             foreach my $item (@contacts) {              foreach my $item (@contacts) {
Line 3268  sub print_contacts { Line 3387  sub print_contacts {
         foreach my $type (@mailings) {          foreach my $type (@mailings) {
             $otheremails{$type} = '';              $otheremails{$type} = '';
         }          }
       } elsif ($position eq 'lower') {
           if (ref($settings) eq 'HASH') {
               if (ref($settings->{'lonstatus'}) eq 'HASH') {
                   %lonstatus = %{$settings->{'lonstatus'}};
               }
           }
     } else {      } else {
         @mailings = ('helpdeskmail','otherdomsmail');          @mailings = ('helpdeskmail','otherdomsmail');
         foreach my $type (@mailings) {          foreach my $type (@mailings) {
Line 3280  sub print_contacts { Line 3405  sub print_contacts {
         ($fields,$fieldtitles,$fieldoptions,$possoptions) = &helpform_fields();          ($fields,$fieldtitles,$fieldoptions,$possoptions) = &helpform_fields();
     }      }
     if (ref($settings) eq 'HASH') {      if (ref($settings) eq 'HASH') {
         unless ($position eq 'top') {          unless (($position eq 'top') || ($position eq 'lower')) {
             foreach my $type (@mailings) {              foreach my $type (@mailings) {
                 if (exists($settings->{$type})) {                  if (exists($settings->{$type})) {
                     if (ref($settings->{$type}) eq 'HASH') {                      if (ref($settings->{$type}) eq 'HASH') {
Line 3401  sub print_contacts { Line 3526  sub print_contacts {
                     if ($currfield{$field} eq 'no') {                      if ($currfield{$field} eq 'no') {
                         $display = ' style="display:none"';                          $display = ' style="display:none"';
                     }                      }
                     $datatable .= '</td></tr><tr id="help_screenshotsize"'.$display.' />'.                      $datatable .= '</td></tr><tr id="help_screenshotsize"'.$display.'>'.
                                   '<td>'.&mt('Maximum size for upload (MB)').'</td><td>'.                                    '<td>'.&mt('Maximum size for upload (MB)').'</td><td>'.
                                   '<input type="text" size="5" name="helpform_maxsize" value="'.$maxsize.'" />';                                    '<input type="text" size="5" name="helpform_maxsize" value="'.$maxsize.'" />';
                 }                  }
Line 3412  sub print_contacts { Line 3537  sub print_contacts {
         $datatable .= '</td></tr>'."\n";          $datatable .= '</td></tr>'."\n";
         $rownum ++;          $rownum ++;
     }      }
     unless ($position eq 'top') {      unless (($position eq 'top') || ($position eq 'lower')) {
         foreach my $type (@mailings) {          foreach my $type (@mailings) {
             $css_class = $rownum%2?' class="LC_odd_row"':'';              $css_class = $rownum%2?' class="LC_odd_row"':'';
             $datatable .= '<tr'.$css_class.'>'.              $datatable .= '<tr'.$css_class.'>'.
Line 3446  sub print_contacts { Line 3571  sub print_contacts {
                               'value="'.$bccemails{$type}.'"  /></fieldset>'.                                'value="'.$bccemails{$type}.'"  /></fieldset>'.
                               '<fieldset><legend>'.&mt('Optional added text').'</legend>'.                                '<fieldset><legend>'.&mt('Optional added text').'</legend>'.
                               &mt('Text automatically added to e-mail:').' '.                                &mt('Text automatically added to e-mail:').' '.
                               '<input type="text" name="'.$type.'_includestr" value="'.$includestr{$type}.'" /><br >'.                                '<input type="text" name="'.$type.'_includestr" value="'.$includestr{$type}.'" /><br />'.
                               '<span class="LC_nobreak">'.&mt('Location:').'&nbsp;'.                                '<span class="LC_nobreak">'.&mt('Location:').'&nbsp;'.
                               '<label><input type="radio" name="'.$type.'_includeloc" value="s"'.$locchecked{'s'}.' />'.&mt('in subject').'</label>'.                                '<label><input type="radio" name="'.$type.'_includeloc" value="s"'.$locchecked{'s'}.' />'.&mt('in subject').'</label>'.
                               ('&nbsp;'x2).                                ('&nbsp;'x2).
Line 3459  sub print_contacts { Line 3584  sub print_contacts {
     }      }
     if ($position eq 'middle') {      if ($position eq 'middle') {
         my %choices;          my %choices;
         $choices{'reporterrors'} = &mt('E-mail error reports to [_1]',          my $corelink = &core_link_msu();
                                        &Apache::loncommon::modal_link('http://loncapa.org/core.html',          $choices{'reporterrors'} = &mt('E-mail error reports to [_1]',$corelink);
                                        &mt('LON-CAPA core group - MSU'),600,500));  
         $choices{'reportupdates'} = &mt('E-mail record of completed LON-CAPA updates to [_1]',          $choices{'reportupdates'} = &mt('E-mail record of completed LON-CAPA updates to [_1]',
                                         &Apache::loncommon::modal_link('http://loncapa.org/core.html',                                          $corelink);
                                         &mt('LON-CAPA core group - MSU'),600,500));          $choices{'reportstatus'} = &mt('E-mail status if errors above threshold to [_1]',$corelink);
         my @toggles = ('reporterrors','reportupdates');          my @toggles = ('reporterrors','reportupdates','reportstatus');
         my %defaultchecked = ('reporterrors'  => 'on',          my %defaultchecked = ('reporterrors'  => 'on',
                               'reportupdates' => 'on');                                'reportupdates' => 'on',
                                 'reportstatus'  => 'on');
         (my $reports,$rownum) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,          (my $reports,$rownum) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
                                                    \%choices,$rownum);                                                     \%choices,$rownum);
         $datatable .= $reports;          $datatable .= $reports;
       } elsif ($position eq 'lower') {
           $css_class = $rownum%2?' class="LC_odd_row"':'';
           my ($threshold,$sysmail,%excluded,%weights);
           my ($defaults,$names) = &Apache::loncommon::lon_status_items();
           if ($lonstatus{'threshold'} =~ /^\d+$/) {
               $threshold = $lonstatus{'threshold'};
           } else {
               $threshold = $defaults->{'threshold'};
           }
           if ($lonstatus{'sysmail'} =~ /^\d+$/) {
               $sysmail = $lonstatus{'sysmail'};
           } else {
               $sysmail = $defaults->{'sysmail'};
           }
           if (ref($lonstatus{'weights'}) eq 'HASH') {
               foreach my $type ('E','W','N','U') {
                   if ($lonstatus{'weights'}{$type} =~ /^\d+$/) {
                       $weights{$type} = $lonstatus{'weights'}{$type};
                   } else {
                       $weights{$type} = $defaults->{$type};
                   }
               }
           } else {
               foreach my $type ('E','W','N','U') {
                   $weights{$type} = $defaults->{$type};
               }
           }
           if (ref($lonstatus{'excluded'}) eq 'ARRAY') {
               if (@{$lonstatus{'excluded'}} > 0) {
                   map {$excluded{$_} = 1; } @{$lonstatus{'excluded'}};
               }
           }
           $datatable .= '<tr'.$css_class.'>'.
                         '<td class="LC_left_item"><span class="LC_nobreak">'.
                         $titles->{'errorthreshold'}.
                         '</span></td><td class="LC_left_item">'.
                         '<input type="text" name="errorthreshold" value="'.
                         $threshold.'" size="5" /></td></tr>';
           $rownum ++;
           $css_class = $rownum%2?' class="LC_odd_row"':'';
           $datatable .= '<tr'.$css_class.'>'.
                         '<td class="LC_left_item">'.
                         '<span class="LC_nobreak">'.$titles->{'errorweights'}.
                         '</span></td><td class="LC_left_item"><table><tr>';
           foreach my $type ('E','W','N','U') {
               $datatable .= '<td>'.$names->{$type}.'<br />'.
                             '<input type="text" name="errorweights_'.$type.'" value="'.
                             $weights{$type}.'" size="5" /></td>';
           }
           $datatable .= '</tr></table></tr>';
           $rownum ++;
           $css_class = $rownum%2?' class="LC_odd_row"':'';
           $datatable .= '<tr'.$css_class.'><td class="LC_left_item">'.
                         $titles->{'errorexcluded'}.'</td>'.
                         '<td class="LC_left_item"><table>';
           my $numinrow = 4;
           my @ids = sort(values(%Apache::lonnet::serverhomeIDs));
           for (my $i=0; $i<@ids; $i++) {
               my $rem = $i%($numinrow);
               if ($rem == 0) {
                   if ($i > 0) {
                       $datatable .= '</tr>';
                   }
                   $datatable .= '<tr>';
               }
               my $check;
               if ($excluded{$ids[$i]}) {
                   $check = ' checked="checked" ';
               }
               $datatable .= '<td class="LC_left_item">'.
                             '<span class="LC_nobreak"><label>'.
                             '<input type="checkbox" name="errorexcluded" '.
                             'value="'.$ids[$i].'"'.$check.' />'.
                             $ids[$i].'</label></span></td>';
           }
           my $colsleft = $numinrow - @ids%($numinrow);
           if ($colsleft > 1 ) {
               $datatable .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
                             '&nbsp;</td>';
           } elsif ($colsleft == 1) {
               $datatable .= '<td class="LC_left_item">&nbsp;</td>';
           }
           $datatable .= '</tr></table></td></tr>';
           $rownum ++;
           $css_class = $rownum%2?' class="LC_odd_row"':'';
           $datatable .= '<tr'.$css_class.'>'.
                         '<td class="LC_left_item"><span class="LC_nobreak">'.
                         $titles->{'errorsysmail'}.
                         '</span></td><td class="LC_left_item">'.
                         '<input type="text" name="errorsysmail" value="'.
                         $sysmail.'" size="5" /></td></tr>';
           $rownum ++;
     } elsif ($position eq 'bottom') {      } elsif ($position eq 'bottom') {
         my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);          my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
         my (@posstypes,%usertypeshash);          my (@posstypes,%usertypeshash);
Line 3544  sub print_contacts { Line 3761  sub print_contacts {
     return $datatable;      return $datatable;
 }  }
   
   sub core_link_msu {
       return &Apache::loncommon::modal_link('http://loncapa.org/core.html',
                                             &mt('LON-CAPA core group - MSU'),600,500);
   }
   
 sub overridden_helpdesk {  sub overridden_helpdesk {
     my ($checked,$otheremails,$bccemails,$includeloc,$includestr,$type,$rowid,      my ($checked,$otheremails,$bccemails,$includeloc,$includestr,$type,$rowid,
         $typetitle,$css_class,$rowstyle,$contacts,$short_titles) = @_;          $typetitle,$css_class,$rowstyle,$contacts,$short_titles) = @_;
Line 3594  sub overridden_helpdesk { Line 3816  sub overridden_helpdesk {
                'value="'.$bccemails.'"  /></fieldset>'.                 'value="'.$bccemails.'"  /></fieldset>'.
                '<fieldset><legend>'.&mt('Optional added text').'</legend>'.                 '<fieldset><legend>'.&mt('Optional added text').'</legend>'.
                &mt('Text automatically added to e-mail:').' '.                 &mt('Text automatically added to e-mail:').' '.
                '<input type="text" name="override_'.$type.'_includestr" value="'.$includestr.'" /><br >'.                 '<input type="text" name="override_'.$type.'_includestr" value="'.$includestr.'" /><br />'.
                '<span class="LC_nobreak">'.&mt('Location:').'&nbsp;'.                 '<span class="LC_nobreak">'.&mt('Location:').'&nbsp;'.
                '<label><input type="radio" name="override_'.$type.'_includeloc" value="s"'.$locchecked{'s'}.' />'.&mt('in subject').'</label>'.                 '<label><input type="radio" name="override_'.$type.'_includeloc" value="s"'.$locchecked{'s'}.' />'.&mt('in subject').'</label>'.
                ('&nbsp;'x2).                 ('&nbsp;'x2).
Line 3723  sub print_helpsettings { Line 3945  sub print_helpsettings {
             push(@jsarray,('notinc','notexc'));              push(@jsarray,('notinc','notexc'));
         }          }
         my $hiddenstr = join("','",@jsarray);          my $hiddenstr = join("','",@jsarray);
         $datatable .= &helpsettings_javascript(\@roles_by_num,$maxnum,$hiddenstr,$formname);  
         my $context = 'domprefs';          my $context = 'domprefs';
         my $crstype = 'Course';          my $crstype = 'Course';
         my $prefix = 'helproles_';          my $prefix = 'helproles_';
Line 3826  sub print_helpsettings { Line 4047  sub print_helpsettings {
                                                                 \@templateroles,$newcust).                                                                  \@templateroles,$newcust).
                       &Apache::lonuserutils::custom_role_table('Course',\%full,\%levels,                        &Apache::lonuserutils::custom_role_table('Course',\%full,\%levels,
                                                                \%levelscurrent,$newcust).                                                                 \%levelscurrent,$newcust).
                       '</fieldset></td></tr>';                        '</fieldset>'.
                         &helpsettings_javascript(\@roles_by_num,$maxnum,$hiddenstr,$formname).
                         '</td></tr>';
         $count ++;          $count ++;
         $$rowtotal += $count;          $$rowtotal += $count;
     }      }
Line 4115  sub print_ltitools { Line 4338  sub print_ltitools {
     my $confname = $dom.'-domainconfig';      my $confname = $dom.'-domainconfig';
     my $switchserver = &check_switchserver($dom,$confname);      my $switchserver = &check_switchserver($dom,$confname);
     my $maxnum = scalar(keys(%ordered));      my $maxnum = scalar(keys(%ordered));
     my $datatable = &ltitools_javascript($settings);      my $datatable;
     my %lt = &ltitools_names();      my %lt = &ltitools_names();
     my @courseroles = ('cc','in','ta','ep','st');      my @courseroles = ('cc','in','ta','ep','st');
     my @ltiroles = qw(Instructor ContentDeveloper TeachingAssistant Learner);      my @ltiroles = qw(Instructor ContentDeveloper TeachingAssistant Learner);
Line 4216  sub print_ltitools { Line 4439  sub print_ltitools {
                               '<input type="text" name="ltitools_'.$dimen.'_'.$i.'" size="5" value="'.$currdisp{$dimen}.'" /></label>'.                                '<input type="text" name="ltitools_'.$dimen.'_'.$i.'" size="5" value="'.$currdisp{$dimen}.'" /></label>'.
                               ('&nbsp;'x2);                                ('&nbsp;'x2);
             }              }
             $datatable .= '<br />'.              $datatable .= '</span><br />'.
                           '<div class="LC_left_float">'.$lt{'linktext'}.'<br />'.                            '<div class="LC_left_float">'.$lt{'linktext'}.'<br />'.
                           '<input type="text" name="ltitools_linktext_'.$i.'" size="25" value="'.$currdisp{'linktext'}.'" /></label></div>'.                            '<input type="text" name="ltitools_linktext_'.$i.'" size="25" value="'.$currdisp{'linktext'}.'" /></div>'.
                           '<div class="LC_left_float">'.$lt{'explanation'}.'<br />'.                            '<div class="LC_left_float">'.$lt{'explanation'}.'<br />'.
                           '<textarea name="ltitools_explanation_'.$i.'" rows="5" cols="40">'.$currdisp{'explanation'}.                            '<textarea name="ltitools_explanation_'.$i.'" rows="5" cols="40">'.$currdisp{'explanation'}.
                           '</textarea></div><div style=""></div><br />';                            '</textarea></div><div style=""></div><br />';
Line 4389  sub print_ltitools { Line 4612  sub print_ltitools {
         $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';          $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
     }      }
     $datatable .= '</select>&nbsp;'."\n".      $datatable .= '</select>&nbsp;'."\n".
                   '<input type="checkbox" name="ltitools_add" value="1" />'.&mt('Add').'</td>'."\n".                    '<input type="checkbox" name="ltitools_add" value="1" />'.&mt('Add').'</span></td>'."\n".
                   '<td colspan="2">'.                    '<td colspan="2">'.
                   '<fieldset><legend>'.&mt('Required settings').'</legend>'.                    '<fieldset><legend>'.&mt('Required settings').'</legend>'.
                   '<span class="LC_nobreak">'.$lt{'title'}.':<input type="text" size="20" name="ltitools_add_title" value="" /></span> '."\n".                    '<span class="LC_nobreak">'.$lt{'title'}.':<input type="text" size="20" name="ltitools_add_title" value="" /></span> '."\n".
Line 4426  sub print_ltitools { Line 4649  sub print_ltitools {
                       '<input type="text" name="ltitools_add_'.$dimen.'" size="5" /></label>'.                        '<input type="text" name="ltitools_add_'.$dimen.'" size="5" /></label>'.
                       ('&nbsp;'x2);                        ('&nbsp;'x2);
     }      }
     $datatable .= '<br />'.      $datatable .= '</span><br />'.
                   '<div class="LC_left_float">'.$lt{'linktext'}.'<br />'.                    '<div class="LC_left_float">'.$lt{'linktext'}.'<br />'.
                   '<input type="text" name="ltitools_add_linktext" size="5" /></label></div>'.                    '<input type="text" name="ltitools_add_linktext" size="5" /></div>'.
                   '<div class="LC_left_float">'.$lt{'explanation'}.'<br />'.                    '<div class="LC_left_float">'.$lt{'explanation'}.'<br />'.
                   '<textarea name=ltitools_add_explanation" rows="5" cols="40"></textarea>'.                    '<textarea name="ltitools_add_explanation" rows="5" cols="40"></textarea>'.
                   '</div><div style=""></div><br />';                    '</div><div style=""></div><br />';
     my %units = (      my %units = (
                   'passback' => 'days',                    'passback' => 'days',
Line 4509  sub print_ltitools { Line 4732  sub print_ltitools {
                   '<label><input type="checkbox" name="ltitools_add_custom" value="1" />'.                    '<label><input type="checkbox" name="ltitools_add_custom" value="1" />'.
                   &mt('Add').'</label></span></td><td><input type="text" name="ltitools_add_custom_name" />'.                    &mt('Add').'</label></span></td><td><input type="text" name="ltitools_add_custom_name" />'.
                   '</td><td><input type="text" name="ltitools_add_custom_value" /></td></tr>'.                    '</td><td><input type="text" name="ltitools_add_custom_value" /></td></tr>'.
                   '</table></fieldset></td></tr>'."\n".                    '</table></fieldset>'."\n".
                   '</td>'."\n".                    '</td>'."\n".
                   '</tr>'."\n";                    '</tr>'."\n";
     $itemcount ++;      $itemcount ++;
Line 4567  sub print_lti { Line 4790  sub print_lti {
         }          }
     }      }
     my $maxnum = scalar(keys(%ordered));      my $maxnum = scalar(keys(%ordered));
     my $datatable = &lti_javascript($settings);      my $datatable;
     my %lt = &lti_names();      my %lt = &lti_names();
     if (keys(%ordered)) {      if (keys(%ordered)) {
         my @items = sort { $a <=> $b } keys(%ordered);          my @items = sort { $a <=> $b } keys(%ordered);
         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,$current);              my ($key,$secret,$lifetime,$consumer,$requser,$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'};
                 $current = $settings->{$item};                  $current = $settings->{$item};
             }              }
               my $onclickrequser = ' onclick="toggleLTI(this.form,'."'requser','$i'".');"';
               my %checkedrequser = (
                                      yes => ' checked="checked"',
                                      no  => '',
                                    );
               if (!$requser) {
                   $checkedrequser{'no'} = $checkedrequser{'yes'};
                   $checkedrequser{'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 4599  sub print_lti { Line 4832  sub print_lti {
                 '<td colspan="2">'.                  '<td colspan="2">'.
                 '<fieldset><legend>'.&mt('Required settings').'</legend>'.                  '<fieldset><legend>'.&mt('Required settings').'</legend>'.
                 '<span class="LC_nobreak">'.$lt{'consumer'}.                  '<span class="LC_nobreak">'.$lt{'consumer'}.
                 ':<input type="text" size="20" name="lti_consumer_'.$i.'" value="'.$consumer.'" /></span> '.                  ':<input type="text" size="15" name="lti_consumer_'.$i.'" value="'.$consumer.'" /></span> '.
                 ('&nbsp;'x2).                  ('&nbsp;'x2).
                 '<span class="LC_nobreak">'.$lt{'version'}.':<select name="lti_version_'.$i.'">'.                  '<span class="LC_nobreak">'.$lt{'version'}.':<select name="lti_version_'.$i.'">'.
                 '<option value="LTI-1p0" selected="selected">1.1</option></select></span> '.                  '<option value="LTI-1p0" selected="selected">1.1</option></select></span> '.
                 ('&nbsp;'x2).                  ('&nbsp;'x2).
                 '<span class="LC_nobreak">'.$lt{'lifetime'}.':<input type="text" name="lti_lifetime_'.$i.'"'.                  '<span class="LC_nobreak">'.$lt{'lifetime'}.':<input type="text" name="lti_lifetime_'.$i.'"'.
                 'value="'.$lifetime.'" size="5" /></span>'.                  'value="'.$lifetime.'" size="3" /></span>'.
                   ('&nbsp;'x2).
                    '<span class="LC_nobreak">'.$lt{'requser'}.':'.
                    '<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".
                 '<br /><br />'.                  '<br /><br />'.
                 '<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> '.
Line 4614  sub print_lti { Line 4851  sub print_lti {
                 '<input type="password" size="20" name="lti_secret_'.$i.'" value="'.$secret.'" />'.                  '<input type="password" size="20" name="lti_secret_'.$i.'" value="'.$secret.'" />'.
                 '<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.lti_secret_'.$i.'.type='."'text'".' } else { this.form.lti_secret_'.$i.'.type='."'password'".' }" />'.&mt('Visible input').'</label>'.                  '<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.lti_secret_'.$i.'.type='."'text'".' } else { this.form.lti_secret_'.$i.'.type='."'password'".' }" />'.&mt('Visible input').'</label>'.
                 '<input type="hidden" name="lti_id_'.$i.'" value="'.$item.'" /></span>'.                  '<input type="hidden" name="lti_id_'.$i.'" value="'.$item.'" /></span>'.
                 '</fieldset>'.&lti_options($i,$current,%lt).'</td></tr>';                  '</fieldset>'.&lti_options($i,$current,$itemcount,%lt).'</td></tr>';
             $itemcount ++;              $itemcount ++;
         }          }
     }      }
Line 4632  sub print_lti { Line 4869  sub print_lti {
         $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';          $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
     }      }
     $datatable .= '</select>&nbsp;'."\n".      $datatable .= '</select>&nbsp;'."\n".
                   '<input type="checkbox" name="lti_add" value="1" />'.&mt('Add').'</td>'."\n".                    '<input type="checkbox" name="lti_add" value="1" />'.&mt('Add').'</span></td>'."\n".
                   '<td colspan="2">'.                    '<td colspan="2">'.
                   '<fieldset><legend>'.&mt('Required settings').'</legend>'.                    '<fieldset><legend>'.&mt('Required settings').'</legend>'.
                   '<span class="LC_nobreak">'.$lt{'consumer'}.                    '<span class="LC_nobreak">'.$lt{'consumer'}.
                   ':<input type="text" size="20" name="lti_consumer_add" value="" /></span> '."\n".                    ':<input type="text" size="15" name="lti_consumer_add" value="" /></span> '."\n".
                   ('&nbsp;'x2).                    ('&nbsp;'x2).
                   '<span class="LC_nobreak">'.$lt{'version'}.':<select name="lti_version_add">'.                    '<span class="LC_nobreak">'.$lt{'version'}.':<select name="lti_version_add">'.
                   '<option value="LTI-1p0" selected="selected">1.1</option></select></span> '."\n".                    '<option value="LTI-1p0" selected="selected">1.1</option></select></span> '."\n".
                   ('&nbsp;'x2).                    ('&nbsp;'x2).
                   '<span class="LC_nobreak">'.$lt{'lifetime'}.':<input type="text" size="5" name="lti_lifetime_add" value="300" /></span> '."\n".                    '<span class="LC_nobreak">'.$lt{'lifetime'}.':<input type="text" size="3" name="lti_lifetime_add" value="300" /></span> '."\n".
                     ('&nbsp;'x2).
                     '<span class="LC_nobreak">'.$lt{'requser'}.':'.
                     '<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".
                   '<br /><br />'.                    '<br /><br />'.
                   '<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="" />'.
                   '<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.lti_secret_add.type='."'text'".' } else { this.form.lti_secret_add.type='."'password'".' }" />'.&mt('Visible input').'</label></span> '."\n".                    '<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.lti_secret_add.type='."'text'".' } else { this.form.lti_secret_add.type='."'password'".' }" />'.&mt('Visible input').'</label></span> '."\n".
                   '</fieldset>'.&lti_options('add',undef,%lt).                    '</fieldset>'.&lti_options('add',undef,$itemcount,%lt).
                   '</td>'."\n".                    '</td>'."\n".
                   '</tr>'."\n";                    '</tr>'."\n";
     $$rowtotal ++;      $$rowtotal ++;
Line 4660  sub lti_names { Line 4901  sub lti_names {
                                           'url'       => 'URL',                                            'url'       => 'URL',
                                           'key'       => 'Key',                                            'key'       => 'Key',
                                           'lifetime'  => 'Nonce lifetime (s)',                                            'lifetime'  => 'Nonce lifetime (s)',
                                           'consumer'  => 'LTI Consumer',                                             'consumer'  => 'Consumer',
                                           'secret'    => 'Secret',                                            'secret'    => 'Secret',
                                             'requser'   => "User's identity sent",
                                           'email'     => 'Email address',                                            'email'     => 'Email address',
                                           'sourcedid' => 'User ID',                                            'sourcedid' => 'User ID',
                                           'other'     => 'Other',                                            'other'     => 'Other',
                                           'passback'  => 'Can return grades to Consumer:',                                            'passback'  => 'Can return grades to Consumer:',
                                           'roster'    => 'Can retrieve roster from Consumer:',                                            'roster'    => 'Can retrieve roster from Consumer:',
                                             'topmenu'   => 'Display LON-CAPA page header',
                                             'inlinemenu'=> 'Display LON-CAPA inline menu',
                                         );                                          );
     return %lt;      return %lt;
 }  }
   
 sub lti_options {  sub lti_options {
     my ($num,$current,%lt) = @_;      my ($num,$current,$itemcount,%lt) = @_;
     my (%checked,%rolemaps,$crssecsrc,$userfield,$cidfield);      my (%checked,%rolemaps,$crssecsrc,$userfield,$cidfield);
     $checked{'mapuser'}{'sourcedid'} = ' checked="checked"';      $checked{'mapuser'}{'sourcedid'} = ' checked="checked"';
     $checked{'mapcrs'}{'course_offering_sourcedid'} = ' checked="checked"';      $checked{'mapcrs'}{'course_offering_sourcedid'} = ' checked="checked"';
Line 4682  sub lti_options { Line 4926  sub lti_options {
     $checked{'selfenroll'} = {};      $checked{'selfenroll'} = {};
     $checked{'crssec'} = {};      $checked{'crssec'} = {};
     $checked{'crssecsrc'} = {};      $checked{'crssecsrc'} = {};
       $checked{'lcauth'} = {};
       $checked{'menuitem'} = {};
       if ($num eq 'add') {
           $checked{'lcauth'}{'lti'} = ' checked="checked"';
       }
     my $userfieldsty = 'none';      my $userfieldsty = 'none';
     my $crsfieldsty = 'none';      my $crsfieldsty = 'none';
     my $crssecfieldsty = 'none';      my $crssecfieldsty = 'none';
     my $secsrcfieldsty = 'none';      my $secsrcfieldsty = 'none';
       my $passbacksty = 'none';
       my $optionsty = 'block';
       my $lcauthparm;
       my $lcauthparmstyle = 'display:none';
       my $lcauthparmtext;
       my $menusty;
       my $numinrow = 4;
       my %menutitles = &ltimenu_titles();
   
     if (ref($current) eq 'HASH') {      if (ref($current) eq 'HASH') {
           if (!$current->{'requser'}) {
               $optionsty = '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'} = '';
             if ($current->{'mapuser'} eq 'lis_person_contact_email_primary') {              if ($current->{'mapuser'} eq 'lis_person_contact_email_primary') {
Line 4714  sub lti_options { Line 4973  sub lti_options {
                 $checked{'mapcrstype'}{$type} = ' checked="checked"';                  $checked{'mapcrstype'}{$type} = ' checked="checked"';
             }              }
         }          }
         if ($current->{'makecrs'}) {           if ($current->{'makecrs'}) {
             $checked{'makecrs'}{'Y'} = '  checked="checked"';              $checked{'makecrs'}{'Y'} = '  checked="checked"';
         }           }
         if (ref($current->{'makeuser'}) eq 'ARRAY') {          if (ref($current->{'makeuser'}) eq 'ARRAY') {
             foreach my $role (@{$current->{'makeuser'}}) {              foreach my $role (@{$current->{'makeuser'}}) {
                 $checked{'makeuser'}{$role} = ' checked="checked"';                  $checked{'makeuser'}{$role} = ' checked="checked"';
             }              }
         }          }
           if ($current->{'lcauth'} =~ /^(internal|localauth|krb4|krb5|lti)$/) {
               $checked{'lcauth'}{$1} = ' checked="checked"';
               unless (($current->{'lcauth'} eq 'lti') || ($current->{'lcauth'} eq 'internal')) {
                   $lcauthparm = $current->{'lcauthparm'};
                   $lcauthparmstyle = 'display:table-row'; 
                   if ($current->{'lcauth'} eq 'localauth') {
                       $lcauthparmtext = &mt('Local auth argument');
                   } else {
                       $lcauthparmtext = &mt('Kerberos domain');
                   }
               }
           }
         if (ref($current->{'selfenroll'}) eq 'ARRAY') {          if (ref($current->{'selfenroll'}) eq 'ARRAY') {
             foreach my $role (@{$current->{'selfenroll'}}) {              foreach my $role (@{$current->{'selfenroll'}}) {
                 $checked{'selfenroll'}{$role} = ' checked="checked"';                  $checked{'selfenroll'}{$role} = ' checked="checked"';
Line 4743  sub lti_options { Line 5014  sub lti_options {
         } else {          } else {
             $checked{'crssec'}{'N'} = ' checked="checked"';              $checked{'crssec'}{'N'} = ' checked="checked"';
         }          }
           if ($current->{'topmenu'}) {
               $checked{'topmenu'}{'Y'} = ' checked="checked"';
           } else {
               $checked{'topmenu'}{'N'} = ' checked="checked"';
           }
           if ($current->{'inlinemenu'}) {
               $checked{'inlinemenu'}{'Y'} = ' checked="checked"';
           } else {
               $checked{'inlinemenu'}{'N'} = ' checked="checked"';
           }
           if (($current->{'topmenu'}) || ($current->{'inlinemenu'})) {
               $menusty = 'inline-block';
               if (ref($current->{'lcmenu'}) eq 'ARRAY') {
                   foreach my $item (@{$current->{'lcmenu'}}) {
                       if (exists($menutitles{$item})) {
                           $checked{'menuitem'}{$item} = ' checked="checked"';
                       }
                   }
               }
           } else {
               $menusty = 'none';
           }
     } else {      } else {
         $checked{'makecrs'}{'N'} = ' checked="checked"';          $checked{'makecrs'}{'N'} = ' checked="checked"';
         $checked{'crssec'}{'N'} = ' checked="checked"';          $checked{'crssec'}{'N'} = ' checked="checked"';
           $checked{'topmenu'}{'N'} = ' checked="checked"';
           $checked{'inlinemenu'}{'Y'} = ' checked="checked"'; 
           $checked{'menuitem'}{'grades'} = ' checked="checked"';
           $menusty = 'inline-block'; 
     }      }
     my @coursetypes = ('official','unofficial','community','textbook','placement');      my @coursetypes = ('official','unofficial','community','textbook','placement','lti');
     my %coursetypetitles = &Apache::lonlocal::texthash (      my %coursetypetitles = &Apache::lonlocal::texthash (
                                official   => 'Official',                                 official   => 'Official',
                                unofficial => 'Unofficial',                                 unofficial => 'Unofficial',
                                community  => 'Community',                                 community  => 'Community',
                                textbook   => 'Textbook',                                 textbook   => 'Textbook',
                                placement  => 'Placement Test',                                 placement  => 'Placement Test',
                                  lti        => 'LTI Provider',
     );      );
       my @authtypes = ('internal','krb4','krb5','localauth');
       my %shortauth = (
                        internal => 'int',
                        krb4 => 'krb4',
                        krb5 => 'krb5',
                        localauth  => 'loc'
                       );
       my %authnames = &authtype_names();
     my @ltiroles = qw(Learner Instructor ContentDeveloper TeachingAssistant Mentor Member Manager Administrator);      my @ltiroles = qw(Learner Instructor ContentDeveloper TeachingAssistant Mentor Member Manager Administrator);
     my @lticourseroles = qw(Learner Instructor TeachingAssistant Mentor);      my @lticourseroles = qw(Learner Instructor TeachingAssistant Mentor);
     my @courseroles = ('cc','in','ta','ep','st');      my @courseroles = ('cc','in','ta','ep','st');
Line 4762  sub lti_options { Line 5068  sub lti_options {
     my $onclickcrs = ' onclick="toggleLTI(this.form,'."'crs','$num'".');"';      my $onclickcrs = ' onclick="toggleLTI(this.form,'."'crs','$num'".');"';
     my $onclicksec = ' onclick="toggleLTI(this.form,'."'sec','$num'".');"';      my $onclicksec = ' onclick="toggleLTI(this.form,'."'sec','$num'".');"';
     my $onclicksecsrc = ' onclick="toggleLTI(this.form,'."'secsrc','$num'".')"';      my $onclicksecsrc = ' onclick="toggleLTI(this.form,'."'secsrc','$num'".')"';
     my $output = '<fieldset><legend>'.&mt('Mapping users').'</legend>'.      my $onclicklcauth = ' onclick="toggleLTI(this.form,'."'lcauth','$num'".')"';
       my $onclickmenu = ' onclick="toggleLTI(this.form,'."'lcmenu','$num'".');"';
       my $output = '<fieldset class="ltioption_'.$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 4773  sub lti_options { Line 5081  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><legend>'.&mt('Mapping course roles').'</legend><table><tr>';                 '<fieldset class="ltioption_'.$num.'" style="display:'.$optionsty.'"><legend>'.&mt('Mapping course roles').'</legend><table><tr>';
     foreach my $ltirole (@lticourseroles) {      foreach my $ltirole (@lticourseroles) {
         my ($selected,$selectnone);          my ($selected,$selectnone);
         if ($rolemaps{$ltirole} eq '') {          if ($rolemaps{$ltirole} eq '') {
Line 4797  sub lti_options { Line 5105  sub lti_options {
         $output .= '</select></td>';          $output .= '</select></td>';
     }      }
     $output .= '</tr></table></fieldset>'.      $output .= '</tr></table></fieldset>'.
                '<fieldset><legend>'.&mt('Roles which may create user accounts').'</legend>';                 '<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><legend>'.&mt('Mapping courses').'</legend>'.                 '<fieldset class="ltioption_'.$num.'" style="display:'.$optionsty.'"><legend>'.&mt('New user accounts created for LTI users').'</legend>'.
                  '<table>'.
                  &modifiable_userdata_row('lti','instdata_'.$num,$current,$numinrow,$itemcount).
                  '</table>'.
                  '<table class="LC_nested"><tr><td class="LC_left_item">LON-CAPA Authentication</td>'.
                  '<td class="LC_left_item">';
       foreach my $auth ('lti',@authtypes) {
           my $authtext;
           if ($auth eq 'lti') {
               $authtext = &mt('None');
           } else {
               $authtext = $authnames{$shortauth{$auth}};
           }
           $output .= '<span class="LC_nobreak"><label><input type="radio" name="lti_lcauth_'.$num.
                      '" value="'.$auth.'"'.$checked{'lcauth'}{$auth}.$onclicklcauth.' />'.
                      $authtext.'</label></span> &nbsp;';
       }
       $output .= '</td></tr>'.
                  '<tr id="lti_lcauth_parmrow_'.$num.'" style="'.$lcauthparmstyle.'">'.
                  '<td class="LC_right_item" colspan="2"><span class="LC_nobreak">'.
                  '<span id="lti_lcauth_parmtext_'.$num.'">'.$lcauthparmtext.'</span>'.
                  '<input type="text" name="lti_lcauthparm_'.$num.'" value="" /></span></td></tr>'.
                  '</table></fieldset>'.
                  '<fieldset class="ltioption_'.$num.'" style="display:'.$optionsty.'"><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 4811  sub lti_options { Line 5142  sub lti_options {
                    $checked{'mapcrs'}{$option}.$onclickcrs.' />'.$option.'</label>'.                     $checked{'mapcrs'}{$option}.$onclickcrs.' />'.$option.'</label>'.
                    ($option eq 'other' ? '' : ('&nbsp;'x2) );                     ($option eq 'other' ? '' : ('&nbsp;'x2) );
     }      }
     $output .= '</div><div class="LC_floatleft" style="display:'.$crsfieldsty.';" id="lti_crsfield_'.$num.'".>'.      $output .= '</span></div><div class="LC_floatleft" style="display:'.$crsfieldsty.';" id="lti_crsfield_'.$num.'">'.
                '<input type="text" name="lti_mapcrsfield_'.$num.'" value="'.$cidfield.'" />'.                 '<input type="text" name="lti_mapcrsfield_'.$num.'" value="'.$cidfield.'" />'.
                '</div><div style="padding:0;clear:both;margin:0;border:0"></div>'.                 '</div><div style="padding:0;clear:both;margin:0;border:0"></div>'.
                '<span class="LC_nobreak">'.&mt('LON-CAPA course type(s)').':&nbsp;';                 '<span class="LC_nobreak">'.&mt('LON-CAPA course type(s)').':&nbsp;';
Line 4821  sub lti_options { Line 5152  sub lti_options {
                    ('&nbsp;'x2);                     ('&nbsp;'x2);
     }      }
     $output .= '</span></fieldset>'.      $output .= '</span></fieldset>'.
                '<fieldset><legend>'.&mt('Creating courses').'</legend>'.                 '<fieldset class="ltioption_'.$num.'" style="display:'.$optionsty.'"><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><legend>'.&mt('Roles which may self-enroll').'</legend>';                 '<fieldset class="ltioption_'.$num.'" style="display:'.$optionsty.'"><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><legend>'.&mt('Course options').'</legend>'.                 '<fieldset class="ltioption_'.$num.'" style="display:'.$optionsty.'"><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).
                '<label><input type="radio" name="lti_crssec_'.$num.'" value="1"'.                 '<label><input type="radio" name="lti_crssec_'.$num.'" value="1"'.
                $checked{'crssec'}{'Y'}.$onclicksec.' />'.&mt('Yes').'</label><span></div>'.                 $checked{'crssec'}{'Y'}.$onclicksec.' />'.&mt('Yes').'</label></span></div>'.
                '<div class="LC_floatleft" style="display:'.$crssecfieldsty.';" id="lti_crssecfield_'.$num.'">'.                 '<div class="LC_floatleft" style="display:'.$crssecfieldsty.';" id="lti_crssecfield_'.$num.'">'.
                '<span class="LC_nobreak">'.&mt('From').':<label>'.                 '<span class="LC_nobreak">'.&mt('From').':<label>'.
                '<input type="radio" name="lti_crssecsrc_'.$num.'" value="course_section_sourcedid"'.                 '<input type="radio" name="lti_crssecsrc_'.$num.'" value="course_section_sourcedid"'.
Line 4847  sub lti_options { Line 5178  sub lti_options {
                &mt('Standard field').'</label>'.('&nbsp;'x2).                 &mt('Standard field').'</label>'.('&nbsp;'x2).
                '<label><input type="radio" name="lti_crssecsrc_'.$num.'" value="other"'.                 '<label><input type="radio" name="lti_crssecsrc_'.$num.'" value="other"'.
                $checked{'crssecsrc'}{'other'}.$onclicksecsrc.' />'.&mt('Other').                 $checked{'crssecsrc'}{'other'}.$onclicksecsrc.' />'.&mt('Other').
                '</label></div><div class="LC_floatleft" style="display:'.$secsrcfieldsty.';" id="lti_secsrcfield_'.$num.'">'.                 '</label></span></div><div class="LC_floatleft" style="display:'.$secsrcfieldsty.';" id="lti_secsrcfield_'.$num.'">'.
                '<input type="text" name="lti_customsection_'.$num.'" value="'.$crssecsrc.'" />'.                 '<input type="text" name="lti_customsection_'.$num.'" value="'.$crssecsrc.'" />'.
                '</div><div style="padding:0;clear:both;margin:0;border:0"></div>';                  '</div><div style="padding:0;clear:both;margin:0;border:0"></div>';
     foreach my $extra ('passback','roster') {      my ($pb1p1chk,$pb1p0chk,$onclickpb);
       foreach my $extra ('roster','passback') {
         my $checkedon = '';          my $checkedon = '';
         my $checkedoff = ' checked="checked"';          my $checkedoff = ' checked="checked"';
           if ($extra eq 'passback') {
               $pb1p1chk = ' checked="checked"';
               $pb1p0chk = '';
               $onclickpb = ' onclick="toggleLTI(this.form,'."'passback','$num'".');"'; 
           } else {
               $onclickpb = ''; 
           }
         if (ref($current) eq 'HASH') {          if (ref($current) eq 'HASH') {
             if (($current->{$extra})) {              if (($current->{$extra})) {
                 $checkedon = $checkedoff;                  $checkedon = $checkedoff;
                 $checkedoff = '';                  $checkedoff = '';
                   if ($extra eq 'passback') {
                       $passbacksty = 'inline-block';
                   }
                   if ($current->{'passbackformat'} eq '1.0') {
                       $pb1p0chk =  ' checked="checked"';
                       $pb1p1chk = '';
                   }
             }              }
         }          }
         $output .= $lt{$extra}.'&nbsp;'.          $output .= $lt{$extra}.'&nbsp;'.
                    '<label><input type="radio" name="lti_'.$extra.'_'.$num.'" value="0"'.$checkedoff.' />'.                     '<label><input type="radio" name="lti_'.$extra.'_'.$num.'" value="0"'.$checkedoff.$onclickpb.' />'.
                    &mt('No').'</label>'.('&nbsp;'x2).                     &mt('No').'</label>'.('&nbsp;'x2).
                    '<label><input type="radio" name="lti_'.$extra.'_'.$num.'" value="1"'.$checkedon.' />'.                     '<label><input type="radio" name="lti_'.$extra.'_'.$num.'" value="1"'.$checkedon.$onclickpb.' />'.
                    &mt('Yes').'</label><br />';                     &mt('Yes').'</label><br />';
     }      }
     $output .= '</span></fieldset>';      $output .= '<div class="LC_floatleft" style="display:'.$passbacksty.';" id="lti_passback_'.$num.'">'.
                  '<span class="LC_nobreak">'.&mt('Grade format').
                  '<label><input type="radio" name="lti_passbackformat_'.$num.'" value="1.1"'.$pb1p1chk.' />'.
                  &mt('Outcomes Service (1.1)').'</label>'.('&nbsp;'x2).
                  '<label><input type="radio" name="lti_passbackformat_'.$num.'" value="1.0"'.$pb1p0chk.'/>'.
                  &mt('Outcomes Extension (1.0)').'</label></span></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>';
 #        '<fieldset><legend>'.&mt('Assigning author roles').'</legend>';  #        '<fieldset><legend>'.&mt('Assigning author roles').'</legend>';
 #  #
 #    $output .= '</fieldset>'.  #    $output .= '</fieldset>'.
Line 4873  sub lti_options { Line 5245  sub lti_options {
     return $output;      return $output;
 }  }
   
   sub ltimenu_titles {
       return &Apache::lonlocal::texthash(
                                           fullname    => 'Full name',
                                           coursetitle => 'Course title',
                                           role        => 'Role',
                                           logout      => 'Logout',
                                           grades      => 'Grades',
       );
   }
   
 sub print_coursedefaults {  sub print_coursedefaults {
     my ($position,$dom,$settings,$rowtotal) = @_;      my ($position,$dom,$settings,$rowtotal) = @_;
     my ($css_class,$datatable,%checkedon,%checkedoff,%defaultchecked,@toggles);      my ($css_class,$datatable,%checkedon,%checkedoff,%defaultchecked,@toggles);
Line 5351  sub print_validation_rows { Line 5733  sub print_validation_rows {
                               '</label></span> ';                                '</label></span> ';
             }              }
         } elsif ($item eq 'markup') {          } elsif ($item eq 'markup') {
             $datatable .= '<textarea name="'.$caller.'_validation_markup" cols="50" rows="5" wrap="soft">'.              $datatable .= '<textarea name="'.$caller.'_validation_markup" cols="50" rows="5">'.
                            $currvalidation{$item}.                             $currvalidation{$item}.
                               '</textarea>';                                '</textarea>';
         }          }
Line 5373  sub print_validation_rows { Line 5755  sub print_validation_rows {
         my ($numdc,$dctable,$rows) = &active_dc_picker($dom,$numinrow,'radio',          my ($numdc,$dctable,$rows) = &active_dc_picker($dom,$numinrow,'radio',
                                                        'validationdc',%currhash);                                                         'validationdc',%currhash);
         my $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';          my $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
         $datatable .= '</td></tr><tr'.$css_class.'><td>';          $datatable .= '<tr'.$css_class.'><td>';
         if ($numdc > 1) {          if ($numdc > 1) {
             $datatable .= &mt('Course creation processed as: (choose Dom. Coord.)');              $datatable .= &mt('Course creation processed as: (choose Dom. Coord.)');
         } else {          } else {
Line 6010  sub print_loadbalancing { Line 6392  sub print_loadbalancing {
     my $numinrow = 1;      my $numinrow = 1;
     my $datatable;      my $datatable;
     my %servers = &Apache::lonnet::internet_dom_servers($dom);      my %servers = &Apache::lonnet::internet_dom_servers($dom);
     my (%currbalancer,%currtargets,%currrules,%existing);      my (%currbalancer,%currtargets,%currrules,%existing,%currcookies);
     if (ref($settings) eq 'HASH') {      if (ref($settings) eq 'HASH') {
         %existing = %{$settings};          %existing = %{$settings};
     }      }
     if ((keys(%servers) > 1) || (keys(%existing) > 0)) {      if ((keys(%servers) > 1) || (keys(%existing) > 0)) {
         &get_loadbalancers_config(\%servers,\%existing,\%currbalancer,          &get_loadbalancers_config(\%servers,\%existing,\%currbalancer,
                                   \%currtargets,\%currrules);                                    \%currtargets,\%currrules,\%currcookies);
     } else {      } else {
         return;          return;
     }      }
Line 6093  sub print_loadbalancing { Line 6475  sub print_loadbalancing {
         my %hostherechecked = (          my %hostherechecked = (
                                   no => ' checked="checked"',                                    no => ' checked="checked"',
                               );                                );
           my %balcookiechecked = (
                                     no => ' checked="checked"', 
                                  );
         foreach my $sparetype (@sparestypes) {          foreach my $sparetype (@sparestypes) {
             my $targettable;              my $targettable;
             for (my $i=0; $i<$numspares; $i++) {              for (my $i=0; $i<$numspares; $i++) {
Line 6148  sub print_loadbalancing { Line 6533  sub print_loadbalancing {
                 }                  }
             }              }
         }          }
           if ($currcookies{$lonhost}) {
               %balcookiechecked = (
                                       yes => ' checked="checked"',
                                   );
           }
         $datatable .= &mt('Hosting on balancer itself').'<br />'.          $datatable .= &mt('Hosting on balancer itself').'<br />'.
                       '<label><input type="radio" name="loadbalancing_target_'.$balnum.'_hosthere" value="no"'.                        '<label><input type="radio" name="loadbalancing_target_'.$balnum.'_hosthere" value="no"'.
                       $hostherechecked{'no'}.' />'.&mt('No').'</label><br />';                        $hostherechecked{'no'}.' />'.&mt('No').'</label><br />';
Line 6156  sub print_loadbalancing { Line 6546  sub print_loadbalancing {
                           'value="'.$sparetype.'"'.$hostherechecked{$sparetype}.' /><i>'.$typetitles{$sparetype}.                            'value="'.$sparetype.'"'.$hostherechecked{$sparetype}.' /><i>'.$typetitles{$sparetype}.
                           '</i></label><br />';                            '</i></label><br />';
         }          }
         $datatable .= '</div></td></tr>'.          $datatable .= &mt('Use balancer cookie').'<br />'.
                         '<label><input type="radio" name="loadbalancing_cookie_'.$balnum.'" value="1"'.
                         $balcookiechecked{'yes'}.' />'.&mt('Yes').'</label><br />'.
                         '<label><input type="radio" name="loadbalancing_cookie_'.$balnum.'" value="0"'.
                         $balcookiechecked{'no'}.' />'.&mt('No').'</label><br />'.
                         '</div></td></tr>'.
                       &loadbalancing_rules($dom,$intdom,$currrules{$lonhost},                        &loadbalancing_rules($dom,$intdom,$currrules{$lonhost},
                                            $othertitle,$usertypes,$types,\%servers,                                             $othertitle,$usertypes,$types,\%servers,
                                            \%currbalancer,$lonhost,                                             \%currbalancer,$lonhost,
Line 6170  sub print_loadbalancing { Line 6565  sub print_loadbalancing {
 }  }
   
 sub get_loadbalancers_config {  sub get_loadbalancers_config {
     my ($servers,$existing,$currbalancer,$currtargets,$currrules) = @_;      my ($servers,$existing,$currbalancer,$currtargets,$currrules,$currcookies) = @_;
     return unless ((ref($servers) eq 'HASH') &&      return unless ((ref($servers) eq 'HASH') &&
                    (ref($existing) eq 'HASH') && (ref($currbalancer) eq 'HASH') &&                     (ref($existing) eq 'HASH') && (ref($currbalancer) eq 'HASH') &&
                    (ref($currtargets) eq 'HASH') && (ref($currrules) eq 'HASH'));                     (ref($currtargets) eq 'HASH') && (ref($currrules) eq 'HASH') &&
                      (ref($currcookies) eq 'HASH'));
     if (keys(%{$existing}) > 0) {      if (keys(%{$existing}) > 0) {
         my $oldlonhost;          my $oldlonhost;
         foreach my $key (sort(keys(%{$existing}))) {          foreach my $key (sort(keys(%{$existing}))) {
Line 6192  sub get_loadbalancers_config { Line 6588  sub get_loadbalancers_config {
                 $currbalancer->{$key} = 1;                  $currbalancer->{$key} = 1;
                 $currtargets->{$key} = $existing->{$key}{'targets'};                  $currtargets->{$key} = $existing->{$key}{'targets'};
                 $currrules->{$key} = $existing->{$key}{'rules'};                  $currrules->{$key} = $existing->{$key}{'rules'};
                   if ($existing->{$key}{'cookie'}) {
                       $currcookies->{$key} = 1;
                   }
             }              }
         }          }
     } else {      } else {
Line 6387  sub contact_titles { Line 6786  sub contact_titles {
                    'requestsmail'    => 'E-mail from course requests requiring approval',                     'requestsmail'    => 'E-mail from course requests requiring approval',
                    'updatesmail'     => 'E-mail from nightly check of LON-CAPA module integrity/updates',                     'updatesmail'     => 'E-mail from nightly check of LON-CAPA module integrity/updates',
                    'idconflictsmail' => 'E-mail from bi-nightly check for multiple users sharing same student/employee ID',                     'idconflictsmail' => 'E-mail from bi-nightly check for multiple users sharing same student/employee ID',
                      'errorthreshold'  => 'Error/warning threshold for status e-mail',
                      'errorsysmail'    => 'Error threshold for e-mail to core group',
                      'errorweights'    => 'Weights used to compute error count',
                      'errorexcluded'   => 'Servers with unsent updates excluded from count',
                  );                   );
     my %short_titles = &Apache::lonlocal::texthash (      my %short_titles = &Apache::lonlocal::texthash (
                            adminemail   => 'Admin E-mail address',                             adminemail   => 'Admin E-mail address',
Line 6445  sub courserequest_titles { Line 6848  sub courserequest_titles {
                                    community  => 'Communities',                                     community  => 'Communities',
                                    textbook   => 'Textbook',                                     textbook   => 'Textbook',
                                    placement  => 'Placement tests',                                     placement  => 'Placement tests',
                                      lti        => 'LTI Provider',
                                    norequest  => 'Not allowed',                                     norequest  => 'Not allowed',
                                    approval   => 'Approval by Dom. Coord.',                                     approval   => 'Approval by DC',
                                    validate   => 'With validation',                                     validate   => 'With validation',
                                    autolimit  => 'Numerical limit',                                     autolimit  => 'Numerical limit',
                                    unlimited  => '(blank for unlimited)',                                     unlimited  => '(blank for unlimited)',
Line 6558  sub print_usercreation { Line 6962  sub print_usercreation {
         }          }
     } else {      } else {
         my @contexts = ('author','course','domain');          my @contexts = ('author','course','domain');
         my @authtypes = ('int','krb4','krb5','loc');          my @authtypes = ('int','krb4','krb5','loc','lti');
         my %checked;          my %checked;
         if (ref($settings) eq 'HASH') {          if (ref($settings) eq 'HASH') {
             if (ref($settings->{'authtypes'}) eq 'HASH') {              if (ref($settings->{'authtypes'}) eq 'HASH') {
Line 6675  sub print_selfcreation { Line 7079  sub print_selfcreation {
         $datatable .= '<tr'.$css_class.'>'.          $datatable .= '<tr'.$css_class.'>'.
                      '<td class="LC_left_item">'.&mt('Mapping of Shibboleth environment variable names to user data fields (SSO auth)').'</td>'.                       '<td class="LC_left_item">'.&mt('Mapping of Shibboleth environment variable names to user data fields (SSO auth)').'</td>'.
                      '<td class="LC_left_item">'."\n".                       '<td class="LC_left_item">'."\n".
                      '<table><tr><td>'."\n";                       '<table>'."\n";
         for (my $i=0; $i<@fields; $i++) {          for (my $i=0; $i<@fields; $i++) {
             $rem = $i%($numperrow);              $rem = $i%($numperrow);
             if ($rem == 0) {              if ($rem == 0) {
Line 7298  sub authtype_names { Line 7702  sub authtype_names {
                       krb4   => 'Kerberos 4',                        krb4   => 'Kerberos 4',
                       krb5   => 'Kerberos 5',                        krb5   => 'Kerberos 5',
                       loc    => 'Local',                        loc    => 'Local',
                         lti    => 'LTI',
                   );                    );
     return %lt;      return %lt;
 }  }
Line 7366  sub print_defaults { Line 7771  sub print_defaults {
                           '<td><span class="LC_nobreak">'.$titles->{$item}.                            '<td><span class="LC_nobreak">'.$titles->{$item}.
                           '</span></td><td class="LC_right_item" colspan="3">';                            '</span></td><td class="LC_right_item" colspan="3">';
             if ($item eq 'auth_def') {              if ($item eq 'auth_def') {
                 my @authtypes = ('internal','krb4','krb5','localauth');                  my @authtypes = ('internal','krb4','krb5','localauth','lti');
                 my %shortauth = (                  my %shortauth = (
                                  internal => 'int',                                   internal => 'int',
                                  krb4 => 'krb4',                                   krb4 => 'krb4',
                                  krb5 => 'krb5',                                   krb5 => 'krb5',
                                  localauth  => 'loc'                                   localauth  => 'loc',
                                    lti => 'lti',
                                 );                                  );
                 my %authnames = &authtype_names();                  my %authnames = &authtype_names();
                 foreach my $auth (@authtypes) {                  foreach my $auth (@authtypes) {
Line 7459  sub print_defaults { Line 7865  sub print_defaults {
                                    1 => 'Yes, allow login then update passwd file using default cost (if higher)',                                     1 => 'Yes, allow login then update passwd file using default cost (if higher)',
                                    2 => 'Yes, disallow login if stored cost is less than domain default',                                     2 => 'Yes, disallow login if stored cost is less than domain default',
                                  );                                   );
                 $datatable .= '<table wisth="100%">';                  $datatable .= '<table width="100%">';
                 foreach my $option (@options) {                  foreach my $option (@options) {
                     my $checked = ' ';                      my $checked = ' ';
                     my $onclick;                      my $onclick;
Line 7574  sub defaults_titles { Line 7980  sub defaults_titles {
     return (\%titles);      return (\%titles);
 }  }
   
   sub print_scantron {
       my ($r,$position,$dom,$confname,$settings,$rowtotal) = @_;
       if ($position eq 'top') {
           return &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
       } else {
           return &print_scantronconfig($dom,$settings,\$rowtotal);
       }
   }
   
   sub scantron_javascript {
       return <<"ENDSCRIPT";
   
   <script type="text/javascript">
   // <![CDATA[
   
   function toggleScantron(form) {
       var csvfieldset = new Array();
       if (document.getElementById('scantroncsv_cols')) {
           csvfieldset.push(document.getElementById('scantroncsv_cols'));
       }
       if (document.getElementById('scantroncsv_options')) {
           csvfieldset.push(document.getElementById('scantroncsv_options'));
       }
       if (csvfieldset.length) {
           if (document.getElementById('scantronconfcsv')) {
               var scantroncsv = document.getElementById('scantronconfcsv');
               if (scantroncsv.checked) {
                   for (var i=0; i<csvfieldset.length; i++) {
                       csvfieldset[i].style.display = 'block';
                   }
               } else {
                   for (var i=0; i<csvfieldset.length; i++) {
                       csvfieldset[i].style.display = 'none';
                   }
                   var csvselects = document.getElementsByClassName('scantronconfig_csv');
                   if (csvselects.length) {
                       for (var j=0; j<csvselects.length; j++) {
                           csvselects[j].selectedIndex = 0;
                       }
                   }
               }
           }
       }
       return;
   }
   // ]]>
   </script>
   
   ENDSCRIPT
   
   }
   
 sub print_scantronformat {  sub print_scantronformat {
     my ($r,$dom,$confname,$settings,$rowtotal) = @_;      my ($r,$dom,$confname,$settings,$rowtotal) = @_;
     my $itemcount = 1;      my $itemcount = 1;
Line 7600  sub print_scantronformat { Line 8058  sub print_scantronformat {
             if ($configuserok eq 'ok') {              if ($configuserok eq 'ok') {
                 if ($author_ok eq 'ok') {                  if ($author_ok eq 'ok') {
                     my %legacyfile = (                      my %legacyfile = (
  default => $Apache::lonnet::perlvar{'lonTabDir'}.'/default_scantronformat.tab',    default => $Apache::lonnet::perlvar{'lonTabDir'}.'/default_scantronformat.tab',
  custom  => $Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab',    custom  => $Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab',
                     );                      );
                     my %md5chk;                      my %md5chk;
                     foreach my $type (keys(%legacyfile)) {                      foreach my $type (keys(%legacyfile)) {
Line 7610  sub print_scantronformat { Line 8068  sub print_scantronformat {
                     }                      }
                     if ($md5chk{'default'} ne $md5chk{'custom'}) {                      if ($md5chk{'default'} ne $md5chk{'custom'}) {
                         foreach my $type (keys(%legacyfile)) {                          foreach my $type (keys(%legacyfile)) {
                             ($scantronurls{$type},my $error) =                               ($scantronurls{$type},my $error) =
                                 &legacy_scantronformat($r,$dom,$confname,                                  &legacy_scantronformat($r,$dom,$confname,
                                                  $type,$legacyfile{$type},                                                   $type,$legacyfile{$type},
                                                  $scantronurls{$type},                                                   $scantronurls{$type},
Line 7621  sub print_scantronformat { Line 8079  sub print_scantronformat {
                         }                          }
                         if (keys(%error) == 0) {                          if (keys(%error) == 0) {
                             $is_custom = 1;                              $is_custom = 1;
                             $confhash{'scantron'}{'scantronformat'} =                               $confhash{'scantron'}{'scantronformat'} =
                                 $scantronurls{'custom'};                                  $scantronurls{'custom'};
                             my $putresult =                               my $putresult =
                                 &Apache::lonnet::put_dom('configuration',                                  &Apache::lonnet::put_dom('configuration',
                                                          \%confhash,$dom);                                                           \%confhash,$dom);
                             if ($putresult ne 'ok') {                              if ($putresult ne 'ok') {
                                 $error{'custom'} =                                   $error{'custom'} =
                                     '<span class="LC_error">'.                                      '<span class="LC_error">'.
                                     &mt('An error occurred updating the domain configuration: [_1]',$putresult).'</span>';                                      &mt('An error occurred updating the domain configuration: [_1]',$putresult).'</span>';
                             }                              }
Line 7747  sub legacy_scantronformat { Line 8205  sub legacy_scantronformat {
     return ($url,$error);      return ($url,$error);
 }  }
   
   sub print_scantronconfig {
       my ($dom,$settings,$rowtotal) = @_;
       my $itemcount = 2;
       my $is_checked = ' checked="checked"';
       my %optionson = (
                        hdr => ' checked="checked"',
                        pad => ' checked="checked"',
                        rem => ' checked="checked"',
                       );
       my %optionsoff = (
                         hdr => '',
                         pad => '',
                         rem => '',
                        );
       my $currcsvsty = 'none';
       my ($datatable,%csvfields,%checked,%onclick,%csvoptions);
       my @fields = &scantroncsv_fields();
       my %titles = &scantronconfig_titles();
       if (ref($settings) eq 'HASH') {
           if (ref($settings->{config}) eq 'HASH') {
               if ($settings->{config}->{dat}) {
                   $checked{'dat'} = $is_checked;
               }
               if (ref($settings->{config}->{csv}) eq 'HASH') {
                   if (ref($settings->{config}->{csv}->{fields}) eq 'HASH') {
                       %csvfields = %{$settings->{config}->{csv}->{fields}};
                       if (keys(%csvfields) > 0) {
                           $checked{'csv'} = $is_checked;
                           $currcsvsty = 'block';
                       }
                   }
                   if (ref($settings->{config}->{csv}->{options}) eq 'HASH') {
                       %csvoptions = %{$settings->{config}->{csv}->{options}};
                       foreach my $option (keys(%optionson)) {
                           unless ($csvoptions{$option}) {
                               $optionsoff{$option} = $optionson{$option};
                               $optionson{$option} = '';
                           }
                       }
                   }
               }
           } else {
               $checked{'dat'} = $is_checked;
           }
       } else {
           $checked{'dat'} = $is_checked;
       }
       $onclick{'csv'} = ' onclick="toggleScantron(this.form);"';
       my $css_class = $itemcount%2? ' class="LC_odd_row"':'';
       $datatable = '<tr '.$css_class.'><td>'.&mt('Supported formats').'</td>'.
                    '<td class="LC_left_item" valign="top"><span class="LC_nobreak">';
       foreach my $item ('dat','csv') {
           my $id;
           if ($item eq 'csv') {
               $id = 'id="scantronconfcsv" ';
           }
           $datatable .= '<label><input type="checkbox" name="scantronconfig" '.$id.'value="'.$item.'"'.$checked{$item}.$onclick{$item}.' />'.
                         $titles{$item}.'</label>'.('&nbsp;'x3);
           if ($item eq 'csv') {
               $datatable .= '<fieldset style="display:'.$currcsvsty.'" id="scantroncsv_cols">'.
                             '<legend>'.&mt('CSV Column Mapping').'</legend>'.
                             '<table><tr><th>'.&mt('Field').'</th><th>'.&mt('Location').'</th></tr>'."\n";
               foreach my $col (@fields) {
                   my $selnone;
                   if ($csvfields{$col} eq '') {
                       $selnone = ' selected="selected"';
                   }
                   $datatable .= '<tr><td>'.$titles{$col}.'</td>'.
                                 '<td><select name="scantronconfig_csv_'.$col.'" class="scantronconfig_csv">'.
                                 '<option value=""'.$selnone.'></option>';
                   for (my $i=0; $i<20; $i++) {
                       my $shown = $i+1;
                       my $sel;
                       unless ($selnone) {
                           if (exists($csvfields{$col})) {
                               if ($csvfields{$col} == $i) {
                                   $sel = ' selected="selected"';
                               }
                           }
                       }
                       $datatable .= '<option value="'.$i.'"'.$sel.'>'.$shown.'</option>';
                   }
                   $datatable .= '</select></td></tr>';
              }
              $datatable .= '</table></fieldset>'.
                            '<fieldset style="display:'.$currcsvsty.'" id="scantroncsv_options">'.
                            '<legend>'.&mt('CSV Options').'</legend>';
              foreach my $option ('hdr','pad','rem') {
                  $datatable .= '<span class="LC_nobreak">'.$titles{$option}.':'.
                            '<label><input type="radio" name="scantroncsv_'.$option.'" value="1"'.$optionson{$option}.' />'.
                            &mt('Yes').'</label>'.('&nbsp;'x2)."\n".
                            '<label><input type="radio" name="scantroncsv_'.$option.'" value="0"'.$optionsoff{$option}.' />'.&mt('No').'</label></span><br />';
              }
              $datatable .= '</fieldset>';
              $itemcount ++;
           }
       }
       $datatable .= '</td></tr>';
       $$rowtotal ++;
       return $datatable;
   }
   
   sub scantronconfig_titles {
       return &Apache::lonlocal::texthash(
                                             dat => 'Standard format (.dat)',
                                             csv => 'Comma separated values (.csv)',
                                             hdr => 'Remove first line in file (contains column titles)',
                                             pad => 'Prepend 0s to PaperID',
                                             rem => 'Remove leading spaces (except Q columns)',
                                             CODE => 'CODE',
                                             ID   => 'Student ID',
                                             PaperID => 'Paper ID',
                                             FirstName => 'First Name',
                                             LastName => 'Last Name',
                                             FirstQuestion => 'First Question Response',
                                             Section => 'Section',
       );
   }
   
   sub scantroncsv_fields {
       return ('PaperID','LastName','FirstName','ID','Section','CODE','FirstQuestion');
   }
   
 sub print_coursecategories {  sub print_coursecategories {
     my ($position,$dom,$hdritem,$settings,$rowtotal) = @_;      my ($position,$dom,$hdritem,$settings,$rowtotal) = @_;
     my $datatable;      my $datatable;
Line 7789  sub print_coursecategories { Line 8370  sub print_coursecategories {
                              '<input type="radio" name="coursecat_'.$item.'" value="'.$type.'"'.$ischecked.                               '<input type="radio" name="coursecat_'.$item.'" value="'.$type.'"'.$ischecked.
                              ' />'.$lt{$type}.'</label>&nbsp;';                               ' />'.$lt{$type}.'</label>&nbsp;';
            }             }
            $datatable .= '</td></tr>';             $datatable .= '</span></td></tr>';
            $itemcount ++;             $itemcount ++;
         }          }
         $$rowtotal += $itemcount;          $$rowtotal += $itemcount;
Line 7875  sub print_coursecategories { Line 8456  sub print_coursecategories {
                   $can_catcomm_dom.' value="dom" />'.$level{'dom'}.'</label>&nbsp;'.                    $can_catcomm_dom.' value="dom" />'.$level{'dom'}.'</label>&nbsp;'.
                   '<label><input type="radio" name="categorizecomm"'.                    '<label><input type="radio" name="categorizecomm"'.
                   $can_catcomm_comm.'value="comm" />'.$level{'comm'}.'</label></span></td>'.                    $can_catcomm_comm.'value="comm" />'.$level{'comm'}.'</label></span></td>'.
                   '</tr><tr>'.                    '</tr><tr class="LC_odd_row">'.
                   '<td>'.$title{'togglecatsplace'}.'</td>'.                    '<td>'.$title{'togglecatsplace'}.'</td>'.
                   '<td class="LC_right_item"><span class="LC_nobreak"><label>'.                    '<td class="LC_right_item"><span class="LC_nobreak"><label>'.
                   '<input type="radio" name="togglecatsplace"'.                    '<input type="radio" name="togglecatsplace"'.
Line 8032  sub print_coursecategories { Line 8613  sub print_coursecategories {
                 $datatable .= &initialize_categories($itemcount);                  $datatable .= &initialize_categories($itemcount);
             }              }
         } else {          } else {
             $datatable .= '<td class="LC_right_item">'.$hdritem->{'header'}->[1]->{'col2'}.'</td>'              $datatable .= '<tr><td class="LC_right_item">'.$hdritem->{'header'}->[1]->{'col2'}.'</td></tr>'
                           .&initialize_categories($itemcount);                            .&initialize_categories($itemcount);
         }          }
         $$rowtotal += $itemcount;          $$rowtotal += $itemcount;
Line 8080  sub print_serverstatuses { Line 8661  sub print_serverstatuses {
                       '<span class="LC_nobreak">'.                        '<span class="LC_nobreak">'.
                       '<input type="text" name="'.$type.'_machines" '.                        '<input type="text" name="'.$type.'_machines" '.
                       'value="'.$machineaccess{$type}.'" size="10" />'.                        'value="'.$machineaccess{$type}.'" size="10" />'.
                       '</td></tr>'."\n";                        '</span></td></tr>'."\n";
     }      }
     $$rowtotal += $rownum;      $$rowtotal += $rownum;
     return $datatable;      return $datatable;
Line 8308  sub initialize_categories { Line 8889  sub initialize_categories {
                       communities => 'Communities',                        communities => 'Communities',
                       placement   => 'Placement Tests',                        placement   => 'Placement Tests',
                         );                          );
     my $select0 = ' selected="selected"';      my %selnum = (
     my $select1 = '';                     instcode    => '0',
                      communities => '1',
                      placement   => '2',
                    );
       my %selected;
     foreach my $default ('instcode','communities','placement') {      foreach my $default ('instcode','communities','placement') {
         $css_class = $itemcount%2?' class="LC_odd_row"':'';          $css_class = $itemcount%2?' class="LC_odd_row"':'';
         $chgstr = ' onchange="javascript:reorderCats(this.form,'."'',$default"."_pos','0'".');"';          $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','$default"."_pos','0'".');"';
         if (($default eq 'communities') || ($default eq 'placement')) {          map { $selected{$selnum{$_}} = '' } keys(%selnum);
             $select1 = $select0;          $selected{$selnum{$default}} = ' selected="selected"';
             $select0 = '';  
         }  
         $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'          $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'
                      .'<select name="'.$default.'_pos">'                       .'<select name="'.$default.'_pos"'.$chgstr.'>'
                      .'<option value="0"'.$select0.'>1</option>'                       .'<option value="0"'.$selected{'0'}.'>1</option>'
                      .'<option value="1"'.$select1.'>2</option>'                       .'<option value="1"'.$selected{'1'}.'>2</option>'
                      .'<option value="2">3</option></select>&nbsp;'                       .'<option value="2"'.$selected{'2'}.'>3</option>'
                        .'<option value="3">4</option></select>&nbsp;'
                      .$default_names{$default}                       .$default_names{$default}
                      .'</span></td><td><span class="LC_nobreak">'                       .'</span></td><td><span class="LC_nobreak">'
                      .'<label><input type="radio" name="'.$default.'" value="1" checked="checked" />'                       .'<label><input type="radio" name="'.$default.'" value="1" checked="checked" />'
Line 8336  sub initialize_categories { Line 8920  sub initialize_categories {
                   .'<select name="addcategory_pos"'.$chgstr.'>'                    .'<select name="addcategory_pos"'.$chgstr.'>'
                   .'<option value="0">1</option>'                    .'<option value="0">1</option>'
                   .'<option value="1">2</option>'                    .'<option value="1">2</option>'
                   .'<option value="2" selected="selected">3</option></select>&nbsp;'                    .'<option value="2">3</option>'
                   .&mt('Add category').'</td><td>'.&mt('Name:')                    .'<option value="3" selected="selected">4</option></select>&nbsp;'
                   .'&nbsp;<input type="text" size="20" name="addcategory_name" value="" /></td></tr>';                    .&mt('Add category').'</span></td><td><span class="LC_nobreak">'.&mt('Name:')
                     .'&nbsp;<input type="text" size="20" name="addcategory_name" value="" /></span>'
                     .'</td></tr>';
     return $datatable;      return $datatable;
 }  }
   
Line 8393  sub build_category_rows { Line 8979  sub build_category_rows {
                             pop(@{$path});                              pop(@{$path});
                         }                          }
                     } else {                      } else {
                         $text .= &mt('Add subcategory:').'&nbsp;</span><input type="textbox" size="20" name="addcategory_name_';                          $text .= &mt('Add subcategory:').'&nbsp;</span><input type="text" size="20" name="addcategory_name_';
                         if ($j == $numchildren) {                          if ($j == $numchildren) {
                             $text .= $name;                              $text .= $name;
                         } else {                          } else {
Line 8416  sub build_category_rows { Line 9002  sub build_category_rows {
                 my $colspan;                  my $colspan;
                 if ($parent ne 'instcode') {                  if ($parent ne 'instcode') {
                     $colspan = $maxdepth - $depth - 1;                      $colspan = $maxdepth - $depth - 1;
                     $text .= '<td colspan="'.$colspan.'">'.&mt('Add subcategory:').'<input type="textbox" size="20" name="subcat_'.$name.'" value="" /></td>';                      $text .= '<td colspan="'.$colspan.'">'.&mt('Add subcategory:').'<input type="text" size="20" name="subcat_'.$name.'" value="" /></td>';
                 }                  }
             }              }
         }          }
Line 8447  sub modifiable_userdata_row { Line 9033  sub modifiable_userdata_row {
         } else {          } else {
             $rolename = $role;              $rolename = $role;
         }          }
       } elsif ($context eq 'lti') {
           $rolename = &mt('Institutional data used (if available)');
     } else {      } else {
         if ($role eq 'cr') {          if ($role eq 'cr') {
             $rolename = &mt('Custom role');              $rolename = &mt('Custom role');
Line 8489  sub modifiable_userdata_row { Line 9077  sub modifiable_userdata_row {
               '<td class="LC_left_item" colspan="2"><table>';                '<td class="LC_left_item" colspan="2"><table>';
     my $rem;      my $rem;
     my %checks;      my %checks;
       my %current;
     if (ref($settings) eq 'HASH') {      if (ref($settings) eq 'HASH') {
         if (ref($settings->{$context}) eq 'HASH') {          my $hashref;
           if ($context eq 'lti') {
               if (ref($settings) eq 'HASH') {
                   $hashref = $settings->{'instdata'};
               }
           } elsif (ref($settings->{$context}) eq 'HASH') {
             if (ref($settings->{$context}->{$role}) eq 'HASH') {              if (ref($settings->{$context}->{$role}) eq 'HASH') {
                 my $hashref = $settings->{$context}->{$role};                  $hashref = $settings->{'lti_instdata'};
                 if ($role eq 'emailusername') {              }
                     if ($statustype) {              if ($role eq 'emailusername') {
                         if (ref($settings->{$context}->{$role}->{$statustype}) eq 'HASH') {                  if ($statustype) {
                             $hashref = $settings->{$context}->{$role}->{$statustype};                      if (ref($settings->{$context}->{$role}->{$statustype}) eq 'HASH') {
                             if (ref($hashref) eq 'HASH') {                           $hashref = $settings->{$context}->{$role}->{$statustype};
                                 foreach my $field (@fields) {  
                                     if ($hashref->{$field}) {  
                                         $checks{$field} = $hashref->{$field};  
                                     }  
                                 }  
                             }  
                         }  
                     }                      }
                 } else {                  }
                     if (ref($hashref) eq 'HASH') {              }
                         foreach my $field (@fields) {          }
                             if ($hashref->{$field}) {          if (ref($hashref) eq 'HASH') { 
                                 $checks{$field} = ' checked="checked" ';              foreach my $field (@fields) {
                             }                  if ($hashref->{$field}) {
                         }                      if ($role eq 'emailusername') {
                           $checks{$field} = $hashref->{$field};
                       } else {
                           $checks{$field} = ' checked="checked" ';
                     }                      }
                 }                  }
             }              }
Line 8532  sub modifiable_userdata_row { Line 9122  sub modifiable_userdata_row {
         unless ($role eq 'emailusername') {          unless ($role eq 'emailusername') {
             if (exists($checks{$fields[$i]})) {              if (exists($checks{$fields[$i]})) {
                 $check = $checks{$fields[$i]}                  $check = $checks{$fields[$i]}
             } else {              } elsif ($context ne 'lti') {
                 if ($role eq 'st') {                  if ($role eq 'st') {
                     if (ref($settings) ne 'HASH') {                      if (ref($settings) ne 'HASH') {
                         $check = ' checked="checked" ';                           $check = ' checked="checked" '; 
Line 8542  sub modifiable_userdata_row { Line 9132  sub modifiable_userdata_row {
         }          }
         $output .= '<td class="LC_left_item">'.          $output .= '<td class="LC_left_item">'.
                    '<span class="LC_nobreak">';                     '<span class="LC_nobreak">';
           my $prefix = 'canmodify';
         if ($role eq 'emailusername') {          if ($role eq 'emailusername') {
             unless ($checks{$fields[$i]} =~ /^(required|optional)$/) {              unless ($checks{$fields[$i]} =~ /^(required|optional)$/) {
                 $checks{$fields[$i]} = 'omit';                  $checks{$fields[$i]} = 'omit';
Line 8552  sub modifiable_userdata_row { Line 9143  sub modifiable_userdata_row {
                     $checked='checked="checked" ';                      $checked='checked="checked" ';
                 }                  }
                 $output .= '<label>'.                  $output .= '<label>'.
                            '<input type="radio" name="canmodify_'.$item.'_'.$fields[$i].'" value="'.$option.'" '.$checked.'/>'.                             '<input type="radio" name="'.$prefix.'_'.$item.'_'.$fields[$i].'" value="'.$option.'" '.$checked.'/>'.
                            &mt($option).'</label>'.('&nbsp;' x2);                             &mt($option).'</label>'.('&nbsp;' x2);
             }              }
             $output .= '<i>'.$fieldtitles{$fields[$i]}.'</i>';              $output .= '<i>'.$fieldtitles{$fields[$i]}.'</i>';
         } else {          } else {
               if ($context eq 'lti') {
                   $prefix = 'lti';
               }
             $output .= '<label>'.              $output .= '<label>'.
                        '<input type="checkbox" name="canmodify_'.$role.'" '.                         '<input type="checkbox" name="'.$prefix.'_'.$role.'" '.
                        'value="'.$fields[$i].'"'.$check.'/>'.$fieldtitles{$fields[$i]}.                         'value="'.$fields[$i].'"'.$check.'/>'.$fieldtitles{$fields[$i]}.
                        '</label>';                         '</label>';
         }          }
Line 8660  sub insttypes_row { Line 9254  sub insttypes_row {
         }          }
         $output .= '&nbsp;';            $output .= '&nbsp;';  
     } else {      } else {
         if (($rem == 0) && (@{$types} > 0)) {          if ($rem == 0) {
             $output .= '<tr>';              $output .= '<tr>';
         }          }
         if ($colsleft > 1) {          if ($colsleft > 1) {
Line 9968  sub modify_quotas { Line 10562  sub modify_quotas {
         $context = $action;          $context = $action;
     }      }
     if ($context eq 'requestcourses') {      if ($context eq 'requestcourses') {
         @usertools = ('official','unofficial','community','textbook','placement');          @usertools = ('official','unofficial','community','textbook','placement','lti');
         @options =('norequest','approval','validate','autolimit');          @options =('norequest','approval','validate','autolimit');
         %validations = &Apache::lonnet::auto_courserequest_checks($dom);          %validations = &Apache::lonnet::auto_courserequest_checks($dom);
         %titles = &courserequest_titles();          %titles = &courserequest_titles();
Line 10017  sub modify_quotas { Line 10611  sub modify_quotas {
         my @approvalnotify = &Apache::loncommon::get_env_multiple('form.'.$context.'notifyapproval');          my @approvalnotify = &Apache::loncommon::get_env_multiple('form.'.$context.'notifyapproval');
         @approvalnotify = sort(@approvalnotify);          @approvalnotify = sort(@approvalnotify);
         $confhash{'notify'}{'approval'} = join(',',@approvalnotify);          $confhash{'notify'}{'approval'} = join(',',@approvalnotify);
         my @crstypes = ('official','unofficial','community','textbook','placement');          my @crstypes = ('official','unofficial','community','textbook','placement','lti');
         my @hasuniquecode = &Apache::loncommon::get_env_multiple('form.uniquecode');          my @hasuniquecode = &Apache::loncommon::get_env_multiple('form.uniquecode');
         foreach my $type (@hasuniquecode) {          foreach my $type (@hasuniquecode) {
             if (grep(/^\Q$type\E$/,@crstypes)) {              if (grep(/^\Q$type\E$/,@crstypes)) {
Line 10939  sub modify_ltitools { Line 11533  sub modify_ltitools {
                         if ($env{'form.ltitools_'.$extra.'_'.$i}) {                          if ($env{'form.ltitools_'.$extra.'_'.$i}) {
                             $confhash{$itemid}{$extra} = 1;                              $confhash{$itemid}{$extra} = 1;
                             if ($env{'form.ltitools_'.$extra.'valid_'.$i} ne '') {                              if ($env{'form.ltitools_'.$extra.'valid_'.$i} ne '') {
                                 my $lifetime = $env{'form.ltitools_'.$extra.'valid_add'};                                  my $lifetime = $env{'form.ltitools_'.$extra.'valid_'.$i};
                                 $lifetime =~ s/^\s+|\s+$//g;                                  $lifetime =~ s/^\s+|\s+$//g;
                                 if ($lifetime =~ /^\d+\.?\d*$/) {                                  if ($lifetime =~ /^\d+\.?\d*$/) {
                                     $confhash{$itemid}{$extra.'valid'} = $lifetime;                                      $confhash{$itemid}{$extra.'valid'} = $lifetime;
Line 11361  sub modify_lti { Line 11955  sub modify_lti {
                                textbook   => 'Textbook',                                 textbook   => 'Textbook',
                                placement  => 'Placement Test',                                 placement  => 'Placement Test',
     );      );
       my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
     my %lt = &lti_names();      my %lt = &lti_names();
     map { $posslti{$_} = 1; } @ltiroles;      map { $posslti{$_} = 1; } @ltiroles;
     map { $posslticrs{$_} = 1; } @lticourseroles;      map { $posslticrs{$_} = 1; } @lticourseroles;
     map { $posscrstype{$_} = 1; } @coursetypes;      map { $posscrstype{$_} = 1; } @coursetypes;
       
       my %menutitles = &ltimenu_titles();
   
     my (@items,%deletions,%itemids);      my (@items,%deletions,%itemids);
     if ($env{'form.lti_add'}) {      if ($env{'form.lti_add'}) {
         my $consumer = $env{'form.lti_consumer_add'};          my $consumer = $env{'form.lti_consumer_add'};
Line 11407  sub modify_lti { Line 12004  sub modify_lti {
         if ($position ne '') {          if ($position ne '') {
             $allpos[$position] = $itemid;              $allpos[$position] = $itemid;
         }          }
         foreach my $item ('consumer','key','secret','lifetime') {          foreach my $item ('consumer','key','secret','lifetime','requser') {
             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 11429  sub modify_lti { Line 12026  sub modify_lti {
         if ($env{'form.lti_version_'.$idx} eq 'LTI-1p0') {          if ($env{'form.lti_version_'.$idx} eq 'LTI-1p0') {
             $confhash{$itemid}{'version'} = $env{'form.lti_version_'.$idx};              $confhash{$itemid}{'version'} = $env{'form.lti_version_'.$idx};
         }          }
         if ($env{'form.lti_mapuser_'.$idx} eq 'sourcedid') {          if ($confhash{$itemid}{'requser'}) {
             $confhash{$itemid}{'mapuser'} = 'lis_person_sourcedid';               if ($env{'form.lti_mapuser_'.$idx} eq 'sourcedid') {
         } elsif ($env{'form.lti_mapuser_'.$idx} eq 'email') {                  $confhash{$itemid}{'mapuser'} = 'lis_person_sourcedid'; 
             $confhash{$itemid}{'mapuser'} = 'lis_person_contact_email_primary';              } elsif ($env{'form.lti_mapuser_'.$idx} eq 'email') {
         } elsif ($env{'form.lti_mapuser_'.$idx} eq 'other') {                  $confhash{$itemid}{'mapuser'} = 'lis_person_contact_email_primary';
             my $mapuser = $env{'form.lti_customuser_'.$idx};              } elsif ($env{'form.lti_mapuser_'.$idx} eq 'other') {
             $mapuser =~ s/(`)/'/g;                  my $mapuser = $env{'form.lti_customuser_'.$idx};
             $mapuser =~ s/^\s+|\s+$//g;                   $mapuser =~ s/(`)/'/g;
             $confhash{$itemid}{'mapuser'} = $mapuser;                   $mapuser =~ s/^\s+|\s+$//g; 
         }                  $confhash{$itemid}{'mapuser'} = $mapuser; 
         foreach my $ltirole (@lticourseroles) {              }
             my $possrole = $env{'form.lti_maprole_'.$ltirole.'_'.$idx};              foreach my $ltirole (@lticourseroles) {
             if (grep(/^\Q$possrole\E$/,@courseroles)) {                  my $possrole = $env{'form.lti_maprole_'.$ltirole.'_'.$idx};
                 $confhash{$itemid}{'maproles'}{$ltirole} = $possrole;                  if (grep(/^\Q$possrole\E$/,@courseroles)) {
             }                      $confhash{$itemid}{'maproles'}{$ltirole} = $possrole;
         }                  }
         my @possmakeuser = &Apache::loncommon::get_env_multiple('form.lti_makeuser_'.$idx);              }
         my @makeuser;              my @possmakeuser = &Apache::loncommon::get_env_multiple('form.lti_makeuser_'.$idx);
         foreach my $ltirole (sort(@possmakeuser)) {              my @makeuser;
             if ($posslti{$ltirole}) {              foreach my $ltirole (sort(@possmakeuser)) {
                 push(@makeuser,$ltirole);                  if ($posslti{$ltirole}) {
             }                      push(@makeuser,$ltirole);
         }                  }
         $confhash{$itemid}{'makeuser'} = \@makeuser;              }
         if (($env{'form.lti_mapcrs_'.$idx} eq 'course_offering_sourcedid') ||              $confhash{$itemid}{'makeuser'} = \@makeuser;
             ($env{'form.lti_mapcrs_'.$idx} eq 'context_id'))  {              if (@makeuser) {
             $confhash{$itemid}{'mapcrs'} = $env{'form.lti_mapcrs_'.$idx};                  my $lcauth = $env{'form.lti_lcauth_'.$idx};
         } elsif ($env{'form.lti_mapcrs_'.$idx} eq 'other') {                  if ($lcauth =~ /^(internal|krb4|krb5|localauth)$/) {
             my $mapcrs = $env{'form.lti_mapcrsfield_'.$idx};                       $confhash{$itemid}{'lcauth'} = $lcauth;
             $mapcrs =~ s/(`)/'/g;                      if ($lcauth ne 'internal') {
             $mapcrs =~ s/^\s+|\s+$//g;                          my $lcauthparm = $env{'form.lti_lcauthparm_'.$idx};
             $confhash{$itemid}{'mapcrs'} = $mapcrs;                          $lcauthparm =~ s/^(\s+|\s+)$//g;
         }                          $lcauthparm =~ s/`//g;
         my @posstypes = &Apache::loncommon::get_env_multiple('form.lti_mapcrstype_'.$idx);                          if ($lcauthparm ne '') {
         my @crstypes;                              $confhash{$itemid}{'lcauthparm'} = $lcauthparm;
         foreach my $type (sort(@posstypes)) {                          }
             if ($posscrstype{$type}) {                      }
                 push(@crstypes,$type);                  } else {
             }                      $confhash{$itemid}{'lcauth'} = 'lti';
         }  
         $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;  
                 }  
             }  
         }  
         foreach my $field ('passback','roster') {  
             if ($env{'form.lti_'.$field.'_'.$idx}) {  
                 $confhash{$itemid}{$field} = 1;  
             }  
         }  
         unless (($idx eq 'add') || ($changes{$itemid})) {  
             foreach my $field ('mapuser','mapcrs','section','passback','roster') {  
                 if ($domconfig{$action}{$itemid}{$field} ne $confhash{$itemid}{$field}) {  
                     $changes{$itemid} = 1;  
                 }                  }
             }              }
             foreach my $field ('makeuser','mapcrstype','selfenroll') {              my @possinstdata =  &Apache::loncommon::get_env_multiple('form.lti_instdata_'.$idx);
                 unless ($changes{$itemid}) {              if (@possinstdata) {
                     if (ref($domconfig{$action}{$itemid}{$field}) eq 'ARRAY') {                  foreach my $field (@possinstdata) {
                         if (ref($confhash{$itemid}{$field}) eq 'ARRAY') {                      if (exists($fieldtitles{$field})) {
                             my @diffs = &Apache::loncommon::compare_arrays($domconfig{$action}{$itemid}{$field},                          push(@{$confhash{$itemid}{'instdata'}});
                                                                            $confhash{$itemid}{$field});                      }
                             if (@diffs) {                  }
                                 $changes{$itemid} = 1;              }
                             }              if (($env{'form.lti_mapcrs_'.$idx} eq 'course_offering_sourcedid') ||
                         } elsif (@{$domconfig{$action}{$itemid}{$field}} > 0) {                  ($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;
               }
               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;
                       }
                   }
               }
               foreach my $field ('passback','roster','topmenu','inlinemenu') {
                   if ($env{'form.lti_'.$field.'_'.$idx}) {
                       $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}) {
                   $confhash{$itemid}{lcmenu} = [];
                   my @possmenu = &Apache::loncommon::get_env_multiple('form.lti_menuitem_'.$idx);
                   foreach my $field (@possmenu) {
                       if (exists($menutitles{$field})) {
                           if ($field eq 'grades') {
                               next unless ($env{'form.lti_inlinemenu_'.$idx});
                         }                          }
                     } elsif (ref($confhash{$itemid}{$field}) eq 'ARRAY') {                          push(@{$confhash{$itemid}{lcmenu}},$field);
                         if (@{$confhash{$itemid}{$field}} > 0) {                      }
                   }
               }
               unless (($idx eq 'add') || ($changes{$itemid})) {
                   foreach my $field ('mapuser','mapcrs','makecrs','section','passback','roster','lcauth','lcauthparm','topmenu','inlinemenu') {
                       if ($domconfig{$action}{$itemid}{$field} ne $confhash{$itemid}{$field}) {
                           $changes{$itemid} = 1;
                       }
                   }
                   unless ($changes{$itemid}) {
                       if ($domconfig{$action}{$itemid}{'passback'} eq $confhash{$itemid}{'passback'}) {
                           if ($domconfig{$action}{$itemid}{'passbackformat'} ne $confhash{$itemid}{'passbackformat'}) {
                             $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}{'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}) {
                     } elsif (keys(%{$domconfig{$action}{$itemid}{'maproles'}}) > 0) {                                  foreach my $ltirole (keys(%{$confhash{$itemid}{'maproles'}})) {
                         $changes{$itemid} = 1;                                      if ($confhash{$itemid}{'maproles'}{$ltirole} ne 
                     }                                          $domconfig{$action}{$itemid}{'maproles'}{$ltirole}) {
                 } elsif (ref($confhash{$itemid}{'maproles'}) eq 'HASH') {                                          $changes{$itemid} = 1;
                     unless ($changes{$itemid}) {                                          last;
                         if (keys(%{$confhash{$itemid}{'maproles'}}) > 0) {                                      }
                                   }
                               }
                           } elsif (keys(%{$domconfig{$action}{$itemid}{'maproles'}}) > 0) {
                             $changes{$itemid} = 1;                              $changes{$itemid} = 1;
                         }                          }
                       } elsif (ref($confhash{$itemid}{'maproles'}) eq 'HASH') {
                           unless ($changes{$itemid}) {
                               if (keys(%{$confhash{$itemid}{'maproles'}}) > 0) {
                                   $changes{$itemid} = 1;
                               }
                           }
                     }                      }
                 }                  }
             }              }
Line 11622  sub modify_lti { Line 12271  sub modify_lti {
                         my $num = length($encconfig{$itemid}{'secret'});                          my $num = length($encconfig{$itemid}{'secret'});
                         $resulttext .= ('*'x$num).'</li>';                          $resulttext .= ('*'x$num).'</li>';
                     }                      }
                     if ($confhash{$itemid}{'mapuser'}) {                      if ($confhash{$itemid}{'requser'}) {
                         my $shownmapuser;                          if ($confhash{$itemid}{'mapuser'}) {
                         if ($confhash{$itemid}{'mapuser'} eq 'lis_person_sourcedid') {                              my $shownmapuser;
                             $shownmapuser = $lt{'sourcedid'}.' (lis_person_sourcedid)';                              if ($confhash{$itemid}{'mapuser'} eq 'lis_person_sourcedid') {
                         } elsif ($confhash{$itemid}{'mapuser'} eq 'lis_person_contact_email_primary') {                                  $shownmapuser = $lt{'sourcedid'}.' (lis_person_sourcedid)';
                             $shownmapuser = $lt{'email'}.' (lis_person_contact_email_primary)';                              } elsif ($confhash{$itemid}{'mapuser'} eq 'lis_person_contact_email_primary') {
                         } else {                                  $shownmapuser = $lt{'email'}.' (lis_person_contact_email_primary)';
                             $shownmapuser = &mt('Other').' ('.$confhash{$itemid}{'mapuser'}.')';                              } else {
                         }                                   $shownmapuser = &mt('Other').' ('.$confhash{$itemid}{'mapuser'}.')';
                         $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').',';  
                             }                              }
                               $resulttext .= '<li>'.&mt('LON-CAPA username').': '.$shownmapuser.'</li>';
                         }                          }
                         if ($rolemaps) {                          if (ref($confhash{$itemid}{'maproles'}) eq 'HASH') {
                             $rolemaps =~ s/,$//;                              my $rolemaps;
                             $resulttext .= '<li>'.&mt('Role mapping:').$rolemaps.'</li>';                              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 (@{$confhash{$itemid}{'makeuser'}} > 0) { 
                                   $resulttext .= '<li>'.&mt('Following roles may create user accounts: [_1]',
                                                             join(', ',@{$confhash{$itemid}{'makeuser'}})).'<br />';
                                   if ($confhash{$itemid}{'lcauth'} eq 'lti') {
                                       $resulttext .= &mt('New users will only be able to authenticate via LTI').'</li>';
                                   } else {
                                       $resulttext .= &mt('New users will be assigned LON-CAPA authentication: [_1]',
                                                          $confhash{$itemid}{'lcauth'});
                                       if ($confhash{$itemid}{'lcauth'} eq 'internal') {
                                           $resulttext .= '; '.&mt('a randomly generated password will be created');
                                       } elsif ($confhash{$itemid}{'lcauth'} eq 'localauth') {
                                           if ($confhash{$itemid}{'lcauthparm'} ne '') {
                                               $resulttext .= ' '.&mt('with argument: [_1]',$confhash{$itemid}{'lcauthparm'});
                                           }
                                       } else {
                                           $resulttext .= '; '.&mt('Kerberos domain: [_1]',$confhash{$itemid}{'lcauthparm'});
                                       }
                                   }
                                   $resulttext .= '</li>';
                               } else {
                                   $resulttext .= '<li>'.&mt('User account creation not permitted.').'</li>';
                               }
                         }                          }
                     }                          if (ref($confhash{$itemid}{'instdata'}) eq 'ARRAY') {
                     if (ref($confhash{$itemid}{'makeuser'}) eq 'ARRAY') {                              if (@{$confhash{$itemid}{'instdata'}} > 0) {
                         if (@{$confhash{$itemid}{'makeuser'}} > 0) {                                   $resulttext .= '<li>'.&mt('Institutional data will be used when creating a new user for: [_1]',
                             $resulttext .= '<li>'.&mt('Following roles may create user accounts: [_1]',                                                            join(', ',map { $fieldtitles{$_}; } @{$confhash{$itemid}{'instdata'}})).'</li>';
                                                       join(', ',@{$confhash{$itemid}{'makeuser'}})).'</li>';                              } else {
                         } else {                                  $resulttext .= '<li>'.&mt('No institutional data used when creating a new user.').'</li>';
                             $resulttext .= '<li>'.&mt('User account creation not permitted.').'</li>';                              }
                         }                          }
                     }                          if ($confhash{$itemid}{'mapcrs'}) {
                     if ($confhash{$itemid}{'mapcrs'}) {                              $resulttext .= '<li>'.&mt('Unique course identifier').': '.$confhash{$itemid}{'mapcrs'}.'</li>';
                         $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 (ref($confhash{$itemid}{'mapcrstype'}) eq 'ARRAY') {
                     if ($confhash{$itemid}{'makecrs'}) {                              if (@{$confhash{$itemid}{'mapcrstype'}} > 0) {
                         $resulttext .= '<li>'.&mt('Instructor may create course (if absent).').'</li>';                                  $resulttext .= '<li>'.&mt('Mapping for the following LON-CAPA course types: [_1]',
                     } else {                                                 join(', ',map { $coursetypetitles{$_}; } @coursetypes)).
                         $resulttext .= '<li>'.&mt('Instructor may not create course (if absent).').'</li>';                                                 '</li>';
                     }                              } else {
                     if (ref($confhash{$itemid}{'selfenroll'}) eq 'ARRAY') {                                  $resulttext .= '<li>'.&mt('No mapping to LON-CAPA courses').'</li>';
                         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}{'makecrs'}) {
                     if ($confhash{$itemid}{'section'}) {                              $resulttext .= '<li>'.&mt('Instructor may create course (if absent).').'</li>';
                         if ($confhash{$itemid}{'section'} eq 'course_section_sourcedid') {  
                             $resulttext .= '<li>'.&mt('User section from standard field:').  
                                                  ' (course_section_sourcedid)'.'</li>';    
                         } else {                          } else {
                             $resulttext .= '<li>'.&mt('User section from:').' '.                              $resulttext .= '<li>'.&mt('Instructor may not create course (if absent).').'</li>';
                                                   $confhash{$itemid}{'section'}.'</li>';  
                         }                          }
                     } else {                          if (ref($confhash{$itemid}{'selfenroll'}) eq 'ARRAY') {
                         $resulttext .= '<li>'.&mt('No section assignment').'</li>';                              if (@{$confhash{$itemid}{'selfenroll'}} > 0) {
                     }                                  $resulttext .= '<li>'.&mt('Self-enrollment for following roles: [_1]',
                     foreach my $item ('passback','roster') {                                                            join(', ',@{$confhash{$itemid}{'selfenroll'}})).
                         $resulttext .= '<li>'.$lt{$item}.'&nbsp;';                                                 '</li>';
                         if ($confhash{$itemid}{$item}) {                              } else {
                             $resulttext .= &mt('Yes');                                  $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 {                          } else {
                             $resulttext .= &mt('No');                              $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>'; 
                               }
                         }                          }
                         $resulttext .= '</li>';  
                     }                      }
                     $resulttext .= '</ul></li>';                      $resulttext .= '</ul></li>';
                 }                  }
Line 12347  sub modify_contacts { Line 13037  sub modify_contacts {
     my @contacts = ('supportemail','adminemail');      my @contacts = ('supportemail','adminemail');
     my @mailings = ('errormail','packagesmail','helpdeskmail','otherdomsmail',      my @mailings = ('errormail','packagesmail','helpdeskmail','otherdomsmail',
                     'lonstatusmail','requestsmail','updatesmail','idconflictsmail');                      'lonstatusmail','requestsmail','updatesmail','idconflictsmail');
     my @toggles = ('reporterrors','reportupdates');      my @toggles = ('reporterrors','reportupdates','reportstatus');
       my @lonstatus = ('threshold','sysmail','weights','excluded');
     my ($fields,$fieldtitles,$fieldoptions,$possoptions) = &helpform_fields();      my ($fields,$fieldtitles,$fieldoptions,$possoptions) = &helpform_fields();
     foreach my $type (@mailings) {      foreach my $type (@mailings) {
         @{$newsetting{$type}} =           @{$newsetting{$type}} = 
Line 12380  sub modify_contacts { Line 13071  sub modify_contacts {
             $contacts_hash{'contacts'}{$item} = $env{'form.'.$item};              $contacts_hash{'contacts'}{$item} = $env{'form.'.$item};
         }          }
     }      }
       my ($lonstatus_defs,$lonstatus_names) = &Apache::loncommon::lon_status_items();
       foreach my $item (@lonstatus) {
           if ($item eq 'excluded') {
               my (%serverhomes,@excluded);
               map { $serverhomes{$_} = 1; } values(%Apache::lonnet::serverhomeIDs);
               my @possexcluded = &Apache::loncommon::get_env_multiple('form.errorexcluded');
               if (@possexcluded) {
                   foreach my $id (sort(@possexcluded)) {
                       if ($serverhomes{$id}) {
                           push(@excluded,$id);
                       }
                   }
               }
               if (@excluded) {
                   $contacts_hash{'contacts'}{'lonstatus'}{$item} = \@excluded;
               }
           } elsif ($item eq 'weights') {
               foreach my $type ('E','W','N') {
                   $env{'form.error'.$item.'_'.$type} =~ s/^\s+|\s+$//g;
                   if ($env{'form.error'.$item.'_'.$type} =~ /^\d+$/) {
                       unless ($env{'form.error'.$item.'_'.$type} == $lonstatus_defs->{$type}) {
                           $contacts_hash{'contacts'}{'lonstatus'}{$item}{$type} =
                               $env{'form.error'.$item.'_'.$type};
                       }
                   }
               }
           } elsif (($item eq 'threshold') || ($item eq 'sysmail')) {
               $env{'form.error'.$item} =~ s/^\s+|\s+$//g;
               if ($env{'form.error'.$item} =~ /^\d+$/) {
                   unless ($env{'form.error'.$item} == $lonstatus_defs->{$item}) {
                       $contacts_hash{'contacts'}{'lonstatus'}{$item} = $env{'form.error'.$item};
                   }
               }
           }
       }
     if ((ref($fields) eq 'ARRAY') && (ref($possoptions) eq 'HASH')) {      if ((ref($fields) eq 'ARRAY') && (ref($possoptions) eq 'HASH')) {
         foreach my $field (@{$fields}) {          foreach my $field (@{$fields}) {
             if (ref($possoptions->{$field}) eq 'ARRAY') {              if (ref($possoptions->{$field}) eq 'ARRAY') {
Line 12518  sub modify_contacts { Line 13244  sub modify_contacts {
                 }                  }
             }              }
         }          }
           if (ref($currsetting{'lonstatus'}) eq 'HASH') {
               foreach my $key ('excluded','weights','threshold','sysmail') {
                   if ($key eq 'excluded') {
                       if ((ref($contacts_hash{contacts}{lonstatus}) eq 'HASH') &&
                           (ref($contacts_hash{contacts}{lonstatus}{excluded}) eq 'ARRAY')) {
                           if ((ref($currsetting{'lonstatus'}{$key}) eq 'ARRAY') &&
                               (@{$currsetting{'lonstatus'}{$key}})) {
                               my @diffs =
                                   &Apache::loncommon::compare_arrays($contacts_hash{contacts}{lonstatus}{excluded},
                                                                      $currsetting{'lonstatus'}{$key});
                               if (@diffs) {
                                   push(@{$changes{'lonstatus'}},$key);
                               }
                           } elsif (@{$contacts_hash{contacts}{lonstatus}{excluded}}) {
                               push(@{$changes{'lonstatus'}},$key);
                           }
                       } elsif ((ref($currsetting{'lonstatus'}{$key}) eq 'ARRAY') &&
                                (@{$currsetting{'lonstatus'}{$key}})) {
                           push(@{$changes{'lonstatus'}},$key);
                       }
                   } elsif ($key eq 'weights') {
                       if ((ref($contacts_hash{contacts}{lonstatus}) eq 'HASH') &&
                           (ref($contacts_hash{contacts}{lonstatus}{$key}) eq 'HASH')) {
                           if (ref($currsetting{'lonstatus'}{$key}) eq 'HASH') {
                               foreach my $type ('E','W','N','U') {
                                   unless ($contacts_hash{contacts}{lonstatus}{$key}{$type} eq
                                           $currsetting{'lonstatus'}{$key}{$type}) {
                                       push(@{$changes{'lonstatus'}},$key);
                                       last;
                                   }
                               }
                           } else {
                               foreach my $type ('E','W','N','U') {
                                   if ($contacts_hash{contacts}{lonstatus}{$key}{$type} ne '') {
                                       push(@{$changes{'lonstatus'}},$key);
                                       last;
                                   }
                               }
                           }
                       } elsif (ref($currsetting{'lonstatus'}{$key}) eq 'HASH') {
                           foreach my $type ('E','W','N','U') {
                               if ($currsetting{'lonstatus'}{$key}{$type} ne '') {
                                   push(@{$changes{'lonstatus'}},$key);
                                   last;
                               }
                           }
                       }
                   } elsif (($key eq 'threshold') || ($key eq 'sysmail')) {
                       if (ref($contacts_hash{contacts}{lonstatus}) eq 'HASH') {
                           if ($currsetting{'lonstatus'}{$key} =~ /^\d+$/) {
                               if ($currsetting{'lonstatus'}{$key} != $contacts_hash{contacts}{lonstatus}{$key}) {
                                   push(@{$changes{'lonstatus'}},$key);
                               }
                           } elsif ($contacts_hash{contacts}{lonstatus}{$key} =~ /^\d+$/) {
                               push(@{$changes{'lonstatus'}},$key);
                           }
                       } elsif ($currsetting{'lonstatus'}{$key} =~ /^\d+$/) {
                           push(@{$changes{'lonstatus'}},$key);
                       }
                   }
               }
           } else {
               if (ref($contacts_hash{contacts}{lonstatus}) eq 'HASH') {
                   foreach my $key ('excluded','weights','threshold','sysmail') {
                       if (exists($contacts_hash{contacts}{lonstatus}{$key})) {
                           push(@{$changes{'lonstatus'}},$key);
                       }
                   }
               }
           }
     } else {      } else {
         my %default;          my %default;
         $default{'supportemail'} = $Apache::lonnet::perlvar{'lonSupportEMail'};          $default{'supportemail'} = $Apache::lonnet::perlvar{'lonSupportEMail'};
Line 12562  sub modify_contacts { Line 13358  sub modify_contacts {
                 }                  }
             }              }
         }          }
           if (ref($contacts_hash{contacts}{lonstatus}) eq 'HASH') {
               foreach my $key ('excluded','weights','threshold','sysmail') {
                   if (exists($contacts_hash{contacts}{lonstatus}{$key})) {
                       push(@{$changes{'lonstatus'}},$key);
                   }
               }
           }
     }      }
     foreach my $item (@toggles) {      foreach my $item (@toggles) {
         if (($env{'form.'.$item} == 1) && ($currsetting{$item} == 0)) {          if (($env{'form.'.$item} == 1) && ($currsetting{$item} == 0)) {
Line 12687  sub modify_contacts { Line 13490  sub modify_contacts {
                 }                  }
             }              }
             my @offon = ('off','on');              my @offon = ('off','on');
               my $corelink = &core_link_msu();
             if ($changes{'reporterrors'}) {              if ($changes{'reporterrors'}) {
                 $resulttext .= '<li>'.                  $resulttext .= '<li>'.
                                &mt('E-mail error reports to [_1] set to "'.                                 &mt('E-mail error reports to [_1] set to "'.
                                    $offon[$env{'form.reporterrors'}].'".',                                     $offon[$env{'form.reporterrors'}].'".',
                                    &Apache::loncommon::modal_link('http://loncapa.org/core.html',                                     $corelink).
                                        &mt('LON-CAPA core group - MSU'),600,500)).  
                                '</li>';                                 '</li>';
             }              }
             if ($changes{'reportupdates'}) {              if ($changes{'reportupdates'}) {
                 $resulttext .= '<li>'.                  $resulttext .= '<li>'.
                                 &mt('E-mail record of completed LON-CAPA updates to [_1] set to "'.                                  &mt('E-mail record of completed LON-CAPA updates to [_1] set to "'.
                                     $offon[$env{'form.reportupdates'}].'".',                                      $offon[$env{'form.reportupdates'}].'".',
                                     &Apache::loncommon::modal_link('http://loncapa.org/core.html',                                      $corelink).
                                         &mt('LON-CAPA core group - MSU'),600,500)).                                  '</li>';
               }
               if ($changes{'reportstatus'}) {
                   $resulttext .= '<li>'.
                                   &mt('E-mail status if errors above threshold to [_1] set to "'.
                                       $offon[$env{'form.reportstatus'}].'".',
                                       $corelink).
                                 '</li>';                                  '</li>';
             }              }
               if (ref($changes{'lonstatus'}) eq 'ARRAY') {
                   $resulttext .= '<li>'.
                                  &mt('Nightly status check e-mail settings').':<ul>';
                   my (%defval,%use_def,%shown);
                   $defval{'threshold'} = $lonstatus_defs->{'threshold'};
                   $defval{'sysmail'} = $lonstatus_defs->{'sysmail'};
                   $defval{'weights'} =
                       join(', ',map { $lonstatus_names->{$_}.'='.$lonstatus_defs->{$_}; } ('E','W','N','U'));
                   $defval{'excluded'} = &mt('None');
                   if (ref($contacts_hash{'contacts'}{'lonstatus'}) eq 'HASH') {
                       foreach my $item ('threshold','sysmail','weights','excluded') {
                           if (exists($contacts_hash{'contacts'}{'lonstatus'}{$item})) {
                               if (($item eq 'threshold') || ($item eq 'sysmail')) {
                                   $shown{$item} = $contacts_hash{'contacts'}{'lonstatus'}{$item};
                               } elsif ($item eq 'weights') {
                                   if (ref($contacts_hash{'contacts'}{'lonstatus'}{$item}) eq 'HASH') {
                                       foreach my $type ('E','W','N','U') {
                                           $shown{$item} .= $lonstatus_names->{$type}.'=';
                                           if (exists($contacts_hash{'contacts'}{'lonstatus'}{$item}{$type})) {
                                               $shown{$item} .= $contacts_hash{'contacts'}{'lonstatus'}{$item}{$type};
                                           } else {
                                               $shown{$item} .= $lonstatus_defs->{$type};
                                           }
                                           $shown{$item} .= ', ';
                                       }
                                       $shown{$item} =~ s/, $//;
                                   } else {
                                       $shown{$item} = $defval{$item};
                                   }
                               } elsif ($item eq 'excluded') {
                                   if (ref($contacts_hash{'contacts'}{'lonstatus'}{$item}) eq 'ARRAY') {
                                       $shown{$item} = join(', ',@{$contacts_hash{'contacts'}{'lonstatus'}{$item}});
                                   } else {
                                       $shown{$item} = $defval{$item};
                                   }
                               }
                           } else {
                               $shown{$item} = $defval{$item};
                           }
                       }
                   } else {
                       foreach my $item ('threshold','weights','excluded','sysmail') {
                           $shown{$item} = $defval{$item};
                       }
                   }
                   foreach my $item ('threshold','weights','excluded','sysmail') {
                       $resulttext .= '<li>'.&mt($titles->{'error'.$item}.' -- [_1]',
                                             $shown{$item}).'</li>';
                   }
                   $resulttext .= '</ul></li>';
               }
             if ((ref($changes{'helpform'}) eq 'ARRAY') && (ref($fields) eq 'ARRAY')) {              if ((ref($changes{'helpform'}) eq 'ARRAY') && (ref($fields) eq 'ARRAY')) {
                 my (@optional,@required,@unused,$maxsizechg);                  my (@optional,@required,@unused,$maxsizechg);
                 foreach my $field (@{$changes{'helpform'}}) {                  foreach my $field (@{$changes{'helpform'}}) {
Line 12838  sub modify_usercreation { Line 13698  sub modify_usercreation {
     }      }
   
     my @authen_contexts = ('author','course','domain');      my @authen_contexts = ('author','course','domain');
     my @authtypes = ('int','krb4','krb5','loc');      my @authtypes = ('int','krb4','krb5','loc','lti');
     my %authhash;      my %authhash;
     foreach my $item (@authen_contexts) {      foreach my $item (@authen_contexts) {
         my @authallowed =  &Apache::loncommon::get_env_multiple('form.'.$item.'_auth');          my @authallowed =  &Apache::loncommon::get_env_multiple('form.'.$item.'_auth');
Line 14020  sub modify_defaults { Line 14880  sub modify_defaults {
     my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);      my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
     my @items = ('auth_def','auth_arg_def','lang_def','timezone_def','datelocale_def',      my @items = ('auth_def','auth_arg_def','lang_def','timezone_def','datelocale_def',
                  'portal_def','intauth_cost','intauth_check','intauth_switch');                   'portal_def','intauth_cost','intauth_check','intauth_switch');
     my @authtypes = ('internal','krb4','krb5','localauth');      my @authtypes = ('internal','krb4','krb5','localauth','lti');
     foreach my $item (@items) {      foreach my $item (@items) {
         $newvalues{$item} = $env{'form.'.$item};          $newvalues{$item} = $env{'form.'.$item};
         if ($item eq 'auth_def') {          if ($item eq 'auth_def') {
Line 14212  sub modify_defaults { Line 15072  sub modify_defaults {
                                           krb4       => 'krb4',                                            krb4       => 'krb4',
                                           krb5       => 'krb5',                                            krb5       => 'krb5',
                                           localauth  => 'loc',                                            localauth  => 'loc',
                                             lti        => 'lti',
                         );                          );
                         $value = $authnames{$shortauth{$value}};                          $value = $authnames{$shortauth{$value}};
                     } elsif ($item eq 'intauth_switch') {                      } elsif ($item eq 'intauth_switch') {
Line 14284  sub modify_scantron { Line 15145  sub modify_scantron {
     my $custom = 'custom.tab';      my $custom = 'custom.tab';
     my $default = 'default.tab';      my $default = 'default.tab';
     my $servadm = $r->dir_config('lonAdmEMail');      my $servadm = $r->dir_config('lonAdmEMail');
     my ($configuserok,$author_ok,$switchserver) =       my ($configuserok,$author_ok,$switchserver) =
         &config_check($dom,$confname,$servadm);          &config_check($dom,$confname,$servadm);
     if ($env{'form.scantronformat.filename'} ne '') {      if ($env{'form.scantronformat.filename'} ne '') {
         my $error;          my $error;
Line 14319  sub modify_scantron { Line 15180  sub modify_scantron {
             if ($env{'form.scantronformat_del'}) {              if ($env{'form.scantronformat_del'}) {
                 $confhash{'scantron'}{'scantronformat'} = '';                  $confhash{'scantron'}{'scantronformat'} = '';
                 $changes{'scantronformat'} = 1;                  $changes{'scantronformat'} = 1;
               } else {
                   $confhash{'scantron'}{'scantronformat'} = $domconfig{'scantron'}{'scantronformat'};
               }
           }
       }
       my @options = ('hdr','pad','rem');
       my @fields = &scantroncsv_fields();
       my %titles = &scantronconfig_titles();
       my @formats = &Apache::loncommon::get_env_multiple('form.scantronconfig');
       my ($newdat,$currdat,%newcol,%currcol);
       if (grep(/^dat$/,@formats)) {
           $confhash{'scantron'}{config}{dat} = 1;
           $newdat = 1;
       } else {
           $newdat = 0;
       }
       if (grep(/^csv$/,@formats)) {
           my %bynum;
           foreach my $field (@fields) {
               if ($env{'form.scantronconfig_csv_'.$field} =~ /^(\d+)$/) {
                   my $posscol = $1;
                   if (($posscol < 20) && (!$bynum{$posscol})) {
                       $confhash{'scantron'}{config}{csv}{fields}{$field} = $posscol;
                       $bynum{$posscol} = $field;
                       $newcol{$field} = $posscol;
                   }
               }
           }
           if (keys(%newcol)) {
               foreach my $option (@options) {
                   if ($env{'form.scantroncsv_'.$option}) {
                       $confhash{'scantron'}{config}{csv}{options}{$option} = 1;
                   }
               }
           }
       }
       $currdat = 1;
       if (ref($domconfig{'scantron'}) eq 'HASH') {
           if (ref($domconfig{'scantron'}{'config'}) eq 'HASH') {
               unless (exists($domconfig{'scantron'}{'config'}{'dat'})) {
                   $currdat = 0;
               }
               if (ref($domconfig{'scantron'}{'config'}{'csv'}) eq 'HASH') {
                   if (ref($domconfig{'scantron'}{'config'}{'csv'}{'fields'}) eq 'HASH') {
                       %currcol = %{$domconfig{'scantron'}{'config'}{'csv'}{'fields'}};
                   }
               }
           }
       }
       if ($currdat != $newdat) {
           $changes{'config'} = 1;
       } else {
           foreach my $field (@fields) {
               if ($currcol{$field} ne '') {
                   if ($currcol{$field} ne $newcol{$field}) {
                       $changes{'config'} = 1;
                       last;
                   }
               } elsif ($newcol{$field} ne '') {
                   $changes{'config'} = 1;
                   last;
             }              }
         }          }
     }      }
Line 14329  sub modify_scantron { Line 15251  sub modify_scantron {
             if (keys(%changes) > 0) {              if (keys(%changes) > 0) {
                 if (ref($confhash{'scantron'}) eq 'HASH') {                  if (ref($confhash{'scantron'}) eq 'HASH') {
                     $resulttext = &mt('Changes made:').'<ul>';                      $resulttext = &mt('Changes made:').'<ul>';
                     if ($confhash{'scantron'}{'scantronformat'} eq '') {                      if ($changes{'scantronformat'}) {
                         $resulttext .= '<li>'.&mt('[_1] bubblesheet format file removed; [_2] file will be used for courses in this domain.',$custom,$default).'</li>';                          if ($confhash{'scantron'}{'scantronformat'} eq '') {
                     } else {                              $resulttext .= '<li>'.&mt('[_1] bubblesheet format file removed; [_2] file will be used for courses in this domain.',$custom,$default).'</li>';
                         $resulttext .= '<li>'.&mt('Custom bubblesheet format file ([_1]) uploaded for use with courses in this domain.',$custom).'</li>';                          } else {
                               $resulttext .= '<li>'.&mt('Custom bubblesheet format file ([_1]) uploaded for use with courses in this domain.',$custom).'</li>';
                           }
                       }
                       if ($changes{'config'}) {
                           if (ref($confhash{'scantron'}{'config'}) eq 'HASH') {
                               if ($confhash{'scantron'}{'config'}{'dat'}) {
                                   $resulttext .= '<li>'.&mt('Bubblesheet data upload formats includes .dat format').'</li>';
                               }
                               if (ref($confhash{'scantron'}{'config'}{'csv'}) eq 'HASH') {
                                   if (ref($confhash{'scantron'}{'config'}{'csv'}{'fields'}) eq 'HASH') {
                                       if (keys(%{$confhash{'scantron'}{'config'}{'csv'}{'fields'}})) {
                                           $resulttext .= '<li>'.&mt('Bubblesheet data upload formats includes .csv format, with following fields/column numbers supported:').'<ul>';
                                           foreach my $field (@fields) {
                                               if ($confhash{'scantron'}{'config'}{'csv'}{'fields'}{$field} ne '') {
                                                   my $showcol = $confhash{'scantron'}{'config'}{'csv'}{'fields'}{$field} + 1;
                                                   $resulttext .= '<li>'.$titles{$field}.': '.$showcol.'</li>';
                                               }
                                           }
                                           $resulttext .= '</ul></li>';
                                           if (ref($confhash{'scantron'}{'config'}{'csv'}{'options'}) eq 'HASH') {
                                               if (keys(%{$confhash{'scantron'}{'config'}{'csv'}{'options'}})) {
                                                   $resulttext .= '<li>'.&mt('Bubblesheet data upload formats includes .csv format, with following options:').'<ul>';
                                                   foreach my $option (@options) {
                                                       if ($confhash{'scantron'}{'config'}{'csv'}{'options'}{$option} ne '') {
                                                           $resulttext .= '<li>'.$titles{$option}.'</li>';
                                                       }
                                                   }
                                                   $resulttext .= '</ul></li>';
                                               }
                                           }
                                       }
                                   }
                               }
                           } else {
                               $resulttext .= '<li>'.&mt('No bubblesheet data upload formats set -- will default to assuming .dat format').'</li>';
                           }
                     }                      }
                     $resulttext .= '</ul>';                      $resulttext .= '</ul>';
                 } else {                  } else {
                     $resulttext = &mt('Changes made to bubblesheet format file.');                      $resulttext = &mt('Changes made to bubblesheet format file.');
                 }                  }
                 $resulttext .= '</ul>';  
                 &Apache::loncommon::devalidate_domconfig_cache($dom);                  &Apache::loncommon::devalidate_domconfig_cache($dom);
                 if (ref($lastactref) eq 'HASH') {                  if (ref($lastactref) eq 'HASH') {
                     $lastactref->{'domainconfig'} = 1;                      $lastactref->{'domainconfig'} = 1;
                 }                  }
             } else {              } else {
                 $resulttext = &mt('No changes made to bubblesheet format file');                  $resulttext = &mt('No changes made to bubblesheet format settings');
             }              }
         } else {          } else {
             $resulttext = '<span class="LC_error">'.              $resulttext = '<span class="LC_error">'.
Line 16013  sub modify_usersessions { Line 16970  sub modify_usersessions {
                         } else {                          } else {
                             foreach my $type (@{$types{$prefix}}) {                              foreach my $type (@{$types{$prefix}}) {
                                 if (defined($changes{$prefix}{$type})) {                                  if (defined($changes{$prefix}{$type})) {
                                     my $newvalue;                                      my ($newvalue,$notinuse);
                                     if (ref($defaultshash{'usersessions'}) eq 'HASH') {                                      if (ref($defaultshash{'usersessions'}) eq 'HASH') {
                                         if (ref($defaultshash{'usersessions'}{$prefix})) {                                          if (ref($defaultshash{'usersessions'}{$prefix})) {
                                             if ($type eq 'version') {                                              if ($type eq 'version') {
                                                 $newvalue = $defaultshash{'usersessions'}{$prefix}{$type};                                                  $newvalue = $defaultshash{'usersessions'}{$prefix}{$type};
                                             } elsif (ref($defaultshash{'usersessions'}{$prefix}{$type}) eq 'ARRAY') {                                              } else {
                                                 if (@{$defaultshash{'usersessions'}{$prefix}{$type}} > 0) {                                                  if (ref($defaultshash{'usersessions'}{$prefix}{$type}) eq 'ARRAY') {
                                                     $newvalue = join(', ',@{$defaultshash{'usersessions'}{$prefix}{$type}});                                                      if (@{$defaultshash{'usersessions'}{$prefix}{$type}} > 0) {
                                                           $newvalue = join(', ',@{$defaultshash{'usersessions'}{$prefix}{$type}});
                                                       }
                                                   } else {
                                                       $notinuse = 1;
                                                 }                                                  }
                                             }                                              }
                                         }                                          }
Line 16028  sub modify_usersessions { Line 16989  sub modify_usersessions {
                                     if ($newvalue eq '') {                                      if ($newvalue eq '') {
                                         if ($type eq 'version') {                                          if ($type eq 'version') {
                                             $resulttext .= '<li>'.&mt('[_1] set to: off',$lt{$type}).'</li>';                                              $resulttext .= '<li>'.&mt('[_1] set to: off',$lt{$type}).'</li>';
                                           } elsif ($notinuse) {
                                               $resulttext .= '<li>'.&mt('[_1] set to: not in use',$lt{$type}).'</li>';
                                         } else {                                          } else {
                                             $resulttext .= '<li>'.&mt('[_1] set to: none',$lt{$type}).'</li>';                                              $resulttext .= '<li>'.&mt('[_1] set to: none',$lt{$type}).'</li>';
                                         }                                          }
                                     } else {                                      } else {
                                         if ($type eq 'version') {                                          if ($type eq 'version') {
                                             $newvalue .= ' '.&mt('(or later)');                                               $newvalue .= ' '.&mt('(or later)');
                                         }                                          }
                                         $resulttext .= '<li>'.&mt('[_1] set to: [_2].',$lt{$type},$newvalue).'</li>';                                          $resulttext .= '<li>'.&mt('[_1] set to: [_2].',$lt{$type},$newvalue).'</li>';
                                     }                                      }
Line 16101  sub modify_ssl { Line 17064  sub modify_ssl {
                 if ($env{'form.'.$prefix.'_'.$type} =~ /^(no|req)$/) {                  if ($env{'form.'.$prefix.'_'.$type} =~ /^(no|req)$/) {
                     $value = $env{'form.'.$prefix.'_'.$type};                      $value = $env{'form.'.$prefix.'_'.$type};
                 }                  }
                 if (ref($domconfig{$action}{$prefix}) eq 'HASH') {                  if (ref($domconfig{$action}) eq 'HASH') {
                     if ($domconfig{$action}{$prefix}{$type} ne '') {                      if (ref($domconfig{$action}{$prefix}) eq 'HASH') {
                         if ($value ne $domconfig{$action}{$prefix}{$type}) {                          if ($domconfig{$action}{$prefix}{$type} ne '') {
                               if ($value ne $domconfig{$action}{$prefix}{$type}) {
                                   $changes{$prefix}{$type} = 1;
                               }
                               $defaultshash{$action}{$prefix}{$type} = $value;
                           } else {
                               $defaultshash{$action}{$prefix}{$type} = $value;
                             $changes{$prefix}{$type} = 1;                              $changes{$prefix}{$type} = 1;
                         }                          }
                         $defaultshash{$action}{$prefix}{$type} = $value;  
                     } else {                      } else {
                         $defaultshash{$action}{$prefix}{$type} = $value;                          $defaultshash{$action}{$prefix}{$type} = $value;
                         $changes{$prefix}{$type} = 1;                          $changes{$prefix}{$type} = 1;
Line 16176  sub modify_ssl { Line 17144  sub modify_ssl {
             }              }
         }          }
     }      }
       if (keys(%changes)) {
           foreach my $prefix (keys(%changes)) {
               if (ref($changes{$prefix}) eq 'HASH') {
                   if (scalar(keys(%{$changes{$prefix}})) == 0) {
                       delete($changes{$prefix});
                   }
               } else {
                   delete($changes{$prefix});
               }
           }
       }
     my $nochgmsg = &mt('No changes made to LON-CAPA SSL settings');      my $nochgmsg = &mt('No changes made to LON-CAPA SSL settings');
     if (keys(%changes) > 0) {      if (keys(%changes) > 0) {
         my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,          my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
Line 16186  sub modify_ssl { Line 17165  sub modify_ssl {
                     $domdefaults{'replication'} = $defaultshash{$action}{'replication'};                      $domdefaults{'replication'} = $defaultshash{$action}{'replication'};
                 }                  }
                 if (ref($defaultshash{$action}{'connto'}) eq 'HASH') {                  if (ref($defaultshash{$action}{'connto'}) eq 'HASH') {
                     $domdefaults{'connto'} = $domconfig{$action}{'connto'};                      $domdefaults{'connto'} = $defaultshash{$action}{'connto'};
                 }                  }
                 if (ref($defaultshash{$action}{'connfrom'}) eq 'HASH') {                  if (ref($defaultshash{$action}{'connfrom'}) eq 'HASH') {
                     $domdefaults{'connfrom'} = $domconfig{$action}{'connfrom'};                      $domdefaults{'connfrom'} = $defaultshash{$action}{'connfrom'};
                 }                  }
             }              }
             my $cachetime = 24*60*60;              my $cachetime = 24*60*60;
Line 16205  sub modify_ssl { Line 17184  sub modify_ssl {
                         $resulttext .= '<li>'.$titles{$prefix}.'<ul>';                          $resulttext .= '<li>'.$titles{$prefix}.'<ul>';
                         foreach my $type (@{$types{$prefix}}) {                          foreach my $type (@{$types{$prefix}}) {
                             if (defined($changes{$prefix}{$type})) {                              if (defined($changes{$prefix}{$type})) {
                                 my $newvalue;                                  my ($newvalue,$notinuse);
                                 if (ref($defaultshash{$action}) eq 'HASH') {                                  if (ref($defaultshash{$action}) eq 'HASH') {
                                     if (ref($defaultshash{$action}{$prefix})) {                                      if (ref($defaultshash{$action}{$prefix})) {
                                         if (($prefix eq 'connto') || ($prefix eq 'connfrom')) {                                          if (($prefix eq 'connto') || ($prefix eq 'connfrom')) {
                                             $newvalue = $titles{$defaultshash{$action}{$prefix}{$type}};                                              $newvalue = $titles{$defaultshash{$action}{$prefix}{$type}};
                                         } elsif (ref($defaultshash{$action}{$prefix}{$type}) eq 'ARRAY') {                                          } else {
                                             if (@{$defaultshash{$action}{$prefix}{$type}} > 0) {                                              if (ref($defaultshash{$action}{$prefix}{$type}) eq 'ARRAY') {
                                                 $newvalue = join(', ',@{$defaultshash{$action}{$prefix}{$type}});                                                  if (@{$defaultshash{$action}{$prefix}{$type}} > 0) {
                                                       $newvalue = join(', ',@{$defaultshash{$action}{$prefix}{$type}});
                                                   }
                                               } else {
                                                   $notinuse = 1;
                                             }                                              }
                                         }                                          }
                                     }                                      }
                                     if ($newvalue eq '') {                                      if ($notinuse) {
                                           $resulttext .= '<li>'.&mt('[_1] set to: not in use',$titles{$type}).'</li>';
                                       } elsif ($newvalue eq '') {
                                         $resulttext .= '<li>'.&mt('[_1] set to: none',$titles{$type}).'</li>';                                          $resulttext .= '<li>'.&mt('[_1] set to: none',$titles{$type}).'</li>';
                                     } else {                                      } else {
                                         $resulttext .= '<li>'.&mt('[_1] set to: [_2].',$titles{$type},$newvalue).'</li>';                                          $resulttext .= '<li>'.&mt('[_1] set to: [_2].',$titles{$type},$newvalue).'</li>';
Line 16330  sub modify_trust { Line 17315  sub modify_trust {
                         $resulttext .= '<li>'.$lt{$prefix}.'<ul>';                          $resulttext .= '<li>'.$lt{$prefix}.'<ul>';
                         foreach my $type (@types) {                          foreach my $type (@types) {
                             if (defined($changes{$prefix}{$type})) {                              if (defined($changes{$prefix}{$type})) {
                                 my $newvalue;                                  my ($newvalue,$notinuse);
                                 if (ref($defaultshash{'trust'}) eq 'HASH') {                                  if (ref($defaultshash{'trust'}) eq 'HASH') {
                                     if (ref($defaultshash{'trust'}{$prefix})) {                                      if (ref($defaultshash{'trust'}{$prefix})) {
                                         if (ref($defaultshash{'trust'}{$prefix}{$type}) eq 'ARRAY') {                                          if (ref($defaultshash{'trust'}{$prefix}{$type}) eq 'ARRAY') {
                                             if (@{$defaultshash{'trust'}{$prefix}{$type}} > 0) {                                              if (@{$defaultshash{'trust'}{$prefix}{$type}} > 0) {
                                                 $newvalue = join(', ',@{$defaultshash{'trust'}{$prefix}{$type}});                                                  $newvalue = join(', ',@{$defaultshash{'trust'}{$prefix}{$type}});
                                             }                                              }
                                           } else {
                                               $notinuse = 1;
                                         }                                          }
                                     }                                      }
                                 }                                  }
                                 if ($newvalue eq '') {                                  if ($notinuse) {
                                       $resulttext .= '<li>'.&mt('[_1] set to: not in use',$lt{$type}).'</li>';
                                   } elsif ($newvalue eq '') {
                                     $resulttext .= '<li>'.&mt('[_1] set to: none',$lt{$type}).'</li>';                                      $resulttext .= '<li>'.&mt('[_1] set to: none',$lt{$type}).'</li>';
                                 } else {                                  } else {
                                     $resulttext .= '<li>'.&mt('[_1] set to: [_2].',$lt{$type},$newvalue).'</li>';                                      $resulttext .= '<li>'.&mt('[_1] set to: [_2].',$lt{$type},$newvalue).'</li>';
Line 16375  sub modify_loadbalancing { Line 17364  sub modify_loadbalancing {
     my @sparestypes = ('primary','default');      my @sparestypes = ('primary','default');
     my %typetitles = &sparestype_titles();      my %typetitles = &sparestype_titles();
     my $resulttext;      my $resulttext;
     my (%currbalancer,%currtargets,%currrules,%existing);      my (%currbalancer,%currtargets,%currrules,%existing,%currcookies);
     if (ref($domconfig{'loadbalancing'}) eq 'HASH') {      if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
         %existing = %{$domconfig{'loadbalancing'}};          %existing = %{$domconfig{'loadbalancing'}};
     }      }
     &get_loadbalancers_config(\%servers,\%existing,\%currbalancer,      &get_loadbalancers_config(\%servers,\%existing,\%currbalancer,
                               \%currtargets,\%currrules);                                \%currtargets,\%currrules,\%currcookies);
     my ($saveloadbalancing,%defaultshash,%changes);      my ($saveloadbalancing,%defaultshash,%changes);
     my ($alltypes,$othertypes,$titles) =      my ($alltypes,$othertypes,$titles) =
         &loadbalancing_titles($dom,$intdom,$usertypes,$types);          &loadbalancing_titles($dom,$intdom,$usertypes,$types);
Line 16432  sub modify_loadbalancing { Line 17421  sub modify_loadbalancing {
             }              }
             $defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype} = \@offloadto;              $defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype} = \@offloadto;
         }          }
           if ($env{'form.loadbalancing_cookie_'.$i}) {
               $defaultshash{'loadbalancing'}{$balancer}{'cookie'} = 1;
               if (exists($currbalancer{$balancer})) { 
                   unless ($currcookies{$balancer}) {
                       $changes{'curr'}{$balancer}{'cookie'} = 1;
                   }
               }
           } elsif (exists($currbalancer{$balancer})) {
               if ($currcookies{$balancer}) {
                   $changes{'curr'}{$balancer}{'cookie'} = 1;
               }
           }
         if (ref($currtargets{$balancer}) eq 'HASH') {          if (ref($currtargets{$balancer}) eq 'HASH') {
             foreach my $sparetype (@sparestypes) {              foreach my $sparetype (@sparestypes) {
                 if (ref($currtargets{$balancer}{$sparetype}) eq 'ARRAY') {                  if (ref($currtargets{$balancer}{$sparetype}) eq 'ARRAY') {
Line 16585  sub modify_loadbalancing { Line 17586  sub modify_loadbalancing {
                                 }                                  }
                             }                              }
                         }                          }
                           if ($changes{'curr'}{$balancer}{'cookie'}) {
                               $resulttext .= '<li>'.&mt('Load Balancer: [_1] -- cookie use enabled',
                                                         $balancer).'</li>'; 
                           }
                         if (keys(%toupdate)) {                          if (keys(%toupdate)) {
                             my %thismachine;                              my %thismachine;
                             my $updatedhere;                              my $updatedhere;
Line 16814  sub lonbalance_targets_js { Line 17819  sub lonbalance_targets_js {
     }      }
     push(@alltypes,'default','_LC_adv','_LC_author','_LC_internetdom','_LC_external');      push(@alltypes,'default','_LC_adv','_LC_author','_LC_internetdom','_LC_external');
     $allinsttypes = join("','",@alltypes);      $allinsttypes = join("','",@alltypes);
     my (%currbalancer,%currtargets,%currrules,%existing);      my (%currbalancer,%currtargets,%currrules,%existing,%currcookies);
     if (ref($settings) eq 'HASH') {      if (ref($settings) eq 'HASH') {
         %existing = %{$settings};          %existing = %{$settings};
     }      }
     &get_loadbalancers_config($servers,\%existing,\%currbalancer,      &get_loadbalancers_config($servers,\%existing,\%currbalancer,
                               \%currtargets,\%currrules);                                \%currtargets,\%currrules,\%currcookies);
     my $balancers = join("','",sort(keys(%currbalancer)));      my $balancers = join("','",sort(keys(%currbalancer)));
     return <<"END";      return <<"END";
   

Removed from v.1.324  
changed lines
  Added in v.1.347


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