--- loncom/interface/domainprefs.pm 2009/11/16 04:03:05 1.119 +++ loncom/interface/domainprefs.pm 2009/11/30 06:23:32 1.121 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.119 2009/11/16 04:03:05 raeburn Exp $ +# $Id: domainprefs.pm,v 1.121 2009/11/30 06:23:32 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -202,11 +202,12 @@ sub handler { 'quotas','autoenroll','autoupdate','directorysrch', 'usercreation','usermodification','contacts','defaults', 'scantron','coursecategories','serverstatuses', - 'requestcourses','helpsettings'],$dom); + 'requestcourses','helpsettings','coursedefaults'],$dom); my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', 'autoupdate','directorysrch','contacts', 'usercreation','usermodification','scantron', - 'requestcourses','coursecategories','serverstatuses','helpsettings'); + 'requestcourses','coursecategories','serverstatuses','helpsettings', + 'coursedefaults'); my %prefs = ( 'rolecolors' => { text => 'Default color schemes', @@ -303,7 +304,7 @@ sub handler { col2 => 'Value'}], }, 'coursecategories' => - { text => 'Cataloging of courses', + { text => 'Cataloging of courses/communities', help => 'Domain_Configuration_Cataloging_Courses', header => [{col1 => 'Category settings', col2 => '',}, @@ -325,6 +326,18 @@ sub handler { header => [{col1 => 'Setting', col2 => 'Value',}], }, + 'coursedefaults' => + {text => 'Course/Community defaults', + help => 'Domain_Configuration_Course_Defaults', + header => [{col1 => 'Setting', + col2 => 'Value',}], + }, + 'privacy' => + {text => 'User Privacy', + help => 'Domain_Configuration_User_Privacy', + header => [{col1 => 'Setting', + col2 => 'Value',}], + }, ); my %servers = &dom_servers($dom); if (keys(%servers) > 1) { @@ -423,6 +436,8 @@ sub process_changes { $output = &modify_quotas($dom,$action,%domconfig); } elsif ($action eq 'helpsettings') { $output = &modify_helpsettings($dom,%domconfig); + } elsif ($action eq 'coursedefaults') { + $output = &modify_coursedefaults($dom,%domconfig); } return $output; } @@ -611,8 +626,10 @@ sub print_config_box { } elsif ($action eq 'serverstatuses') { $output .= &print_serverstatuses($dom,$settings,\$rowtotal); } elsif ($action eq 'helpsettings') { - $output .= &print_helpsettings($dom,$settings,\$rowtotal); - } + $output .= &print_helpsettings($dom,$settings,\$rowtotal); + } elsif ($action eq 'coursedefaults') { + $output .= &print_coursedefaults($dom,$settings,\$rowtotal); + } } $output .= ' @@ -1929,33 +1946,40 @@ sub print_contacts { } sub print_helpsettings { - - my ($dom,$settings,$rowtotal) = @_; - my ($css_class,$datatable); - my $itemcount = 1; - my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles); - - %choices = + my ($dom,$settings,$rowtotal) = @_; + my ($css_class,$datatable); + my $itemcount = 1; + my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles); + %choices = &Apache::lonlocal::texthash ( submitbugs => 'Display "Submit a bug" link?', ); - - %defaultchecked = ('submitbugs' => 'on'); - - @toggles = ('submitbugs',); - - foreach my $item (@toggles) { - if ($defaultchecked{$item} eq 'on') { + %defaultchecked = ('submitbugs' => 'on'); + @toggles = ('submitbugs',); + ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, + \%choices,$itemcount); + $$rowtotal += $itemcount; + return $datatable; +} + +sub radiobutton_prefs { + my ($settings,$toggles,$defaultchecked,$choices,$itemcount) = @_; + return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') && + (ref($choices) eq 'HASH')); + + my (%checkedon,%checkedoff,$datatable,$css_class); + + foreach my $item (@{$toggles}) { + if ($defaultchecked->{$item} eq 'on') { $checkedon{$item} = ' checked="checked" '; $checkedoff{$item} = ' '; - } elsif ($defaultchecked{$item} eq 'off') { + } elsif ($defaultchecked->{$item} eq 'off') { $checkedoff{$item} = ' checked="checked" '; $checkedon{$item} = ' '; } } - if (ref($settings) eq 'HASH') { - foreach my $item (@toggles) { + foreach my $item (@{$toggles}) { if ($settings->{$item} eq '1') { $checkedon{$item} = ' checked="checked" '; $checkedoff{$item} = ' '; @@ -1964,12 +1988,11 @@ sub print_helpsettings { $checkedon{$item} = ' '; } } - } - - foreach my $item (@toggles) { + } + foreach my $item (@{$toggles}) { $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= - ''.$choices{$item}. + $datatable .= + ''.$choices->{$item}. ''. ''. ' '. ''. + ''. + ''.$title{'togglecatscomm'}.''. + ' '. + ''. + ''. + ''.$title{'categorizecomm'}.''. + ''. + ' '. + ''. ''; - $$rowtotal += 2; + $$rowtotal += 4; } else { my $css_class; my $itemcount = 1; @@ -2650,7 +2719,15 @@ sub print_coursecategories { if (ref($cats[0]) eq 'ARRAY') { my $numtop = @{$cats[0]}; my $maxnum = $numtop; - if ((!grep(/^instcode$/,@{$cats[0]})) || ($cathash->{'instcode::0'} eq '')) { + my %default_names = ( + instcode => &mt('Official courses'), + communities => &mt('Communities'), + ); + + if ((!grep(/^instcode$/,@{$cats[0]})) || + ($cathash->{'instcode::0'} eq '') || + (!grep(/^communities$/,@{$cats[0]})) || + ($cathash->{'communities::0'} eq '')) { $maxnum ++; } my $lastidx; @@ -2671,14 +2748,33 @@ sub print_coursecategories { $datatable .= ''; } $datatable .= ''; - if ($parent eq 'instcode') { - $datatable .= ''.&mt('Official courses') - .'
(' - .&mt('with institutional codes').')' - .' ' - .''; + if ($parent eq 'instcode' || $parent eq 'communities') { + $datatable .= '' + .$default_names{$parent}.''; + if ($parent eq 'instcode') { + $datatable .= '
(' + .&mt('with institutional codes') + .')'; + } else { + $datatable .= '
'; + } + $datatable .= '' + .''; + if ($parent eq 'instcode') { + $datatable .= ' '; + } else { + $datatable .= '
' + .''; + } + $datatable .= ''; + if ($parent eq 'communities') { + $datatable .= '
'; + } + $datatable .= ''; } else { $datatable .= $parent .' 
' - .&mt('Official courses').''.'
(' - .&mt('with institutional codes').')' - .' ' - .''; } } } else { @@ -2814,6 +2917,9 @@ sub coursecategories_javascript { $jstext = ' var categories = Array(1);'."\n". ' categories[0] = Array("instcode_pos");'."\n"; } + my $instcode_reserved = &mt('The name: "instcode" is a reserved category'); + my $communities_reserved = &mt('The name: "communities" is a reserved category'); + my $choose_again = '\\n'.&mt('Please use a different name for the new top level category'); $output = <<"ENDSCRIPT"; @@ -2882,25 +3001,40 @@ ENDSCRIPT sub initialize_categories { my ($itemcount) = @_; - my $datatable; - my $css_class = $itemcount%2?' class="LC_odd_row"':''; - my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','instcode_pos','0'".');"'; - - $datatable = '' - .' ' - .&mt('Official courses (with institutional codes)') - .'' - .'