--- loncom/interface/domainprefs.pm 2015/03/11 17:15:40 1.160.6.57 +++ loncom/interface/domainprefs.pm 2012/12/20 13:23:49 1.181 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.160.6.57 2015/03/11 17:15:40 raeburn Exp $ +# $Id: domainprefs.pm,v 1.181 2012/12/20 13:23:49 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -45,7 +45,7 @@ described at http://www.lon-capa.org. =head1 OVERVIEW Each institution using LON-CAPA will typically have a single domain designated -for use by individuals affiliated with the institution. Accordingly, each domain +for use by individuals affliated with the institution. Accordingly, each domain may define a default set of logos and a color scheme which can be used to "brand" the LON-CAPA instance. In addition, an institution will typically have a language and timezone which are used for the majority of courses. @@ -86,7 +86,7 @@ $dom,$settings,$rowtotal,$action. $dom is the domain, $settings is a reference to a hash of current settings for the current context, $rowtotal is a reference to the scalar used to record the -number of rows displayed on the page, and $action is the context (quotas, +number of rows displayed on the page, and $action is the context (quotas, requestcourses or requestauthor). The print_quotas routine was orginally created to display/store information @@ -94,8 +94,7 @@ about default quota sizes for portfolio institutional affiliation in the domain (e.g., Faculty, Staff, Student etc.), but is now also used to manage availability of user tools: i.e., blogs, aboutme page, and portfolios, and the course request tool, -used by course owners to request creation of a course, and to display/store -default quota sizes for Authoring Spaces. +used by course owners to request creation of a course. Outputs: 1 @@ -103,8 +102,8 @@ $datatable - HTML containing form eleme In the case of course requests, radio buttons are displayed for each institutional affiliate type (and also default, and _LC_adv) for each of the course types -(official, unofficial, community, and textbook). In each case the radio buttons -allow the selection of one of four values: +(official, unofficial and community). In each case the radio buttons allow the +selection of one of four values: 0, approval, validate, autolimit=N (where N is blank, or a positive integer). which have the following effects: @@ -164,8 +163,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(); @@ -213,15 +210,15 @@ sub handler { 'quotas','autoenroll','autoupdate','autocreate', 'directorysrch','usercreation','usermodification', 'contacts','defaults','scantron','coursecategories', - 'serverstatuses','requestcourses','coursedefaults', - 'usersessions','loadbalancing','requestauthor', - 'selfenrollment','inststatus'],$dom); + 'serverstatuses','requestcourses','helpsettings', + 'coursedefaults','usersessions','loadbalancing', + 'requestauthor'],$dom); my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', 'autoupdate','autocreate','directorysrch','contacts', - 'usercreation','selfcreation','usermodification','scantron', + 'usercreation','usermodification','scantron', 'requestcourses','requestauthor','coursecategories', - 'serverstatuses','coursedefaults','selfenrollment', - 'usersessions'); + 'serverstatuses','helpsettings', + 'coursedefaults','usersessions'); my %existing; if (ref($domconfig{'loadbalancing'}) eq 'HASH') { %existing = %{$domconfig{'loadbalancing'}}; @@ -241,8 +238,6 @@ sub handler { col2 => '',}, {col1 => 'Administrator Settings', col2 => '',}], - print => \&print_rolecolors, - modify => \&modify_rolecolors, }, 'login' => { text => 'Log-in page options', @@ -250,38 +245,26 @@ sub handler { header => [{col1 => 'Log-in Page Items', col2 => '',}, {col1 => 'Log-in Help', - col2 => 'Value'}, - {col1 => 'Custom HTML in document head', col2 => 'Value'}], - print => \&print_login, - modify => \&modify_login, }, '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 => 'Assignable to e-mail usernames'}], - print => \&print_defaults, - modify => \&modify_defaults, + col2 => 'Value'}], }, 'quotas' => - { text => 'Blogs, personal web pages, webDAV/quotas, portfolios', + { text => 'Blogs, personal web pages, webDAV, portfolios', help => 'Domain_Configuration_Quotas', header => [{col1 => 'User affiliation', col2 => 'Available tools', - col3 => 'Quotas, MB; (Authoring requires role)',}], - print => \&print_quotas, - modify => \&modify_quotas, + col3 => 'Portfolio quota',}], }, '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', @@ -291,34 +274,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 => 'Institutional directory searches', help => 'Domain_Configuration_InstDirectory_Search', header => [{col1 => 'Setting', col2 => 'Value',}], - print => \&print_directorysrch, - modify => \&modify_directorysrch, }, 'contacts' => { text => 'Contact Information', help => 'Domain_Configuration_Contact_Info', header => [{col1 => 'Setting', col2 => 'Value',}], - print => \&print_contacts, - modify => \&modify_contacts, }, + 'usercreation' => { text => 'User creation', help => 'Domain_Configuration_User_Creation', @@ -328,30 +304,16 @@ 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 as username', - 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 file', @@ -359,8 +321,6 @@ sub handler { header => [ {col1 => 'Item', col2 => '', }], - print => \&print_scantron, - modify => \&modify_scantron, }, 'requestcourses' => {text => 'Request creation of courses', @@ -368,38 +328,24 @@ sub handler { header => [{col1 => 'User affiliation', col2 => 'Availability/Processing of requests',}, {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 => 'Value'}], }, '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', @@ -408,8 +354,12 @@ sub handler { col2 => 'Other named users', col3 => 'Specific IPs', }], - print => \&print_serverstatuses, - modify => \&modify_serverstatuses, + }, + 'helpsettings' => + {text => 'Help page settings', + help => 'Domain_Configuration_Help_Settings', + header => [{col1 => 'Help Settings (logged-in users)', + col2 => 'Value'}], }, 'coursedefaults' => {text => 'Course/Community defaults', @@ -418,20 +368,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', @@ -442,19 +384,15 @@ sub handler { col2 => 'Rules'}, {col1 => "Hosting domain's own users elsewhere", col2 => 'Rules'}], - print => \&print_usersessions, - modify => \&modify_usersessions, }, 'loadbalancing' => - {text => 'Dedicated Load Balancer(s)', + {text => 'Dedicated Load Balancer', help => 'Domain_Configuration_Load_Balancing', header => [{col1 => 'Balancers', col2 => 'Default destinations', - col3 => 'User affiliation', + col3 => 'User affliation', col4 => 'Overrides'}, ], - print => \&print_loadbalancing, - modify => \&modify_loadbalancing, }, ); if (keys(%servers) > 1) { @@ -465,14 +403,12 @@ sub handler { {col1 => 'Log-in Page Items', col2 => ''}, {col1 => 'Log-in Help', - col2 => 'Value'}, - {col1 => 'Custom HTML in document head', col2 => 'Value'}], - print => \&print_login, - modify => \&modify_login, }; } + + my @roles = ('student','coordinator','author','admin'); my @actions = &Apache::loncommon::get_env_multiple('form.actions'); &Apache::lonhtmlcommon::add_breadcrumb @@ -481,15 +417,9 @@ sub handler { my $confname = $dom.'-domainconfig'; if ($phase eq 'process') { - my $result = &Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order, - \%prefs,\%domconfig,$confname,\@roles); - if ((ref($result) eq 'HASH') && (keys(%{$result}))) { - $r->rflush(); - &devalidate_remote_domconfs($dom,$result); - } + &Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,\@roles); } elsif ($phase eq 'display') { - my $js = &recaptcha_js(). - &toggle_display_js(); + my $js = &recaptcha_js(); if ((keys(%servers) > 1) || (keys(%existing) > 0)) { my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); @@ -499,16 +429,6 @@ sub handler { &common_domprefs_js(). &Apache::loncommon::javascript_array_indexof(); } - if (grep(/^requestcourses$/,@actions)) { - my $javascript_validations; - my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'}); - $js .= < -$javascript_validations - -$coursebrowserjs -END - } &Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,$js); } else { # check if domconfig user exists for the domain. @@ -518,7 +438,7 @@ END unless ($configuserok eq 'ok') { &Apache::lonconfigsettings::print_header($r,$phase,$context); $r->print(&mt('The domain configuration user "[_1]" has yet to be created.', - $confname). + $confname). '
' ); if ($switchserver) { @@ -572,27 +492,28 @@ END } } } + &Apache::lonconfigsettings::display_choices($r,$phase,$context,\@prefs_order,\%prefs); } return OK; } sub process_changes { - my ($r,$dom,$confname,$action,$roles,$values,$lastactref) = @_; + my ($r,$dom,$confname,$action,$roles,$values) = @_; my %domconfig; if (ref($values) eq 'HASH') { %domconfig = %{$values}; } my $output; if ($action eq 'login') { - $output = &modify_login($r,$dom,$confname,$lastactref,%domconfig); + $output = &modify_login($r,$dom,$confname,%domconfig); } elsif ($action eq 'rolecolors') { $output = &modify_rolecolors($r,$dom,$confname,$roles, - $lastactref,%domconfig); + %domconfig); } elsif ($action eq 'quotas') { - $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig); + $output = &modify_quotas($dom,$action,%domconfig); } elsif ($action eq 'autoenroll') { - $output = &modify_autoenroll($dom,$lastactref,%domconfig); + $output = &modify_autoenroll($dom,%domconfig); } elsif ($action eq 'autoupdate') { $output = &modify_autoupdate($dom,%domconfig); } elsif ($action eq 'autocreate') { @@ -601,30 +522,28 @@ sub process_changes { $output = &modify_directorysrch($dom,%domconfig); } elsif ($action eq 'usercreation') { $output = &modify_usercreation($dom,%domconfig); - } elsif ($action eq 'selfcreation') { - $output = &modify_selfcreation($dom,%domconfig); } elsif ($action eq 'usermodification') { $output = &modify_usermodification($dom,%domconfig); } elsif ($action eq 'contacts') { - $output = &modify_contacts($dom,$lastactref,%domconfig); + $output = &modify_contacts($dom,%domconfig); } elsif ($action eq 'defaults') { - $output = &modify_defaults($dom,$lastactref,%domconfig); + $output = &modify_defaults($dom,$r); } elsif ($action eq 'scantron') { - $output = &modify_scantron($r,$dom,$confname,$lastactref,%domconfig); + $output = &modify_scantron($r,$dom,$confname,%domconfig); } elsif ($action eq 'coursecategories') { - $output = &modify_coursecategories($dom,$lastactref,%domconfig); + $output = &modify_coursecategories($dom,%domconfig); } elsif ($action eq 'serverstatuses') { $output = &modify_serverstatuses($dom,%domconfig); } elsif ($action eq 'requestcourses') { - $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig); + $output = &modify_quotas($dom,$action,%domconfig); } elsif ($action eq 'requestauthor') { - $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig); + $output = &modify_quotas($dom,$action,%domconfig); + } elsif ($action eq 'helpsettings') { + $output = &modify_helpsettings($r,$dom,$confname,%domconfig); } elsif ($action eq 'coursedefaults') { - $output = &modify_coursedefaults($dom,$lastactref,%domconfig); - } elsif ($action eq 'selfenrollment') { - $output = &modify_selfenrollment($dom,$lastactref,%domconfig) + $output = &modify_coursedefaults($dom,%domconfig); } elsif ($action eq 'usersessions') { - $output = &modify_usersessions($dom,$lastactref,%domconfig); + $output = &modify_usersessions($dom,%domconfig); } elsif ($action eq 'loadbalancing') { $output = &modify_loadbalancing($dom,%domconfig); } @@ -635,12 +554,11 @@ sub print_config_box { my ($r,$dom,$confname,$phase,$action,$item,$settings) = @_; my $rowtotal = 0; my $output; + if ($action eq 'coursecategories') { $output = &coursecategories_javascript($settings); - } elsif ($action eq 'defaults') { - $output = &defaults_javascript($settings); } - $output .= + $output .= ''; $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')) { - $output .= $item->{'print'}->('top',$dom,$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); + $output .= &print_coursecategories('top',$dom,$item,$settings,\$rowtotal); } elsif ($action eq 'login') { - if ($numheaders == 4) { + 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 .= '
'. @@ -655,8 +573,8 @@ sub print_config_box { if ($numheaders > 1) { my $colspan = ''; my $rightcolspan = ''; - if (($action eq 'rolecolors') || ($action eq 'defaults') || - (($action eq 'login') && ($numheaders < 4))) { + if (($action eq 'rolecolors') || ($action eq 'coursecategories') || + (($action eq 'login') && ($numheaders < 3))) { $colspan = ' colspan="2"'; } if ($action eq 'usersessions') { @@ -671,23 +589,31 @@ sub print_config_box { '.&mt($item->{'header'}->[0]->{'col2'}).'
@@ -697,20 +623,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')) { - if ($action eq 'coursecategories') { - $output .= &print_coursecategories('middle',$dom,$item,$settings,\$rowtotal); - $colspan = ' colspan="2"'; - } 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'}).'
@@ -719,20 +638,11 @@ sub print_config_box { - - '."\n"; - if ($action eq 'coursecategories') { - $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal); - } else { - $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); - } + '. + &print_autoupdate('bottom',$dom,$settings,\$rowtotal); $rowtotal ++; - } elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') || - ($action eq 'defaults')) { - $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); - } elsif ($action eq 'login') { - if ($numheaders == 4) { - $output .= &print_login('page',$dom,$confname,$phase,$settings,\$rowtotal).' + } elsif ($action eq 'usercreation') { + $output .= &print_usercreation('middle',$dom,$settings,\$rowtotal).'
'.&mt($item->{'header'}->[2]->{'col1'}).''.&mt($item->{'header'}->[2]->{'col2'}).'
'.&mt($item->{'header'}->[2]->{'col2'}).'
@@ -741,37 +651,27 @@ 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 == 4) { - $output .= ' - - - '; - } else { - $output .= ' + - - '; - } - $rowtotal ++; - $output .= &print_login('headtag',$dom,$confname,$phase,$settings,\$rowtotal); - } elsif ($action eq 'requestcourses') { - $output .= &print_requestmail($dom,$action,$settings,\$rowtotal); + '. + &print_usermodification('bottom',$dom,$settings,\$rowtotal); $rowtotal ++; - $output .= &print_studentcode($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'}).'
@@ -780,33 +680,31 @@ sub print_config_box { - '. - &textbookcourses_javascript($settings). - &print_textbookcourses($dom,'textbooks',$settings,\$rowtotal).' -
'.&mt($item->{'header'}->[2]->{'col1'}).''.&mt($item->{'header'}->[2]->{'col2'}).'
- - + '.&mt($item->{'header'}->[2]->{'col2'}).' '. + &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal); + $rowtotal ++; + } else { + $output .= &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal); + } + } elsif ($action eq 'requestcourses') { + $output .= &print_requestmail($dom,$action,$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'}).'
@@ -885,15 +783,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 'directorysrch') || - ($action eq 'contacts') || ($action eq 'serverstatuses') || ($action eq 'loadbalancing')) { - $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,\$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 'coursedefaults') { - $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); + } elsif ($action eq 'loadbalancing') { + $output .= &print_loadbalancing($dom,$settings,\$rowtotal); } } $output .= ' @@ -936,7 +843,7 @@ sub print_login { ''. - $lt{'del'}.' '.$lt{'rep'}.''; - } else { - $datatable .= ''.$lt{'none'}.''.$lt{'upl'}; - } - $datatable .='
'; - if ($switchserver) { - $datatable .= &mt('Upload to library server: [_1]',$switchserver); - } else { - $datatable .= ''; - } - $datatable .= ''; - } - $datatable .= ''; } return $datatable; } @@ -1250,7 +1105,6 @@ sub login_choices { &Apache::lonlocal::texthash ( coursecatalog => 'Display Course/Community Catalog link?', adminmail => "Display Administrator's E-mail Address?", - helpdesk => 'Display "Contact Helpdesk" link', disallowlogin => "Login page requests redirected", hostid => "Server", server => "Redirect to:", @@ -1274,9 +1128,6 @@ sub login_choices { link => "Link", alink => "Active link", vlink => "Visited link", - headtag => "Custom markup", - action => "Action", - current => "Current", ); return %choices; } @@ -1291,7 +1142,17 @@ sub print_rolecolors { my %designhash = &Apache::loncommon::get_domainconf($dom); my %defaultdesign = %Apache::loncommon::defaultdesign; my (%is_custom,%designs); - my %defaults = &role_defaults($role,\@bgs,\@links,\@images); + my %defaults = ( + img => $defaultdesign{$role.'.img'}, + font => $defaultdesign{$role.'.font'}, + fontmenu => $defaultdesign{$role.'.fontmenu'}, + ); + foreach my $item (@bgs) { + $defaults{'bgs'}{$item} = $defaultdesign{$role.'.'.$item}; + } + foreach my $item (@links) { + $defaults{'links'}{$item} = $defaultdesign{$role.'.'.$item}; + } if (ref($settings) eq 'HASH') { if (ref($settings->{$role}) eq 'HASH') { if ($settings->{$role}->{'img'} ne '') { @@ -1352,44 +1213,6 @@ sub print_rolecolors { return $datatable; } -sub role_defaults { - my ($role,$bgs,$links,$images,$logintext) = @_; - my %defaults; - unless ((ref($bgs) eq 'ARRAY') && (ref($links) eq 'ARRAY') && (ref($images) eq 'ARRAY')) { - return %defaults; - } - my %defaultdesign = %Apache::loncommon::defaultdesign; - if ($role eq 'login') { - %defaults = ( - font => $defaultdesign{$role.'.font'}, - ); - if (ref($logintext) eq 'ARRAY') { - foreach my $item (@{$logintext}) { - $defaults{'logintext'}{$item} = $defaultdesign{$role.'.'.$item}; - } - } - foreach my $item (@{$images}) { - $defaults{'showlogo'}{$item} = 1; - } - } else { - %defaults = ( - img => $defaultdesign{$role.'.img'}, - font => $defaultdesign{$role.'.font'}, - fontmenu => $defaultdesign{$role.'.fontmenu'}, - ); - } - foreach my $item (@{$bgs}) { - $defaults{'bgs'}{$item} = $defaultdesign{$role.'.'.$item}; - } - foreach my $item (@{$links}) { - $defaults{'links'}{$item} = $defaultdesign{$role.'.'.$item}; - } - foreach my $item (@{$images}) { - $defaults{$item} = $defaultdesign{$role.'.'.$item}; - } - return %defaults; -} - sub display_color_options { my ($dom,$confname,$phase,$role,$itemcount,$choices,$is_custom,$defaults,$designs, $images,$bgs,$links,$alt_text,$rowtotal,$logintext) = @_; @@ -1406,7 +1229,7 @@ sub display_color_options { $datatable .= ''. ' '. + ' value="'.$current_color.'" /> '. ' '; unless ($role eq 'login') { $datatable .= ''. @@ -1416,7 +1239,7 @@ sub display_color_options { } else { $datatable .= ' '; } - $current_color = $designs->{'fontmenu'} ? + $current_color = $designs->{'fontmenu'} ? $designs->{'fontmenu'} : $defaults->{'fontmenu'}; $datatable .= ''. ''. - &mt('Upload:').'
'; + $datatable .= '
'. + &mt('Upload:'); } } else { - $datatable .= ' '. - &mt('Upload:').'
'; + $datatable .= '
'. + &mt('Upload:'); } if ($switchserver) { $datatable .= &mt('Upload to library server: [_1]',$switchserver); @@ -1550,8 +1373,10 @@ sub display_color_options { $datatable .= ''. ''; + foreach my $item (@{$bgs}) { - $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; } @@ -3548,10 +2792,7 @@ sub spares_row { $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; $datatable .= ' '."\n"; my (%current,%canselect); my @choices = &possible_newspares($server,$spareid->{$server},$serverhomes,$altids); @@ -3687,7 +2928,7 @@ sub print_loadbalancing { } my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); - my $rownum = 8; + my $rownum = 6; if (ref($types) eq 'ARRAY') { $rownum += scalar(@{$types}); } @@ -3718,7 +2959,7 @@ sub print_loadbalancing { ''; + ''; my $rem = $i%($numinrow); if ($rem == 0) { if (($i > 0) && ($i < $numspares-1)) { @@ -3801,6 +3041,7 @@ sub print_loadbalancing { '
'.$choices->{$item}; +# my $link = &color_pick($phase,$role,$item,$choices->{$item},$designs->{'bgs'}{$item}); + $datatable .= ''; my $color = $designs->{'bgs'}{$item} ? $designs->{'bgs'}{$item} : $defaults->{'bgs'}{$item}; if ($designs->{'bgs'}{$item}) { $datatable .= ' '; @@ -1578,8 +1403,9 @@ sub display_color_options { $datatable .= ''. ''; foreach my $item (@{$links}) { - my $color = $designs->{'links'}{$item} ? $designs->{'links'}{$item} : $defaults->{'links'}{$item}; - $datatable .= ''; + '" size="5" /> Mb'; } $datatable .= ''; } @@ -1849,16 +1679,12 @@ sub print_quotas { } unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) { $defaultquota = '20'; - $authorquota = '500'; if (ref($settings) eq 'HASH') { if (ref($settings->{'defaultquota'}) eq 'HASH') { $defaultquota = $settings->{'defaultquota'}->{'default'}; } elsif (defined($settings->{'default'})) { $defaultquota = $settings->{'default'}; } - if (ref($settings->{'authorquota'}) eq 'HASH') { - $authorquota = $settings->{'authorquota'}->{'default'}; - } } } $typecount ++; @@ -1969,19 +1795,15 @@ sub print_quotas { } $datatable .= ''; unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) { - $datatable .= ''; + $defaultquota.'" size="5" /> Mb'; } $datatable .= ''; $typecount ++; $css_class = $typecount%2?' class="LC_odd_row"':''; $datatable .= ''. - ''. @@ -2108,293 +1930,85 @@ sub print_quotas { sub print_requestmail { my ($dom,$action,$settings,$rowtotal) = @_; - my ($now,$datatable,%currapp); + my ($now,$datatable,%dompersonnel,@domcoord,@currapproval,$rows); $now = time; + $rows = 0; + %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc'],$now,$now); + foreach my $server (keys(%dompersonnel)) { + foreach my $user (sort(keys(%{$dompersonnel{$server}}))) { + my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,$user); + if (!grep(/^$uname:$udom$/,@domcoord)) { + push(@domcoord,$uname.':'.$udom); + } + } + } if (ref($settings) eq 'HASH') { if (ref($settings->{'notify'}) eq 'HASH') { if ($settings->{'notify'}{'approval'} ne '') { - map {$currapp{$_}=1;} split(/,/,$settings->{'notify'}{'approval'}); + @currapproval = split(',',$settings->{'notify'}{'approval'}); } } } - my $numinrow = 2; - my $css_class; - $css_class = ($$rowtotal%2? ' class="LC_odd_row"':''); + if (@currapproval) { + foreach my $dc (@currapproval) { + unless (grep(/^\Q$dc\E$/,@domcoord)) { + push(@domcoord,$dc); + } + } + } + @domcoord = sort(@domcoord); + my $numinrow = 4; + my $numdc = @domcoord; + my $css_class = 'class="LC_odd_row"'; my $text; if ($action eq 'requestcourses') { $text = &mt('Receive notification of course requests requiring approval'); - } elsif ($action eq 'requestauthor') { - $text = &mt('Receive notification of Authoring Space requests requiring approval'); } else { - $text = &mt('Receive notification of queued requests for self-created user accounts requiring approval'); + $text = &mt('Receive notification of authoring space requests requiring approval') } - $datatable = ''. + $datatable = ''. ' '. ' '; - return $datatable; -} - -sub print_studentcode { - my ($settings,$rowtotal) = @_; - 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}; - } - } - } - $output .= ''. - ''. - ''; - $$rowtotal ++; - return $output; -} - -sub print_textbookcourses { - my ($dom,$type,$settings,$rowtotal) = @_; - my $rownum = 0; - my $css_class; - my $itemcount = 1; - my $maxnum = 0; - my $bookshash; - if (ref($settings) eq 'HASH') { - $bookshash = $settings->{$type}; - } - my %ordered; - if (ref($bookshash) eq 'HASH') { - foreach my $item (keys(%{$bookshash})) { - if (ref($bookshash->{$item}) eq 'HASH') { - my $num = $bookshash->{$item}{'order'}; - $ordered{$num} = $item; - } - } - } - my $confname = $dom.'-domainconfig'; - my $switchserver = &check_switchserver($dom,$confname); - my $maxnum = scalar(keys(%ordered)); - my $datatable; - if (keys(%ordered)) { - my @items = sort { $a <=> $b } keys(%ordered); - for (my $i=0; $i<@items; $i++) { - $css_class = $itemcount%2?' class="LC_odd_row"':''; - my $key = $ordered{$items[$i]}; - my %coursehash=&Apache::lonnet::coursedescription($key); - my $coursetitle = $coursehash{'description'}; - my ($subject,$title,$author,$publisher,$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').''; - } + if (@domcoord > 0) { + $datatable .= '
'.$choices->{$item}."\n"; + my $color = $designs->{'link'}{$item} ? $designs->{'link'}{$item} : $defaults->{'links'}{$item}; + $datatable .= ''."\n"; + if ($designs->{'links'}{$item}) { $datatable.=' '; } @@ -1637,13 +1463,17 @@ sub login_header_options { } sub login_text_colors { - my ($img,$role,$logintext,$phase,$choices,$designs,$defaults) = @_; + my ($img,$role,$logintext,$phase,$choices,$designs) = @_; my $color_menu = ''; foreach my $item (@{$logintext}) { - $color_menu .= ''; + my $link = &color_pick($phase,$role,$item,$choices->{$item},$designs->{'logintext'}{$item}); + $color_menu .= ''. + ''; } $color_menu .= '
'.$choices->{$item}; - my $color = $designs->{'logintext'}{$item} ? $designs->{'logintext'}{$item} : $defaults->{'logintext'}{$item}; - $color_menu .= '
'.$link; + if ($designs->{'logintext'}{$item}) { + $color_menu .= '    '; + } + $color_menu .= '
 

'; return $color_menu; @@ -1675,12 +1505,20 @@ sub image_changes { $role.'_del_'.$img.'" value="1" />'.&mt('Delete?'). ' '.&mt('Replace:').'
'; } else { - $output .= '
'.$logincolors.&mt('Upload:').'
'; + $output .= '
'.$logincolors.&mt('Upload:').'
'; } } return $output; } +sub color_pick { + my ($phase,$role,$item,$desc,$curcol) = @_; + my $link = ''.$desc.''; + return $link; +} + sub print_quotas { my ($dom,$settings,$rowtotal,$action) = @_; my $context; @@ -1689,37 +1527,34 @@ sub print_quotas { } else { $context = $action; } - my ($datatable,$defaultquota,$authorquota,@usertools,@options,%validations); + my ($datatable,$defaultquota,@usertools,@options,%validations); my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); my $typecount = 0; my ($css_class,%titles); if ($context eq 'requestcourses') { - @usertools = ('official','unofficial','community','textbook'); + @usertools = ('official','unofficial','community'); @options =('norequest','approval','validate','autolimit'); %validations = &Apache::lonnet::auto_courserequest_checks($dom); %titles = &courserequest_titles(); } elsif ($context eq 'requestauthor') { @usertools = ('author'); @options = ('norequest','approval','automatic'); - %titles = &authorrequest_titles(); + %titles = &authorrequest_titles(); } else { @usertools = ('aboutme','blog','webdav','portfolio'); %titles = &tool_titles(); } if (ref($types) eq 'ARRAY') { foreach my $type (@{$types}) { - my ($currdefquota,$currauthorquota); + my $currdefquota; unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) { if (ref($settings) eq 'HASH') { if (ref($settings->{defaultquota}) eq 'HASH') { - $currdefquota = $settings->{defaultquota}->{$type}; + $currdefquota = $settings->{defaultquota}->{$type}; } else { $currdefquota = $settings->{$type}; } - if (ref($settings->{authorquota}) eq 'HASH') { - $currauthorquota = $settings->{authorquota}->{$type}; - } } } if (defined($usertypes->{$type})) { @@ -1833,15 +1668,10 @@ sub print_quotas { unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) { $datatable .= - '
'. - ''.&mt('Portfolio').': '. + ''. ''.(' ' x 2). - ''.&mt('Authoring').': '. - '
'. - ''.&mt('Portfolio').': '. + $datatable .= ''. ''.(' ' x2). - ''.&mt('Authoring').': '. - '
'.&mt('LON-CAPA Advanced Users').'
'; + '
'.&mt('LON-CAPA Advanced Users').' '; if ($context eq 'requestcourses') { $datatable .= &mt('(overrides affiliation, if set)'). '
'.$text.''; - my ($numdc,$table,$rows) = &active_dc_picker($dom,$numinrow,'checkbox', - $action.'notifyapproval',%currapp); - if ($numdc > 0) { - $datatable .= $table; - } else { - $datatable .= &mt('There are no active Domain Coordinators'); - } - $datatable .='
'.&mt('Generate unique six character code as course identifier?').''; - foreach my $type (@crstypes) { - my $check = ' '; - if ($current{$type}) { - $check = ' checked="checked" '; - } - $output .= ''.(' 'x2).' '; - } - $output .= '
'; + for (my $i=0; $i<$numdc; $i++) { + my $rem = $i%($numinrow); + if ($rem == 0) { + if ($i > 0) { + $datatable .= ''; } + $datatable .= ''; + $rows ++; } - my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$type".'_'."$key','$type'".');"'; - $datatable .= ''. - ''."\n"; - $itemcount ++; - } - } - $css_class = $itemcount%2?' class="LC_odd_row"':''; - my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$type"."_addbook_pos','$type'".');"'; - $datatable .= ''."\n". - ''."\n". - ''."\n"; - $itemcount ++; - return $datatable; -} - -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"; - } - return <<"ENDSCRIPT"; - - -ENDSCRIPT + $datatable .=''; + $$rowtotal += $rows; + return $datatable; } sub print_autoenroll { @@ -2545,7 +2159,8 @@ sub print_autoupdate { sub print_autocreate { my ($dom,$settings,$rowtotal) = @_; - my (%createon,%createoff,%currhash); + my (%createon,%createoff); + my $curr_dc; my @types = ('xml','req'); if (ref($settings) eq 'HASH') { foreach my $item (@types) { @@ -2558,9 +2173,7 @@ sub print_autocreate { } } } - if ($settings->{'xmldc'} ne '') { - $currhash{$settings->{'xmldc'}} = 1; - } + $curr_dc = $settings->{'xmldc'}; } else { foreach my $item (@types) { $createoff{$item} = ' checked="checked" '; @@ -2568,7 +2181,6 @@ sub print_autocreate { } } $$rowtotal += 2; - my $numinrow = 2; my $datatable=''. ''. ''; + $$rowtotal ++ ; } else { - $datatable .= &mt('Course creation processed as:'). - ''; } - $datatable .= $dctable.''; - $$rowtotal += $rows; return $datatable; } @@ -2717,7 +2326,7 @@ sub print_contacts { my @contacts = ('adminemail','supportemail'); my (%checked,%to,%otheremails,%bccemails); my @mailings = ('errormail','packagesmail','lonstatusmail','helpdeskmail', - 'requestsmail','updatesmail','idconflictsmail'); + 'requestsmail'); foreach my $type (@mailings) { $otheremails{$type} = ''; } @@ -2753,22 +2362,21 @@ sub print_contacts { $checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" '; $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" '; $checked{'requestsmail'}{'adminemail'} = ' checked="checked" '; - $checked{'updatesmail'}{'adminemail'} = ' checked="checked" '; - $checked{'idconflictsmail'}{'adminemail'} = ' checked="checked" '; } my ($titles,$short_titles) = &contact_titles(); my $rownum = 0; my $css_class; foreach my $item (@contacts) { + $rownum ++; $css_class = $rownum%2?' class="LC_odd_row"':''; $datatable .= ''. ''; - $rownum ++; } foreach my $type (@mailings) { + $rownum ++; $css_class = $rownum%2?' class="LC_odd_row"':''; $datatable .= ''. ''."\n"; - $rownum ++; } - my %choices; - $choices{'reporterrors'} = &mt('E-mail error reports to [_1]', - &Apache::loncommon::modal_link('http://loncapa.org/core.html', - &mt('LON-CAPA core group - MSU'),600,500)); - $choices{'reportupdates'} = &mt('E-mail record of completed LON-CAPA updates to [_1]', - &Apache::loncommon::modal_link('http://loncapa.org/core.html', - &mt('LON-CAPA core group - MSU'),600,500)); - my @toggles = ('reporterrors','reportupdates'); - my %defaultchecked = ('reporterrors' => 'on', - 'reportupdates' => 'on'); - (my $reports,$rownum) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, - \%choices,$rownum); - $datatable .= $reports; $$rowtotal += $rownum; return $datatable; } @@ -2827,8 +2421,7 @@ sub print_helpsettings { } sub radiobutton_prefs { - my ($settings,$toggles,$defaultchecked,$choices,$itemcount,$onclick, - $additional,$align) = @_; + my ($settings,$toggles,$defaultchecked,$choices,$itemcount) = @_; return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') && (ref($choices) eq 'HASH')); @@ -2854,28 +2447,17 @@ sub radiobutton_prefs { } } } - if ($onclick) { - $onclick = ' onclick="'.$onclick.'"'; - } foreach my $item (@{$toggles}) { $css_class = $itemcount%2?' class="LC_odd_row"':''; $datatable .= - ''; - if ($align eq 'left') { - $datatable .= ''. + ''. + $checkedoff{$item}.' value="0" />'.&mt('No').''. + ''. ''; $itemcount ++; } @@ -2884,379 +2466,41 @@ sub radiobutton_prefs { sub print_coursedefaults { my ($position,$dom,$settings,$rowtotal) = @_; - my ($css_class,$datatable,%checkedon,%checkedoff,%defaultchecked,@toggles); + my ($css_class,$datatable); my $itemcount = 1; - my %choices = &Apache::lonlocal::texthash ( - 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)', - postsubmit => 'Disable submit button/keypress following student submission', - ); - my %staticdefaults = ( - anonsurvey_threshold => 10, - uploadquota => 500, - postsubmit => 60, - ); if ($position eq 'top') { - %defaultchecked = ( - 'uselcmath' => 'on', - 'usejsme' => 'on', - ); - @toggles = ('uselcmath','usejsme'); + my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles); + %choices = + &Apache::lonlocal::texthash ( + canuse_pdfforms => 'Course/Community users can create/upload PDF forms', + ); + %defaultchecked = ('canuse_pdfforms' => 'off'); + @toggles = ('canuse_pdfforms',); ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, - \%choices,$itemcount); + \%choices,$itemcount); + $$rowtotal += $itemcount; } else { $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - my ($currdefresponder,%defcredits,%curruploadquota,%deftimeout); - my $currusecredits = 0; - my $postsubmitclient = 1; - my @types = ('official','unofficial','community','textbook'); + my %choices = + &Apache::lonlocal::texthash ( + anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys', + ); + my $currdefresponder; if (ref($settings) eq 'HASH') { $currdefresponder = $settings->{'anonsurvey_threshold'}; - if (ref($settings->{'uploadquota'}) eq 'HASH') { - foreach my $type (keys(%{$settings->{'uploadquota'}})) { - $curruploadquota{$type} = $settings->{'uploadquota'}{$type}; - } - } - if (ref($settings->{'coursecredits'}) eq 'HASH') { - foreach my $type (@types) { - next if ($type eq 'community'); - $defcredits{$type} = $settings->{'coursecredits'}->{$type}; - if ($defcredits{$type} 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 (!$currdefresponder) { - $currdefresponder = $staticdefaults{'anonsurvey_threshold'}; + $currdefresponder = 10; } elsif ($currdefresponder < 1) { $currdefresponder = 1; } - foreach my $type (@types) { - if ($curruploadquota{$type} eq '') { - $curruploadquota{$type} = $staticdefaults{'uploadquota'}; - } - } $datatable .= - ''. ''."\n"; - $itemcount ++; - $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable .= ''. - ''."\n"; - $itemcount ++; - my $onclick = "toggleDisplay(this.form,'credits');"; - my $display = 'none'; - if ($currusecredits) { - $display = 'block'; - } - my $additional = '
'. - ''.&mt('Default credits').'
' - .''.(' 'x2). - ''. - ''.&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 .= ''; - } - } - $datatable .= ' '. - ''.&mt('LON-CAPA course:').' '. - $coursetitle.'
'."\n". - ''."\n". - ' '."\n". - ''.&mt('Add').''. - ''.&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". - ''.&mt('LON-CAPA course:').' '. - &Apache::loncommon::select_dom_form($env{'request.role.domain'},$type.'_addbook_cdom'). - ''. - &Apache::loncommon::selectcourse_link - ('display',$type.'_addbook_cnum',$type.'_addbook_cdom',undef,undef,undef,'Course'); - '
'.&mt('Create pending official courses from XML files').' '. ''; - my ($numdc,$dctable,$rows) = &active_dc_picker($dom,$numinrow,'radio', - 'autocreate_xmldc',%currhash); - $datatable .= '
'; + my ($numdc,$dctable) = &active_dc_picker($dom,$curr_dc); if ($numdc > 1) { - $datatable .= &mt('Course creation processed as: (choose Dom. Coord.)'). - ''; + $datatable .= '
'. + &mt('Course creation processed as: (choose Dom. Coord.)'). + ''.$dctable.'
'; + $datatable .= $dctable.'
'.$titles->{$item}. ''. '
'. @@ -2791,21 +2399,7 @@ sub print_contacts { 'value="'.$bccemails{$type}.'" />'; } $datatable .= '
'. - ''.$choices->{$item}. - ''; - } else { - $datatable .= ''; - } - $datatable .= - ''. + ''.$choices->{$item}. + ''. ' '. - ''.$additional. - '
'. - $choices{'anonsurvey_threshold'}. + ''.$choices{'anonsurvey_threshold'}. ''. ''. - '
'. - $choices{'uploadquota'}. - ''. - ''; - foreach my $type (@types) { - $datatable .= ''; - } - $datatable .= '
'.&mt($type).'
'. - '
'; - foreach my $type (@types) { - next if ($type eq 'community'); - $additional .= ''; - } - $additional .= '
'.&mt($type).'
'. - '
'."\n"; - %defaultchecked = ('coursecredits' => 'off'); - @toggles = ('coursecredits'); - my $current = { - 'coursecredits' => $currusecredits, - }; - (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').'
'; - foreach my $type (@types) { - $additional .= ''; - } - $additional .= '
'.&mt($type).'
'. - '
'."\n"; - %defaultchecked = ('postsubmit' => 'on'); - @toggles = ('postsubmit'); - my $current = { - 'postsubmit' => $postsubmitclient, - }; - ($table,$itemcount) = - &radiobutton_prefs($current,\@toggles,\%defaultchecked, - \%choices,$itemcount,$onclick,$additional,'left'); - $datatable .= $table; - } - $$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 .= ''. - '
'.$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.'
- '. - &mt('[_1] when busy, offloads to:' - ,''.$server.''). - "\n"; + '.$server.' when busy, offloads to:'. '

'; if ($lonhost eq '') { - $datatable .= ''; + $datatable .= ''; if (keys(%currbalancer) > 0) { $datatable .= &mt('Add balancer:'); } else { @@ -3734,7 +2975,7 @@ sub print_loadbalancing { next if ($currbalancer{$server}); $datatable .= ''."\n"; } - $datatable .= + $datatable .= ''."\n". ' '."\n"; } else { @@ -3773,11 +3014,10 @@ sub print_loadbalancing { if (exists($currbalancer{$spares[$i]})) { $disabled = ' disabled="disabled"'; } - $targettable .= - '

'.$targettable.'

'; } } + my $cssidx = $balnum%2; $datatable .= ''. &loadbalancing_rules($dom,$intdom,$currrules{$lonhost}, $othertitle,$usertypes,$types,\%servers, @@ -3858,7 +3099,7 @@ sub loadbalancing_rules { $css_class,$balnum,$islast) = @_; my $output; my $num = 0; - my ($alltypes,$othertypes,$titles) = + my ($alltypes,$othertypes,$titles) = &loadbalancing_titles($dom,$intdom,$usertypes,$types); if ((ref($alltypes) eq 'ARRAY') && (ref($titles) eq 'HASH')) { foreach my $type (@{$alltypes}) { @@ -3888,10 +3129,8 @@ sub loadbalancing_titles { '_LC_author' => &mt('Users from [_1] with author role',$dom), '_LC_internetdom' => &mt('Users not from [_1], but from [_2]',$dom,$intdom), '_LC_external' => &mt('Users not from [_1]',$intdom), - '_LC_ipchangesso' => &mt('SSO users from [_1], with IP mismatch',$dom), - '_LC_ipchange' => &mt('Non-SSO users with IP mismatch'), ); - my @alltypes = ('_LC_adv','_LC_author','_LC_internetdom','_LC_external','_LC_ipchangesso','_LC_ipchange'); + my @alltypes = ('_LC_adv','_LC_author','_LC_internetdom','_LC_external'); if (ref($types) eq 'ARRAY') { unshift(@alltypes,@{$types},'default'); } @@ -3916,19 +3155,14 @@ sub loadbalancing_titles { sub loadbalance_rule_row { my ($type,$title,$current,$servers,$currbalancer,$lonhost,$dom, $targets_div_style,$homedom_div_style,$css_class,$balnum,$num,$islast) = @_; - my @rulenames; + my @rulenames = ('default','homeserver'); my %ruletitles = &offloadtype_text(); - if (($type eq '_LC_ipchangesso') || ($type eq '_LC_ipchange')) { - @rulenames = ('balancer','offloadedto','specific'); + if ($type eq '_LC_external') { + push(@rulenames,'externalbalancer'); } else { - @rulenames = ('default','homeserver'); - if ($type eq '_LC_external') { - push(@rulenames,'externalbalancer'); - } else { - push(@rulenames,'specific'); - } - push(@rulenames,'none'); + push(@rulenames,'specific'); } + push(@rulenames,'none'); my $style = $targets_div_style; if (($type eq '_LC_external') || ($type eq '_LC_internetdom')) { $style = $homedom_div_style; @@ -3937,7 +3171,7 @@ sub loadbalance_rule_row { if ($islast && $num == 1) { $space = '
 
'; } - my $output = + my $output = ''.$space. '
'.$title.'
'."\n". ''.$space. @@ -3957,7 +3191,7 @@ sub loadbalance_rule_row { unless ($checked) { $default = ' selected="selected"'; } - $extra = + $extra = ':  '; - 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; @@ -4000,9 +3229,6 @@ sub offloadtype_text { 'externalbalancer' => "Offloads to Load Balancer in user's domain", 'specific' => 'Offloads to specific server', 'none' => 'No offload', - 'balancer' => 'Session hosted on Load Balancer, after re-authentication', - 'offloadedto' => 'Session hosted on offload server, after re-authentication', - 'particular' => 'Session hosted (after re-auth) on server:', ); return %ruletitles; } @@ -4024,8 +3250,6 @@ sub contact_titles { 'helpdeskmail' => 'Helpdesk requests to be e-mailed to', 'lonstatusmail' => 'E-mail from nightly status check (warnings/errors)', 'requestsmail' => 'E-mail from course requests requiring approval', - 'updatesmail' => 'E-mail from nightly check of LON-CAPA module integrity/updates', - 'idconflictsmail' => 'E-mail from bi-nightly check for multiple users sharing same student/employee ID', ); my %short_titles = &Apache::lonlocal::texthash ( adminemail => 'Admin E-mail address', @@ -4043,7 +3267,6 @@ sub tool_titles { official => 'Official courses (with institutional codes)', unofficial => 'Unofficial courses', community => 'Communities', - textbook => 'Textbook courses', ); return %titles; } @@ -4053,7 +3276,6 @@ sub courserequest_titles { official => 'Official', unofficial => 'Unofficial', community => 'Communities', - textbook => 'Textbook', norequest => 'Not allowed', approval => 'Approval by Dom. Coord.', validate => 'With validation', @@ -4070,12 +3292,12 @@ sub authorrequest_titles { automatic => 'Automatic approval', ); return %titles; -} +} sub courserequest_conditions { my %conditions = &Apache::lonlocal::texthash ( approval => '(Processing of request subject to approval by Domain Coordinator).', - validate => '(Processing of request subject to institutional validation).', + validate => '(Processing of request subject to instittutional validation).', ); return %conditions; } @@ -4106,22 +3328,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'}})) { @@ -4133,8 +3375,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) { @@ -4145,18 +3389,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 .= '