Diff for /loncom/interface/courseprefs.pm between versions 1.55 and 1.56

version 1.55, 2013/04/08 23:57:21 version 1.56, 2013/04/11 15:30:37
Line 317  sub handler { Line 317  sub handler {
                 stul => 'Student agreement needed to be listed',                  stul => 'Student agreement needed to be listed',
                 clas => 'Classlists and staff listing',                  clas => 'Classlists and staff listing',
                 priv => 'Privileged users (Domain Coordinators) in staff listing',                  priv => 'Privileged users (Domain Coordinators) in staff listing',
                   prdo => "Domains to check for privileged users (besides course's domain)",
                 defc => 'Default Course Spreadsheet',                  defc => 'Default Course Spreadsheet',
                 defs => 'Default Student Spreadsheet',                  defs => 'Default Student Spreadsheet',
                 seme => 'Send message to student when clicking Done on Tasks',                  seme => 'Send message to student when clicking Done on Tasks',
Line 424  sub handler { Line 425  sub handler {
                      ordered => ['default_enrollment_start_date',                       ordered => ['default_enrollment_start_date',
                                  'default_enrollment_end_date',                                   'default_enrollment_end_date',
                                  'defaultcredits',                                   'defaultcredits',
                                  'nothideprivileged','student_classlist_view',                                   'nothideprivileged','checkforpriv',
                                    'student_classlist_view',
                                  'student_classlist_opt_in','student_classlist_portfiles'],                                   'student_classlist_opt_in','student_classlist_portfiles'],
                      itemtext => {                       itemtext => {
                          default_enrollment_start_date => 'Start date',                           default_enrollment_start_date => 'Start date',
                          default_enrollment_end_date   => 'End date',                           default_enrollment_end_date   => 'End date',
                          nothideprivileged             => $lt{'priv'},                           nothideprivileged             => $lt{'priv'},
                            checkforpriv                  => $lt{'prdo'},
                          student_classlist_view        => $lt{'stuv'},                           student_classlist_view        => $lt{'stuv'},
                          student_classlist_opt_in      => $lt{'stul'},                           student_classlist_opt_in      => $lt{'stul'},
                          student_classlist_portfiles   => 'Include link to accessible portfolio files',                           student_classlist_portfiles   => 'Include link to accessible portfolio files',
Line 568  sub print_config_box { Line 571  sub print_config_box {
             exists $item->{'header'}->[0]->{'col2'}) {              exists $item->{'header'}->[0]->{'col2'}) {
  $output .= '             $output .= '          
           <tr class="LC_info_row">            <tr class="LC_info_row">
               <td class="LC_left_item">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>                <td class="LC_left_item">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
               <td class="LC_right_item">'.&mt($item->{'header'}->[0]->{'col2'}).'</td>              if ($action eq 'feedback') {
                   $output .= '
                     <td class="LC_right_item" colspan="2">';
               } else {
                   $output .= '
                     <td class="LC_right_item">';
               }
               $output .= &mt($item->{'header'}->[0]->{'col2'}).'</td>
             </tr>';              </tr>';
         }          }
         $rowtotal ++;          $rowtotal ++;
Line 587  sub print_config_box { Line 597  sub print_config_box {
             <table class="LC_nested">              <table class="LC_nested">
              <tr class="LC_info_row">               <tr class="LC_info_row">
               <td class="LC_left_item">'.&mt($item->{'header'}->[1]->{'col1'}).'</td>';                <td class="LC_left_item">'.&mt($item->{'header'}->[1]->{'col1'}).'</td>';
         $output .= '          if ($action eq 'classlists') {
               <td class="LC_right_item">'.&mt($item->{'header'}->[1]->{'col2'}).'</td>              $output .= '
                 <td class="LC_right_item" colspan="2">';
           } else {
               $output .= '
                 <td class="LC_right_item">';
           }
           $output .= &mt($item->{'header'}->[1]->{'col2'}).'</td>
              </tr>';               </tr>';
         if ($action eq 'classlists') {          if ($action eq 'classlists') {
             $output .= &print_classlists('middle',$cdom,$settings,$itemtext,\$rowtotal,$crstype).              $output .= &print_classlists('middle',$cdom,$settings,$itemtext,\$rowtotal,$crstype).
Line 617  sub print_config_box { Line 633  sub print_config_box {
             exists $item->{'header'}->[0]->{'col2'}) {              exists $item->{'header'}->[0]->{'col2'}) {
  $output .= '             $output .= '          
           <tr class="LC_info_row">            <tr class="LC_info_row">
               <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>                <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
               <td class="LC_right_item" valign="top">'.&mt($item->{'header'}->[0]->{'col2'}).'</td>              if (($action eq 'courseinfo') || ($action eq 'localization') ||
                   ($action eq 'print_discussion')) {
                   $output .= '<td class="LC_right_item" valign="top" colspan="2">';
               } else {
                   $output .= '<td class="LC_right_item" valign="top">';
               }
               $output .= &mt($item->{'header'}->[0]->{'col2'}).'</td>
             </tr>';              </tr>';
         }          }
     }      }
Line 1104  sub process_changes { Line 1126  sub process_changes {
                             my $newtext = $maxnum-1;                              my $newtext = $maxnum-1;
                             $newhdr[$env{'form.printfmthdr_pos_'.$newtext}] = $env{'form.printfmthdr_text_'.$newtext};                              $newhdr[$env{'form.printfmthdr_pos_'.$newtext}] = $env{'form.printfmthdr_text_'.$newtext};
                             $newvalues{$entry} = join('',@newhdr);                              $newvalues{$entry} = join('',@newhdr);
                         } elsif ($entry eq 'languages') {                          } elsif (($entry eq 'languages') || 
                             my $langstr;                                   ($entry eq 'checkforpriv')) {
                               my $settings;
                             my $total = $env{'form.'.$entry.'_total'};                              my $total = $env{'form.'.$entry.'_total'};
                             if ($total) {                              if ($total) {
                                 my @deletes = &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');                                  my @deletes = &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
                                 for (my $i=0; $i<$total; $i++) {                                  for (my $i=0; $i<$total; $i++) {
                                     unless (grep(/^$i$/,@deletes)) {                                      unless (grep(/^$i$/,@deletes)) {
                                        $langstr .= $env{'form.'.$entry.'_'.$i}.',';                                          $settings .= $env{'form.'.$entry.'_'.$i}.',';
                                     }                                      }
                                 }                                  }
                             } else {                              } else {
                                 $total = 0;                                  $total = 0;
                             }                              }
                             if ($env{'form.'.$entry.'_'.$total} ne '') {                              if ($env{'form.'.$entry.'_'.$total} ne '') {
                                 my $newlang = $env{'form.'.$entry.'_'.$total};                                  my $new = $env{'form.'.$entry.'_'.$total};
                                 my %langchoices = &get_lang_choices();                                  if ($entry eq 'languages') { 
                                 if ($langchoices{$newlang}) {                                      my %langchoices = &get_lang_choices();
                                     $langstr .= $newlang;                                      if ($langchoices{$new}) {
                                           $settings .= $new;
                                       } else {
                                           $settings =~ s/,$//;
                                           $disallowed->{'localization'}{$entry} = $new;
                                       }
                                 } else {                                  } else {
                                     $langstr =~ s/,$//;                                      my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
                                     $disallowed->{'localization'}{$entry} = $newlang;                                      if ($domains{$new}) {
                                           $settings .= $new;
                                       } else {
                                           $settings =~ s/,$//;
                                           $disallowed->{'classlists'}{$entry} = $new;
                                       }
                                 }                                  }
                             } else {                              } else {
                                 $langstr =~ s/,$//;                                  $settings =~ s/,$//;
                             }                              }
                             $newvalues{$entry} = $langstr;                              $newvalues{$entry} = $settings;
                         } else {                          } else {
                             $newvalues{$entry} = $env{'form.'.$entry};                              $newvalues{$entry} = $env{'form.'.$entry};
                         }                          }
Line 1662  function loncaparevinfo() { Line 1695  function loncaparevinfo() {
 ENDSCRIPT  ENDSCRIPT
     }      }
     $jscript = '<script type="text/javascript" language="Javascript">'."\n".      $jscript = '<script type="text/javascript" language="Javascript">'."\n".
                  '// <![CDATA['."\n".  
                $browse_js."\n".$categorize_js."\n".$loncaparev_js."\n".                 $browse_js."\n".$categorize_js."\n".$loncaparev_js."\n".
                $cloners_js."\n".'</script>'."\n".$stubrowse_js."\n";                 $cloners_js."\n".'// ]]>'."\n".
                  '</script>'."\n".$stubrowse_js."\n";
     return $jscript;      return $jscript;
 }  }
   
Line 1849  sub print_courseinfo { Line 1884  sub print_courseinfo {
     my $datatable;      my $datatable;
     my $count = 0;      my $count = 0;
     foreach my $item (@{$ordered}) {      foreach my $item (@{$ordered}) {
           my $colspan;
         if ($item eq 'hidefromcat') {          if ($item eq 'hidefromcat') {
             next if (!$can_toggle_cat);              next if (!$can_toggle_cat);
         } elsif ($item eq 'categories') {          } elsif ($item eq 'categories') {
             next if (!$can_categorize);              next if (!$can_categorize);
         }          }
           unless (($item eq 'cloners') || ($item eq 'rolenames')) {
               $colspan = 2; 
           }
         $count ++;          $count ++;
         if (exists $items{$item}{advanced} && $items{$item}{advanced} == 1) {          if (exists $items{$item}{advanced} && $items{$item}{advanced} == 1) {
         $datatable .= &item_table_row_start($items{$item}{text},$count,"advanced");          $datatable .= &item_table_row_start($items{$item}{text},$count,"advanced",$colspan);
         } else {          } else {
         $datatable .= &item_table_row_start($items{$item}{text},$count);          $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
         }          }
         if ($items{$item}{input} eq 'radio') {          if ($items{$item}{input} eq 'radio') {
             $datatable .= &yesno_radio($item,$settings);              $datatable .= &yesno_radio($item,$settings);
         } elsif ($item eq 'cloners') {          } elsif ($item eq 'cloners') {
             my $includeempty = 1;              my $includeempty = 1;
             my $num = 0;              my $num = 0;
             $datatable .= &Apache::loncommon::start_data_table().              $datatable .= '</td><td align="right">'.
                             &Apache::loncommon::start_data_table().
                           &Apache::loncommon::start_data_table_row().                            &Apache::loncommon::start_data_table_row().
                           '<td><span class="LC_nobreak"><label>'.                            '<td><span class="LC_nobreak"><label>'.
                           &mt('Any user in any domain:').                            &mt('Any user in any domain:').
Line 1883  sub print_courseinfo { Line 1923  sub print_courseinfo {
                           "'cloners_all'".');"/>'.&mt('No').'</label></td>'.                            "'cloners_all'".');"/>'.&mt('No').'</label></td>'.
                           &Apache::loncommon::end_data_table_row().                            &Apache::loncommon::end_data_table_row().
                           &Apache::loncommon::end_data_table().                            &Apache::loncommon::end_data_table().
                           '<table><tr><td align="left">'.&mt('Or').                            '<table><tr><td align="left"><b>'.&mt('Or').
                           '</td></tr></table>'.                            '</b></td></tr></table>'.
                           &Apache::loncommon::start_data_table();                            &Apache::loncommon::start_data_table();
             my @cloners;              my @cloners;
             if ($settings->{$item} eq '') {              if ($settings->{$item} eq '') {
Line 1936  sub print_courseinfo { Line 1976  sub print_courseinfo {
                           '<input type="hidden" name="cloners_total" value="'.$num.'" />'.                            '<input type="hidden" name="cloners_total" value="'.$num.'" />'.
                           '</td>'.&Apache::loncommon::end_data_table_row().                            '</td>'.&Apache::loncommon::end_data_table_row().
                           &Apache::loncommon::end_data_table().                            &Apache::loncommon::end_data_table().
                           '<table><tr><td align="left">'.&mt('And').                            '<table><tr><td align="left"><b>'.&mt('And').
                           '</td></tr></table>'.                            '</b></td></tr></table>'.
                           &Apache::loncommon::start_data_table().                            &Apache::loncommon::start_data_table().
                           &Apache::loncommon::start_data_table_row().                            &Apache::loncommon::start_data_table_row().
                           '<td align="left">'.                            '<td align="left">'.
Line 1948  sub print_courseinfo { Line 1988  sub print_courseinfo {
                           '</td>'.&Apache::loncommon::end_data_table_row().                            '</td>'.&Apache::loncommon::end_data_table_row().
                           &Apache::loncommon::end_data_table();                            &Apache::loncommon::end_data_table();
         } elsif ($item eq 'rolenames') {          } elsif ($item eq 'rolenames') {
             $datatable .= &Apache::loncommon::start_data_table();              $datatable .= '</td><td align="right">'.
                             &Apache::loncommon::start_data_table();
             my @roles;              my @roles;
             if ($crstype eq 'Community') {              if ($crstype eq 'Community') {
                 @roles = ('co');                  @roles = ('co');
Line 1968  sub print_courseinfo { Line 2009  sub print_courseinfo {
             }              }
             $datatable .= &Apache::loncommon::end_data_table().'</td>';              $datatable .= &Apache::loncommon::end_data_table().'</td>';
         } elsif ($item eq 'categories') {          } elsif ($item eq 'categories') {
             my $launcher = 'onFocus="this.blur();javascript:catsbrowser();";';              my $launcher = 'onfocus="this.blur();javascript:catsbrowser();"';
             $datatable .= '<input type="hidden" name="categories" value="'.$settings->{$item}.'" />'.              $datatable .= '<input type="hidden" name="categories" value="'.$settings->{$item}.'" />'.
                           &Apache::lonhtmlcommon::textbox($item.'_display',$settings->{$item},                            &Apache::lonhtmlcommon::textbox($item.'_display',$settings->{$item},
                                                           $items{$item}{size},$launcher);                                                            $items{$item}{size},$launcher);
Line 2621  sub get_param_description { Line 2662  sub get_param_description {
   
 sub show_autocoowners {  sub show_autocoowners {
     my (@currcoown) = @_;      my (@currcoown) = @_;
     my $output = '<i>'.&mt('Co-ownership is set automatically when a Course Coordinator role is assigned to official course personnel (from institutional data).').'</i>';      my $output = '<i><span class="LC_nobreak">'.&mt('Co-ownership is set automatically when a Course Coordinator role[_1] is assigned to official course personnel (from institutional data).','</span><br /><span class="LC_nobreak">').'</span></i>';
     if (@currcoown > 0) {       if (@currcoown > 0) { 
         $output .= '<br />'.&mt('Current co-owners are:').'&nbsp;'.          $output .= '<br />'.&mt('Current co-owners are:').'&nbsp;'.
                    join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));                     join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
Line 2765  sub print_localization { Line 2806  sub print_localization {
     my $count = 0;      my $count = 0;
     foreach my $item (@{$ordered}) {      foreach my $item (@{$ordered}) {
         $count ++;          $count ++;
         $datatable .= &item_table_row_start($items{$item}{text},$count);          my $colspan;
           unless ($item eq 'languages') {
               $colspan = 2; 
           }
           $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
         if ($item eq 'timezone') {          if ($item eq 'timezone') {
             my $includeempty = 1;              my $includeempty = 1;
             my $timezone = &Apache::lonlocal::gettimezone();              my $timezone = &Apache::lonlocal::gettimezone();
Line 2784  sub print_localization { Line 2829  sub print_localization {
                                                       undef,$includeempty);                                                        undef,$includeempty);
         } else {          } else {
             if ($settings->{$item} eq '') {              if ($settings->{$item} eq '') {
                 $datatable .=                   $datatable .= '</td><td align="right">'.
                     &Apache::loncommon::select_language('languages_0','',1);                      &Apache::loncommon::select_language('languages_0','',1);
             } else {              } else {
                 my $num = 0;                  my $num = 0;
                 my @languages = split(/\s*[,;:]\s*/,$settings->{$item});                  my @languages = split(/\s*[,;:]\s*/,$settings->{$item});
                 $datatable .= &Apache::loncommon::start_data_table();                  $datatable .= '</td><td align="right"><br />'.
                                 &Apache::loncommon::start_data_table();
                 if (@languages > 0) {                  if (@languages > 0) {
                     my %langchoices = &get_lang_choices();                      my %langchoices = &get_lang_choices();
                     foreach my $lang (@languages) {                      foreach my $lang (@languages) {
Line 2816  sub print_localization { Line 2862  sub print_localization {
                               &Apache::loncommon::select_language('languages_'.$num,'',1).                                &Apache::loncommon::select_language('languages_'.$num,'',1).
                               '<input type="hidden" name="languages_total" value="'.$num.'" />'.                                '<input type="hidden" name="languages_total" value="'.$num.'" />'.
                               '</td>'.&Apache::loncommon::end_data_table_row().                                '</td>'.&Apache::loncommon::end_data_table_row().
                               &Apache::loncommon::end_data_table();                                &Apache::loncommon::end_data_table().'<br />';
             }              }
         }          }
         $datatable .= &item_table_row_end();          $datatable .= &item_table_row_end();
Line 2878  sub print_feedback { Line 2924  sub print_feedback {
         if ($position eq 'top') {          if ($position eq 'top') {
         $datatable .= &item_table_row_start($items{$item}{text},$count);          $datatable .= &item_table_row_start($items{$item}{text},$count);
         } else {          } else {
         $datatable .= &item_table_row_start($items{$item}{text}."<br/>(Custom text)",$count, "advanced");          $datatable .= &item_table_row_start($items{$item}{text}."<br/>(Custom text)",$count, "advanced",2);
         }          }
         if ($position eq 'top') {          if ($position eq 'top') {
             my $includeempty = 0;              my $includeempty = 0;
             $datatable .= &user_table($cdom,$item,\@sections,              $datatable .=  '</td><td align="right">'.
                              &user_table($cdom,$item,\@sections,
                                       $settings->{$item},\%lt);                                        $settings->{$item},\%lt);
         } else {          } else {
             $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text',              $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text',
Line 2902  sub user_table { Line 2949  sub user_table {
     } else {      } else {
         my $num = 0;          my $num = 0;
         my @curr = split(/,/,$currvalue);          my @curr = split(/,/,$currvalue);
         $output .= '<table class="LC_nested_outer">';          $output .= '<table class="LC_data_table">';
         my ($currusers);          my ($currusers);
         foreach my $val (@curr) {          foreach my $val (@curr) {
             next if ($val eq '');              next if ($val eq '');
Line 3066  sub print_discussion { Line 3113  sub print_discussion {
                                           del      => 'Delete?',                                            del      => 'Delete?',
                                           sec      => 'Sections:',                                            sec      => 'Sections:',
                                          );                                           );
   
     foreach my $item (@{$ordered}) {      foreach my $item (@{$ordered}) {
         $count ++;          $count ++;
         $datatable .= &item_table_row_start($items{$item}{text},$count);          my $colspan;
           if ($item eq 'allow_limited_html_in_feedback') {
               $colspan = 2;
           } 
           $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
         if ($item eq 'plc.roles.denied') {          if ($item eq 'plc.roles.denied') {
             $datatable .= '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings).              $datatable .= '</td><td align="right">'.
                             '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings).
                           '</table>';                            '</table>';
         } elsif ($item eq 'plc.users.denied') {          } elsif ($item eq 'plc.users.denied') {
             $datatable .= &user_table($cdom,$item,undef,              $datatable .=  '</td><td align="right">'.
                              &user_table($cdom,$item,undef,
                                       $settings->{$item},\%lt);                                        $settings->{$item},\%lt);
         } elsif ($item eq 'pch.roles.denied') {          } elsif ($item eq 'pch.roles.denied') {
             $datatable .= '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings).              $datatable .= '</td><td align="right">'.
                             '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings).
                           '</table>';                            '</table>';
         } elsif ($item eq 'pch.users.denied') {          } elsif ($item eq 'pch.users.denied') {
             $datatable .= &user_table($cdom,$item,undef,              $datatable .= '</td><td align="right">'.
                             &user_table($cdom,$item,undef,
                                       $settings->{$item},\%lt);                                        $settings->{$item},\%lt);
         } elsif ($item eq 'allow_limited_html_in_feedback') {          } elsif ($item eq 'allow_limited_html_in_feedback') {
             $datatable .= &yesno_radio($item,$settings);              $datatable .= &yesno_radio($item,$settings);
         } elsif ($item eq 'allow_discussion_post_editing') {          } elsif ($item eq 'allow_discussion_post_editing') {
             $datatable .= &Apache::loncommon::start_data_table().              $datatable .= '</td><td align="right"><br />'.
                             &Apache::loncommon::start_data_table().
                           &Apache::loncommon::start_data_table_row().                            &Apache::loncommon::start_data_table_row().
                           '<th align="left">'.&mt('Role').'</th><th>'.                            '<th align="left">'.&mt('Role').'</th><th>'.
                           &mt('Sections').'</th>'.                            &mt('Sections').'</th>'.
                           &Apache::loncommon::end_data_table_row().                            &Apache::loncommon::end_data_table_row().
                           &role_checkboxes($cdom,$cnum,$item,$settings,1).                            &role_checkboxes($cdom,$cnum,$item,$settings,1).
                           &Apache::loncommon::end_data_table();                            &Apache::loncommon::end_data_table().'<br />';
         } elsif ($item eq 'discussion_post_fonts') {          } elsif ($item eq 'discussion_post_fonts') {
             $datatable .= &Apache::loncommon::start_data_table().              $datatable .= '</td><td align="right"><br />'.
                             &Apache::loncommon::start_data_table().
                           &Apache::loncommon::start_data_table_row().                            &Apache::loncommon::start_data_table_row().
                           '<th align="center">'.&mt('Sum of likes/dislikes').'</th>'.                            '<th align="center">'.&mt('Sum of likes/dislikes').'</th>'.
                           '<th align="center">'.&mt('font-size').'</th>'.                            '<th align="center">'.&mt('font-size').'</th>'.
Line 3102  sub print_discussion { Line 3158  sub print_discussion {
                           '<th align="center">'.&mt('Other css').'</th>'.                             '<th align="center">'.&mt('Other css').'</th>'. 
                           &Apache::loncommon::end_data_table_row().                            &Apache::loncommon::end_data_table_row().
                           &set_discussion_fonts($cdom,$cnum,$item,$settings).                            &set_discussion_fonts($cdom,$cnum,$item,$settings).
                           &Apache::loncommon::end_data_table();                            &Apache::loncommon::end_data_table().'<br />';
         }          }
         $datatable .= &item_table_row_end();          $datatable .= &item_table_row_end();
     }      }
Line 3303  sub print_classlists { Line 3359  sub print_classlists {
             push(@ordered,'defaultcredits');              push(@ordered,'defaultcredits');
         }          }
     } elsif ($position eq 'middle') {      } elsif ($position eq 'middle') {
         @ordered = ('nothideprivileged');          @ordered = ('nothideprivileged','checkforpriv');
     } else {      } else {
         @ordered = ('student_classlist_view',          @ordered = ('student_classlist_view',
                     'student_classlist_opt_in',                      'student_classlist_opt_in',
Line 3343  sub print_classlists { Line 3399  sub print_classlists {
                    input => 'checkbox',                     input => 'checkbox',
                  },                   },
   
           'checkforpriv' => {
                      text => '<b>'.&mt($itemtext->{'checkforpriv'}).'</b>',
                      input => 'selectbox',
                    },
   
         'student_classlist_view'   => {          'student_classlist_view'   => {
                    text => '<b>'.&mt($itemtext->{'student_classlist_view'}).'</b>',                     text => '<b>'.&mt($itemtext->{'student_classlist_view'}).'</b>',
                    input => 'selectbox',                     input => 'selectbox',
Line 3363  sub print_classlists { Line 3424  sub print_classlists {
             ($settings->{'student_classlist_view'} eq 'section')) {               ($settings->{'student_classlist_view'} eq 'section')) { 
         $settings->{'student_classlist_view'} = 'disabled';          $settings->{'student_classlist_view'} = 'disabled';
     }      }
     return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype);      return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'classlists');
 }  }
   
 sub print_appearance {  sub print_appearance {
Line 3412  sub print_appearance { Line 3473  sub print_appearance {
                    size => 40,                     size => 40,
                  },                   },
     );      );
     return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);      return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'appearance');
 }  }
   
 sub print_grading {  sub print_grading {
Line 3468  sub print_grading { Line 3529  sub print_grading {
                    input => 'radio',                     input => 'radio',
                  },                   },
     );      );
     return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);      return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'grading');
 }  }
   
 sub print_printouts {  sub print_printouts {
Line 3521  sub print_printouts { Line 3582  sub print_printouts {
             nullval => &mt('None specified - use domain default'),              nullval => &mt('None specified - use domain default'),
                     }                      }
     );      );
     return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);      return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'printouts');
 }  }
   
 sub print_spreadsheet {  sub print_spreadsheet {
Line 3557  sub print_spreadsheet { Line 3618  sub print_spreadsheet {
             input => 'radio',              input => 'radio',
                          },                           },
                 );                  );
     return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);      return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'spreadsheet');
 }  }
   
 sub print_bridgetasks {  sub print_bridgetasks {
Line 3599  sub print_bridgetasks { Line 3660  sub print_bridgetasks {
              input => 'radio',               input => 'radio',
                                   },                                    },
                 );                  );
     return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype);      return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'bridgetasks');
 }  }
   
 sub print_other {  sub print_other {
Line 3624  sub print_other { Line 3685  sub print_other {
                             input => 'textbox',                              input => 'textbox',
                             size  => '30',                              size  => '30',
                            };                             };
     my $output = &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype);      my $output = &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'other');
 }  }
   
 sub get_other_items {  sub get_other_items {
Line 3651  sub get_other_items { Line 3712  sub get_other_items {
 }  }
   
 sub item_table_row_start {  sub item_table_row_start {
     my ($text,$count,$add_class) = @_;      my ($text,$count,$add_class,$colspan) = @_;
     my $output;      my $output;
  my $css_class = ($count % 2) ? 'LC_odd_row' : 'LC_even_row';      my $css_class = ($count % 2) ? 'LC_odd_row' : 'LC_even_row';
  $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq '');      $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq '');
  $output .= '<tr class="'.$css_class.'">'."\n";;      $output .= '<tr class="'.$css_class.'">'."\n".
     $output .= '<td class="LC_left_item">'.$text.                 '<td class="LC_left_item">'.$text.
                '</td><td class="LC_right_item">';                 '</td>';
       if ($colspan) {
           $output .= '<td class="LC_right_item" colspan="'.$colspan.'">';
       } else {
           $output .= '<td class="LC_right_item">';
       }
     return $output;      return $output;
 }  }
   
Line 3728  sub select_from_options { Line 3794  sub select_from_options {
 }  }
   
 sub make_item_rows {  sub make_item_rows {
     my ($cdom,$items,$ordered,$settings,$rowtotal,$crstype) = @_;      my ($cdom,$items,$ordered,$settings,$rowtotal,$crstype,$caller) = @_;
     my $datatable;      my $datatable;
     if ((ref($items) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {      if ((ref($items) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
         my $count = 0;          my $count = 0;
         foreach my $item (@{$ordered}) {          foreach my $item (@{$ordered}) {
             $count ++;              $count ++;
               my $colspan;
               if ((($caller eq 'classlists') && ($item eq 'nothideprivileged')) ||
                   (($caller eq 'printouts') && ($item ne 'print_header_format'))) {
                   $colspan = 2;
               }
             if (exists $items->{$item}{advanced} && $items->{$item}{advanced} == 1) {              if (exists $items->{$item}{advanced} && $items->{$item}{advanced} == 1) {
                 $datatable .= &item_table_row_start($items->{$item}{text},$count,"advanced");                  $datatable .= &item_table_row_start($items->{$item}{text},$count,"advanced",$colspan);
             } else {              } else {
                 $datatable .= &item_table_row_start($items->{$item}{text},$count);                  $datatable .= &item_table_row_start($items->{$item}{text},$count,undef,$colspan);
             }              }
             if ($item eq 'defaultcredits') {              if ($item eq 'defaultcredits') {
                 my $defaultcredits = $env{'course.'.$env{'request.course.id'}.'.internal.defaultcredits'};                  my $defaultcredits = $env{'course.'.$env{'request.course.id'}.'.internal.defaultcredits'};
Line 3750  sub make_item_rows { Line 3821  sub make_item_rows {
                 $datatable .= $showcredits;                  $datatable .= $showcredits;
             } elsif ($item eq 'nothideprivileged') {              } elsif ($item eq 'nothideprivileged') {
                 $datatable .= &nothidepriv_row($cdom,$item,$settings,$crstype);                  $datatable .= &nothidepriv_row($cdom,$item,$settings,$crstype);
               } elsif ($item eq 'checkforpriv') {
                   $datatable .= &checkforpriv_row($cdom,$item,$settings,$crstype);
             } elsif ($item eq 'print_header_format') {              } elsif ($item eq 'print_header_format') {
                 $datatable .= &print_hdrfmt_row($item,$settings);                  $datatable .= &print_hdrfmt_row($item,$settings);
             } elsif ($items->{$item}{input} eq 'dates') {              } elsif ($items->{$item}{input} eq 'dates') {
Line 3781  sub make_item_rows { Line 3854  sub make_item_rows {
 sub nothidepriv_row {  sub nothidepriv_row {
     my ($cdom,$item,$settings,$crstype) = @_;      my ($cdom,$item,$settings,$crstype) = @_;
     my ($cnum) = &get_course();      my ($cnum) = &get_course();
     my %nothide;      my ($datatable,%nothide,@checkdoms);
     my $datatable;  
     if (ref($settings) eq 'HASH') {      if (ref($settings) eq 'HASH') {
         if ($settings->{$item} ne '') {          if ($settings->{$item} ne '') {
             foreach my $user (split(/\s*\,\s*/,$settings->{$item})) {              foreach my $user (split(/\s*\,\s*/,$settings->{$item})) {
Line 3793  sub nothidepriv_row { Line 3865  sub nothidepriv_row {
                 }                  }
             }              }
         }          }
           if ($settings->{'checkforpriv'}) {
               @checkdoms = split(/,/,$settings->{'checkforpriv'}); 
           }
     }      }
     my %coursepersonnel = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum);      push(@checkdoms,$cdom);
     my $now = time;      my %coursepersonnel =
           &Apache::lonnet::get_my_roles($cnum,$cdom,'',['previous','future','active']);
     my @privusers;      my @privusers;
     my %privileged;  
     foreach my $person (keys(%coursepersonnel)) {      foreach my $person (keys(%coursepersonnel)) {
         my ($role,$user,$usec) = ($person =~ /^([^:]*):([^:]+:[^:]+):([^:]*)/);          my ($uname,$udom,$role) = split(/:/,$person);
         $user =~ s/:$//;          my $user = $uname.':'.$udom;
         my ($end,$start) = split(/:/,$coursepersonnel{$person});          my ($start,$end) = split(/:/,$coursepersonnel{$person});
         if ($end == -1 || $start == -1) {          if ($end == -1 || $start == -1) {
             next;              next;
         }          }
         my ($uname,$udom) = split(':',$user);          foreach my $dom (@checkdoms) { 
         unless (ref($privileged{$udom}) eq 'HASH') {              if (&Apache::lonnet::privileged($uname,$udom,\@checkdoms,['dc','su'])) {
             my %dompersonnel = &Apache::lonnet::get_domain_roles($udom,['dc'],undef,$now);                  unless (grep(/^\Q$user\E$/,@privusers)) {
             $privileged{$udom} = {};                      push(@privusers,$user);
             if (keys(%dompersonnel)) {  
                 foreach my $server (keys(%dompersonnel)) {  
                     foreach my $user (sort(keys(%{$dompersonnel{$server}}))) {  
                         my ($trole,$uname,$udom) = split(/:/,$user);   
                         $privileged{$udom}{$uname} = $trole;  
                     }  
                 }                  }
             }              }
         }          }
         if (exists($privileged{$udom}{$uname})) {  
             unless (grep(/^\Q$user\E$/,@privusers)) {  
                 push(@privusers,$user);  
             }  
         }  
     }      }
     if (@privusers) {      if (@privusers > 0) {
         $datatable .= '<table align="right">';          $datatable .= '<table align="right">';
         foreach my $user (sort(@privusers)) {          foreach my $user (sort(@privusers)) {
             my $hideon = ' checked="checked" ';              my $hideon = ' checked="checked" ';
Line 3856  sub nothidepriv_row { Line 3920  sub nothidepriv_row {
     return $datatable;      return $datatable;
 }  }
   
   sub checkforpriv_row {
       my ($cdom,$item,$settings,$crstype) = @_;
       my $datatable;
       my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
       if (keys(%domains) == 1) {
           $datatable = '</td><td align="right">'.
                        &mt("Course's domain is only domain");
           return $datatable;
       }
       my @excdoms = ($cdom);
       my $num = 0;
       if ($settings->{$item} eq '') {
           $datatable = '</td><td align="right">'.
                        &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,
                                                            1,1,undef,undef,\@excdoms);
       } else {
           my @privdoms = split(/,/,$settings->{$item});
           my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
           $datatable = '</td><td align="right"><br />'.
                        &Apache::loncommon::start_data_table();
           if (@privdoms > 0) {
               foreach my $currdom (@privdoms) {
                   next unless ($domains{$currdom});
                   my $domdesc = &Apache::lonnet::domain($currdom,'description');
                   if ($domdesc eq '') {
                       $domdesc = $currdom;
                   } 
                   $datatable .=
                       &Apache::loncommon::start_data_table_row().
                       '<td align="left"><span class="LC_nobreak">'.
                       &mt('Domain:').'<b>&nbsp;'.$domdesc.
                       '</b><input type="hidden" name="checkforpriv_'.$num.
                       '" value="'.$currdom.'" /></span><br />'.
                       '<span class="LC_nobreak"><label><input type="checkbox" '.
                       'name="checkforpriv_delete" value="'.$num.'" />'.
                       &mt('Delete').'</label></span></td>'.
                       &Apache::loncommon::end_data_table_row();
                   $num ++;
                   unless (grep(/^\Q$currdom\E$/,@excdoms)) { 
                       push(@excdoms,$currdom);
                   }
               }
           }
           if ((scalar(keys(%domains)) - scalar(@excdoms)) > 0) {
               $datatable .= 
                   &Apache::loncommon::start_data_table_row().
                   '<td align="left"><span class="LC_nobreak">'.
                   &mt('Additional domain:'). '</span><br />'.
                   &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,1,
                                                       1,undef,undef,\@excdoms).
                   '</td>'.&Apache::loncommon::end_data_table_row();
           }
           $datatable .= &Apache::loncommon::end_data_table().
                         '<input type="hidden" name="checkforpriv_total" value="'.$num.'" />'.
                         '<br />';
       }
       return $datatable;
   }
   
 sub print_hdrfmt_row {  sub print_hdrfmt_row {
     my ($item,$settings) = @_;      my ($item,$settings) = @_;
     my @curr;      my @curr;
Line 3928  function getIndexByName(item) { Line 4051  function getIndexByName(item) {
 </script>  </script>
   
 ENDJS  ENDJS
     $output .= $currstr.'<table class="LC_nested_outer">';      $output .= '</td><td align="right"><br />'.
                  $currstr.'<table class="LC_data_table">';
     if (@curr > 0) {      if (@curr > 0) {
         for (my $i=0; $i<@curr; $i++) {          for (my $i=0; $i<@curr; $i++) {
             my $pos = $i+1;              my $pos = $i+1;
Line 3968  ENDJS Line 4092  ENDJS
                '<input type="hidden" name="printfmthdr_maxnum" value="'.                 '<input type="hidden" name="printfmthdr_maxnum" value="'.
                 $maxnum.'" /></td>'.                  $maxnum.'" /></td>'.
                '</tr>'.                 '</tr>'.
                '</table>';                  '</table><br />';
     return $output;      return $output;
 }  }
   

Removed from v.1.55  
changed lines
  Added in v.1.56


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