--- loncom/interface/domainprefs.pm 2014/03/03 18:09:24 1.160.6.35 +++ loncom/interface/domainprefs.pm 2012/08/21 21:12:08 1.164 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.160.6.35 2014/03/03 18:09:24 raeburn Exp $ +# $Id: domainprefs.pm,v 1.164 2012/08/21 21:12:08 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 @@ -103,8 +102,8 @@ $datatable - HTML containing form eleme In the case of course requests, radio buttons are displayed for each institutional affiliate type (and also default, and _LC_adv) for each of the course types -(official, unofficial, community, and textbook). In each case the radio buttons -allow the selection of one of four values: +(official, unofficial and community). In each case the radio buttons allow the +selection of one of four values: 0, approval, validate, autolimit=N (where N is blank, or a positive integer). which have the following effects: @@ -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','selfcreation','usermodification','scantron', + '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 = ( @@ -241,11 +238,10 @@ sub handler { 'login' => { text => 'Log-in page options', help => 'Domain_Configuration_Login_Page', - header => [{col1 => 'Log-in Page Items', - col2 => '',}, - {col1 => 'Log-in Help', - col2 => 'Value'}], + header => [{col1 => 'Item', + col2 => '',}], }, + 'defaults' => { text => 'Default authentication/language/timezone/portal', help => 'Domain_Configuration_LangTZAuth', @@ -253,11 +249,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', @@ -273,7 +269,7 @@ sub handler { {col1 => 'Setting', col2 => 'Affiliation'}, {col1 => 'User population', - col2 => 'Updatable user data'}], + col2 => 'Updateable user data'}], }, 'autocreate' => { text => 'Auto-course creation settings', @@ -293,6 +289,7 @@ sub handler { header => [{col1 => 'Setting', col2 => 'Value',}], }, + 'usercreation' => { text => 'User creation', help => 'Domain_Configuration_User_Creation', @@ -303,23 +300,15 @@ sub handler { {col1 => 'Context', col2 => 'Assignable authentication types'}], }, - 'selfcreation' => - { text => 'Users self-creating accounts', - help => 'Domain_Configuration_Self_Creation', - header => [{col1 => 'Self-creation with institutional username', - col2 => 'Enabled?'}, - {col1 => 'Institutional user type (login/SSO self-creation)', - col2 => 'Information user can enter'}, - {col1 => 'Self-creation with e-mail as username', - col2 => 'Settings'}], - }, 'usermodification' => { text => 'User modification', help => 'Domain_Configuration_User_Modification', header => [{col1 => 'Target user has role', - col2 => 'User information updatable in author context'}, + col2 => 'User information updateable in author context'}, {col1 => 'Target user has role', - col2 => 'User information updatable in course context'}], + col2 => 'User information updateable in course context'}, + {col1 => "Status of user", + col2 => 'Information settable when self-creating account (if directory data blank)'}], }, 'scantron' => { text => 'Bubblesheet format file', @@ -334,12 +323,10 @@ sub handler { header => [{col1 => 'User affiliation', col2 => 'Availability/Processing of requests',}, {col1 => 'Setting', - col2 => 'Value'}, - {col1 => 'Available textbooks', - col2 => ''}], + col2 => 'Value'}], }, 'requestauthor' => - {text => 'Request Authoring Space', + {text => 'Request authoring space', help => 'Domain_Configuration_Request_Author', header => [{col1 => 'User affiliation', col2 => 'Availability/Processing of requests',}, @@ -363,12 +350,28 @@ sub handler { col3 => 'Specific IPs', }], }, - 'coursedefaults' => + 'helpsettings' => + {text => 'Help page settings', + help => 'Domain_Configuration_Help_Settings', + header => [{col1 => 'Authenticated Help Settings', + col2 => ''}, + {col1 => 'Unauthenticated Help Settings', + col2 => ''}], + }, + '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', @@ -380,11 +383,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'}, ], }, @@ -395,78 +398,29 @@ sub handler { header => [{col1 => 'Log-in Service', col2 => 'Server Setting',}, {col1 => 'Log-in Page Items', - col2 => ''}, - {col1 => 'Log-in Help', - col2 => 'Value'}], + col2 => ''}], }; } - 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') && (keys(%{$result}))) { - $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; + if (keys(%servers) > 1) { my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); - $js .= &lonbalance_targets_js($dom,$types,\%servers, - $domconfig{'loadbalancing'}). - &new_spares_js(). - &common_domprefs_js(). - &Apache::loncommon::javascript_array_indexof(); - } - if (grep(/^requestcourses$/,@actions)) { - my $javascript_validations; - my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'}); - $js .= < -$javascript_validations - -$coursebrowserjs -END + $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(); @@ -506,21 +460,21 @@ END } 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($r,$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') { @@ -529,28 +483,28 @@ sub process_changes { $output = &modify_directorysrch($dom,%domconfig); } elsif ($action eq 'usercreation') { $output = &modify_usercreation($dom,%domconfig); - } elsif ($action eq 'selfcreation') { - $output = &modify_selfcreation($dom,%domconfig); } 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($r,$dom,$action,$lastactref,%domconfig); + $output = &modify_quotas($dom,$action,%domconfig); } elsif ($action eq 'requestauthor') { - $output = &modify_quotas($r,$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); } @@ -579,8 +533,7 @@ sub print_config_box { if ($numheaders > 1) { my $colspan = ''; my $rightcolspan = ''; - if (($action eq 'rolecolors') || ($action eq 'coursecategories') || - (($action eq 'login') && ($numheaders < 3))) { + if (($action eq 'rolecolors') || ($action eq 'coursecategories') || ($action eq 'helpsettings')) { $colspan = ' colspan="2"'; } if ($action eq 'usersessions') { @@ -599,27 +552,25 @@ sub print_config_box { $output .= &print_autoupdate('top',$dom,$settings,\$rowtotal); } elsif ($action eq 'usercreation') { $output .= &print_usercreation('top',$dom,$settings,\$rowtotal); - } elsif ($action eq 'selfcreation') { - $output .= &print_selfcreation('top',$dom,$settings,\$rowtotal); } elsif ($action eq 'usermodification') { $output .= &print_usermodification('top',$dom,$settings,\$rowtotal); } elsif ($action eq 'coursecategories') { $output .= &print_coursecategories('top',$dom,$item,$settings,\$rowtotal); } elsif ($action eq 'login') { - if ($numheaders == 3) { - $colspan = ' colspan="2"'; - $output .= &print_login('service',$dom,$confname,$phase,$settings,\$rowtotal); - } else { - $output .= &print_login('page',$dom,$confname,$phase,$settings,\$rowtotal); - } + $output .= &print_login('top',$dom,$confname,$phase,$settings,\$rowtotal); + $colspan = ' colspan="2"'; } elsif ($action eq 'requestcourses') { $output .= &print_quotas($dom,$settings,\$rowtotal,$action); } elsif ($action eq 'requestauthor') { $output .= &print_quotas($dom,$settings,\$rowtotal,$action); + } elsif ($action eq 'helpsettings') { + $output .= &print_helpsettings('top',$dom,$confname,$settings,\$rowtotal); } elsif ($action eq 'usersessions') { $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 .= ' @@ -660,8 +611,8 @@ sub print_config_box { '.&mt($item->{'header'}->[2]->{'col2'}).' '. &print_usercreation('bottom',$dom,$settings,\$rowtotal); $rowtotal ++; - } elsif ($action eq 'selfcreation') { - $output .= &print_selfcreation('middle',$dom,$settings,\$rowtotal).' + } elsif ($action eq 'usermodification') { + $output .= &print_usermodification('middle',$dom,$settings,\$rowtotal).' @@ -670,46 +621,19 @@ sub print_config_box { - - '. - &print_selfcreation('bottom',$dom,$settings,\$rowtotal); + '. + &print_usermodification('bottom',$dom,$settings,\$rowtotal); $rowtotal ++; - } elsif ($action eq 'usermodification') { - $output .= &print_usermodification('middle',$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).' -
'.&mt($item->{'header'}->[2]->{'col1'}).''.&mt($item->{'header'}->[2]->{'col2'}).'
'.&mt($item->{'header'}->[2]->{'col2'}).'
- - - - - - - - '. - &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal); - $rowtotal ++; - } else { - $output .= &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal); - } + $output .= &print_login('bottom',$dom,$confname,$phase,$settings,\$rowtotal); } elsif ($action eq 'requestcourses') { - $output .= &print_requestmail($dom,$action,$settings,\$rowtotal). - &print_studentcode($settings,\$rowtotal).' -
'.&mt($item->{'header'}->[2]->{'col1'}).''.&mt($item->{'header'}->[2]->{'col2'}).'
- - - - - - - - '. - &print_textbookcourses($dom,$settings,\$rowtotal); + $output .= &print_requestmail($dom,$action,$settings,\$rowtotal); } elsif ($action eq 'requestauthor') { $output .= &print_requestmail($dom,$action,$settings,\$rowtotal); + } elsif ($action eq 'helpsettings') { + $output .= &print_helpsettings('bottom',$dom,$confname,$settings,\$rowtotal); } elsif ($action eq 'usersessions') { $output .= &print_usersessions('middle',$dom,$settings,\$rowtotal).'
'.&mt($item->{'header'}->[2]->{'col1'}).''.&mt($item->{'header'}->[2]->{'col2'}).'
@@ -723,6 +647,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).' @@ -799,7 +725,10 @@ sub print_config_box { } $output .= ''; $rowtotal ++; - if ($action eq 'quotas') { + if ($action eq 'login') { + $output .= &print_login('bottom',$dom,$confname,$phase,$settings, + \$rowtotal); + } elsif ($action eq 'quotas') { $output .= &print_quotas($dom,$settings,\$rowtotal,$action); } elsif ($action eq 'autoenroll') { $output .= &print_autoenroll($dom,$settings,\$rowtotal); @@ -810,17 +739,15 @@ 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') { $output .= &print_serverstatuses($dom,$settings,\$rowtotal); } elsif ($action eq 'helpsettings') { - $output .= &print_helpsettings($dom,$confname,$settings,\$rowtotal); + $output .= &print_helpsettings('top',$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 .= ' @@ -832,11 +759,11 @@ sub print_config_box { } sub print_login { - my ($caller,$dom,$confname,$phase,$settings,$rowtotal) = @_; + my ($position,$dom,$confname,$phase,$settings,$rowtotal) = @_; my ($css_class,$datatable); my %choices = &login_choices(); - if ($caller eq 'service') { + if ($position eq 'top') { my %servers = &Apache::lonnet::internet_dom_servers($dom); my $choice = $choices{'disallowlogin'}; $css_class = ' class="LC_odd_row"'; @@ -863,7 +790,7 @@ sub print_login { ''.&mt('Yes'). - ' '. - ''; - $itemcount ++; + } else { + if ($designhash{$dom.'.login.font'} ne '') { + $designs{'font'} = $designhash{$dom.'.login.font'}; + $is_custom{'font'} = 1; } - $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal,\@logintext); - $datatable .= ''; - } elsif ($caller eq 'help') { - my ($defaulturl,$defaulttype,%url,%type,%lt,%langchoices); - my $switchserver = &check_switchserver($dom,$confname); - my $itemcount = 1; - $defaulturl = '/adm/loginproblems.html'; - $defaulttype = 'default'; - %lt = &Apache::lonlocal::texthash ( - del => 'Delete?', - rep => 'Replace:', - upl => 'Upload:', - default => 'Default', - custom => 'Custom', - ); - %langchoices = &Apache::lonlocal::texthash(&get_languages_hash()); - my @currlangs; - if (ref($settings) eq 'HASH') { - if (ref($settings->{'helpurl'}) eq 'HASH') { - foreach my $key (sort(keys(%{$settings->{'helpurl'}}))) { - next if ($settings->{'helpurl'}{$key} eq ''); - $url{$key} = $settings->{'helpurl'}{$key}.'?inhibitmenu=yes'; - $type{$key} = 'custom'; - unless ($key eq 'nolang') { - push(@currlangs,$key); - } - } - } elsif ($settings->{'helpurl'} ne '') { - $type{'nolang'} = 'custom'; - $url{'nolang'} = $settings->{'helpurl'}.'?inhibitmenu=yes'; + foreach my $item (@images) { + if ($designhash{$dom.'.login.'.$item} ne '') { + $designs{$item} = $designhash{$dom.'.login.'.$item}; + $is_custom{$item} = 1; } } - foreach my $lang ('nolang',sort(@currlangs)) { - $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable .= ''; - if ($url{$lang} eq '') { - $url{$lang} = $defaulturl; - } - if ($type{$lang} eq '') { - $type{$lang} = $defaulttype; - } - $datatable .= ''; - if ($lang eq 'nolang') { - $datatable .= &mt('Log-in help page if no specific language file: [_1]', - &Apache::loncommon::modal_link($url{$lang},$lt{$type{$lang}},600,500)); - } else { - $datatable .= &mt('Log-in help page for language: [_1] is [_2]', - $langchoices{$lang}, - &Apache::loncommon::modal_link($url{$lang},$lt{$type{$lang}},600,500)); - } - $datatable .= ''."\n". - ''; - if ($type{$lang} eq 'custom') { - $datatable .= ' '.$lt{'rep'}.''; - } else { - $datatable .= $lt{'upl'}; - } - $datatable .='
'; - if ($switchserver) { - $datatable .= &mt('Upload to library server: [_1]',$switchserver); - } else { - $datatable .= ''; + foreach my $item (@bgs) { + if ($designhash{$dom.'.login.'.$item} ne '') { + $designs{'bgs'}{$item} = $designhash{$dom.'.login.'.$item}; + $is_custom{$item} = 1; } - $datatable .= ''; - $itemcount ++; } - my @addlangs; - foreach my $lang (sort(keys(%langchoices))) { - next if ((grep(/^\Q$lang\E$/,@currlangs)) || ($lang eq 'x_chef')); - push(@addlangs,$lang); - } - if (@addlangs > 0) { - my %toadd; - map { $toadd{$_} = $langchoices{$_} ; } @addlangs; - $toadd{''} = &mt('Select'); - $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable .= ''. - &mt('Add log-in help page for a specific language:').' '. - &Apache::loncommon::select_form('','loginhelpurl_add_lang',\%toadd). - ''.$lt{'upl'}.'
'; - if ($switchserver) { - $datatable .= &mt('Upload to library server: [_1]',$switchserver); - } else { - $datatable .= ''; + foreach my $item (@links) { + if ($designhash{$dom.'.login.'.$item} ne '') { + $designs{'links'}{$item} = $designhash{$dom.'.login.'.$item}; + $is_custom{$item} = 1; } - $datatable .= ''; - $itemcount ++; } - $datatable .= &captcha_choice('login',$settings,$itemcount); } + my %alt_text = &Apache::lonlocal::texthash ( img => 'Log-in banner', + logo => 'Institution Logo', + domlogo => 'Domain Logo', + login => 'Login box'); + my $itemcount = 1; + foreach my $item (@toggles) { + $css_class = $itemcount%2?' class="LC_odd_row"':''; + $datatable .= + ''.$choices{$item}. + ''. + ' '. + ''; + $itemcount ++; + } + $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal,\@logintext); + $datatable .= ''; return $datatable; } @@ -1126,7 +963,6 @@ sub login_choices { &Apache::lonlocal::texthash ( coursecatalog => 'Display Course/Community Catalog link?', adminmail => "Display Administrator's E-mail Address?", - helpdesk => 'Display "Contact Helpdesk" link', disallowlogin => "Login page requests redirected", hostid => "Server", server => "Redirect to:", @@ -1164,7 +1000,17 @@ sub print_rolecolors { my %designhash = &Apache::loncommon::get_domainconf($dom); my %defaultdesign = %Apache::loncommon::defaultdesign; my (%is_custom,%designs); - my %defaults = &role_defaults($role,\@bgs,\@links,\@images); + my %defaults = ( + img => $defaultdesign{$role.'.img'}, + font => $defaultdesign{$role.'.font'}, + fontmenu => $defaultdesign{$role.'.fontmenu'}, + ); + foreach my $item (@bgs) { + $defaults{'bgs'}{$item} = $defaultdesign{$role.'.'.$item}; + } + foreach my $item (@links) { + $defaults{'links'}{$item} = $defaultdesign{$role.'.'.$item}; + } if (ref($settings) eq 'HASH') { if (ref($settings->{$role}) eq 'HASH') { if ($settings->{$role}->{'img'} ne '') { @@ -1225,44 +1071,6 @@ sub print_rolecolors { return $datatable; } -sub role_defaults { - my ($role,$bgs,$links,$images,$logintext) = @_; - my %defaults; - unless ((ref($bgs) eq 'ARRAY') && (ref($links) eq 'ARRAY') && (ref($images) eq 'ARRAY')) { - return %defaults; - } - my %defaultdesign = %Apache::loncommon::defaultdesign; - if ($role eq 'login') { - %defaults = ( - font => $defaultdesign{$role.'.font'}, - ); - if (ref($logintext) eq 'ARRAY') { - foreach my $item (@{$logintext}) { - $defaults{'logintext'}{$item} = $defaultdesign{$role.'.'.$item}; - } - } - foreach my $item (@{$images}) { - $defaults{'showlogo'}{$item} = 1; - } - } else { - %defaults = ( - img => $defaultdesign{$role.'.img'}, - font => $defaultdesign{$role.'.font'}, - fontmenu => $defaultdesign{$role.'.fontmenu'}, - ); - } - foreach my $item (@{$bgs}) { - $defaults{'bgs'}{$item} = $defaultdesign{$role.'.'.$item}; - } - foreach my $item (@{$links}) { - $defaults{'links'}{$item} = $defaultdesign{$role.'.'.$item}; - } - foreach my $item (@{$images}) { - $defaults{$item} = $defaultdesign{$role.'.'.$item}; - } - return %defaults; -} - sub display_color_options { my ($dom,$confname,$phase,$role,$itemcount,$choices,$is_custom,$defaults,$designs, $images,$bgs,$links,$alt_text,$rowtotal,$logintext) = @_; @@ -1275,12 +1083,13 @@ sub display_color_options { } else { $datatable .= ' '; } - my $current_color = $designs->{'font'} ? $designs->{'font'} : $defaults->{'font'}; - + my $fontlink = &color_pick($phase,$role,'font',$choices->{'font'},$designs->{'font'}); $datatable .= ''. - ' '. - ' '; + ' '.$fontlink. + '    '. + ''; unless ($role eq 'login') { $datatable .= ''. ''.$choices->{'fontmenu'}.''; @@ -1289,13 +1098,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}) { @@ -1310,7 +1119,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); } @@ -1389,12 +1198,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); @@ -1422,14 +1231,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 .= '
'; @@ -1451,12 +1259,13 @@ sub display_color_options { $datatable .= ''. ''; foreach my $item (@{$links}) { - my $color = $designs->{'link'}{$item} ? $designs->{'link'}{$item} : $defaults->{'links'}{$item}; - $datatable .= ''; } $$rowtotal += $itemcount; @@ -1510,13 +1319,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; @@ -1548,12 +1361,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; @@ -1562,37 +1383,34 @@ 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); if ($context eq 'requestcourses') { - @usertools = ('official','unofficial','community','textbook'); + @usertools = ('official','unofficial','community'); @options =('norequest','approval','validate','autolimit'); %validations = &Apache::lonnet::auto_courserequest_checks($dom); %titles = &courserequest_titles(); } 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})) { @@ -1706,15 +1524,10 @@ sub print_quotas { unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) { $datatable .= - ''. - ''.&mt('Portfolio').': '. + ''. ''.(' ' x 2). - ''.&mt('Authoring').': '. - ''; + '" size="5" /> Mb'; } $datatable .= ''; } @@ -1722,16 +1535,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 ++; @@ -1797,7 +1606,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'; @@ -1842,19 +1653,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)'). ''. @@ -1946,8 +1753,8 @@ sub print_quotas { $checked = ' checked="checked"'; } $datatable .= '  '; } } else { @@ -1981,249 +1788,85 @@ 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; - my $css_class; - $css_class = ($$rowtotal%2? ' class="LC_odd_row"':''); + 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') { $text = &mt('Receive notification of course requests requiring approval'); - } elsif ($action eq 'requestauthor') { - $text = &mt('Receive notification of Authoring Space requests requiring approval'); } else { - $text = &mt('Receive notification of queued requests for self-created user accounts requiring approval'); + $text = &mt('Receive notification of authoring space requests requiring approval') } - $datatable = ''. + $datatable = ''. ' '.$text.''. ' '; - my ($numdc,$table,$rows) = &active_dc_picker($dom,$numinrow,'checkbox', - $action.'notifyapproval',%currapp); - if ($numdc > 0) { - $datatable .= $table; - } else { - $datatable .= &mt('There are no active Domain Coordinators'); - } - $datatable .=''; - $$rowtotal += $rows; - return $datatable; -} - -sub print_studentcode { - my ($settings,$rowtotal) = @_; - my $rownum = 0; - my ($output,%current); - my @crstypes = ('official','unofficial','community','textbook'); - if (ref($settings->{'uniquecode'}) eq 'HASH') { - foreach my $type (@crstypes) { - $current{$type} = $settings->{'uniquecode'}{$type}; - } - } - $output .= ''. - ''.&mt('Generate unique six character code as course identifier?').''. - ''; - foreach my $type (@crstypes) { - my $check = ' '; - if ($current{$type}) { - $check = ' checked="checked" '; - } - $output .= ''.(' 'x2).' '; - } - $output .= ''; - $$rowtotal ++; - return $output; -} - -sub print_textbookcourses { - my ($dom,$settings,$rowtotal) = @_; - my $rownum = 0; - my $css_class; - my $itemcount = 1; - my $maxnum = 0; - my $bookshash; - if (ref($settings) eq 'HASH') { - $bookshash = $settings->{'textbooks'}; - } - my %ordered; - if (ref($bookshash) eq 'HASH') { - foreach my $item (keys(%{$bookshash})) { - if (ref($bookshash->{$item}) eq 'HASH') { - my $num = $bookshash->{$item}{'order'}; - $ordered{$num} = $item; + 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 $confname = $dom.'-domainconfig'; - my $switchserver = &check_switchserver($dom,$confname); - my $maxnum = scalar(keys(%ordered)); - my $datatable = &textbookcourses_javascript(\%ordered); - if (keys(%ordered)) { - my @items = sort { $a <=> $b } keys(%ordered); - for (my $i=0; $i<@items; $i++) { - $css_class = $itemcount%2?' class="LC_odd_row"':''; - my $key = $ordered{$items[$i]}; - my %coursehash=&Apache::lonnet::coursedescription($key); - my $coursetitle = $coursehash{'description'}; - my ($subject,$title,$author,$image,$imgsrc,$cdom,$cnum); - if (ref($bookshash->{$key}) eq 'HASH') { - $subject = $bookshash->{$key}->{'subject'}; - $title = $bookshash->{$key}->{'title'}; - $author = $bookshash->{$key}->{'author'}; - $image = $bookshash->{$key}->{'image'}; - if ($image ne '') { - my ($path,$imagefile) = ($image =~ m{^(.+)/([^/]+)$}); - my $imagethumb = "$path/tn-".$imagefile; - $imgsrc = ''.&mt('Textbook image').''; - } - } - my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$key'".');"'; - $datatable .= ''. - ''."\n"; - $itemcount ++; - } - } - $css_class = $itemcount%2?' class="LC_odd_row"':''; - my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'addbook_pos'".');"'; - $datatable .= ''."\n". - ''."\n". - ''."\n"; - $itemcount ++; - return $datatable; -} - -sub textbookcourses_javascript { - my ($textbooks) = @_; - return unless(ref($textbooks) eq 'HASH'); - my $num = scalar(keys(%{$textbooks})); - my @jsarray; - foreach my $item (sort {$a <=> $b } (keys(%{$textbooks}))) { - push(@jsarray,$textbooks->{$item}); - } - my $jstext = ' var textbooks = Array('."'".join("','",@jsarray)."'".');'."\n"; - return <<"ENDSCRIPT"; - - -ENDSCRIPT + $datatable .=''; + $$rowtotal += $rows; + return $datatable; } sub print_autoenroll { @@ -2374,7 +2017,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) { @@ -2387,9 +2031,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" '; @@ -2397,7 +2039,6 @@ sub print_autocreate { } } $$rowtotal += 2; - my $numinrow = 2; my $datatable=''. ''. ''; + $$rowtotal ++ ; } else { $datatable .= $dctable.''; } - $$rowtotal += $rows; return $datatable; } @@ -2544,7 +2184,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} = ''; } @@ -2580,22 +2220,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 .= ''. ''; - $rownum ++; } foreach my $type (@mailings) { + $rownum ++; $css_class = $rownum%2?' class="LC_odd_row"':''; $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; } sub print_helpsettings { - my ($dom,$confname,$settings,$rowtotal) = @_; - my ($datatable,$itemcount); - $itemcount = 1; - my (%choices,%defaultchecked,@toggles); - $choices{'submitbugs'} = &mt('Display link to: [_1]?', - &Apache::loncommon::modal_link('http://bugs.loncapa.org', - &mt('LON-CAPA bug tracker'),600,500)); - %defaultchecked = ('submitbugs' => 'on'); - @toggles = ('submitbugs',); - ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, - \%choices,$itemcount); - return $datatable; + my ($position,$dom,$confname,$settings,$rowtotal) = @_; + my ($css_class,$datatable); + + my $switchserver = &check_switchserver($dom,$confname); + + my $itemcount = 1; + + if ($position eq 'top') { + + 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') { + $checkedon{$item} = ' checked="checked" '; + $checkedoff{$item} = ' '; + } elsif ($defaultchecked{$item} eq 'off') { + $checkedoff{$item} = ' checked="checked" '; + $checkedon{$item} = ' '; + } + } + + if (ref($settings) eq 'HASH') { + foreach my $item (@toggles) { + if ($settings->{$item} eq '1') { + $checkedon{$item} = ' checked="checked" '; + $checkedoff{$item} = ' '; + } elsif ($settings->{$item} eq '0') { + $checkedoff{$item} = ' checked="checked" '; + $checkedon{$item} = ' '; + } + } + } + + foreach my $item (@toggles) { + $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; + $datatable .= + ' + + + '. + ''; + $itemcount ++; + } + + } else { + + $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; + + $datatable .= ''; + + if (ref($settings) eq 'HASH') { + if ($settings->{'loginhelpurl'} ne '') { + my($directory, $filename) = $settings->{'loginhelpurl'} =~ m/(.*\/)(.*)$/; + $datatable .= ''; + $datatable .= '' + } else { + $datatable .= ''; + $datatable .= ''; + } + } else { + $datatable .= ''; + $datatable .= ''; + } + + $datatable .= ''; + + } + + return $datatable; + } + 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')); @@ -2681,22 +2383,17 @@ sub radiobutton_prefs { } } } - if ($onclick) { - $onclick = ' onclick="'.$onclick.'"'; - } foreach my $item (@{$toggles}) { $css_class = $itemcount%2?' class="LC_odd_row"':''; $datatable .= - ''. ''. + $checkedoff{$item}.' value="0" />'.&mt('No').''. + ''. ''; $itemcount ++; } @@ -2705,108 +2402,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,$def_textbook_credits, - %curruploadquota); - my $currusecredits = 0; - my @types = ('official','unofficial','community','textbook'); + 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'}; - $def_textbook_credits = $settings->{'coursecredits'}->{'textbook'}; - if (($def_official_credits ne '') || ($def_unofficial_credits ne '') || - ($def_textbook_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 .= - ''. ''."\n". - ''. - ''."\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]', - ''). - '
'. - ''. - &mt('Default credits for textbook 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; } @@ -3097,10 +2728,7 @@ sub spares_row { $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; $datatable .= ' '."\n"; my (%current,%canselect); my @choices = &possible_newspares($server,$spareid->{$server},$serverhomes,$altids); @@ -3224,206 +2852,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 .= ''. - ''; - 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 = ''. + ''; - } elsif ($colsleft == 1) { - $targettable .= ''; - } - $datatable .= ''.$typetitles{$sparetype}.'
'. - '
' - .''.(' 'x2). - ''. - ''.&mt('Subject:').' '. - (' 'x2). - ''.&mt('Title:').' '. - (' 'x2). - ''.&mt('Author(s):').' '. - (' 'x2). - ''.&mt('Thumbnail:'); - if ($image) { - $datatable .= ''. - $imgsrc. - ' '. - ' '.&mt('Replace:').' '; + my $check = ' '; + if (grep(/^\Q$domcoord[$i]\E$/,@currapproval)) { + $check = ' checked="checked" '; } - if ($switchserver) { - $datatable .= &mt('Upload to library server: [_1]',$switchserver); + 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 .= ''; + } else { + $datatable .= ''; + } } else { - $datatable .= ''; + $datatable .= ''; } - $datatable .= ' '. - ''.&mt('LON-CAPA course:').' '. - $coursetitle.'
'."\n". - ''."\n". - ' '."\n". - ''.&mt('Add').''. - ''.&mt('Subject:').' '."\n". - (' 'x2). - ''.&mt('Title:').' '."\n". - (' 'x2). - ''.&mt('Author(s):').' '."\n". - (' 'x2). - ''.&mt('Image:').' '; - if ($switchserver) { - $datatable .= &mt('Upload to library server: [_1]',$switchserver); - } else { - $datatable .= ''; - } - $datatable .= ''."\n". - ''.&mt('LON-CAPA course:').' '. - &Apache::loncommon::select_dom_form($env{'request.role.domain'},'addbook_cdom'). - ''. - &Apache::loncommon::selectcourse_link - ('display','addbook_cnum','addbook_cdom',undef,undef,undef,'Course'); - '
'.&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.'
'.$titles->{$item}. ''. '
'. @@ -2618,44 +2257,107 @@ sub print_contacts { 'value="'.$bccemails{$type}.'" />'; } $datatable .= '
'.$choices{$item}.'  +   + '. + '
   '; + if ($switchserver) { + $datatable .= &mt('Upload to library server: [_1]',$switchserver); + } else { + $datatable .= &mt('Upload Custom Login Page Help File:'); + $datatable .=''; + } + $datatable .= '
'. - ''.$choices->{$item}. + ''.$choices->{$item}. ''. ' '. - ''.$additional. - '
'. - $choices{'anonsurvey_threshold'}. + ''.$choices{'anonsurvey_threshold'}. ''. ''. - '
'. - $choices{'uploadquota'}. - ''. - ''; - foreach my $type (@types) { - $datatable .= ''; - } - $datatable .= '
'.&mt($type).'
'. - '
- '. - &mt('[_1] when busy, offloads to:' - ,''.$server.''). - "\n"; + '.$server.' when busy, offloads to:
'. - '

'; - 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 .= - '
'. + '

'. + '
'.&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 .= '
'. - '  
'.$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; @@ -3436,10 +2981,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'); } @@ -3462,34 +3005,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); @@ -3505,20 +3037,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 .= ''; } @@ -3526,9 +3055,9 @@ sub loadbalance_rule_row { $checked = ' checked="checked"'; } $output .= ''.$extra.'
'."\n"; } @@ -3543,8 +3072,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; } @@ -3566,8 +3093,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', @@ -3585,7 +3110,6 @@ sub tool_titles { official => 'Official courses (with institutional codes)', unofficial => 'Unofficial courses', community => 'Communities', - textbook => 'Textbook courses', ); return %titles; } @@ -3595,7 +3119,6 @@ sub courserequest_titles { official => 'Official', unofficial => 'Unofficial', community => 'Communities', - textbook => 'Textbook', norequest => 'Not allowed', approval => 'Approval by Dom. Coord.', validate => 'With validation', @@ -3612,12 +3135,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; } @@ -3648,22 +3171,42 @@ sub print_usercreation { $rowcount ++; } } + my ($emailrules,$emailruleorder) = + &Apache::lonnet::inst_userrules($dom,'email'); + if (ref($emailrules) eq 'HASH') { + if (keys(%{$emailrules}) > 0) { + $datatable .= &user_formats_row('email',$settings,$emailrules, + $emailruleorder,$numinrow,$rowcount); + $$rowtotal ++; + $rowcount ++; + } + } if ($rowcount == 0) { $datatable .= ''.&mt('No format rules have been defined for usernames or IDs in this domain.').''; $$rowtotal ++; $rowcount ++; } } elsif ($position eq 'middle') { - my @creators = ('author','course','requestcrs'); + my @creators = ('author','course','requestcrs','selfcreate'); my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom,'username'); my %lt = &usercreation_types(); my %checked; + my @selfcreate; if (ref($settings) eq 'HASH') { if (ref($settings->{'cancreate'}) eq 'HASH') { foreach my $item (@creators) { $checked{$item} = $settings->{'cancreate'}{$item}; } + if (ref($settings->{'cancreate'}{'selfcreate'}) eq 'ARRAY') { + @selfcreate = @{$settings->{'cancreate'}{'selfcreate'}}; + } elsif ($settings->{'cancreate'}{'selfcreate'} ne '') { + if ($settings->{'cancreate'}{'selfcreate'} eq 'any') { + @selfcreate = ('email','login','sso'); + } elsif ($settings->{'cancreate'}{'selfcreate'} ne 'none') { + @selfcreate = ($settings->{'cancreate'}{'selfcreate'}); + } + } } elsif (ref($settings->{'cancreate'}) eq 'ARRAY') { foreach my $item (@creators) { if (grep(/^\Q$item\E$/,@{$settings->{'cancreate'}})) { @@ -3675,8 +3218,10 @@ sub print_usercreation { my $rownum = 0; foreach my $item (@creators) { $rownum ++; - if ($checked{$item} eq '') { - $checked{$item} = 'any'; + if ($item ne 'selfcreate') { + if ($checked{$item} eq '') { + $checked{$item} = 'any'; + } } my $css_class; if ($rownum%2) { @@ -3687,18 +3232,30 @@ sub print_usercreation { $datatable .= ''. ''.$lt{$item}. ''; - my @options = ('any'); - if (ref($rules) eq 'HASH') { - if (keys(%{$rules}) > 0) { - push(@options,('official','unofficial')); + my @options; + if ($item eq 'selfcreate') { + push(@options,('email','login','sso')); + } else { + @options = ('any'); + if (ref($rules) eq 'HASH') { + if (keys(%{$rules}) > 0) { + push(@options,('official','unofficial')); + } } + push(@options,'none'); } - push(@options,'none'); foreach my $option (@options) { my $type = 'radio'; my $check = ' '; - if ($checked{$item} eq $option) { - $check = ' checked="checked" '; + if ($item eq 'selfcreate') { + $type = 'checkbox'; + if (grep(/^\Q$option\E$/,@selfcreate)) { + $check = ' checked="checked" '; + } + } else { + if ($checked{$item} eq $option) { + $check = ' checked="checked" '; + } } $datatable .= ''; + $datatable .= ''; if ($parent eq 'instcode' || $parent eq 'communities') { $datatable .= '' .$default_names{$parent}.''; @@ -4492,8 +3864,7 @@ sub print_coursecategories { $datatable .= ''; } else { $datatable .= $parent - .' '; } my $depth = 1; @@ -4607,9 +3978,8 @@ sub print_serverstatuses { sub serverstatus_pages { return ('userstatus','lonstatus','loncron','server-status','codeversions', - 'checksums','clusterstatus','metadata_keywords','metadata_harvest', - 'takeoffline','takeonline','showenv','toggledebug','ping','domconf', - 'uniquecodes'); + 'clusterstatus','metadata_keywords','metadata_harvest', + 'takeoffline','takeonline','showenv','toggledebug','ping','domconf'); } sub coursecategories_javascript { @@ -4766,7 +4136,7 @@ sub build_category_rows { if (ref($cats->[$depth]{$parent}) eq 'ARRAY') { my $numchildren = @{$cats->[$depth]{$parent}}; my $css_class = $itemcount%2?' class="LC_odd_row"':''; - $text .= ''; + $text .= '
'; my ($idxnum,$parent_name,$parent_item); my $higher = $depth - 1; if ($higher == 0) { @@ -4840,22 +4210,9 @@ sub build_category_rows { } sub modifiable_userdata_row { - my ($context,$item,$settings,$numinrow,$rowcount,$usertypes,$fieldsref,$titlesref) = @_; - my ($role,$rolename,$statustype); - $role = $item; - if ($context eq 'cancreate') { - if ($item =~ /^emailusername_(.+)$/) { - $statustype = $1; - $role = 'emailusername'; - if (ref($usertypes) eq 'HASH') { - if ($usertypes->{$statustype}) { - $rolename = &mt('Data provided by [_1]',$usertypes->{$statustype}); - } else { - $rolename = &mt('Data provided by user'); - } - } - } - } elsif ($context eq 'selfcreate') { + my ($context,$role,$settings,$numinrow,$rowcount,$usertypes) = @_; + my $rolename; + if ($context eq 'selfcreate') { if (ref($usertypes) eq 'HASH') { $rolename = $usertypes->{$role}; } else { @@ -4868,18 +4225,9 @@ sub modifiable_userdata_row { $rolename = &Apache::lonnet::plaintext($role); } } - my (@fields,%fieldtitles); - if (ref($fieldsref) eq 'ARRAY') { - @fields = @{$fieldsref}; - } else { - @fields = ('lastname','firstname','middlename','generation', - 'permanentemail','id'); - } - if ((ref($titlesref) eq 'HASH')) { - %fieldtitles = %{$titlesref}; - } else { - %fieldtitles = &Apache::loncommon::personal_data_fieldtitles(); - } + my @fields = ('lastname','firstname','middlename','generation', + 'permanentemail','id'); + my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles(); my $output; my $css_class = $rowcount%2?' class="LC_odd_row"':''; $output = ''. @@ -4890,33 +4238,14 @@ sub modifiable_userdata_row { if (ref($settings) eq 'HASH') { if (ref($settings->{$context}) eq 'HASH') { if (ref($settings->{$context}->{$role}) eq 'HASH') { - my $hashref = $settings->{$context}->{$role}; - if ($role eq 'emailusername') { - if ($statustype) { - if (ref($settings->{$context}->{$role}->{$statustype}) eq 'HASH') { - $hashref = $settings->{$context}->{$role}->{$statustype}; - if (ref($hashref) eq 'HASH') { - foreach my $field (@fields) { - if ($hashref->{$field}) { - $checks{$field} = $hashref->{$field}; - } - } - } - } - } - } else { - if (ref($hashref) eq 'HASH') { - foreach my $field (@fields) { - if ($hashref->{$field}) { - $checks{$field} = ' checked="checked" '; - } - } + foreach my $field (@fields) { + if ($settings->{$context}->{$role}->{$field}) { + $checks{$field} = ' checked="checked" '; } } } } } - for (my $i=0; $i<@fields; $i++) { my $rem = $i%($numinrow); if ($rem == 0) { @@ -4926,40 +4255,20 @@ sub modifiable_userdata_row { $output .= ''; } my $check = ' '; - unless ($role eq 'emailusername') { - if (exists($checks{$fields[$i]})) { - $check = $checks{$fields[$i]} - } else { - if ($role eq 'st') { - if (ref($settings) ne 'HASH') { - $check = ' checked="checked" '; - } + if (exists($checks{$fields[$i]})) { + $check = $checks{$fields[$i]} + } else { + if ($role eq 'st') { + if (ref($settings) ne 'HASH') { + $check = ' checked="checked" '; } } } $output .= ''; + ''; $rem = @fields%($numinrow); } my $colsleft = $numinrow - $rem; @@ -4974,7 +4283,7 @@ sub modifiable_userdata_row { } sub insttypes_row { - my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle,$context,$rownum) = @_; + my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle,$context) = @_; my %lt = &Apache::lonlocal::texthash ( cansearch => 'Users allowed to search', statustocreate => 'Institutional affiliation(s) able to create own account (login/SSO)', @@ -4984,17 +4293,9 @@ sub insttypes_row { if ($context eq 'cansearch') { $showdom = ' ('.$dom.')'; } - my $class = 'LC_left_item'; - if ($context eq 'statustocreate') { - $class = 'LC_right_item'; - } - my $css_class = ' class="LC_odd_row"'; - if ($rownum ne '') { - $css_class = ($rownum%2? ' class="LC_odd_row"':''); - } - my $output = ''. - '
'. - ''; - if ($role eq 'emailusername') { - unless ($checks{$fields[$i]} =~ /^(required|optional)$/) { - $checks{$fields[$i]} = 'omit'; - } - foreach my $option ('required','optional','omit') { - my $checked=''; - if ($checks{$fields[$i]} eq $option) { - $checked='checked="checked" '; - } - $output .= ''.(' ' x2); - } - $output .= ''.$fieldtitles{$fields[$i]}.''; - } else { - $output .= ''; - } - $output .= ''.$lt{$context}.$showdom. - ''; + my $output = ''. + ''; } + $datatable .= '
'.$lt{$context}.$showdom. + ''; my $rem; if (ref($types) eq 'ARRAY') { for (my $i=0; $i<@{$types}; $i++) { @@ -5123,15 +4424,14 @@ sub usertype_update_row { } sub modify_login { - my ($r,$dom,$confname,$lastactref,%domconfig) = @_; - my ($resulttext,$errors,$colchgtext,%changes,%colchanges,%newfile,%newurl, - %curr_loginvia,%loginhash,@currlangs,@newlangs,$addedfile,%title,@offon); - %title = ( coursecatalog => 'Display course catalog', - adminmail => 'Display administrator E-mail address', - helpdesk => 'Display "Contact Helpdesk" link', - newuser => 'Link for visitors to create a user account', - loginheader => 'Log-in box header'); - @offon = ('off','on'); + my ($r,$dom,$confname,%domconfig) = @_; + my ($resulttext,$errors,$colchgtext,%changes,%colchanges); + my %title = ( coursecatalog => 'Display course catalog', + adminmail => 'Display administrator E-mail address', + newuser => 'Link for visitors to create a user account', + loginheader => 'Log-in box header'); + my @offon = ('off','on'); + my %curr_loginvia; if (ref($domconfig{login}) eq 'HASH') { if (ref($domconfig{login}{loginvia}) eq 'HASH') { foreach my $lonhost (keys(%{$domconfig{login}{loginvia}})) { @@ -5139,9 +4439,10 @@ sub modify_login { } } } + my %loginhash; ($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'], \%domconfig,\%loginhash); - my @toggles = ('coursecatalog','adminmail','helpdesk','newuser'); + my @toggles = ('coursecatalog','adminmail','newuser'); foreach my $item (@toggles) { $loginhash{login}{$item} = $env{'form.'.$item}; } @@ -5211,6 +4512,7 @@ sub modify_login { $new = ''; } } + $loginhash{login}{loginvia}{$lonhost}{$item} = $new; } } @@ -5236,103 +4538,12 @@ sub modify_login { } } - my $servadm = $r->dir_config('lonAdmEMail'); - my %langchoices = &Apache::lonlocal::texthash(&get_languages_hash()); - if (ref($domconfig{'login'}) eq 'HASH') { - if (ref($domconfig{'login'}{'helpurl'}) eq 'HASH') { - foreach my $lang (sort(keys(%{$domconfig{'login'}{'helpurl'}}))) { - if ($lang eq 'nolang') { - push(@currlangs,$lang); - } elsif (defined($langchoices{$lang})) { - push(@currlangs,$lang); - } else { - next; - } - } - } - } - my @delurls = &Apache::loncommon::get_env_multiple('form.loginhelpurl_del'); - if (@currlangs > 0) { - foreach my $lang (@currlangs) { - if (grep(/^\Q$lang\E$/,@delurls)) { - $changes{'helpurl'}{$lang} = 1; - } elsif ($env{'form.loginhelpurl_'.$lang.'.filename'}) { - $changes{'helpurl'}{$lang} = 1; - $newfile{$lang} = $env{'form.loginhelpurl_'.$lang.'.filename'}; - push(@newlangs,$lang); - } else { - $loginhash{'login'}{'helpurl'}{$lang} = $domconfig{'login'}{'helpurl'}{$lang}; - } - } - } - unless (grep(/^nolang$/,@currlangs)) { - if ($env{'form.loginhelpurl_nolang.filename'}) { - $changes{'helpurl'}{'nolang'} = 1; - $newfile{'nolang'} = $env{'form.loginhelpurl_nolang.filename'}; - push(@newlangs,'nolang'); - } - } - if ($env{'form.loginhelpurl_add_lang'}) { - if ((defined($langchoices{$env{'form.loginhelpurl_add_lang'}})) && - ($env{'form.loginhelpurl_add_file.filename'})) { - $newfile{$env{'form.loginhelpurl_add_lang'}} = $env{'form.loginhelpurl_add_file.filename'}; - $addedfile = $env{'form.loginhelpurl_add_lang'}; - } - } - if ((@newlangs > 0) || ($addedfile)) { - my $error; - my ($configuserok,$author_ok,$switchserver) = &config_check($dom,$confname,$servadm); - if ($configuserok eq 'ok') { - if ($switchserver) { - $error = &mt("Upload of custom help file is not permitted to this server: [_1]",$switchserver); - } elsif ($author_ok eq 'ok') { - my @allnew = @newlangs; - if ($addedfile ne '') { - push(@allnew,$addedfile); - } - foreach my $lang (@allnew) { - my $formelem = 'loginhelpurl_'.$lang; - if ($lang eq $env{'form.loginhelpurl_add_lang'}) { - $formelem = 'loginhelpurl_add_file'; - } - (my $result,$newurl{$lang}) = &publishlogo($r,'upload',$formelem,$dom,$confname, - "help/$lang",'','',$newfile{$lang}); - if ($result eq 'ok') { - $loginhash{'login'}{'helpurl'}{$lang} = $newurl{$lang}; - $changes{'helpurl'}{$lang} = 1; - } else { - my $puberror = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$newfile{$lang},$result); - $errors .= '
  • '.$puberror.'
  • '; - if ((grep(/^\Q$lang\E$/,@currlangs)) && - (!grep(/^\Q$lang\E$/,@delurls))) { - - $loginhash{'login'}{'helpurl'}{$lang} = $domconfig{'login'}{'helpurl'}{$lang}; - } - } - } - } else { - $error = &mt("Upload of custom log-in help file(s) failed because an author role could not be assigned to a Domain Configuration user ([_1]) in domain: [_2]. Error was: [_3].",$confname,$dom,$author_ok); - } - } else { - $error = &mt("Upload of custom log-in help file(s) failed because a Domain Configuration user ([_1]) could not be created in domain: [_2]. Error was: [_3].",$confname,$dom,$configuserok); - } - if ($error) { - &Apache::lonnet::logthis($error); - $errors .= '
  • '.$error.'
  • '; - } - } - &process_captcha('login',\%changes,$loginhash{'login'},$domconfig{'login'}); - - my $defaulthelpfile = '/adm/loginproblems.html'; - my $defaulttext = &mt('Default in use'); - my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash, $dom); if ($putresult eq 'ok') { - my @toggles = ('coursecatalog','adminmail','helpdesk','newuser'); + my @toggles = ('coursecatalog','adminmail','newuser'); my %defaultchecked = ( 'coursecatalog' => 'on', - 'helpdesk' => 'on', 'adminmail' => 'off', 'newuser' => 'off', ); @@ -5361,9 +4572,6 @@ sub modify_login { } if (keys(%changes) > 0 || $colchgtext) { &Apache::loncommon::devalidate_domconfig_cache($dom); - if (ref($lastactref) eq 'HASH') { - $lastactref->{'domainconfig'} = 1; - } $resulttext = &mt('Changes made:').'
      '; foreach my $item (sort(keys(%changes))) { if ($item eq 'loginvia') { @@ -5395,68 +4603,6 @@ sub modify_login { } $resulttext .= '
    '; } - } elsif ($item eq 'helpurl') { - if (ref($changes{$item}) eq 'HASH') { - foreach my $lang (sort(keys(%{$changes{$item}}))) { - if (grep(/^\Q$lang\E$/,@delurls)) { - my ($chg,$link); - $link = &Apache::loncommon::modal_link($defaulthelpfile,$defaulttext,600,500); - if ($lang eq 'nolang') { - $chg = &mt('custom log-in help file removed for no preferred language; [_1]',$link); - } else { - $chg = &mt('custom log-in help file removed for specific language: [_1]; [_2]',$langchoices{$lang},$link); - } - $resulttext .= '
  • '.$chg.'
  • '; - } else { - my $chg; - if ($lang eq 'nolang') { - $chg = &mt('custom log-in help file for no preferred language'); - } else { - $chg = &mt('custom log-in help file for specific language: [_1]',$langchoices{$lang}); - } - $resulttext .= '
  • '.&Apache::loncommon::modal_link( - $loginhash{'login'}{'helpurl'}{$lang}. - '?inhibitmenu=yes',$chg,600,500). - '
  • '; - } - } - } - } elsif ($item eq 'captcha') { - if (ref($loginhash{'login'}) eq 'HASH') { - my $chgtxt; - if ($loginhash{'login'}{$item} eq 'notused') { - $chgtxt .= &mt('No CAPTCHA validation in use for helpdesk form.'); - } else { - my %captchas = &captcha_phrases(); - if ($captchas{$loginhash{'login'}{$item}}) { - $chgtxt .= &mt("Validation for helpdesk form set to $captchas{$loginhash{'login'}{$item}}."); - } else { - $chgtxt .= &mt('Validation for helpdesk form set to unknown type.'); - } - } - $resulttext .= '
  • '.$chgtxt.'
  • '; - } - } elsif ($item eq 'recaptchakeys') { - if (ref($loginhash{'login'}) eq 'HASH') { - my ($privkey,$pubkey); - if (ref($loginhash{'login'}{$item}) eq 'HASH') { - $pubkey = $loginhash{'login'}{$item}{'public'}; - $privkey = $loginhash{'login'}{$item}{'private'}; - } - my $chgtxt .= &mt('ReCAPTCHA keys changes').'
      '; - if (!$pubkey) { - $chgtxt .= '
    • '.&mt('Public key deleted').'
    • '; - } else { - $chgtxt .= '
    • '.&mt('Public key set to [_1]',$pubkey).'
    • '; - } - if (!$privkey) { - $chgtxt .= '
    • '.&mt('Private key deleted').'
    • '; - } else { - $chgtxt .= '
    • '.&mt('Private key set to [_1]',$pubkey).'
    • '; - } - $chgtxt .= '
    '; - $resulttext .= '
  • '.$chgtxt.'
  • '; - } } else { $resulttext .= '
  • '.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'
  • '; } @@ -5484,7 +4630,7 @@ sub color_font_choices { links => "Link colors", images => "Images", font => "Font color", - fontmenu => "Font menu", + fontmenu => "Font Menu", pgbg => "Page", tabbg => "Header", sidebg => "Border", @@ -5496,7 +4642,7 @@ sub color_font_choices { } sub modify_rolecolors { - my ($r,$dom,$confname,$roles,$lastactref,%domconfig) = @_; + my ($r,$dom,$confname,$roles,%domconfig) = @_; my ($resulttext,%rolehash); $rolehash{'rolecolors'} = {}; if (ref($domconfig{'rolecolors'}) ne 'HASH') { @@ -5511,9 +4657,6 @@ sub modify_rolecolors { if ($putresult eq 'ok') { if (keys(%changes) > 0) { &Apache::loncommon::devalidate_domconfig_cache($dom); - if (ref($lastactref) eq 'HASH') { - $lastactref->{'domainconfig'} = 1; - } $resulttext = &display_colorchgs($dom,\%changes,$roles, $rolehash{'rolecolors'}); } else { @@ -5539,45 +4682,24 @@ sub modify_colors { my @images; my $servadm = $r->dir_config('lonAdmEMail'); my $errors; - my %defaults; foreach my $role (@{$roles}) { if ($role eq 'login') { %choices = &login_choices(); @logintext = ('textcol','bgcol'); } else { %choices = &color_font_choices(); + $confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'}; } if ($role eq 'login') { @images = ('img','logo','domlogo','login'); @bgs = ('pgbg','mainbg','sidebg'); } else { @images = ('img'); - @bgs = ('pgbg','tabbg','sidebg'); + @bgs = ('pgbg','tabbg','sidebg'); } - my %defaults = &role_defaults($role,\@bgs,\@links,\@images,\@logintext); - unless ($env{'form.'.$role.'_font'} eq $defaults{'font'}) { - $confhash->{$role}{'font'} = $env{'form.'.$role.'_font'}; - } - if ($role eq 'login') { - foreach my $item (@logintext) { - unless ($env{'form.'.$role.'_'.$item} eq $defaults{'logintext'}{$item}) { - $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item}; - } - } - } else { - unless($env{'form.'.$role.'_fontmenu'} eq $defaults{'fontmenu'}) { - $confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'}; - } - } - foreach my $item (@bgs) { - unless ($env{'form.'.$role.'_'.$item} eq $defaults{'bgs'}{$item} ) { - $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item}; - } - } - foreach my $item (@links) { - unless ($env{'form.'.$role.'_'.$item} eq $defaults{'links'}{$item}) { - $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item}; - } + $confhash->{$role}{'font'} = $env{'form.'.$role.'_font'}; + foreach my $item (@bgs,@links,@logintext) { + $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item}; } my ($configuserok,$author_ok,$switchserver) = &config_check($dom,$confname,$servadm); @@ -5925,7 +5047,7 @@ sub publishlogo { # See if there is anything left unless ($fname) { return ('error: no uploaded file'); } $fname="$subdir/$fname"; - my $docroot=$r->dir_config('lonDocRoot'); + my $docroot=$r->dir_config('lonDocRoot'); my $filepath="$docroot/priv"; my $relpath = "$dom/$confname"; my ($fnamepath,$file,$fetchthumb); @@ -5945,19 +5067,19 @@ sub publishlogo { if ($file=~/\.(\w+)$/ && (&Apache::loncommon::fileembstyle($1) eq 'hdn')) { $output = - &mt('Invalid file extension ([_1]) - reserved for internal use.',$1); + &mt('Invalid file extension ([_1]) - reserved for LONCAPA use.',$1); } elsif ($file=~/\.(\w+)$/ && !defined(&Apache::loncommon::fileembstyle($1))) { $output = &mt('Unrecognized file extension ([_1]) - rename the file with a proper extension and re-upload.',$1); } elsif ($file=~/\.(\d+)\.(\w+)$/) { - $output = &mt('Filename not allowed - rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2); + $output = &mt('File name not allowed - rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2); } elsif (-d "$filepath/$file") { - $output = &mt('Filename is a directory name - rename the file and re-upload'); + $output = &mt('File name is a directory name - rename the file and re-upload'); } else { my $source = $filepath.'/'.$file; my $logfile; if (!open($logfile,">>$source".'.log')) { - return (&mt('No write permission to Authoring Space')); + return (&mt('No write permission to Construction Space')); } print $logfile "\n================= Publish ".localtime()." ================\n". @@ -6104,7 +5226,7 @@ sub write_metadata { print $logfile "\nWrite metadata file for ".$targetdir.'/'.$file; my $mfh; if (open($mfh,'>'.$targetdir.'/'.$file.'.meta')) { - foreach (sort(keys(%metadatafields))) { + foreach (sort keys %metadatafields) { unless ($_=~/\./) { my $unikey=$_; $unikey=~/^([A-Za-z]+)/; @@ -6188,31 +5310,27 @@ sub check_switchserver { my @ids=&Apache::lonnet::current_machine_ids(); foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } if (!$allowed) { - $switchserver=''.&mt('Switch Server').''; + $switchserver=''.&mt('Switch Server').''; } return $switchserver; } sub modify_quotas { - my ($r,$dom,$action,$lastactref,%domconfig) = @_; + my ($dom,$action,%domconfig) = @_; my ($context,@usertools,@options,%validations,%titles,%confhash,%toolshash, - %limithash,$toolregexp,%conditions,$resulttext,%changes,$confname,$configuserok, - $author_ok,$switchserver,$errors); + %limithash,$toolregexp,%conditions,$resulttext,%changes); if ($action eq 'quotas') { $context = 'tools'; } else { $context = $action; } if ($context eq 'requestcourses') { - @usertools = ('official','unofficial','community','textbook'); + @usertools = ('official','unofficial','community'); @options =('norequest','approval','validate','autolimit'); %validations = &Apache::lonnet::auto_courserequest_checks($dom); %titles = &courserequest_titles(); $toolregexp = join('|',@usertools); %conditions = &courserequest_conditions(); - $confname = $dom.'-domainconfig'; - my $servadm = $r->dir_config('lonAdmEMail'); - ($configuserok,$author_ok,$switchserver) = &config_check($dom,$confname,$servadm); } elsif ($context eq 'requestauthor') { @usertools = ('author'); %titles = &authorrequest_titles(); @@ -6220,7 +5338,7 @@ sub modify_quotas { @usertools = ('aboutme','blog','webdav','portfolio'); %titles = &tool_titles(); } - my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); + my %domdefaults = &Apache::lonnet::get_domain_defaults($dom); my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); foreach my $key (keys(%env)) { if ($context eq 'requestcourses') { @@ -6240,47 +5358,16 @@ sub modify_quotas { } else { if ($key =~ /^form\.quota_(.+)$/) { $confhash{'defaultquota'}{$1} = $env{$key}; - } elsif ($key =~ /^form\.authorquota_(.+)$/) { - $confhash{'authorquota'}{$1} = $env{$key}; - } elsif ($key =~ /^form\.\Q$context\E_(.+)$/) { + } + if ($key =~ /^form\.\Q$context\E_(.+)$/) { @{$toolshash{$1}} = &Apache::loncommon::get_env_multiple($key); } } } if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { - my @approvalnotify = &Apache::loncommon::get_env_multiple('form.'.$context.'notifyapproval'); + my @approvalnotify = &Apache::loncommon::get_env_multiple('form.reqapprovalnotify'); @approvalnotify = sort(@approvalnotify); $confhash{'notify'}{'approval'} = join(',',@approvalnotify); - my @crstypes = ('official','unofficial','community','textbook'); - my @hasuniquecode = &Apache::loncommon::get_env_multiple('form.uniquecode'); - foreach my $type (@hasuniquecode) { - if (grep(/^\Q$type\E$/,@crstypes)) { - $confhash{'uniquecode'}{$type} = 1; - } - } - my ($newbook,@allpos); - if ($context eq 'requestcourses') { - if ($env{'form.addbook'}) { - if (($env{'form.addbook_cnum'} =~ /^$match_courseid$/) && - ($env{'form.addbook_cdom'} =~ /^$match_domain$/)) { - if (&Apache::lonnet::homeserver($env{'form.addbook_cnum'}, - $env{'form.addbook_cdom'}) eq 'no_host') { - $errors .= '
  • '.&mt('Invalid LON-CAPA course for textbook'). - '
  • '; - } else { - $newbook = $env{'form.addbook_cdom'}.'_'.$env{'form.addbook_cnum'}; - my $position = $env{'form.addbook_pos'}; - $position =~ s/\D+//g; - if ($position ne '') { - $allpos[$position] = $newbook; - } - } - } else { - $errors .= '
  • '.&mt('Invalid LON-CAPA course for textbook'). - '
  • '; - } - } - } if (ref($domconfig{$action}) eq 'HASH') { if (ref($domconfig{$action}{'notify'}) eq 'HASH') { if ($domconfig{$action}{'notify'}{'approval'} ne $confhash{'notify'}{'approval'}) { @@ -6291,135 +5378,13 @@ sub modify_quotas { $changes{'notify'}{'approval'} = 1; } } - if (ref($domconfig{$action}{'uniquecode'}) eq 'HASH') { - if (ref($confhash{'uniquecode'}) eq 'HASH') { - foreach my $crstype (keys(%{$domconfig{$action}{'uniquecode'}})) { - unless ($confhash{'uniquecode'}{$crstype}) { - $changes{'uniquecode'} = 1; - } - } - unless ($changes{'uniquecode'}) { - foreach my $crstype (keys(%{$confhash{'uniquecode'}})) { - unless ($domconfig{$action}{'uniquecode'}{$crstype}) { - $changes{'uniquecode'} = 1; - } - } - } - } else { - $changes{'uniquecode'} = 1; - } - } elsif (ref($confhash{'uniquecode'}) eq 'HASH') { - $changes{'uniquecode'} = 1; - } - if ($context eq 'requestcourses') { - if (ref($domconfig{$action}{'textbooks'}) eq 'HASH') { - my %deletions; - my @todelete = &Apache::loncommon::get_env_multiple('form.book_del'); - if (@todelete) { - map { $deletions{$_} = 1; } @todelete; - } - my %imgdeletions; - my @todeleteimages = &Apache::loncommon::get_env_multiple('form.book_image_del'); - if (@todeleteimages) { - map { $imgdeletions{$_} = 1; } @todeleteimages; - } - my $maxnum = $env{'form.book_maxnum'}; - for (my $i=0; $i<=$maxnum; $i++) { - my $key = $env{'form.book_id_'.$i}; - if (ref($domconfig{$action}{'textbooks'}{$key}) eq 'HASH') { - if ($deletions{$key}) { - if ($domconfig{$action}{'textbooks'}{$key}{'image'}) { - #FIXME need to obsolete item in RES space - } - next; - } else { - my $newpos = $env{'form.'.$key}; - $newpos =~ s/\D+//g; - foreach my $item ('subject','title','author') { - $confhash{'textbooks'}{$key}{$item} = $env{'form.book_'.$item.'_'.$i}; - if ($domconfig{$action}{'textbooks'}{$key}{$item} ne $confhash{'textbooks'}{$key}{$item}) { - $changes{'textbooks'}{$key} = 1; - } - } - $allpos[$newpos] = $key; - } - if ($imgdeletions{$key}) { - $changes{'textbooks'}{$key} = 1; - #FIXME need to obsolete item in RES space - } elsif ($env{'form.book_image_'.$i.'.filename'}) { - my ($cdom,$cnum) = split(/_/,$key); - my ($imgurl,$error) = &process_textbook_image($r,$dom,$confname,'book_image_'.$i, - $cdom,$cnum,$configuserok, - $switchserver,$author_ok); - if ($imgurl) { - $confhash{'textbooks'}{$key}{'image'} = $imgurl; - $changes{'textbooks'}{$key} = 1; - } - if ($error) { - &Apache::lonnet::logthis($error); - $errors .= '
  • '.$error.'
  • '; - } - } elsif ($domconfig{$action}{'textbooks'}{$key}{'image'}) { - $confhash{'textbooks'}{$key}{'image'} = - $domconfig{$action}{'textbooks'}{$key}{'image'}; - } - } - } - } - } } else { if ($confhash{'notify'}{'approval'}) { $changes{'notify'}{'approval'} = 1; } - if (ref($confhash{'uniquecode'} eq 'HASH')) { - $changes{'uniquecode'} = 1; - } - } - if ($context eq 'requestcourses') { - if ($newbook) { - $changes{'textbooks'}{$newbook} = 1; - foreach my $item ('subject','title','author') { - $env{'form.addbook_'.$item} =~ s/(`)/'/g; - if ($env{'form.addbook_'.$item}) { - $confhash{'textbooks'}{$newbook}{$item} = $env{'form.addbook_'.$item}; - } - } - if ($env{'form.addbook_image.filename'} ne '') { - my ($cdom,$cnum) = split(/_/,$newbook); - my ($imageurl,$error) = - &process_textbook_image($r,$dom,$confname,'addbook_image',$cdom,$cnum,$configuserok, - $switchserver,$author_ok); - if ($imageurl) { - $confhash{'textbooks'}{$newbook}{'image'} = $imageurl; - } - if ($error) { - &Apache::lonnet::logthis($error); - $errors .= '
  • '.$error.'
  • '; - } - } - } - if (@allpos > 0) { - my $idx = 0; - foreach my $item (@allpos) { - if ($item ne '') { - $confhash{'textbooks'}{$item}{'order'} = $idx; - if (ref($domconfig{$action}) eq 'HASH') { - if (ref($domconfig{$action}{'textbooks'}) eq 'HASH') { - if (ref($domconfig{$action}{'textbooks'}{$item}) eq 'HASH') { - if ($domconfig{$action}{'textbooks'}{$item}{'order'} ne $idx) { - $changes{'textbooks'}{$item} = 1; - } - } - } - } - $idx ++; - } - } - } } } else { $confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'}; - $confhash{'authorquota'}{'default'} = $env{'form.authorquota'}; } foreach my $item (@usertools) { foreach my $type (@{$types},'default','_LC_adv') { @@ -6507,17 +5472,6 @@ sub modify_quotas { } } } - if (ref($domconfig{'quotas'}{'authorquota'}) eq 'HASH') { - foreach my $key (keys(%{$domconfig{'quotas'}{'authorquota'}})) { - if (exists($confhash{'authorquota'}{$key})) { - if ($confhash{'authorquota'}{$key} ne $domconfig{'quotas'}{'authorquota'}{$key}) { - $changes{'authorquota'}{$key} = 1; - } - } else { - $confhash{'authorquota'}{$key} = $domconfig{'quotas'}{'authorquota'}{$key}; - } - } - } } if (ref($confhash{'defaultquota'}) eq 'HASH') { foreach my $key (keys(%{$confhash{'defaultquota'}})) { @@ -6536,30 +5490,13 @@ sub modify_quotas { } } } - if (ref($confhash{'authorquota'}) eq 'HASH') { - foreach my $key (keys(%{$confhash{'authorquota'}})) { - if (ref($domconfig{'quotas'}) eq 'HASH') { - if (ref($domconfig{'quotas'}{'authorquota'}) eq 'HASH') { - if (!exists($domconfig{'quotas'}{'authorquota'}{$key})) { - $changes{'authorquota'}{$key} = 1; - } - } else { - $changes{'authorquota'}{$key} = 1; - } - } else { - $changes{'authorquota'}{$key} = 1; - } - } - } } if ($context eq 'requestauthor') { $domdefaults{'requestauthor'} = \%confhash; } else { foreach my $key (keys(%confhash)) { - unless (($context eq 'requestcourses') && ($key eq 'textbooks')) { - $domdefaults{$key} = $confhash{$key}; - } + $domdefaults{$key} = $confhash{$key}; } } @@ -6572,11 +5509,9 @@ sub modify_quotas { if (keys(%changes) > 0) { my $cachetime = 24*60*60; &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime); - if (ref($lastactref) eq 'HASH') { - $lastactref->{'domdefaults'} = 1; - } + $resulttext = &mt('Changes made:').'
      '; - unless (($context eq 'requestcourses') || + unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) { if (ref($changes{'defaultquota'}) eq 'HASH') { $resulttext .= '
    • '.&mt('Portfolio default quotas').'
        '; @@ -6586,20 +5521,7 @@ sub modify_quotas { if ($type eq 'default') { $typetitle = $othertitle; } - $resulttext .= '
      • '.&mt('[_1] set to [_2] MB',$typetitle,$confhash{'defaultquota'}{$type}).'
      • '; - } - } - $resulttext .= '
    • '; - } - if (ref($changes{'authorquota'}) eq 'HASH') { - $resulttext .= '
    • '.&mt('Authoring Space default quotas').'
        '; - foreach my $type (@{$types},'default') { - if (defined($changes{'authorquota'}{$type})) { - my $typetitle = $usertypes->{$type}; - if ($type eq 'default') { - $typetitle = $othertitle; - } - $resulttext .= '
      • '.&mt('[_1] set to [_2] MB',$typetitle,$confhash{'authorquota'}{$type}).'
      • '; + $resulttext .= '
      • '.&mt('[_1] set to [_2] Mb',$typetitle,$confhash{'defaultquota'}{$type}).'
      • '; } } $resulttext .= '
    • '; @@ -6610,7 +5532,7 @@ sub modify_quotas { my (%haschgs,%inconf); if ($context eq 'requestauthor') { %haschgs = %changes; - %inconf = %confhash; + %inconf = %confhash; } else { if (ref($changes{$item}) eq 'HASH') { %haschgs = %{$changes{$item}}; @@ -6624,7 +5546,7 @@ sub modify_quotas { &Apache::lonnet::usertools_access($env{'user.name'}, $env{'user.domain'}, $item,'reload',$context); - if (($context eq 'requestcourses') || + if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { if ($env{'environment.canrequest.'.$item} ne $newacc) { $newenv{'environment.canrequest.'.$item} = $newacc; @@ -6658,10 +5580,6 @@ sub modify_quotas { $cond = $conditions{$inconf{$type}}; } $resulttext .= '
    • '.&mt('Set to be available to [_1].',$typetitle).' '.$cond.'
    • '; - } elsif ($context eq 'requestauthor') { - $resulttext .= '
    • '.&mt('Set to "[_1]" for "[_2]".', - $titles{$inconf{$type}},$typetitle); - } else { $resulttext .= '
    • '.&mt('Set to be available to [_1]',$typetitle).'
    • '; } @@ -6696,42 +5614,6 @@ sub modify_quotas { } } } - if ($action eq 'requestcourses') { - my @offon = ('off','on'); - if ($changes{'uniquecode'}) { - if (ref($confhash{'uniquecode'}) eq 'HASH') { - my $codestr = join(' ',map{ &mt($_); } sort(keys(%{$confhash{'uniquecode'}}))); - $resulttext .= '
    • '. - &mt('Generation of six character code as course identifier for distribution to students set to on for: [_1].',''.$codestr.''). - '
    • '; - } else { - $resulttext .= '
    • '.&mt('Generation of six character code as course identifier for distribution to students set to off.'). - '
    • '; - } - } - if (ref($changes{'textbooks'}) eq 'HASH') { - $resulttext .= '
    • '.&mt('Available textbooks updated').'
        '; - foreach my $key (sort(keys(%{$changes{'textbooks'}}))) { - my %coursehash = &Apache::lonnet::coursedescription($key); - my $coursetitle = $coursehash{'description'}; - my $position = $confhash{'textbooks'}{$key}{'order'} + 1; - $resulttext .= '
      • '; - foreach my $item ('subject','title','author') { - my $name = $item.':'; - $name =~ s/^(\w)/\U$1/; - $resulttext .= &mt($name).' '.$confhash{'textbooks'}{$key}{$item}.'
        '; - } - $resulttext .= ' '.&mt('Order: [_1]',$position).'
        '; - if ($confhash{'textbooks'}{$key}{'image'}) { - $resulttext .= ' '.&mt('Image: [_1]', - 'Textbook cover').'
        '; - } - $resulttext .= ' '.&mt('LON-CAPA Course: [_1]',$coursetitle).'
      • '; - } - $resulttext .= '
    • '; - } - } $resulttext .= '
    '; if (keys(%newenv)) { &Apache::lonnet::appenv(\%newenv); @@ -6749,42 +5631,11 @@ sub modify_quotas { $resulttext = ''. &mt('An error occurred: [_1]',$putresult).''; } - if ($errors) { - $resulttext .= '

    '.&mt('The following errors occurred when modifying Textbook settings.'). - '

      '.$errors.'

    '; - } return $resulttext; } -sub process_textbook_image { - my ($r,$dom,$confname,$caller,$cdom,$cnum,$configuserok,$switchserver,$author_ok) = @_; - my $filename = $env{'form.'.$caller.'.filename'}; - my ($error,$url); - my ($width,$height) = (50,50); - if ($configuserok eq 'ok') { - if ($switchserver) { - $error = &mt('Upload of textbook image is not permitted to this server: [_1]', - $switchserver); - } elsif ($author_ok eq 'ok') { - my ($result,$imageurl) = - &publishlogo($r,'upload',$caller,$dom,$confname, - "textbooks/$dom/$cnum/cover",$width,$height); - if ($result eq 'ok') { - $url = $imageurl; - } else { - $error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$filename,$result); - } - } else { - $error = &mt("Upload of [_1] failed because an author role could not be assigned to a Domain Configuration user ([_2]) in domain: [_3]. Error was: [_4].",$filename,$confname,$dom,$author_ok); - } - } else { - $error = &mt("Upload of [_1] failed because a Domain Configuration user ([_2]) could not be created in domain: [_3]. Error was: [_4].",$filename,$confname,$dom,$configuserok); - } - return ($url,$error); -} - sub modify_autoenroll { - my ($dom,$lastactref,%domconfig) = @_; + my ($dom,%domconfig) = @_; my ($resulttext,%changes); my %currautoenroll; if (ref($domconfig{'autoenroll'}) eq 'HASH') { @@ -6852,9 +5703,6 @@ sub modify_autoenroll { if ($changes{'coowners'}) { $resulttext .= '
  • '.&mt("$title{'coowners'} set to $offon[$env{'form.autoassign_coowners'}]").'
  • '; &Apache::loncommon::devalidate_domconfig_cache($dom); - if (ref($lastactref) eq 'HASH') { - $lastactref->{'domainconfig'} = 1; - } } $resulttext .= ''; } else { @@ -7105,16 +5953,13 @@ sub modify_autocreate { foreach my $item (@types) { if ($changes{$item}) { my $newtxt = $offon[$newvals{$item}]; - $resulttext .= '
  • '. - &mt("$title{$item} set to [_1]$newtxt [_2]", - '',''). - '
  • '; + $resulttext .= '
  • '.&mt("$title{$item} set to [_1]$newtxt [_2]",'','').'
  • '; } } if ($changes{'xmldc'}) { my ($dcname,$dcdom) = split(':',$newvals{'xmldc'}); my $newtxt = &Apache::loncommon::plainname($dcname,$dcdom); - $resulttext .= '
  • '.&mt("$title{'xmldc'} set to [_1]",''.$newtxt.'').'
  • '; + $resulttext .= '
  • '.&mt("$title{'xmldc'} set to [_1]$newtxt [_2]",'','').'
  • '; } $resulttext .= ''; } else { @@ -7260,11 +6105,7 @@ sub modify_directorysrch { } else { $chgtext =~ s/\; $//; } - $resulttext .= - '
  • '. - &mt("Users from domain '[_1]' permitted to search the institutional directory set to: [_2]", - ''.$dom.'',$chgtext). - '
  • '; + $resulttext .= '
  • '.&mt("Users from domain '[_1]' permitted to search the institutional directory set to: [_2]",$dom,$chgtext).'
  • '; } } } @@ -7292,7 +6133,7 @@ sub modify_directorysrch { } } $chgtext =~ s/\; $//; - $resulttext .= '
  • '.&mt($title{'searchtypes'}.' set to: "[_1]"',$chgtext).'
  • '; + $resulttext .= '
  • '.&mt("$title{'searchtypes'} set to: \"[_1]\"",$chgtext).'
  • '; } $resulttext .= ''; } else { @@ -7306,7 +6147,7 @@ sub modify_directorysrch { } sub modify_contacts { - my ($dom,$lastactref,%domconfig) = @_; + my ($dom,%domconfig) = @_; my ($resulttext,%currsetting,%newsetting,%changes,%contacts_hash); if (ref($domconfig{'contacts'}) eq 'HASH') { foreach my $key (keys(%{$domconfig{'contacts'}})) { @@ -7316,8 +6157,7 @@ sub modify_contacts { my (%others,%to,%bcc); my @contacts = ('supportemail','adminemail'); my @mailings = ('errormail','packagesmail','helpdeskmail','lonstatusmail', - 'requestsmail','updatesmail','idconflictsmail'); - my @toggles = ('reporterrors','reportupdates'); + 'requestsmail'); foreach my $type (@mailings) { @{$newsetting{$type}} = &Apache::loncommon::get_env_multiple('form.'.$type); @@ -7339,11 +6179,6 @@ sub modify_contacts { $to{$item} = $env{'form.'.$item}; $contacts_hash{'contacts'}{$item} = $to{$item}; } - foreach my $item (@toggles) { - if ($env{'form.'.$item} =~ /^(0|1)$/) { - $contacts_hash{'contacts'}{$item} = $env{'form.'.$item}; - } - } if (keys(%currsetting) > 0) { foreach my $item (@contacts) { if ($to{$item} ne $currsetting{$item}) { @@ -7378,11 +6213,10 @@ sub modify_contacts { $default{'helpdeskmail'} = 'supportemail'; $default{'lonstatusmail'} = 'adminemail'; $default{'requestsmail'} = 'adminemail'; - $default{'updatesmail'} = 'adminemail'; foreach my $item (@contacts) { if ($to{$item} ne $default{$item}) { $changes{$item} = 1; - } + } } foreach my $type (@mailings) { if ((@{$newsetting{$type}} != 1) || ($newsetting{$type}[0] ne $default{$type})) { @@ -7399,22 +6233,10 @@ sub modify_contacts { } } } - foreach my $item (@toggles) { - if (($env{'form.'.$item} == 1) && ($currsetting{$item} == 0)) { - $changes{$item} = 1; - } elsif ((!$env{'form.'.$item}) && - (($currsetting{$item} eq '') || ($currsetting{$item} == 1))) { - $changes{$item} = 1; - } - } my $putresult = &Apache::lonnet::put_dom('configuration',\%contacts_hash, $dom); if ($putresult eq 'ok') { if (keys(%changes) > 0) { - &Apache::loncommon::devalidate_domconfig_cache($dom); - if (ref($lastactref) eq 'HASH') { - $lastactref->{'domainconfig'} = 1; - } my ($titles,$short_titles) = &contact_titles(); $resulttext = &mt('Changes made:').'
      '; foreach my $item (@contacts) { @@ -7445,23 +6267,6 @@ sub modify_contacts { $resulttext .= ''; } } - my @offon = ('off','on'); - if ($changes{'reporterrors'}) { - $resulttext .= '
    • '. - &mt('E-mail error reports to [_1] set to "'. - $offon[$env{'form.reporterrors'}].'".', - &Apache::loncommon::modal_link('http://loncapa.org/core.html', - &mt('LON-CAPA core group - MSU'),600,500)). - '
    • '; - } - if ($changes{'reportupdates'}) { - $resulttext .= '
    • '. - &mt('E-mail record of completed LON-CAPA updates to [_1] set to "'. - $offon[$env{'form.reportupdates'}].'".', - &Apache::loncommon::modal_link('http://loncapa.org/core.html', - &mt('LON-CAPA core group - MSU'),600,500)). - '
    • '; - } $resulttext .= '
    '; } else { $resulttext = &mt('No changes made to contact information'); @@ -7475,38 +6280,105 @@ sub modify_contacts { sub modify_usercreation { my ($dom,%domconfig) = @_; - my ($resulttext,%curr_usercreation,%changes,%authallowed,%cancreate,%save_usercreate); + my ($resulttext,%curr_usercreation,%changes,%authallowed,%cancreate); my $warningmsg; if (ref($domconfig{'usercreation'}) eq 'HASH') { foreach my $key (keys(%{$domconfig{'usercreation'}})) { - if ($key eq 'cancreate') { - if (ref($domconfig{'usercreation'}{$key}) eq 'HASH') { - foreach my $item (keys(%{$domconfig{'usercreation'}{$key}})) { - if (($item eq 'selfcreate') || ($item eq 'statustocreate') || - ($item eq 'captcha') || ($item eq 'recaptchakeys')) { - $save_usercreate{$key}{$item} = $domconfig{'usercreation'}{$key}{$item}; - } else { - $curr_usercreation{$key}{$item} = $domconfig{'usercreation'}{$key}{$item}; - } - } - } - } elsif ($key eq 'email_rule') { - $save_usercreate{$key} = $domconfig{'usercreation'}{$key}; - } else { - $curr_usercreation{$key} = $domconfig{'usercreation'}{$key}; - } + $curr_usercreation{$key} = $domconfig{'usercreation'}{$key}; } } my @username_rule = &Apache::loncommon::get_env_multiple('form.username_rule'); my @id_rule = &Apache::loncommon::get_env_multiple('form.id_rule'); - my @contexts = ('author','course','requestcrs'); + my @email_rule = &Apache::loncommon::get_env_multiple('form.email_rule'); + my @contexts = ('author','course','requestcrs','selfcreate'); foreach my $item(@contexts) { - $cancreate{$item} = $env{'form.can_createuser_'.$item}; + if ($item eq 'selfcreate') { + @{$cancreate{$item}} = &Apache::loncommon::get_env_multiple('form.can_createuser_'.$item); + my %domdefaults = &Apache::lonnet::get_domain_defaults($dom); + if (!((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth'))) { + if (ref($cancreate{$item}) eq 'ARRAY') { + if (grep(/^login$/,@{$cancreate{$item}})) { + $warningmsg = &mt('Although account creation has been set to be available for institutional logins, currently default authentication in this domain has not been set to support this.').' '.&mt('You need to set the default authentication type to Kerberos 4 or 5 (with a Kerberos domain specified), or to Local authentication, if the localauth module has been customized in your domain to authenticate institutional logins.'); + } + } + } + } else { + $cancreate{$item} = $env{'form.can_createuser_'.$item}; + } + } + my ($othertitle,$usertypes,$types) = + &Apache::loncommon::sorted_inst_types($dom); + if (ref($types) eq 'ARRAY') { + if (@{$types} > 0) { + @{$cancreate{'statustocreate'}} = + &Apache::loncommon::get_env_multiple('form.statustocreate'); + } else { + @{$cancreate{'statustocreate'}} = (); + } + push(@contexts,'statustocreate'); } if (ref($curr_usercreation{'cancreate'}) eq 'HASH') { foreach my $item (@contexts) { - if ($curr_usercreation{'cancreate'}{$item} ne $cancreate{$item}) { - push(@{$changes{'cancreate'}},$item); + if (($item eq 'selfcreate') || ($item eq 'statustocreate')) { + if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') { + foreach my $curr (@{$curr_usercreation{'cancreate'}{$item}}) { + if (ref($cancreate{$item}) eq 'ARRAY') { + if (!grep(/^$curr$/,@{$cancreate{$item}})) { + if (!grep(/^$item$/,@{$changes{'cancreate'}})) { + push(@{$changes{'cancreate'}},$item); + } + } + } + } + } else { + if ($curr_usercreation{'cancreate'}{$item} eq '') { + if (@{$cancreate{$item}} > 0) { + if (!grep(/^$item$/,@{$changes{'cancreate'}})) { + push(@{$changes{'cancreate'}},$item); + } + } + } else { + if ($curr_usercreation{'cancreate'}{$item} eq 'any') { + if (@{$cancreate{$item}} < 3) { + if (!grep(/^$item$/,@{$changes{'cancreate'}})) { + push(@{$changes{'cancreate'}},$item); + } + } + } elsif ($curr_usercreation{'cancreate'}{$item} eq 'none') { + if (@{$cancreate{$item}} > 0) { + if (!grep(/^$item$/,@{$changes{'cancreate'}})) { + push(@{$changes{'cancreate'}},$item); + } + } + } elsif (!grep(/^$curr_usercreation{'cancreate'}{$item}$/,@{$cancreate{$item}})) { + if (!grep(/^$item$/,@{$changes{'cancreate'}})) { + push(@{$changes{'cancreate'}},$item); + } + } + } + } + if (!grep(/^$item$/,@{$changes{'cancreate'}})) { + foreach my $type (@{$cancreate{$item}}) { + if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') { + if (!grep(/^$type$/,@{$curr_usercreation{'cancreate'}{$item}})) { + if (!grep(/^$item$/,@{$changes{'cancreate'}})) { + push(@{$changes{'cancreate'}},$item); + } + } + } elsif (($curr_usercreation{'cancreate'}{$item} ne 'any') && + ($curr_usercreation{'cancreate'}{$item} ne 'none')) { + if ($curr_usercreation{'cancreate'}{$item} ne $type) { + if (!grep(/^$item$/,@{$changes{'cancreate'}})) { + push(@{$changes{'cancreate'}},$item); + } + } + } + } + } + } else { + if ($curr_usercreation{'cancreate'}{$item} ne $cancreate{$item}) { + push(@{$changes{'cancreate'}},$item); + } } } } elsif (ref($curr_usercreation{'cancreate'}) eq 'ARRAY') { @@ -7557,6 +6429,21 @@ sub modify_usercreation { push(@{$changes{'id_rule'}},@id_rule); } + if (ref($curr_usercreation{'email_rule'}) eq 'ARRAY') { + foreach my $type (@{$curr_usercreation{'email_rule'}}) { + if (!grep(/^\Q$type\E$/,@email_rule)) { + push(@{$changes{'email_rule'}},$type); + } + } + foreach my $type (@email_rule) { + if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'email_rule'}})) { + push(@{$changes{'email_rule'}},$type); + } + } + } else { + push(@{$changes{'email_rule'}},@email_rule); + } + my @authen_contexts = ('author','course','domain'); my @authtypes = ('int','krb4','krb5','loc'); my %authhash; @@ -7587,435 +6474,39 @@ sub modify_usercreation { } } - $save_usercreate{'cancreate'}{'course'} = $cancreate{'course'}; - $save_usercreate{'cancreate'}{'author'} = $cancreate{'author'}; - $save_usercreate{'cancreate'}{'requestcrs'} = $cancreate{'requestcrs'}; - $save_usercreate{'id_rule'} = \@id_rule; - $save_usercreate{'username_rule'} = \@username_rule, - $save_usercreate{'authtypes'} = \%authhash; - my %usercreation_hash = ( - usercreation => \%save_usercreate, - ); + usercreation => { + cancreate => \%cancreate, + username_rule => \@username_rule, + id_rule => \@id_rule, + email_rule => \@email_rule, + authtypes => \%authhash, + } + ); my $putresult = &Apache::lonnet::put_dom('configuration',\%usercreation_hash, $dom); - if ($putresult eq 'ok') { - if (keys(%changes) > 0) { - $resulttext = &mt('Changes made:').'
      '; - if (ref($changes{'cancreate'}) eq 'ARRAY') { - my %lt = &usercreation_types(); - foreach my $type (@{$changes{'cancreate'}}) { - my $chgtext = $lt{$type}.', '; - if ($cancreate{$type} eq 'none') { - $chgtext .= &mt('creation of new users is not permitted, except by a Domain Coordinator.'); - } elsif ($cancreate{$type} eq 'any') { - $chgtext .= &mt('creation of new users is permitted for both institutional and non-institutional usernames.'); - } elsif ($cancreate{$type} eq 'official') { - $chgtext .= &mt('creation of new users is only permitted for institutional usernames.'); - } elsif ($cancreate{$type} eq 'unofficial') { - $chgtext .= &mt('creation of new users is only permitted for non-institutional usernames.'); - } - $resulttext .= '
    • '.$chgtext.'
    • '; - } - } - if (ref($changes{'username_rule'}) eq 'ARRAY') { - my ($rules,$ruleorder) = - &Apache::lonnet::inst_userrules($dom,'username'); - my $chgtext = '
        '; - foreach my $type (@username_rule) { - if (ref($rules->{$type}) eq 'HASH') { - $chgtext .= '
      • '.$rules->{$type}{'name'}.'
      • '; - } - } - $chgtext .= '
      '; - if (@username_rule > 0) { - $resulttext .= '
    • '.&mt('Usernames with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'
    • '; - } else { - $resulttext .= '
    • '.&mt('There are now no username formats restricted to verified users in the institutional directory.').'
    • '; - } - } - if (ref($changes{'id_rule'}) eq 'ARRAY') { - my ($idrules,$idruleorder) = - &Apache::lonnet::inst_userrules($dom,'id'); - my $chgtext = '
        '; - foreach my $type (@id_rule) { - if (ref($idrules->{$type}) eq 'HASH') { - $chgtext .= '
      • '.$idrules->{$type}{'name'}.'
      • '; - } - } - $chgtext .= '
      '; - if (@id_rule > 0) { - $resulttext .= '
    • '.&mt('IDs with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'
    • '; - } else { - $resulttext .= '
    • '.&mt('There are now no ID formats restricted to verified users in the institutional directory.').'
    • '; - } - } - my %authname = &authtype_names(); - my %context_title = &context_names(); - if (ref($changes{'authtypes'}) eq 'ARRAY') { - my $chgtext = '
        '; - foreach my $type (@{$changes{'authtypes'}}) { - my @allowed; - $chgtext .= '
      • '.$context_title{$type}.' - '.&mt('assignable authentication types: '); - foreach my $auth (@authtypes) { - if ($authhash{$type}{$auth}) { - push(@allowed,$authname{$auth}); - } - } - if (@allowed > 0) { - $chgtext .= join(', ',@allowed).'
      • '; - } else { - $chgtext .= &mt('none').''; - } - } - $chgtext .= '
      '; - $resulttext .= '
    • '.&mt('Authentication types available for assignment to new users').'
      '.$chgtext; - $resulttext .= '
    • '; - } - $resulttext .= '
    '; - } else { - $resulttext = &mt('No changes made to user creation settings'); - } - } else { - $resulttext = ''. - &mt('An error occurred: [_1]',$putresult).''; - } - if ($warningmsg ne '') { - $resulttext .= '
    '.$warningmsg.'
    '; - } - return $resulttext; -} - -sub modify_selfcreation { - my ($dom,%domconfig) = @_; - my ($resulttext,$warningmsg,%curr_usercreation,%curr_usermodify,%changes,%cancreate); - my (%save_usercreate,%save_usermodify); - my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); - if (ref($types) eq 'ARRAY') { - $usertypes->{'default'} = $othertitle; - push(@{$types},'default'); - } -# -# Retrieve current domain configuration for self-creation of usernames from $domconfig{'usercreation'}. -# - if (ref($domconfig{'usercreation'}) eq 'HASH') { - foreach my $key (keys(%{$domconfig{'usercreation'}})) { - if ($key eq 'cancreate') { - if (ref($domconfig{'usercreation'}{$key}) eq 'HASH') { - foreach my $item (keys(%{$domconfig{'usercreation'}{$key}})) { - if (($item eq 'selfcreate') || ($item eq 'statustocreate') || - ($item eq 'captcha') || ($item eq 'recaptchakeys') || - ($item eq 'emailusername') || ($item eq 'notify')) { - $curr_usercreation{$key}{$item} = $domconfig{'usercreation'}{$key}{$item}; - } else { - $save_usercreate{$key}{$item} = $domconfig{'usercreation'}{$key}{$item}; - } - } - } - } elsif ($key eq 'email_rule') { - $curr_usercreation{$key} = $domconfig{'usercreation'}{$key}; - } else { - $save_usercreate{$key} = $domconfig{'usercreation'}{$key}; - } - } - } -# -# Retrieve current domain configuration for self-creation of usernames from $domconfig{'usermodification'}. -# - if (ref($domconfig{'usermodification'}) eq 'HASH') { - foreach my $key (keys(%{$domconfig{'usermodification'}})) { - if ($key eq 'selfcreate') { - $curr_usermodify{$key} = $domconfig{'usermodification'}{$key}; - } else { - $save_usermodify{$key} = $domconfig{'usermodification'}{$key}; - } - } - } - - my @contexts = ('selfcreate'); - @{$cancreate{'selfcreate'}} = (); - %{$cancreate{'emailusername'}} = (); - @{$cancreate{'statustocreate'}} = (); my %selfcreatetypes = ( sso => 'users authenticated by institutional single sign on', login => 'users authenticated by institutional log-in', - email => 'users who provide a valid e-mail address for use as username (automatic creation)', - emailapproval => 'users who provide a valid e-mail address for use as username (queued for Domain Coordinator review)', + email => 'users who provide a valid e-mail address for use as the username', ); -# -# Populate $cancreate{'selfcreate'} array reference with types of user, for which self-creation of user accounts -# is permitted. -# - foreach my $item ('login','sso','email') { - if ($item eq 'email') { - if ($env{'form.cancreate_email'} eq 'email') { - push(@{$cancreate{'selfcreate'}},'email'); - } elsif ($env{'form.cancreate_email'} eq 'emailapproval') { - push(@{$cancreate{'selfcreate'}},'emailapproval'); - } - } else { - if ($env{'form.cancreate_'.$item}) { - push(@{$cancreate{'selfcreate'}},$item); - } - } - } - my (@email_rule,%userinfo,%savecaptcha); - my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info(); -# -# Populate $cancreate{'emailusername'}{$type} hash ref with information fields (if new user will provide data -# value set to one), if self-creation with e-mail address permitted, where $type is user type: faculty, staff, student etc. -# - if (($env{'form.cancreate_email'} eq 'email') || ($env{'form.cancreate_email'} eq 'emailapproval')) { - push(@contexts,'emailusername'); - if (ref($types) eq 'ARRAY') { - foreach my $type (@{$types}) { - if (ref($infofields) eq 'ARRAY') { - foreach my $field (@{$infofields}) { - if ($env{'form.canmodify_emailusername_'.$type.'_'.$field} =~ /^(required|optional)$/) { - $cancreate{'emailusername'}{$type}{$field} = $1; - } - } - } - } - } -# -# Populate $cancreate{'notify'} hash ref with names of Domain Coordinators who are to be notified of -# queued requests for self-creation of account using e-mail address as username -# - - my @approvalnotify = &Apache::loncommon::get_env_multiple('form.selfcreationnotifyapproval'); - @approvalnotify = sort(@approvalnotify); - $cancreate{'notify'}{'approval'} = join(',',@approvalnotify); - if (ref($curr_usercreation{'cancreate'}) eq 'HASH') { - if (ref($curr_usercreation{'cancreate'}{'notify'}) eq 'HASH') { - if ($curr_usercreation{'cancreate'}{'notify'}{'approval'} ne $cancreate{'notify'}{'approval'}) { - push(@{$changes{'cancreate'}},'notify'); - } - } else { - if ($cancreate{'notify'}{'approval'}) { - push(@{$changes{'cancreate'}},'notify'); - } - } - } elsif ($cancreate{'notify'}{'approval'}) { - push(@{$changes{'cancreate'}},'notify'); - } - -# -# Retrieve rules (if any) governing types of e-mail address which may be used as a username -# - @email_rule = &Apache::loncommon::get_env_multiple('form.email_rule'); - &process_captcha('cancreate',\%changes,\%savecaptcha,$curr_usercreation{'cancreate'}); - if (ref($curr_usercreation{'email_rule'}) eq 'ARRAY') { - if (@{$curr_usercreation{'email_rule'}} > 0) { - foreach my $type (@{$curr_usercreation{'email_rule'}}) { - if (!grep(/^\Q$type\E$/,@email_rule)) { - push(@{$changes{'email_rule'}},$type); - } - } - } - if (@email_rule > 0) { - foreach my $type (@email_rule) { - if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'email_rule'}})) { - push(@{$changes{'email_rule'}},$type); - } - } - } - } elsif (@email_rule > 0) { - push(@{$changes{'email_rule'}},@email_rule); - } - } -# -# Check if domain default is set appropriately, if selef-creation of accounts is to be available for -# institutional log-in. -# - if (grep(/^login$/,@{$cancreate{'selfcreate'}})) { - my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); - if (!((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || - ($domdefaults{'auth_def'} eq 'localauth'))) { - $warningmsg = &mt('Although account creation has been set to be available for institutional logins, currently default authentication in this domain has not been set to support this.').' '. - &mt('You need to set the default authentication type to Kerberos 4 or 5 (with a Kerberos domain specified), or to Local authentication, if the localauth module has been customized in your domain to authenticate institutional logins.'); - } - } - my @fields = ('lastname','firstname','middlename','generation', - 'permanentemail','id'); - my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles(); -# -# Where usernames may created for institutional log-in and/or institutional single sign on: -# (a) populate $cancreate{'statustocreate'} array reference with institutional status types who -# may self-create accounts -# (b) populate $save_usermodify{'selfcreate'} hash reference with status types, and information fields -# which the user may supply, if institutional data is unavailable. -# - if (($env{'form.cancreate_login'}) || ($env{'form.cancreate_sso'})) { - if (ref($types) eq 'ARRAY') { - if (@{$types} > 1) { - @{$cancreate{'statustocreate'}} = &Apache::loncommon::get_env_multiple('form.statustocreate'); - push(@contexts,'statustocreate'); - } else { - undef($cancreate{'statustocreate'}); - } - foreach my $type (@{$types}) { - my @modifiable = &Apache::loncommon::get_env_multiple('form.canmodify_'.$type); - foreach my $field (@fields) { - if (grep(/^\Q$field\E$/,@modifiable)) { - $save_usermodify{'selfcreate'}{$type}{$field} = 1; - } else { - $save_usermodify{'selfcreate'}{$type}{$field} = 0; - } - } - } - if (ref($curr_usermodify{'selfcreate'}) eq 'HASH') { - foreach my $type (@{$types}) { - if (ref($curr_usermodify{'selfcreate'}{$type}) eq 'HASH') { - foreach my $field (@fields) { - if ($save_usermodify{'selfcreate'}{$type}{$field} ne - $curr_usermodify{'selfcreate'}{$type}{$field}) { - push(@{$changes{'selfcreate'}},$type); - last; - } - } - } - } - } else { - foreach my $type (@{$types}) { - push(@{$changes{'selfcreate'}},$type); - } - } - } - } - foreach my $item (@contexts) { - if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') { - foreach my $curr (@{$curr_usercreation{'cancreate'}{$item}}) { - if (ref($cancreate{$item}) eq 'ARRAY') { - if (!grep(/^$curr$/,@{$cancreate{$item}})) { - if (!grep(/^$item$/,@{$changes{'cancreate'}})) { - push(@{$changes{'cancreate'}},$item); - } - } - } - } - if (ref($cancreate{$item}) eq 'ARRAY') { - foreach my $type (@{$cancreate{$item}}) { - if (!grep(/^$type$/,@{$curr_usercreation{'cancreate'}{$item}})) { - if (!grep(/^$item$/,@{$changes{'cancreate'}})) { - push(@{$changes{'cancreate'}},$item); - } - } - } - } - } elsif (ref($curr_usercreation{'cancreate'}{$item}) eq 'HASH') { - if (ref($cancreate{$item}) eq 'HASH') { - foreach my $curr (keys(%{$curr_usercreation{'cancreate'}{$item}})) { - if (ref($curr_usercreation{'cancreate'}{$item}{$curr}) eq 'HASH') { - foreach my $field (keys(%{$curr_usercreation{'cancreate'}{$item}{$curr}})) { - unless ($curr_usercreation{'cancreate'}{$item}{$curr}{$field} eq $cancreate{$item}{$curr}{$field}) { - if (!grep(/^$item$/,@{$changes{'cancreate'}})) { - push(@{$changes{'cancreate'}},$item); - } - } - } - } else { - if (!$cancreate{$item}{$curr}) { - if (!grep(/^$item$/,@{$changes{'cancreate'}})) { - push(@{$changes{'cancreate'}},$item); - } - } - } - } - foreach my $field (keys(%{$cancreate{$item}})) { - if (ref($cancreate{$item}{$field}) eq 'HASH') { - foreach my $inner (keys(%{$cancreate{$item}{$field}})) { - if (ref($curr_usercreation{'cancreate'}{$item}{$field}) eq 'HASH') { - unless ($curr_usercreation{'cancreate'}{$item}{$field}{$inner} eq $cancreate{$item}{$field}{$inner}) { - if (!grep(/^$item$/,@{$changes{'cancreate'}})) { - push(@{$changes{'cancreate'}},$item); - } - } - } else { - if (!grep(/^$item$/,@{$changes{'cancreate'}})) { - push(@{$changes{'cancreate'}},$item); - } - } - } - } else { - if (!$curr_usercreation{'cancreate'}{$item}{$field}) { - if (!grep(/^$item$/,@{$changes{'cancreate'}})) { - push(@{$changes{'cancreate'}},$item); - } - } - } - } - } - } elsif ($curr_usercreation{'cancreate'}{$item}) { - if (ref($cancreate{$item}) eq 'ARRAY') { - if (!grep(/^\Q$curr_usercreation{'cancreate'}{$item}\E$/,@{$cancreate{$item}})) { - if (!grep(/^$item$/,@{$changes{'cancreate'}})) { - push(@{$changes{'cancreate'}},$item); - } - } - } elsif (ref($cancreate{$item}) eq 'HASH') { - if (!$cancreate{$item}{$curr_usercreation{'cancreate'}{$item}}) { - if (!grep(/^$item$/,@{$changes{'cancreate'}})) { - push(@{$changes{'cancreate'}},$item); - } - } - } - } elsif ($item eq 'emailusername') { - if (ref($cancreate{$item}) eq 'HASH') { - foreach my $type (keys(%{$cancreate{$item}})) { - if (ref($cancreate{$item}{$type}) eq 'HASH') { - foreach my $field (keys(%{$cancreate{$item}{$type}})) { - if ($cancreate{$item}{$type}{$field}) { - if (!grep(/^$item$/,@{$changes{'cancreate'}})) { - push(@{$changes{'cancreate'}},$item); - } - last; - } - } - } - } - } - } - } -# -# Populate %save_usercreate hash with updates to self-creation configuration. -# - $save_usercreate{'cancreate'}{'captcha'} = $savecaptcha{'captcha'}; - $save_usercreate{'cancreate'}{'recaptchakeys'} = $savecaptcha{'recaptchakeys'}; - $save_usercreate{'cancreate'}{'selfcreate'} = $cancreate{'selfcreate'}; - if (ref($cancreate{'notify'}) eq 'HASH') { - $save_usercreate{'cancreate'}{'notify'} = $cancreate{'notify'}; - } - if (ref($cancreate{'statustocreate'}) eq 'ARRAY') { - $save_usercreate{'cancreate'}{'statustocreate'} = $cancreate{'statustocreate'}; - } - $save_usercreate{'cancreate'}{'emailusername'} = $cancreate{'emailusername'}; - $save_usercreate{'emailrule'} = \@email_rule; - - my %userconfig_hash = ( - usercreation => \%save_usercreate, - usermodification => \%save_usermodify, - ); - my $putresult = &Apache::lonnet::put_dom('configuration',\%userconfig_hash, - $dom); -# -# Accumulate details of changes to domain cofiguration for self-creation of usernames in $resulttext -# if ($putresult eq 'ok') { if (keys(%changes) > 0) { $resulttext = &mt('Changes made:').'
      '; if (ref($changes{'cancreate'}) eq 'ARRAY') { - my %lt = &selfcreation_types(); + my %lt = &usercreation_types(); foreach my $type (@{$changes{'cancreate'}}) { my $chgtext; + unless ($type eq 'statustocreate') { + $chgtext = $lt{$type}.', '; + } if ($type eq 'selfcreate') { if (@{$cancreate{$type}} == 0) { - $chgtext .= &mt('Self creation of a new user account is not permitted.'); + $chgtext .= &mt('creation of a new user account is not permitted.'); } else { - $chgtext .= &mt('Self-creation of a new account is permitted for:'). - '
        '; + $chgtext .= &mt('creation of a new account is permitted for:').'
          '; foreach my $case (@{$cancreate{$type}}) { $chgtext .= '
        • '.$selfcreatetypes{$case}.'
        • '; } @@ -8024,10 +6515,7 @@ sub modify_selfcreation { if (grep(/^(login|sso)$/,@{$cancreate{$type}})) { if (ref($cancreate{'statustocreate'}) eq 'ARRAY') { if (@{$cancreate{'statustocreate'}} == 0) { - $chgtext .= '
          '. - ''. - &mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts."). - ''; + $chgtext .= '
          '.&mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts.").''; } } } @@ -8038,13 +6526,11 @@ sub modify_selfcreation { (ref($cancreate{'statustocreate'}) eq 'ARRAY')) { if (@{$cancreate{'selfcreate'}} > 0) { if (@{$cancreate{'statustocreate'}} == 0) { + $chgtext .= &mt("Institutional affiliations permitted to create accounts set to 'None'."); if (!grep(/^email$/,@{$cancreate{'selfcreate'}})) { - $chgtext .= '
          '. - ''. - &mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts."). - ''; - } + $chgtext .= '
          '.&mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts.").''; + } } elsif (ref($usertypes) eq 'HASH') { if (grep(/^(login|sso)$/,@{$cancreate{'selfcreate'}})) { $chgtext .= &mt('Creation of a new account for an institutional user is restricted to the following institutional affiliation(s):'); @@ -8061,9 +6547,7 @@ sub modify_selfcreation { } $chgtext .= '
        '; if (!grep(/^(login|sso)$/,@{$cancreate{'selfcreate'}})) { - $chgtext .= '
        '. - &mt('However, users authenticated by institutional login/single sign on are not currently permitted to create accounts.'). - ''; + $chgtext .= '
        '.&mt('However, users authenticated by institutional login/single sign on are not currently permitted to create accounts.').''; } } } else { @@ -8074,70 +6558,51 @@ sub modify_selfcreation { } } } - } elsif ($type eq 'captcha') { - if ($savecaptcha{$type} eq 'notused') { - $chgtext .= &mt('No CAPTCHA validation in use for self-creation screen.'); - } else { - my %captchas = &captcha_phrases(); - if ($captchas{$savecaptcha{$type}}) { - $chgtext .= &mt("Validation for self-creation screen set to $captchas{$savecaptcha{$type}}."); - } else { - $chgtext .= &mt('Validation for self-creation screen set to unknown type.'); - } - } - } elsif ($type eq 'recaptchakeys') { - my ($privkey,$pubkey); - if (ref($savecaptcha{$type}) eq 'HASH') { - $pubkey = $savecaptcha{$type}{'public'}; - $privkey = $savecaptcha{$type}{'private'}; - } - $chgtext .= &mt('ReCAPTCHA keys changes').'
          '; - if (!$pubkey) { - $chgtext .= '
        • '.&mt('Public key deleted').'
        • '; - } else { - $chgtext .= '
        • '.&mt('Public key set to [_1]',$pubkey).'
        • '; - } - if (!$privkey) { - $chgtext .= '
        • '.&mt('Private key deleted').'
        • '; - } else { - $chgtext .= '
        • '.&mt('Private key set to [_1]',$pubkey).'
        • '; - } - $chgtext .= '
        '; - } elsif ($type eq 'emailusername') { - if (ref($cancreate{'emailusername'}) eq 'HASH') { - if (ref($types) eq 'ARRAY') { - foreach my $type (@{$types}) { - if (ref($cancreate{'emailusername'}{$type}) eq 'HASH') { - if (keys(%{$cancreate{'emailusername'}{$type}}) > 0) { - $chgtext .= &mt('When self-creating account with e-mail as username, the following information will be provided by [_1]:',$usertypes->{$type}). - '
          '; - foreach my $field (@{$infofields}) { - if ($cancreate{'emailusername'}{$type}{$field}) { - $chgtext .= '
        • '.$infotitles->{$field}.'
        • '; - } - } - } - $chgtext .= '
        '; - } else { - $chgtext .= &mt('When self creating account with e-mail as username, no information besides e-mail address will be provided by [_1].',$usertypes->{$type}).'
        '; - } - } - } - } - } elsif ($type eq 'notify') { - $chgtext = &mt('No Domain Coordinators will receive notification of username requests requiring approval.'); - if (ref($changes{'cancreate'}) eq 'ARRAY') { - if ((grep(/^notify$/,@{$changes{'cancreate'}})) && (ref($cancreate{'notify'}) eq 'HASH')) { - if ($cancreate{'notify'}{'approval'}) { - $chgtext = &mt('Notification of username requests requiring approval will be sent to: ').$cancreate{'notify'}{'approval'}; - } - } + } else { + if ($cancreate{$type} eq 'none') { + $chgtext .= &mt('creation of new users is not permitted, except by a Domain Coordinator.'); + } elsif ($cancreate{$type} eq 'any') { + $chgtext .= &mt('creation of new users is permitted for both institutional and non-institutional usernames.'); + } elsif ($cancreate{$type} eq 'official') { + $chgtext .= &mt('creation of new users is only permitted for institutional usernames.'); + } elsif ($cancreate{$type} eq 'unofficial') { + $chgtext .= &mt('creation of new users is only permitted for non-institutional usernames.'); } } - if ($chgtext) { - $resulttext .= '
      • '.$chgtext.'
      • '; + $resulttext .= '
      • '.$chgtext.'
      • '; + } + } + if (ref($changes{'username_rule'}) eq 'ARRAY') { + my ($rules,$ruleorder) = + &Apache::lonnet::inst_userrules($dom,'username'); + my $chgtext = '
          '; + foreach my $type (@username_rule) { + if (ref($rules->{$type}) eq 'HASH') { + $chgtext .= '
        • '.$rules->{$type}{'name'}.'
        • '; } } + $chgtext .= '
        '; + if (@username_rule > 0) { + $resulttext .= '
      • '.&mt('Usernames with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'
      • '; + } else { + $resulttext .= '
      • '.&mt('There are now no username formats restricted to verified users in the institutional directory.').'
      • '; + } + } + if (ref($changes{'id_rule'}) eq 'ARRAY') { + my ($idrules,$idruleorder) = + &Apache::lonnet::inst_userrules($dom,'id'); + my $chgtext = '
          '; + foreach my $type (@id_rule) { + if (ref($idrules->{$type}) eq 'HASH') { + $chgtext .= '
        • '.$idrules->{$type}{'name'}.'
        • '; + } + } + $chgtext .= '
        '; + if (@id_rule > 0) { + $resulttext .= '
      • '.&mt('IDs with the following formats are restricted to verified users in the institutional directory: ').$chgtext.'
      • '; + } else { + $resulttext .= '
      • '.&mt('There are now no ID formats restricted to verified users in the institutional directory.').'
      • '; + } } if (ref($changes{'email_rule'}) eq 'ARRAY') { my ($emailrules,$emailruleorder) = @@ -8150,48 +6615,37 @@ sub modify_selfcreation { } $chgtext .= '
      '; if (@email_rule > 0) { - $resulttext .= '
    • '. - &mt('Accounts may not be created by users self-enrolling with e-mail addresses of the following types: '). - $chgtext. - '
    • '; - } else { - $resulttext .= '
    • '. - &mt('There are now no restrictions on e-mail addresses which may be used as a username when self-enrolling.'). - '
    • '; - } - } - if (ref($changes{'selfcreate'}) eq 'ARRAY') { - $resulttext .= '
    • '.&mt('When self-creating institutional account:').'
        '; - my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles(); - foreach my $type (@{$changes{'selfcreate'}}) { - my $typename = $type; - if (ref($usertypes) eq 'HASH') { - if ($usertypes->{$type} ne '') { - $typename = $usertypes->{$type}; - } - } - my @modifiable; - $resulttext .= '
      • '. - &mt('Self-creation of account by users with status: [_1]', - ''.$typename.''). - ' - '.&mt('modifiable fields (if institutional data blank): '); - foreach my $field (@fields) { - if ($save_usermodify{'selfcreate'}{$type}{$field}) { - push(@modifiable,''.$fieldtitles{$field}.''); + $resulttext .= '
      • '.&mt('Accounts may not be created by users self-enrolling with e-mail addresses of the following types: ').$chgtext.'
      • '; + } else { + $resulttext .= '
      • '.&mt('There are now no restrictions on e-mail addresses which may be used as a username when self-enrolling.').'
      • '; + } + } + + my %authname = &authtype_names(); + my %context_title = &context_names(); + if (ref($changes{'authtypes'}) eq 'ARRAY') { + my $chgtext = '
          '; + foreach my $type (@{$changes{'authtypes'}}) { + my @allowed; + $chgtext .= '
        • '.$context_title{$type}.' - '.&mt('assignable authentication types: '); + foreach my $auth (@authtypes) { + if ($authhash{$type}{$auth}) { + push(@allowed,$authname{$auth}); } } - if (@modifiable > 0) { - $resulttext .= join(', ',@modifiable); + if (@allowed > 0) { + $chgtext .= join(', ',@allowed).'
        • '; } else { - $resulttext .= &mt('none'); + $chgtext .= &mt('none').''; } - $resulttext .= ''; } - $resulttext .= '
        '; + $chgtext .= '
      '; + $resulttext .= '
    • '.&mt('Authentication types available for assignment to new users').'
      '.$chgtext; + $resulttext .= '
    • '; } $resulttext .= '
    '; } else { - $resulttext = &mt('No changes made to self-creation settings'); + $resulttext = &mt('No changes made to user creation settings'); } } else { $resulttext = ''. @@ -8203,75 +6657,19 @@ sub modify_selfcreation { return $resulttext; } -sub process_captcha { - my ($container,$changes,$newsettings,$current) = @_; - return unless ((ref($changes) eq 'HASH') && (ref($newsettings) eq 'HASH') || (ref($current) eq 'HASH')); - $newsettings->{'captcha'} = $env{'form.'.$container.'_captcha'}; - unless ($newsettings->{'captcha'} eq 'recaptcha' || $newsettings->{'captcha'} eq 'notused') { - $newsettings->{'captcha'} = 'original'; - } - if ($current->{'captcha'} ne $newsettings->{'captcha'}) { - if ($container eq 'cancreate') { - if (ref($changes->{'cancreate'}) eq 'ARRAY') { - push(@{$changes->{'cancreate'}},'captcha'); - } elsif (!defined($changes->{'cancreate'})) { - $changes->{'cancreate'} = ['captcha']; - } - } else { - $changes->{'captcha'} = 1; - } - } - my ($newpub,$newpriv,$currpub,$currpriv); - if ($newsettings->{'captcha'} eq 'recaptcha') { - $newpub = $env{'form.'.$container.'_recaptchapub'}; - $newpriv = $env{'form.'.$container.'_recaptchapriv'}; - $newpub =~ s/\W//g; - $newpriv =~ s/\W//g; - $newsettings->{'recaptchakeys'} = { - public => $newpub, - private => $newpriv, - }; - } - if (ref($current->{'recaptchakeys'}) eq 'HASH') { - $currpub = $current->{'recaptchakeys'}{'public'}; - $currpriv = $current->{'recaptchakeys'}{'private'}; - unless ($newsettings->{'captcha'} eq 'recaptcha') { - $newsettings->{'recaptchakeys'} = { - public => '', - private => '', - } - } - } - if (($newpub ne $currpub) || ($newpriv ne $currpriv)) { - if ($container eq 'cancreate') { - if (ref($changes->{'cancreate'}) eq 'ARRAY') { - push(@{$changes->{'cancreate'}},'recaptchakeys'); - } elsif (!defined($changes->{'cancreate'})) { - $changes->{'cancreate'} = ['recaptchakeys']; - } - } else { - $changes->{'recaptchakeys'} = 1; - } - } - return; -} - sub modify_usermodification { my ($dom,%domconfig) = @_; - my ($resulttext,%curr_usermodification,%changes,%modifyhash); + my ($resulttext,%curr_usermodification,%changes); if (ref($domconfig{'usermodification'}) eq 'HASH') { foreach my $key (keys(%{$domconfig{'usermodification'}})) { - if ($key eq 'selfcreate') { - $modifyhash{$key} = $domconfig{'usermodification'}{$key}; - } else { - $curr_usermodification{$key} = $domconfig{'usermodification'}{$key}; - } + $curr_usermodification{$key} = $domconfig{'usermodification'}{$key}; } } - my @contexts = ('author','course'); + my @contexts = ('author','course','selfcreate'); my %context_title = ( author => 'In author context', course => 'In course context', + selfcreate => 'When self creating account', ); my @fields = ('lastname','firstname','middlename','generation', 'permanentemail','id'); @@ -8279,7 +6677,14 @@ sub modify_usermodification { author => ['ca','aa'], course => ['st','ep','ta','in','cr'], ); + my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); + if (ref($types) eq 'ARRAY') { + push(@{$types},'default'); + $usertypes->{'default'} = $othertitle; + } + $roles{'selfcreate'} = $types; my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles(); + my %modifyhash; foreach my $context (@contexts) { foreach my $role (@{$roles{$context}}) { my @modifiable = &Apache::loncommon::get_env_multiple('form.canmodify_'.$role); @@ -8325,13 +6730,26 @@ sub modify_usermodification { if (ref($changes{$context}) eq 'ARRAY') { foreach my $role (@{$changes{$context}}) { my $rolename; - if ($role eq 'cr') { - $rolename = &mt('Custom'); + if ($context eq 'selfcreate') { + $rolename = $role; + if (ref($usertypes) eq 'HASH') { + if ($usertypes->{$role} ne '') { + $rolename = $usertypes->{$role}; + } + } } else { - $rolename = &Apache::lonnet::plaintext($role); + if ($role eq 'cr') { + $rolename = &mt('Custom'); + } else { + $rolename = &Apache::lonnet::plaintext($role); + } } my @modifiable; - $resulttext .= '
  • '.&mt('Target user with [_1] role',$rolename).' - '.&mt('modifiable fields: '); + if ($context eq 'selfcreate') { + $resulttext .= '
  • '.&mt('Self-creation of account by users with status: [_1]',$rolename).' - '.&mt('modifiable fields (if institutional data blank): '); + } else { + $resulttext .= '
  • '.&mt('Target user with [_1] role',$rolename).' - '.&mt('modifiable fields: '); + } foreach my $field (@fields) { if ($modifyhash{$context}{$role}{$field}) { push(@modifiable,$fieldtitles{$field}); @@ -8360,9 +6778,9 @@ sub modify_usermodification { } sub modify_defaults { - my ($dom,$lastactref,%domconfig) = @_; + my ($dom,$r) = @_; my ($resulttext,$mailmsgtxt,%newvalues,%changes,@errors); - my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); + my %domdefaults = &Apache::lonnet::get_domain_defaults($dom); my @items = ('auth_def','auth_arg_def','lang_def','timezone_def','datelocale_def','portal_def'); my @authtypes = ('internal','krb4','krb5','localauth'); foreach my $item (@items) { @@ -8422,7 +6840,7 @@ sub modify_defaults { if ($putresult eq 'ok') { if (keys(%changes) > 0) { $resulttext = &mt('Changes made:').'
      '; - my $version = &Apache::lonnet::get_server_loncaparev($dom); + my $version = $r->dir_config('lonVersion'); my $mailmsgtext = "Changes made to domain settings in a LON-CAPA installation - domain: $dom (running version: $version) - dns_domain.tab needs to be updated with the following changes, to support legacy 2.4, 2.5 and 2.6 versions of LON-CAPA.\n\n"; foreach my $item (sort(keys(%changes))) { my $value = $env{'form.'.$item}; @@ -8445,21 +6863,9 @@ sub modify_defaults { $mailmsgtext .= "\n"; my $cachetime = 24*60*60; &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime); - if (ref($lastactref) eq 'HASH') { - $lastactref->{'domdefaults'} = 1; - } if ($changes{'auth_def'} || $changes{'auth_arg_def'} || $changes{'lang_def'} || $changes{'datelocale_def'}) { - my $notify = 1; - if (ref($domconfig{'contacts'}) eq 'HASH') { - if ($domconfig{'contacts'}{'reportupdates'} == 0) { - $notify = 0; - } - } - if ($notify) { - &Apache::lonmsg::sendemail('installrecord@loncapa.org', - "LON-CAPA Domain Settings Change - $dom", - $mailmsgtext); - } + my $sysmail = $r->dir_config('lonSysEMail'); + &Apache::lonmsg::sendemail($sysmail,"LON-CAPA Domain Settings Change - $dom",$mailmsgtext); } } else { $resulttext = &mt('No changes made to default authentication/language/timezone settings'); @@ -8479,7 +6885,7 @@ sub modify_defaults { } sub modify_scantron { - my ($r,$dom,$confname,$lastactref,%domconfig) = @_; + my ($r,$dom,$confname,%domconfig) = @_; my ($resulttext,%confhash,%changes,$errors); my $custom = 'custom.tab'; my $default = 'default.tab'; @@ -8540,9 +6946,6 @@ sub modify_scantron { } $resulttext .= '
    '; &Apache::loncommon::devalidate_domconfig_cache($dom); - if (ref($lastactref) eq 'HASH') { - $lastactref->{'domainconfig'} = 1; - } } else { $resulttext = &mt('No changes made to bubblesheet format file'); } @@ -8910,73 +7313,133 @@ sub modify_serverstatuses { sub modify_helpsettings { my ($r,$dom,$confname,%domconfig) = @_; - my ($resulttext,$errors,%changes,%helphash); - my %defaultchecked = ('submitbugs' => 'on'); - my @offon = ('off','on'); + my ($resulttext,$errors,%changes,%helphash); + + my $customhelpfile = $env{'form.loginhelpurl.filename'}; + my $defaulthelpfile = 'defaulthelp.html'; + my $servadm = $r->dir_config('lonAdmEMail'); + my ($configuserok,$author_ok,$switchserver) = + &config_check($dom,$confname,$servadm); + + my %defaultchecked = ('submitbugs' => 'on'); + my @offon = ('off','on'); + my %title = ( submitbugs => 'Display link for users to submit a bug', + loginhelpurl => 'Unauthenticated login help page set to custom file'); + my @toggles = ('submitbugs'); + + $helphash{'helpsettings'} = {}; + + if (ref($domconfig{'helpsettings'}) ne 'HASH') { + if ($domconfig{'helpsettings'} eq '') { + $domconfig{'helpsettings'} = {}; + } + } + if (ref($domconfig{'helpsettings'}) eq 'HASH') { + foreach my $item (@toggles) { - if ($defaultchecked{$item} eq 'on') { - if ($domconfig{'helpsettings'}{$item} eq '') { - if ($env{'form.'.$item} eq '0') { - $changes{$item} = 1; - } - } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) { - $changes{$item} = 1; - } - } elsif ($defaultchecked{$item} eq 'off') { - if ($domconfig{'helpsettings'}{$item} eq '') { - if ($env{'form.'.$item} eq '1') { - $changes{$item} = 1; - } - } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) { - $changes{$item} = 1; - } - } - if (($env{'form.'.$item} eq '0') || ($env{'form.'.$item} eq '1')) { - $helphash{'helpsettings'}{$item} = $env{'form.'.$item}; + + if ($defaultchecked{$item} eq 'on') { + if (($domconfig{'helpsettings'}{$item} eq '') && + ($env{'form.'.$item} eq '0')) { + $changes{$item} = 1; + } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) { + $changes{$item} = 1; + } + } elsif ($defaultchecked{$item} eq 'off') { + if (($domconfig{'helpsettings'}{$item} eq '') && + ($env{'form.'.$item} eq '1')) { + $changes{$item} = 1; + } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) { + $changes{$item} = 1; + } + } + $helphash{'helpsettings'}{$item} = $env{'form.'.$item}; + } + + if ($customhelpfile ne '') { + my $error; + if ($configuserok eq 'ok') { + if ($switchserver) { + $error = &mt("Upload of custom help file is not permitted to this server: [_1]",$switchserver); + } else { + if ($author_ok eq 'ok') { + my ($result,$loginhelpurl) = + &publishlogo($r,'upload','loginhelpurl',$dom, + $confname,'help','','',$customhelpfile); + if ($result eq 'ok') { + $helphash{'helpsettings'}{'loginhelpurl'} = $loginhelpurl; + $changes{'loginhelpurl'} = 1; + } else { + $error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$customhelpfile,$result); + } + } else { + $error = &mt("Upload of [_1] failed because an author role could not be assigned to a Domain Configuration user ([_2]) in domain: [_3]. Error was: [_4].",$customhelpfile,$confname,$dom,$author_ok); + } + } + } else { + $error = &mt("Upload of [_1] failed because a Domain Configuration user ([_2]) could not be created in domain: [_3]. Error was: [_4].",$customhelpfile,$confname,$dom,$configuserok); + } + if ($error) { + &Apache::lonnet::logthis($error); + $errors .= '
  • '.$error.'
  • '; + } + } + + if ($domconfig{'helpsettings'}{'loginhelpurl'} ne '') { + if ($env{'form.loginhelpurl_del'}) { + $helphash{'helpsettings'}{'loginhelpurl'} = ''; + $changes{'loginhelpurl'} = 1; } } } + + my $putresult; + if (keys(%changes) > 0) { - $putresult = &Apache::lonnet::put_dom('configuration',\%helphash,$dom); - if ($putresult eq 'ok') { - $resulttext = &mt('Changes made:').'
      '; - foreach my $item (sort(keys(%changes))) { - if ($item eq 'submitbugs') { - $resulttext .= '
    • '.&mt('Display link to: [_1] set to "'.$offon[$env{'form.'.$item}].'".', - &Apache::loncommon::modal_link('http://bugs.loncapa.org', - &mt('LON-CAPA bug tracker'),600,500)).'
    • '; - } - } - $resulttext .= '
    '; - } else { - $resulttext = &mt('No changes made to help settings'); - $errors .= '
  • '. - &mt('An error occurred storing the settings: [_1]', - $putresult).'
  • '; - } + $putresult = &Apache::lonnet::put_dom('configuration',\%helphash,$dom); + } else { + $putresult = 'ok'; + } + + if ($putresult eq 'ok') { + if (keys(%changes) > 0) { + $resulttext = &mt('Changes made:').'
      '; + foreach my $item (sort(keys(%changes))) { + if ($item eq 'submitbugs') { + $resulttext .= '
    • '.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'
    • '; + } + if ($item eq 'loginhelpurl') { + if ($helphash{'helpsettings'}{'loginhelpurl'} eq '') { + $resulttext .= '
    • '.&mt('[_1] help file removed; [_2] file will be used for the unathorized help page in this domain.',$customhelpfile,$defaulthelpfile).'
    • '; + } else { + $resulttext .= '
    • '.&mt("$title{$item} [_1]",$customhelpfile).'
    • '; + } + } + } + $resulttext .= '
    '; + } else { + $resulttext = &mt('No changes made to help settings'); + } + } else { + $resulttext = ''. + &mt('An error occurred: [_1]',$putresult).''; } if ($errors) { - $resulttext .= '
    '.&mt('The following errors occurred: ').'
      '. + $resulttext .= &mt('The following errors occurred: ').'
        '. $errors.'
      '; } return $resulttext; } sub modify_coursedefaults { - my ($dom,$lastactref,%domconfig) = @_; + my ($dom,%domconfig) = @_; my ($resulttext,$errors,%changes,%defaultshash); my %defaultchecked = ('canuse_pdfforms' => 'off'); + my @offon = ('off','on'); my @toggles = ('canuse_pdfforms'); - my @numbers = ('anonsurvey_threshold','uploadquota_official','uploadquota_unofficial', - 'uploadquota_community','uploadquota_textbook'); - my @types = ('official','unofficial','community','textbook'); - my %staticdefaults = ( - anonsurvey_threshold => 10, - uploadquota => 500, - ); $defaultshash{'coursedefaults'} = {}; @@ -8992,7 +7455,7 @@ sub modify_coursedefaults { if (($domconfig{'coursedefaults'}{$item} eq '') && ($env{'form.'.$item} eq '0')) { $changes{$item} = 1; - } elsif ($domconfig{'coursedefaults'}{$item} ne $env{'form.'.$item}) { + } elsif ($domconfig{'coursdefaults'}{$item} ne $env{'form.'.$item}) { $changes{$item} = 1; } } elsif ($defaultchecked{$item} eq 'off') { @@ -9005,90 +7468,28 @@ sub modify_coursedefaults { } $defaultshash{'coursedefaults'}{$item} = $env{'form.'.$item}; } - foreach my $item (@numbers) { - my ($currdef,$newdef); - $newdef = $env{'form.'.$item}; - if ($item eq 'anonsurvey_threshold') { - $currdef = $domconfig{'coursedefaults'}{$item}; - $newdef =~ s/\D//g; - if ($newdef eq '' || $newdef < 1) { - $newdef = 1; - } - $defaultshash{'coursedefaults'}{$item} = $newdef; - } else { - my ($type) = ($item =~ /^\Quploadquota_\E(\w+)$/); - if (ref($domconfig{'coursedefaults'}{'uploadquota'}) eq 'HASH') { - $currdef = $domconfig{'coursedefaults'}{'uploadquota'}{$type}; - } - $newdef =~ s/[^\w.\-]//g; - $defaultshash{'coursedefaults'}{'uploadquota'}{$type} = $newdef; - } - if ($currdef ne $newdef) { - my $staticdef; - if ($item eq 'anonsurvey_threshold') { - unless (($currdef eq '') && ($newdef == $staticdefaults{$item})) { - $changes{$item} = 1; - } - } else { - unless (($currdef eq '') && ($newdef == $staticdefaults{'uploadquota'})) { - $changes{'uploadquota'} = 1; - } - } + my $currdefresponder = $domconfig{'coursedefaults'}{'anonsurvey_threshold'}; + my $newdefresponder = $env{'form.anonsurvey_threshold'}; + $newdefresponder =~ s/\D//g; + if ($newdefresponder eq '' || $newdefresponder < 1) { + $newdefresponder = 1; + } + $defaultshash{'coursedefaults'}{'anonsurvey_threshold'} = $newdefresponder; + if ($currdefresponder ne $newdefresponder) { + unless ($currdefresponder eq '' && $newdefresponder == 10) { + $changes{'anonsurvey_threshold'} = 1; } } - my $officialcreds = $env{'form.official_credits'}; - $officialcreds =~ s/[^\d.]+//g; - my $unofficialcreds = $env{'form.unofficial_credits'}; - $unofficialcreds =~ s/[^\d.]+//g; - my $textbookcreds = $env{'form.textbook_credits'}; - $textbookcreds =~ s/[^\d.]+//g; - if (ref($domconfig{'coursedefaults'}{'coursecredits'} ne 'HASH') && - ($env{'form.coursecredits'} eq '1')) { - $changes{'coursecredits'} = 1; - } else { - if (($domconfig{'coursedefaults'}{'coursecredits'}{'official'} ne $officialcreds) || - ($domconfig{'coursedefaults'}{'coursecredits'}{'unofficial'} ne $unofficialcreds) || - ($domconfig{'coursedefaults'}{'coursecredits'}{'textbook'} ne $textbookcreds)) { - $changes{'coursecredits'} = 1; - } - } - $defaultshash{'coursedefaults'}{'coursecredits'} = { - official => $officialcreds, - unofficial => $unofficialcreds, - textbook => $textbookcreds, - } } my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash, $dom); if ($putresult eq 'ok') { if (keys(%changes) > 0) { - my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); - if (($changes{'canuse_pdfforms'}) || ($changes{'coursecredits'}) || ($changes{'uploadquota'})) { - if ($changes{'canuse_pdfforms'}) { - $domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'}; - } - if ($changes{'coursecredits'}) { - if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') { - $domdefaults{'officialcredits'} = - $defaultshash{'coursedefaults'}{'coursecredits'}{'official'}; - $domdefaults{'unofficialcredits'} = - $defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'}; - $domdefaults{'textbookcredits'} = - $domdefaults{'coursedefaults'}{'coursecredits'}{'textbook'}; - } - } - if ($changes{'uploadquota'}) { - if (ref($defaultshash{'coursedefaults'}{'uploadquota'}) eq 'HASH') { - foreach my $type (@types) { - $domdefaults{$type.'quota'}=$defaultshash{'coursedefaults'}{'uploadquota'}{$type}; - } - } - } + if ($changes{'canuse_pdfforms'}) { + my %domdefaults = &Apache::lonnet::get_domain_defaults($dom); + $domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'}; my $cachetime = 24*60*60; &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime); - if (ref($lastactref) eq 'HASH') { - $lastactref->{'domdefaults'} = 1; - } } $resulttext = &mt('Changes made:').'
        '; foreach my $item (sort(keys(%changes))) { @@ -9099,37 +7500,7 @@ sub modify_coursedefaults { $resulttext .= '
      • '.&mt('Course/Community users can create/upload PDF forms set to "off"').'
      • '; } } elsif ($item eq 'anonsurvey_threshold') { - $resulttext .= '
      • '.&mt('Responder count required for display of anonymous survey submissions set to [_1].',$defaultshash{'coursedefaults'}{'anonsurvey_threshold'}).'
      • '; - } elsif ($item eq 'uploadquota') { - if (ref($defaultshash{'coursedefaults'}{'uploadquota'}) eq 'HASH') { - $resulttext .= '
      • '.&mt('Default quota for content uploaded to a course/community via Course Editor set as follows:').'
          '. - '
        • '.&mt('Official courses: [_1] MB',''.$defaultshash{'coursedefaults'}{'uploadquota'}{'official'}.'').'
        • '. - '
        • '.&mt('Unofficial courses: [_1] MB',''.$defaultshash{'coursedefaults'}{'uploadquota'}{'unofficial'}.'').'
        • '. - '
        • '.&mt('Textbook courses: [_1] MB',''.$defaultshash{'coursedefaults'}{'uploadquota'}{'textbook'}.'').'
        • '. - - '
        • '.&mt('Communities: [_1] MB',''.$defaultshash{'coursedefaults'}{'uploadquota'}{'community'}.'').'
        • '. - '
        '. - '
      • '; - } else { - $resulttext .= '
      • '.&mt('Default quota for content uploaded via Course Editor remains default: [_1] MB',$staticdefaults{'uploadquota'}).'
      • '; - } - } elsif ($item eq 'coursecredits') { - if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') { - if (($domdefaults{'officialcredits'} eq '') && - ($domdefaults{'unofficialcredits'} eq '') && - ($domdefaults{'textbookcredits'} eq '')) { - $resulttext .= '
      • '.&mt('Student credits not in use for courses in this domain').'
      • '; - } else { - $resulttext .= '
      • '.&mt('Student credits can be set per course by a Domain Coordinator, with the following defaults applying:').'
          '. - '
        • '.&mt('Official courses: [_1]',$defaultshash{'coursedefaults'}{'coursecredits'}{'official'}).'
        • '. - '
        • '.&mt('Unofficial courses: [_1]',$defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'}).'
        • '. - '
        • '.&mt('Textbook courses: [_1]',$defaultshash{'coursedefaults'}{'coursecredits'}{'textbook'}).'
        • '. - '
        '. - '
      • '; - } - } else { - $resulttext .= '
      • '.&mt('Student credits not in use for courses in this domain').'
      • '; - } + $resulttext .= '
      • '.&mt('Responder count required for display of anonymous survey submissions set to [_1].',$defaultshash{'coursedefaults'}{'anonsurvey_threshold'}).'
      • '; } } $resulttext .= '
      '; @@ -9144,7 +7515,7 @@ sub modify_coursedefaults { } sub modify_usersessions { - my ($dom,$lastactref,%domconfig) = @_; + my ($dom,%domconfig) = @_; my @hostingtypes = ('version','excludedomain','includedomain'); my @offloadtypes = ('primary','default'); my %types = ( @@ -9161,7 +7532,7 @@ sub modify_usersessions { foreach my $prefix (@prefixes) { $defaultshash{'usersessions'}{$prefix} = {}; } - my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); + my %domdefaults = &Apache::lonnet::get_domain_defaults($dom); my $resulttext; my %iphost = &Apache::lonnet::get_iphost(); foreach my $prefix (@prefixes) { @@ -9337,9 +7708,6 @@ sub modify_usersessions { } my $cachetime = 24*60*60; &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime); - if (ref($lastactref) eq 'HASH') { - $lastactref->{'domdefaults'} = 1; - } if (keys(%changes) > 0) { my %lt = &usersession_titles(); $resulttext = &mt('Changes made:').'
        '; @@ -9351,8 +7719,7 @@ sub modify_usersessions { foreach my $lonhost (sort(keys(%{$changes{$prefix}}))) { $resulttext .= '
      • '.$lonhost.' '; my $lonhostdom = &Apache::lonnet::host_domain($lonhost); - my $cachekey = &escape('spares').':'.&escape($lonhostdom); - &Apache::lonnet::remote_devalidate_cache($lonhost,[$cachekey]); + &Apache::lonnet::remote_devalidate_cache($lonhost,'spares',$lonhostdom); if (ref($changes{$prefix}{$lonhost}) eq 'HASH') { foreach my $type (@{$types{$prefix}}) { if ($changes{$prefix}{$lonhost}{$type}) { @@ -9426,194 +7793,186 @@ sub modify_loadbalancing { my @sparestypes = ('primary','default'); my %typetitles = &sparestype_titles(); my $resulttext; - my (%currbalancer,%currtargets,%currrules,%existing); - if (ref($domconfig{'loadbalancing'}) eq 'HASH') { - %existing = %{$domconfig{'loadbalancing'}}; - } - &get_loadbalancers_config(\%servers,\%existing,\%currbalancer, - \%currtargets,\%currrules); - my ($saveloadbalancing,%defaultshash,%changes); - my ($alltypes,$othertypes,$titles) = - &loadbalancing_titles($dom,$intdom,$usertypes,$types); - my %ruletitles = &offloadtype_text(); - my @deletions = &Apache::loncommon::get_env_multiple('form.loadbalancing_delete'); - for (my $i=0; $i<$env{'form.loadbalancing_total'}; $i++) { - my $balancer = $env{'form.loadbalancing_lonhost_'.$i}; - if ($balancer eq '') { - next; - } - if (!exists($servers{$balancer})) { - if (exists($currbalancer{$balancer})) { - push(@{$changes{'delete'}},$balancer); + if (keys(%servers) > 1) { + my ($currbalancer,$currtargets,$currrules); + if (ref($domconfig{'loadbalancing'}) eq 'HASH') { + $currbalancer = $domconfig{'loadbalancing'}{'lonhost'}; + $currtargets = $domconfig{'loadbalancing'}{'targets'}; + $currrules = $domconfig{'loadbalancing'}{'rules'}; + } else { + ($currbalancer,$currtargets) = + &Apache::lonnet::get_lonbalancer_config(\%servers); + } + my ($saveloadbalancing,%defaultshash,%changes); + my ($alltypes,$othertypes,$titles) = + &loadbalancing_titles($dom,$intdom,$usertypes,$types); + my %ruletitles = &offloadtype_text(); + my $balancer = $env{'form.loadbalancing_lonhost'}; + if (!$servers{$balancer}) { + undef($balancer); + } + if ($currbalancer ne $balancer) { + $changes{'lonhost'} = 1; + } + $defaultshash{'loadbalancing'}{'lonhost'} = $balancer; + if ($balancer ne '') { + unless (ref($domconfig{'loadbalancing'}) eq 'HASH') { + $saveloadbalancing = 1; } - next; - } - if ((@deletions > 0) && (grep(/^\Q$i\E$/,@deletions))) { - push(@{$changes{'delete'}},$balancer); - next; - } - if (!exists($currbalancer{$balancer})) { - push(@{$changes{'add'}},$balancer); - } - $defaultshash{'loadbalancing'}{$balancer}{'targets'}{'primary'} = []; - $defaultshash{'loadbalancing'}{$balancer}{'targets'}{'default'} = []; - $defaultshash{'loadbalancing'}{$balancer}{'rules'} = {}; - unless (ref($domconfig{'loadbalancing'}) eq 'HASH') { - $saveloadbalancing = 1; - } - foreach my $sparetype (@sparestypes) { - my @targets = &Apache::loncommon::get_env_multiple('form.loadbalancing_target_'.$i.'_'.$sparetype); - my @offloadto; - foreach my $target (@targets) { - if (($servers{$target}) && ($target ne $balancer)) { - if ($sparetype eq 'default') { - if (ref($defaultshash{'loadbalancing'}{$balancer}{'targets'}{'primary'}) eq 'ARRAY') { - next if (grep(/^\Q$target\E$/,@{$defaultshash{'loadbalancing'}{$balancer}{'targets'}{'primary'}})); + foreach my $sparetype (@sparestypes) { + my @targets = &Apache::loncommon::get_env_multiple('form.loadbalancing_target_'.$sparetype); + my @offloadto; + foreach my $target (@targets) { + if (($servers{$target}) && ($target ne $balancer)) { + if ($sparetype eq 'default') { + if (ref($defaultshash{'loadbalancing'}{'targets'}{'primary'}) eq 'ARRAY') { + next if (grep(/^\Q$target\E$/,@{$defaultshash{'loadbalancing'}{'targets'}{'primary'}})); + } + } + unless(grep(/^\Q$target\E$/,@offloadto)) { + push(@offloadto,$target); } } - unless(grep(/^\Q$target\E$/,@offloadto)) { - push(@offloadto,$target); - } + $defaultshash{'loadbalancing'}{'targets'}{$sparetype} = \@offloadto; } - $defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype} = \@offloadto; + } + } else { + foreach my $sparetype (@sparestypes) { + $defaultshash{'loadbalancing'}{'targets'}{$sparetype} = []; } } - if (ref($currtargets{$balancer}) eq 'HASH') { + if (ref($currtargets) eq 'HASH') { foreach my $sparetype (@sparestypes) { - if (ref($currtargets{$balancer}{$sparetype}) eq 'ARRAY') { - my @targetdiffs = &Apache::loncommon::compare_arrays($currtargets{$balancer}{$sparetype},$defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype}); + if (ref($currtargets->{$sparetype}) eq 'ARRAY') { + my @targetdiffs = &Apache::loncommon::compare_arrays($currtargets->{$sparetype},$defaultshash{'loadbalancing'}{'targets'}{$sparetype}); if (@targetdiffs > 0) { - $changes{'curr'}{$balancer}{'targets'} = 1; + $changes{'targets'} = 1; } - } elsif (ref($defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype}) eq 'ARRAY') { - if (@{$defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype}} > 0) { - $changes{'curr'}{$balancer}{'targets'} = 1; + } elsif (ref($defaultshash{'loadbalancing'}{'targets'}{$sparetype}) eq 'ARRAY') { + if (@{$defaultshash{'loadbalancing'}{'targets'}{$sparetype}} > 0) { + $changes{'targets'} = 1; } } } } else { - if (ref($defaultshash{'loadbalancing'}{$balancer}) eq 'HASH') { - foreach my $sparetype (@sparestypes) { - if (ref($defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype}) eq 'ARRAY') { - if (@{$defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype}} > 0) { - $changes{'curr'}{$balancer}{'targets'} = 1; - } + foreach my $sparetype (@sparestypes) { + if (ref($defaultshash{'loadbalancing'}{'targets'}{$sparetype}) eq 'ARRAY') { + if (@{$defaultshash{'loadbalancing'}{'targets'}{$sparetype}} > 0) { + $changes{'targets'} = 1; } } - } + } } my $ishomedom; - if (&Apache::lonnet::host_domain($balancer) eq $dom) { - $ishomedom = 1; + if ($balancer ne '') { + if (&Apache::lonnet::host_domain($balancer) eq $dom) { + $ishomedom = 1; + } } if (ref($alltypes) eq 'ARRAY') { foreach my $type (@{$alltypes}) { my $rule; - unless ((($type eq '_LC_external') || ($type eq '_LC_internetdom')) && + if ($balancer ne '') { + unless ((($type eq '_LC_external') || ($type eq '_LC_internetdom')) && (!$ishomedom)) { - $rule = $env{'form.loadbalancing_rules_'.$i.'_'.$type}; - } - if ($rule eq 'specific') { - $rule = $env{'form.loadbalancing_singleserver_'.$i.'_'.$type}; + $rule = $env{'form.loadbalancing_rules_'.$type}; + } + if ($rule eq 'specific') { + $rule = $env{'form.loadbalancing_singleserver_'.$type}; + } } - $defaultshash{'loadbalancing'}{$balancer}{'rules'}{$type} = $rule; - if (ref($currrules{$balancer}) eq 'HASH') { - if ($rule ne $currrules{$balancer}{$type}) { - $changes{'curr'}{$balancer}{'rules'}{$type} = 1; + $defaultshash{'loadbalancing'}{'rules'}{$type} = $rule; + if (ref($currrules) eq 'HASH') { + if ($rule ne $currrules->{$type}) { + $changes{'rules'}{$type} = 1; } } elsif ($rule ne '') { - $changes{'curr'}{$balancer}{'rules'}{$type} = 1; + $changes{'rules'}{$type} = 1; } } } - } - my $nochgmsg = &mt('No changes made to Load Balancer settings.'); - if ((keys(%changes) > 0) || ($saveloadbalancing)) { - unless (ref($defaultshash{'loadbalancing'}) eq 'HASH') { - $defaultshash{'loadbalancing'} = {}; - } - my $putresult = &Apache::lonnet::put_dom('configuration', - \%defaultshash,$dom); - if ($putresult eq 'ok') { - if (keys(%changes) > 0) { - if (ref($changes{'delete'}) eq 'ARRAY') { - foreach my $balancer (sort(@{$changes{'delete'}})) { - $resulttext .= '
      • '.&mt('Load Balancing discontinued for: [_1]',$balancer).'
      • '; - my $cachekey = &escape('loadbalancing').':'.&escape($dom); - &Apache::lonnet::remote_devalidate_cache($balancer,[$cachekey]); - } - } - if (ref($changes{'add'}) eq 'ARRAY') { - foreach my $balancer (sort(@{$changes{'add'}})) { - $resulttext .= '
      • '.&mt('Load Balancing enabled for: [_1]',$balancer); - } - } - if (ref($changes{'curr'}) eq 'HASH') { - foreach my $balancer (sort(keys(%{$changes{'curr'}}))) { - if (ref($changes{'curr'}{$balancer}) eq 'HASH') { - if ($changes{'curr'}{$balancer}{'targets'}) { - my %offloadstr; - foreach my $sparetype (@sparestypes) { - if (ref($defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype}) eq 'ARRAY') { - if (@{$defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype}} > 0) { - $offloadstr{$sparetype} = join(', ',@{$defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype}}); - } - } + my $nochgmsg = &mt('No changes made to Load Balancer settings.'); + if ((keys(%changes) > 0) || ($saveloadbalancing)) { + my $putresult = &Apache::lonnet::put_dom('configuration', + \%defaultshash,$dom); + if ($putresult eq 'ok') { + if (keys(%changes) > 0) { + if ($changes{'lonhost'}) { + if ($currbalancer ne '') { + &Apache::lonnet::remote_devalidate_cache($currbalancer,'loadbalancing',$dom); + } + if ($balancer eq '') { + $resulttext .= '
      • '.&mt('Load Balancing with dedicated server discontinued').'
      • '; + } else { + &Apache::lonnet::remote_devalidate_cache($balancer,'loadbalancing',$dom); + $resulttext .= '
      • '.&mt('Dedicated Load Balancer server set to [_1]',$balancer); + } + } else { + &Apache::lonnet::remote_devalidate_cache($balancer,'loadbalancing',$dom); + } + if (($changes{'targets'}) && ($balancer ne '')) { + my %offloadstr; + foreach my $sparetype (@sparestypes) { + if (ref($defaultshash{'loadbalancing'}{'targets'}{$sparetype}) eq 'ARRAY') { + if (@{$defaultshash{'loadbalancing'}{'targets'}{$sparetype}} > 0) { + $offloadstr{$sparetype} = join(', ',@{$defaultshash{'loadbalancing'}{'targets'}{$sparetype}}); } - if (keys(%offloadstr) == 0) { - $resulttext .= '
      • '.&mt("Servers to which Load Balance server offloads set to 'None', by default").'
      • '; + } + } + if (keys(%offloadstr) == 0) { + $resulttext .= '
      • '.&mt("Servers to which Load Balance server offloads set to 'None', by default").'
      • '; + } else { + my $showoffload; + foreach my $sparetype (@sparestypes) { + $showoffload .= ''.$typetitles{$sparetype}.': '; + if (defined($offloadstr{$sparetype})) { + $showoffload .= $offloadstr{$sparetype}; } else { - my $showoffload; - foreach my $sparetype (@sparestypes) { - $showoffload .= ''.$typetitles{$sparetype}.': '; - if (defined($offloadstr{$sparetype})) { - $showoffload .= $offloadstr{$sparetype}; - } else { - $showoffload .= &mt('None'); - } - $showoffload .= (' 'x3); - } - $resulttext .= '
      • '.&mt('By default, Load Balancer: [_1] set to offload to - [_2]',$balancer,$showoffload).'
      • '; + $showoffload .= &mt('None'); } + $showoffload .= (' 'x3); } + $resulttext .= '
      • '.&mt('By default, Load Balancer server set to offload to: [_1]',$showoffload).'
      • '; } - if (ref($changes{'curr'}{$balancer}{'rules'}) eq 'HASH') { - if ((ref($alltypes) eq 'ARRAY') && (ref($titles) eq 'HASH')) { - foreach my $type (@{$alltypes}) { - if ($changes{'curr'}{$balancer}{'rules'}{$type}) { - my $rule = $defaultshash{'loadbalancing'}{$balancer}{'rules'}{$type}; - my $balancetext; - if ($rule eq '') { - $balancetext = $ruletitles{'default'}; - } elsif (($rule eq 'homeserver') || ($rule eq 'externalbalancer') || - ($rule eq 'balancer') || ($rule eq 'offloadedto')) { - $balancetext = $ruletitles{$rule}; - } else { - $balancetext = &mt('offload to [_1]',$defaultshash{'loadbalancing'}{$balancer}{'rules'}{$type}); - } - $resulttext .= '
      • '.&mt('Load Balancer: [_1] -- balancing for [_2] set to - "[_3]"',$balancer,$titles->{$type},$balancetext).'
      • '; + } + if ((ref($changes{'rules'}) eq 'HASH') && ($balancer ne '')) { + if ((ref($alltypes) eq 'ARRAY') && (ref($titles) eq 'HASH')) { + foreach my $type (@{$alltypes}) { + if ($changes{'rules'}{$type}) { + my $rule = $defaultshash{'loadbalancing'}{'rules'}{$type}; + my $balancetext; + if ($rule eq '') { + $balancetext = $ruletitles{'default'}; + } elsif (($rule eq 'homeserver') || ($rule eq 'externalbalancer')) { + $balancetext = $ruletitles{$rule}; + } else { + $balancetext = &mt('offload to [_1]',$defaultshash{'loadbalancing'}{'rules'}{$type}); } + $resulttext .= '
      • '.&mt('Load Balancing for [_1] set to: [_2]',$titles->{$type},$balancetext).'
      • '; } } } - my $cachekey = &escape('loadbalancing').':'.&escape($dom); - &Apache::lonnet::remote_devalidate_cache($balancer,[$cachekey]); } - } - if ($resulttext ne '') { - $resulttext = &mt('Changes made:').'
          '.$resulttext.'
        '; + if ($resulttext ne '') { + $resulttext = &mt('Changes made:').'
          '.$resulttext.'
        '; + } else { + $resulttext = $nochgmsg; + } } else { $resulttext = $nochgmsg; + if ($balancer ne '') { + &Apache::lonnet::remote_devalidate_cache($balancer,'loadbalancing',$dom); + } } } else { - $resulttext = $nochgmsg; + $resulttext = ''. + &mt('An error occurred: [_1]',$putresult).''; } } else { - $resulttext = ''. - &mt('An error occurred: [_1]',$putresult).''; + $resulttext = $nochgmsg; } } else { - $resulttext = $nochgmsg; + $resulttext = &mt('Load Balancing unavailable as this domain only has one server.'); } return $resulttext; } @@ -9652,7 +8011,7 @@ sub recurse_cat_deletes { delete($coursecategories->{$subitem}); $deletions->{$subitem} = 1; &recurse_cat_deletes($subitem,$coursecategories,$deletions); - } + } } } return; @@ -9660,104 +8019,72 @@ sub recurse_cat_deletes { sub get_active_dcs { my ($dom) = @_; - my $now = time; - my %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc'],$now,$now); + my %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc']); my %domcoords; my $numdcs = 0; + my $now = time; foreach my $server (keys(%dompersonnel)) { foreach my $user (sort(keys(%{$dompersonnel{$server}}))) { my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,$user); - $domcoords{$uname.':'.$udom} = $dompersonnel{$server}{$user}; + my ($end,$start) = split(':',$dompersonnel{$server}{$user}); + if (($end eq '') || ($end == 0) || ($end > $now)) { + if ($start <= $now) { + $domcoords{$uname.':'.$udom} = $dompersonnel{$server}{$user}; + } + } } } return %domcoords; } sub active_dc_picker { - my ($dom,$numinrow,$inputtype,$name,%currhash) = @_; + my ($dom,$curr_dc) = @_; my %domcoords = &get_active_dcs($dom); - my @domcoord = keys(%domcoords); - if (keys(%currhash)) { - foreach my $dc (keys(%currhash)) { - unless (exists($domcoords{$dc})) { - push(@domcoord,$dc); - } - } - } - @domcoord = sort(@domcoord); - my $numdcs = scalar(@domcoord); - my $rows = 0; - my $table; + my @dcs = sort(keys(%domcoords)); + my $numdcs = scalar(@dcs); + my $datatable; + my $numinrow = 2; if ($numdcs > 1) { - $table = '
    '; - for (my $i=0; $i<@domcoord; $i++) { + $datatable = '
    '; + for (my $i=0; $i<@dcs; $i++) { my $rem = $i%($numinrow); if ($rem == 0) { if ($i > 0) { - $table .= ''; + $datatable .= ''; } - $table .= ''; - $rows ++; + $datatable .= ''; } - my $check = ''; - if ($inputtype eq 'radio') { - if (keys(%currhash) == 0) { - if (!$i) { - $check = ' checked="checked"'; - } - } elsif (exists($currhash{$domcoord[$i]})) { - $check = ' checked="checked"'; - } - } else { - if (exists($currhash{$domcoord[$i]})) { - $check = ' checked="checked"'; + my $check = ' '; + if ($curr_dc eq '') { + if (!$i) { + $check = ' checked="checked" '; } + } elsif ($dcs[$i] eq $curr_dc) { + $check = ' checked="checked" '; } - if ($i == @domcoord - 1) { + if ($i == @dcs - 1) { my $colsleft = $numinrow - $rem; if ($colsleft > 1) { - $table .= ''; - } - $table .= '
    '; + $datatable .= ''; } else { - $table .= ''; + $datatable .= ''; } } else { - $table .= ''; - } - my ($dcname,$dcdom) = split(':',$domcoord[$i]); - my $user = &Apache::loncommon::plainname($dcname,$dcdom); - $table .= '
    '; - } elsif ($numdcs == 1) { - my ($dcname,$dcdom) = split(':',$domcoord[0]); - my $user = &Apache::loncommon::plainname($dcname,$dcdom); - if ($inputtype eq 'radio') { - $table .= ''.$user; - if ($user ne $dcname.':'.$dcdom) { - $table .= ' ('.$dcname.':'.$dcdom.')'; - } - } else { - my $check; - if (exists($currhash{$domcoord[0]})) { - $check = ' checked="checked"'; - } - $table .= '
    '; } - $table .= ''; - $rows ++; + my ($dcname,$dcdom) = split(':',$dcs[$i]); + $datatable .= '
    '; + } elsif (@dcs) { + $datatable .= ''; } - return ($numdcs,$table,$rows); + return ($numdcs,$datatable); } sub usersession_titles { @@ -9801,7 +8128,7 @@ sub count_servers { } sub lonbalance_targets_js { - my ($dom,$types,$servers,$settings) = @_; + my ($dom,$types,$servers) = @_; my $select = &mt('Select'); my ($alltargets,$allishome,$allinsttypes,@alltypes); if (ref($servers) eq 'HASH') { @@ -9823,71 +8150,39 @@ sub lonbalance_targets_js { } push(@alltypes,'default','_LC_adv','_LC_author','_LC_internetdom','_LC_external'); $allinsttypes = join("','",@alltypes); - my (%currbalancer,%currtargets,%currrules,%existing); - if (ref($settings) eq 'HASH') { - %existing = %{$settings}; - } - &get_loadbalancers_config($servers,\%existing,\%currbalancer, - \%currtargets,\%currrules); - my $balancers = join("','",sort(keys(%currbalancer))); return <<"END"; - -END - -} - -sub credits_js { - return <<"END"; - - - -END - -} - -sub captcha_phrases { - return &Apache::lonlocal::texthash ( - priv => 'Private key', - pub => 'Public key', - original => 'original (CAPTCHA)', - recaptcha => 'successor (ReCAPTCHA)', - notused => 'unused', - ); -} - -sub devalidate_remote_domconfs { - my ($dom,$cachekeys) = @_; - return unless (ref($cachekeys) eq 'HASH'); - my %servers = &Apache::lonnet::internet_dom_servers($dom); - my %thismachine; - map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids(); - my @posscached = ('domainconfig','domdefaults'); - if (keys(%servers) > 1) { - foreach my $server (keys(%servers)) { - next if ($thismachine{$server}); - my @cached; - foreach my $name (@posscached) { - if ($cachekeys->{$name}) { - push(@cached,&escape($name).':'.&escape($dom)); - } - } - if (@cached) { - &Apache::lonnet::remote_devalidate_cache($server,\@cached); - } - } - } - return; -} - 1;