--- loncom/interface/domainprefs.pm 2014/04/25 17:56:43 1.237 +++ loncom/interface/domainprefs.pm 2014/05/05 21:28:10 1.240 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.237 2014/04/25 17:56:43 bisitz Exp $ +# $Id: domainprefs.pm,v 1.240 2014/05/05 21:28:10 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -387,7 +387,9 @@ sub handler { 'coursecategories' => { text => 'Cataloging of courses/communities', help => 'Domain_Configuration_Cataloging_Courses', - header => [{col1 => 'Category settings', + header => [{col1 => 'Catalog type/availability', + col2 => '',}, + {col1 => 'Category settings for standard catalog', col2 => '',}, {col1 => 'Categories', col2 => '', @@ -620,7 +622,7 @@ sub process_changes { } elsif ($action eq 'scantron') { $output = &modify_scantron($r,$dom,$confname,$lastactref,%domconfig); } elsif ($action eq 'coursecategories') { - $output = &modify_coursecategories($dom,%domconfig); + $output = &modify_coursecategories($dom,$lastactref,%domconfig); } elsif ($action eq 'serverstatuses') { $output = &modify_serverstatuses($dom,%domconfig); } elsif ($action eq 'requestcourses') { @@ -665,7 +667,7 @@ sub print_config_box { if ($numheaders > 1) { my $colspan = ''; my $rightcolspan = ''; - if (($action eq 'rolecolors') || ($action eq 'coursecategories') || ($action eq 'defaults') || + if (($action eq 'rolecolors') || ($action eq 'defaults') || (($action eq 'login') && ($numheaders < 3))) { $colspan = ' colspan="2"'; } @@ -713,8 +715,14 @@ sub print_config_box { $rowtotal ++; if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') || ($action eq 'selfenrollment') || - ($action eq 'usersessions')) { - $output .= $item->{'print'}->('middle',$dom,$settings,\$rowtotal).' + ($action eq 'usersessions') || ($action eq 'coursecategories')) { + if ($action eq 'coursecategories') { + $output .= &print_coursecategories('middle',$dom,$item,$settings,\$rowtotal); + $colspan = ' colspan="2"'; + } else { + $output .= $item->{'print'}->('middle',$dom,$settings,\$rowtotal); + } + $output .= ' @@ -724,14 +732,16 @@ sub print_config_box { '.&mt($item->{'header'}->[2]->{'col1'}).' '.&mt($item->{'header'}->[2]->{'col2'}).' - '."\n". - $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); + '."\n"; + if ($action eq 'coursecategories') { + $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal); + } else { + $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); + } $rowtotal ++; } elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') || ($action eq 'defaults')) { $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); - } elsif ($action eq 'coursecategories') { - $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal); } elsif ($action eq 'login') { if ($numheaders == 3) { $output .= &print_login('page',$dom,$confname,$phase,$settings,\$rowtotal).' @@ -4071,6 +4081,43 @@ sub print_selfcreation { $$rowtotal ++; } } + my @fields = ('lastname','firstname','middlename','permanentemail','id','inststatus'); + my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles(); + $fieldtitles{'inststatus'} = &mt('Institutional status'); + my $rem; + my $numperrow = 2; + my $css_class = $$rowtotal%2?' class="LC_odd_row"':''; + $datatable .= ''. + ''.&mt('Shibboleth (SSO) Data').''. + ''."\n". + ''; + } + $datatable .= ''; + } + my $currval; + if (ref($createsettings->{'shibenv'}) eq 'HASH') { + $currval = $createsettings->{'shibenv'}{$fields[$i]}; + } + $datatable .= ''; + } + my $colsleft = $numperrow - $rem; + if ($colsleft > 1 ) { + $datatable .= ''; + } elsif ($colsleft == 1) { + $datatable .= ''; + } + $datatable .= '
'."\n"; + for (my $i=0; $i<@fields; $i++) { + $rem = $i%($numperrow); + if ($rem == 0) { + if ($i > 0) { + $datatable .= '
'. + ''. + ' '. + $fieldtitles{$fields[$i]}.''. + '  
'; + $$rowtotal ++; } elsif ($position eq 'middle') { my %domconf = &Apache::lonnet::get_dom('configuration',['usermodification'],$dom); my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); @@ -4081,7 +4128,7 @@ sub print_selfcreation { foreach my $status (@{$types}) { $datatable .= &modifiable_userdata_row('selfcreate',$status,$domconf{'usermodification'}, $numinrow,$$rowtotal,$usertypes); - $$rowtotal ++; + $$rowtotal ++; } } } else { @@ -4127,8 +4174,8 @@ sub print_selfcreation { $additional .= ''."\n"; ($datatable,$itemcount) = &radiobutton_prefs(\%radiohash,\@toggles,\%defaultchecked, - \%choices,$itemcount,$onclick,$additional); - $$rowtotal += $itemcount; + \%choices,$$rowtotal,$onclick,$additional); + $$rowtotal ++; $datatable .= &print_requestmail($dom,'selfcreation',$createsettings,$rowtotal); $$rowtotal ++; my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info(); @@ -4746,6 +4793,49 @@ sub print_coursecategories { my ($position,$dom,$hdritem,$settings,$rowtotal) = @_; my $datatable; if ($position eq 'top') { + my (%checked); + my @catitems = ('unauth','auth'); + my @cattypes = ('std','domonly','codesrch','none'); + $checked{'unauth'} = 'std'; + $checked{'auth'} = 'std'; + if (ref($settings) eq 'HASH') { + foreach my $type (@cattypes) { + if ($type eq $settings->{'unauth'}) { + $checked{'unauth'} = $type; + } + if ($type eq $settings->{'auth'}) { + $checked{'auth'} = $type; + } + } + } + my %lt = &Apache::lonlocal::texthash ( + unauth => 'Catalog type for unauthenticated users', + auth => 'Catalog type for authenticated users', + none => 'No catalog', + std => 'Standard catalog', + domonly => 'Domain-only catalog', + codesrch => "Code search form", + ); + my $itemcount = 0; + foreach my $item (@catitems) { + my $css_class = $itemcount%2? ' class="LC_odd_row"':''; + $datatable .= ''. + ''.$lt{$item}.''. + ''; + foreach my $type (@cattypes) { + my $ischecked; + if ($checked{$item} eq $type) { + $ischecked=' checked="checked"'; + } + $datatable .= ' '; + } + $datatable .= ''; + $itemcount ++; + } + $$rowtotal += $itemcount; + } elsif ($position eq 'middle') { my $toggle_cats_crs = ' '; my $toggle_cats_dom = ' checked="checked" '; my $can_cat_crs = ' '; @@ -4952,7 +5042,7 @@ sub print_coursecategories { $datatable .= &initialize_categories($itemcount); } } else { - $datatable .= ''.$hdritem->{'header'}->[0]->{'col2'}.'' + $datatable .= ''.$hdritem->{'header'}->[1]->{'col2'}.'' .&initialize_categories($itemcount); } $$rowtotal += $itemcount; @@ -8283,7 +8373,7 @@ sub modify_selfcreation { if (($item eq 'selfcreate') || ($item eq 'statustocreate') || ($item eq 'captcha') || ($item eq 'recaptchakeys') || ($item eq 'emailusername') || ($item eq 'notify') || - ($item eq 'selfcreateprocessing')) { + ($item eq 'selfcreateprocessing') || ($item eq 'shibenv')) { $curr_usercreation{$key}{$item} = $domconfig{'usercreation'}{$key}{$item}; } else { $save_usercreate{$key}{$item} = $domconfig{'usercreation'}{$key}{$item}; @@ -8315,6 +8405,7 @@ sub modify_selfcreation { %{$cancreate{'emailusername'}} = (); @{$cancreate{'statustocreate'}} = (); %{$cancreate{'selfcreateprocessing'}} = (); + %{$cancreate{'shibenv'}} = (); my %selfcreatetypes = ( sso => 'users authenticated by institutional single sign on', login => 'users authenticated by institutional log-in', @@ -8432,6 +8523,7 @@ sub modify_selfcreation { } my @fields = ('lastname','firstname','middlename','generation', 'permanentemail','id'); + my @shibfields = (@fields,'inststatus'); my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles(); # # Where usernames may created for institutional log-in and/or institutional single sign on: @@ -8476,6 +8568,27 @@ sub modify_selfcreation { } } } + foreach my $field (@shibfields) { + if ($env{'form.shibenv_'.$field} ne '') { + $cancreate{'shibenv'}{$field} = $env{'form.shibenv_'.$field}; + } + } + if (ref($curr_usercreation{'cancreate'}) eq 'HASH') { + if (ref($curr_usercreation{'cancreate'}{'shibenv'}) eq 'HASH') { + foreach my $field (@shibfields) { + if ($env{'form.shibenv_'.$field} ne $curr_usercreation{'cancreate'}{'shibenv'}{$field}) { + push(@{$changes{'cancreate'}},'shibenv'); + } + } + } else { + foreach my $field (@shibfields) { + if ($env{'form.shibenv_'.$field}) { + push(@{$changes{'cancreate'}},'shibenv'); + last; + } + } + } + } } foreach my $item (@contexts) { if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') { @@ -8598,6 +8711,9 @@ sub modify_selfcreation { if (ref($cancreate{'statustocreate'}) eq 'ARRAY') { $save_usercreate{'cancreate'}{'statustocreate'} = $cancreate{'statustocreate'}; } + if (ref($cancreate{'shibenv'}) eq 'HASH') { + $save_usercreate{'cancreate'}{'shibenv'} = $cancreate{'shibenv'}; + } $save_usercreate{'cancreate'}{'emailusername'} = $cancreate{'emailusername'}; $save_usercreate{'emailrule'} = \@email_rule; @@ -8640,6 +8756,22 @@ sub modify_selfcreation { } } } + } elsif ($type eq 'shibenv') { + if (keys(%{$cancreate{$type}}) == 0) { + $chgtext .= &mt('Shibboleth-autheticated user does not use environment variables to set user information'); + } else { + $chgtext .= &mt('Shibboleth-autheticated user information set from environment variables, as follows:'). + ''; + } } elsif ($type eq 'statustocreate') { if ((ref($cancreate{'selfcreate'}) eq 'ARRAY') && (ref($cancreate{'statustocreate'}) eq 'ARRAY')) { @@ -9311,10 +9443,12 @@ sub modify_scantron { } sub modify_coursecategories { - my ($dom,%domconfig) = @_; + my ($dom,$lastactref,%domconfig) = @_; my ($resulttext,%deletions,%reorderings,%needreordering,%adds,%changes,$errors, $cathash); my @deletecategory = &Apache::loncommon::get_env_multiple('form.deletecategory'); + my @catitems = ('unauth','auth'); + my @cattypes = ('std','domonly','codesrch','none'); if (ref($domconfig{'coursecategories'}) eq 'HASH') { $cathash = $domconfig{'coursecategories'}{'cats'}; if ($domconfig{'coursecategories'}{'togglecats'} ne $env{'form.togglecats'}) { @@ -9333,6 +9467,14 @@ sub modify_coursecategories { $changes{'categorizecomm'} = 1; $domconfig{'coursecategories'}{'categorizecomm'} = $env{'form.categorizecomm'}; } + foreach my $item (@catitems) { + if (grep(/^\Q$env{'form.coursecat_'.$item}\E$/,@cattypes)) { + if ($domconfig{'coursecategories'}{$item} ne $env{'form.coursecat_'.$item}) { + $changes{$item} = 1; + $domconfig{'coursecategories'}{$item} = $env{'form.coursecat_'.$item}; + } + } + } } else { $changes{'togglecats'} = 1; $changes{'categorize'} = 1; @@ -9344,6 +9486,14 @@ sub modify_coursecategories { togglecatscomm => $env{'form.togglecatscomm'}, categorizecomm => $env{'form.categorizecomm'}, }; + foreach my $item (@catitems) { + if ($env{'form.coursecat_'.$item} ne 'std') { + $changes{$item} = 1; + } + if (grep(/^\Q$env{'form.coursecat_'.$item}\E$/,@cattypes)) { + $domconfig{'coursecategories'}{$item} = $env{'form.coursecat_'.$item}; + } + } } if (ref($cathash) eq 'HASH') { if (($domconfig{'coursecategories'}{'cats'}{'instcode::0'} ne '') && ($env{'form.instcode'} == 0)) { @@ -9466,6 +9616,10 @@ sub modify_coursecategories { dom => 'set in Domain ("Modify Course/Community")', crs => 'set in Course ("Course Configuration")', comm => 'set in Community ("Community Configuration")', + none => 'No catalog', + std => 'Standard catalog', + domonly => 'Domain-only catalog', + codesrch => 'Code search form', ); $resulttext = &mt('Changes made:').''; + if ($changes{'unauth'} || $changes{'auth'}) { + &Apache::loncommon::devalidate_domconfig_cache($dom); + if (ref($lastactref) eq 'HASH') { + $lastactref->{'domainconfig'} = 1; + } + } } else { $resulttext = ''. &mt('An error occurred: [_1]',$putresult).'';