--- loncom/interface/courseprefs.pm 2013/05/12 01:03:11 1.49.2.6 +++ loncom/interface/courseprefs.pm 2013/05/12 03:22:05 1.49.2.7 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set configuration settings for a course # -# $Id: courseprefs.pm,v 1.49.2.6 2013/05/12 01:03:11 raeburn Exp $ +# $Id: courseprefs.pm,v 1.49.2.7 2013/05/12 03:22:05 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -288,7 +288,7 @@ sub handler { stuv => 'Member-viewable membership list options', stul => 'Member agreement needed to be listed', clas => 'Membership and facilitator listing', - priv => 'Privileged users (Domain Coordinators) in facilitator listing', + prus => 'Privileged users (Domain Coordinators) in facilitator listing', defc => 'Default Community Spreadsheet', defs => 'Default User Spreadsheet', seme => 'Send message to member when clicking Done on Tasks' @@ -316,7 +316,8 @@ sub handler { stuv => 'Student-viewable classlist options', stul => 'Student agreement needed to be listed', clas => 'Classlists and staff listing', - priv => 'Privileged users (Domain Coordinators) in staff listing', + prus => 'Privileged users (Domain Coordinators) in staff listing', + prdo => "Domains to check for privileged users (besides course's domain)", defc => 'Default Course Spreadsheet', defs => 'Default Student Spreadsheet', seme => 'Send message to student when clicking Done on Tasks', @@ -424,12 +425,14 @@ sub handler { ordered => ['default_enrollment_start_date', 'default_enrollment_end_date', 'defaultcredits', - 'nothideprivileged','student_classlist_view', + 'nothideprivileged','checkforpriv', + 'student_classlist_view', 'student_classlist_opt_in','student_classlist_portfiles'], itemtext => { default_enrollment_start_date => 'Start date', default_enrollment_end_date => 'End date', - nothideprivileged => $lt{'priv'}, + nothideprivileged => $lt{'prus'}, + checkforpriv => $lt{'prdo'}, student_classlist_view => $lt{'stuv'}, student_classlist_opt_in => $lt{'stul'}, student_classlist_portfiles => 'Include link to accessible portfolio files', @@ -568,8 +571,15 @@ sub print_config_box { exists $item->{'header'}->[0]->{'col2'}) { $output .= ' <tr class="LC_info_row"> - <td class="LC_left_item">'.&mt($item->{'header'}->[0]->{'col1'}).'</td> - <td class="LC_right_item">'.&mt($item->{'header'}->[0]->{'col2'}).'</td> + <td class="LC_left_item">'.&mt($item->{'header'}->[0]->{'col1'}).'</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>'; } $rowtotal ++; @@ -587,8 +597,14 @@ sub print_config_box { <table class="LC_nested"> <tr class="LC_info_row"> <td class="LC_left_item">'.&mt($item->{'header'}->[1]->{'col1'}).'</td>'; - $output .= ' - <td class="LC_right_item">'.&mt($item->{'header'}->[1]->{'col2'}).'</td> + if ($action eq 'classlists') { + $output .= ' + <td class="LC_right_item" colspan="2">'; + } else { + $output .= ' + <td class="LC_right_item">'; + } + $output .= &mt($item->{'header'}->[1]->{'col2'}).'</td> </tr>'; if ($action eq 'classlists') { $output .= &print_classlists('middle',$cdom,$settings,$itemtext,\$rowtotal,$crstype). @@ -617,8 +633,14 @@ sub print_config_box { exists $item->{'header'}->[0]->{'col2'}) { $output .= ' <tr class="LC_info_row"> - <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> + <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}).'</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>'; } } @@ -1104,32 +1126,43 @@ sub process_changes { my $newtext = $maxnum-1; $newhdr[$env{'form.printfmthdr_pos_'.$newtext}] = $env{'form.printfmthdr_text_'.$newtext}; $newvalues{$entry} = join('',@newhdr); - } elsif ($entry eq 'languages') { - my $langstr; + } elsif (($entry eq 'languages') || + ($entry eq 'checkforpriv')) { + my $settings; my $total = $env{'form.'.$entry.'_total'}; if ($total) { my @deletes = &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete'); for (my $i=0; $i<$total; $i++) { unless (grep(/^$i$/,@deletes)) { - $langstr .= $env{'form.'.$entry.'_'.$i}.','; + $settings .= $env{'form.'.$entry.'_'.$i}.','; } } } else { $total = 0; } if ($env{'form.'.$entry.'_'.$total} ne '') { - my $newlang = $env{'form.'.$entry.'_'.$total}; - my %langchoices = &get_lang_choices(); - if ($langchoices{$newlang}) { - $langstr .= $newlang; + my $new = $env{'form.'.$entry.'_'.$total}; + if ($entry eq 'languages') { + my %langchoices = &get_lang_choices(); + if ($langchoices{$new}) { + $settings .= $new; + } else { + $settings =~ s/,$//; + $disallowed->{'localization'}{$entry} = $new; + } } else { - $langstr =~ s/,$//; - $disallowed->{'localization'}{$entry} = $newlang; + my %domains=map { $_ => 1; } &Apache::lonnet::all_domains(); + if ($domains{$new}) { + $settings .= $new; + } else { + $settings =~ s/,$//; + $disallowed->{'classlists'}{$entry} = $new; + } } } else { - $langstr =~ s/,$//; + $settings =~ s/,$//; } - $newvalues{$entry} = $langstr; + $newvalues{$entry} = $settings; } else { $newvalues{$entry} = $env{'form.'.$entry}; } @@ -1662,8 +1695,10 @@ function loncaparevinfo() { ENDSCRIPT } $jscript = '<script type="text/javascript" language="Javascript">'."\n". + '// <![CDATA['."\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; } @@ -1849,23 +1884,28 @@ sub print_courseinfo { my $datatable; my $count = 0; foreach my $item (@{$ordered}) { + my $colspan; if ($item eq 'hidefromcat') { next if (!$can_toggle_cat); } elsif ($item eq 'categories') { next if (!$can_categorize); } + unless (($item eq 'cloners') || ($item eq 'rolenames')) { + $colspan = 2; + } $count ++; 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 { - $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') { $datatable .= &yesno_radio($item,$settings); } elsif ($item eq 'cloners') { my $includeempty = 1; 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(). '<td><span class="LC_nobreak"><label>'. &mt('Any user in any domain:'). @@ -1883,8 +1923,8 @@ sub print_courseinfo { "'cloners_all'".');"/>'.&mt('No').'</label></td>'. &Apache::loncommon::end_data_table_row(). &Apache::loncommon::end_data_table(). - '<table><tr><td align="left">'.&mt('Or'). - '</td></tr></table>'. + '<table><tr><td align="left"><b>'.&mt('Or'). + '</b></td></tr></table>'. &Apache::loncommon::start_data_table(); my @cloners; if ($settings->{$item} eq '') { @@ -1936,8 +1976,8 @@ sub print_courseinfo { '<input type="hidden" name="cloners_total" value="'.$num.'" />'. '</td>'.&Apache::loncommon::end_data_table_row(). &Apache::loncommon::end_data_table(). - '<table><tr><td align="left">'.&mt('And'). - '</td></tr></table>'. + '<table><tr><td align="left"><b>'.&mt('And'). + '</b></td></tr></table>'. &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_row(). '<td align="left">'. @@ -1948,7 +1988,8 @@ sub print_courseinfo { '</td>'.&Apache::loncommon::end_data_table_row(). &Apache::loncommon::end_data_table(); } elsif ($item eq 'rolenames') { - $datatable .= &Apache::loncommon::start_data_table(); + $datatable .= '</td><td align="right">'. + &Apache::loncommon::start_data_table(); my @roles; if ($crstype eq 'Community') { @roles = ('co'); @@ -1968,7 +2009,7 @@ sub print_courseinfo { } $datatable .= &Apache::loncommon::end_data_table().'</td>'; } 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}.'" />'. &Apache::lonhtmlcommon::textbox($item.'_display',$settings->{$item}, $items{$item}{size},$launcher); @@ -2621,7 +2662,7 @@ sub get_param_description { sub show_autocoowners { 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) { $output .= '<br />'.&mt('Current co-owners are:').' '. join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown)); @@ -2765,7 +2806,11 @@ sub print_localization { my $count = 0; foreach my $item (@{$ordered}) { $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') { my $includeempty = 1; my $timezone = &Apache::lonlocal::gettimezone(); @@ -2784,12 +2829,13 @@ sub print_localization { undef,$includeempty); } else { if ($settings->{$item} eq '') { - $datatable .= + $datatable .= '</td><td align="right">'. &Apache::loncommon::select_language('languages_0','',1); } else { my $num = 0; 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) { my %langchoices = &get_lang_choices(); foreach my $lang (@languages) { @@ -2816,7 +2862,7 @@ sub print_localization { &Apache::loncommon::select_language('languages_'.$num,'',1). '<input type="hidden" name="languages_total" value="'.$num.'" />'. '</td>'.&Apache::loncommon::end_data_table_row(). - &Apache::loncommon::end_data_table(); + &Apache::loncommon::end_data_table().'<br />'; } } $datatable .= &item_table_row_end(); @@ -2878,11 +2924,12 @@ sub print_feedback { if ($position eq 'top') { $datatable .= &item_table_row_start($items{$item}{text},$count); } 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') { my $includeempty = 0; - $datatable .= &user_table($cdom,$item,\@sections, + $datatable .= '</td><td align="right">'. + &user_table($cdom,$item,\@sections, $settings->{$item},\%lt); } else { $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text', @@ -2902,7 +2949,7 @@ sub user_table { } else { my $num = 0; my @curr = split(/,/,$currvalue); - $output .= '<table class="LC_nested_outer">'; + $output .= '<table class="LC_data_table">'; my ($currusers); foreach my $val (@curr) { next if ($val eq ''); @@ -3066,34 +3113,43 @@ sub print_discussion { del => 'Delete?', sec => 'Sections:', ); - foreach my $item (@{$ordered}) { $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') { - $datatable .= '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings). + $datatable .= '</td><td align="right">'. + '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings). '</table>'; } 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); } 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>'; } 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); } elsif ($item eq 'allow_limited_html_in_feedback') { $datatable .= &yesno_radio($item,$settings); } 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(). '<th align="left">'.&mt('Role').'</th><th>'. &mt('Sections').'</th>'. &Apache::loncommon::end_data_table_row(). &role_checkboxes($cdom,$cnum,$item,$settings,1). - &Apache::loncommon::end_data_table(); + &Apache::loncommon::end_data_table().'<br />'; } 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(). '<th align="center">'.&mt('Sum of likes/dislikes').'</th>'. '<th align="center">'.&mt('font-size').'</th>'. @@ -3102,7 +3158,7 @@ sub print_discussion { '<th align="center">'.&mt('Other css').'</th>'. &Apache::loncommon::end_data_table_row(). &set_discussion_fonts($cdom,$cnum,$item,$settings). - &Apache::loncommon::end_data_table(); + &Apache::loncommon::end_data_table().'<br />'; } $datatable .= &item_table_row_end(); } @@ -3303,7 +3359,7 @@ sub print_classlists { push(@ordered,'defaultcredits'); } } elsif ($position eq 'middle') { - @ordered = ('nothideprivileged'); + @ordered = ('nothideprivileged','checkforpriv'); } else { @ordered = ('student_classlist_view', 'student_classlist_opt_in', @@ -3334,12 +3390,20 @@ sub print_classlists { text => '<b>'.&mt($itemtext->{'default_enrollment_end_date'}).'</b>', input => 'dates', }, + 'defaultcredits' => { + text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>', + }, 'nothideprivileged' => { text => '<b>'.&mt($itemtext->{'nothideprivileged'}).'</b>', input => 'checkbox', }, + 'checkforpriv' => { + text => '<b>'.&mt($itemtext->{'checkforpriv'}).'</b>', + input => 'selectbox', + }, + 'student_classlist_view' => { text => '<b>'.&mt($itemtext->{'student_classlist_view'}).'</b>', input => 'selectbox', @@ -3360,7 +3424,7 @@ sub print_classlists { ($settings->{'student_classlist_view'} eq 'section')) { $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 { @@ -3409,7 +3473,7 @@ sub print_appearance { 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 { @@ -3464,7 +3528,7 @@ sub print_grading { 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 { @@ -3517,7 +3581,7 @@ sub print_printouts { 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 { @@ -3553,7 +3617,7 @@ sub print_spreadsheet { 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 { @@ -3595,7 +3659,7 @@ sub print_bridgetasks { 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 { @@ -3620,7 +3684,7 @@ sub print_other { input => 'textbox', 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 { @@ -3647,13 +3711,18 @@ sub get_other_items { } sub item_table_row_start { - my ($text,$count,$add_class) = @_; + my ($text,$count,$add_class,$colspan) = @_; my $output; - my $css_class = ($count % 2) ? 'LC_odd_row' : 'LC_even_row'; - $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq ''); - $output .= '<tr class="'.$css_class.'">'."\n";; - $output .= '<td class="LC_left_item">'.$text. - '</td><td class="LC_right_item">'; + my $css_class = ($count % 2) ? 'LC_odd_row' : 'LC_even_row'; + $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq ''); + $output .= '<tr class="'.$css_class.'">'."\n". + '<td class="LC_left_item">'.$text. + '</td>'; + if ($colspan) { + $output .= '<td class="LC_right_item" colspan="'.$colspan.'">'; + } else { + $output .= '<td class="LC_right_item">'; + } return $output; } @@ -3724,16 +3793,21 @@ sub select_from_options { } sub make_item_rows { - my ($cdom,$items,$ordered,$settings,$rowtotal,$crstype) = @_; + my ($cdom,$items,$ordered,$settings,$rowtotal,$crstype,$caller) = @_; my $datatable; if ((ref($items) eq 'HASH') && (ref($ordered) eq 'ARRAY')) { my $count = 0; foreach my $item (@{$ordered}) { $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) { - $datatable .= &item_table_row_start($items->{$item}{text},$count,"advanced"); + $datatable .= &item_table_row_start($items->{$item}{text},$count,"advanced",$colspan); } 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') { my $defaultcredits = $env{'course.'.$env{'request.course.id'}.'.internal.defaultcredits'}; @@ -3746,6 +3820,8 @@ sub make_item_rows { $datatable .= $showcredits; } elsif ($item eq 'nothideprivileged') { $datatable .= ¬hidepriv_row($cdom,$item,$settings,$crstype); + } elsif ($item eq 'checkforpriv') { + $datatable .= &checkforpriv_row($cdom,$item,$settings,$crstype); } elsif ($item eq 'print_header_format') { $datatable .= &print_hdrfmt_row($item,$settings); } elsif ($items->{$item}{input} eq 'dates') { @@ -3777,8 +3853,7 @@ sub make_item_rows { sub nothidepriv_row { my ($cdom,$item,$settings,$crstype) = @_; my ($cnum) = &get_course(); - my %nothide; - my $datatable; + my ($datatable,%nothide,@checkdoms); if (ref($settings) eq 'HASH') { if ($settings->{$item} ne '') { foreach my $user (split(/\s*\,\s*/,$settings->{$item})) { @@ -3789,38 +3864,30 @@ sub nothidepriv_row { } } } + if ($settings->{'checkforpriv'}) { + @checkdoms = split(/,/,$settings->{'checkforpriv'}); + } } - my %coursepersonnel = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum); - my $now = time; + push(@checkdoms,$cdom); + my %coursepersonnel = + &Apache::lonnet::get_my_roles($cnum,$cdom,'',['previous','future','active']); my @privusers; - my %privileged; foreach my $person (keys(%coursepersonnel)) { - my ($role,$user,$usec) = ($person =~ /^([^:]*):([^:]+:[^:]+):([^:]*)/); - $user =~ s/:$//; - my ($end,$start) = split(/:/,$coursepersonnel{$person}); + my ($uname,$udom,$role) = split(/:/,$person); + my $user = $uname.':'.$udom; + my ($start,$end) = split(/:/,$coursepersonnel{$person}); if ($end == -1 || $start == -1) { next; } - my ($uname,$udom) = split(':',$user); - unless (ref($privileged{$udom}) eq 'HASH') { - my %dompersonnel = &Apache::lonnet::get_domain_roles($udom,['dc'],undef,$now); - $privileged{$udom} = {}; - 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; - } + foreach my $dom (@checkdoms) { + if (&Apache::lonnet::privileged($uname,$udom,\@checkdoms,['dc','su'])) { + unless (grep(/^\Q$user\E$/,@privusers)) { + push(@privusers,$user); } } } - if (exists($privileged{$udom}{$uname})) { - unless (grep(/^\Q$user\E$/,@privusers)) { - push(@privusers,$user); - } - } } - if (@privusers) { + if (@privusers > 0) { $datatable .= '<table align="right">'; foreach my $user (sort(@privusers)) { my $hideon = ' checked="checked" '; @@ -3852,6 +3919,65 @@ sub nothidepriv_row { 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> '.$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 { my ($item,$settings) = @_; my @curr; @@ -3924,7 +4050,8 @@ function getIndexByName(item) { </script> ENDJS - $output .= $currstr.'<table class="LC_nested_outer">'; + $output .= '</td><td align="right"><br />'. + $currstr.'<table class="LC_data_table">'; if (@curr > 0) { for (my $i=0; $i<@curr; $i++) { my $pos = $i+1; @@ -3964,7 +4091,7 @@ ENDJS '<input type="hidden" name="printfmthdr_maxnum" value="'. $maxnum.'" /></td>'. '</tr>'. - '</table>'; + '</table><br />'; return $output; }