--- loncom/interface/domainprefs.pm 2013/12/19 08:25:48 1.160.6.28 +++ loncom/interface/domainprefs.pm 2012/09/07 10:34:28 1.170 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.160.6.28 2013/12/19 08:25:48 raeburn Exp $ +# $Id: domainprefs.pm,v 1.170 2012/09/07 10:34:28 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -45,7 +45,7 @@ described at http://www.lon-capa.org. =head1 OVERVIEW Each institution using LON-CAPA will typically have a single domain designated -for use by individuals affiliated with the institution. Accordingly, each domain +for use by individuals affliated with the institution. Accordingly, each domain may define a default set of logos and a color scheme which can be used to "brand" the LON-CAPA instance. In addition, an institution will typically have a language and timezone which are used for the majority of courses. @@ -86,7 +86,7 @@ $dom,$settings,$rowtotal,$action. $dom is the domain, $settings is a reference to a hash of current settings for the current context, $rowtotal is a reference to the scalar used to record the -number of rows displayed on the page, and $action is the context (quotas, +number of rows displayed on the page, and $action is the context (quotas, requestcourses or requestauthor). The print_quotas routine was orginally created to display/store information @@ -94,8 +94,7 @@ about default quota sizes for portfolio institutional affiliation in the domain (e.g., Faculty, Staff, Student etc.), but is now also used to manage availability of user tools: i.e., blogs, aboutme page, and portfolios, and the course request tool, -used by course owners to request creation of a course, and to display/store -default quota sizes for authoring spaces. +used by course owners to request creation of a course. Outputs: 1 @@ -211,18 +210,16 @@ sub handler { 'quotas','autoenroll','autoupdate','autocreate', 'directorysrch','usercreation','usermodification', 'contacts','defaults','scantron','coursecategories', - 'serverstatuses','requestcourses','coursedefaults', - 'usersessions','loadbalancing','requestauthor'],$dom); + 'serverstatuses','requestcourses','helpsettings', + 'coursedefaults','usersessions','loadbalancing', + 'requestauthor'],$dom); my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', 'autoupdate','autocreate','directorysrch','contacts', 'usercreation','usermodification','scantron', 'requestcourses','requestauthor','coursecategories', - 'serverstatuses','coursedefaults','usersessions'); - my %existing; - if (ref($domconfig{'loadbalancing'}) eq 'HASH') { - %existing = %{$domconfig{'loadbalancing'}}; - } - if ((keys(%servers) > 1) || (keys(%existing) > 0)) { + 'serverstatuses','helpsettings', + 'coursedefaults','usersessions'); + if (keys(%servers) > 1) { push(@prefs_order,'loadbalancing'); } my %prefs = ( @@ -253,11 +250,11 @@ sub handler { col2 => 'Value'}], }, 'quotas' => - { text => 'Blogs, personal web pages, webDAV/quotas, portfolios', + { text => 'Blogs, personal web pages, webDAV, portfolios', help => 'Domain_Configuration_Quotas', header => [{col1 => 'User affiliation', col2 => 'Available tools', - col3 => 'Quotas, MB; (Authoring requires role)',}], + col3 => 'Portfolio quota',}], }, 'autoenroll' => { text => 'Auto-enrollment settings', @@ -354,12 +351,26 @@ sub handler { col3 => 'Specific IPs', }], }, - 'coursedefaults' => + 'helpsettings' => + {text => 'Help page settings', + help => 'Domain_Configuration_Help_Settings', + header => [{col1 => 'Help Settings (logged-in users)', + col2 => 'Value'}], + }, + 'coursedefaults' => {text => 'Course/Community defaults', help => 'Domain_Configuration_Course_Defaults', - header => [{col1 => 'Defaults which can be overridden for each course by a DC', + header => [{col1 => 'Defaults which can be overridden in each course by a CC', + col2 => 'Value',}, + {col1 => 'Defaults which can be overridden for each course by a DC', col2 => 'Value',},], }, + 'privacy' => + {text => 'User Privacy', + help => 'Domain_Configuration_User_Privacy', + header => [{col1 => 'Setting', + col2 => 'Value',}], + }, 'usersessions' => {text => 'User session hosting/offloading', help => 'Domain_Configuration_User_Sessions', @@ -371,11 +382,11 @@ sub handler { col2 => 'Rules'}], }, 'loadbalancing' => - {text => 'Dedicated Load Balancer(s)', + {text => 'Dedicated Load Balancer', help => 'Domain_Configuration_Load_Balancing', - header => [{col1 => 'Balancers', + header => [{col1 => 'Server', col2 => 'Default destinations', - col3 => 'User affiliation', + col3 => 'User affliation', col4 => 'Overrides'}, ], }, @@ -391,63 +402,26 @@ sub handler { col2 => 'Value'}], }; } - my @roles = ('student','coordinator','author','admin'); my @actions = &Apache::loncommon::get_env_multiple('form.actions'); &Apache::lonhtmlcommon::add_breadcrumb ({href=>"javascript:changePage(document.$phase,'pickactions')", text=>"Settings to display/modify"}); my $confname = $dom.'-domainconfig'; - if ($phase eq 'process') { - my $result = &Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order, - \%prefs,\%domconfig,$confname,\@roles); - if (ref($result) eq 'HASH') { - $r->rflush(); - &devalidate_remote_domconfs($dom,$result); - } + &Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,\@roles); } elsif ($phase eq 'display') { - my $js = &recaptcha_js(). - &credits_js(); - if ((keys(%servers) > 1) || (keys(%existing) > 0)) { + my $js = &recaptcha_js(); + if (keys(%servers) > 1) { my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); - $js .= &lonbalance_targets_js($dom,$types,\%servers, - $domconfig{'loadbalancing'}). + $js .= &lonbalance_targets_js($dom,$types,\%servers). &new_spares_js(). &common_domprefs_js(). &Apache::loncommon::javascript_array_indexof(); } &Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,$js); } else { -# check if domconfig user exists for the domain. - my $servadm = $r->dir_config('lonAdmEMail'); - my ($configuserok,$author_ok,$switchserver) = - &config_check($dom,$confname,$servadm); - unless ($configuserok eq 'ok') { - &Apache::lonconfigsettings::print_header($r,$phase,$context); - $r->print(&mt('The domain configuration user "[_1]" has yet to be created.', - $confname). - '
' - ); - if ($switchserver) { - $r->print(&mt('Ordinarily, that domain configuration user is created when the ./UPDATE script is run to install LON-CAPA for the first time.'). - '
'. - &mt('However, that does not apply when new domains are added to a multi-domain server, and ./UPDATE has not been run recently.'). - '
'. - &mt('The "[_1]" user can be created automatically when a Domain Coordinator visits the web-based "Set domain configuration" screen, in a session hosted on the primary library server.',$confname). - '
'. - &mt('To do that now, use the following link: [_1]',$switchserver) - ); - } else { - $r->print(&mt('To create that user from the command line run the ./UPDATE script found in the top level directory of the extracted LON-CAPA tarball.'). - '
'. - &mt('Once that is done, you will be able to use the web-based "Set domain configuration" to configure the domain') - ); - } - $r->print(&Apache::loncommon::end_page()); - return OK; - } if (keys(%domconfig) == 0) { my $primarylibserv = &Apache::lonnet::domain($dom,'primary'); my @ids=&Apache::lonnet::current_machine_ids(); @@ -487,21 +461,21 @@ sub handler { } sub process_changes { - my ($r,$dom,$confname,$action,$roles,$values,$lastactref) = @_; + my ($r,$dom,$confname,$action,$roles,$values) = @_; my %domconfig; if (ref($values) eq 'HASH') { %domconfig = %{$values}; } my $output; if ($action eq 'login') { - $output = &modify_login($r,$dom,$confname,$lastactref,%domconfig); + $output = &modify_login($r,$dom,$confname,%domconfig); } elsif ($action eq 'rolecolors') { $output = &modify_rolecolors($r,$dom,$confname,$roles, - $lastactref,%domconfig); + %domconfig); } elsif ($action eq 'quotas') { - $output = &modify_quotas($dom,$action,$lastactref,%domconfig); + $output = &modify_quotas($dom,$action,%domconfig); } elsif ($action eq 'autoenroll') { - $output = &modify_autoenroll($dom,$lastactref,%domconfig); + $output = &modify_autoenroll($dom,%domconfig); } elsif ($action eq 'autoupdate') { $output = &modify_autoupdate($dom,%domconfig); } elsif ($action eq 'autocreate') { @@ -513,23 +487,25 @@ sub process_changes { } elsif ($action eq 'usermodification') { $output = &modify_usermodification($dom,%domconfig); } elsif ($action eq 'contacts') { - $output = &modify_contacts($dom,$lastactref,%domconfig); + $output = &modify_contacts($dom,%domconfig); } elsif ($action eq 'defaults') { - $output = &modify_defaults($dom,$lastactref,%domconfig); + $output = &modify_defaults($dom,$r); } elsif ($action eq 'scantron') { - $output = &modify_scantron($r,$dom,$confname,$lastactref,%domconfig); + $output = &modify_scantron($r,$dom,$confname,%domconfig); } elsif ($action eq 'coursecategories') { $output = &modify_coursecategories($dom,%domconfig); } elsif ($action eq 'serverstatuses') { $output = &modify_serverstatuses($dom,%domconfig); } elsif ($action eq 'requestcourses') { - $output = &modify_quotas($dom,$action,$lastactref,%domconfig); + $output = &modify_quotas($dom,$action,%domconfig); } elsif ($action eq 'requestauthor') { - $output = &modify_quotas($dom,$action,$lastactref,%domconfig); + $output = &modify_quotas($dom,$action,%domconfig); + } elsif ($action eq 'helpsettings') { + $output = &modify_helpsettings($r,$dom,$confname,%domconfig); } elsif ($action eq 'coursedefaults') { - $output = &modify_coursedefaults($dom,$lastactref,%domconfig); + $output = &modify_coursedefaults($dom,%domconfig); } elsif ($action eq 'usersessions') { - $output = &modify_usersessions($dom,$lastactref,%domconfig); + $output = &modify_usersessions($dom,%domconfig); } elsif ($action eq 'loadbalancing') { $output = &modify_loadbalancing($dom,%domconfig); } @@ -558,7 +534,7 @@ sub print_config_box { if ($numheaders > 1) { my $colspan = ''; my $rightcolspan = ''; - if (($action eq 'rolecolors') || ($action eq 'coursecategories') || + if (($action eq 'rolecolors') || ($action eq 'coursecategories') || (($action eq 'login') && ($numheaders < 3))) { $colspan = ' colspan="2"'; } @@ -597,6 +573,8 @@ sub print_config_box { $output .= &print_usersessions('top',$dom,$settings,\$rowtotal); } elsif ($action eq 'rolecolors') { $output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal); + } elsif ($action eq 'coursedefaults') { + $output .= &print_coursedefaults('top',$dom,$settings,\$rowtotal); } $output .= ' @@ -686,6 +664,8 @@ sub print_config_box { '.&mt($item->{'header'}->[2]->{'col2'}).' '. &print_usersessions('bottom',$dom,$settings,\$rowtotal); $rowtotal ++; + } elsif ($action eq 'coursedefaults') { + $output .= &print_coursedefaults('bottom',$dom,$settings,\$rowtotal); } elsif ($action eq 'rolecolors') { $output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).' @@ -773,7 +753,7 @@ sub print_config_box { } elsif ($action eq 'contacts') { $output .= &print_contacts($dom,$settings,\$rowtotal); } elsif ($action eq 'defaults') { - $output .= &print_defaults($dom,$settings,\$rowtotal); + $output .= &print_defaults($dom,\$rowtotal); } elsif ($action eq 'scantron') { $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal); } elsif ($action eq 'serverstatuses') { @@ -782,8 +762,6 @@ sub print_config_box { $output .= &print_helpsettings($dom,$confname,$settings,\$rowtotal); } elsif ($action eq 'loadbalancing') { $output .= &print_loadbalancing($dom,$settings,\$rowtotal); - } elsif ($action eq 'coursedefaults') { - $output .= &print_coursedefaults('bottom',$dom,$settings,\$rowtotal); } } $output .= ' @@ -826,7 +804,7 @@ sub print_login { ' '. - ' '; + ' '.$fontlink. + '    '. + ''; unless ($role eq 'login') { $datatable .= ''. ''.$choices->{'fontmenu'}.''; @@ -1252,13 +1201,13 @@ sub display_color_options { } else { $datatable .= ' '; } - $current_color = $designs->{'fontmenu'} ? - $designs->{'fontmenu'} : $defaults->{'fontmenu'}; + $fontlink = &color_pick($phase,$role,'fontmenu',$choices->{'fontmenu'},$designs->{'fontmenu'}); $datatable .= ''. - ' '. - ' '; + ' '.$fontlink. + '    '. + ''; } my $switchserver = &check_switchserver($dom,$confname); foreach my $img (@{$images}) { @@ -1273,7 +1222,7 @@ sub display_color_options { &login_header_options($img,$role,$defaults,$is_custom,$choices); $logincolors = &login_text_colors($img,$role,$logintext,$phase,$choices, - $designs,$defaults); + $designs); } elsif ($img ne 'domlogo') { $datatable.= &logo_display_options($img,$defaults,$designs); } @@ -1352,12 +1301,12 @@ sub display_color_options { $datatable .= &image_changes($is_custom->{$img},$alt_text->{$img},$img_import, $showfile,$fullsize,$role,$img,$imgfile,$logincolors); } else { - $datatable .= ' '. - &mt('Upload:').'
'; + $datatable .= '
'. + &mt('Upload:'); } } else { - $datatable .= ' '. - &mt('Upload:').'
'; + $datatable .= '
'. + &mt('Upload:'); } if ($switchserver) { $datatable .= &mt('Upload to library server: [_1]',$switchserver); @@ -1385,14 +1334,13 @@ sub display_color_options { } $datatable .= ''. ''; - foreach my $item (@{$bgs}) { - $datatable .= ''; } $datatable .= '
'.$choices->{$item}; - my $color = $designs->{'bgs'}{$item} ? $designs->{'bgs'}{$item} : $defaults->{'bgs'}{$item}; + my $link = &color_pick($phase,$role,$item,$choices->{$item},$designs->{'bgs'}{$item}); + $datatable .= ''.$link; if ($designs->{'bgs'}{$item}) { - $datatable .= ' '; + $datatable .= '    '; } - $datatable .= '
'; @@ -1414,12 +1362,13 @@ sub display_color_options { $datatable .= ''. ''; foreach my $item (@{$links}) { - my $color = $designs->{'link'}{$item} ? $designs->{'link'}{$item} : $defaults->{'links'}{$item}; - $datatable .= ''; } $$rowtotal += $itemcount; @@ -1473,13 +1422,17 @@ sub login_header_options { } sub login_text_colors { - my ($img,$role,$logintext,$phase,$choices,$designs,$defaults) = @_; + my ($img,$role,$logintext,$phase,$choices,$designs) = @_; my $color_menu = '
'.$choices->{$item}."\n"; + $datatable .= ''."\n". + &color_pick($phase,$role,$item,$choices->{$item}, + $designs->{'links'}{$item}); if ($designs->{'links'}{$item}) { - $datatable.=' '; + $datatable.='    '; } - $datatable .= '
'; foreach my $item (@{$logintext}) { - $color_menu .= ''; + my $link = &color_pick($phase,$role,$item,$choices->{$item},$designs->{'logintext'}{$item}); + $color_menu .= ''. + ''; } $color_menu .= '
'.$choices->{$item}; - my $color = $designs->{'logintext'}{$item} ? $designs->{'logintext'}{$item} : $defaults->{'logintext'}{$item}; - $color_menu .= '
'.$link; + if ($designs->{'logintext'}{$item}) { + $color_menu .= '    '; + } + $color_menu .= '
 

'; return $color_menu; @@ -1511,12 +1464,20 @@ sub image_changes { $role.'_del_'.$img.'" value="1" />'.&mt('Delete?'). ' '.&mt('Replace:').'
'; } else { - $output .= ''.$logincolors.&mt('Upload:').'
'; + $output .= ''.$logincolors.&mt('Upload:').'
'; } } return $output; } +sub color_pick { + my ($phase,$role,$item,$desc,$curcol) = @_; + my $link = ''.$desc.''; + return $link; +} + sub print_quotas { my ($dom,$settings,$rowtotal,$action) = @_; my $context; @@ -1525,7 +1486,7 @@ sub print_quotas { } else { $context = $action; } - my ($datatable,$defaultquota,$authorquota,@usertools,@options,%validations); + my ($datatable,$defaultquota,@usertools,@options,%validations); my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); my $typecount = 0; my ($css_class,%titles); @@ -1537,25 +1498,22 @@ sub print_quotas { } elsif ($context eq 'requestauthor') { @usertools = ('author'); @options = ('norequest','approval','automatic'); - %titles = &authorrequest_titles(); + %titles = &authorrequest_titles(); } else { @usertools = ('aboutme','blog','webdav','portfolio'); %titles = &tool_titles(); } if (ref($types) eq 'ARRAY') { foreach my $type (@{$types}) { - my ($currdefquota,$currauthorquota); + my $currdefquota; unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) { if (ref($settings) eq 'HASH') { if (ref($settings->{defaultquota}) eq 'HASH') { - $currdefquota = $settings->{defaultquota}->{$type}; + $currdefquota = $settings->{defaultquota}->{$type}; } else { $currdefquota = $settings->{$type}; } - if (ref($settings->{authorquota}) eq 'HASH') { - $currauthorquota = $settings->{authorquota}->{$type}; - } } } if (defined($usertypes->{$type})) { @@ -1669,15 +1627,10 @@ sub print_quotas { unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) { $datatable .= - ''. - ''.&mt('Portfolio').': '. + ''. ''.(' ' x 2). - ''.&mt('Authoring').': '. - ''; + '" size="5" /> Mb'; } $datatable .= ''; } @@ -1685,16 +1638,12 @@ sub print_quotas { } unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) { $defaultquota = '20'; - $authorquota = '500'; if (ref($settings) eq 'HASH') { if (ref($settings->{'defaultquota'}) eq 'HASH') { $defaultquota = $settings->{'defaultquota'}->{'default'}; } elsif (defined($settings->{'default'})) { $defaultquota = $settings->{'default'}; } - if (ref($settings->{'authorquota'}) eq 'HASH') { - $authorquota = $settings->{'authorquota'}->{'default'}; - } } } $typecount ++; @@ -1760,7 +1709,9 @@ sub print_quotas { } elsif ($context eq 'requestauthor') { my $curroption; if (ref($settings) eq 'HASH') { - $curroption = $settings->{'default'}; + if (ref($settings->{'requestauthor'}) eq 'HASH') { + $curroption = $settings->{'requestauthor'}; + } } if (!$curroption) { $curroption = 'norequest'; @@ -1805,19 +1756,15 @@ sub print_quotas { } $datatable .= ''; unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) { - $datatable .= ''. - ''.&mt('Portfolio').': '. + $datatable .= ''. ''.(' ' x2). - ''.&mt('Authoring').': '. - ''; + $defaultquota.'" size="5" /> Mb'; } $datatable .= ''; $typecount ++; $css_class = $typecount%2?' class="LC_odd_row"':''; $datatable .= ''. - ''.&mt('LON-CAPA Advanced Users').'
'; + ''.&mt('LON-CAPA Advanced Users').' '; if ($context eq 'requestcourses') { $datatable .= &mt('(overrides affiliation, if set)'). ''. @@ -1909,8 +1856,8 @@ sub print_quotas { $checked = ' checked="checked"'; } $datatable .= '  '; } } else { @@ -1944,16 +1891,35 @@ sub print_quotas { sub print_requestmail { my ($dom,$action,$settings,$rowtotal) = @_; - my ($now,$datatable,%currapp); + my ($now,$datatable,%dompersonnel,@domcoord,@currapproval,$rows); $now = time; + $rows = 0; + %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc'],$now,$now); + foreach my $server (keys(%dompersonnel)) { + foreach my $user (sort(keys(%{$dompersonnel{$server}}))) { + my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,$user); + if (!grep(/^$uname:$udom$/,@domcoord)) { + push(@domcoord,$uname.':'.$udom); + } + } + } if (ref($settings) eq 'HASH') { if (ref($settings->{'notify'}) eq 'HASH') { if ($settings->{'notify'}{'approval'} ne '') { - map {$currapp{$_}=1;} split(/,/,$settings->{'notify'}{'approval'}); + @currapproval = split(',',$settings->{'notify'}{'approval'}); } } } - my $numinrow = 2; + if (@currapproval) { + foreach my $dc (@currapproval) { + unless (grep(/^\Q$dc\E$/,@domcoord)) { + push(@domcoord,$dc); + } + } + } + @domcoord = sort(@domcoord); + my $numinrow = 4; + my $numdc = @domcoord; my $css_class = 'class="LC_odd_row"'; my $text; if ($action eq 'requestcourses') { @@ -1964,12 +1930,42 @@ sub print_requestmail { $datatable = ''. ' '.$text.''. ' '; - my ($numdc,$table,$rows) = &active_dc_picker($dom,$numinrow,'checkbox', - 'reqapprovalnotify',%currapp); - if ($numdc > 0) { - $datatable .= $table; + if (@domcoord > 0) { + $datatable .= ''; + for (my $i=0; $i<$numdc; $i++) { + my $rem = $i%($numinrow); + if ($rem == 0) { + if ($i > 0) { + $datatable .= ''; + } + $datatable .= ''; + $rows ++; + } + my $check = ' '; + if (grep(/^\Q$domcoord[$i]\E$/,@currapproval)) { + $check = ' checked="checked" '; + } + my ($uname,$udom) = split(':',$domcoord[$i]); + my $fullname = &Apache::loncommon::plainname($uname,$udom); + if ($i == $numdc-1) { + my $colsleft = $numinrow-$rem; + if ($colsleft > 1) { + $datatable .= ''; + } + $datatable .= '
'; + } else { + $datatable .= ''; + } + } else { + $datatable .= ''; + } + $datatable .= '
'; } else { $datatable .= &mt('There are no active Domain Coordinators'); + $rows ++; } $datatable .=''; $$rowtotal += $rows; @@ -2124,7 +2120,8 @@ sub print_autoupdate { sub print_autocreate { my ($dom,$settings,$rowtotal) = @_; - my (%createon,%createoff,%currhash); + my (%createon,%createoff); + my $curr_dc; my @types = ('xml','req'); if (ref($settings) eq 'HASH') { foreach my $item (@types) { @@ -2137,9 +2134,7 @@ sub print_autocreate { } } } - if ($settings->{'xmldc'} ne '') { - $currhash{$settings->{'xmldc'}} = 1; - } + $curr_dc = $settings->{'xmldc'}; } else { foreach my $item (@types) { $createoff{$item} = ' checked="checked" '; @@ -2147,7 +2142,6 @@ sub print_autocreate { } } $$rowtotal += 2; - my $numinrow = 2; my $datatable=''. ''.&mt('Create pending official courses from XML files').''. ' '. ''; - my ($numdc,$dctable,$rows) = &active_dc_picker($dom,$numinrow,'radio', - 'autocreate_xmldc',%currhash); + my ($numdc,$dctable) = &active_dc_picker($dom,$curr_dc); if ($numdc > 1) { $datatable .= ''. &mt('Course creation processed as: (choose Dom. Coord.)'). ''.$dctable.''; + $$rowtotal ++ ; } else { $datatable .= $dctable.''; } - $$rowtotal += $rows; return $datatable; } @@ -2294,7 +2287,7 @@ sub print_contacts { my @contacts = ('adminemail','supportemail'); my (%checked,%to,%otheremails,%bccemails); my @mailings = ('errormail','packagesmail','lonstatusmail','helpdeskmail', - 'requestsmail','updatesmail','idconflictsmail'); + 'requestsmail'); foreach my $type (@mailings) { $otheremails{$type} = ''; } @@ -2330,22 +2323,21 @@ sub print_contacts { $checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" '; $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" '; $checked{'requestsmail'}{'adminemail'} = ' checked="checked" '; - $checked{'updatesmail'}{'adminemail'} = ' checked="checked" '; - $checked{'idconflictsmail'}{'adminemail'} = ' checked="checked" '; } my ($titles,$short_titles) = &contact_titles(); my $rownum = 0; my $css_class; foreach my $item (@contacts) { + $rownum ++; $css_class = $rownum%2?' class="LC_odd_row"':''; $datatable .= ''. ''.$titles->{$item}. ''. ''; - $rownum ++; } foreach my $type (@mailings) { + $rownum ++; $css_class = $rownum%2?' class="LC_odd_row"':''; $datatable .= ''. ''. @@ -2368,21 +2360,7 @@ sub print_contacts { 'value="'.$bccemails{$type}.'" />'; } $datatable .= ''."\n"; - $rownum ++; } - my %choices; - $choices{'reporterrors'} = &mt('E-mail error reports to [_1]', - &Apache::loncommon::modal_link('http://loncapa.org/core.html', - &mt('LON-CAPA core group - MSU'),600,500)); - $choices{'reportupdates'} = &mt('E-mail record of completed LON-CAPA updates to [_1]', - &Apache::loncommon::modal_link('http://loncapa.org/core.html', - &mt('LON-CAPA core group - MSU'),600,500)); - my @toggles = ('reporterrors','reportupdates'); - my %defaultchecked = ('reporterrors' => 'on', - 'reportupdates' => 'on'); - (my $reports,$rownum) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, - \%choices,$rownum); - $datatable .= $reports; $$rowtotal += $rownum; return $datatable; } @@ -2404,8 +2382,7 @@ sub print_helpsettings { } sub radiobutton_prefs { - my ($settings,$toggles,$defaultchecked,$choices,$itemcount,$onclick, - $additional) = @_; + my ($settings,$toggles,$defaultchecked,$choices,$itemcount) = @_; return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') && (ref($choices) eq 'HASH')); @@ -2431,22 +2408,17 @@ sub radiobutton_prefs { } } } - if ($onclick) { - $onclick = ' onclick="'.$onclick.'"'; - } foreach my $item (@{$toggles}) { $css_class = $itemcount%2?' class="LC_odd_row"':''; $datatable .= - ''. - ''.$choices->{$item}. + ''.$choices->{$item}. ''. ''. ' '. - ''.$additional. - ''. + $checkedoff{$item}.' value="0" />'.&mt('No').''. + ''. ''; $itemcount ++; } @@ -2455,100 +2427,42 @@ sub radiobutton_prefs { sub print_coursedefaults { my ($position,$dom,$settings,$rowtotal) = @_; - my ($css_class,$datatable,%checkedon,%checkedoff,%defaultchecked,@toggles); + my ($css_class,$datatable); my $itemcount = 1; - my %choices = &Apache::lonlocal::texthash ( - canuse_pdfforms => 'Course/Community users can create/upload PDF forms', - uploadquota => 'Default quota for files uploaded directly to course/community using Course Editor (MB)', - anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys', - coursecredits => 'Credits can be specified for courses', - ); - my %staticdefaults = ( - anonsurvey_threshold => 10, - uploadquota => 500, - ); if ($position eq 'top') { + my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles); + %choices = + &Apache::lonlocal::texthash ( + canuse_pdfforms => 'Course/Community users can create/upload PDF forms', + ); %defaultchecked = ('canuse_pdfforms' => 'off'); - @toggles = ('canuse_pdfforms'); + @toggles = ('canuse_pdfforms',); ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, \%choices,$itemcount); + $$rowtotal += $itemcount; } else { $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - my ($currdefresponder,$def_official_credits,$def_unofficial_credits,%curruploadquota); - my $currusecredits = 0; - my @types = ('official','unofficial','community'); + my %choices = + &Apache::lonlocal::texthash ( + anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys', + ); + my $currdefresponder; if (ref($settings) eq 'HASH') { $currdefresponder = $settings->{'anonsurvey_threshold'}; - if (ref($settings->{'uploadquota'}) eq 'HASH') { - foreach my $type (keys(%{$settings->{'uploadquota'}})) { - $curruploadquota{$type} = $settings->{'uploadquota'}{$type}; - } - } - if (ref($settings->{'coursecredits'}) eq 'HASH') { - $def_official_credits = $settings->{'coursecredits'}->{'official'}; - $def_unofficial_credits = $settings->{'coursecredits'}->{'unofficial'}; - if (($def_official_credits ne '') || ($def_unofficial_credits ne '')) { - $currusecredits = 1; - } - } } if (!$currdefresponder) { - $currdefresponder = $staticdefaults{'anonsurvey_threshold'}; + $currdefresponder = 10; } elsif ($currdefresponder < 1) { $currdefresponder = 1; } - foreach my $type (@types) { - if ($curruploadquota{$type} eq '') { - $curruploadquota{$type} = $staticdefaults{'uploadquota'}; - } - } $datatable .= - ''. - $choices{'anonsurvey_threshold'}. + ''.$choices{'anonsurvey_threshold'}. ''. ''. ''. - ''."\n". - ''. - $choices{'uploadquota'}. - ''. - ''. - ''; - foreach my $type (@types) { - $datatable .= ''; - } - $datatable .= '
'.&mt($type).'
'. - '
'."\n"; - $itemcount += 2; - my $onclick = 'toggleCredits(this.form);'; - my $display = 'none'; - if ($currusecredits) { - $display = 'block'; - } - my $additional = '
'. - ''. - &mt('Default credits for official courses [_1]', - ''). - '
'. - ''. - &mt('Default credits for unofficial courses [_1]', - ''). - '
'."\n"; - %defaultchecked = ('coursecredits' => 'off'); - @toggles = ('coursecredits'); - my $current = { - 'coursecredits' => $currusecredits, - }; - (my $table,$itemcount) = - &radiobutton_prefs($current,\@toggles,\%defaultchecked, - \%choices,$itemcount,$onclick,$additional); - $datatable .= $table; + ''; } - $$rowtotal += $itemcount; return $datatable; } @@ -2839,10 +2753,7 @@ sub spares_row { $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; $datatable .= ' - '. - &mt('[_1] when busy, offloads to:' - ,''.$server.''). - "\n"; + '.$server.' when busy, offloads to:'."\n"; my (%current,%canselect); my @choices = &possible_newspares($server,$spareid->{$server},$serverhomes,$altids); @@ -2966,206 +2877,123 @@ sub print_loadbalancing { my $numinrow = 1; my $datatable; my %servers = &Apache::lonnet::internet_dom_servers($dom); - my (%currbalancer,%currtargets,%currrules,%existing); - if (ref($settings) eq 'HASH') { - %existing = %{$settings}; - } - if ((keys(%servers) > 1) || (keys(%existing) > 0)) { - &get_loadbalancers_config(\%servers,\%existing,\%currbalancer, - \%currtargets,\%currrules); + my ($currbalancer,$currtargets,$currrules); + if (keys(%servers) > 1) { + if (ref($settings) eq 'HASH') { + $currbalancer = $settings->{'lonhost'}; + $currtargets = $settings->{'targets'}; + $currrules = $settings->{'rules'}; + } else { + ($currbalancer,$currtargets) = + &Apache::lonnet::get_lonbalancer_config(\%servers); + } } else { return; } my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); - my $rownum = 8; + my $rownum = 6; if (ref($types) eq 'ARRAY') { $rownum += scalar(@{$types}); } - my @css_class = ('LC_odd_row','LC_even_row'); - my $balnum = 0; - my $islast; - my (@toshow,$disabledtext); - if (keys(%currbalancer) > 0) { - @toshow = sort(keys(%currbalancer)); - if (scalar(@toshow) < scalar(keys(%servers)) + 1) { - push(@toshow,''); - } - } else { - @toshow = (''); - $disabledtext = &mt('No existing load balancer'); - } - foreach my $lonhost (@toshow) { - if ($balnum == scalar(@toshow)-1) { - $islast = 1; - } else { - $islast = 0; - } - my $cssidx = $balnum%2; - my $targets_div_style = 'display: none'; - my $disabled_div_style = 'display: block'; - my $homedom_div_style = 'display: none'; - $datatable .= ''. - ''. - '

'; - if ($lonhost eq '') { - $datatable .= ''; - if (keys(%currbalancer) > 0) { - $datatable .= &mt('Add balancer:'); - } else { - $datatable .= &mt('Enable balancer:'); - } - $datatable .= ' '. - ''."\n". - ' '."\n"; - } else { - $datatable .= ''.$lonhost.'
'. - ''. - ''; - $targets_div_style = 'display: block'; - $disabled_div_style = 'display: none'; - if ($dom eq &Apache::lonnet::host_domain($lonhost)) { - $homedom_div_style = 'display: block'; - } - } - $datatable .= '

'. - '
'.$disabledtext.'
'."\n". - '
'.&mt('Offloads to:').'
'; - my ($numspares,@spares) = &count_servers($lonhost,%servers); - my @sparestypes = ('primary','default'); - my %typetitles = &sparestype_titles(); - foreach my $sparetype (@sparestypes) { - my $targettable; - for (my $i=0; $i<$numspares; $i++) { - my $checked; - if (ref($currtargets{$lonhost}) eq 'HASH') { - if (ref($currtargets{$lonhost}{$sparetype}) eq 'ARRAY') { - if (grep(/^\Q$spares[$i]\E$/,@{$currtargets{$lonhost}{$sparetype}})) { - $checked = ' checked="checked"'; - } - } - } - my ($chkboxval,$disabled); - if (($lonhost ne '') && (exists($servers{$lonhost}))) { - $chkboxval = $spares[$i]; - } - if (exists($currbalancer{$spares[$i]})) { - $disabled = ' disabled="disabled"'; - } - $targettable .= - ''; - my $rem = $i%($numinrow); - if ($rem == 0) { - if (($i > 0) && ($i < $numspares-1)) { - $targettable .= ''; - } - if ($i < $numspares-1) { - $targettable .= ''; + my $css_class = ' class="LC_odd_row"'; + my $targets_div_style = 'display: none'; + my $disabled_div_style = 'display: block'; + my $homedom_div_style = 'display: none'; + $datatable = ''. + ''. + '

'. + '
'.&mt('No dedicated Load Balancer').'
'."\n". + '
'.&mt('Offloads to:').'
'; + my ($numspares,@spares) = &count_servers($currbalancer,%servers); + my @sparestypes = ('primary','default'); + my %typetitles = &sparestype_titles(); + foreach my $sparetype (@sparestypes) { + my $targettable; + for (my $i=0; $i<$numspares; $i++) { + my $checked; + if (ref($currtargets) eq 'HASH') { + if (ref($currtargets->{$sparetype}) eq 'ARRAY') { + if (grep(/^\Q$spares[$i]\E$/,@{$currtargets->{$sparetype}})) { + $checked = ' checked="checked"'; } } } - if ($targettable ne '') { - my $rem = $numspares%($numinrow); - my $colsleft = $numinrow - $rem; - if ($colsleft > 1 ) { - $targettable .= ''. - ' '; - } elsif ($colsleft == 1) { - $targettable .= ' '; - } - $datatable .= ''.$typetitles{$sparetype}.'
'. - ''.$targettable.'

'; - } - } - $datatable .= '
'. - &loadbalancing_rules($dom,$intdom,$currrules{$lonhost}, - $othertitle,$usertypes,$types,\%servers, - \%currbalancer,$lonhost, - $targets_div_style,$homedom_div_style, - $css_class[$cssidx],$balnum,$islast); - $$rowtotal += $rownum; - $balnum ++; - } - $datatable .= ''; - return $datatable; -} - -sub get_loadbalancers_config { - my ($servers,$existing,$currbalancer,$currtargets,$currrules) = @_; - return unless ((ref($servers) eq 'HASH') && - (ref($existing) eq 'HASH') && (ref($currbalancer) eq 'HASH') && - (ref($currtargets) eq 'HASH') && (ref($currrules) eq 'HASH')); - if (keys(%{$existing}) > 0) { - my $oldlonhost; - foreach my $key (sort(keys(%{$existing}))) { - if ($key eq 'lonhost') { - $oldlonhost = $existing->{'lonhost'}; - $currbalancer->{$oldlonhost} = 1; - } elsif ($key eq 'targets') { - if ($oldlonhost) { - $currtargets->{$oldlonhost} = $existing->{'targets'}; - } - } elsif ($key eq 'rules') { - if ($oldlonhost) { - $currrules->{$oldlonhost} = $existing->{'rules'}; - } - } elsif (ref($existing->{$key}) eq 'HASH') { - $currbalancer->{$key} = 1; - $currtargets->{$key} = $existing->{$key}{'targets'}; - $currrules->{$key} = $existing->{$key}{'rules'}; + my $chkboxval; + if (($currbalancer ne '') && (grep((/^\Q$currbalancer\E$/,keys(%servers))))) { + $chkboxval = $spares[$i]; + } + $targettable .= ''; + my $rem = $i%($numinrow); + if ($rem == 0) { + if ($i > 0) { + $targettable .= ''; + } + $targettable .= ''; } } - } else { - my ($balancerref,$targetsref) = - &Apache::lonnet::get_lonbalancer_config($servers); - if ((ref($balancerref) eq 'HASH') && (ref($targetsref) eq 'HASH')) { - foreach my $server (sort(keys(%{$balancerref}))) { - $currbalancer->{$server} = 1; - $currtargets->{$server} = $targetsref->{$server}; + if ($targettable ne '') { + my $rem = $numspares%($numinrow); + my $colsleft = $numinrow - $rem; + if ($colsleft > 1 ) { + $targettable .= ''. + ' '; + } elsif ($colsleft == 1) { + $targettable .= ' '; } + $datatable .= ''.$typetitles{$sparetype}.'
'. + ''.$targettable.'

'; } } - return; + $datatable .= '
'. + &loadbalancing_rules($dom,$intdom,$currrules,$othertitle, + $usertypes,$types,\%servers,$currbalancer, + $targets_div_style,$homedom_div_style,$css_class); + $$rowtotal += $rownum; + return $datatable; } sub loadbalancing_rules { my ($dom,$intdom,$currrules,$othertitle,$usertypes,$types,$servers, - $currbalancer,$lonhost,$targets_div_style,$homedom_div_style, - $css_class,$balnum,$islast) = @_; + $currbalancer,$targets_div_style,$homedom_div_style,$css_class) = @_; my $output; - my $num = 0; - my ($alltypes,$othertypes,$titles) = + my ($alltypes,$othertypes,$titles) = &loadbalancing_titles($dom,$intdom,$usertypes,$types); if ((ref($alltypes) eq 'ARRAY') && (ref($titles) eq 'HASH')) { foreach my $type (@{$alltypes}) { - $num ++; my $current; if (ref($currrules) eq 'HASH') { $current = $currrules->{$type}; } - if (($type eq '_LC_external') || ($type eq '_LC_internetdom') || ($type eq '_LC_ipchange')) { - if ($dom ne &Apache::lonnet::host_domain($lonhost)) { + if (($type eq '_LC_external') || ($type eq '_LC_internetdom')) { + if ($dom ne &Apache::lonnet::host_domain($currbalancer)) { $current = ''; } } $output .= &loadbalance_rule_row($type,$titles->{$type},$current, - $servers,$currbalancer,$lonhost,$dom, - $targets_div_style,$homedom_div_style, - $css_class,$balnum,$num,$islast); + $servers,$currbalancer,$dom, + $targets_div_style,$homedom_div_style,$css_class); } } return $output; @@ -3178,10 +3006,8 @@ sub loadbalancing_titles { '_LC_author' => &mt('Users from [_1] with author role',$dom), '_LC_internetdom' => &mt('Users not from [_1], but from [_2]',$dom,$intdom), '_LC_external' => &mt('Users not from [_1]',$intdom), - '_LC_ipchangesso' => &mt('SSO users from [_1], with IP mismatch',$dom), - '_LC_ipchange' => &mt('Non-SSO users with IP mismatch'), ); - my @alltypes = ('_LC_adv','_LC_author','_LC_internetdom','_LC_external','_LC_ipchangesso','_LC_ipchange'); + my @alltypes = ('_LC_adv','_LC_author','_LC_internetdom','_LC_external'); if (ref($types) eq 'ARRAY') { unshift(@alltypes,@{$types},'default'); } @@ -3204,34 +3030,23 @@ sub loadbalancing_titles { } sub loadbalance_rule_row { - my ($type,$title,$current,$servers,$currbalancer,$lonhost,$dom, - $targets_div_style,$homedom_div_style,$css_class,$balnum,$num,$islast) = @_; - my @rulenames; + my ($type,$title,$current,$servers,$currbalancer,$dom,$targets_div_style, + $homedom_div_style,$css_class) = @_; + my @rulenames = ('default','homeserver'); my %ruletitles = &offloadtype_text(); - if (($type eq '_LC_ipchangesso') || ($type eq '_LC_ipchange')) { - @rulenames = ('balancer','offloadedto'); + if ($type eq '_LC_external') { + push(@rulenames,'externalbalancer'); } else { - @rulenames = ('default','homeserver'); - if ($type eq '_LC_external') { - push(@rulenames,'externalbalancer'); - } else { - push(@rulenames,'specific'); - } - push(@rulenames,'none'); + push(@rulenames,'specific'); } + push(@rulenames,'none'); my $style = $targets_div_style; - if (($type eq '_LC_external') || ($type eq '_LC_internetdom') || ($type eq '_LC_ipchange')) { + if (($type eq '_LC_external') || ($type eq '_LC_internetdom')) { $style = $homedom_div_style; } - my $space; - if ($islast && $num == 1) { - $space = '
 
'; - } - my $output = - ''.$space. - '
'.$title.'
'."\n". - ''.$space. - '
'."\n"; + my $output = + '
'.$title.'
'."\n". + '
'."\n"; for (my $i=0; $i<@rulenames; $i++) { my $rule = $rulenames[$i]; my ($checked,$extra); @@ -3247,20 +3062,17 @@ sub loadbalance_rule_row { unless ($checked) { $default = ' selected="selected"'; } - $extra = - ': '."\n". + ''."\n"; + foreach my $lonhost (sort(keys(%{$servers}))) { + next if ($lonhost eq $currbalancer); my $selected; - if ($server eq $current) { + if ($lonhost eq $current) { $selected = ' selected="selected"'; } - $extra .= ''; + $extra .= ''; } $extra .= ''; } @@ -3268,9 +3080,9 @@ sub loadbalance_rule_row { $checked = ' checked="checked"'; } $output .= ''.$extra.'
'."\n"; } @@ -3285,8 +3097,6 @@ sub offloadtype_text { 'externalbalancer' => "Offloads to Load Balancer in user's domain", 'specific' => 'Offloads to specific server', 'none' => 'No offload', - 'balancer' => 'Session hosted on Load Balancer, after re-authentication', - 'offloadedto' => 'Session hosted on offload server, after re-authentication', ); return %ruletitles; } @@ -3308,8 +3118,6 @@ sub contact_titles { 'helpdeskmail' => 'Helpdesk requests to be e-mailed to', 'lonstatusmail' => 'E-mail from nightly status check (warnings/errors)', 'requestsmail' => 'E-mail from course requests requiring approval', - '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', ); my %short_titles = &Apache::lonlocal::texthash ( adminemail => 'Admin E-mail address', @@ -3352,12 +3160,12 @@ sub authorrequest_titles { automatic => 'Automatic approval', ); return %titles; -} +} sub courserequest_conditions { my %conditions = &Apache::lonlocal::texthash ( approval => '(Processing of request subject to approval by Domain Coordinator).', - validate => '(Processing of request subject to institutional validation).', + validate => '(Processing of request subject to instittutional validation).', ); return %conditions; } @@ -3591,9 +3399,9 @@ sub captcha_choice { # # Note: If reCAPTCHA is to be used for LON-CAPA servers in a domain, a domain coordinator should visit: # https://www.google.com/recaptcha and generate a Public and Private key. For domains with multiple -# servers a single key pair will be used for all servers, so the internet domain (e.g., yourcollege.edu) +# servers a single key pair will be used for all servers, so the internet domain (e.g., yourcollege.edu) # specified for use with the key should be broad enough to accommodate all servers in the LON-CAPA domain. -# +# $output .= ''."\n". ''."\n". ''.$pubtext.' '."\n". @@ -3740,18 +3548,10 @@ sub print_usermodification { } sub print_defaults { - my ($dom,$settings,$rowtotal) = @_; + my ($dom,$rowtotal) = @_; my @items = ('auth_def','auth_arg_def','lang_def','timezone_def', 'datelocale_def','portal_def'); - my %defaults; - if (ref($settings) eq 'HASH') { - %defaults = %{$settings}; - } else { - my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); - foreach my $item (@items) { - $defaults{$item} = $domdefaults{$item}; - } - } + my %domdefaults = &Apache::lonnet::get_domain_defaults($dom); my $titles = &defaults_titles($dom); my $rownum = 0; my ($datatable,$css_class); @@ -3775,7 +3575,7 @@ sub print_defaults { my %authnames = &authtype_names(); foreach my $auth (@authtypes) { my $checked = ' '; - if ($defaults{$item} eq $auth) { + if ($domdefaults{$item} eq $auth) { $checked = ' checked="checked" '; } $datatable .= '