--- loncom/interface/domainprefs.pm 2021/12/16 19:46:34 1.160.6.114 +++ loncom/interface/domainprefs.pm 2014/01/05 21:24:12 1.222 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.160.6.114 2021/12/16 19:46:34 raeburn Exp $ +# $Id: domainprefs.pm,v 1.222 2014/01/05 21:24:12 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -19,8 +19,7 @@ # # 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/ @@ -96,7 +95,7 @@ institutional affiliation in the domain but is now also used to manage availability of user tools: i.e., blogs, aboutme page, and portfolios, and the course request tool, used by course owners to request creation of a course, and to display/store -default quota sizes for Authoring Spaces. +default quota sizes for authoring spaces. Outputs: 1 @@ -165,8 +164,6 @@ use Apache::lonhtmlcommon(); use Apache::lonlocal; use Apache::lonmsg(); use Apache::lonconfigsettings; -use Apache::lonuserutils(); -use Apache::loncoursequeueadmin(); use LONCAPA qw(:DEFAULT :match); use LONCAPA::Enrollment; use LONCAPA::lonauthcgi(); @@ -174,7 +171,6 @@ use File::Copy; use Locale::Language; use DateTime::TimeZone; use DateTime::Locale; -use Net::CIDR; my $registered_cleanup; my $modified_urls; @@ -217,14 +213,13 @@ sub handler { 'contacts','defaults','scantron','coursecategories', 'serverstatuses','requestcourses','helpsettings', 'coursedefaults','usersessions','loadbalancing', - 'requestauthor','selfenrollment','inststatus', - 'passwords','wafproxy','ipaccess'],$dom); - my @prefs_order = ('rolecolors','login','ipaccess','defaults','wafproxy','passwords', - 'quotas','autoenroll','autoupdate','autocreate','directorysrch', - 'contacts','usercreation','selfcreation','usermodification', - 'scantron','requestcourses','requestauthor','coursecategories', - 'serverstatuses','helpsettings','coursedefaults', - 'selfenrollment','usersessions'); + 'requestauthor'],$dom); + my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', + 'autoupdate','autocreate','directorysrch','contacts', + 'usercreation','usermodification','scantron', + 'requestcourses','requestauthor','coursecategories', + 'serverstatuses','helpsettings', + 'coursedefaults','usersessions'); my %existing; if (ref($domconfig{'loadbalancing'}) eq 'HASH') { %existing = %{$domconfig{'loadbalancing'}}; @@ -244,8 +239,6 @@ sub handler { col2 => '',}, {col1 => 'Administrator Settings', col2 => '',}], - print => \&print_rolecolors, - modify => \&modify_rolecolors, }, 'login' => { text => 'Log-in page options', @@ -253,49 +246,13 @@ sub handler { header => [{col1 => 'Log-in Page Items', 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'}, - ], - print => \&print_login, - modify => \&modify_login, + col2 => 'Value'}], }, 'defaults' => - { text => 'Default authentication/language/timezone/portal/types', + { text => 'Default authentication/language/timezone/portal', help => 'Domain_Configuration_LangTZAuth', header => [{col1 => 'Setting', - col2 => 'Value'}, - {col1 => 'Institutional user types', - col2 => 'Name displayed'}], - 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, + col2 => 'Value'}], }, 'quotas' => { text => 'Blogs, personal web pages, webDAV/quotas, portfolios', @@ -303,16 +260,12 @@ sub handler { header => [{col1 => 'User affiliation', col2 => 'Available tools', col3 => 'Quotas, MB; (Authoring requires role)',}], - print => \&print_quotas, - modify => \&modify_quotas, }, 'autoenroll' => { text => 'Auto-enrollment settings', help => 'Domain_Configuration_Auto_Enrollment', header => [{col1 => 'Configuration setting', col2 => 'Value(s)'}], - print => \&print_autoenroll, - modify => \&modify_autoenroll, }, 'autoupdate' => { text => 'Auto-update settings', @@ -322,42 +275,27 @@ sub handler { {col1 => 'Setting', col2 => 'Affiliation'}, {col1 => 'User population', - col2 => 'Updatable user data'}], - print => \&print_autoupdate, - modify => \&modify_autoupdate, + col2 => 'Updateable user data'}], }, 'autocreate' => { text => 'Auto-course creation settings', help => 'Domain_Configuration_Auto_Creation', header => [{col1 => 'Configuration Setting', col2 => 'Value',}], - print => \&print_autocreate, - modify => \&modify_autocreate, }, 'directorysrch' => - { text => 'Directory searches', + { text => 'Institutional directory searches', help => 'Domain_Configuration_InstDirectory_Search', - header => [{col1 => 'Institutional Directory Setting', - col2 => 'Value',}, - {col1 => 'LON-CAPA Directory Setting', + header => [{col1 => 'Setting', col2 => 'Value',}], - print => \&print_directorysrch, - 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',},], - print => \&print_contacts, - modify => \&modify_contacts, + header => [{col1 => 'Setting', + col2 => 'Value',}], }, + 'usercreation' => { text => 'User creation', help => 'Domain_Configuration_User_Creation', @@ -367,40 +305,23 @@ sub handler { col2 => 'Usernames which may be created',}, {col1 => 'Context', col2 => 'Assignable authentication types'}], - print => \&print_usercreation, - modify => \&modify_usercreation, - }, - 'selfcreation' => - { text => 'Users self-creating accounts', - help => 'Domain_Configuration_Self_Creation', - header => [{col1 => 'Self-creation with institutional username', - col2 => 'Enabled?'}, - {col1 => 'Institutional user type (login/SSO self-creation)', - col2 => 'Information user can enter'}, - {col1 => 'Self-creation with e-mail verification', - col2 => 'Settings'}], - print => \&print_selfcreation, - modify => \&modify_selfcreation, }, 'usermodification' => { text => 'User modification', help => 'Domain_Configuration_User_Modification', header => [{col1 => 'Target user has role', - col2 => 'User information updatable in author context'}, + col2 => 'User information updateable in author context'}, {col1 => 'Target user has role', - col2 => 'User information updatable in course context'}], - print => \&print_usermodification, - modify => \&modify_usermodification, + col2 => 'User information updateable in course context'}, + {col1 => "Status of user", + col2 => 'Information settable when self-creating account (if directory data blank)'}], }, 'scantron' => - { text => 'Bubblesheet format', + { text => 'Bubblesheet format file', help => 'Domain_Configuration_Scantron_Format', - header => [ {col1 => 'Bubblesheet format file', - col2 => ''}, - {col1 => 'Bubblesheet data upload formats', - col2 => 'Settings'}], - print => \&print_scantron, - modify => \&modify_scantron, + header => [ {col1 => 'Item', + col2 => '', + }], }, 'requestcourses' => {text => 'Request creation of courses', @@ -410,36 +331,24 @@ sub handler { {col1 => 'Setting', col2 => 'Value'}, {col1 => 'Available textbooks', - col2 => ''}, - {col1 => 'Available templates', - col2 => ''}, - {col1 => 'Validation (not official courses)', - col2 => 'Value'},], - print => \&print_quotas, - modify => \&modify_quotas, + col2 => ''}], }, 'requestauthor' => - {text => 'Request Authoring Space', + {text => 'Request authoring space', help => 'Domain_Configuration_Request_Author', header => [{col1 => 'User affiliation', col2 => 'Availability/Processing of requests',}, {col1 => 'Setting', col2 => 'Value'}], - print => \&print_quotas, - modify => \&modify_quotas, }, 'coursecategories' => { text => 'Cataloging of courses/communities', help => 'Domain_Configuration_Cataloging_Courses', - header => [{col1 => 'Catalog type/availability', - col2 => '',}, - {col1 => 'Category settings for standard catalog', + header => [{col1 => 'Category settings', col2 => '',}, {col1 => 'Categories', col2 => '', }], - print => \&print_coursecategories, - modify => \&modify_coursecategories, }, 'serverstatuses' => {text => 'Access to server status pages', @@ -448,18 +357,12 @@ sub handler { col2 => 'Other named users', col3 => 'Specific IPs', }], - print => \&print_serverstatuses, - modify => \&modify_serverstatuses, }, 'helpsettings' => - {text => 'Support settings', + {text => 'Help page settings', help => 'Domain_Configuration_Help_Settings', - header => [{col1 => 'Help Page Settings (logged-in users)', - col2 => 'Value'}, - {col1 => 'Helpdesk Roles', - col2 => 'Settings'},], - print => \&print_helpsettings, - modify => \&modify_helpsettings, + header => [{col1 => 'Help Settings (logged-in users)', + col2 => 'Value'}], }, 'coursedefaults' => {text => 'Course/Community defaults', @@ -468,20 +371,12 @@ sub handler { col2 => 'Value',}, {col1 => 'Defaults which can be overridden for each course by a DC', col2 => 'Value',},], - print => \&print_coursedefaults, - modify => \&modify_coursedefaults, }, - 'selfenrollment' => - {text => 'Self-enrollment in Course/Community', - help => 'Domain_Configuration_Selfenrollment', - header => [{col1 => 'Configuration Rights', - col2 => 'Configured by Course Personnel or Domain Coordinator?'}, - {col1 => 'Defaults', - col2 => 'Value'}, - {col1 => 'Self-enrollment validation (optional)', - col2 => 'Value'},], - print => \&print_selfenrollment, - modify => \&modify_selfenrollment, + 'privacy' => + {text => 'User Privacy', + help => 'Domain_Configuration_User_Privacy', + header => [{col1 => 'Setting', + col2 => 'Value',}], }, 'usersessions' => {text => 'User session hosting/offloading', @@ -492,10 +387,8 @@ sub handler { col2 => 'Rules'}, {col1 => "Hosting domain's own users elsewhere", col2 => 'Rules'}], - print => \&print_usersessions, - modify => \&modify_usersessions, }, - 'loadbalancing' => + 'loadbalancing' => {text => 'Dedicated Load Balancer(s)', help => 'Domain_Configuration_Load_Balancing', header => [{col1 => 'Balancers', @@ -503,17 +396,7 @@ sub handler { col3 => 'User affiliation', col4 => 'Overrides'}, ], - print => \&print_loadbalancing, - modify => \&modify_loadbalancing, }, - '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', @@ -523,14 +406,7 @@ sub handler { {col1 => 'Log-in Page Items', 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'}, - ], - print => \&print_login, - modify => \&modify_login, + col2 => 'Value'}], }; } @@ -544,13 +420,13 @@ sub handler { if ($phase eq 'process') { my $result = &Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order, \%prefs,\%domconfig,$confname,\@roles); - if ((ref($result) eq 'HASH') && (keys(%{$result}))) { + if ((ref($result) eq 'HASH') && (keys(%{$result}))) { $r->rflush(); &devalidate_remote_domconfs($dom,$result); } } elsif ($phase eq 'display') { my $js = &recaptcha_js(). - &toggle_display_js(); + &credits_js(); if ((keys(%servers) > 1) || (keys(%existing) > 0)) { my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); @@ -569,17 +445,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 { @@ -670,11 +535,9 @@ 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); } elsif ($action eq 'usermodification') { $output = &modify_usermodification($dom,%domconfig); } elsif ($action eq 'contacts') { @@ -684,7 +547,7 @@ sub process_changes { } elsif ($action eq 'scantron') { $output = &modify_scantron($r,$dom,$confname,$lastactref,%domconfig); } elsif ($action eq 'coursecategories') { - $output = &modify_coursecategories($dom,$lastactref,%domconfig); + $output = &modify_coursecategories($dom,%domconfig); } elsif ($action eq 'serverstatuses') { $output = &modify_serverstatuses($dom,%domconfig); } elsif ($action eq 'requestcourses') { @@ -692,21 +555,13 @@ 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') { - $output = &modify_selfenrollment($dom,$lastactref,%domconfig) } elsif ($action eq 'usersessions') { $output = &modify_usersessions($dom,$lastactref,%domconfig); } elsif ($action eq 'loadbalancing') { $output = &modify_loadbalancing($dom,%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); } return $output; } @@ -717,39 +572,11 @@ sub print_config_box { my $output; if ($action eq 'coursecategories') { $output = &coursecategories_javascript($settings); - } elsif ($action eq 'defaults') { - $output = &defaults_javascript($settings); - } elsif ($action eq 'passwords') { - $output = &passwords_javascript(); - } elsif ($action eq 'helpsettings') { - my (%privs,%levelscurrent); - my %full=(); - my %levels=( - course => {}, - domain => {}, - system => {}, - ); - my $context = 'domain'; - my $crstype = 'Course'; - my $formname = 'display'; - &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, - \@templateroles); - } elsif ($action eq 'wafproxy') { - $output .= &wafproxy_javascript($dom); - } elsif ($action eq 'autoupdate') { - $output .= &autoupdate_javascript(); - } elsif ($action eq 'login') { - $output .= &saml_javascript(); - } elsif ($action eq 'ipaccess') { - $output .= &ipaccess_javascript($settings); } - $output .= + $output .= ' - '."\n". ''; @@ -761,49 +588,47 @@ 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))) { + if (($action eq 'rolecolors') || ($action eq 'coursecategories') || + (($action eq 'login') && ($numheaders < 3))) { $colspan = ' colspan="2"'; } if ($action eq 'usersessions') { $rightcolspan = ' colspan="3"'; } - if ($action eq 'passwords') { - $leftnobr = ' LC_nobreak'; - } $output .= ' @@ -838,50 +653,11 @@ sub print_config_box {
'. + '. &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')) { - $output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal); - } elsif ($action eq 'passwords') { - $output .= $item->{'print'}->('top',$dom,$confname,$settings,\$rowtotal); + if ($action eq 'autoupdate') { + $output .= &print_autoupdate('top',$dom,$settings,\$rowtotal); + } elsif ($action eq 'usercreation') { + $output .= &print_usercreation('top',$dom,$settings,\$rowtotal); + } elsif ($action eq 'usermodification') { + $output .= &print_usermodification('top',$dom,$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); + $output .= &print_coursecategories('top',$dom,$item,$settings,\$rowtotal); } elsif ($action eq 'login') { - if ($numheaders == 5) { + if ($numheaders == 3) { $colspan = ' colspan="2"'; $output .= &print_login('service',$dom,$confname,$phase,$settings,\$rowtotal); } else { $output .= &print_login('page',$dom,$confname,$phase,$settings,\$rowtotal); } - } elsif (($action eq 'requestcourses') || ($action eq 'requestauthor')) { + } elsif ($action eq 'requestcourses') { $output .= &print_quotas($dom,$settings,\$rowtotal,$action); + } elsif ($action eq 'requestauthor') { + $output .= &print_quotas($dom,$settings,\$rowtotal,$action); + } elsif ($action eq 'usersessions') { + $output .= &print_usersessions('top',$dom,$settings,\$rowtotal); } elsif ($action eq 'rolecolors') { $output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal); + } elsif ($action eq 'coursedefaults') { + $output .= &print_coursedefaults('top',$dom,$settings,\$rowtotal); } $output .= '
'.&mt($item->{'header'}->[0]->{'col1'}).''.&mt($item->{'header'}->[0]->{'col1'}).' '.&mt($item->{'header'}->[0]->{'col2'}).'
@@ -813,23 +638,13 @@ sub print_config_box {
- + '; + $output .= ' '; $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')) { - 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); - } else { - $output .= $item->{'print'}->('middle',$dom,$settings,\$rowtotal); - } - $output .= ' + if ($action eq 'autoupdate') { + $output .= &print_autoupdate('middle',$dom,$settings,\$rowtotal).'
'.&mt($item->{'header'}->[1]->{'col1'}).''.&mt($item->{'header'}->[1]->{'col1'}).''.&mt($item->{'header'}->[1]->{'col2'}).'
- - '."\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); - } - $output .= ' - -
'.&mt($item->{'header'}->[2]->{'col1'}).''.&mt($item->{'header'}->[2]->{'col2'}).'
- - - - - - - - '."\n"; - if ($action eq 'passwords') { - $output .= $item->{'print'}->('bottom',$dom,$confname,$settings,\$rowtotal); - } else { - $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); - } - $output .= ' -
'.&mt($item->{'header'}->[3]->{'col1'}).''.&mt($item->{'header'}->[3]->{'col2'}).'
- - - '; - } else { - $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); - } + '.&mt($item->{'header'}->[2]->{'col2'}).' '. + &print_autoupdate('bottom',$dom,$settings,\$rowtotal); $rowtotal ++; - } elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') || - ($action eq 'defaults') || ($action eq 'directorysrch') || - ($action eq 'helpsettings') || ($action eq 'wafproxy')) { - $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) { - $output .= &print_login('page',$dom,$confname,$phase,$settings,\$rowtotal).' + } elsif ($action eq 'usercreation') { + $output .= &print_usercreation('middle',$dom,$settings,\$rowtotal).' @@ -890,57 +666,44 @@ sub print_config_box { - '. - &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal); - $rowtotal ++; - } else { - $output .= &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal); - } - $output .= ' + '. + &print_usercreation('bottom',$dom,$settings,\$rowtotal); + $rowtotal ++; + } elsif ($action eq 'usermodification') { + $output .= &print_usermodification('middle',$dom,$settings,\$rowtotal).'
'.&mt($item->{'header'}->[2]->{'col1'}).''.&mt($item->{'header'}->[2]->{'col2'}).'
'.&mt($item->{'header'}->[2]->{'col2'}).'
- '; - if ($numheaders == 5) { - $output .= ' - - - '; - } else { - $output .= ' + - - '; - } + '. + &print_usermodification('bottom',$dom,$settings,\$rowtotal); $rowtotal ++; - $output .= &print_login('headtag',$dom,$confname,$phase,$settings,\$rowtotal).' + } elsif ($action eq 'coursecategories') { + $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal); + } elsif ($action eq 'login') { + if ($numheaders == 3) { + $output .= &print_login('page',$dom,$confname,$phase,$settings,\$rowtotal).'
'.&mt($item->{'header'}->[3]->{'col1'}).''.&mt($item->{'header'}->[3]->{'col2'}).'
'.&mt($item->{'header'}->[2]->{'col1'}).''.&mt($item->{'header'}->[2]->{'col2'}).'
'.&mt($item->{'header'}->[2]->{'col2'}).'
- '; - if ($numheaders == 5) { - $output .= ' - - - '; + + + '. + &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal); + $rowtotal ++; } else { - $output .= ' - - - '; + $output .= &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal); } - $rowtotal ++; - $output .= &print_login('saml',$dom,$confname,$phase,$settings,\$rowtotal); } elsif ($action eq 'requestcourses') { - $output .= &print_requestmail($dom,$action,$settings,\$rowtotal); - $rowtotal ++; - $output .= &print_studentcode($settings,\$rowtotal).' + $output .= &print_requestmail($dom,$action,$settings,\$rowtotal). + &print_studentcode($settings,\$rowtotal).'
'.&mt($item->{'header'}->[4]->{'col1'}).''.&mt($item->{'header'}->[4]->{'col2'}).'
'.&mt($item->{'header'}->[2]->{'col1'}).''.&mt($item->{'header'}->[2]->{'col2'}).'
'.&mt($item->{'header'}->[3]->{'col1'}).''.&mt($item->{'header'}->[3]->{'col2'}).'
@@ -950,32 +713,24 @@ sub print_config_box { '.&mt($item->{'header'}->[2]->{'col1'}).' '.&mt($item->{'header'}->[2]->{'col2'}).' '. - &textbookcourses_javascript($settings). - &print_textbookcourses($dom,'textbooks',$settings,\$rowtotal).' - - - + &print_textbookcourses($dom,$settings,\$rowtotal); + } elsif ($action eq 'requestauthor') { + $output .= &print_requestmail($dom,$action,$settings,\$rowtotal); + } elsif ($action eq 'usersessions') { + $output .= &print_usersessions('middle',$dom,$settings,\$rowtotal).' + + + - - '. - &print_textbookcourses($dom,'templates',$settings,\$rowtotal).' -
'.&mt($item->{'header'}->[3]->{'col1'}).''.&mt($item->{'header'}->[3]->{'col2'}).'
- - - - - - - - - '. - &print_validation_rows('requestcourses',$dom,$settings,\$rowtotal); - } elsif ($action eq 'requestauthor') { - $output .= &print_requestmail($dom,$action,$settings,\$rowtotal); + + '. + &print_usersessions('bottom',$dom,$settings,\$rowtotal); $rowtotal ++; + } elsif ($action eq 'coursedefaults') { + $output .= &print_coursedefaults('bottom',$dom,$settings,\$rowtotal); } elsif ($action eq 'rolecolors') { $output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
'.&mt($item->{'header'}->[4]->{'col1'}).''.&mt($item->{'header'}->[4]->{'col2'}).'
'.&mt($item->{'header'}->[2]->{'col1'}).''.&mt($item->{'header'}->[2]->{'col2'}).'
@@ -1010,7 +765,7 @@ sub print_config_box { '; - if ($action eq 'login') { + if (($action eq 'login') || ($action eq 'directorysrch')) { $output .= ' '; } elsif ($action eq 'serverstatuses') { @@ -1054,10 +809,24 @@ sub print_config_box { $rowtotal ++; 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')) { - $output .= $item->{'print'}->($dom,$settings,\$rowtotal); + } elsif ($action eq 'autoenroll') { + $output .= &print_autoenroll($dom,$settings,\$rowtotal); + } elsif ($action eq 'autocreate') { + $output .= &print_autocreate($dom,$settings,\$rowtotal); + } elsif ($action eq 'directorysrch') { + $output .= &print_directorysrch($dom,$settings,\$rowtotal); + } elsif ($action eq 'contacts') { + $output .= &print_contacts($dom,$settings,\$rowtotal); + } elsif ($action eq 'defaults') { + $output .= &print_defaults($dom,$settings,\$rowtotal); + } elsif ($action eq 'scantron') { + $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal); + } elsif ($action eq 'serverstatuses') { + $output .= &print_serverstatuses($dom,$settings,\$rowtotal); + } elsif ($action eq 'helpsettings') { + $output .= &print_helpsettings($dom,$confname,$settings,\$rowtotal); + } elsif ($action eq 'loadbalancing') { + $output .= &print_loadbalancing($dom,$settings,\$rowtotal); } } $output .= ' @@ -1070,12 +839,8 @@ 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); @@ -1270,10 +1035,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'}->[0]->{'col1'}).'
'; } 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') { @@ -1350,131 +1123,6 @@ sub print_login { $itemcount ++; } $datatable .= &captcha_choice('login',$settings,$itemcount); - } elsif ($caller eq 'headtag') { - my %domservers = &Apache::lonnet::get_servers($dom); - my $choice = $choices{'headtag'}; - $css_class = ' class="LC_odd_row"'; - $datatable .= ''.$choice.''. - ''. - ''. - ''. - ''."\n"; - my (%currurls,%currexempt); - if (ref($settings) eq 'HASH') { - if (ref($settings->{'headtag'}) eq 'HASH') { - foreach my $lonhost (keys(%{$settings->{'headtag'}})) { - if (ref($settings->{'headtag'}{$lonhost}) eq 'HASH') { - $currurls{$lonhost} = $settings->{'headtag'}{$lonhost}{'url'}; - $currexempt{$lonhost} = $settings->{'headtag'}{$lonhost}{'exempt'}; - } - } - } - } - foreach my $lonhost (sort(keys(%domservers))) { - my $exempt = &check_exempt_addresses($currexempt{$lonhost}); - $datatable .= ''; - if ($currurls{$lonhost}) { - $datatable .= ''. - ''; - } - $datatable .= '
'.$choices{'hostid'}.''.$choices{'current'}.''.$choices{'action'}.''.$choices{'exempt'}.'
'.$domservers{$lonhost}.''.$lt{'curr'}.' '.$lt{'rep'}.''; - } else { - $datatable .= ''.$lt{'none'}.''.$lt{'upl'}; - } - $datatable .='
'; - if ($switchserver) { - $datatable .= &mt('Upload to library server: [_1]',$switchserver); - } else { - $datatable .= ''; - } - $datatable .= '
'; - } elsif ($caller eq 'saml') { - my %domservers = &Apache::lonnet::get_servers($dom); - $datatable .= ''. - ''. - ''. - ''."\n"; - my (%saml,%samltext,%samlimg,%samlalt,%samlurl,%samltitle,%samlnotsso,%styleon,%styleoff); - foreach my $lonhost (keys(%domservers)) { - $samlurl{$lonhost} = '/adm/sso'; - $styleon{$lonhost} = 'display:none'; - $styleoff{$lonhost} = ''; - } - if (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'}; - $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 $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= ''. - ''. - ''. - ''; - $itemcount ++; - } - $datatable .= '
'.$choices{'hostid'}.''.$choices{'samllanding'}.''.$choices{'samloptions'}.'
'.$domservers{$lonhost}.''.(' 'x2). - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - '
'.&mt('SSO').''. - ''.&mt('Non-SSO').'
'.&mt('Text').''.&mt('Image').''.&mt('Alt Text').''.&mt('URL').''.&mt('Tool Tip').''.&mt('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 .= '
 
'; } return $datatable; } @@ -1508,204 +1156,10 @@ sub login_choices { link => "Link", alink => "Active link", vlink => "Visited link", - headtag => "Custom markup", - action => "Action", - current => "Current", - samllanding => "Dual login?", - samloptions => "Options", ); 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', - ); - my $typeorder = ['com','chat','boards','port','groups','blogs','about','printout','grades','passwd']; - return ($typeorder,\%types); -} - sub print_rolecolors { my ($phase,$role,$dom,$confname,$settings,$rowtotal) = @_; my %choices = &color_font_choices(); @@ -1823,7 +1277,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 .= ' '; } @@ -1832,12 +1286,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 .= ' '; } @@ -1847,7 +1301,7 @@ sub display_color_options { ' '. - ' '; + ' '; } my $switchserver = &check_switchserver($dom,$confname); foreach my $img (@{$images}) { @@ -1906,8 +1360,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; } } @@ -1965,7 +1418,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) { @@ -1993,7 +1446,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) { @@ -2004,7 +1457,7 @@ sub display_color_options { $datatable .= ''. ''; foreach my $item (@{$links}) { - my $color = $designs->{'links'}{$item} ? $designs->{'links'}{$item} : $defaults->{'links'}{$item}; + my $color = $designs->{'link'}{$item} ? $designs->{'link'}{$item} : $defaults->{'links'}{$item}; $datatable .= ''. ' '. ' '; + $$rowtotal += $rows; return $datatable; } @@ -2583,11 +2024,9 @@ sub print_studentcode { my $rownum = 0; my ($output,%current); my @crstypes = ('official','unofficial','community','textbook'); - if (ref($settings) eq 'HASH') { - if (ref($settings->{'uniquecode'}) eq 'HASH') { - foreach my $type (@crstypes) { - $current{$type} = $settings->{'uniquecode'}{$type}; - } + if (ref($settings->{'uniquecode'}) eq 'HASH') { + foreach my $type (@crstypes) { + $current{$type} = $settings->{'uniquecode'}{$type}; } } $output .= ''. @@ -2608,14 +2047,14 @@ sub print_studentcode { } sub print_textbookcourses { - my ($dom,$type,$settings,$rowtotal) = @_; + my ($dom,$settings,$rowtotal) = @_; my $rownum = 0; my $css_class; my $itemcount = 1; my $maxnum = 0; my $bookshash; if (ref($settings) eq 'HASH') { - $bookshash = $settings->{$type}; + $bookshash = $settings->{'textbooks'}; } my %ordered; if (ref($bookshash) eq 'HASH') { @@ -2629,7 +2068,7 @@ sub print_textbookcourses { my $confname = $dom.'-domainconfig'; my $switchserver = &check_switchserver($dom,$confname); my $maxnum = scalar(keys(%ordered)); - my $datatable; + my $datatable = &textbookcourses_javascript(\%ordered); if (keys(%ordered)) { my @items = sort { $a <=> $b } keys(%ordered); for (my $i=0; $i<@items; $i++) { @@ -2637,24 +2076,21 @@ sub print_textbookcourses { my $key = $ordered{$items[$i]}; my %coursehash=&Apache::lonnet::coursedescription($key); my $coursetitle = $coursehash{'description'}; - my ($subject,$title,$author,$publisher,$image,$imgsrc,$cdom,$cnum); + my ($subject,$title,$author,$image,$imgsrc,$cdom,$cnum); if (ref($bookshash->{$key}) eq 'HASH') { $subject = $bookshash->{$key}->{'subject'}; $title = $bookshash->{$key}->{'title'}; - if ($type eq 'textbooks') { - $publisher = $bookshash->{$key}->{'publisher'}; - $author = $bookshash->{$key}->{'author'}; - $image = $bookshash->{$key}->{'image'}; - if ($image ne '') { - my ($path,$imagefile) = ($image =~ m{^(.+)/([^/]+)$}); - my $imagethumb = "$path/tn-".$imagefile; - $imgsrc = ''.&mt('Textbook image').''; - } + $author = $bookshash->{$key}->{'author'}; + $image = $bookshash->{$key}->{'image'}; + if ($image ne '') { + my ($path,$imagefile) = ($image =~ m{^(.+)/([^/]+)$}); + my $imagethumb = "$path/tn-".$imagefile; + $imgsrc = ''.&mt('Textbook image').''; } } - my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$type".'_'."$key','$type'".');"'; + my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$key'".');"'; $datatable .= ''. ''."\n"; $itemcount ++; } } $css_class = $itemcount%2?' class="LC_odd_row"':''; - my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$type"."_addbook_pos','$type'".');"'; + my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'addbook_pos'".');"'; $datatable .= ''."\n". + ''.&mt('Add').''."\n". ''."\n". ''."\n"; $itemcount ++; @@ -2740,316 +2169,23 @@ sub print_textbookcourses { } sub textbookcourses_javascript { - my ($settings) = @_; - return unless(ref($settings) eq 'HASH'); - my (%ordered,%total,%jstext); - foreach my $type ('textbooks','templates') { - $total{$type} = 0; - if (ref($settings->{$type}) eq 'HASH') { - foreach my $item (keys(%{$settings->{$type}})) { - if (ref($settings->{$type}->{$item}) eq 'HASH') { - my $num = $settings->{$type}->{$item}{'order'}; - $ordered{$type}{$num} = $item; - } - } - $total{$type} = scalar(keys(%{$settings->{$type}})); - } - my @jsarray = (); - foreach my $item (sort {$a <=> $b } (keys(%{$ordered{$type}}))) { - push(@jsarray,$ordered{$type}{$item}); - } - $jstext{$type} = ' var '.$type.' = Array('."'".join("','",@jsarray)."'".');'."\n"; + my ($textbooks) = @_; + return unless(ref($textbooks) eq 'HASH'); + my $num = scalar(keys(%{$textbooks})); + my @jsarray; + foreach my $item (sort {$a <=> $b } (keys(%{$textbooks}))) { + push(@jsarray,$textbooks->{$item}); } + my $jstext = ' var textbooks = Array('."'".join("','",@jsarray)."'".');'."\n"; return <<"ENDSCRIPT"; - -ENDSCRIPT -} - -sub wafproxy_javascript { - my ($dom) = @_; - return <<"ENDSCRIPT"; - - -ENDSCRIPT -} - -sub autoupdate_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"; - @@ -3095,7 +2232,7 @@ ENDSCRIPT sub print_autoenroll { my ($dom,$settings,$rowtotal) = @_; my $autorun = &Apache::lonnet::auto_run(undef,$dom), - my ($defdom,$runon,$runoff,$coownerson,$coownersoff,$failsafe); + my ($defdom,$runon,$runoff,$coownerson,$coownersoff); if (ref($settings) eq 'HASH') { if (exists($settings->{'run'})) { if ($settings->{'run'} eq '0') { @@ -3129,9 +2266,6 @@ sub print_autoenroll { if (exists($settings->{'sender_domain'})) { $defdom = $settings->{'sender_domain'}; } - if (exists($settings->{'autofailsafe'})) { - $failsafe = $settings->{'autofailsafe'}; - } } else { if ($autorun) { $runon = ' checked="checked" '; @@ -3167,87 +2301,56 @@ sub print_autoenroll { $coownerson.' value="1" />'.&mt('Yes').' '. ''. - ''. - ''. - ''; - $$rowtotal += 4; + ''; + $$rowtotal += 3; 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 = ''. - ''. - ''. + ''. + ''. + $updateoff.'value="0" />'.&mt('No').''. + ''. + ''. + ''. ''; - 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 .= ''. - ''. - ''. - ''; - $$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); @@ -3314,1062 +2417,248 @@ sub print_autocreate { $createoff{'req'}.' value="0" />'.&mt('No').''; my ($numdc,$dctable,$rows) = &active_dc_picker($dom,$numinrow,'radio', 'autocreate_xmldc',%currhash); - $datatable .= ''; } else { - $datatable .= &mt('Course creation processed as:'). - ''; } - $datatable .= $dctable.''; $$rowtotal += $rows; return $datatable; } sub print_directorysrch { - my ($position,$dom,$settings,$rowtotal) = @_; - my $datatable; - if ($position eq 'top') { - my $instsrchon = ' '; - my $instsrchoff = ' checked="checked" '; - my ($exacton,$containson,$beginson); - my $instlocalon = ' '; - my $instlocaloff = ' checked="checked" '; - if (ref($settings) eq 'HASH') { - if ($settings->{'available'} eq '1') { - $instsrchon = $instsrchoff; - $instsrchoff = ' '; - } - if ($settings->{'localonly'} eq '1') { - $instlocalon = $instlocaloff; - $instlocaloff = ' '; - } - if (ref($settings->{'searchtypes'}) eq 'ARRAY') { - foreach my $type (@{$settings->{'searchtypes'}}) { - if ($type eq 'exact') { - $exacton = ' checked="checked" '; - } elsif ($type eq 'contains') { - $containson = ' checked="checked" '; - } elsif ($type eq 'begins') { - $beginson = ' checked="checked" '; - } - } - } else { - if ($settings->{'searchtypes'} eq 'exact') { - $exacton = ' checked="checked" '; - } elsif ($settings->{'searchtypes'} eq 'contains') { - $containson = ' checked="checked" '; - } elsif ($settings->{'searchtypes'} eq 'specify') { + my ($dom,$settings,$rowtotal) = @_; + my $srchon = ' '; + my $srchoff = ' checked="checked" '; + my ($exacton,$containson,$beginson); + my $localon = ' '; + my $localoff = ' checked="checked" '; + if (ref($settings) eq 'HASH') { + if ($settings->{'available'} eq '1') { + $srchon = $srchoff; + $srchoff = ' '; + } + if ($settings->{'localonly'} eq '1') { + $localon = $localoff; + $localoff = ' '; + } + if (ref($settings->{'searchtypes'}) eq 'ARRAY') { + foreach my $type (@{$settings->{'searchtypes'}}) { + if ($type eq 'exact') { $exacton = ' checked="checked" '; + } elsif ($type eq 'contains') { $containson = ' checked="checked" '; + } elsif ($type eq 'begins') { + $beginson = ' checked="checked" '; } } - } - my ($searchtitles,$titleorder) = &sorted_searchtitles(); - my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); - - my $numinrow = 4; - my $cansrchrow = 0; - $datatable=''. - ''. - ''. - ''. - ''. - ''. - ''; - $$rowtotal += 2; - if (ref($usertypes) eq 'HASH') { - if (keys(%{$usertypes}) > 0) { - $datatable .= &insttypes_row($settings,$types,$usertypes,$dom, - $numinrow,$othertitle,'cansearch', - $rowtotal); - $cansrchrow = 1; + } else { + if ($settings->{'searchtypes'} eq 'exact') { + $exacton = ' checked="checked" '; + } elsif ($settings->{'searchtypes'} eq 'contains') { + $containson = ' checked="checked" '; + } elsif ($settings->{'searchtypes'} eq 'specify') { + $exacton = ' checked="checked" '; + $containson = ' checked="checked" '; } } - if ($cansrchrow) { - $$rowtotal ++; - $datatable .= ''; - } else { - $datatable .= ''; + } + my ($searchtitles,$titleorder) = &sorted_searchtitles(); + my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); + + my $numinrow = 4; + my $cansrchrow = 0; + my $datatable=''. + ''. + ''. + ''. + ''. + ''. + ''; + $$rowtotal += 2; + if (ref($usertypes) eq 'HASH') { + if (keys(%{$usertypes}) > 0) { + $datatable .= &insttypes_row($settings,$types,$usertypes,$dom, + $numinrow,$othertitle,'cansearch'); + $cansrchrow = 1; } - $datatable .= ''; + $$rowtotal ++; + if ($cansrchrow) { + $datatable .= ''; } else { - my $domsrchon = ' checked="checked" '; - my $domsrchoff = ' '; - my $domlocalon = ' '; - my $domlocaloff = ' checked="checked" '; - if (ref($settings) eq 'HASH') { - if ($settings->{'lclocalonly'} eq '1') { - $domlocalon = $domlocaloff; - $domlocaloff = ' '; - } - if ($settings->{'lcavailable'} eq '0') { - $domsrchoff = $domsrchon; - $domsrchon = ' '; - } - } - $datatable=''. - ''. - ''. - ''. - ''. - ''. - ''; - $$rowtotal += 2; + $datatable .= ''; } + $datatable .= ''. + ''; + $$rowtotal ++; return $datatable; } 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'}}; + 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') { + foreach my $item (@contacts) { + if (exists($settings->{$item})) { + $to{$item} = $settings->{$item}; } } - } else { - @mailings = ('helpdeskmail','otherdomsmail'); foreach my $type (@mailings) { - $otheremails{$type} = ''; - } - $bccemails{'helpdeskmail'} = ''; - $bccemails{'otherdomsmail'} = ''; - $includestr{'helpdeskmail'} = ''; - $includestr{'otherdomsmail'} = ''; - ($fields,$fieldtitles,$fieldoptions,$possoptions) = &helpform_fields(); - } - 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}); - } + if (exists($settings->{$type})) { + if (ref($settings->{$type}) eq 'HASH') { + foreach my $item (@contacts) { + if ($settings->{$type}{$item}) { + $checked{$type}{$item} = ' checked="checked" '; } } - } elsif ($type eq 'lonstatusmail') { - $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" '; - } - } - } - 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}; + $otheremails{$type} = $settings->{$type}{'others'}; + if ($type eq 'helpdeskmail') { + $bccemails{$type} = $settings->{$type}{'bcc'}; } } - 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'; - } - } - $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 .= ''. - ''; - $rownum ++; - } - } elsif ($position eq 'bottom') { + foreach my $item (@contacts) { $css_class = $rownum%2?' class="LC_odd_row"':''; - $datatable .= ''. - ''."\n"; + $datatable .= ''. + ''; $rownum ++; } - unless (($position eq 'top') || ($position eq 'lower')) { - foreach my $type (@mailings) { - $css_class = $rownum%2?' class="LC_odd_row"':''; - $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 .= ''. - ''; - $rownum ++; - } + foreach my $type (@mailings) { $css_class = $rownum%2?' class="LC_odd_row"':''; $datatable .= ''. + ''. ''; - $rownum ++; - $css_class = $rownum%2?' class="LC_odd_row"':''; - $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 = ''. - "\n". - ''."\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 ($dom,$confname,$settings,$rowtotal) = @_; my ($datatable,$itemcount); - if ($position eq 'top') { - $itemcount = 1; - my (%choices,%defaultchecked,@toggles); - $choices{'submitbugs'} = &mt('Display link to: [_1]?', - &Apache::loncommon::modal_link('http://bugs.loncapa.org', - &mt('LON-CAPA bug tracker'),600,500)); - %defaultchecked = ('submitbugs' => 'on'); - @toggles = ('submitbugs'); - ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, - \%choices,$itemcount); - $$rowtotal ++; - } 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))) { - if ($key=~/^rolesdef\_(\w+)$/) { - my $rolename = $1; - my (%privs,$order); - ($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); - $datatable .= &helpsettings_javascript(\@roles_by_num,$maxnum,$hiddenstr,$formname); - 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; - my %full=(); - my %levels= ( - course => {}, - domain => {}, - system => {}, - ); - my %levelscurrent=( - course => {}, - domain => {}, - system => {}, - ); - &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 .= ''. - ''; - $itemcount ++; - } - $css_class = $itemcount%2?' class="LC_odd_row"':''; - my $newcust = 'custhelp'.$count; - my (%privs,%levelscurrent); - my %full=(); - my %levels= ( - course => {}, - domain => {}, - system => {}, - ); - &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 .= ''. - ''; - $count ++; - $$rowtotal += $count; - } - return $datatable; -} - -sub adhocbutton { - my ($prefix,$num,$field,$visibility) = @_; - my %lt = &Apache::lonlocal::texthash( - show => 'Show details', - hide => 'Hide details', - ); - return ''.(' 'x10). - ''.(' 'x2).''.(' 'x2); -} - -sub helpsettings_javascript { - my ($roles_by_num,$total,$hiddenstr,$formname) = @_; - return unless(ref($roles_by_num) eq 'ARRAY'); - my %html_js_lt = &Apache::lonlocal::texthash( - show => 'Show details', - hide => 'Hide details', - ); - &html_escape(\%html_js_lt); - my $jstext = ' var helproles = Array('."'".join("','",@{$roles_by_num})."'".');'."\n"; - return <<"ENDSCRIPT"; - - -ENDSCRIPT -} - -sub helpdeskroles_access { - my ($dom,$prefix,$num,$add_class,$current,$accesstypes,$othertitle, - $usertypes,$types,$domhelpdesk) = @_; - return unless ((ref($accesstypes) eq 'ARRAY') && (ref($domhelpdesk) eq 'HASH')); - my %lt = &Apache::lonlocal::texthash( - 'rou' => 'Role usage', - 'whi' => 'Which helpdesk personnel may use this role?', - 'all' => 'All with domain helpdesk or helpdesk assistant role', - 'dh' => 'All with domain helpdesk role', - 'da' => 'All with domain helpdesk assistant role', - 'none' => 'None', - 'status' => 'Determined based on institutional status', - 'inc' => 'Include all, but exclude specific personnel', - 'exc' => 'Exclude all, but include specific personnel', - ); - my %usecheck = ( - all => ' checked="checked"', - ); - my %displaydiv = ( - status => 'none', - inc => 'none', - exc => 'none', - priv => 'block', - ); - my $output; - if (ref($current) eq 'HASH') { - if (($current->{'access'} ne '') && ($current->{'access'} ne 'all')) { - if (grep(/^\Q$current->{access}\E$/,@{$accesstypes})) { - $usecheck{$current->{access}} = $usecheck{'all'}; - delete($usecheck{'all'}); - if ($current->{access} =~ /^(status|inc|exc)$/) { - my $access = $1; - $displaydiv{$access} = 'inline'; - } elsif ($current->{access} eq 'none') { - $displaydiv{'priv'} = 'none'; - } - } - } - } - $output = '
'.$lt{'rou'}.''. - '

'.$lt{'whi'}.'

'; - foreach my $access (@{$accesstypes}) { - $output .= '

'; - if ($access eq 'status') { - $output .= '

'. - &Apache::lonuserutils::adhoc_status_types($dom,$prefix,$num,$current->{$access}, - $othertitle,$usertypes,$types). - '
'; - } elsif (($access eq 'inc') && (keys(%{$domhelpdesk}) > 0)) { - $output .= '
'. - &Apache::lonuserutils::adhoc_staff($access,$prefix,$num,$current->{$access},$domhelpdesk). - '
'; - } elsif (($access eq 'exc') && (keys(%{$domhelpdesk}) > 0)) { - $output .= '
'. - &Apache::lonuserutils::adhoc_staff($access,$prefix,$num,$current->{$access},$domhelpdesk). - '
'; - } - $output .= '

'; - } - $output .= '
'; - return $output; + ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, + \%choices,$itemcount); + return $datatable; } sub radiobutton_prefs { my ($settings,$toggles,$defaultchecked,$choices,$itemcount,$onclick, - $additional,$align,$firstval) = @_; + $additional) = @_; return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') && (ref($choices) eq 'HASH')); @@ -4403,27 +2692,15 @@ sub radiobutton_prefs { $datatable .= ''; - if ($align eq 'left') { - $datatable .= ''. + ''; + $checkedoff{$item}.' value="0"'.$onclick.' />'.&mt('No').''. + ''.$additional. + ''. + ''; $itemcount ++; } return ($datatable,$itemcount); @@ -4434,135 +2711,25 @@ sub print_coursedefaults { 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)', 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)', - 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', ); my %staticdefaults = ( anonsurvey_threshold => 10, uploadquota => 500, - postsubmit => 60, - mysqltables => 172800, ); if ($position eq 'top') { - %defaultchecked = ( - 'uselcmath' => 'on', - 'usejsme' => 'on', - 'canclone' => 'none', - ); - @toggles = ('uselcmath','usejsme'); - 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 = ''."\n"; - $itemcount ++; + %defaultchecked = ('canuse_pdfforms' => 'off'); + @toggles = ('canuse_pdfforms'); ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, - \%choices,$itemcount); - $datatable = $mathdisp.$datatable; - $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= - ''. - ''; - $itemcount ++; + \%choices,$itemcount); } else { $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - my ($currdefresponder,%defcredits,%curruploadquota,%deftimeout,%currmysql); + my ($currdefresponder,$def_official_credits,$def_unofficial_credits,$def_textbook_credits, + %curruploadquota); my $currusecredits = 0; - my $postsubmitclient = 1; my @types = ('official','unofficial','community','textbook'); if (ref($settings) eq 'HASH') { $currdefresponder = $settings->{'anonsurvey_threshold'}; @@ -4572,51 +2739,14 @@ sub print_coursedefaults { } } if (ref($settings->{'coursecredits'}) eq 'HASH') { - foreach my $type (@types) { - next if ($type eq 'community'); - $defcredits{$type} = $settings->{'coursecredits'}->{$type}; - if ($defcredits{$type} ne '') { - $currusecredits = 1; - } + $def_official_credits = $settings->{'coursecredits'}->{'official'}; + $def_unofficial_credits = $settings->{'coursecredits'}->{'unofficial'}; + $def_textbook_credits = $settings->{'coursecredits'}->{'textbook'}; + if (($def_official_credits ne '') || ($def_unofficial_credits ne '') || + ($def_textbook_credits ne '')) { + $currusecredits = 1; } } - if (ref($settings->{'postsubmit'}) eq 'HASH') { - if ($settings->{'postsubmit'}->{'client'} eq 'off') { - $postsubmitclient = 0; - foreach my $type (@types) { - $deftimeout{$type} = $staticdefaults{'postsubmit'}; - } - } else { - foreach my $type (@types) { - if (ref($settings->{'postsubmit'}->{'timeout'}) eq 'HASH') { - if ($settings->{'postsubmit'}->{'timeout'}->{$type} =~ /^\d+$/) { - $deftimeout{$type} = $settings->{'postsubmit'}->{'timeout'}->{$type}; - } else { - $deftimeout{$type} = $staticdefaults{'postsubmit'}; - } - } else { - $deftimeout{$type} = $staticdefaults{'postsubmit'}; - } - } - } - } else { - foreach my $type (@types) { - $deftimeout{$type} = $staticdefaults{'postsubmit'}; - } - } - if (ref($settings->{'mysqltables'}) eq 'HASH') { - foreach my $type (keys(%{$settings->{'mysqltables'}})) { - $currmysql{$type} = $settings->{'mysqltables'}{$type}; - } - } else { - foreach my $type (@types) { - $currmysql{$type} = $staticdefaults{'mysqltables'}; - } - } - } else { - foreach my $type (@types) { - $deftimeout{$type} = $staticdefaults{'postsubmit'}; - } } if (!$currdefresponder) { $currdefresponder = $staticdefaults{'anonsurvey_threshold'}; @@ -4635,35 +2765,40 @@ sub print_coursedefaults { ''."\n"; - $itemcount ++; - $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable .= ''. - ''. - ''."\n"; - $itemcount ++; - } $$rowtotal += $itemcount; return $datatable; } -sub print_selfenrollment { - my ($position,$dom,$settings,$rowtotal) = @_; - my ($css_class,$datatable); - my $itemcount = 1; - my @types = ('official','unofficial','community','textbook'); - if (($position eq 'top') || ($position eq 'middle')) { - my ($rowsref,$titlesref) = &Apache::lonuserutils::get_selfenroll_titles(); - my %descs = &Apache::lonuserutils::selfenroll_default_descs(); - my @rows; - my $key; - if ($position eq 'top') { - $key = 'admin'; - if (ref($rowsref) eq 'ARRAY') { - @rows = @{$rowsref}; - } - } elsif ($position eq 'middle') { - $key = 'default'; - @rows = ('types','registered','approval','limit'); - } - foreach my $row (@rows) { - if (defined($titlesref->{$row})) { - $itemcount ++; - $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= ''. - ''. - ''; - } - } elsif ($position eq 'bottom') { - $datatable .= &print_validation_rows('selfenroll',$dom,$settings,\$itemcount); - } - $$rowtotal += $itemcount; - return $datatable; -} - -sub print_validation_rows { - my ($caller,$dom,$settings,$rowtotal) = @_; - my ($itemsref,$namesref,$fieldsref); - if ($caller eq 'selfenroll') { - ($itemsref,$namesref,$fieldsref) = &Apache::lonuserutils::selfenroll_validation_types(); - } elsif ($caller eq 'requestcourses') { - ($itemsref,$namesref,$fieldsref) = &Apache::loncoursequeueadmin::requestcourses_validation_types(); - } - my %currvalidation; - if (ref($settings) eq 'HASH') { - if (ref($settings->{'validation'}) eq 'HASH') { - %currvalidation = %{$settings->{'validation'}}; - } - } - my $datatable; - my $itemcount = 0; - foreach my $item (@{$itemsref}) { - my $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable .= ''. - ''."\n"; - if (ref($rowtotal)) { - $itemcount ++; - } - } - if ($caller eq 'requestcourses') { - my %currhash; - if (ref($settings) eq 'HASH') { - if (ref($settings->{'validation'}) eq 'HASH') { - if ($settings->{'validation'}{'dc'} ne '') { - $currhash{$settings->{'validation'}{'dc'}} = 1; - } - } - } - my $numinrow = 2; - my ($numdc,$dctable,$rows) = &active_dc_picker($dom,$numinrow,'radio', - 'validationdc',%currhash); - my $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable .= ''; - $itemcount ++; - } - if (ref($rowtotal)) { - $$rowtotal += $itemcount; - } - 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', - ); - 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 .= ''. - ''; - $itemcount ++; - $css_class = $itemcount%2?' class="LC_odd_row"':''; - $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 .= ''. - ''; - $itemcount ++; - $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= ''. - ''; - $itemcount ++; - $css_class = $itemcount%2?' class="LC_odd_row"':''; - $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 .= ''. - ''; - } 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 .= ''. - ''; - $itemcount ++; - } - } elsif ($position eq 'lower') { - my ($min,$max,%chars,$numsaved); - $min = $Apache::lonnet::passwdmin; - 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 ($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', - ); - $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= ''. - ''; - $itemcount ++; - $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= ''. - ''; - $itemcount ++; - $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= ''; - my $numinrow = 2; - my @possrules = ('uc','lc','num','spec'); - $datatable .= ''; - $itemcount ++; - $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= ''. - ''; - } 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 .= ''. - ''. - ''; - } - 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'}; - } - } - } - } - } - 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 = ''. - ''; - 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 .= ''; - } 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 .= ''; - } - $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 = ''. - ''. - ''; - $itemcount++; - } - if (keys(%otherdoms)) { - foreach my $key (sort(keys(%otherdoms))) { - $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable .= ''. - ''. - ''; - $itemcount++; - } - } - } else { - my %ip_methods = &remoteip_methods(); - if ($setdom) { - $itemcount ++; - $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 .= ''. - ''. - ''. - ''. - ''. - ''. - ''; - } - if (keys(%otherdoms)) { - foreach my $domain (sort(keys(%otherdoms))) { - $itemcount ++; - $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable .= ''. - ''. - ''; - } - } - } - $$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', - ); -} - sub print_usersessions { my ($position,$dom,$settings,$rowtotal) = @_; my ($css_class,$datatable,%checked,%choices); @@ -5684,18 +2827,7 @@ sub print_usersessions { 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 $other_insts = scalar(keys(%by_location)); - $datatable .= &spares_row($dom,\%servers,\%spareid,\%serverhomes,\%altids, - $other_insts,$curroffloadnow,$curroffloadoth,$rowtotal); + $datatable .= &spares_row($dom,\%servers,\%spareid,\%serverhomes,\%altids,$rowtotal); } else { $datatable .= ''; + ''; my $rem = $i%($numinrow); if ($rem == 0) { if (($i > 0) && ($i < $numspares-1)) { @@ -6248,35 +3351,8 @@ sub print_loadbalancing { $datatable .= ''.$typetitles{$sparetype}.'
'. '
'.$choices->{$item}."\n"; if ($designs->{'links'}{$item}) { $datatable.=' '; @@ -2079,15 +1532,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 .= ''; } @@ -2531,50 +1986,36 @@ 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') { if (ref($settings->{'notify'}) eq 'HASH') { if ($settings->{'notify'}{'approval'} ne '') { - map {$currapp{$_}=1;} split(/,/,$settings->{'notify'}{'approval'}); + map {$currapp{$_}=1;} split(/,/,$settings->{'notify'}{'approval'}); } } } 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.'"'; - } + my $css_class = 'class="LC_odd_row"'; my $text; if ($action eq 'requestcourses') { $text = &mt('Receive notification of course requests requiring approval'); - } elsif ($action eq 'requestauthor') { - $text = &mt('Receive notification of Authoring Space requests requiring approval'); } else { - $text = &mt('Receive notification of queued requests for self-created user accounts requiring approval'); + $text = &mt('Receive notification of authoring space requests requiring approval') } - $datatable = ''. + $datatable = '
'.$text.''; my ($numdc,$table,$rows) = &active_dc_picker($dom,$numinrow,'checkbox', - $action.'notifyapproval',%currapp); + 'reqapprovalnotify',%currapp); if ($numdc > 0) { $datatable .= $table; } else { $datatable .= &mt('There are no active Domain Coordinators'); } $datatable .='
' - .''; for (my $k=0; $k<=$maxnum; $k++) { my $vpos = $k+1; my $selstr; @@ -2664,42 +2100,39 @@ sub print_textbookcourses { $datatable .= ''; } $datatable .= ''.(' 'x2). - ''. - ''.&mt('Subject:').' '. + ''.&mt('Subject:').' '. (' 'x2). - ''.&mt('Title:').' '; - if ($type eq 'textbooks') { - $datatable .= (' 'x2). - ''.&mt('Publisher:').' '. - (' 'x2). - ''.&mt('Author(s):').' '. - (' 'x2). - ''.&mt('Thumbnail:'); - if ($image) { - $datatable .= $imgsrc. - ' '. - ' '.&mt('Replace:').' '; - } - if ($switchserver) { - $datatable .= &mt('Upload to library server: [_1]',$switchserver); - } else { - $datatable .= ''; - } + ''.&mt('Title:').' '. + (' 'x2). + ''.&mt('Author(s):').' '. + (' 'x2). + ''.&mt('Thumbnail:'); + if ($image) { + $datatable .= ''. + $imgsrc. + ' '. + ' '.&mt('Replace:').' '; } - $datatable .= ' '. + if ($switchserver) { + $datatable .= &mt('Upload to library server: [_1]',$switchserver); + } else { + $datatable .= ''; + } + $datatable .= ' '. ''.&mt('LON-CAPA course:').' '. $coursetitle.'
'."\n". - ''."\n". - ''."\n". + ' '."\n". - ''.&mt('Add').''. - ''.&mt('Subject:').' '."\n". + ''.&mt('Subject:').' '."\n". (' 'x2). - ''.&mt('Title:').' '."\n". - (' 'x2); - if ($type eq 'textbooks') { - $datatable .= ''.&mt('Publisher:').' '."\n". - (' 'x2). - ''.&mt('Author(s):').' '."\n". - (' 'x2). - ''.&mt('Image:').' '; - if ($switchserver) { - $datatable .= &mt('Upload to library server: [_1]',$switchserver); - } else { - $datatable .= ''; - } - $datatable .= ''."\n"; - } - $datatable .= ''.&mt('LON-CAPA course:').' '. - &Apache::loncommon::select_dom_form($env{'request.role.domain'},$type.'_addbook_cdom'). - ''. + ''.&mt('Title:').' '."\n". + (' 'x2). + ''.&mt('Author(s):').' '."\n". + (' 'x2). + ''.&mt('Image:').' '; + if ($switchserver) { + $datatable .= &mt('Upload to library server: [_1]',$switchserver); + } else { + $datatable .= ''; + } + $datatable .= ''."\n". + ''.&mt('LON-CAPA course:').' '. + &Apache::loncommon::select_dom_form($env{'request.role.domain'},'addbook_cdom'). + ''. &Apache::loncommon::selectcourse_link - ('display',$type.'_addbook_cnum',$type.'_addbook_cdom',undef,undef,undef,'Course'). + ('display','addbook_cnum','addbook_cdom',undef,undef,undef,'Course'); '
'.&mt('Failsafe for no drops when institutional data missing').''. - '
'.&mt($choices{'run'}).'
'.&mt($title{'run'}).' '. + $updateon.' value="1" />'.&mt('Yes').' '. '
'.&mt($title{'classlists'}).''. + ' '. + '
'.$choices{'lastactive'}.''. - ' '. - '
'. - ': '.&mt('inactive = no activity in last [_1] days', - ''). - '
'; if ($numdc > 1) { - $datatable .= &mt('Course creation processed as: (choose Dom. Coord.)'). - ''; + $datatable .= '
'. + &mt('Course creation processed as: (choose Dom. Coord.)'). + ''.$dctable.'
'; + $datatable .= $dctable.'
'.&mt('Institutional directory search available?').' '. - '
'.&mt('Other domains can search institution?').' '. - '
'.&mt('Directory search available?').' '. + '
'.&mt('Other domains can search?').' '. + '
'.&mt('Supported search methods'). - ''; - foreach my $title (@{$titleorder}) { - if (defined($searchtitles->{$title})) { - my $check = ' '; - if (ref($settings) eq 'HASH') { - if (ref($settings->{'searchby'}) eq 'ARRAY') { - if (grep(/^\Q$title\E$/,@{$settings->{'searchby'}})) { - $check = ' checked="checked" '; - } + } + if ($cansrchrow) { + $$rowtotal ++; + $datatable .= ''; + } else { + $datatable .= ''; + } + $datatable .= ''; - $$rowtotal ++; - if ($cansrchrow) { - $datatable .= ''; - } else { - $datatable .= ''; - } - $datatable .= ''. - ''; - $$rowtotal ++; + } + $datatable .= '
'.&mt('Supported search methods'). + ''; + foreach my $title (@{$titleorder}) { + if (defined($searchtitles->{$title})) { + my $check = ' '; + if (ref($settings) eq 'HASH') { + if (ref($settings->{'searchby'}) eq 'ARRAY') { + if (grep(/^\Q$title\E$/,@{$settings->{'searchby'}})) { + $check = ' checked="checked" '; } } - $datatable .= ''; } + $datatable .= ''; } - $datatable .= '
'. - ''. + '
'.&mt('Search latitude').''. - ' '. - ' '. - '
'.&mt('LON-CAPA directory search available?').' '. - '
'.&mt('Other domains can search LON-CAPA domain?').' '. - '
'.&mt('Search latitude').''. + ' '. + ' '. + '
'.$titles->{$item}. - ''. - '
'.&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 .= '
'.$titles->{$item}. + ''. + '
'. - $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 .= '
'. - $titles->{$item}. - ''. - '
'. + $titles->{$type}.': '. - ''.$titles->{'errorweights'}. - ''; - foreach my $type ('E','W','N','U') { - $datatable .= ''; - } - $datatable .= '
'.$names->{$type}.'
'. - '
'. - $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 .= '
'. - ''. - '  
$description'. - '
'.&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). - ''. - '
'. - '
'.$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').''. - &Apache::lonuserutils::custom_role_table($crstype,\%full,\%levels, - \%levelscurrent,$identifier, - 'LC_hidden',$prefix.$num.'_privs'). - '
'.&mt('Role name').''. - ''. - &mt('Internal name:'). - ''. - ''.(' 'x4). - ''. - &mt('Name shown to users:'). - ''. - '
'. - &helpdeskroles_access($dom,$prefix,$count,'',undef,\@accesstypes,$othertitle, - $usertypes,$types,\%domhelpdesk). - '
'.&mt('Role privileges').''. - &Apache::lonuserutils::custom_role_header($context,$crstype, - \@templateroles,$newcust). - &Apache::lonuserutils::custom_role_table('Course',\%full,\%levels, - \%levelscurrent,$newcust). - '
'. - &helpsettings_javascript(\@roles_by_num,$maxnum,$hiddenstr,$formname). - '
'. ''.$choices->{$item}. - ''; - } else { - $datatable .= ''; - } - $datatable .= ''; - if ($firstval eq 'no') { - $datatable .= - ' '; - } else { - $datatable .= + ''. ' '; - } - $datatable .= ''.$additional.'
'. - ''.$choices{'texengine'}. - ''. - '
'. - ''.$choices{'canclone'}. - ''; - my $currcanclone = 'none'; - my $onclick; - my @cloneoptions = ('none','domain'); - my %clonetitles = &Apache::lonlocal::texthash ( - none => 'No additional course requesters', - domain => "Any course requester in course's domain", - instcode => 'Course requests for official courses ...', - ); - my (%codedefaults,@code_order,@posscodes); - if (&Apache::lonnet::auto_instcode_defaults($dom,\%codedefaults, - \@code_order) eq 'ok') { - if (@code_order > 0) { - push(@cloneoptions,'instcode'); - $onclick = ' onclick="toggleDisplay(this.form,'."'cloneinstcode'".');"'; - } - } - if (ref($settings) eq 'HASH') { - if ($settings->{'canclone'}) { - if (ref($settings->{'canclone'}) eq 'HASH') { - if (ref($settings->{'canclone'}{'instcode'}) eq 'ARRAY') { - if (@code_order > 0) { - $currcanclone = 'instcode'; - @posscodes = @{$settings->{'canclone'}{'instcode'}}; - } - } - } elsif ($settings->{'canclone'} eq 'domain') { - $currcanclone = $settings->{'canclone'}; - } - } - } - foreach my $option (@cloneoptions) { - my ($checked,$additional); - if ($currcanclone eq $option) { - $checked = ' checked="checked"'; - } - if ($option eq 'instcode') { - if (@code_order) { - my $show = 'none'; - if ($checked) { - $show = 'block'; - } - $additional = '
'. - &mt('Institutional codes for new and cloned course have identical:'). - '
'; - foreach my $item (@code_order) { - my $codechk; - if ($checked) { - if (grep(/^\Q$item\E$/,@posscodes)) { - $codechk = ' checked="checked"'; - } - } - $additional .= ''; - } - $additional .= (' 'x2).'('.&mt('check as many as needed').')
'; - } - } - $datatable .= - ' '.$additional.'
'; - } - $datatable .= '
'. ''. - '
'. - $choices{'uploadquota'}. - ''. - ''; + ''."\n". + ''. + ''."\n"; - $itemcount ++; - my $onclick = "toggleDisplay(this.form,'credits');"; + $itemcount += 2; + my $onclick = 'toggleCredits(this.form);'; my $display = 'none'; if ($currusecredits) { $display = 'block'; } my $additional = '
'. - ''.&mt('Default credits').'
'. + $choices{'uploadquota'}. + ''. + ''; foreach my $type (@types) { $datatable .= ''; } $datatable .= '
'.&mt($type).'
'. '
'; - foreach my $type (@types) { - next if ($type eq 'community'); - $additional .= ''; - } - $additional .= '
'.&mt($type).'
'. - '
'."\n"; + ''. + &mt('Default credits for official courses [_1]', + ''). + '
'. + ''. + &mt('Default credits for unofficial courses [_1]', + ''). + '
'. + ''. + &mt('Default credits for textbook courses [_1]', + ''). + ''."\n"; %defaultchecked = ('coursecredits' => 'off'); @toggles = ('coursecredits'); my $current = { @@ -4671,1005 +2806,13 @@ sub print_coursedefaults { }; (my $table,$itemcount) = &radiobutton_prefs($current,\@toggles,\%defaultchecked, - \%choices,$itemcount,$onclick,$additional,'left'); - $datatable .= $table; - $onclick = "toggleDisplay(this.form,'studentsubmission');"; - my $display = 'none'; - if ($postsubmitclient) { - $display = 'block'; - } - $additional = '
'. - &mt('Number of seconds submit is disabled').'
'. - ''.&mt('Enter 0 to remain disabled until page reload.').'
'. - ''; - foreach my $type (@types) { - $additional .= ''; - } - $additional .= '
'.&mt($type).'
'. - '
'."\n"; - %defaultchecked = ('postsubmit' => 'on'); - @toggles = ('postsubmit'); - $current = { - 'postsubmit' => $postsubmitclient, - }; - ($table,$itemcount) = - &radiobutton_prefs($current,\@toggles,\%defaultchecked, - \%choices,$itemcount,$onclick,$additional,'left'); + \%choices,$itemcount,$onclick,$additional); $datatable .= $table; - $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable .= '
'. - $choices{'mysqltables'}. - ''. - ''; - foreach my $type (@types) { - $datatable .= ''; - } - $datatable .= '
'.&mt($type).'
'. - '
'.$titlesref->{$row}.''. - ''; - my (%current,%currentcap); - if (ref($settings) eq 'HASH') { - if (ref($settings->{$key}) eq 'HASH') { - foreach my $type (@types) { - if (ref($settings->{$key}->{$type}) eq 'HASH') { - $current{$type} = $settings->{$key}->{$type}->{$row}; - } - if (($row eq 'limit') && ($key eq 'default')) { - if (ref($settings->{$key}->{$type}) eq 'HASH') { - $currentcap{$type} = $settings->{$key}->{$type}->{'cap'}; - } - } - } - } - } - my %roles = ( - '0' => &Apache::lonnet::plaintext('dc'), - ); - - foreach my $type (@types) { - unless (($row eq 'registered') && ($key eq 'default')) { - $datatable .= ''; - } - } - unless (($row eq 'registered') && ($key eq 'default')) { - $datatable .= ''; - } - foreach my $type (@types) { - if ($type eq 'community') { - $roles{'1'} = &mt('Community personnel'); - } else { - $roles{'1'} = &mt('Course personnel'); - } - $datatable .= ''; - } - $datatable .= ''; - } - $datatable .= '
'.&mt($type).'
'; - if ($position eq 'top') { - my %checked; - if ($current{$type} eq '0') { - $checked{'0'} = ' checked="checked"'; - } else { - $checked{'1'} = ' checked="checked"'; - } - foreach my $role ('1','0') { - $datatable .= ' '; - } - } else { - if ($row eq 'types') { - my %checked; - if ($current{$type} =~ /^(all|dom)$/) { - $checked{$1} = ' checked="checked"'; - } else { - $checked{''} = ' checked="checked"'; - } - foreach my $val ('','dom','all') { - $datatable .= ' '; - } - } elsif ($row eq 'registered') { - my %checked; - if ($current{$type} eq '1') { - $checked{'1'} = ' checked="checked"'; - } else { - $checked{'0'} = ' checked="checked"'; - } - foreach my $val ('0','1') { - $datatable .= ' '; - } - } elsif ($row eq 'approval') { - my %checked; - if ($current{$type} =~ /^([12])$/) { - $checked{$1} = ' checked="checked"'; - } else { - $checked{'0'} = ' checked="checked"'; - } - for my $val (0..2) { - $datatable .= ' '; - } - } elsif ($row eq 'limit') { - my %checked; - if ($current{$type} =~ /^(allstudents|selfenrolled)$/) { - $checked{$1} = ' checked="checked"'; - } else { - $checked{'none'} = ' checked="checked"'; - } - my $cap; - if ($currentcap{$type} =~ /^\d+$/) { - $cap = $currentcap{$type}; - } - foreach my $val ('none','allstudents','selfenrolled') { - $datatable .= ' '; - } - $datatable .= '
'. - ''.&mt('Maximum allowed: '). - ''. - ''; - } - } - $datatable .= '
'. - $namesref->{$item}. - ''; - if (($item eq 'url') || ($item eq 'button')) { - $datatable .= ''. - ''; - } elsif ($item eq 'fields') { - my @currfields; - if (ref($currvalidation{$item}) eq 'ARRAY') { - @currfields = @{$currvalidation{$item}}; - } - foreach my $field (@{$fieldsref}) { - my $check = ''; - if (grep(/^\Q$field\E$/,@currfields)) { - $check = ' checked="checked"'; - } - $datatable .= ' '; - } - } elsif ($item eq 'markup') { - $datatable .= ''; - } - $datatable .= '
'; - if ($numdc > 1) { - $datatable .= &mt('Course creation processed as: (choose Dom. Coord.)'); - } else { - $datatable .= &mt('Course creation processed as: '); - } - $datatable .= ''.$dctable.'
'.$titles{'link'}.''. - '
'.$titles{'case'}.''; - if ((ref($types) eq 'ARRAY') && (ref($usertypes) eq 'HASH')) { - foreach my $item (@{$types}) { - my $checkedcase; - if ($casesens{$item}) { - $checkedcase = ' checked="checked"'; - } - $datatable .= ''. - '   '; - } - } - my $checkedcase; - if ($casesens{'default'}) { - $checkedcase = ' checked="checked"'; - } - $datatable .= ''.$titles{'prelink'}.''. - '   '. - '
'.$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 .= '
'.$titles{'emailsrc'}.''; - foreach my $type ('permanent','critical','notify') { - my $checkedemail; - if ($emailsrc{$type}) { - $checkedemail = ' checked="checked"'; - } - $datatable .= ''. - '   '; - } - $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).''; - } else { - $datatable .=' '. - ''; - } - $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 .= '
'.$titles{'min'}.''. - ''. - ' '.&mt('(Enter an integer: 7 or larger)').''. - '
'.$titles{'max'}.''. - ''. - ' '.&mt('(Leave blank for no maximum)').''. - '
'.$titles{'chars'}.'
'. - ''.&mt('(Leave unchecked if not required)'). - '
'; - 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 .= ''; - } - $datatable .= ''; - } - my $rem = @possrules%($numinrow); - my $colsleft = $numinrow - $rem; - if ($colsleft > 1 ) { - $datatable .= ''; - } elsif ($colsleft == 1) { - $datatable .= ''; - } - $datatable .='
'. - '  
'.$titles{'numsaved'}.''. - ''. - ' '.&mt('(Leave blank to not save previous passwords)').''. - '
'. - &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 .= '
'. - &mt('Hostname').': '. - ''.&Apache::lonnet::hostname($server).' '. - &mt('Alias').': '; - if ($current) { - $aliasrows .= $current; - if ($forsaml) { - $aliasrows .= ' ('.&mt('also for SSO Auth').')'; - } - } else { - $aliasrows .= &mt('None'); - } - $aliasrows .= ' ('. - &mt('controlled by domain: [_1]', - ''.$dom_in_effect.'').')'. - &mt('Alias').': '. - ''. - (' 'x2).''. - &mt('Alias used for SSO Auth').':  '. - '
'.&mt('Domain: [_1]',''.$dom.'').'
'. - ''.&mt('WAF in use?').' '.(' 'x2).'
'. - ''.$aliasinfo{$dom}. - '
'.&mt('Domain: [_1]',''.$key.'').''.$aliasinfo{$key}. - '
'.&mt('Domain: [_1]',''.$dom.'').''.&mt('WAF not in use, nothing to set').'
'.&mt('Domain: [_1]',''.$dom.'').'

'. - '
'.&mt('Format for comma separated IP ranges').':
'. - &mt('A.B.C.D/N or A.B.C.D-E.F.G.H').'
'. - &mt('Range(s) stored in CIDR notation').'
'. - ''. - ''."\n". - ''."\n". - ''."\n". - ''."\n". - ''. - ''; - foreach my $item ('vpnint','vpnext') { - $datatable .= ''. - ''."\n"; - } - $datatable .= ''."\n". - ''. - ''."\n". - '
'.$lt{'remoteip'}.': '. - '
'. - $lt{'ipheader'}.': '. - ''. - '
'. - $lt{'trusted'}.':
'. - ''. - '

'.$lt{'vpnaccess'}.':
'. - ''.(' 'x2). - '
'.$lt{$item}.':
'. - ''. - '

'.$lt{'sslopt'}.':
'. - ''.(' 'x2). - '
'.&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}}; - } - } - $datatable .= ''. - ''; - } - $datatable .= '
'.$lt{$item}.': '.$showval.'
'. &mt('Nothing to set here, as the cluster to which this domain belongs only contains one server.'); @@ -5945,8 +3077,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,$rowtotal) = @_; my $css_class; my $numinrow = 4; my $itemcount = 1; @@ -5966,34 +3097,13 @@ sub spares_row { } } next unless (ref($spareid->{$server}) eq 'HASH'); - my ($checkednow,$checkedoth); - 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"; - if ($other_insts) { - $datatable .= '
'. - ''."\n". - ''. + ,''.$server.''). "\n"; - } my (%current,%canselect); my @choices = &possible_newspares($server,$spareid->{$server},$serverhomes,$altids); @@ -6117,13 +3227,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; } @@ -6197,12 +3307,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++) { @@ -6222,10 +3326,9 @@ sub print_loadbalancing { $disabled = ' disabled="disabled"'; } $targettable .= - '
'.$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, @@ -6290,11 +3366,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}))) { @@ -6313,9 +3388,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 { @@ -6346,7 +3418,7 @@ sub loadbalancing_rules { if (ref($currrules) eq 'HASH') { $current = $currrules->{$type}; } - if (($type eq '_LC_external') || ($type eq '_LC_internetdom')) { + if (($type eq '_LC_external') || ($type eq '_LC_internetdom') || ($type eq '_LC_ipchange')) { if ($dom ne &Apache::lonnet::host_domain($lonhost)) { $current = ''; } @@ -6371,14 +3443,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_/) { @@ -6403,7 +3470,7 @@ sub loadbalance_rule_row { my @rulenames; my %ruletitles = &offloadtype_text(); if (($type eq '_LC_ipchangesso') || ($type eq '_LC_ipchange')) { - @rulenames = ('balancer','offloadedto','specific'); + @rulenames = ('balancer','offloadedto'); } else { @rulenames = ('default','homeserver'); if ($type eq '_LC_external') { @@ -6414,7 +3481,7 @@ sub loadbalance_rule_row { push(@rulenames,'none'); } my $style = $targets_div_style; - if (($type eq '_LC_external') || ($type eq '_LC_internetdom')) { + if (($type eq '_LC_external') || ($type eq '_LC_internetdom') || ($type eq '_LC_ipchange')) { $style = $homedom_div_style; } my $space; @@ -6465,13 +3532,8 @@ sub loadbalance_rule_row { ' '; - if (($rulenames[$i] eq 'specific') && ($type =~ /^_LC_ipchange/)) { - $output .= $ruletitles{'particular'}; - } else { - $output .= $ruletitles{$rulenames[$i]}; - } - $output .= ''.$extra.'
'."\n"; + ')"'.$checked.' /> '.$ruletitles{$rulenames[$i]}. + ''.$extra.'
'."\n"; } $output .= ''."\n"; return $output; @@ -6486,7 +3548,6 @@ sub offloadtype_text { 'none' => 'No offload', 'balancer' => 'Session hosted on Load Balancer, after re-authentication', 'offloadedto' => 'Session hosted on offload server, after re-authentication', - 'particular' => 'Session hosted (after re-auth) on server:', ); return %ruletitles; } @@ -6501,21 +3562,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', @@ -6524,34 +3579,6 @@ 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', @@ -6624,22 +3651,42 @@ sub print_usercreation { $rowcount ++; } } + my ($emailrules,$emailruleorder) = + &Apache::lonnet::inst_userrules($dom,'email'); + if (ref($emailrules) eq 'HASH') { + if (keys(%{$emailrules}) > 0) { + $datatable .= &user_formats_row('email',$settings,$emailrules, + $emailruleorder,$numinrow,$rowcount); + $$rowtotal ++; + $rowcount ++; + } + } if ($rowcount == 0) { $datatable .= ''.&mt('No format rules have been defined for usernames or IDs in this domain.').''; $$rowtotal ++; $rowcount ++; } } elsif ($position eq 'middle') { - my @creators = ('author','course','requestcrs'); + my @creators = ('author','course','requestcrs','selfcreate'); my ($rules,$ruleorder) = &Apache::lonnet::inst_userrules($dom,'username'); my %lt = &usercreation_types(); my %checked; + my @selfcreate; if (ref($settings) eq 'HASH') { if (ref($settings->{'cancreate'}) eq 'HASH') { foreach my $item (@creators) { $checked{$item} = $settings->{'cancreate'}{$item}; } + if (ref($settings->{'cancreate'}{'selfcreate'}) eq 'ARRAY') { + @selfcreate = @{$settings->{'cancreate'}{'selfcreate'}}; + } elsif ($settings->{'cancreate'}{'selfcreate'} ne '') { + if ($settings->{'cancreate'}{'selfcreate'} eq 'any') { + @selfcreate = ('email','login','sso'); + } elsif ($settings->{'cancreate'}{'selfcreate'} ne 'none') { + @selfcreate = ($settings->{'cancreate'}{'selfcreate'}); + } + } } elsif (ref($settings->{'cancreate'}) eq 'ARRAY') { foreach my $item (@creators) { if (grep(/^\Q$item\E$/,@{$settings->{'cancreate'}})) { @@ -6651,8 +3698,10 @@ sub print_usercreation { my $rownum = 0; foreach my $item (@creators) { $rownum ++; - if ($checked{$item} eq '') { - $checked{$item} = 'any'; + if ($item ne 'selfcreate') { + if ($checked{$item} eq '') { + $checked{$item} = 'any'; + } } my $css_class; if ($rownum%2) { @@ -6663,18 +3712,30 @@ sub print_usercreation { $datatable .= ''. ''.$lt{$item}. ''; - my @options = ('any'); - if (ref($rules) eq 'HASH') { - if (keys(%{$rules}) > 0) { - push(@options,('official','unofficial')); + my @options; + if ($item eq 'selfcreate') { + push(@options,('email','login','sso')); + } else { + @options = ('any'); + if (ref($rules) eq 'HASH') { + if (keys(%{$rules}) > 0) { + push(@options,('official','unofficial')); + } } + push(@options,'none'); } - push(@options,'none'); foreach my $option (@options) { my $type = 'radio'; my $check = ' '; - if ($checked{$item} eq $option) { - $check = ' checked="checked" '; + if ($item eq 'selfcreate') { + $type = 'checkbox'; + if (grep(/^\Q$option\E$/,@selfcreate)) { + $check = ' checked="checked" '; + } + } else { + if ($checked{$item} eq $option) { + $check = ' checked="checked" '; + } } $datatable .= ''."\n". ''; return $output; } 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') { - 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++) { @@ -7360,41 +3904,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') { - $output .= '
'; return $output; } @@ -7403,26 +3931,18 @@ sub usercreation_types { author => 'When adding a co-author', course => 'When adding a user to a course', requestcrs => 'When requesting a course', + selfcreate => 'User creates own account', any => 'Any', official => 'Institutional only ', unofficial => 'Non-institutional only', + email => 'E-mail address', + login => 'Institutional Login', + sso => 'SSO', none => 'None', ); return %lt; } -sub selfcreation_types { - my %lt = &Apache::lonlocal::texthash ( - selfcreate => 'User creates own account', - any => 'Any', - official => 'Institutional only ', - unofficial => 'Non-institutional only', - email => 'E-mail address', - login => 'Institutional Login', - sso => 'SSO', - ); -} - sub authtype_names { my %lt = &Apache::lonlocal::texthash( int => 'Internal', @@ -7455,7 +3975,7 @@ sub print_usermodification { $$rowtotal ++; $rowcount ++; } - } elsif ($position eq 'bottom') { + } elsif ($position eq 'middle') { $context = 'course'; $rowcount = 0; foreach my $role ('st','ep','ta','in','cr') { @@ -7464,126 +3984,89 @@ sub print_usermodification { $$rowtotal ++; $rowcount ++; } + } elsif ($position eq 'bottom') { + $context = 'selfcreate'; + my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); + $usertypes->{'default'} = $othertitle; + if (ref($types) eq 'ARRAY') { + push(@{$types},'default'); + $usertypes->{'default'} = $othertitle; + foreach my $status (@{$types}) { + $datatable .= &modifiable_userdata_row($context,$status,$settings, + $numinrow,$rowcount,$usertypes); + $$rowtotal ++; + $rowcount ++; + } + } } return $datatable; } 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 ($dom,$settings,$rowtotal) = @_; + my @items = ('auth_def','auth_arg_def','lang_def','timezone_def', + 'datelocale_def','portal_def'); + my %defaults; + if (ref($settings) eq 'HASH') { + %defaults = %{$settings}; + } else { + my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); + foreach my $item (@items) { + $defaults{$item} = $domdefaults{$item}; + } } - if ($position eq 'top') { - my @items = ('auth_def','auth_arg_def','lang_def','timezone_def', - 'datelocale_def','portal_def'); - my %defaults; - if (ref($settings) eq 'HASH') { - %defaults = %{$settings}; + my $titles = &defaults_titles($dom); + my $rownum = 0; + my ($datatable,$css_class); + foreach my $item (@items) { + if ($rownum%2) { + $css_class = ''; } else { - my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); - foreach my $item (@items) { - $defaults{$item} = $domdefaults{$item}; - } + $css_class = ' class="LC_odd_row" '; } - foreach my $item (@items) { - if ($rownum%2) { - $css_class = ''; - } else { - $css_class = ' class="LC_odd_row" '; - } - $datatable .= ''. - ''.$titles->{$item}. - ''; - if ($item eq 'auth_def') { - my @authtypes = ('internal','krb4','krb5','localauth'); - my %shortauth = ( - internal => 'int', - krb4 => 'krb4', - krb5 => 'krb5', - localauth => 'loc' - ); - my %authnames = &authtype_names(); - foreach my $auth (@authtypes) { - my $checked = ' '; - if ($defaults{$item} eq $auth) { - $checked = ' checked="checked" '; - } - $datatable .= '  '; - } - } elsif ($item eq 'timezone_def') { - my $includeempty = 1; - $datatable .= &Apache::loncommon::select_timezone($item,$defaults{$item},undef,$includeempty); - } elsif ($item eq 'datelocale_def') { - my $includeempty = 1; - $datatable .= &Apache::loncommon::select_datelocale($item,$defaults{$item},undef,$includeempty); - } elsif ($item eq 'lang_def') { - my $includeempty = 1; - $datatable .= &Apache::loncommon::select_language($item,$defaults{$item},$includeempty); - } else { - my $size; - if ($item eq 'portal_def') { - $size = ' size="25"'; - } - $datatable .= ''; + $datatable .= ''. + ''.$titles->{$item}. + ''; + if ($item eq 'auth_def') { + my @authtypes = ('internal','krb4','krb5','localauth'); + my %shortauth = ( + internal => 'int', + krb4 => 'krb4', + krb5 => 'krb5', + localauth => 'loc' + ); + my %authnames = &authtype_names(); + foreach my $auth (@authtypes) { + my $checked = ' '; + if ($defaults{$item} eq $auth) { + $checked = ' checked="checked" '; + } + $datatable .= '  '; } - $datatable .= ''; - $rownum ++; - } - } else { - my %defaults; - if (ref($settings) eq 'HASH') { - if ((ref($settings->{'inststatusorder'}) eq 'ARRAY') && (ref($settings->{'inststatustypes'}) eq 'HASH')) { - 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 $chgstr = ' onchange="javascript:reorderTypes(this.form,'."'$item'".');"'; - $datatable .= ''. - ''. - ' '.&mt('Internal ID:').' '.$item.' '. - ''. - &mt('delete').''. - ''.&mt('Name displayed').':'. - ''. - ''; - } - $css_class = $rownum%2?' class="LC_odd_row"':''; - my $chgstr = ' onchange="javascript:reorderTypes(this.form,'."'addinststatus_pos'".');"'; - $datatable .= ''. - ' '.&mt('Internal ID:'). - ''. - ' '.&mt('(new)'). - ''. - &mt('Name displayed').':'. - ''. - ''."\n"; - $rownum ++; + } elsif ($item eq 'timezone_def') { + my $includeempty = 1; + $datatable .= &Apache::loncommon::select_timezone($item,$defaults{$item},undef,$includeempty); + } elsif ($item eq 'datelocale_def') { + my $includeempty = 1; + $datatable .= &Apache::loncommon::select_datelocale($item,$defaults{$item},undef,$includeempty); + } elsif ($item eq 'lang_def') { + my %langchoices = &get_languages_hash(); + $langchoices{''} = 'No language preference'; + %langchoices = &Apache::lonlocal::texthash(%langchoices); + $datatable .= &Apache::loncommon::select_form($defaults{$item},$item, + \%langchoices); + } else { + my $size; + if ($item eq 'portal_def') { + $size = ' size="25"'; } + $datatable .= ''; } + $datatable .= ''; + $rownum ++; } $$rowtotal += $rownum; return $datatable; @@ -7609,9 +4092,6 @@ sub defaults_titles { 'timezone_def' => 'Default timezone', 'datelocale_def' => 'Default locale for dates', 'portal_def' => 'Portal/Default 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'); @@ -7626,58 +4106,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; @@ -7704,8 +4132,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)) { @@ -7714,7 +4142,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}, @@ -7725,13 +4153,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).''; } @@ -7851,176 +4279,10 @@ sub legacy_scantronformat { 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 = ''.&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 .= ''; - $$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; if ($position eq 'top') { - my (%checked); - my @catitems = ('unauth','auth'); - my @cattypes = ('std','domonly','codesrch','none'); - $checked{'unauth'} = 'std'; - $checked{'auth'} = 'std'; - if (ref($settings) eq 'HASH') { - foreach my $type (@cattypes) { - if ($type eq $settings->{'unauth'}) { - $checked{'unauth'} = $type; - } - if ($type eq $settings->{'auth'}) { - $checked{'auth'} = $type; - } - } - } - my %lt = &Apache::lonlocal::texthash ( - unauth => 'Catalog type for unauthenticated users', - auth => 'Catalog type for authenticated users', - none => 'No catalog', - std => 'Standard catalog', - domonly => 'Domain-only catalog', - codesrch => "Code search form", - ); - my $itemcount = 0; - foreach my $item (@catitems) { - my $css_class = $itemcount%2? ' class="LC_odd_row"':''; - $datatable .= ''. - ''.$lt{$item}.''. - ''; - foreach my $type (@cattypes) { - my $ischecked; - if ($checked{$item} eq $type) { - $ischecked=' checked="checked"'; - } - $datatable .= ' '; - } - $datatable .= ''; - $itemcount ++; - } - $$rowtotal += $itemcount; - } elsif ($position eq 'middle') { my $toggle_cats_crs = ' '; my $toggle_cats_dom = ' checked="checked" '; my $can_cat_crs = ' '; @@ -8227,7 +4489,7 @@ sub print_coursecategories { $datatable .= &initialize_categories($itemcount); } } else { - $datatable .= ''.$hdritem->{'header'}->[1]->{'col2'}.'' + $datatable .= ''.$hdritem->{'header'}->[0]->{'col2'}.'' .&initialize_categories($itemcount); } $$rowtotal += $itemcount; @@ -8275,7 +4537,7 @@ sub print_serverstatuses { ''. ''. - ''."\n"; + ''."\n"; } $$rowtotal += $rownum; return $datatable; @@ -8285,158 +4547,7 @@ 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'); -} - -sub defaults_javascript { - my ($settings) = @_; - 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 '') { - $maxnum = 0; - } - $maxnum ++; - my $jstext = ' var inststatuses = Array('."'".join("','",@{$settings->{'inststatusorder'}})."'".');'; - return <<"ENDSCRIPT"; - - -ENDSCRIPT - } -} - -sub passwords_javascript { - my %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).', - passexp => 'Warning: days before password expiration must be a positive integer (or blank).', - passnum => 'Warning: number of previous passwords to save must be a positive integer (or blank).', - ); - &js_escape(\%intalert); - my $defmin = $Apache::lonnet::passwdmin; - my $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; -} - -function warnIntPass(field) { - field.value.replace(/^\s+/,''); - field.value.replace(/\s+\$/,''); - var regexdigit=/^\\d+\$/; - if (field.name == 'passwords_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 (field.name == 'passwords_expire') { - var regexpposnum=/^\\d+(|\\.\\d*)\$/; - if (!regexpposnum.test(field.value)) { - alert('$intalert{passexp}'); - field.value = ''; - } else { - var expval = parseFloat(field.value); - if (expval == 0) { - alert('$intalert{passexp}'); - field.value = ''; - } - } - } else { - if (!regexdigit.test(field.value)) { - if (field.name == 'passwords_max') { - alert('$intalert{passmax}'); - } else { - if (field.name == 'passwords_numsaved') { - alert('$intalert{passnum}'); - } - } - field.value = ''; - } - } - } - } - return; -} - -ENDSCRIPT - return &Apache::lonhtmlcommon::scripttag($intauthjs); + 'uniquecodes'); } sub coursecategories_javascript { @@ -8461,12 +4572,9 @@ sub coursecategories_javascript { $jstext = ' var categories = Array(1);'."\n". ' categories[0] = Array("instcode_pos");'."\n"; } - 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 $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(\$choose_again); + my $instcode_reserved = &mt('The name: "instcode" is a reserved category'); + my $communities_reserved = &mt('The name: "communities" is a reserved category'); + my $choose_again = '\\n'.&mt('Please use a different name for the new top level category'); $output = <<"ENDSCRIPT";