--- loncom/interface/domainprefs.pm 2024/01/02 02:25:19 1.160.6.118.2.16 +++ loncom/interface/domainprefs.pm 2016/10/25 12:45:33 1.283 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.160.6.118.2.16 2024/01/02 02:25:19 raeburn Exp $ +# $Id: domainprefs.pm,v 1.283 2016/10/25 12:45:33 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -19,15 +19,14 @@ # # You should have received a copy of the GNU General Public License # along with LON-CAPA; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA# # /home/httpd/html/adm/gpl.txt # # http://www.lon-capa.org/ # # ############################################################### -############################################################### +############################################################## =pod @@ -104,8 +103,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, textbook, and lti). -In each case the radio buttons allow the selection of one of four values: +(official, unofficial, community, textbook, and placement). +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: @@ -167,17 +166,15 @@ use Apache::lonmsg(); use Apache::lonconfigsettings; use Apache::lonuserutils(); use Apache::loncoursequeueadmin(); -use Apache::courseprefs(); use LONCAPA qw(:DEFAULT :match); use LONCAPA::Enrollment; use LONCAPA::lonauthcgi(); +use LONCAPA::SSL; use File::Copy; use Locale::Language; use DateTime::TimeZone; use DateTime::Locale; use Time::HiRes qw( sleep ); -use Net::CIDR; -use Crypt::CBC; my $registered_cleanup; my $modified_urls; @@ -221,78 +218,13 @@ sub handler { 'serverstatuses','requestcourses','helpsettings', 'coursedefaults','usersessions','loadbalancing', 'requestauthor','selfenrollment','inststatus', - 'passwords','ltitools','toolsec','lti','ltisec', - 'wafproxy','ipaccess'],$dom); - my %encconfig = - &Apache::lonnet::get_dom('encconfig',['ltitools','lti','linkprot'],$dom,undef,1); - my ($checked_is_home,$is_home); - if (ref($domconfig{'ltitools'}) eq 'HASH') { - if (ref($encconfig{'ltitools'}) eq 'HASH') { - my $home = &Apache::lonnet::domain($dom,'primary'); - unless (($home eq 'no_host') || ($home eq '')) { - my @ids=&Apache::lonnet::current_machine_ids(); - if (grep(/^\Q$home\E$/,@ids)) { - $is_home = 1; - } - } - $checked_is_home = 1; - foreach my $id (keys(%{$domconfig{'ltitools'}})) { - if ((ref($domconfig{'ltitools'}{$id}) eq 'HASH') && - (ref($encconfig{'ltitools'}{$id}) eq 'HASH')) { - $domconfig{'ltitools'}{$id}{'key'} = $encconfig{'ltitools'}{$id}{'key'}; - if (($is_home) && ($phase eq 'process')) { - $domconfig{'ltitools'}{$id}{'secret'} = $encconfig{'ltitools'}{$id}{'secret'}; - } - } - } - } - } - if (ref($domconfig{'lti'}) eq 'HASH') { - if (ref($encconfig{'lti'}) eq 'HASH') { - unless ($checked_is_home) { - my $home = &Apache::lonnet::domain($dom,'primary'); - unless (($home eq 'no_host') || ($home eq '')) { - my @ids=&Apache::lonnet::current_machine_ids(); - if (grep(/^\Q$home\E$/,@ids)) { - $is_home = 1; - } - } - $checked_is_home = 1; - } - foreach my $id (keys(%{$domconfig{'lti'}})) { - if ((ref($domconfig{'lti'}{$id}) eq 'HASH') && - (ref($encconfig{'lti'}{$id}) eq 'HASH')) { - $domconfig{'lti'}{$id}{'key'} = $encconfig{'lti'}{$id}{'key'}; - if (($is_home) && ($phase eq 'process')) { - $domconfig{'lti'}{$id}{'secret'} = $encconfig{'lti'}{$id}{'secret'}; - } - } - } - } - } - if (ref($domconfig{'ltisec'}) eq 'HASH') { - if (ref($domconfig{'ltisec'}{'linkprot'}) eq 'HASH') { - if (ref($encconfig{'linkprot'}) eq 'HASH') { - foreach my $id (keys(%{$domconfig{'ltisec'}{'linkprot'}})) { - unless ($id =~ /^\d+$/) { - delete($domconfig{'ltisec'}{'linkprot'}{$id}); - } - if ((ref($domconfig{'ltisec'}{'linkprot'}{$id}) eq 'HASH') && - (ref($encconfig{'linkprot'}{$id}) eq 'HASH')) { - foreach my $item ('key','secret') { - $domconfig{'ltisec'}{'linkprot'}{$id}{$item} = $encconfig{'linkprot'}{$id}{$item}; - } - } - } - } - } - } - my @prefs_order = ('rolecolors','login','ipaccess','defaults','wafproxy','passwords', - 'quotas','autoenroll','autoupdate','autocreate','directorysrch', - 'contacts','usercreation','selfcreation','usermodification', - 'scantron','requestcourses','requestauthor','coursecategories', + 'ltitools','ssl','trust'],$dom); + my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', + 'autoupdate','autocreate','directorysrch','contacts', + 'usercreation','selfcreation','usermodification','scantron', + 'requestcourses','requestauthor','coursecategories', 'serverstatuses','helpsettings','coursedefaults', - 'ltitools','selfenrollment','usersessions','lti'); + 'ltitools','selfenrollment','usersessions','ssl','trust'); my %existing; if (ref($domconfig{'loadbalancing'}) eq 'HASH') { %existing = %{$domconfig{'loadbalancing'}}; @@ -323,10 +255,7 @@ sub handler { {col1 => 'Log-in Help', col2 => 'Value'}, {col1 => 'Custom HTML in document head', - col2 => 'Value'}, - {col1 => 'SSO', - col2 => 'Dual login: SSO and non-SSO options'}, - ], + col2 => 'Value'}], print => \&print_login, modify => \&modify_login, }, @@ -336,39 +265,12 @@ sub handler { header => [{col1 => 'Setting', col2 => 'Value'}, {col1 => 'Institutional user types', - col2 => 'Name displayed'}, - {col1 => 'Mapping for missing usernames via standard log-in', - col2 => 'Rules in use'}], + col2 => 'Assignable to e-mail usernames'}], print => \&print_defaults, modify => \&modify_defaults, }, - 'wafproxy' => - { text => 'Web Application Firewall/Reverse Proxy', - help => 'Domain_Configuration_WAF_Proxy', - header => [{col1 => 'Domain(s)', - col2 => 'Servers and WAF/Reverse Proxy alias(es)', - }, - {col1 => 'Domain(s)', - col2 => 'WAF Configuration',}], - print => \&print_wafproxy, - modify => \&modify_wafproxy, - }, - 'passwords' => - { text => 'Passwords (Internal authentication)', - help => 'Domain_Configuration_Passwords', - header => [{col1 => 'Resetting Forgotten Password', - col2 => 'Settings'}, - {col1 => 'Encryption of Stored Passwords (Internal Auth)', - col2 => 'Settings'}, - {col1 => 'Rules for LON-CAPA Passwords', - col2 => 'Settings'}, - {col1 => 'Course Owner Changing Student Passwords', - col2 => 'Settings'}], - print => \&print_passwords, - modify => \&modify_passwords, - }, 'quotas' => - { text => 'Blogs, personal pages/timezones, webDAV/quotas, portfolio', + { text => 'Blogs, personal web pages, webDAV/quotas, portfolios', help => 'Domain_Configuration_Quotas', header => [{col1 => 'User affiliation', col2 => 'Available tools', @@ -415,16 +317,10 @@ sub handler { modify => \&modify_directorysrch, }, 'contacts' => - { text => 'E-mail addresses and helpform', + { text => 'Contact Information', help => 'Domain_Configuration_Contact_Info', - header => [{col1 => 'Default e-mail addresses', - col2 => 'Value',}, - {col1 => 'Recipient(s) for notifications', - col2 => 'Value',}, - {col1 => 'Nightly status check e-mail', - col2 => 'Settings',}, - {col1 => 'Ask helpdesk form settings', - col2 => 'Value',},], + header => [{col1 => 'Setting', + col2 => 'Value',}], print => \&print_contacts, modify => \&modify_contacts, }, @@ -447,7 +343,7 @@ sub handler { col2 => 'Enabled?'}, {col1 => 'Institutional user type (login/SSO self-creation)', col2 => 'Information user can enter'}, - {col1 => 'Self-creation with e-mail verification', + {col1 => 'Self-creation with e-mail as username', col2 => 'Settings'}], print => \&print_selfcreation, modify => \&modify_selfcreation, @@ -463,12 +359,11 @@ sub handler { modify => \&modify_usermodification, }, 'scantron' => - { text => 'Bubblesheet format', + { text => 'Bubblesheet format file', help => 'Domain_Configuration_Scantron_Format', - header => [ {col1 => 'Bubblesheet format file', - col2 => ''}, - {col1 => 'Bubblesheet data upload formats', - col2 => 'Settings'}], + header => [ {col1 => 'Item', + col2 => '', + }], print => \&print_scantron, modify => \&modify_scantron, }, @@ -553,6 +448,14 @@ sub handler { print => \&print_selfenrollment, modify => \&modify_selfenrollment, }, + 'privacy' => + {text => 'User Privacy', + help => 'Domain_Configuration_User_Privacy', + header => [{col1 => 'Setting', + col2 => 'Value',}], + print => \&print_privacy, + modify => \&modify_privacy, + }, 'usersessions' => {text => 'User session hosting/offloading', help => 'Domain_Configuration_User_Sessions', @@ -576,40 +479,50 @@ sub handler { print => \&print_loadbalancing, modify => \&modify_loadbalancing, }, - 'ltitools' => + 'ltitools' => {text => 'External Tools (LTI)', - help => 'Domain_Configuration_LTI_Tools', - header => [{col1 => 'Encryption of shared secrets', - col2 => 'Settings'}, - {col1 => 'Rules for shared secrets', - col2 => 'Settings'}, - {col1 => 'Providers', - col2 => 'Settings',}], + help => 'Domain_configuration_LTI_Tools', + header => [{col1 => 'Setting', + col2 => 'Value',}], print => \&print_ltitools, modify => \&modify_ltitools, }, - 'lti' => - {text => 'LTI Link Protection and LTI Consumers', - help => 'Domain_Configuration_LTI_Provider', - header => [{col1 => 'Encryption of shared secrets', - col2 => 'Settings'}, - {col1 => 'Rules for shared secrets', - col2 => 'Settings'}, - {col1 => 'Link Protectors', - col2 => 'Settings'}, - {col1 => 'Consumers', - col2 => 'Settings'},], - print => \&print_lti, - modify => \&modify_lti, + 'ssl' => + {text => 'LON-CAPA Network (SSL)', + help => 'Domain_Configuration_Network_SSL', + header => [{col1 => 'Server', + col2 => 'Certificate Status'}, + {col1 => 'Connections to other servers', + col2 => 'Rules'}, + {col1 => "Replicating domain's published content", + col2 => 'Rules'}], + print => \&print_ssl, + modify => \&modify_ssl, + }, + 'trust' => + {text => 'Trust Settings', + help => 'Domain_Configuration_Trust', + header => [{col1 => "Access to this domain's content by others", + col2 => 'Rules'}, + {col1 => "Access to other domain's content by this domain", + col2 => 'Rules'}, + {col1 => "Enrollment in this domain's courses by others", + col2 => 'Rules',}, + {col1 => "Co-author roles in this domain for others", + col2 => 'Rules',}, + {col1 => "Co-author roles for this domain's users elsewhere", + col2 => 'Rules',}, + {col1 => "Domain roles in this domain assignable to others", + col2 => 'Rules'}, + {col1 => "Course catalog for this domain displayed elsewhere", + col2 => 'Rules'}, + {col1 => "Requests for creation of courses in this domain by others", + col2 => 'Rules'}, + {col1 => "Users in other domains can send messages to this domain", + col2 => 'Rules'},], + print => \&print_trust, + modify => \&modify_trust, }, - 'ipaccess' => - {text => 'IP-based access control', - help => 'Domain_Configuration_IP_Access', - header => [{col1 => 'Setting', - col2 => 'Value'},], - print => \&print_ipaccess, - modify => \&modify_ipaccess, - }, ); if (keys(%servers) > 1) { $prefs{'login'} = { text => 'Log-in page options', @@ -617,14 +530,11 @@ sub handler { header => [{col1 => 'Log-in Service', col2 => 'Server Setting',}, {col1 => 'Log-in Page Items', - col2 => 'Settings'}, + col2 => ''}, {col1 => 'Log-in Help', col2 => 'Value'}, {col1 => 'Custom HTML in document head', - col2 => 'Value'}, - {col1 => 'SSO', - col2 => 'Dual login: SSO and non-SSO options'}, - ], + col2 => 'Value'}], print => \&print_login, modify => \&modify_login, }; @@ -665,17 +575,6 @@ $javascript_validations $coursebrowserjs END - } elsif (grep(/^ipaccess$/,@actions)) { - $js .= &Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'}); - } - if (grep(/^selfcreation$/,@actions)) { - $js .= &selfcreate_javascript(); - } - if (grep(/^contacts$/,@actions)) { - $js .= &contacts_javascript(); - } - if (grep(/^scantron$/,@actions)) { - $js .= &scantron_javascript(); } &Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,$js); } else { @@ -766,11 +665,11 @@ sub process_changes { } elsif ($action eq 'autocreate') { $output = &modify_autocreate($dom,%domconfig); } elsif ($action eq 'directorysrch') { - $output = &modify_directorysrch($dom,$lastactref,%domconfig); + $output = &modify_directorysrch($dom,%domconfig); } elsif ($action eq 'usercreation') { $output = &modify_usercreation($dom,%domconfig); } elsif ($action eq 'selfcreation') { - $output = &modify_selfcreation($dom,$lastactref,%domconfig); + $output = &modify_selfcreation($dom,%domconfig); } elsif ($action eq 'usermodification') { $output = &modify_usermodification($dom,%domconfig); } elsif ($action eq 'contacts') { @@ -788,7 +687,7 @@ sub process_changes { } elsif ($action eq 'requestauthor') { $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig); } elsif ($action eq 'helpsettings') { - $output = &modify_helpsettings($r,$dom,$confname,$lastactref,%domconfig); + $output = &modify_helpsettings($r,$dom,$confname,%domconfig); } elsif ($action eq 'coursedefaults') { $output = &modify_coursedefaults($dom,$lastactref,%domconfig); } elsif ($action eq 'selfenrollment') { @@ -799,14 +698,10 @@ sub process_changes { $output = &modify_loadbalancing($dom,%domconfig); } elsif ($action eq 'ltitools') { $output = &modify_ltitools($r,$dom,$action,$lastactref,%domconfig); - } elsif ($action eq 'lti') { - $output = &modify_lti($r,$dom,$action,$lastactref,%domconfig); - } elsif ($action eq 'passwords') { - $output = &modify_passwords($r,$dom,$confname,$lastactref,%domconfig); - } elsif ($action eq 'wafproxy') { - $output = &modify_wafproxy($dom,$action,$lastactref,%domconfig); - } elsif ($action eq 'ipaccess') { - $output = &modify_ipaccess($dom,$lastactref,%domconfig); + } elsif ($action eq 'ssl') { + $output = &modify_ssl($dom,$lastactref,%domconfig); + } elsif ($action eq 'trust') { + $output = &modify_trust($dom,$lastactref,%domconfig); } return $output; } @@ -819,8 +714,6 @@ sub print_config_box { $output = &coursecategories_javascript($settings); } elsif ($action eq 'defaults') { $output = &defaults_javascript($settings); - } elsif ($action eq 'passwords') { - $output = &passwords_javascript($action); } elsif ($action eq 'helpsettings') { my (%privs,%levelscurrent); my %full=(); @@ -835,28 +728,13 @@ sub print_config_box { &Apache::lonuserutils::custom_role_privs(\%privs,\%full,\%levels,\%levelscurrent); my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype); $output = - &Apache::lonuserutils::custom_roledefs_js($context,$crstype,$formname,\%full, + &Apache::lonuserutils::custom_roledefs_js($context,$crstype,$formname,\%full, \@templateroles); - } elsif ($action eq 'ltitools') { - $output .= &Apache::lonconfigsettings::ltitools_javascript($settings); - } elsif ($action eq 'lti') { - $output .= &passwords_javascript('ltisecrets')."\n". - <i_javascript($dom,$settings); - } elsif ($action eq 'wafproxy') { - $output .= &wafproxy_javascript($dom); - } elsif ($action eq 'autoupdate') { - $output .= &autoupdate_javascript(); - } elsif ($action eq 'autoenroll') { - $output .= &autoenroll_javascript(); - } elsif ($action eq 'login') { - $output .= &saml_javascript(); - } elsif ($action eq 'ipaccess') { - $output .= &ipaccess_javascript($settings); } $output .= ' - '."\n". ''; @@ -868,41 +746,32 @@ sub print_config_box { if ($numheaders > 1) { my $colspan = ''; my $rightcolspan = ''; - my $leftnobr = ''; if (($action eq 'rolecolors') || ($action eq 'defaults') || ($action eq 'directorysrch') || - (($action eq 'login') && ($numheaders < 5))) { + (($action eq 'login') && ($numheaders < 4))) { $colspan = ' colspan="2"'; } if ($action eq 'usersessions') { $rightcolspan = ' colspan="3"'; } - if ($action eq 'passwords') { - $leftnobr = ' LC_nobreak'; - } $output .= '
'. + '. &mt($item->{text}).' '. &Apache::loncommon::help_open_topic($item->{'help'}).'
- + '; $rowtotal ++; if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') || ($action eq 'usermodification') || ($action eq 'defaults') || ($action eq 'coursedefaults') || - ($action eq 'selfenrollment') || ($action eq 'usersessions') || ($action eq 'directorysrch') || - ($action eq 'helpsettings') || ($action eq 'contacts') || ($action eq 'wafproxy') || - ($action eq 'lti') || ($action eq 'ltitools')) { + ($action eq 'selfenrollment') || ($action eq 'usersessions') || ($action eq 'ssl') || + ($action eq 'directorysrch') || ($action eq 'trust') || ($action eq 'helpsettings')) { $output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal); - } elsif ($action eq 'passwords') { - $output .= $item->{'print'}->('top',$dom,$confname,$settings,\$rowtotal); } elsif ($action eq 'coursecategories') { $output .= $item->{'print'}->('top',$dom,$item,$settings,\$rowtotal); - } elsif ($action eq 'scantron') { - $output .= $item->{'print'}->($r,'top',$dom,$confname,$settings,\$rowtotal); } elsif ($action eq 'login') { - if ($numheaders == 5) { + if ($numheaders == 4) { $colspan = ' colspan="2"'; $output .= &print_login('service',$dom,$confname,$phase,$settings,\$rowtotal); } else { @@ -927,70 +796,69 @@ sub print_config_box { $rowtotal ++; if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') || ($action eq 'selfenrollment') || - ($action eq 'usersessions') || ($action eq 'coursecategories') || - ($action eq 'contacts') || ($action eq 'passwords') || - ($action eq 'defaults') || ($action eq 'lti') || - ($action eq 'ltitools')) { + ($action eq 'usersessions') || ($action eq 'coursecategories') || + ($action eq 'ssl') || ($action eq 'trust')) { if ($action eq 'coursecategories') { $output .= &print_coursecategories('middle',$dom,$item,$settings,\$rowtotal); $colspan = ' colspan="2"'; - } elsif ($action eq 'passwords') { - $output .= $item->{'print'}->('middle',$dom,$confname,$settings,\$rowtotal); + } elsif ($action eq 'trust') { + $output .= $item->{'print'}->('shared',$dom,$settings,\$rowtotal); } else { $output .= $item->{'print'}->('middle',$dom,$settings,\$rowtotal); } - $output .= ' -
'.&mt($item->{'header'}->[0]->{'col1'}).''.&mt($item->{'header'}->[0]->{'col1'}).' '.&mt($item->{'header'}->[0]->{'col2'}).'
+ if ($action eq 'trust') { + $output .= ' +
- + '; + my @trusthdrs = qw(2 3 4 5 6 7); + my @prefixes = qw(enroll othcoau coaurem domroles catalog reqcrs); + for (my $i=0; $i<@trusthdrs; $i++) { + $output .= ' - - - '."\n"; - if ($action eq 'coursecategories') { - $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal); - } elsif (($action eq 'contacts') || ($action eq 'passwords')) { - if ($action eq 'passwords') { - $output .= $item->{'print'}->('lower',$dom,$confname,$settings,\$rowtotal); - } else { - $output .= $item->{'print'}->('lower',$dom,$settings,\$rowtotal); + + '. + $item->{'print'}->($prefixes[$i],$dom,$settings,\$rowtotal).' +
'.&mt($item->{'header'}->[2]->{'col1'}).''.&mt($item->{'header'}->[2]->{'col2'}).'
'.&mt($item->{'header'}->[$trusthdrs[$i]]->{'col1'}).''.&mt($item->{'header'}->[$trusthdrs[$i]]->{'col2'}).'
+ + '; } $output .= ' - - - - - + - - '."\n"; - if ($action eq 'passwords') { - $output .= $item->{'print'}->('bottom',$dom,$confname,$settings,\$rowtotal); - } else { - $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); - } + + '. + $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); + } else { $output .= ' -
'.&mt($item->{'header'}->[3]->{'col1'}).''.&mt($item->{'header'}->[3]->{'col2'}).'
'.&mt($item->{'header'}->[8]->{'col1'}).''.&mt($item->{'header'}->[8]->{'col2'}).'
+ - '; - } else { - $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); + + + + + + + '."\n"; + if ($action eq 'coursecategories') { + $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal); + } else { + $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); + } } $rowtotal ++; } elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') || - ($action eq 'directorysrch') || ($action eq 'helpsettings') || - ($action eq 'wafproxy')) { + ($action eq 'defaults') || ($action eq 'directorysrch') || + ($action eq 'helpsettings')) { $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); - } elsif ($action eq 'scantron') { - $output .= $item->{'print'}->($r,'bottom',$dom,$confname,$settings,\$rowtotal); } elsif ($action eq 'login') { - if ($numheaders == 5) { + if ($numheaders == 4) { $output .= &print_login('page',$dom,$confname,$phase,$settings,\$rowtotal).'
'.&mt($item->{'header'}->[2]->{'col1'}).''.&mt($item->{'header'}->[2]->{'col2'}).'
@@ -1014,7 +882,7 @@ sub print_config_box { '; - if ($numheaders == 5) { + if ($numheaders == 4) { $output .= ' @@ -1026,27 +894,7 @@ sub print_config_box { '; } $rowtotal ++; - $output .= &print_login('headtag',$dom,$confname,$phase,$settings,\$rowtotal).' -
'.&mt($item->{'header'}->[3]->{'col1'}).' '.&mt($item->{'header'}->[3]->{'col2'}).'
- - - - - - '; - if ($numheaders == 5) { - $output .= ' - - - '; - } else { - $output .= ' - - - '; - } - $rowtotal ++; - $output .= &print_login('saml',$dom,$confname,$phase,$settings,\$rowtotal); + $output .= &print_login('headtag',$dom,$confname,$phase,$settings,\$rowtotal); } elsif ($action eq 'requestcourses') { $output .= &print_requestmail($dom,$action,$settings,\$rowtotal); $rowtotal ++; @@ -1165,9 +1013,11 @@ sub print_config_box { if ($action eq 'quotas') { $output .= &print_quotas($dom,$settings,\$rowtotal,$action); } elsif (($action eq 'autoenroll') || ($action eq 'autocreate') || - ($action eq 'serverstatuses') || ($action eq 'loadbalancing') || - ($action eq 'ipaccess')) { + ($action eq 'contacts') || ($action eq 'serverstatuses') || + ($action eq 'loadbalancing') || ($action eq 'ltitools')) { $output .= $item->{'print'}->($dom,$settings,\$rowtotal); + } elsif ($action eq 'scantron') { + $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal); } } $output .= ' @@ -1180,12 +1030,9 @@ sub print_config_box { sub print_login { my ($caller,$dom,$confname,$phase,$settings,$rowtotal) = @_; - my ($css_class,$datatable,$switchserver,%lt); + my ($css_class,$datatable); my %choices = &login_choices(); - if (($caller eq 'help') || ($caller eq 'headtag') || ($caller eq 'saml')) { - %lt = &login_file_options(); - $switchserver = &check_switchserver($dom,$confname); - } + if ($caller eq 'service') { my %servers = &Apache::lonnet::internet_dom_servers($dom); my $choice = $choices{'disallowlogin'}; @@ -1272,7 +1119,6 @@ sub print_login { } } my @images = ('img','logo','domlogo','login'); - my @alttext = ('img','logo','domlogo'); my @logintext = ('textcol','bgcol'); my @bgs = ('pgbg','mainbg','sidebg'); my @links = ('link','alink','vlink'); @@ -1314,13 +1160,6 @@ sub print_login { $designs{'showlogo'}{$item} = $settings->{'showlogo'}{$item}; } } - foreach my $item (@alttext) { - if (ref($settings->{'alttext'}) eq 'HASH') { - if ($settings->{'alttext'}->{$item} ne '') { - $designs{'alttext'}{$item} = $settings->{'alttext'}{$item}; - } - } - } foreach my $item (@logintext) { if ($settings->{$item} ne '') { $designs{'logintext'}{$item} = $settings->{$item}; @@ -1387,10 +1226,18 @@ sub print_login { $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal,\@logintext); $datatable .= '
'.&mt($item->{'header'}->[4]->{'col1'}).''.&mt($item->{'header'}->[4]->{'col2'}).'
'.&mt($item->{'header'}->[3]->{'col1'}).''.&mt($item->{'header'}->[3]->{'col2'}).'
'; } elsif ($caller eq 'help') { - my ($defaulturl,$defaulttype,%url,%type,%langchoices); + 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') { @@ -1487,6 +1334,14 @@ sub print_login { } } } + my %lt = &Apache::lonlocal::texthash( + del => 'Delete?', + rep => 'Replace:', + upl => 'Upload:', + curr => 'View contents', + none => 'None', + ); + my $switchserver = &check_switchserver($dom,$confname); foreach my $lonhost (sort(keys(%domservers))) { my $exempt = &check_exempt_addresses($currexempt{$lonhost}); $datatable .= ''.$domservers{$lonhost}.''; @@ -1507,102 +1362,7 @@ sub print_login { } else { $datatable .= ''; } - $datatable .= ''; - } - $datatable .= ''; - } elsif ($caller eq 'saml') { - my %domservers = &Apache::lonnet::get_servers($dom); - $datatable .= ''. - ''. - ''. - ''."\n"; - my (%saml,%samltext,%samlimg,%samlalt,%samlurl,%samltitle,%samlwindow,%samlnotsso,%styleon,%styleoff); - foreach my $lonhost (keys(%domservers)) { - $samlurl{$lonhost} = '/adm/sso'; - $styleon{$lonhost} = 'display:none'; - $styleoff{$lonhost} = ''; - } - if ((ref($settings) eq 'HASH') && (ref($settings->{'saml'}) eq 'HASH')) { - foreach my $lonhost (keys(%{$settings->{'saml'}})) { - if (ref($settings->{'saml'}{$lonhost}) eq 'HASH') { - $saml{$lonhost} = 1; - $samltext{$lonhost} = $settings->{'saml'}{$lonhost}{'text'}; - $samlimg{$lonhost} = $settings->{'saml'}{$lonhost}{'img'}; - $samlalt{$lonhost} = $settings->{'saml'}{$lonhost}{'alt'}; - $samlurl{$lonhost} = $settings->{'saml'}{$lonhost}{'url'}; - $samltitle{$lonhost} = $settings->{'saml'}{$lonhost}{'title'}; - $samlwindow{$lonhost} = $settings->{'saml'}{$lonhost}{'window'}; - $samlnotsso{$lonhost} = $settings->{'saml'}{$lonhost}{'notsso'}; - $styleon{$lonhost} = ''; - $styleoff{$lonhost} = 'display:none'; - } else { - $styleon{$lonhost} = 'display:none'; - $styleoff{$lonhost} = ''; - } - } - } - my $itemcount = 1; - foreach my $lonhost (sort(keys(%domservers))) { - my $samlon = ' '; - my $samloff = ' checked="checked" '; - if ($saml{$lonhost}) { - $samlon = $samloff; - $samloff = ' '; - } - my $samlwinon = ''; - my $samlwinoff = ' checked="checked"'; - if ($samlwindow{$lonhost}) { - $samlwinon = $samlwinoff; - $samlwinoff = ''; - } - my $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= ''. - ''. - ''. - ''; - $itemcount ++; + $datatable .= ''; } $datatable .= '
'.$choices{'hostid'}.''.$choices{'samllanding'}.''.$choices{'samloptions'}.'
'.$domservers{$lonhost}.''.(' 'x2). - ''. - ''. - ''. - ''. - ''. - '
'.&mt('SSO').'
'.&mt('Text').''.&mt('Image').''.&mt('Alt Text').'
'; - if ($samlimg{$lonhost}) { - $datatable .= '
'. - ' '.$lt{'rep'}.''; - } else { - $datatable .= $lt{'upl'}; - } - $datatable .='
'; - if ($switchserver) { - $datatable .= &mt('Upload to library server: [_1]',$switchserver); - } else { - $datatable .= ''; - } - $datatable .= '

'. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - '
'.&mt('SSO').''. - ''.&mt('Non-SSO').'
'.&mt('URL').''.&mt('Tool Tip').''.&mt('Pop-up if iframe').''.&mt('Text').'
'.(' 'x2).'
 
'; } @@ -1641,205 +1401,10 @@ sub login_choices { headtag => "Custom markup", action => "Action", current => "Current", - samllanding => "Dual login?", - samloptions => "Options", - alttext => "Alt text", ); return %choices; } -sub login_file_options { - return &Apache::lonlocal::texthash( - del => 'Delete?', - rep => 'Replace:', - upl => 'Upload:', - curr => 'View contents', - default => 'Default', - custom => 'Custom', - none => 'None', - ); -} - -sub print_ipaccess { - my ($dom,$settings,$rowtotal) = @_; - my $css_class; - my $itemcount = 0; - my $datatable; - my %ordered; - if (ref($settings) eq 'HASH') { - foreach my $item (keys(%{$settings})) { - if (ref($settings->{$item}) eq 'HASH') { - my $num = $settings->{$item}{'order'}; - if ($num eq '') { - $num = scalar(keys(%{$settings})); - } - $ordered{$num} = $item; - } - } - } - my $maxnum = scalar(keys(%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 $item = $ordered{$items[$i]}; - my ($name,$ipranges,%commblocks,%courses); - if (ref($settings->{$item}) eq 'HASH') { - $name = $settings->{$item}->{'name'}; - $ipranges = $settings->{$item}->{'ip'}; - if (ref($settings->{$item}->{'commblocks'}) eq 'HASH') { - %commblocks = %{$settings->{$item}->{'commblocks'}}; - } - if (ref($settings->{$item}->{'courses'}) eq 'HASH') { - %courses = %{$settings->{$item}->{'courses'}}; - } - } - my $chgstr = ' onchange="javascript:reorderIPaccess(this.form,'."'ipaccess_pos_".$item."'".');"'; - $datatable .= '' - .''.(' 'x2). - ''. - ''. - &ipaccess_options($i,$itemcount,$dom,$name,$ipranges,\%commblocks,\%courses). - ''; - $itemcount ++; - } - } - $css_class = $itemcount%2?' class="LC_odd_row"':''; - my $chgstr = ' onchange="javascript:reorderIPaccess(this.form,'."'ipaccess_pos_add'".');"'; - $datatable .= ''."\n". - ''."\n". - ' '."\n". - ''.&mt('Add').''."\n". - ''. - &ipaccess_options('add',$itemcount,$dom). - ''."\n". - ''."\n"; - $$rowtotal ++; - return $datatable; -} - -sub ipaccess_options { - my ($num,$itemcount,$dom,$name,$ipranges,$blocksref,$coursesref) = @_; - my (%currblocks,%currcourses,$output); - if (ref($blocksref) eq 'HASH') { - %currblocks = %{$blocksref}; - } - if (ref($coursesref) eq 'HASH') { - %currcourses = %{$coursesref}; - } - $output = '
'.&mt('Location(s)').''. - ''.&mt('Name').': '. - ''. - '
'. - '
'.&mt('IP Range(s)').''. - &mt('Format for each IP range').': '.&mt('A.B.C.D/N or A.B.C.D-E.F.G.H').'
'. - &mt('Range(s) will be stored as IP netblock(s) in CIDR notation (comma separated)').'
'. - '
'. - '
'.&mt('Functionality Blocked?').''. - &blocker_checkboxes($num,$blocksref).'
'. - '
'.&mt('Courses/Communities allowed').''. - ''; - foreach my $cid (sort(keys(%currcourses))) { - my %courseinfo = &Apache::lonnet::coursedescription($cid,{'one_time' => 1}); - $output .= ''; - } - $output .= '
'. - ''. - ' ('.$cid.')
'.&mt('Add').': '. - ''. - &Apache::loncommon::selectcourse_link('display','ipaccess_cnum_'.$num,'ipaccess_cdom_'.$num,'ipaccess_cdesc_'.$num,$dom,undef,'Course/Community'). - ''. - ''. - '
'."\n". - '
'; - return $output; -} - -sub blocker_checkboxes { - my ($num,$blocks) = @_; - my ($typeorder,$types) = &commblocktype_text(); - my $numinrow = 6; - my $output = ''; - for (my $i=0; $i<@{$typeorder}; $i++) { - my $block = $typeorder->[$i]; - my $blockstatus; - if (ref($blocks) eq 'HASH') { - if ($blocks->{$block} eq 'on') { - $blockstatus = 'checked="checked"'; - } - } - my $rem = $i%($numinrow); - if ($rem == 0) { - if ($i > 0) { - $output .= ''; - } - $output .= ''; - } - if ($i == scalar(@{$typeorder})-1) { - my $colsleft = $numinrow-$rem; - if ($colsleft > 1) { - $output .= ''; - } - $output .= '
'; - } else { - $output .= ''; - } - } else { - $output .= ''; - } - my $item = 'ipaccess_block_'.$num; - if ($blockstatus) { - $blockstatus = ' '.$blockstatus; - } - $output .= ''."\n". - '
'; - return $output; -} - -sub commblocktype_text { - my %types = &Apache::lonlocal::texthash( - 'com' => 'Messaging', - 'chat' => 'Chat Room', - 'boards' => 'Discussion', - 'port' => 'Portfolio', - 'groups' => 'Groups', - 'blogs' => 'Blogs', - 'about' => 'User Information', - 'printout' => 'Printouts', - 'passwd' => 'Change Password', - 'grades' => 'Gradebook', - 'search' => 'Course search', - 'wishlist' => 'Stored links', - 'annotate' => 'Annotations', - ); - my $typeorder = ['com','chat','boards','port','groups','blogs','about','wishlist','printout','grades','search','annotate','passwd']; - return ($typeorder,\%types); -} - sub print_rolecolors { my ($phase,$role,$dom,$confname,$settings,$rowtotal) = @_; my %choices = &color_font_choices(); @@ -1957,7 +1522,7 @@ sub display_color_options { my $datatable = ''. ''.$choices->{'font'}.''; if (!$is_custom->{'font'}) { - $datatable .= ''.&mt('Default in use:').' '.$defaults->{'font'}.''; + $datatable .= ''.&mt('Default in use:').' '.$defaults->{'font'}.''; } else { $datatable .= ' '; } @@ -1966,12 +1531,12 @@ sub display_color_options { $datatable .= ''. ' '. - ' '; + ' '; unless ($role eq 'login') { $datatable .= ''. ''.$choices->{'fontmenu'}.''; if (!$is_custom->{'fontmenu'}) { - $datatable .= ''.&mt('Default in use:').' '.$defaults->{'fontmenu'}.''; + $datatable .= ''.&mt('Default in use:').' '.$defaults->{'fontmenu'}.''; } else { $datatable .= ' '; } @@ -1981,7 +1546,7 @@ sub display_color_options { ' '. - ' '; + ' '; } my $switchserver = &check_switchserver($dom,$confname); foreach my $img (@{$images}) { @@ -1989,7 +1554,7 @@ sub display_color_options { $css_class = $itemcount%2?' class="LC_odd_row"':''; $datatable .= ''. ''.$choices->{$img}; - my ($imgfile,$img_import,$login_hdr_pick,$logincolors,$alttext); + my ($imgfile,$img_import,$login_hdr_pick,$logincolors); if ($role eq 'login') { if ($img eq 'login') { $login_hdr_pick = @@ -1997,13 +1562,8 @@ sub display_color_options { $logincolors = &login_text_colors($img,$role,$logintext,$phase,$choices, $designs,$defaults); - } else { - if ($img ne 'domlogo') { - $datatable.= &logo_display_options($img,$defaults,$designs); - } - if (ref($designs->{'alttext'}) eq 'HASH') { - $alttext = $designs->{'alttext'}{$img}; - } + } elsif ($img ne 'domlogo') { + $datatable.= &logo_display_options($img,$defaults,$designs); } } $datatable .= ''; @@ -2045,8 +1605,7 @@ sub display_color_options { if ($fullwidth ne '' && $fullheight ne '') { if ($fullwidth > $width && $fullheight > $height) { my $size = $width.'x'.$height; - my @args = ('convert','-sample',$size,$input,$output); - system({$args[0]} @args); + system("convert -sample $size $input $output"); $showfile = "/$imgdir/tn-".$filename; } } @@ -2095,11 +1654,6 @@ sub display_color_options { $datatable .=' '; } } - if (($role eq 'login') && ($img ne 'login')) { - $datatable .= (' ' x2).' '; - } $datatable .= ''; } $itemcount ++; @@ -2109,7 +1663,7 @@ sub display_color_options { my $bgs_def; foreach my $item (@{$bgs}) { if (!$is_custom->{$item}) { - $bgs_def .= ''.$choices->{$item}.'    
'.$defaults->{'bgs'}{$item}.''; + $bgs_def .= ''.$choices->{$item}.'    
'.$defaults->{'bgs'}{$item}.''; } } if ($bgs_def) { @@ -2137,7 +1691,7 @@ sub display_color_options { my $links_def; foreach my $item (@{$links}) { if (!$is_custom->{$item}) { - $links_def .= ''.$choices->{$item}.'
'.$defaults->{'links'}{$item}.''; + $links_def .= ''.$choices->{$item}.'
'.$defaults->{'links'}{$item}.''; } } if ($links_def) { @@ -2223,15 +1777,17 @@ sub image_changes { my ($is_custom,$alt_text,$img_import,$showfile,$fullsize,$role,$img,$imgfile,$logincolors) = @_; my $output; if ($img eq 'login') { - $output = ''.$logincolors; # suppress image for Log-in header + # suppress image for Log-in header } elsif (!$is_custom) { if ($img ne 'domlogo') { - $output = &mt('Default image:').'
'; + $output .= &mt('Default image:').'
'; } else { - $output = &mt('Default in use:').'
'; + $output .= &mt('Default in use:').'
'; } } - if ($img ne 'login') { + if ($img eq 'login') { # suppress image for Log-in header + $output .= ''.$logincolors; + } else { if ($img_import) { $output .= ''; } @@ -2262,7 +1818,7 @@ sub print_quotas { my $typecount = 0; my ($css_class,%titles); if ($context eq 'requestcourses') { - @usertools = ('official','unofficial','community','textbook','lti'); + @usertools = ('official','unofficial','community','textbook','placement'); @options =('norequest','approval','validate','autolimit'); %validations = &Apache::lonnet::auto_courserequest_checks($dom); %titles = &courserequest_titles(); @@ -2271,7 +1827,7 @@ sub print_quotas { @options = ('norequest','approval','automatic'); %titles = &authorrequest_titles(); } else { - @usertools = ('aboutme','blog','webdav','portfolio','timezone'); + @usertools = ('aboutme','blog','webdav','portfolio'); %titles = &tool_titles(); } if (ref($types) eq 'ARRAY') { @@ -2375,12 +1931,9 @@ sub print_quotas { } } else { my $checked = 'checked="checked" '; - if ($item eq 'timezone') { - $checked = ''; - } if (ref($settings) eq 'HASH') { if (ref($settings->{$item}) eq 'HASH') { - if (!$settings->{$item}->{$type}) { + if ($settings->{$item}->{$type} == 0) { $checked = ''; } elsif ($settings->{$item}->{$type} == 1) { $checked = 'checked="checked" '; @@ -2678,7 +2231,7 @@ sub print_quotas { } sub print_requestmail { - my ($dom,$action,$settings,$rowtotal,$customcss,$rowstyle) = @_; + my ($dom,$action,$settings,$rowtotal) = @_; my ($now,$datatable,%currapp); $now = time; if (ref($settings) eq 'HASH') { @@ -2690,19 +2243,7 @@ sub print_requestmail { } my $numinrow = 2; my $css_class; - if ($$rowtotal%2) { - $css_class = 'LC_odd_row'; - } - if ($customcss) { - $css_class .= " $customcss"; - } - $css_class =~ s/^\s+//; - if ($css_class) { - $css_class = ' class="'.$css_class.'"'; - } - if ($rowstyle) { - $css_class .= ' style="'.$rowstyle.'"'; - } + $css_class = ($$rowtotal%2? ' class="LC_odd_row"':''); my $text; if ($action eq 'requestcourses') { $text = &mt('Receive notification of course requests requiring approval'); @@ -2729,7 +2270,7 @@ sub print_studentcode { my ($settings,$rowtotal) = @_; my $rownum = 0; my ($output,%current); - my @crstypes = ('official','unofficial','community','textbook','lti'); + my @crstypes = ('official','unofficial','community','textbook','placement'); if (ref($settings) eq 'HASH') { if (ref($settings->{'uniquecode'}) eq 'HASH') { foreach my $type (@crstypes) { @@ -2856,7 +2397,7 @@ sub print_textbookcourses { $datatable .= ''; } $datatable .= ' '."\n". - ''.&mt('Add').''."\n". + ''.&mt('Add').''."\n". ''. ''.&mt('Subject:').' '."\n". (' 'x2). @@ -2873,13 +2414,13 @@ sub print_textbookcourses { } else { $datatable .= ''; } - $datatable .= ''."\n"; } - $datatable .= ''.&mt('LON-CAPA course:').' '. + $datatable .= ''."\n". + ''.&mt('LON-CAPA course:').' '. &Apache::loncommon::select_dom_form($env{'request.role.domain'},$type.'_addbook_cdom'). ''. &Apache::loncommon::selectcourse_link - ('display',$type.'_addbook_cnum',$type.'_addbook_cdom',undef,undef,undef,'Course'). + ('display',$type.'_addbook_cnum',$type.'_addbook_cdom',undef,undef,undef,'Course'); ''."\n". ''."\n"; $itemcount ++; @@ -2981,10 +2522,7 @@ ENDSCRIPT sub ltitools_javascript { my ($settings) = @_; - my $togglejs = <itools_toggle_js(); - unless (ref($settings) eq 'HASH') { - return $togglejs; - } + return unless(ref($settings) eq 'HASH'); my (%ordered,$total,%jstext); $total = 0; foreach my $item (keys(%{$settings})) { @@ -3002,7 +2540,7 @@ sub ltitools_javascript { return <<"ENDSCRIPT"; -$togglejs - -ENDSCRIPT -} - -sub ltitools_toggle_js { - return <<"ENDSCRIPT"; - - -ENDSCRIPT -} - -sub wafproxy_javascript { - my ($dom) = @_; - return <<"ENDSCRIPT"; - - -ENDSCRIPT -} - -sub lti_javascript { - my ($dom,$settings) = @_; - my $togglejs = <i_toggle_js($dom); - my $linkprot_js = &Apache::courseprefs::linkprot_javascript(); - unless (ref($settings) eq 'HASH') { - return $togglejs.' - -'; - } - my (%ordered,$total,%jstext); - $total = scalar(keys(%{$settings})); - foreach my $item (keys(%{$settings})) { - if (ref($settings->{$item}) eq 'HASH') { - my $num = $settings->{$item}{'order'}; - if ($num eq '') { - $num = $total - 1; - } - $ordered{$num} = $item; - } - } - my @jsarray = (); - foreach my $item (sort {$a <=> $b } (keys(%ordered))) { - push(@jsarray,$ordered{$item}); - } - my $jstext = ' var lti = Array('."'".join("','",@jsarray)."'".');'."\n"; - return <<"ENDSCRIPT"; - - -$togglejs - -ENDSCRIPT -} - -sub lti_toggle_js { - my ($dom) = @_; - my %lcauthparmtext = &Apache::lonlocal::texthash ( - localauth => 'Local auth argument', - krb => 'Kerberos domain', - ); - my $crsincalert = &mt('"User\'s identity sent" needs to be set to "Yes" first,[_1] before setting "Course\'s identity sent" to "Yes"',"\n"); - &js_escape(\$crsincalert); - my %servers = &Apache::lonnet::get_servers($dom,'library'); - my $primary = &Apache::lonnet::domain($dom,'primary'); - my $course_servers = "'".join("','",keys(%servers))."'"; - return <<"ENDSCRIPT"; - - -ENDSCRIPT -} - -sub autoupdate_javascript { - return <<"ENDSCRIPT"; - - -ENDSCRIPT -} - -sub autoenroll_javascript { - return <<"ENDSCRIPT"; - - -ENDSCRIPT -} - -sub saml_javascript { - return <<"ENDSCRIPT"; - - -ENDSCRIPT -} - -sub ipaccess_javascript { - my ($settings) = @_; - my (%ordered,$total,%jstext); - $total = 0; - if (ref($settings) eq 'HASH') { - foreach my $item (keys(%{$settings})) { - if (ref($settings->{$item}) eq 'HASH') { - my $num = $settings->{$item}{'order'}; - $ordered{$num} = $item; - } - } - $total = scalar(keys(%{$settings})); - } - my @jsarray = (); - foreach my $item (sort {$a <=> $b } (keys(%ordered))) { - push(@jsarray,$ordered{$item}); - } - my $jstext = ' var ipaccess = Array('."'".join("','",@jsarray)."'".');'."\n"; - return <<"ENDSCRIPT"; - - ENDSCRIPT } sub print_autoenroll { my ($dom,$settings,$rowtotal) = @_; my $autorun = &Apache::lonnet::auto_run(undef,$dom), - my ($defdom,$runon,$runoff,$coownerson,$coownersoff, - $failsafe,$autofailsafe,$failsafesty,%failsafechecked); - $failsafesty = 'none'; - %failsafechecked = ( - off => ' checked="checked"', - ); + my ($defdom,$runon,$runoff,$coownerson,$coownersoff,$failsafe); if (ref($settings) eq 'HASH') { if (exists($settings->{'run'})) { if ($settings->{'run'} eq '0') { @@ -3748,24 +2625,8 @@ sub print_autoenroll { if (exists($settings->{'sender_domain'})) { $defdom = $settings->{'sender_domain'}; } - if (exists($settings->{'failsafe'})) { - $failsafe = $settings->{'failsafe'}; - if ($failsafe eq 'zero') { - $failsafechecked{'zero'} = ' checked="checked"'; - $failsafechecked{'off'} = ''; - $failsafesty = 'inline-block'; - } elsif ($failsafe eq 'any') { - $failsafechecked{'any'} = ' checked="checked"'; - $failsafechecked{'off'} = ''; - } - $autofailsafe = $settings->{'autofailsafe'}; - } elsif (exists($settings->{'autofailsafe'})) { - $autofailsafe = $settings->{'autofailsafe'}; - if ($autofailsafe ne '') { - $failsafechecked{'zero'} = ' checked="checked"'; - $failsafe = 'zero'; - $failsafechecked{'off'} = ''; - } + if (exists($settings->{'autofailsafe'})) { + $failsafe = $settings->{'autofailsafe'}; } } else { if ($autorun) { @@ -3804,91 +2665,58 @@ sub print_autoenroll { $coownersoff.' value="0" />'.&mt('No').''. ''. ''.&mt('Failsafe for no drops when institutional data missing').''. - ''. - '    '. - '
'. - ''. - '
'. - ''. - &mt('Threshold for number of students in section to drop: [_1]', - ''). - '
'; + ''. + ''; $$rowtotal += 4; return $datatable; } sub print_autoupdate { my ($position,$dom,$settings,$rowtotal) = @_; - my ($enable,$datatable); + my $datatable; if ($position eq 'top') { - my %choices = &Apache::lonlocal::texthash ( - run => 'Auto-update active?', - classlists => 'Update information in classlists?', - unexpired => 'Skip updates for users without active or future roles?', - lastactive => 'Skip updates for inactive users?', - ); - my $itemcount = 0; my $updateon = ' '; my $updateoff = ' checked="checked" '; + my $classlistson = ' '; + my $classlistsoff = ' checked="checked" '; if (ref($settings) eq 'HASH') { if ($settings->{'run'} eq '1') { $updateon = $updateoff; $updateoff = ' '; } + if ($settings->{'classlists'} eq '1') { + $classlistson = $classlistsoff; + $classlistsoff = ' '; + } } - $enable = ''. - ''.$choices{'run'}.''. - ' '. ''. + $updateoff.'value="0" />'.&mt('No').''. + ''. + ''.&mt($title{'classlists'}).''. + ''. + ' '. + ''. ''; - my @toggles = ('classlists','unexpired'); - my %defaultchecked = ('classlists' => 'off', - 'unexpired' => 'off' - ); - $$rowtotal ++; - ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, - \%choices,$itemcount,'','','left','no'); - $datatable = $enable.$datatable; - $$rowtotal += $itemcount; - my $lastactiveon = ' '; - my $lastactiveoff = ' checked="checked" '; - my $lastactivestyle = 'none'; - my $lastactivedays; - my $onclick = ' onclick="javascript:toggleLastActiveDays(this.form);"'; - if (ref($settings) eq 'HASH') { - if ($settings->{'lastactive'} =~ /^\d+$/) { - $lastactiveon = $lastactiveoff; - $lastactiveoff = ' '; - $lastactivestyle = 'inline-block'; - $lastactivedays = $settings->{'lastactive'}; - } - } - my $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= ''. - ''.$choices{'lastactive'}.''. - ''. - ' '. - '
'. - ': '.&mt('inactive = no activity in last [_1] days', - ''). - ''. - ''; - $$rowtotal ++; + $$rowtotal += 2; } elsif ($position eq 'middle') { my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); my $numinrow = 3; my $locknamesettings; $datatable .= &insttypes_row($settings,$types,$usertypes, $dom,$numinrow,$othertitle, - 'lockablenames',$rowtotal); + 'lockablenames'); $$rowtotal ++; } else { my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); @@ -4031,8 +2859,7 @@ sub print_directorysrch { if (ref($usertypes) eq 'HASH') { if (keys(%{$usertypes}) > 0) { $datatable .= &insttypes_row($settings,$types,$usertypes,$dom, - $numinrow,$othertitle,'cansearch', - $rowtotal); + $numinrow,$othertitle,'cansearch'); $cansrchrow = 1; } } @@ -4117,515 +2944,107 @@ sub print_directorysrch { } sub print_contacts { - my ($position,$dom,$settings,$rowtotal) = @_; + my ($dom,$settings,$rowtotal) = @_; my $datatable; my @contacts = ('adminemail','supportemail'); - my (%checked,%to,%otheremails,%bccemails,%includestr,%includeloc,%currfield, - $maxsize,$fields,$fieldtitles,$fieldoptions,$possoptions,@mailings,%lonstatus); - if ($position eq 'top') { - if (ref($settings) eq 'HASH') { - foreach my $item (@contacts) { - if (exists($settings->{$item})) { - $to{$item} = $settings->{$item}; - } - } - } - } elsif ($position eq 'middle') { - @mailings = ('errormail','packagesmail','lonstatusmail','requestsmail', - 'updatesmail','idconflictsmail','hostipmail'); - foreach my $type (@mailings) { - $otheremails{$type} = ''; - } - } elsif ($position eq 'lower') { - if (ref($settings) eq 'HASH') { - if (ref($settings->{'lonstatus'}) eq 'HASH') { - %lonstatus = %{$settings->{'lonstatus'}}; - } - } - } else { - @mailings = ('helpdeskmail','otherdomsmail'); - foreach my $type (@mailings) { - $otheremails{$type} = ''; - } - $bccemails{'helpdeskmail'} = ''; - $bccemails{'otherdomsmail'} = ''; - $includestr{'helpdeskmail'} = ''; - $includestr{'otherdomsmail'} = ''; - ($fields,$fieldtitles,$fieldoptions,$possoptions) = &helpform_fields(); + my (%checked,%to,%otheremails,%bccemails); + my @mailings = ('errormail','packagesmail','lonstatusmail','helpdeskmail', + 'requestsmail','updatesmail','idconflictsmail'); + foreach my $type (@mailings) { + $otheremails{$type} = ''; } + $bccemails{'helpdeskmail'} = ''; if (ref($settings) eq 'HASH') { - unless (($position eq 'top') || ($position eq 'lower')) { - foreach my $type (@mailings) { - if (exists($settings->{$type})) { - if (ref($settings->{$type}) eq 'HASH') { - foreach my $item (@contacts) { - if ($settings->{$type}{$item}) { - $checked{$type}{$item} = ' checked="checked" '; - } - } - $otheremails{$type} = $settings->{$type}{'others'}; - if (($type eq 'helpdeskmail') || ($type eq 'otherdomsmail')) { - $bccemails{$type} = $settings->{$type}{'bcc'}; - if ($settings->{$type}{'include'} ne '') { - ($includeloc{$type},$includestr{$type}) = split(/:/,$settings->{$type}{'include'},2); - $includestr{$type} = &unescape($includestr{$type}); - } - } - } - } elsif ($type eq 'lonstatusmail') { - $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" '; - } + foreach my $item (@contacts) { + if (exists($settings->{$item})) { + $to{$item} = $settings->{$item}; } } - if ($position eq 'bottom') { - foreach my $type (@mailings) { - $bccemails{$type} = $settings->{$type}{'bcc'}; - if ($settings->{$type}{'include'} ne '') { - ($includeloc{$type},$includestr{$type}) = split(/:/,$settings->{$type}{'include'},2); - $includestr{$type} = &unescape($includestr{$type}); - } - } - if (ref($settings->{'helpform'}) eq 'HASH') { - if (ref($fields) eq 'ARRAY') { - foreach my $field (@{$fields}) { - $currfield{$field} = $settings->{'helpform'}{$field}; + foreach my $type (@mailings) { + if (exists($settings->{$type})) { + if (ref($settings->{$type}) eq 'HASH') { + foreach my $item (@contacts) { + if ($settings->{$type}{$item}) { + $checked{$type}{$item} = ' checked="checked" '; + } } - } - if (exists($settings->{'helpform'}{'maxsize'})) { - $maxsize = $settings->{'helpform'}{'maxsize'}; - } else { - $maxsize = '1.0'; - } - } else { - if (ref($fields) eq 'ARRAY') { - foreach my $field (@{$fields}) { - $currfield{$field} = 'yes'; + $otheremails{$type} = $settings->{$type}{'others'}; + if ($type eq 'helpdeskmail') { + $bccemails{$type} = $settings->{$type}{'bcc'}; } } - $maxsize = '1.0'; + } elsif ($type eq 'lonstatusmail') { + $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" '; } } } else { - if ($position eq 'top') { - $to{'supportemail'} = $Apache::lonnet::perlvar{'lonSupportEMail'}; - $to{'adminemail'} = $Apache::lonnet::perlvar{'lonAdmEMail'}; - $checked{'errormail'}{'adminemail'} = ' checked="checked" '; - $checked{'packagesmail'}{'adminemail'} = ' checked="checked" '; - $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" '; - $checked{'requestsmail'}{'adminemail'} = ' checked="checked" '; - $checked{'updatesmail'}{'adminemail'} = ' checked="checked" '; - $checked{'idconflictsmail'}{'adminemail'} = ' checked="checked" '; - $checked{'hostipmail'}{'adminemail'} = ' checked="checked" '; - } elsif ($position eq 'bottom') { - $checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" '; - $checked{'otherdomsmail'}{'supportemail'} = ' checked="checked" '; - if (ref($fields) eq 'ARRAY') { - foreach my $field (@{$fields}) { - $currfield{$field} = 'yes'; - } - } - $maxsize = '1.0'; - } + $to{'supportemail'} = $Apache::lonnet::perlvar{'lonSupportEMail'}; + $to{'adminemail'} = $Apache::lonnet::perlvar{'lonAdmEMail'}; + $checked{'errormail'}{'adminemail'} = ' checked="checked" '; + $checked{'packagesmail'}{'adminemail'} = ' checked="checked" '; + $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; - if ($position eq 'top') { - foreach my $item (@contacts) { - $css_class = $rownum%2?' class="LC_odd_row"':''; - $datatable .= ''. - ''.$titles->{$item}. - ''. - ''; - $rownum ++; - } - } elsif ($position eq 'bottom') { + foreach my $item (@contacts) { $css_class = $rownum%2?' class="LC_odd_row"':''; - $datatable .= ''. - ''.&mt('Extra helpdesk form fields:').'
'. - &mt('(e-mail, subject, and description always shown)'). - ''; - if ((ref($fields) eq 'ARRAY') && (ref($fieldtitles) eq 'HASH') && - (ref($fieldoptions) eq 'HASH') && (ref($possoptions) eq 'HASH')) { - $datatable .= ''; - foreach my $field (@{$fields}) { - $datatable .= ''. - ''; - } - $datatable .= '
'.&mt('Field').''.&mt('Status').'
'.$fieldtitles->{$field}; - if (($field eq 'screenshot') || ($field eq 'cc')) { - $datatable .= ' '.&mt('(logged-in users)'); - } - $datatable .=''; - my $clickaction; - if ($field eq 'screenshot') { - $clickaction = ' onclick="screenshotSize(this);"'; - } - if (ref($possoptions->{$field}) eq 'ARRAY') { - foreach my $option (@{$possoptions->{$field}}) { - my $checked; - if ($currfield{$field} eq $option) { - $checked = ' checked="checked"'; - } - $datatable .= ''.(' 'x2); - } - } - if ($field eq 'screenshot') { - my $display; - if ($currfield{$field} eq 'no') { - $display = ' style="display:none"'; - } - $datatable .= '
'.&mt('Maximum size for upload (MB)').''. - ''; - } - $datatable .= '
'; - } - $datatable .= ''."\n"; + $datatable .= ''. + ''.$titles->{$item}. + ''. + ''; $rownum ++; } - unless (($position eq 'top') || ($position eq 'lower')) { - foreach my $type (@mailings) { - $css_class = $rownum%2?' class="LC_odd_row"':''; - $datatable .= ''. - ''. - $titles->{$type}.': '. - ''; - if (($type eq 'helpdeskmail') || ($type eq 'otherdomsmail')) { - $datatable .= '
'.&mt('E-mail recipient(s)').''; - } - $datatable .= ''; - foreach my $item (@contacts) { - $datatable .= ' '; - } - $datatable .= '
'.&mt('Others').':  '. - ''; - my %locchecked; - if (($type eq 'helpdeskmail') || ($type eq 'otherdomsmail')) { - foreach my $loc ('s','b') { - if ($includeloc{$type} eq $loc) { - $locchecked{$loc} = ' checked="checked"'; - last; - } - } - $datatable .= '
'.&mt('Bcc:').(' 'x6). - '
'. - '
'.&mt('Optional added text').''. - &mt('Text automatically added to e-mail:').' '. - '
'. - ''.&mt('Location:').' '. - ''. - (' 'x2). - ''. - '
'; - } - $datatable .= ''."\n"; - $rownum ++; - } - } - if ($position eq 'middle') { - my %choices; - my $corelink = &core_link_msu(); - $choices{'reporterrors'} = &mt('E-mail error reports to [_1]',$corelink); - $choices{'reportupdates'} = &mt('E-mail record of completed LON-CAPA updates to [_1]', - $corelink); - $choices{'reportstatus'} = &mt('E-mail status if errors above threshold to [_1]',$corelink); - my @toggles = ('reporterrors','reportupdates','reportstatus'); - my %defaultchecked = ('reporterrors' => 'on', - 'reportupdates' => 'on', - 'reportstatus' => 'on'); - (my $reports,$rownum) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, - \%choices,$rownum); - $datatable .= $reports; - } elsif ($position eq 'lower') { - my (%current,%excluded,%weights); - my ($defaults,$names) = &Apache::loncommon::lon_status_items(); - if ($lonstatus{'threshold'} =~ /^\d+$/) { - $current{'errorthreshold'} = $lonstatus{'threshold'}; - } else { - $current{'errorthreshold'} = $defaults->{'threshold'}; - } - if ($lonstatus{'sysmail'} =~ /^\d+$/) { - $current{'errorsysmail'} = $lonstatus{'sysmail'}; - } else { - $current{'errorsysmail'} = $defaults->{'sysmail'}; - } - if (ref($lonstatus{'weights'}) eq 'HASH') { - foreach my $type ('E','W','N','U') { - if ($lonstatus{'weights'}{$type} =~ /^\d+$/) { - $weights{$type} = $lonstatus{'weights'}{$type}; - } else { - $weights{$type} = $defaults->{$type}; - } - } - } else { - foreach my $type ('E','W','N','U') { - $weights{$type} = $defaults->{$type}; - } - } - if (ref($lonstatus{'excluded'}) eq 'ARRAY') { - if (@{$lonstatus{'excluded'}} > 0) { - map {$excluded{$_} = 1; } @{$lonstatus{'excluded'}}; - } - } - foreach my $item ('errorthreshold','errorsysmail') { - $css_class = $rownum%2?' class="LC_odd_row"':''; - $datatable .= ''. - ''. - $titles->{$item}. - ''. - ''; - $rownum ++; - } + foreach my $type (@mailings) { $css_class = $rownum%2?' class="LC_odd_row"':''; $datatable .= ''. + ''. + $titles->{$type}.': '. ''. - ''.$titles->{'errorweights'}. - ''; - foreach my $type ('E','W','N','U') { - $datatable .= ''; - } - $datatable .= '
'.$names->{$type}.'
'. - '
'; - $rownum ++; - $css_class = $rownum%2?' class="LC_odd_row"':''; - $datatable .= ''. - $titles->{'errorexcluded'}.''. - ''; - my $numinrow = 4; - my @ids = sort(values(%Apache::lonnet::serverhomeIDs)); - for (my $i=0; $i<@ids; $i++) { - my $rem = $i%($numinrow); - if ($rem == 0) { - if ($i > 0) { - $datatable .= ''; - } - $datatable .= ''; - } - my $check; - if ($excluded{$ids[$i]}) { - $check = ' checked="checked" '; - } - $datatable .= ''; - } - my $colsleft = $numinrow - @ids%($numinrow); - if ($colsleft > 1 ) { - $datatable .= ''; - } elsif ($colsleft == 1) { - $datatable .= ''; + ''; + foreach my $item (@contacts) { + $datatable .= ' '; + } + $datatable .= '
'.&mt('Others').':  '. + ''; + if ($type eq 'helpdeskmail') { + $datatable .= '
'.&mt('Bcc:').(' 'x6). + ''; } - $datatable .= '
'. - ''. - '  
'; + $datatable .= ''."\n"; $rownum ++; - } elsif ($position eq 'bottom') { - my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); - my (@posstypes,%usertypeshash); - if (ref($types) eq 'ARRAY') { - @posstypes = @{$types}; - } - if (@posstypes) { - if (ref($usertypes) eq 'HASH') { - %usertypeshash = %{$usertypes}; - } - my @overridden; - my $numinrow = 4; - if (ref($settings) eq 'HASH') { - if (ref($settings->{'overrides'}) eq 'HASH') { - foreach my $key (sort(keys(%{$settings->{'overrides'}}))) { - if (ref($settings->{'overrides'}{$key}) eq 'HASH') { - push(@overridden,$key); - foreach my $item (@contacts) { - if ($settings->{'overrides'}{$key}{$item}) { - $checked{'override_'.$key}{$item} = ' checked="checked" '; - } - } - $otheremails{'override_'.$key} = $settings->{'overrides'}{$key}{'others'}; - $bccemails{'override_'.$key} = $settings->{'overrides'}{$key}{'bcc'}; - $includeloc{'override_'.$key} = ''; - $includestr{'override_'.$key} = ''; - if ($settings->{'overrides'}{$key}{'include'} ne '') { - ($includeloc{'override_'.$key},$includestr{'override_'.$key}) = - split(/:/,$settings->{'overrides'}{$key}{'include'},2); - $includestr{'override_'.$key} = &unescape($includestr{'override_'.$key}); - } - } - } - } - } - my $customclass = 'LC_helpdesk_override'; - my $optionsprefix = 'LC_options_helpdesk_'; - - my $onclicktypes = "toggleHelpdeskRow(this.form,'overrides','$customclass','$optionsprefix');"; - $datatable .= &insttypes_row($settings,$types,$usertypes,$dom, - $numinrow,$othertitle,'overrides', - \$rownum,$onclicktypes,$customclass); - $rownum ++; - $usertypeshash{'default'} = $othertitle; - foreach my $status (@posstypes) { - my $css_class; - if ($rownum%2) { - $css_class = 'LC_odd_row '; - } - $css_class .= $customclass; - my $rowid = $optionsprefix.$status; - my $hidden = 1; - my $currstyle = 'display:none'; - if (grep(/^\Q$status\E$/,@overridden)) { - $currstyle = 'display:table-row'; - $hidden = 0; - } - my $key = 'override_'.$status; - $datatable .= &overridden_helpdesk($checked{$key},$otheremails{$key},$bccemails{$key}, - $includeloc{$key},$includestr{$key},$status,$rowid, - $usertypeshash{$status},$css_class,$currstyle, - \@contacts,$short_titles); - unless ($hidden) { - $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 core_link_msu { - return &Apache::loncommon::modal_link('http://loncapa.org/core.html', - &mt('LON-CAPA core group - MSU'),600,500); -} - -sub overridden_helpdesk { - my ($checked,$otheremails,$bccemails,$includeloc,$includestr,$type,$rowid, - $typetitle,$css_class,$rowstyle,$contacts,$short_titles) = @_; - my $class = 'LC_left_item'; - if ($css_class) { - $css_class = ' class="'.$css_class.'"'; - } - if ($rowid) { - $rowid = ' id="'.$rowid.'"'; - } - if ($rowstyle) { - $rowstyle = ' style="'.$rowstyle.'"'; - } - my ($output,$description); - $description = &mt('Helpdesk requests from: [_1] in this domain (overrides default)',"$typetitle"); - $output = ''. - "$description\n". - ''. - '
'.&mt('E-mail recipient(s)').''. - ''; - if (ref($contacts) eq 'ARRAY') { - foreach my $item (@{$contacts}) { - my $check; - if (ref($checked) eq 'HASH') { - $check = $checked->{$item}; - } - my $title; - if (ref($short_titles) eq 'HASH') { - $title = $short_titles->{$item}; - } - $output .= ' '; - } - } - $output .= '
'.&mt('Others').':  '. - ''; - my %locchecked; - foreach my $loc ('s','b') { - if ($includeloc eq $loc) { - $locchecked{$loc} = ' checked="checked"'; - last; - } - } - $output .= '
'.&mt('Bcc:').(' 'x6). - '
'. - '
'.&mt('Optional added text').''. - &mt('Text automatically added to e-mail:').' '. - '
'. - ''.&mt('Location:').' '. - ''. - (' 'x2). - ''. - '
'. - ''."\n"; - return $output; -} - -sub contacts_javascript { - return <<"ENDSCRIPT"; - - - -ENDSCRIPT -} - sub print_helpsettings { my ($position,$dom,$settings,$rowtotal) = @_; my $confname = $dom.'-domainconfig'; - my $formname = 'display'; my ($datatable,$itemcount); if ($position eq 'top') { $itemcount = 1; @@ -4641,70 +3060,20 @@ sub print_helpsettings { } else { my $css_class; my %existing=&Apache::lonnet::dump('roles',$dom,$confname,'rolesdef_'); - my (%customroles,%ordered,%current); - if (ref($settings) eq 'HASH') { - if (ref($settings->{'adhoc'}) eq 'HASH') { - %current = %{$settings->{'adhoc'}}; - } - } - my $count = 0; - foreach my $key (sort(keys(%existing))) { + my %customroles; + foreach my $key (keys(%existing)) { if ($key=~/^rolesdef\_(\w+)$/) { my $rolename = $1; - my (%privs,$order); + my %privs; ($privs{'system'},$privs{'domain'},$privs{'course'}) = split(/\_/,$existing{$key}); $customroles{$rolename} = \%privs; - if (ref($current{$rolename}) eq 'HASH') { - $order = $current{$rolename}{'order'}; - } - if ($order eq '') { - $order = $count; - } - $ordered{$order} = $rolename; - $count++; - } - } - my $maxnum = scalar(keys(%ordered)); - my @roles_by_num = (); - foreach my $item (sort {$a <=> $b } (keys(%ordered))) { - push(@roles_by_num,$item); - } - my $context = 'domprefs'; - my $crstype = 'Course'; - my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); - my @accesstypes = ('all','dh','da','none'); - my ($numstatustypes,@jsarray); - if (ref($types) eq 'ARRAY') { - if (@{$types} > 0) { - $numstatustypes = scalar(@{$types}); - push(@accesstypes,'status'); - @jsarray = ('bystatus'); } } - my %domhelpdesk = &Apache::lonnet::get_active_domroles($dom,['dh','da']); - if (keys(%domhelpdesk)) { - push(@accesstypes,('inc','exc')); - push(@jsarray,('notinc','notexc')); - } - my $hiddenstr = join("','",@jsarray); + my $count = 0; my $context = 'domprefs'; my $crstype = 'Course'; - my $prefix = 'helproles_'; - my $add_class = 'LC_hidden'; - foreach my $num (@roles_by_num) { - my $role = $ordered{$num}; - my ($desc,$access,@statuses); - if (ref($current{$role}) eq 'HASH') { - $desc = $current{$role}{'desc'}; - $access = $current{$role}{'access'}; - if (ref($current{$role}{'insttypes'}) eq 'ARRAY') { - @statuses = @{$current{$role}{'insttypes'}}; - } - } - if ($desc eq '') { - $desc = $role; - } - my $identifier = 'custhelp'.$num; + foreach my $role (sort(keys(%customroles))) { + my $prefix = 'custhelp'.$count; my %full=(); my %levels= ( course => {}, @@ -4719,32 +3088,18 @@ sub print_helpsettings { &Apache::lonuserutils::custom_role_privs($customroles{$role},\%full,\%levels,\%levelscurrent); my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype); $css_class = $itemcount%2?' class="LC_odd_row"':''; - my $chgstr = ' onchange="javascript:reorderHelpRoles(this.form,'."'helproles_".$num."_pos'".');"'; - $datatable .= ''.$role.'
'. - ''.(' 'x2). - ''. - ''. - '
'.&mt('Role name').''. - &mt('Name shown to users:'). - ''. - '
'. - &helpdeskroles_access($dom,$prefix,$num,$add_class,$current{$role},\@accesstypes, - $othertitle,$usertypes,$types,\%domhelpdesk). - '
'. - ''.&mt('Role privileges').&adhocbutton($prefix,$num,'privs','show').''. + $datatable .= ''. + ''.&mt('Existing helpdesk role:').' '. + ''.$role.'
'. + &Apache::lonuserutils::custom_role_header($context,$crstype, + \@templateroles,$prefix). &Apache::lonuserutils::custom_role_table($crstype,\%full,\%levels, - \%levelscurrent,$identifier, - 'LC_hidden',$prefix.$num.'_privs'). - '
'; + \%levelscurrent,$prefix). + '
'; + $count ++; $itemcount ++; } $css_class = $itemcount%2?' class="LC_odd_row"':''; @@ -4758,39 +3113,18 @@ sub print_helpsettings { ); &Apache::lonuserutils::custom_role_privs(\%privs,\%full,\%levels,\%levelscurrent); my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype); - my $chgstr = ' onchange="javascript:reorderHelpRoles(this.form,'."'helproles_".$count."_pos'".');"'; - $datatable .= '
'; -# '
'.&mt('Assigning author roles').''; -# -# $output .= '
'. -# '
'.&mt('Assigning domain roles').''; - return $output; -} - -sub ltimenu_titles { - return &Apache::lonlocal::texthash( - fullname => 'Full name', - coursetitle => 'Course title', - role => 'Role', - logout => 'Logout', - grades => 'Grades', - ); -} - - - sub print_coursedefaults { my ($position,$dom,$settings,$rowtotal) = @_; my ($css_class,$datatable,%checkedon,%checkedoff,%defaultchecked,@toggles); 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)', - coursequota => 'Default cumulative quota for all group portfolio spaces in course', anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys', coursecredits => 'Credits can be specified for courses', uselcmath => 'Math preview uses LON-CAPA previewer (javascript) in place of DragMath (Java)', usejsme => 'Molecule editor uses JSME (HTML5) in place of JME (Java)', - inline_chem => 'Use inline previewer for chemical reaction response in place of pop-up', - texengine => 'Default method to display mathematics', postsubmit => 'Disable submit button/keypress following student submission', canclone => "People who may clone a course (besides course's owner and coordinators)", mysqltables => 'Lifetime (s) of "Temporary" MySQL tables (student performance data) on homeserver', - ltiauth => 'Student username in LTI launch of deep-linked URL can be accepted without re-authentication', - domexttool => 'External Tools defined in the domain may be used in courses/communities (by type)', - exttool => 'External Tools can be defined and configured in courses/communities (by type)', ); my %staticdefaults = ( anonsurvey_threshold => 10, uploadquota => 500, - coursequota => 20, postsubmit => 60, mysqltables => 172800, - domexttool => 1, - exttool => 0, ); if ($position eq 'top') { %defaultchecked = ( + 'canuse_pdfforms' => 'off', 'uselcmath' => 'on', 'usejsme' => 'on', - 'inline_chem' => 'on', - 'canclone' => 'none', + 'canclone' => 'none', ); - @toggles = ('uselcmath','usejsme','inline_chem'); - my $deftex = $Apache::lonnet::deftex; - if (ref($settings) eq 'HASH') { - if ($settings->{'texengine'}) { - if ($settings->{'texengine'} =~ /^(MathJax|mimetex|tth)$/) { - $deftex = $settings->{'texengine'}; - } - } - } - $css_class = $itemcount%2?' class="LC_odd_row"':''; - my $mathdisp = ''. - ''.$choices{'texengine'}. - ''. - ''."\n"; - $itemcount ++; + @toggles = ('canuse_pdfforms','uselcmath','usejsme'); ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, \%choices,$itemcount); - $datatable = $mathdisp.$datatable; $css_class = $itemcount%2?' class="LC_odd_row"':''; $datatable .= ''. @@ -5988,7 +3573,7 @@ sub print_coursedefaults { my $currcanclone = 'none'; my $onclick; my @cloneoptions = ('none','domain'); - my %clonetitles = &Apache::lonlocal::texthash ( + my %clonetitles = ( none => 'No additional course requesters', domain => "Any course requester in course's domain", instcode => 'Course requests for official courses ...', @@ -6014,7 +3599,7 @@ sub print_coursedefaults { $currcanclone = $settings->{'canclone'}; } } - } + } foreach my $option (@cloneoptions) { my ($checked,$additional); if ($currcanclone eq $option) { @@ -6026,7 +3611,7 @@ sub print_coursedefaults { if ($checked) { $show = 'block'; } - $additional = '
'. + $additional = '
'. &mt('Institutional codes for new and cloned course have identical:'). '
'; foreach my $item (@code_order) { @@ -6053,49 +3638,17 @@ sub print_coursedefaults { $itemcount ++; } else { $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - my ($currdefresponder,%defcredits,%curruploadquota,%currcoursequota, - %deftimeout,%currmysql); + my ($currdefresponder,%defcredits,%curruploadquota,%deftimeout,%currmysql); my $currusecredits = 0; my $postsubmitclient = 1; - my $ltiauth = 0; - my %domexttool; - my %exttool; - my @types = ('official','unofficial','community','textbook'); + my @types = ('official','unofficial','community','textbook','placement'); if (ref($settings) eq 'HASH') { - if ($settings->{'ltiauth'}) { - $ltiauth = 1; - } - if (ref($settings->{'domexttool'}) eq 'HASH') { - foreach my $type (@types) { - if ($settings->{'domexttool'}->{$type}) { - $domexttool{$type} = ' checked="checked"'; - } - } - } else { - foreach my $type (@types) { - if ($staticdefaults{'domexttool'}) { - $domexttool{$type} = ' checked="checked"'; - } - } - } - if (ref($settings->{'exttool'}) eq 'HASH') { - foreach my $type (@types) { - if ($settings->{'exttool'}->{$type}) { - $exttool{$type} = ' checked="checked"'; - } - } - } $currdefresponder = $settings->{'anonsurvey_threshold'}; if (ref($settings->{'uploadquota'}) eq 'HASH') { foreach my $type (keys(%{$settings->{'uploadquota'}})) { $curruploadquota{$type} = $settings->{'uploadquota'}{$type}; } } - if (ref($settings->{'coursequota'}) eq 'HASH') { - foreach my $type (keys(%{$settings->{'coursequota'}})) { - $currcoursequota{$type} = $settings->{'coursequota'}{$type}; - } - } if (ref($settings->{'coursecredits'}) eq 'HASH') { foreach my $type (@types) { next if ($type eq 'community'); @@ -6115,7 +3668,7 @@ sub print_coursedefaults { foreach my $type (@types) { if (ref($settings->{'postsubmit'}->{'timeout'}) eq 'HASH') { if ($settings->{'postsubmit'}->{'timeout'}->{$type} =~ /^\d+$/) { - $deftimeout{$type} = $settings->{'postsubmit'}->{'timeout'}->{$type}; + $deftimeout{$type} = $settings->{'postsubmit'}->{'timeout'}->{$type}; } else { $deftimeout{$type} = $staticdefaults{'postsubmit'}; } @@ -6141,9 +3694,6 @@ sub print_coursedefaults { } else { foreach my $type (@types) { $deftimeout{$type} = $staticdefaults{'postsubmit'}; - if ($staticdefaults{'domexttool'}) { - $domexttool{$type} = ' checked="checked"'; - } } } if (!$currdefresponder) { @@ -6155,9 +3705,6 @@ sub print_coursedefaults { if ($curruploadquota{$type} eq '') { $curruploadquota{$type} = $staticdefaults{'uploadquota'}; } - if ($currcoursequota{$type} eq '') { - $currcoursequota{$type} = $staticdefaults{'coursequota'}; - } } $datatable .= ''. @@ -6181,19 +3728,6 @@ sub print_coursedefaults { } $datatable .= ''."\n"; $itemcount ++; - $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable .= ''. - $choices{'coursequota'}. - ''. - ''. - ''; - foreach my $type (@types) { - $datatable .= ''; - } - $datatable .= '
'.&mt($type).'
'. - '
'."\n"; - $itemcount ++; my $onclick = "toggleDisplay(this.form,'credits');"; my $display = 'none'; if ($currusecredits) { @@ -6250,48 +3784,11 @@ sub print_coursedefaults { foreach my $type (@types) { $datatable .= ''.&mt($type).'
'. ''; - } - $datatable .= ''."\n"; - $itemcount ++; - %defaultchecked = ('ltiauth' => 'off'); - @toggles = ('ltiauth'); - $current = { - 'ltiauth' => $ltiauth, - }; - ($table,$itemcount) = - &radiobutton_prefs($current,\@toggles,\%defaultchecked, - \%choices,$itemcount,undef,undef,'left'); - $datatable .= $table; - $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable .= ''. - $choices{'domexttool'}. - ''. - ''. - ''; - foreach my $type (@types) { - $datatable .= ''."\n"; + ' value="'.$currmysql{$type}.'" size="5" />'; } $datatable .= '
'. - ''. - ''. - &mt($type).'
'."\n"; $itemcount ++; - $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable .= ''. - $choices{'exttool'}. - ''. - ''. - ''; - foreach my $type (@types) { - $datatable .= ''."\n"; - } - $datatable .= '
'. - ''. - ''. - &mt($type).'
'."\n"; + } $$rowtotal += $itemcount; return $datatable; @@ -6301,7 +3798,7 @@ sub print_selfenrollment { my ($position,$dom,$settings,$rowtotal) = @_; my ($css_class,$datatable); my $itemcount = 1; - my @types = ('official','unofficial','community','textbook'); + my @types = ('official','unofficial','community','textbook','placement'); if (($position eq 'top') || ($position eq 'middle')) { my ($rowsref,$titlesref) = &Apache::lonuserutils::get_selfenroll_titles(); my %descs = &Apache::lonuserutils::selfenroll_default_descs(); @@ -6485,7 +3982,7 @@ sub print_validation_rows { '
'; } } elsif ($item eq 'markup') { - $datatable .= ''; } @@ -6507,7 +4004,7 @@ sub print_validation_rows { my ($numdc,$dctable,$rows) = &active_dc_picker($dom,$numinrow,'radio', 'validationdc',%currhash); my $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable .= ''; + $datatable .= ''; if ($numdc > 1) { $datatable .= &mt('Course creation processed as: (choose Dom. Coord.)'); } else { @@ -6522,912 +4019,248 @@ sub print_validation_rows { return $datatable; } -sub print_passwords { - my ($position,$dom,$confname,$settings,$rowtotal) = @_; - my ($datatable,$css_class); - my $itemcount = 0; - my %titles = &Apache::lonlocal::texthash ( - captcha => '"Forgot Password" CAPTCHA validation', - link => 'Reset link expiration (hours)', - case => 'Case-sensitive usernames/e-mail', - prelink => 'Information required (form 1)', - postlink => 'Information required (form 2)', - emailsrc => 'LON-CAPA e-mail address type(s)', - customtext => 'Domain specific text (HTML)', - intauth_cost => 'Encryption cost for bcrypt (positive integer)', - intauth_check => 'Check bcrypt cost if authenticated', - intauth_switch => 'Existing crypt-based switched to bcrypt on authentication', - permanent => 'Permanent e-mail address', - critical => 'Critical notification address', - notify => 'Notification address', - min => 'Minimum password length', - max => 'Maximum password length', - chars => 'Required characters', - numsaved => 'Number of previous passwords to save and disallow reuse', - ); +sub print_usersessions { + my ($position,$dom,$settings,$rowtotal) = @_; + my ($css_class,$datatable,$itemcount,%checked,%choices); + my (%by_ip,%by_location,@intdoms,@instdoms); + &build_location_hashes(\@intdoms,\%by_ip,\%by_location,\@instdoms); + + my @alldoms = &Apache::lonnet::all_domains(); + my %serverhomes = %Apache::lonnet::serverhomeIDs; + my %servers = &Apache::lonnet::internet_dom_servers($dom); + my %altids = &id_for_thisdom(%servers); if ($position eq 'top') { - my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); - my $shownlinklife = 2; - my $prelink = 'both'; - my (%casesens,%postlink,%emailsrc,$nostdtext,$customurl); - if (ref($settings) eq 'HASH') { - if ($settings->{resetlink} =~ /^\d+(|\.\d*)$/) { - $shownlinklife = $settings->{resetlink}; - } - if (ref($settings->{resetcase}) eq 'ARRAY') { - map { $casesens{$_} = 1; } (@{$settings->{resetcase}}); - } - if ($settings->{resetprelink} =~ /^(both|either)$/) { - $prelink = $settings->{resetprelink}; - } - if (ref($settings->{resetpostlink}) eq 'HASH') { - %postlink = %{$settings->{resetpostlink}}; - } - if (ref($settings->{resetemail}) eq 'ARRAY') { - map { $emailsrc{$_} = 1; } (@{$settings->{resetemail}}); - } - if ($settings->{resetremove}) { - $nostdtext = 1; - } - if ($settings->{resetcustom}) { - $customurl = $settings->{resetcustom}; - } - } else { - if (ref($types) eq 'ARRAY') { - foreach my $item (@{$types}) { - $casesens{$item} = 1; - $postlink{$item} = ['username','email']; - } - } - $casesens{'default'} = 1; - $postlink{'default'} = ['username','email']; - $prelink = 'both'; - %emailsrc = ( - permanent => 1, - critical => 1, - notify => 1, - ); - } - $datatable = &captcha_choice('passwords',$settings,$$rowtotal); - $itemcount ++; - $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= ''.$titles{'link'}.''. - ''. - ''; - $itemcount ++; - $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= ''.$titles{'case'}.''. - ''; - if ((ref($types) eq 'ARRAY') && (ref($usertypes) eq 'HASH')) { - foreach my $item (@{$types}) { - my $checkedcase; - if ($casesens{$item}) { - $checkedcase = ' checked="checked"'; + if (keys(%serverhomes) > 1) { + my %spareid = ¤t_offloads_to($dom,$settings,\%servers); + my $curroffloadnow; + if (ref($settings) eq 'HASH') { + if (ref($settings->{'offloadnow'}) eq 'HASH') { + $curroffloadnow = $settings->{'offloadnow'}; } - $datatable .= ''. - '   '; - } - } - my $checkedcase; - if ($casesens{'default'}) { - $checkedcase = ' checked="checked"'; - } - $datatable .= ''; - $itemcount ++; - $css_class = $itemcount%2?' class="LC_odd_row"':''; - my %checkedpre = ( - both => ' checked="checked"', - either => '', - ); - if ($prelink eq 'either') { - $checkedpre{either} = ' checked="checked"'; - $checkedpre{both} = ''; - } - $datatable .= ''.$titles{'prelink'}.''. - ''. - '   '. - ''; - $itemcount ++; - $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= ''.$titles{'postlink'}.''. - ''; - my %postlinked; - if ((ref($types) eq 'ARRAY') && (ref($usertypes) eq 'HASH')) { - foreach my $item (@{$types}) { - undef(%postlinked); - $datatable .= '
'. - ''.$usertypes->{$item}.''; - if (ref($postlink{$item}) eq 'ARRAY') { - map { $postlinked{$_} = 1; } (@{$postlink{$item}}); - } - foreach my $field ('email','username') { - my $checked; - if ($postlinked{$field}) { - $checked = ' checked="checked"'; - } - $datatable .= ''. - '   '; - } - $datatable .= '
'; - } - } - if (ref($postlink{'default'}) eq 'ARRAY') { - map { $postlinked{$_} = 1; } (@{$postlink{'default'}}); - } - $datatable .= '
'. - ''.$othertitle.''; - foreach my $field ('email','username') { - my $checked; - if ($postlinked{$field}) { - $checked = ' checked="checked"'; - } - $datatable .= ''. - '   '; - } - $datatable .= '
'; - $itemcount ++; - $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= ''.$titles{'emailsrc'}.''. - ''; - foreach my $type ('permanent','critical','notify') { - my $checkedemail; - if ($emailsrc{$type}) { - $checkedemail = ' checked="checked"'; } - $datatable .= ''. - '   '; - } - $datatable .= ''; - $itemcount ++; - $css_class = $itemcount%2?' class="LC_odd_row"':''; - my $switchserver = &check_switchserver($dom,$confname); - my ($showstd,$noshowstd); - if ($nostdtext) { - $noshowstd = ' checked="checked"'; - } else { - $showstd = ' checked="checked"'; - } - $datatable .= ''.$titles{'customtext'}.''. - ''. - &mt('Retain standard text:'). - ''.' '. - '
'. - ''. - &mt('(If you use the same account ... reset a password from this page.)').'

'. - &mt('Include custom text:'); - if ($customurl) { - my $link = &Apache::loncommon::modal_link($customurl,&mt('custom text'),600,500, - undef,undef,undef,undef,'background-color:#ffffff'); - $datatable .= ' '.$link. - ''. - '  '.&mt('Replace:').''; - } - if ($switchserver) { - $datatable .= ' '.&mt('Upload to library server: [_1]',$switchserver).''; + $datatable .= &spares_row($dom,\%servers,\%spareid,\%serverhomes,\%altids,$curroffloadnow,$rowtotal); } else { - $datatable .=' '. - ''; - } - $datatable .= ''; - } elsif ($position eq 'middle') { - my %domconf = &Apache::lonnet::get_dom('configuration',['defaults'],$dom); - my @items = ('intauth_cost','intauth_check','intauth_switch'); - my %defaults; - if (ref($domconf{'defaults'}) eq 'HASH') { - %defaults = %{$domconf{'defaults'}}; - if ($defaults{'intauth_cost'} !~ /^\d+$/) { - $defaults{'intauth_cost'} = 10; - } - if ($defaults{'intauth_check'} !~ /^(0|1|2)$/) { - $defaults{'intauth_check'} = 0; - } - if ($defaults{'intauth_switch'} !~ /^(0|1|2)$/) { - $defaults{'intauth_switch'} = 0; - } - } else { - %defaults = ( - 'intauth_cost' => 10, - 'intauth_check' => 0, - 'intauth_switch' => 0, - ); - } - foreach my $item (@items) { - if ($itemcount%2) { - $css_class = ''; - } else { - $css_class = ' class="LC_odd_row" '; - } - $datatable .= ''. - ''.$titles{$item}. - ''; - if ($item eq 'intauth_switch') { - my @options = (0,1,2); - my %optiondesc = &Apache::lonlocal::texthash ( - 0 => 'No', - 1 => 'Yes', - 2 => 'Yes, and copy existing passwd file to passwd.bak file', - ); - $datatable .= ''; - foreach my $option (@options) { - my $checked = ' '; - if ($defaults{$item} eq $option) { - $checked = ' checked="checked"'; - } - $datatable .= ''; - } - $datatable .= '
'. - '
'; - } elsif ($item eq 'intauth_check') { - my @options = (0,1,2); - my %optiondesc = &Apache::lonlocal::texthash ( - 0 => 'No', - 1 => 'Yes, allow login then update passwd file using default cost (if higher)', - 2 => 'Yes, disallow login if stored cost is less than domain default', - ); - $datatable .= ''; - foreach my $option (@options) { - my $checked = ' '; - my $onclick; - if ($defaults{$item} eq $option) { - $checked = ' checked="checked"'; - } - if ($option == 2) { - $onclick = ' onclick="javascript:warnIntAuth(this);"'; - } - $datatable .= ''; - } - $datatable .= '
'. - '
'; - } else { - $datatable .= ''; - } - $datatable .= ''; - $itemcount ++; + $datatable .= ''. + &mt('Nothing to set here, as the cluster to which this domain belongs only contains one server.'). + ''; } - } elsif ($position eq 'lower') { - $datatable .= &password_rules('passwords',\$itemcount,$settings); } else { - my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); - my %ownerchg = ( - by => {}, - for => {}, - ); - my %ownertitles = &Apache::lonlocal::texthash ( - by => 'Course owner status(es) allowed', - for => 'Student status(es) allowed', - ); - if (ref($settings) eq 'HASH') { - if (ref($settings->{crsownerchg}) eq 'HASH') { - if (ref($settings->{crsownerchg}{'by'}) eq 'ARRAY') { - map { $ownerchg{by}{$_} = 1; } (@{$settings->{crsownerchg}{'by'}}); - } - if (ref($settings->{crsownerchg}{'for'}) eq 'ARRAY') { - map { $ownerchg{for}{$_} = 1; } (@{$settings->{crsownerchg}{'for'}}); - } - } - } - $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= ''. - ''. - &mt('Requirements').'
    '. - '
  • '.&mt("Course 'type' is not a Community").'
  • '. - '
  • '.&mt('User is Course Coordinator and also course owner').'
  • '. - '
  • '.&mt("Student's only active roles are student role(s) in course(s) owned by this user").'
  • '. - '
  • '.&mt('User, course, and student share same domain').'
  • '. - '
'. - ''. - ''; - foreach my $item ('by','for') { - $datatable .= '
'. - ''.$ownertitles{$item}.''; - if ((ref($types) eq 'ARRAY') && (ref($usertypes) eq 'HASH')) { - foreach my $type (@{$types}) { - my $checked; - if ($ownerchg{$item}{$type}) { - $checked = ' checked="checked"'; - } - $datatable .= ''. - '   '; - } - } - my $checked; - if ($ownerchg{$item}{'default'}) { - $checked = ' checked="checked"'; - } - $datatable .= '
'; - } - $datatable .= ''; - } - return $datatable; -} - -sub password_rules { - my ($prefix,$itemcountref,$settings) = @_; - my ($min,$max,%chars,$numsaved,$numinrow); - my %titles; - if ($prefix eq 'passwords') { - %titles = &Apache::lonlocal::texthash ( - min => 'Minimum password length', - max => 'Maximum password length', - chars => 'Required characters', - ); - } elsif (($prefix eq 'ltisecrets') || ($prefix eq 'toolsecrets')) { - %titles = &Apache::lonlocal::texthash ( - min => 'Minimum secret length', - max => 'Maximum secret length', - chars => 'Required characters', - ); - } - $min = $Apache::lonnet::passwdmin; - my $datatable; - my $itemcount; - if (ref($itemcountref)) { - $itemcount = $$itemcountref; - } - if (ref($settings) eq 'HASH') { - if ($settings->{min}) { - $min = $settings->{min}; - } - if ($settings->{max}) { - $max = $settings->{max}; - } - if (ref($settings->{chars}) eq 'ARRAY') { - map { $chars{$_} = 1; } (@{$settings->{chars}}); - } - if ($prefix eq 'passwords') { - if ($settings->{numsaved}) { - $numsaved = $settings->{numsaved}; - } - } - } - my %rulenames = &Apache::lonlocal::texthash( - uc => 'At least one upper case letter', - lc => 'At least one lower case letter', - num => 'At least one number', - spec => 'At least one non-alphanumeric', - ); - my $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= ''.$titles{'min'}.''. - ''. - ''. - ' '.&mt('(Enter an integer: 7 or larger)').''. - ''; - $itemcount ++; - $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= ''.$titles{'max'}.''. - ''. - ''. - ' '.&mt('(Leave blank for no maximum)').''. - ''; - $itemcount ++; - $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= ''.$titles{'chars'}.'
'. - ''.&mt('(Leave unchecked if not required)'). - ''; - my $numinrow = 2; - my @possrules = ('uc','lc','num','spec'); - $datatable .= ''; - for (my $i=0; $i<@possrules; $i++) { - my ($rem,$checked); - if ($chars{$possrules[$i]}) { - $checked = ' checked="checked"'; - } - $rem = $i%($numinrow); - if ($rem == 0) { - if ($i > 0) { - $datatable .= ''; - } - $datatable .= ''; + my %titles = &usersession_titles(); + my ($prefix,@types); + if ($position eq 'bottom') { + $prefix = 'remote'; + @types = ('version','excludedomain','includedomain'); + } else { + $prefix = 'hosted'; + @types = ('excludedomain','includedomain'); } - $datatable .= ''; - } - my $rem = @possrules%($numinrow); - my $colsleft = $numinrow - $rem; - if ($colsleft > 1 ) { - $datatable .= ''; - } elsif ($colsleft == 1) { - $datatable .= ''; - } - $datatable .='
'. - '  
'; - $itemcount ++; - if ($prefix eq 'passwords') { - $titles{'numsaved'} = &mt('Number of previous passwords to save and disallow reuse'); - $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= ''.$titles{'numsaved'}.''. - ''. - ''. - ' '.&mt('(Leave blank to not save previous passwords)').''. - ''; - $itemcount ++; - } - if (ref($itemcountref)) { - $$itemcountref += $itemcount; + ($datatable,$itemcount) = &rules_by_location($settings,$prefix,\%by_location,\%by_ip,\@types,\%titles); } + $$rowtotal += $itemcount; return $datatable; } -sub print_wafproxy { - my ($position,$dom,$settings,$rowtotal) = @_; - my $css_class; - my $itemcount = 0; - my $datatable; - my %servers = &Apache::lonnet::internet_dom_servers($dom); - my (%othercontrol,%otherdoms,%aliases,%saml,%values,$setdom,$showdom); - my %lt = &wafproxy_titles(); - foreach my $server (sort(keys(%servers))) { - my $serverhome = &Apache::lonnet::get_server_homeID($servers{$server}); - next if ($serverhome eq ''); - my $serverdom; - if ($serverhome ne $server) { - $serverdom = &Apache::lonnet::host_domain($serverhome); - if (($serverdom ne '') && (&Apache::lonnet::domain($serverdom) ne '')) { - $othercontrol{$server} = $serverdom; - } - } else { - $serverdom = &Apache::lonnet::host_domain($server); - next if (($serverdom eq '') || (&Apache::lonnet::domain($serverdom) eq '')); - if ($serverdom ne $dom) { - $othercontrol{$server} = $serverdom; - } else { - $setdom = 1; - if (ref($settings) eq 'HASH') { - if (ref($settings->{'alias'}) eq 'HASH') { - $aliases{$dom} = $settings->{'alias'}; - if ($aliases{$dom} ne '') { - $showdom = 1; - } - } - if (ref($settings->{'saml'}) eq 'HASH') { - $saml{$dom} = $settings->{'saml'}; - } - } - } +sub rules_by_location { + my ($settings,$prefix,$by_location,$by_ip,$types,$titles) = @_; + my ($datatable,$itemcount,$css_class); + if (keys(%{$by_location}) == 0) { + $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; + $datatable = ''. + &mt('Nothing to set here, as the cluster to which this domain belongs only contains one institution.'). + ''; + $itemcount = 1; + } else { + $itemcount = 0; + my $numinrow = 5; + my (%current,%checkedon,%checkedoff); + my @locations = sort(keys(%{$by_location})); + foreach my $type (@{$types}) { + $checkedon{$type} = ''; + $checkedoff{$type} = ' checked="checked"'; } - } - if ($setdom) { - %{$values{$dom}} = (); if (ref($settings) eq 'HASH') { - foreach my $item ('remoteip','ipheader','trusted','vpnint','vpnext') { - $values{$dom}{$item} = $settings->{$item}; - } - } - } - if (keys(%othercontrol)) { - %otherdoms = reverse(%othercontrol); - foreach my $domain (keys(%otherdoms)) { - %{$values{$domain}} = (); - my %config = &Apache::lonnet::get_dom('configuration',['wafproxy'],$domain); - if (ref($config{'wafproxy'}) eq 'HASH') { - $aliases{$domain} = $config{'wafproxy'}{'alias'}; - if (exists($config{'wafproxy'}{'saml'})) { - $saml{$domain} = $config{'wafproxy'}{'saml'}; - } - foreach my $item ('remoteip','ipheader','trusted','vpnint','vpnext') { - $values{$domain}{$item} = $config{'wafproxy'}{$item}; - } - } - } - } - if ($position eq 'top') { - my %servers = &Apache::lonnet::internet_dom_servers($dom); - my %aliasinfo; - foreach my $server (sort(keys(%servers))) { - $itemcount ++; - my $dom_in_effect; - my $aliasrows = ''. - ''. - &mt('Hostname').': '. - ''. - &Apache::lonnet::hostname($server).' '; - if ($othercontrol{$server}) { - $dom_in_effect = $othercontrol{$server}; - my ($current,$forsaml); - if (ref($aliases{$dom_in_effect}) eq 'HASH') { - $current = $aliases{$dom_in_effect}{$server}; - } - if (ref($saml{$dom_in_effect}) eq 'HASH') { - if ($saml{$dom_in_effect}{$server}) { - $forsaml = 1; - } - } - $aliasrows .= ''. - &mt('Alias').': '; - if ($current) { - $aliasrows .= $current; - if ($forsaml) { - $aliasrows .= ' ('.&mt('also for SSO Auth').')'; + if (ref($settings->{$prefix}) eq 'HASH') { + foreach my $key (keys(%{$settings->{$prefix}})) { + $current{$key} = $settings->{$prefix}{$key}; + if ($key eq 'version') { + if ($current{$key} ne '') { + $checkedon{$key} = ' checked="checked"'; + $checkedoff{$key} = ''; + } + } elsif (ref($current{$key}) eq 'ARRAY') { + $checkedon{$key} = ' checked="checked"'; + $checkedoff{$key} = ''; } - } else { - $aliasrows .= &mt('None'); } - $aliasrows .= ' ('. - &mt('controlled by domain: [_1]', - ''.$dom_in_effect.'').')'; - } else { - $dom_in_effect = $dom; - my ($current,$samlon,$samloff); - $samloff = ' checked="checked"'; - if (ref($aliases{$dom}) eq 'HASH') { - if ($aliases{$dom}{$server}) { - $current = $aliases{$dom}{$server}; - } - } - if (ref($saml{$dom}) eq 'HASH') { - if ($saml{$dom}{$server}) { - $samlon = $samloff; - undef($samloff); - } - } - $aliasrows .= ''. - &mt('Alias').': '. - ''. - (' 'x2).''. - &mt('Alias used for SSO Auth').':  '. - ''; - } - $aliasrows .= ''; - $aliasinfo{$dom_in_effect} .= $aliasrows; - } - if ($aliasinfo{$dom}) { - my ($onclick,$wafon,$wafoff,$showtable); - $onclick = ' onclick="javascript:toggleWAF();"'; - $wafoff = ' checked="checked"'; - $showtable = ' style="display:none";'; - if ($showdom) { - $wafon = $wafoff; - $wafoff = ''; - $showtable = ' style="display:inline;"'; - } - $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable = ''. - ''.&mt('Domain: [_1]',''.$dom.'').'
'. - ''.&mt('WAF in use?').' '.(' 'x2).''. - ''. - ''.$aliasinfo{$dom}. - '
'; - $itemcount++; - } - if (keys(%otherdoms)) { - foreach my $key (sort(keys(%otherdoms))) { - $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable .= ''. - ''.&mt('Domain: [_1]',''.$key.'').''. - ''.$aliasinfo{$key}. - '
'; - $itemcount++; } } - } else { - my %ip_methods = &remoteip_methods(); - if ($setdom) { - $itemcount ++; + foreach my $type (@{$types}) { + next if ($type ne 'version' && !@locations); $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - my ($nowafstyle,$wafstyle,$curr_remotip,$currwafdisplay,$vpndircheck,$vpnaliascheck, - $currwafvpn,$wafrangestyle,$alltossl,$ssltossl); - $wafstyle = ' style="display:none;"'; - $nowafstyle = ' style="display:table-row;"'; - $currwafdisplay = ' style="display: none"'; - $wafrangestyle = ' style="display: none"'; - $curr_remotip = 'n'; - $ssltossl = ' checked="checked"'; - if ($showdom) { - $wafstyle = ' style="display:table-row;"'; - $nowafstyle = ' style="display:none;"'; - if (keys(%{$values{$dom}})) { - if ($values{$dom}{remoteip} =~ /^[nmh]$/) { - $curr_remotip = $values{$dom}{remoteip}; - } - if ($curr_remotip eq 'h') { - $currwafdisplay = ' style="display:table-row"'; - $wafrangestyle = ' style="display:inline-block;"'; - } - if ($values{$dom}{'sslopt'}) { - $alltossl = ' checked="checked"'; - $ssltossl = ''; - } - } - if (($values{$dom}{'vpnint'} ne '') || ($values{$dom}{'vpnext'} ne '')) { - $vpndircheck = ' checked="checked"'; - $currwafvpn = ' style="display:table-row;"'; - $wafrangestyle = ' style="display:inline-block;"'; - } else { - $vpnaliascheck = ' checked="checked"'; - $currwafvpn = ' style="display:none;"'; + $datatable .= ' + '.$titles->{$type}.'
+   +   + '; + if ($type eq 'version') { + my @lcversions = &Apache::lonnet::all_loncaparevs(); + my $selector = ''; - foreach my $option ('m','h','n') { - my $sel; - if ($option eq $curr_remotip) { - $sel = ' selected="selected"'; - } - $datatable .= ''; - } - $datatable .= ''."\n". - ''. - $lt{'ipheader'}.': '. - ''. - ''."\n". - ''. - $lt{'trusted'}.':
'. - ''. - ''."\n". - '
'."\n". - ''. - ''.$lt{'vpnaccess'}.':
'. - ''.(' 'x2). - ''; - foreach my $item ('vpnint','vpnext') { - $datatable .= ''. - ''.$lt{$item}.':
'. - ''. - ''."\n"; - } - $datatable .= '
'."\n". - ''. - ''.$lt{'sslopt'}.':
'. - ''.(' 'x2). - ''."\n". - ''; - } - if (keys(%otherdoms)) { - foreach my $domain (sort(keys(%otherdoms))) { - $itemcount ++; - $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable .= ''. - ''.&mt('Domain: [_1]',''.$domain.'').''. - ''; - foreach my $item ('remoteip','ipheader','trusted','vpnint','vpnext','sslopt') { - my $showval = &mt('None'); - if ($item eq 'ssl') { - $showval = $lt{'ssltossl'}; - } - if ($values{$domain}{$item}) { - $showval = $values{$domain}{$item}; - if ($item eq 'ssl') { - $showval = $lt{'alltossl'}; - } elsif ($item eq 'remoteip') { - $showval = $ip_methods{$values{$domain}{$item}}; + $selector .= ' '; + $datatable .= &mt('remote server must be version: [_1] or later',$selector); + } else { + $datatable.= '
'.(' 'x2). + ''. + "\n". + '
'; + my $rem; + for (my $i=0; $i<@locations; $i++) { + my ($showloc,$value,$checkedtype); + if (ref($by_location->{$locations[$i]}) eq 'ARRAY') { + my $ip = $by_location->{$locations[$i]}->[0]; + if (ref($by_ip->{$ip}) eq 'ARRAY') { + $value = join(':',@{$by_ip->{$ip}}); + $showloc = join(', ',@{$by_ip->{$ip}}); + if (ref($current{$type}) eq 'ARRAY') { + foreach my $loc (@{$by_ip->{$ip}}) { + if (grep(/^\Q$loc\E$/,@{$current{$type}})) { + $checkedtype = ' checked="checked"'; + last; + } + } + } } } - $datatable .= ''. - ''; + $rem = $i%($numinrow); + if ($rem == 0) { + if ($i > 0) { + $datatable .= ''; + } + $datatable .= ''; + } + $datatable .= ''; } - $datatable .= '
'.$lt{$item}.': '.$showval.'
'. + '
'; + $rem = @locations%($numinrow); + my $colsleft = $numinrow - $rem; + if ($colsleft > 1 ) { + $datatable .= ''. + ' '; + } elsif ($colsleft == 1) { + $datatable .= ' '; + } + $datatable .= ''; } + $datatable .= ''; + $itemcount ++; } } - $$rowtotal += $itemcount; - return $datatable; -} - -sub wafproxy_titles { - return &Apache::lonlocal::texthash( - remoteip => "Method for determining user's IP", - ipheader => 'Request header containing remote IP', - trusted => 'Trusted IP range(s)', - vpnaccess => 'Access from institutional VPN', - vpndirect => 'via regular hostname (no WAF)', - vpnaliased => 'via aliased hostname (WAF)', - vpnint => 'Internal IP Range(s) for VPN sessions', - vpnext => 'IP Range(s) for backend WAF connections', - sslopt => 'Forwarding http/https', - alltossl => 'WAF forwards both http and https requests to https', - ssltossl => 'WAF forwards http requests to http and https to https', - ); -} - -sub remoteip_methods { - return &Apache::lonlocal::texthash( - m => 'Use Apache mod_remoteip', - h => 'Use headers parsed by LON-CAPA', - n => 'Not in use', - ); + return ($datatable,$itemcount); } -sub print_usersessions { +sub print_ssl { my ($position,$dom,$settings,$rowtotal) = @_; - my ($css_class,$datatable,%checked,%choices); - my (%by_ip,%by_location,@intdoms); - &build_location_hashes(\@intdoms,\%by_ip,\%by_location); - - my @alldoms = &Apache::lonnet::all_domains(); - my %serverhomes = %Apache::lonnet::serverhomeIDs; - my %servers = &Apache::lonnet::internet_dom_servers($dom); - my %altids = &id_for_thisdom(%servers); + my ($css_class,$datatable); my $itemcount = 1; if ($position eq 'top') { - if (keys(%serverhomes) > 1) { - my %spareid = ¤t_offloads_to($dom,$settings,\%servers); - my ($curroffloadnow,$curroffloadoth); - if (ref($settings) eq 'HASH') { - if (ref($settings->{'offloadnow'}) eq 'HASH') { - $curroffloadnow = $settings->{'offloadnow'}; - } - if (ref($settings->{'offloadoth'}) eq 'HASH') { - $curroffloadoth = $settings->{'offloadoth'}; + my $primary_id = &Apache::lonnet::domain($dom,'primary'); + my $intdom = &Apache::lonnet::internet_dom($primary_id); + my $same_institution; + if ($intdom ne '') { + my $internet_names = &Apache::lonnet::get_internet_names($Apache::lonnet::perlvar{'lonHostID'}); + if (ref($internet_names) eq 'ARRAY') { + if (grep(/^\Q$intdom\E$/,@{$internet_names})) { + $same_institution = 1; } } - my $other_insts = scalar(keys(%by_location)); - $datatable .= &spares_row($dom,\%servers,\%spareid,\%serverhomes,\%altids, - $other_insts,$curroffloadnow,$curroffloadoth,$rowtotal); + } + $css_class = $itemcount%2?' class="LC_odd_row"':''; + $datatable = ''; + if ($same_institution) { + my %domservers = &Apache::lonnet::get_servers($dom); + $datatable .= &LONCAPA::SSL::print_certstatus(\%domservers,'web','domprefs'); } else { - $datatable .= ''. - &mt('Nothing to set here, as the cluster to which this domain belongs only contains one server.'). - ''; + $datatable .= &mt("You need to be logged into one of your own domain's servers to display information about the status of LON-CAPA SSL certificates."); } + $datatable .= ''; + $itemcount ++; } else { - if (keys(%by_location) == 0) { - $datatable .= ''. - &mt('Nothing to set here, as the cluster to which this domain belongs only contains one institution.'). - ''; - } else { - my %lt = &usersession_titles(); - my $numinrow = 5; - my $prefix; - my @types; - if ($position eq 'bottom') { - $prefix = 'remote'; - @types = ('version','excludedomain','includedomain'); - } else { - $prefix = 'hosted'; - @types = ('excludedomain','includedomain'); - } - my (%current,%checkedon,%checkedoff); - my @lcversions = &Apache::lonnet::all_loncaparevs(); - my @locations = sort(keys(%by_location)); - foreach my $type (@types) { - $checkedon{$type} = ''; - $checkedoff{$type} = ' checked="checked"'; - } - if (ref($settings) eq 'HASH') { - if (ref($settings->{$prefix}) eq 'HASH') { - foreach my $key (keys(%{$settings->{$prefix}})) { - $current{$key} = $settings->{$prefix}{$key}; - if ($key eq 'version') { - if ($current{$key} ne '') { - $checkedon{$key} = ' checked="checked"'; - $checkedoff{$key} = ''; - } - } elsif (ref($current{$key}) eq 'ARRAY') { - $checkedon{$key} = ' checked="checked"'; - $checkedoff{$key} = ''; - } + my %titles = &ssl_titles(); + my (%by_ip,%by_location,@intdoms,@instdoms); + &build_location_hashes(\@intdoms,\%by_ip,\%by_location,\@instdoms); + my @alldoms = &Apache::lonnet::all_domains(); + my %serverhomes = %Apache::lonnet::serverhomeIDs; + my @domservers = &Apache::lonnet::get_servers($dom); + my %servers = &Apache::lonnet::internet_dom_servers($dom); + my %altids = &id_for_thisdom(%servers); + if ($position eq 'middle') { + foreach my $type ('dom','intdom','other') { + my %checked; + $css_class = $itemcount%2?' class="LC_odd_row"':''; + $datatable .= ''.$titles{$type}.''. + ''; + my $skip; + if ($type eq 'dom') { + unless (keys(%servers) > 1) { + $datatable .= &mt('Nothing to set here, as there are no other servers/VMs'); + $skip = 1; } } - } - foreach my $type (@types) { - next if ($type ne 'version' && !@locations); - $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable .= ' - '.$lt{$type}.'
-   -   - '; - if ($type eq 'version') { - my $selector = ' '; - $datatable .= &mt('remote server must be version: [_1] or later',$selector); - } else { - $datatable.= '
'.(' 'x2). - ''. - "\n". - '
'; - my $rem; - for (my $i=0; $i<@locations; $i++) { - my ($showloc,$value,$checkedtype); - if (ref($by_location{$locations[$i]}) eq 'ARRAY') { - my $ip = $by_location{$locations[$i]}->[0]; - if (ref($by_ip{$ip}) eq 'ARRAY') { - $value = join(':',@{$by_ip{$ip}}); - $showloc = join(', ',@{$by_ip{$ip}}); - if (ref($current{$type}) eq 'ARRAY') { - foreach my $loc (@{$by_ip{$ip}}) { - if (grep(/^\Q$loc\E$/,@{$current{$type}})) { - $checkedtype = ' checked="checked"'; - last; - } - } - } + } + unless ($skip) { + $checked{'yes'} = ' checked="checked"'; + if (ref($settings) eq 'HASH') { + if (ref($settings->{'connect'}) eq 'HASH') { + if ($settings->{'connect'}->{$type} =~ /^(no|req)$/) { + $checked{$1} = $checked{'yes'}; + delete($checked{'yes'}); } } - $rem = $i%($numinrow); - if ($rem == 0) { - if ($i > 0) { - $datatable .= ''; - } - $datatable .= ''; - } - $datatable .= ''; } - $rem = @locations%($numinrow); - my $colsleft = $numinrow - $rem; - if ($colsleft > 1 ) { - $datatable .= ''; - } elsif ($colsleft == 1) { - $datatable .= ''; + foreach my $option ('no','yes','req') { + $datatable .= ''.(' 'x2); } - $datatable .= '
'. - ''. - '  
'; } $datatable .= ''; + $itemcount ++; + } + } else { + my $prefix = 'replication'; + my @types = ('certreq','nocertreq'); + if (keys(%by_location) == 0) { + $datatable .= ''. + &mt('Nothing to set here, as there are no other institutions'). + ''; $itemcount ++; + } else { + ($datatable,$itemcount) = + &rules_by_location($settings,$prefix,\%by_location,\%by_ip,\@types,\%titles); } } } @@ -7435,10 +4268,59 @@ sub print_usersessions { return $datatable; } +sub ssl_titles { + return &Apache::lonlocal::texthash ( + dom => 'LON-CAPA servers/VMs from same domain', + intdom => 'LON-CAPA servers/VMs from same "internet" domain', + other => 'External LON-CAPA servers/VMs', + connect => 'Connections to other servers', + replication => 'Replicating content to other institutions', + certreq => 'Client certificate required, but specific domains exempt', + nocertreq => 'No client certificate required, except for specific domains', + no => 'SSL not used', + yes => 'SSL Optional (used if available)', + req => 'SSL Required', + ); +} + +sub print_trust { + my ($prefix,$dom,$settings,$rowtotal) = @_; + my ($css_class,$datatable,%checked,%choices); + my (%by_ip,%by_location,@intdoms,@instdoms); + &build_location_hashes(\@intdoms,\%by_ip,\%by_location,\@instdoms); + my $itemcount = 1; + my %titles = &trust_titles(); + my @types = ('exc','inc'); + if ($prefix eq 'top') { + $prefix = 'content'; + } elsif ($prefix eq 'bottom') { + $prefix = 'msg'; + } + ($datatable,$itemcount) = &rules_by_location($settings,$prefix,\%by_location,\%by_ip,\@types,\%titles); + $$rowtotal += $itemcount; + return $datatable; +} + +sub trust_titles { + return &Apache::lonlocal::texthash( + content => "Access to this domain's content by others", + shared => "Access to other domain's content by this domain", + enroll => "Enrollment in this domain's courses by others", + othcoau => "Co-author roles in this domain for others", + coaurem => "Co-author roles for this domain's users elsewhere", + domroles => "Domain roles in this domain assignable to others", + catalog => "Course Catalog for this domain displayed elsewhere", + reqcrs => "Requests for creation of courses in this domain by others", + msg => "Users in other domains can send messages to this domain", + exc => "Allow all, but exclude specific domains", + inc => "Deny all, but include specific domains", + ); +} + sub build_location_hashes { - my ($intdoms,$by_ip,$by_location) = @_; + my ($intdoms,$by_ip,$by_location,$instdoms) = @_; return unless((ref($intdoms) eq 'ARRAY') && (ref($by_ip) eq 'HASH') && - (ref($by_location) eq 'HASH')); + (ref($by_location) eq 'HASH') && (ref($instdoms) eq 'ARRAY')); my %iphost = &Apache::lonnet::get_iphost(); my $primary_id = &Apache::lonnet::domain($env{'request.role.domain'},'primary'); my $primary_ip = &Apache::lonnet::get_host_ip($primary_id); @@ -7455,7 +4337,13 @@ sub build_location_hashes { foreach my $id (@{$iphost{$ip}}) { my $location = &Apache::lonnet::internet_dom($id); if ($location) { - next if (grep(/^\Q$location\E$/,@{$intdoms})); + if (grep(/^\Q$location\E$/,@{$intdoms})) { + my $dom = &Apache::lonnet::host_domain($id); + unless (grep(/^\Q$dom\E/,@{$instdoms})) { + push(@{$instdoms},$dom); + } + next; + } if (ref($by_ip->{$ip}) eq 'ARRAY') { unless(grep(/^\Q$location\E$/,@{$by_ip->{$ip}})) { push(@{$by_ip->{$ip}},$location); @@ -7563,8 +4451,7 @@ sub current_offloads_to { } sub spares_row { - my ($dom,$servers,$spareid,$serverhomes,$altids,$other_insts, - $curroffloadnow,$curroffloadoth,$rowtotal) = @_; + my ($dom,$servers,$spareid,$serverhomes,$altids,$curroffloadnow,$rowtotal) = @_; my $css_class; my $numinrow = 4; my $itemcount = 1; @@ -7584,34 +4471,22 @@ sub spares_row { } } next unless (ref($spareid->{$server}) eq 'HASH'); - my ($checkednow,$checkedoth); + my $checkednow; if (ref($curroffloadnow) eq 'HASH') { if ($curroffloadnow->{$server}) { $checkednow = ' checked="checked"'; } } - if (ref($curroffloadoth) eq 'HASH') { - if ($curroffloadoth->{$server}) { - $checkedoth = ' checked="checked"'; - } - } $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; $datatable .= ' '. &mt('[_1] when busy, offloads to:' ,''.$server.'').'
'. - ''."\n". + ''."\n". ''. + ' '.&mt('Switch active users on next access').''. "\n"; - if ($other_insts) { - $datatable .= '
'. - ''."\n". - ''. - "\n"; - } my (%current,%canselect); my @choices = &possible_newspares($server,$spareid->{$server},$serverhomes,$altids); @@ -7735,13 +4610,13 @@ sub print_loadbalancing { my $numinrow = 1; my $datatable; my %servers = &Apache::lonnet::internet_dom_servers($dom); - my (%currbalancer,%currtargets,%currrules,%existing,%currcookies); + 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,\%currcookies); + \%currtargets,\%currrules); } else { return; } @@ -7815,12 +4690,6 @@ sub print_loadbalancing { my ($numspares,@spares) = &count_servers($lonhost,%servers); my @sparestypes = ('primary','default'); my %typetitles = &sparestype_titles(); - my %hostherechecked = ( - no => ' checked="checked"', - ); - my %balcookiechecked = ( - no => ' checked="checked"', - ); foreach my $sparetype (@sparestypes) { my $targettable; for (my $i=0; $i<$numspares; $i++) { @@ -7866,35 +4735,8 @@ sub print_loadbalancing { $datatable .= ''.$typetitles{$sparetype}.'
'. ''.$targettable.'

'; } - $hostherechecked{$sparetype} = ''; - if (ref($currtargets{$lonhost}) eq 'HASH') { - if (ref($currtargets{$lonhost}{$sparetype}) eq 'ARRAY') { - if (grep(/^\Q$lonhost\E$/,@{$currtargets{$lonhost}{$sparetype}})) { - $hostherechecked{$sparetype} = ' checked="checked"'; - $hostherechecked{'no'} = ''; - } - } - } - } - if ($currcookies{$lonhost}) { - %balcookiechecked = ( - yes => ' checked="checked"', - ); } - $datatable .= &mt('Hosting on balancer itself').'
'. - '
'; - foreach my $sparetype (@sparestypes) { - $datatable .= '
'; - } - $datatable .= &mt('Use balancer cookie').'
'. - '
'. - '
'. - '
'. + $datatable .= '
'. &loadbalancing_rules($dom,$intdom,$currrules{$lonhost}, $othertitle,$usertypes,$types,\%servers, \%currbalancer,$lonhost, @@ -7908,11 +4750,10 @@ sub print_loadbalancing { } sub get_loadbalancers_config { - my ($servers,$existing,$currbalancer,$currtargets,$currrules,$currcookies) = @_; + 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') && - (ref($currcookies) eq 'HASH')); + (ref($currtargets) eq 'HASH') && (ref($currrules) eq 'HASH')); if (keys(%{$existing}) > 0) { my $oldlonhost; foreach my $key (sort(keys(%{$existing}))) { @@ -7931,9 +4772,6 @@ sub get_loadbalancers_config { $currbalancer->{$key} = 1; $currtargets->{$key} = $existing->{$key}{'targets'}; $currrules->{$key} = $existing->{$key}{'rules'}; - if ($existing->{$key}{'cookie'}) { - $currcookies->{$key} = 1; - } } } } else { @@ -7989,14 +4827,9 @@ sub loadbalancing_titles { '_LC_ipchange' => &mt('Non-SSO users with IP mismatch'), ); my @alltypes = ('_LC_adv','_LC_author','_LC_internetdom','_LC_external','_LC_ipchangesso','_LC_ipchange'); - my @available; if (ref($types) eq 'ARRAY') { - @available = @{$types}; - } - unless (grep(/^default$/,@available)) { - push(@available,'default'); + unshift(@alltypes,@{$types},'default'); } - unshift(@alltypes,@available); my %titles; foreach my $type (@alltypes) { if ($type =~ /^_LC_/) { @@ -8037,7 +4870,7 @@ sub loadbalance_rule_row { } my $space; if ($islast && $num == 1) { - $space = '
 
'; + $space = '
 
'; } my $output = ''.$space. @@ -8119,21 +4952,15 @@ sub sparestype_titles { sub contact_titles { my %titles = &Apache::lonlocal::texthash ( - 'supportemail' => 'Support E-mail address', - 'adminemail' => 'Default Server Admin E-mail address', - 'errormail' => 'Error reports to be e-mailed to', - 'packagesmail' => 'Package update alerts to be e-mailed to', - 'helpdeskmail' => "Helpdesk requests from all users in this domain", - 'otherdomsmail' => 'Helpdesk requests from users in other (unconfigured) domains', - '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', + 'supportemail' => 'Support E-mail address', + 'adminemail' => 'Default Server Admin E-mail address', + 'errormail' => 'Error reports to be e-mailed to', + 'packagesmail' => 'Package update alerts to be e-mailed to', + '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', - 'hostipmail' => 'E-mail from nightly check of hostname/IP network changes', - 'errorthreshold' => 'Error count threshold for status e-mail to admin(s)', - 'errorsysmail' => 'Error count threshold for e-mail to developer group', - 'errorweights' => 'Weights used to compute error count', - 'errorexcluded' => 'Servers with unsent updates excluded from count', ); my %short_titles = &Apache::lonlocal::texthash ( adminemail => 'Admin E-mail address', @@ -8142,45 +4969,17 @@ sub contact_titles { return (\%titles,\%short_titles); } -sub helpform_fields { - my %titles = &Apache::lonlocal::texthash ( - 'username' => 'Name', - 'user' => 'Username/domain', - 'phone' => 'Phone', - 'cc' => 'Cc e-mail', - 'course' => 'Course Details', - 'section' => 'Sections', - 'screenshot' => 'File upload', - ); - my @fields = ('username','phone','user','course','section','cc','screenshot'); - my %possoptions = ( - username => ['yes','no','req'], - phone => ['yes','no','req'], - user => ['yes','no'], - cc => ['yes','no'], - course => ['yes','no'], - section => ['yes','no'], - screenshot => ['yes','no'], - ); - my %fieldoptions = &Apache::lonlocal::texthash ( - 'yes' => 'Optional', - 'req' => 'Required', - 'no' => "Not shown", - ); - return (\@fields,\%titles,\%fieldoptions,\%possoptions); -} - sub tool_titles { my %titles = &Apache::lonlocal::texthash ( aboutme => 'Personal web page', blog => 'Blog', webdav => 'WebDAV', portfolio => 'Portfolio', - timezone => 'Can set time zone', official => 'Official courses (with institutional codes)', unofficial => 'Unofficial courses', community => 'Communities', textbook => 'Textbook courses', + placement => 'Placement tests', ); return %titles; } @@ -8191,7 +4990,7 @@ sub courserequest_titles { unofficial => 'Unofficial', community => 'Communities', textbook => 'Textbook', - lti => 'LTI Provider', + placement => 'Placement tests', norequest => 'Not allowed', approval => 'Approval by Dom. Coord.', validate => 'With validation', @@ -8305,7 +5104,7 @@ sub print_usercreation { } } else { my @contexts = ('author','course','domain'); - my @authtypes = ('int','krb4','krb5','loc','lti'); + my @authtypes = ('int','krb4','krb5','loc'); my %checked; if (ref($settings) eq 'HASH') { if (ref($settings->{'authtypes'}) eq 'HASH') { @@ -8356,8 +5155,7 @@ sub print_usercreation { sub print_selfcreation { my ($position,$dom,$settings,$rowtotal) = @_; - my (@selfcreate,$createsettings,$processing,$emailoptions,$emailverified, - $emaildomain,$datatable); + my (@selfcreate,$createsettings,$processing,$datatable); if (ref($settings) eq 'HASH') { if (ref($settings->{'cancreate'}) eq 'HASH') { $createsettings = $settings->{'cancreate'}; @@ -8374,22 +5172,12 @@ sub print_selfcreation { if (ref($createsettings->{'selfcreateprocessing'}) eq 'HASH') { $processing = $createsettings->{'selfcreateprocessing'}; } - if (ref($createsettings->{'emailoptions'}) eq 'HASH') { - $emailoptions = $createsettings->{'emailoptions'}; - } - if (ref($createsettings->{'emailverified'}) eq 'HASH') { - $emailverified = $createsettings->{'emailverified'}; - } - if (ref($createsettings->{'emaildomain'}) eq 'HASH') { - $emaildomain = $createsettings->{'emaildomain'}; - } } } } my %radiohash; my $numinrow = 4; map { $radiohash{'cancreate_'.$_} = 1; } @selfcreate; - my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); if ($position eq 'top') { my %choices = &Apache::lonlocal::texthash ( cancreate_login => 'Institutional Login', @@ -8404,12 +5192,14 @@ sub print_selfcreation { ($datatable,$itemcount) = &radiobutton_prefs(\%radiohash,\@toggles,\%defaultchecked, \%choices,$itemcount,$onclick); $$rowtotal += $itemcount; + + my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); if (ref($usertypes) eq 'HASH') { if (keys(%{$usertypes}) > 0) { $datatable .= &insttypes_row($createsettings,$types,$usertypes, $dom,$numinrow,$othertitle, - 'statustocreate',$rowtotal); + 'statustocreate',$$rowtotal); $$rowtotal ++; } } @@ -8422,7 +5212,7 @@ sub print_selfcreation { $datatable .= ''. ''.&mt('Mapping of Shibboleth environment variable names to user data fields (SSO auth)').''. ''."\n". - ''."\n"; + '
\n". - '\n"; + $$rowtotal ++; return $output; } sub captcha_choice { - my ($context,$settings,$itemcount,$customcss,$rowstyle) = @_; + my ($context,$settings,$itemcount) = @_; my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext, $vertext,$currver); my %lt = &captcha_phrases(); $keyentry = 'hidden'; - my $colspan=2; if ($context eq 'cancreate') { $rowname = &mt('CAPTCHA validation'); } elsif ($context eq 'login') { $rowname = &mt('"Contact helpdesk" CAPTCHA validation'); - } elsif ($context eq 'passwords') { - $rowname = &mt('"Forgot Password" CAPTCHA validation'); - $colspan=1; } if (ref($settings) eq 'HASH') { if ($settings->{'captcha'}) { @@ -8902,22 +5412,9 @@ sub captcha_choice { } else { $checked{'original'} = ' checked="checked"'; } - my $css_class; - if ($itemcount%2) { - $css_class = 'LC_odd_row'; - } - if ($customcss) { - $css_class .= " $customcss"; - } - $css_class =~ s/^\s+//; - if ($css_class) { - $css_class = ' class="'.$css_class.'"'; - } - if ($rowstyle) { - $css_class .= ' style="'.$rowstyle.'"'; - } + my $css_class = $itemcount%2?' class="LC_odd_row"':''; my $output = ''. - ''; @@ -9853,7 +6172,7 @@ sub print_coursecategories { .'' .''."\n"; $itemcount ++; - foreach my $default ('instcode','communities') { + foreach my $default ('instcode','communities','placement') { if ((!grep(/^\Q$default\E$/,@{$cats[0]})) || ($cathash->{$default.'::0'} eq '')) { $css_class = $itemcount%2?' class="LC_odd_row"':''; my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','$default"."_pos','$lastidx'".');"'; @@ -9886,7 +6205,7 @@ sub print_coursecategories { $datatable .= &initialize_categories($itemcount); } } else { - $datatable .= '' + $datatable .= '' .&initialize_categories($itemcount); } $$rowtotal += $itemcount; @@ -9934,7 +6253,7 @@ sub print_serverstatuses { ''. ''. - ''."\n"; + ''."\n"; } $$rowtotal += $rownum; return $datatable; @@ -9942,31 +6261,14 @@ 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','diskusage','coursecatalog'); + 'checksums','clusterstatus','certstatus','metadata_keywords', + 'metadata_harvest','takeoffline','takeonline','showenv','toggledebug', + 'ping','domconf','uniquecodes','diskusage','coursecatalog'); } sub defaults_javascript { my ($settings) = @_; - return unless (ref($settings) eq 'HASH'); - my $portal_js = <<"ENDPORTAL"; - -function portalExtras(caller) { - var x = caller.value; - var y = new Array('email','web'); - for (var i=0; i 0) { - z.style.display = 'block'; - } else { - z.style.display = 'none'; - } - } - } -} -ENDPORTAL + return unless (ref($settings) eq 'HASH'); if ((ref($settings->{'inststatusorder'}) eq 'ARRAY') && (ref($settings->{'inststatustypes'}) eq 'HASH')) { my $maxnum = scalar(@{$settings->{'inststatusorder'}}); if ($maxnum eq '') { @@ -10020,112 +6322,11 @@ $jstext return; } -$portal_js - -// ]]> - - -ENDSCRIPT - } else { -return <<"ENDSCRIPT"; - ENDSCRIPT } - return; -} - -sub passwords_javascript { - my ($prefix) = @_; - my %intalert; - if ($prefix eq 'passwords') { - %intalert = &Apache::lonlocal::texthash ( - authcheck => 'Warning: disallowing login for an authenticated user if the stored cost is less than the default will require a password reset by/for the user.', - authcost => 'Warning: bcrypt encryption cost for internal authentication must be an integer.', - passmin => 'Warning: minimum password length must be a positive integer greater than 6.', - passmax => 'Warning: maximum password length must be a positive integer (or blank).', - passnum => 'Warning: number of previous passwords to save must be a positive integer (or blank).', - ); - } elsif (($prefix eq 'ltisecrets') || ($prefix eq 'toolsecrets')) { - %intalert = &Apache::lonlocal::texthash ( - passmin => 'Warning: minimum secret length must be a positive integer greater than 6.', - passmax => 'Warning: maximum secret length must be a positive integer (or blank).', - ); - } - &js_escape(\%intalert); - my $defmin = $Apache::lonnet::passwdmin; - my $intauthjs; - if ($prefix eq 'passwords') { $intauthjs = <<"ENDSCRIPT"; - -function warnIntAuth(field) { - if (field.name == 'intauth_check') { - if (field.value == '2') { - alert('$intalert{authcheck}'); - } - } - if (field.name == 'intauth_cost') { - field.value.replace(/\s/g,''); - if (field.value != '') { - var regexdigit=/^\\d+\$/; - if (!regexdigit.test(field.value)) { - alert('$intalert{authcost}'); - } - } - } - return; -} - -ENDSCRIPT - - } - - $intauthjs .= <<"ENDSCRIPT"; - -function warnInt$prefix(field) { - field.value.replace(/^\s+/,''); - field.value.replace(/\s+\$/,''); - var regexdigit=/^\\d+\$/; - if (field.name == '${prefix}_min') { - if (field.value == '') { - alert('$intalert{passmin}'); - field.value = '$defmin'; - } else { - if (!regexdigit.test(field.value)) { - alert('$intalert{passmin}'); - field.value = '$defmin'; - } - var minval = parseInt(field.value,10); - if (minval < $defmin) { - alert('$intalert{passmin}'); - field.value = '$defmin'; - } - } - } else { - if (field.value == '0') { - field.value = ''; - } - if (field.value != '') { - if (!regexdigit.test(field.value)) { - if (field.name == '${prefix}_max') { - alert('$intalert{passmax}'); - } else { - if (field.name == '${prefix}_numsaved') { - alert('$intalert{passnum}'); - } - } - field.value = ''; - } - } - } - return; -} - -ENDSCRIPT - return &Apache::lonhtmlcommon::scripttag($intauthjs); } sub coursecategories_javascript { @@ -10152,9 +6353,11 @@ sub coursecategories_javascript { } my $instcode_reserved = &mt('The name: [_1] is a reserved category.','"instcode"'); my $communities_reserved = &mt('The name: [_1] is a reserved category.','"communities"'); + my $placement_reserved = &mt('The name: [_1] is a reserved category.','"placement"'); my $choose_again = "\n".&mt('Please use a different name for the new top level category.'); &js_escape(\$instcode_reserved); &js_escape(\$communities_reserved); + &js_escape(\$placement_reserved); &js_escape(\$choose_again); $output = <<"ENDSCRIPT";
'."\n"; for (my $i=0; $i<@fields; $i++) { $rem = $i%($numperrow); if ($rem == 0) { @@ -8454,430 +5244,150 @@ sub print_selfcreation { $$rowtotal ++; } elsif ($position eq 'middle') { my %domconf = &Apache::lonnet::get_dom('configuration',['usermodification'],$dom); - my @posstypes; + my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); + $usertypes->{'default'} = $othertitle; if (ref($types) eq 'ARRAY') { - @posstypes = @{$types}; - } - unless (grep(/^default$/,@posstypes)) { - push(@posstypes,'default'); - } - my %usertypeshash; - if (ref($usertypes) eq 'HASH') { - %usertypeshash = %{$usertypes}; - } - $usertypeshash{'default'} = $othertitle; - foreach my $status (@posstypes) { - $datatable .= &modifiable_userdata_row('selfcreate',$status,$domconf{'usermodification'}, - $numinrow,$$rowtotal,\%usertypeshash); - $$rowtotal ++; + push(@{$types},'default'); + $usertypes->{'default'} = $othertitle; + foreach my $status (@{$types}) { + $datatable .= &modifiable_userdata_row('selfcreate',$status,$domconf{'usermodification'}, + $numinrow,$$rowtotal,$usertypes); + $$rowtotal ++; + } } } else { my %choices = &Apache::lonlocal::texthash ( - 'cancreate_email' => 'Non-institutional username (via e-mail verification)', + cancreate_email => 'E-mail address as username', ); my @toggles = sort(keys(%choices)); my %defaultchecked = ( 'cancreate_email' => 'off', ); - my $customclass = 'LC_selfcreate_email'; - my $classprefix = 'LC_canmodify_emailusername_'; - my $optionsprefix = 'LC_options_emailusername_'; + my $itemcount = 0; my $display = 'none'; - my $rowstyle = 'display:none'; if (grep(/^\Qemail\E$/,@selfcreate)) { $display = 'block'; - $rowstyle = 'display:table-row'; } - my $onclick = "toggleRows(this.form,'cancreate_email','selfassign','$customclass','$classprefix','$optionsprefix');"; - ($datatable,$$rowtotal) = &radiobutton_prefs(\%radiohash,\@toggles,\%defaultchecked, - \%choices,$$rowtotal,$onclick); - $datatable .= &print_requestmail($dom,'selfcreation',$createsettings,$rowtotal,$customclass, - $rowstyle); - $$rowtotal ++; - $datatable .= &captcha_choice('cancreate',$createsettings,$$rowtotal,$customclass, - $rowstyle); - $$rowtotal ++; - my (@ordered,@posstypes,%usertypeshash); + my $onclick = "toggleDisplay(this.form,'emailoptions');"; + my $additional = '
'; my %domdefaults = &Apache::lonnet::get_domain_defaults($dom); - my ($emailrules,$emailruleorder) = - &Apache::lonnet::inst_userrules($dom,'email'); - my $primary_id = &Apache::lonnet::domain($dom,'primary'); - my $intdom = &Apache::lonnet::internet_dom($primary_id); - if (ref($types) eq 'ARRAY') { - @posstypes = @{$types}; - } - if (@posstypes) { - unless (grep(/^default$/,@posstypes)) { - push(@posstypes,'default'); - } - if (ref($usertypes) eq 'HASH') { - %usertypeshash = %{$usertypes}; - } - my $currassign; - if (ref($domdefaults{'inststatusguest'}) eq 'ARRAY') { - $currassign = { - selfassign => $domdefaults{'inststatusguest'}, - }; - @ordered = @{$domdefaults{'inststatusguest'}}; - } else { - $currassign = { selfassign => [] }; - } - my $onclicktypes = "toggleDataRow(this.form,'selfassign','$customclass','$optionsprefix',);". - "toggleDataRow(this.form,'selfassign','$customclass','$classprefix',1);"; - $datatable .= &insttypes_row($currassign,$types,$usertypes,$dom, - $numinrow,$othertitle,'selfassign', - $rowtotal,$onclicktypes,$customclass, - $rowstyle); - $$rowtotal ++; - $usertypeshash{'default'} = $othertitle; - foreach my $status (@posstypes) { - my $css_class; - if ($$rowtotal%2) { - $css_class = 'LC_odd_row '; - } - $css_class .= $customclass; - my $rowid = $optionsprefix.$status; - my $hidden = 1; - my $currstyle = 'display:none'; - if (grep(/^\Q$status\E$/,@ordered)) { - $currstyle = $rowstyle; - $hidden = 0; - } - $datatable .= &noninst_users($processing,$emailverified,$emailoptions,$emaildomain, - $emailrules,$emailruleorder,$settings,$status,$rowid, - $usertypeshash{$status},$css_class,$currstyle,$intdom); - unless ($hidden) { - $$rowtotal ++; + my $usertypes = {}; + my $order = []; + if ((ref($domdefaults{'inststatustypes'}) eq 'HASH') && (ref($domdefaults{'inststatusguest'}) eq 'ARRAY')) { + $usertypes = $domdefaults{'inststatustypes'}; + $order = $domdefaults{'inststatusguest'}; + } + if (ref($order) eq 'ARRAY') { + push(@{$order},'default'); + if (@{$order} > 1) { + $usertypes->{'default'} = &mt('Other users'); + $additional .= ''; + foreach my $status (@{$order}) { + $additional .= ''; + } + $additional .= ''; + foreach my $status (@{$order}) { + $additional .= ''; } + $additional .= '
'.$usertypes->{$status}.'
'.&email_as_username($rowtotal,$processing,$status).'
'; + } else { + $usertypes->{'default'} = &mt('All users'); + $additional .= &email_as_username($rowtotal,$processing); } - } else { - my $css_class; - if ($$rowtotal%2) { - $css_class = 'LC_odd_row '; - } - $css_class .= $customclass; - $usertypeshash{'default'} = $othertitle; - $datatable .= &noninst_users($processing,$emailverified,$emailoptions,$emaildomain, - $emailrules,$emailruleorder,$settings,'default','', - $othertitle,$css_class,$rowstyle,$intdom); - $$rowtotal ++; } + $additional .= '
'."\n"; + + ($datatable,$itemcount) = &radiobutton_prefs(\%radiohash,\@toggles,\%defaultchecked, + \%choices,$$rowtotal,$onclick,$additional); + $$rowtotal ++; + $datatable .= &print_requestmail($dom,'selfcreation',$createsettings,$rowtotal); + $$rowtotal ++; my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info(); $numinrow = 1; - if (@posstypes) { - foreach my $status (@posstypes) { - my $rowid = $classprefix.$status; - my $datarowstyle = 'display:none'; - if (grep(/^\Q$status\E$/,@ordered)) { - $datarowstyle = $rowstyle; - } + if (ref($order) eq 'ARRAY') { + foreach my $status (@{$order}) { $datatable .= &modifiable_userdata_row('cancreate','emailusername_'.$status,$settings, - $numinrow,$$rowtotal,\%usertypeshash,$infofields, - $infotitles,$rowid,$customclass,$datarowstyle); - unless ($datarowstyle eq 'display:none') { - $$rowtotal ++; - } + $numinrow,$$rowtotal,$usertypes,$infofields,$infotitles); + $$rowtotal ++; } - } else { - $datatable .= &modifiable_userdata_row('cancreate','emailusername_default',$settings, - $numinrow,$$rowtotal,\%usertypeshash,$infofields, - $infotitles,'',$customclass,$rowstyle); } - } - return $datatable; -} - -sub selfcreate_javascript { - return <<"ENDSCRIPT"; - - - -ENDSCRIPT -} - -sub noninst_users { - my ($processing,$emailverified,$emailoptions,$emaildomain,$emailrules, - $emailruleorder,$settings,$type,$rowid,$typetitle,$css_class,$rowstyle,$intdom) = @_; - my $class = 'LC_left_item'; - if ($css_class) { - $css_class = ' class="'.$css_class.'"'; - } - if ($rowid) { - $rowid = ' id="'.$rowid.'"'; - } - if ($rowstyle) { - $rowstyle = ' style="'.$rowstyle.'"'; - } - my ($output,$description); - if ($type eq 'default') { - $description = &mt('Requests for: [_1]',$typetitle); - } else { - $description = &mt('Requests for: [_1] (status self-reported)',$typetitle); - } - $output = ''. - "
$description'. - ''; - my %headers = &Apache::lonlocal::texthash( - approve => 'Processing', - email => 'E-mail', - username => 'Username', - ); - foreach my $item ('approve','email','username') { - $output .= ''; - } - $output .= ''; - foreach my $item ('approve','email','username') { - $output .= ''."\n"; } - $output .= "
'.$headers{$item}.'
'; - my (%choices,@options,$hashref,$defoption,$name,$onclick,$hascustom); - if ($item eq 'approve') { - %choices = &Apache::lonlocal::texthash ( - automatic => 'Automatically approved', - approval => 'Queued for approval', - ); - @options = ('automatic','approval'); - $hashref = $processing; - $defoption = 'automatic'; - $name = 'cancreate_emailprocess_'.$type; - } elsif ($item eq 'email') { - %choices = &Apache::lonlocal::texthash ( - any => 'Any e-mail', - inst => 'Institutional only', - noninst => 'Non-institutional only', - custom => 'Custom restrictions', - ); - @options = ('any','inst','noninst'); - my $showcustom; - if (ref($emailrules) eq 'HASH') { - if (keys(%{$emailrules}) > 0) { - push(@options,'custom'); - $showcustom = 'cancreate_emailrule'; - if (ref($settings) eq 'HASH') { - if (ref($settings->{'email_rule'}) eq 'ARRAY') { - foreach my $rule (@{$settings->{'email_rule'}}) { - if (exists($emailrules->{$rule})) { - $hascustom ++; - } - } - } elsif (ref($settings->{'email_rule'}) eq 'HASH') { - if (ref($settings->{'email_rule'}{$type}) eq 'ARRAY') { - foreach my $rule (@{$settings->{'email_rule'}{$type}}) { - if (exists($emailrules->{$rule})) { - $hascustom ++; - } - } - } - } + if ($processing->{'default'} eq $option) { + $checked = ' checked="checked"'; } } - } - $onclick = ' onclick="toggleEmailOptions(this.form,'."'cancreate_emailoptions','$showcustom',". - "'cancreate_emaildomain','$type'".');"'; - $hashref = $emailoptions; - $defoption = 'any'; - $name = 'cancreate_emailoptions_'.$type; - } elsif ($item eq 'username') { - %choices = &Apache::lonlocal::texthash ( - all => 'Same as e-mail', - first => 'Omit @domain', - free => 'Free to choose', - ); - @options = ('all','first','free'); - $hashref = $emailverified; - $defoption = 'all'; - $name = 'cancreate_usernameoptions_'.$type; - } - foreach my $option (@options) { - my $checked; - if (ref($hashref) eq 'HASH') { - if ($type eq '') { - if (!exists($hashref->{'default'})) { - if ($option eq $defoption) { - $checked = ' checked="checked"'; - } - } else { - if ($hashref->{'default'} eq $option) { - $checked = ' checked="checked"'; - } + } else { + if (!exists($processing->{$type})) { + if ($option eq 'automatic') { + $checked = ' checked="checked"'; } } else { - if (!exists($hashref->{$type})) { - if ($option eq $defoption) { - $checked = ' checked="checked"'; - } - } else { - if ($hashref->{$type} eq $option) { - $checked = ' checked="checked"'; - } - } - } - } elsif (($item eq 'email') && ($hascustom)) { - if ($option eq 'custom') { - $checked = ' checked="checked"'; - } - } elsif ($option eq $defoption) { - $checked = ' checked="checked"'; - } - $output .= '
'; - if ($item eq 'email') { - if ($option eq 'custom') { - my $id = 'cancreate_emailrule_'.$type; - my $display = 'none'; - if ($checked) { - $display = 'inline'; - } - my $numinrow = 2; - $output .= '
'. - ''.&mt('Disallow').''. - &user_formats_row('email',$settings,$emailrules, - $emailruleorder,$numinrow,'',$type); - '
'; - } elsif (($option eq 'inst') || ($option eq 'noninst')) { - my %text = &Apache::lonlocal::texthash ( - inst => 'must end:', - noninst => 'cannot end:', - ); - my $value; - if (ref($emaildomain) eq 'HASH') { - if (ref($emaildomain->{$type}) eq 'HASH') { - $value = $emaildomain->{$type}->{$option}; - } - } - if ($value eq '') { - $value = '@'.$intdom; - } - my $condition = 'cancreate_emaildomain_'.$option.'_'.$type; - my $display = 'none'; - if ($checked) { - $display = 'inline'; + if ($processing->{$type} eq $option) { + $checked = ' checked="checked"'; } - $output .= '
'. - ''.$text{$option}.' '. - ''. - '
'; } } + } elsif ($option eq 'automatic') { + $checked = ' checked="checked"'; + } + my $name = 'cancreate_emailprocess'; + if (($type ne '') && ($type ne 'default')) { + $name .= '_'.$type; + } + $output .= ''; + if ($type eq '') { + $output .= ' '; + } else { + $output .= '
'; } - $output .= '
'.$rowname.''."\n". + ''.$rowname.''."\n". ''. - ''; return $output; } @@ -9049,7 +5534,6 @@ sub authtype_names { krb4 => 'Kerberos 4', krb5 => 'Kerberos 5', loc => 'Local', - lti => 'LTI', ); return %lt; } @@ -9092,10 +5576,7 @@ sub print_usermodification { sub print_defaults { my ($position,$dom,$settings,$rowtotal) = @_; my $rownum = 0; - my ($datatable,$css_class,$titles); - unless ($position eq 'bottom') { - $titles = &defaults_titles($dom); - } + my ($datatable,$css_class); if ($position eq 'top') { my @items = ('auth_def','auth_arg_def','lang_def','timezone_def', 'datelocale_def','portal_def'); @@ -9108,6 +5589,7 @@ sub print_defaults { $defaults{$item} = $domdefaults{$item}; } } + my $titles = &defaults_titles($dom); foreach my $item (@items) { if ($rownum%2) { $css_class = ''; @@ -9118,13 +5600,12 @@ sub print_defaults { ''; $rownum ++; } - } elsif ($position eq 'middle') { - my %defaults; + } else { + my (%defaults); if (ref($settings) eq 'HASH') { - if ((ref($settings->{'inststatusorder'}) eq 'ARRAY') && (ref($settings->{'inststatustypes'}) eq 'HASH')) { + if ((ref($settings->{'inststatusorder'}) eq 'ARRAY') && (ref($settings->{'inststatustypes'}) eq 'HASH') && + (ref($settings->{'inststatusguest'}) eq 'ARRAY')) { my $maxnum = @{$settings->{'inststatusorder'}}; for (my $i=0; $i<$maxnum; $i++) { $css_class = $rownum%2?' class="LC_odd_row"':''; my $item = $settings->{'inststatusorder'}->[$i]; my $title = $settings->{'inststatustypes'}->{$item}; + my $guestok; + if (grep(/^\Q$item\E$/,@{$settings->{'inststatusguest'}})) { + $guestok = 1; + } my $chgstr = ' onchange="javascript:reorderTypes(this.form,'."'$item'".');"'; $datatable .= ''. ''. - ''; + ''. + ''; } $css_class = $rownum%2?' class="LC_odd_row"':''; my $chgstr = ' onchange="javascript:reorderTypes(this.form,'."'addinststatus_pos'".');"'; @@ -9216,28 +5697,17 @@ sub print_defaults { ''. ' '.&mt('(new)'). ''. + ''; ''."\n"; $rownum ++; } } - } else { - my ($unamemaprules,$ruleorder) = - &Apache::lonnet::inst_userrules($dom,'unamemap'); - $css_class = $rownum%2?' class="LC_odd_row"':''; - if ((ref($unamemaprules) eq 'HASH') && (ref($ruleorder) eq 'ARRAY')) { - my $numinrow = 2; - $datatable .= ''; - } - if ($datatable eq '') { - $datatable .= ''; - } } $$rowtotal += $rownum; return $datatable; @@ -9263,11 +5733,6 @@ sub defaults_titles { 'timezone_def' => 'Default timezone', 'datelocale_def' => 'Default locale for dates', 'portal_def' => 'Portal/Default URL', - 'email' => 'Email links use portal URL', - 'web' => 'Public web links use portal URL', - 'intauth_cost' => 'Encryption cost for bcrypt (positive integer)', - 'intauth_check' => 'Check bcrypt cost if authenticated', - 'intauth_switch' => 'Existing crypt-based switched to bcrypt on authentication', ); if ($dom) { my $uprimary_id = &Apache::lonnet::domain($dom,'primary'); @@ -9282,58 +5747,6 @@ sub defaults_titles { return (\%titles); } -sub print_scantron { - my ($r,$position,$dom,$confname,$settings,$rowtotal) = @_; - if ($position eq 'top') { - return &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal); - } else { - return &print_scantronconfig($dom,$settings,\$rowtotal); - } -} - -sub scantron_javascript { - return <<"ENDSCRIPT"; - - - -ENDSCRIPT - -} - sub print_scantronformat { my ($r,$dom,$confname,$settings,$rowtotal) = @_; my $itemcount = 1; @@ -9360,8 +5773,8 @@ sub print_scantronformat { if ($configuserok eq 'ok') { if ($author_ok eq 'ok') { my %legacyfile = ( - default => $Apache::lonnet::perlvar{'lonTabDir'}.'/default_scantronformat.tab', - custom => $Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab', + default => $Apache::lonnet::perlvar{'lonTabDir'}.'/default_scantronformat.tab', + custom => $Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab', ); my %md5chk; foreach my $type (keys(%legacyfile)) { @@ -9370,7 +5783,7 @@ sub print_scantronformat { } if ($md5chk{'default'} ne $md5chk{'custom'}) { foreach my $type (keys(%legacyfile)) { - ($scantronurls{$type},my $error) = + ($scantronurls{$type},my $error) = &legacy_scantronformat($r,$dom,$confname, $type,$legacyfile{$type}, $scantronurls{$type}, @@ -9381,13 +5794,13 @@ sub print_scantronformat { } if (keys(%error) == 0) { $is_custom = 1; - $confhash{'scantron'}{'scantronformat'} = + $confhash{'scantron'}{'scantronformat'} = $scantronurls{'custom'}; - my $putresult = + my $putresult = &Apache::lonnet::put_dom('configuration', \%confhash,$dom); if ($putresult ne 'ok') { - $error{'custom'} = + $error{'custom'} = ''. &mt('An error occurred updating the domain configuration: [_1]',$putresult).''; } @@ -9497,142 +5910,16 @@ sub legacy_scantronformat { my ($url,$error); my @statinfo = &Apache::lonnet::stat_file($newurl); if ((!@statinfo) || ($statinfo[0] eq 'no_such_dir')) { - my $modified = []; (my $result,$url) = - &Apache::lonconfigsettings::publishlogo($r,'copy',$legacyfile,$dom,$confname, - 'scantron','','',$newfile,$modified); - if ($result eq 'ok') { - &update_modify_urls($r,$modified); - } else { + &publishlogo($r,'copy',$legacyfile,$dom,$confname,'scantron', + '','',$newfile); + if ($result ne 'ok') { $error = &mt("An error occurred publishing the [_1] bubblesheet format file in RES space. Error was: [_2].",$newfile,$result); } } return ($url,$error); } -sub print_scantronconfig { - my ($dom,$settings,$rowtotal) = @_; - my $itemcount = 2; - my $is_checked = ' checked="checked"'; - my %optionson = ( - hdr => ' checked="checked"', - pad => ' checked="checked"', - rem => ' checked="checked"', - ); - my %optionsoff = ( - hdr => '', - pad => '', - rem => '', - ); - my $currcsvsty = 'none'; - my ($datatable,%csvfields,%checked,%onclick,%csvoptions); - my @fields = &scantroncsv_fields(); - my %titles = &scantronconfig_titles(); - if (ref($settings) eq 'HASH') { - if (ref($settings->{config}) eq 'HASH') { - if ($settings->{config}->{dat}) { - $checked{'dat'} = $is_checked; - } - if (ref($settings->{config}->{csv}) eq 'HASH') { - if (ref($settings->{config}->{csv}->{fields}) eq 'HASH') { - %csvfields = %{$settings->{config}->{csv}->{fields}}; - if (keys(%csvfields) > 0) { - $checked{'csv'} = $is_checked; - $currcsvsty = 'block'; - } - } - if (ref($settings->{config}->{csv}->{options}) eq 'HASH') { - %csvoptions = %{$settings->{config}->{csv}->{options}}; - foreach my $option (keys(%optionson)) { - unless ($csvoptions{$option}) { - $optionsoff{$option} = $optionson{$option}; - $optionson{$option} = ''; - } - } - } - } - } else { - $checked{'dat'} = $is_checked; - } - } else { - $checked{'dat'} = $is_checked; - } - $onclick{'csv'} = ' onclick="toggleScantron(this.form);"'; - my $css_class = $itemcount%2? ' class="LC_odd_row"':''; - $datatable = ''. - ''; - $$rowtotal ++; - return $datatable; -} - -sub scantronconfig_titles { - return &Apache::lonlocal::texthash( - dat => 'Standard format (.dat)', - csv => 'Comma separated values (.csv)', - hdr => 'Remove first line in file (contains column titles)', - pad => 'Prepend 0s to PaperID', - rem => 'Remove leading spaces (except Question Response columns)', - CODE => 'CODE', - ID => 'Student ID', - PaperID => 'Paper ID', - FirstName => 'First Name', - LastName => 'Last Name', - FirstQuestion => 'First Question Response', - Section => 'Section', - ); -} - -sub scantroncsv_fields { - return ('PaperID','LastName','FirstName','ID','Section','CODE','FirstQuestion'); -} - sub print_coursecategories { my ($position,$dom,$hdritem,$settings,$rowtotal) = @_; my $datatable; @@ -9675,7 +5962,7 @@ sub print_coursecategories { ''.$lt{$type}.' '; } - $datatable .= ''; + $datatable .= ''; $itemcount ++; } $$rowtotal += $itemcount; @@ -9688,6 +5975,10 @@ sub print_coursecategories { my $toggle_catscomm_dom = ' checked="checked" '; my $can_catcomm_comm = ' '; my $can_catcomm_dom = ' checked="checked" '; + my $toggle_catsplace_place = ' '; + my $toggle_catsplace_dom = ' checked="checked" '; + my $can_catplace_place = ' '; + my $can_catplace_dom = ' checked="checked" '; if (ref($settings) eq 'HASH') { if ($settings->{'togglecats'} eq 'crs') { @@ -9706,17 +5997,28 @@ sub print_coursecategories { $can_catcomm_comm = $can_catcomm_dom; $can_catcomm_dom = ' '; } + if ($settings->{'togglecatsplace'} eq 'place') { + $toggle_catsplace_place = $toggle_catsplace_dom; + $toggle_catsplace_dom = ' '; + } + if ($settings->{'categorizeplace'} eq 'place') { + $can_catplace_place = $can_catplace_dom; + $can_catplace_dom = ' '; + } } my %title = &Apache::lonlocal::texthash ( - togglecats => 'Show/Hide a course in catalog', - togglecatscomm => 'Show/Hide a community in catalog', - categorize => 'Assign a category to a course', - categorizecomm => 'Assign a category to a community', + togglecats => 'Show/Hide a course in catalog', + togglecatscomm => 'Show/Hide a community in catalog', + togglecatsplace => 'Show/Hide a placement test in catalog', + categorize => 'Assign a category to a course', + categorizecomm => 'Assign a category to a community', + categorizeplace => 'Assign a category to a placement test', ); my %level = &Apache::lonlocal::texthash ( - dom => 'Set in Domain', - crs => 'Set in Course', - comm => 'Set in Community', + dom => 'Set in Domain', + crs => 'Set in Course', + comm => 'Set in Community', + place => 'Set in Placement Test', ); $datatable = ''. ''. @@ -9746,8 +6048,22 @@ sub print_coursecategories { $can_catcomm_dom.' value="dom" />'.$level{'dom'}.' '. ''. + ''. + ''. + ''. + ''. + ''. + ''. ''; - $$rowtotal += 4; + $$rowtotal += 6; } else { my $css_class; my $itemcount = 1; @@ -9772,12 +6088,15 @@ sub print_coursecategories { my %default_names = ( instcode => &mt('Official courses'), communities => &mt('Communities'), + placement => &mt('Placement Tests'), ); if ((!grep(/^instcode$/,@{$cats[0]})) || ($cathash->{'instcode::0'} eq '') || (!grep(/^communities$/,@{$cats[0]})) || - ($cathash->{'communities::0'} eq '')) { + ($cathash->{'communities::0'} eq '') || + (!grep(/^placement$/,@{$cats[0]})) || + ($cathash->{'placement::0'} eq '')) { $maxnum ++; } my $lastidx; @@ -9798,7 +6117,7 @@ sub print_coursecategories { $datatable .= ''; } $datatable .= '
'."\n"; foreach my $option ('original','recaptcha','notused') { $output .= ''."\n". + '
'."\n". ''.$pubtext.' '."\n". '
'."\n". @@ -8950,19 +5447,23 @@ sub captcha_choice { } sub user_formats_row { - my ($type,$settings,$rules,$ruleorder,$numinrow,$rowcount,$status) = @_; + my ($type,$settings,$rules,$ruleorder,$numinrow,$rowcount) = @_; my $output; my %text = ( 'username' => 'new usernames', 'id' => 'IDs', + 'email' => 'self-created accounts (e-mail)', ); - unless (($type eq 'email') || ($type eq 'unamemap')) { - my $css_class = $rowcount%2?' class="LC_odd_row"':''; - $output = '
'. - &mt("Format rules to check for $text{$type}: "). - ''; + my $css_class = $rowcount%2?' class="LC_odd_row"':''; + $output = ''. + ''. + ''; - } + $output .= '
'; + if ($type eq 'email') { + $output .= &mt("Formats disallowed for $text{$type}: "); + } else { + $output .= &mt("Format rules to check for $text{$type}: "); } + $output .= ''; my $rem; if (ref($ruleorder) eq 'ARRAY') { for (my $i=0; $i<@{$ruleorder}; $i++) { @@ -8980,41 +5481,25 @@ sub user_formats_row { if (grep(/^\Q$ruleorder->[$i]\E$/,@{$settings->{$type.'_rule'}})) { $check = ' checked="checked" '; } - } elsif ((ref($settings->{$type.'_rule'}) eq 'HASH') && ($status ne '')) { - if (ref($settings->{$type.'_rule'}->{$status}) eq 'ARRAY') { - if (grep(/^\Q$ruleorder->[$i]\E$/,@{$settings->{$type.'_rule'}->{$status}})) { - $check = ' checked="checked" '; - } - } } } - my $name = $type.'_rule'; - if ($type eq 'email') { - $name .= '_'.$status; - } $output .= ''; } } $rem = @{$ruleorder}%($numinrow); } - my $colsleft; - if ($rem) { - $colsleft = $numinrow - $rem; - } + my $colsleft = $numinrow - $rem; if ($colsleft > 1 ) { $output .= ''; } elsif ($colsleft == 1) { $output .= ''; } - $output .= ''; - unless (($type eq 'email') || ($type eq 'unamemap')) { - $output .= '
'. ''. '  
'.$titles->{$item}. ''; if ($item eq 'auth_def') { - my @authtypes = ('internal','krb4','krb5','localauth','lti'); + my @authtypes = ('internal','krb4','krb5','localauth'); my %shortauth = ( internal => 'int', krb4 => 'krb4', krb5 => 'krb5', - localauth => 'loc', - lti => 'lti', + localauth => 'loc' ); my %authnames = &authtype_names(); foreach my $auth (@authtypes) { @@ -9145,42 +5626,31 @@ sub print_defaults { } elsif ($item eq 'lang_def') { my $includeempty = 1; $datatable .= &Apache::loncommon::select_language($item,$defaults{$item},$includeempty); - } elsif ($item eq 'portal_def') { - $datatable .= ''; - my $portalsty = 'none'; - if ($defaults{$item}) { - $portalsty = 'block'; - } - foreach my $field ('email','web') { - my $checkedoff = ' checked="checked"'; - my $checkedon; - if ($defaults{$item.'_'.$field}) { - $checkedon = $checkedoff; - $checkedoff = ''; - } - $datatable .= '
'. - ''.$titles->{$field}.' '. - ''. - (' 'x2). - ''. - '
'; - } } else { - $datatable .= ''; + my $size; + if ($item eq 'portal_def') { + $size = ' size="25"'; + } + $datatable .= ''; } $datatable .= '
'. @@ -9193,12 +5663,23 @@ sub print_defaults { } $datatable .= ''; } + my ($checkedon,$checkedoff); + $checkedoff = ' checked="checked"'; + if ($guestok) { + $checkedon = $checkedoff; + $checkedoff = ''; + } $datatable .= ' '.&mt('Internal ID:').' '.$item.' '. ''. &mt('delete').''.&mt('Name displayed').':'. + ''.&mt('Name displayed:'). ''. - '
'. + ''.(' 'x2). + '
'. - &mt('Name displayed').':'. + &mt('Name displayed:'). ''. + ''.(' 'x2). + '
'.&mt('Available conversions').''. - &user_formats_row('unamemap',$settings,$unamemaprules, - $ruleorder,$numinrow). - '
'. - &mt('No rules set for domain in customized localenroll.pm'). - '
'.&mt('Supported formats').''; - foreach my $item ('dat','csv') { - my $id; - if ($item eq 'csv') { - $id = 'id="scantronconfcsv" '; - } - $datatable .= ''.(' 'x3); - if ($item eq 'csv') { - $datatable .= '
'. - ''.&mt('CSV Column Mapping').''. - ''."\n"; - foreach my $col (@fields) { - my $selnone; - if ($csvfields{$col} eq '') { - $selnone = ' selected="selected"'; - } - $datatable .= ''. - ''; - } - $datatable .= '
'.&mt('Field').''.&mt('Location').'
'.$titles{$col}.'
'. - '
'. - ''.&mt('CSV Options').''; - foreach my $option ('hdr','pad','rem') { - $datatable .= ''.$titles{$option}.':'. - ''.(' 'x2)."\n". - '
'; - } - $datatable .= '
'; - $itemcount ++; - } - } - $datatable .= '
'.$title{'togglecats'}.'
'.$title{'togglecatsplace'}.' '. + '
'.$title{'categorizeplace'}.''. + ' '. + '
'; - if ($parent eq 'instcode' || $parent eq 'communities') { + if ($parent eq 'instcode' || $parent eq 'communities' || $parent eq 'placement') { $datatable .= '' .$default_names{$parent}.''; if ($parent eq 'instcode') { @@ -9821,7 +6140,7 @@ sub print_coursecategories { $datatable .= ''; - if ($parent eq 'communities') { + if (($parent eq 'communities') || ($parent eq 'placement')) { $datatable .= '
'; } $datatable .= '
'.$hdritem->{'header'}->[1]->{'col2'}.'
'.$hdritem->{'header'}->[1]->{'col2'}.'