--- loncom/interface/domainprefs.pm 2009/02/09 03:42:03 1.87
+++ loncom/interface/domainprefs.pm 2009/08/08 00:36:00 1.101
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.87 2009/02/09 03:42:03 raeburn Exp $
+# $Id: domainprefs.pm,v 1.101 2009/08/08 00:36:00 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -28,6 +28,131 @@
###############################################################
##############################################################
+=pod
+
+=head1 NAME
+
+Apache::domainprefs.pm
+
+=head1 SYNOPSIS
+
+Handles configuration of a LON-CAPA domain.
+
+This is part of the LearningOnline Network with CAPA project
+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 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.
+
+LON-CAPA provides a mechanism to display and modify these defaults, as well as a
+host of other domain-wide settings which determine the types of functionality
+available to users and courses in the domain.
+
+There is also a mechanism to configure cataloging of courses in the domain, and
+controls on the operation of automated processes which govern such things as
+roster updates, user directory updates and processing of course requests.
+
+The domain coordination manual which is built dynamically on install/update of
+LON-CAPA from the relevant help items provides more information about domain
+configuration.
+
+Most of the domain settings are stored in the configuration.db GDBM file which is
+housed on the primary library server for the domain in /home/httpd/lonUsers/$dom,
+where $dom is the domain. The configuration.db stores settings in a number of
+frozen hashes of hashes. In a few cases, domain information must be uploaded to
+the domain as files (e.g., image files for logos etc., or plain text files for
+bubblesheet formats). In this case the domainprefs.pm must be running in a user
+session hosted on the primary library server in the domain, as these files are
+stored in author space belonging to a special $dom-domainconfig user.
+
+domainprefs.pm in combination with lonconfigsettings.pm will retrieve and display
+the current settings, and provides an interface to make modifications.
+
+=head1 SUBROUTINES
+
+=over
+
+=item print_quotas()
+
+Inputs: 4
+
+$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 (either quotas
+or requestcourses).
+
+The print_quotas routine was orginally created to display/store information
+about default quota sizes for portfolio spaces for the different types of
+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.
+
+Outputs: 1
+
+$datatable - HTML containing form elements which allow settings to be changed.
+
+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 and community). In each case the radio buttons allow the
+selection of one of four values:
+
+0, approve, validate, autolimit=N (where N is blank, or a positive integer).
+which have the following effects:
+
+0
+
+=over
+
+- course requests are not allowed for this course types/affiliation
+
+=back
+
+approve
+
+=over
+
+- course requests must be approved by a Doman Coordinator in the
+course's domain
+
+=back
+
+validate
+
+=over
+
+- an institutional validation (e.g., check requestor is instructor
+of record) needs to be passed before the course will be created. The required
+validation is in localenroll.pm on the primary library server for the course
+domain.
+
+=back
+
+autolimit
+
+=over
+
+- course requests will be processed autoatically up to a limit of
+N requests for the course type for the particular requestor.
+If N is undefined, there is no limit to the number of course requests
+which a course owner may submit and have processed automatically.
+
+=back
+
+=item modify_quotas()
+
+=back
+
+=cut
+
package Apache::domainprefs;
use strict;
@@ -37,6 +162,7 @@ use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::lonlocal;
use Apache::lonmsg();
+use Apache::lonconfigsettings;
use LONCAPA qw(:DEFAULT :match);
use LONCAPA::Enrollment;
use LONCAPA::lonauthcgi();
@@ -53,6 +179,7 @@ sub handler {
return OK;
}
+ my $context = 'domain';
my $dom = $env{'request.role.domain'};
my $domdesc = &Apache::lonnet::domain($dom,'description');
if (&Apache::lonnet::allowed('mau',$dom)) {
@@ -106,7 +233,7 @@ sub handler {
col2 => 'Value'}],
},
'quotas' =>
- { text => 'User blogs, home pages and portfolios',
+ { text => 'User blogs, personal information pages and portfolios',
help => 'Domain_Configuration_Quotas',
header => [{col1 => 'User affiliation',
col2 => 'Available tools',
@@ -160,7 +287,7 @@ sub handler {
col2 => 'Information settable when self-creating account (if directory data blank)'}],
},
'scantron' =>
- { text => 'Scantron format file',
+ { text => 'Bubblesheet format file',
help => 'Domain_Configuration_Scantron_Format',
header => [ {col1 => 'Item',
col2 => '',
@@ -170,7 +297,7 @@ sub handler {
{text => 'Request creation of courses',
help => 'Domain_Configuration_Request_Courses',
header => [{col1 => 'User affiliation',
- col2 => 'Requestable course types',}],
+ col2 => 'Availability/Processing of requests',}],
},
'coursecategories' =>
{ text => 'Cataloging of courses',
@@ -197,98 +324,10 @@ sub handler {
text=>"Pick functionality"});
my $confname = $dom.'-domainconfig';
if ($phase eq 'process') {
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"javascript:changePage(document.$phase,'display')",
- text=>"Domain Configuration"},
- {href=>"javascript:changePage(document.$phase,'$phase')",
- text=>"Updated"});
- &print_header($r,$phase);
- foreach my $item (@prefs_order) {
- if (grep(/^\Q$item\E$/,@actions)) {
- $r->print('
';
}
my $defcheck = ' ';
- if (ref($settings->{'cansearch'}) eq 'ARRAY') {
- if (grep(/^default$/,@{$settings->{'cansearch'}})) {
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{$context}) eq 'ARRAY') {
+ if (grep(/^default$/,@{$settings->{$context}})) {
+ $defcheck = ' checked="checked" ';
+ }
+ } elsif ($context eq 'statustocreate') {
$defcheck = ' checked="checked" ';
}
}
$output .= '
'.
'
';
@@ -2933,6 +3054,7 @@ sub color_font_choices {
links => "Link colors",
images => "Images",
font => "Font color",
+ fontmenu => "Font Menu",
pgbg => "Page",
tabbg => "Header",
sidebg => "Border",
@@ -2999,6 +3121,7 @@ sub modify_colors {
@bgs = ('pgbg','tabbg','sidebg');
}
$confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
+ $confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'};
foreach my $item (@bgs,@links,@logintext) {
$confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
}
@@ -3112,6 +3235,15 @@ sub modify_colors {
$changes{$role}{'font'} = 1;
}
}
+ if ($domconfig->{$role}{'fontmenu'} ne '') {
+ if ($confhash->{$role}{'fontmenu'} ne $domconfig->{$role}{'fontmenu'}) {
+ $changes{$role}{'fontmenu'} = 1;
+ }
+ } else {
+ if ($confhash->{$role}{'fontmenu'}) {
+ $changes{$role}{'fontmenu'} = 1;
+ }
+ }
foreach my $item (@bgs) {
if ($domconfig->{$role}{$item} ne '') {
if ($confhash->{$role}{$item} ne $domconfig->{$role}{$item}) {
@@ -3541,44 +3673,46 @@ sub check_switchserver {
return $switchserver;
}
-sub javascript_set_colnums {
- return < 1100) {
- document.pickactions.numcols[1].checked = true;
- } else {
- document.pickactions.numcols[0].checked = true;
- }
-}
-END
-}
-
sub modify_quotas {
my ($dom,$action,%domconfig) = @_;
- my ($context,@usertools);
+ my ($context,@usertools,@options,%validations,%titles,%confhash,%toolshash,
+ %limithash,$toolregexp,%conditions,$resulttext,%changes);
if ($action eq 'quotas') {
$context = 'tools';
} else {
$context = $action;
}
if ($context eq 'requestcourses') {
- @usertools = ('official','unofficial');
+ @usertools = ('official','unofficial','community');
+ @options =('norequest','approve','autolimit','validate');
+ %validations = &Apache::lonnet::auto_courserequest_checks($dom);
+ %titles = &courserequest_titles();
+ $toolregexp = join('|',@usertools);
+ %conditions = &courserequest_conditions();
} else {
@usertools = ('aboutme','blog','portfolio');
+ %titles = &tool_titles();
}
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
- my ($resulttext,%changes);
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
- my %titles = &tool_titles();
- my (%confhash,%toolshash);
foreach my $key (keys(%env)) {
- unless ($context eq 'requestcourses') {
+ if ($context eq 'requestcourses') {
+ if ($key =~ /^form\.crsreq_($toolregexp)_(.+)$/) {
+ my $item = $1;
+ my $type = $2;
+ if ($type =~ /^limit_(.+)/) {
+ $limithash{$item}{$1} = $env{$key};
+ } else {
+ $confhash{$item}{$type} = $env{$key};
+ }
+ }
+ } else {
if ($key =~ /^form\.quota_(.+)$/) {
$confhash{'defaultquota'}{$1} = $env{$key};
}
- }
- if ($key =~ /^form\.\Q$context\E_(.+)$/) {
- @{$toolshash{$1}} = &Apache::loncommon::get_env_multiple($key);
+ if ($key =~ /^form\.\Q$context\E_(.+)$/) {
+ @{$toolshash{$1}} = &Apache::loncommon::get_env_multiple($key);
+ }
}
}
unless ($context eq 'requestcourses') {
@@ -3586,10 +3720,19 @@ sub modify_quotas {
}
foreach my $item (@usertools) {
foreach my $type (@{$types},'default','_LC_adv') {
- if (grep(/^\Q$type\E$/,@{$toolshash{$item}})) {
- $confhash{$item}{$type} = 1;
+ if ($context eq 'requestcourses') {
+ if ($confhash{$item}{$type} eq 'autolimit') {
+ $confhash{$item}{$type} .= '=';
+ unless ($limithash{$item}{$type} =~ /\D/) {
+ $confhash{$item}{$type} .= $limithash{$item}{$type};
+ }
+ }
} else {
- $confhash{$item}{$type} = 0;
+ if (grep(/^\Q$type\E$/,@{$toolshash{$item}})) {
+ $confhash{$item}{$type} = 1;
+ } else {
+ $confhash{$item}{$type} = 0;
+ }
}
if (ref($domconfig{$action}) eq 'HASH') {
if (ref($domconfig{$action}{$item}) eq 'HASH') {
@@ -3598,7 +3741,7 @@ sub modify_quotas {
}
} else {
if ($context eq 'requestcourses') {
- if ($confhash{$item}{$type}) {
+ if ($confhash{$item}{$type} ne 'norequest') {
$changes{$item}{$type} = 1;
}
} else {
@@ -3609,7 +3752,7 @@ sub modify_quotas {
}
} else {
if ($context eq 'requestcourses') {
- if ($confhash{$item}{$type}) {
+ if ($confhash{$item}{$type} eq 'norequest') {
$changes{$item}{$type} = 1;
}
} else {
@@ -3701,8 +3844,8 @@ sub modify_quotas {
$env{'user.domain'},
$item,'reload',$context);
if ($context eq 'requestcourses') {
- if ($env{'environment.canrequest.'.$item} ne $newacc) {
- $newenv{'environment.canrequest.'.$item} = $newacc;
+ if ($env{'environment.crsrequest.'.$item} ne $newacc) {
+ $newenv{'environment.crsrequest.'.$item} = $newacc;
}
} else {
if ($env{'environment.availabletools.'.$item} ne $newacc) {
@@ -3719,7 +3862,21 @@ sub modify_quotas {
$typetitle = 'LON-CAPA Advanced Users';
}
if ($confhash{$item}{$type}) {
- $resulttext .= '
'.&mt('Set to be available to [_1]',$typetitle).'
';
+ if ($context eq 'requestcourses') {
+ my $cond;
+ if ($confhash{$item}{$type} =~ /^autolimit=(\d*)$/) {
+ if ($1 eq '') {
+ $cond = &mt('(Automatic processing of any request).');
+ } else {
+ $cond = &mt('(Automatic processing of requests up to limit of [quant,_1,request] per user).',$1);
+ }
+ } else {
+ $cond = $conditions{$confhash{$item}{$type}};
+ }
+ $resulttext .= '
'.&mt('Set to be available to [_1].',$typetitle).' '.$cond.'
';
+ } else {
+ $resulttext .= '
'.&mt('Set to be available to [_1]',$typetitle).'
';
+ }
} else {
$resulttext .= '
'.&mt('Set to be unavailable to [_1]',$typetitle).'
';
}
@@ -3736,7 +3893,7 @@ sub modify_quotas {
if ($context eq 'requestcourses') {
$resulttext = &mt('No changes made to rights to request creation of courses.');
} else {
- $resulttext = &mt('No changes made to availability of home pages, blogs, portfolios or default quotas');
+ $resulttext = &mt('No changes made to availability of personal information pages, blogs, portfolios or default quotas');
}
}
} else {
@@ -4120,7 +4277,7 @@ sub modify_contacts {
}
my (%others,%to);
my @contacts = ('supportemail','adminemail');
- my @mailings = ('errormail','packagesmail','helpdeskmail');
+ my @mailings = ('errormail','packagesmail','helpdeskmail','lonstatusmail');
foreach my $type (@mailings) {
@{$newsetting{$type}} =
&Apache::loncommon::get_env_multiple('form.'.$type);
@@ -4165,6 +4322,7 @@ sub modify_contacts {
$default{'errormail'} = 'adminemail';
$default{'packagesmail'} = 'adminemail';
$default{'helpdeskmail'} = 'supportemail';
+ $default{'lonstatusmail'} = 'adminemail';
foreach my $item (@contacts) {
if ($to{$item} ne $default{$item}) {
$changes{$item} = 1;
@@ -4231,7 +4389,7 @@ sub modify_usercreation {
my @username_rule = &Apache::loncommon::get_env_multiple('form.username_rule');
my @id_rule = &Apache::loncommon::get_env_multiple('form.id_rule');
my @email_rule = &Apache::loncommon::get_env_multiple('form.email_rule');
- my @contexts = ('author','course','selfcreate');
+ my @contexts = ('author','course','requestcrs','selfcreate');
foreach my $item(@contexts) {
if ($item eq 'selfcreate') {
@{$cancreate{$item}} = &Apache::loncommon::get_env_multiple('form.can_createuser_'.$item);
@@ -4247,10 +4405,19 @@ sub modify_usercreation {
$cancreate{$item} = $env{'form.can_createuser_'.$item};
}
}
+ my ($othertitle,$usertypes,$types) =
+ &Apache::loncommon::sorted_inst_types($dom);
+ if (ref($types) eq 'ARRAY') {
+ if (@{$types} > 0) {
+ @{$cancreate{'statustocreate'}} =
+ &Apache::loncommon::get_env_multiple('form.statustocreate');
+ }
+ push(@contexts,'statustocreate');
+ }
if (ref($curr_usercreation{'cancreate'}) eq 'HASH') {
foreach my $item (@contexts) {
- if ($item eq 'selfcreate') {
- if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') {
+ if (($item eq 'selfcreate') || ($item eq 'statustocreate')) {
+ if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') {
foreach my $curr (@{$curr_usercreation{'cancreate'}{$item}}) {
if (!grep(/^$curr$/,@{$cancreate{$item}})) {
if (!grep(/^$item$/,@{$changes{'cancreate'}})) {
@@ -4426,16 +4593,65 @@ sub modify_usercreation {
if (ref($changes{'cancreate'}) eq 'ARRAY') {
my %lt = &usercreation_types();
foreach my $type (@{$changes{'cancreate'}}) {
- my $chgtext = $lt{$type}.', ';
+ my $chgtext;
+ unless ($type eq 'statustocreate') {
+ $chgtext = $lt{$type}.', ';
+ }
if ($type eq 'selfcreate') {
if (@{$cancreate{$type}} == 0) {
$chgtext .= &mt('creation of a new user account is not permitted.');
} else {
- $chgtext .= &mt('creation of a new account is permitted for:
');
+ $chgtext .= &mt('creation of a new account is permitted for:').'
';
foreach my $case (@{$cancreate{$type}}) {
$chgtext .= '
'.$selfcreatetypes{$case}.'
';
}
$chgtext .= '
';
+ if (ref($cancreate{$type}) eq 'ARRAY') {
+ if (grep(/^(login|sso)$/,@{$cancreate{$type}})) {
+ if (ref($cancreate{'statustocreate'}) eq 'ARRAY') {
+ if (@{$cancreate{'statustocreate'}} == 0) {
+ $chgtext .= ' '.&mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts.").'';
+ }
+ }
+ }
+ }
+ }
+ } elsif ($type eq 'statustocreate') {
+ if ((ref($cancreate{'selfcreate'}) eq 'ARRAY') &&
+ (ref($cancreate{'statustocreate'}) eq 'ARRAY')) {
+ if (@{$cancreate{'selfcreate'}} > 0) {
+ if (@{$cancreate{'statustocreate'}} == 0) {
+
+ $chgtext .= &mt("Institutional affiliations permitted to create accounts set to 'None'.");
+ if (!grep(/^email$/,@{$cancreate{'selfcreate'}})) {
+ $chgtext .= ' '.&mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts.").'';
+ }
+ } elsif (ref($usertypes) eq 'HASH') {
+ if (grep(/^(login|sso)$/,@{$cancreate{'selfcreate'}})) {
+ $chgtext .= &mt('Creation of a new account for an institutional user is restricted to the following institutional affiliation(s):');
+ } else {
+ $chgtext .= &mt('Institutional affiliations permitted to create accounts with institutional authentication were set as follows:');
+ }
+ $chgtext .= '
';
+ foreach my $case (@{$cancreate{$type}}) {
+ if ($case eq 'default') {
+ $chgtext .= '
'.$othertitle.'
';
+ } else {
+ $chgtext .= '
'.$usertypes->{$case}.'
';
+ }
+ }
+ $chgtext .= '
';
+ if (!grep(/^(login|sso)$/,@{$cancreate{'selfcreate'}})) {
+ $chgtext .= ' '.&mt('However, users authenticated by institutional login/single sign on are not currently permitted to create accounts.').'';
+ }
+ }
+ } else {
+ if (@{$cancreate{$type}} == 0) {
+ $chgtext .= &mt("Institutional affiliations permitted to create accounts were set to 'none'.");
+ } else {
+ $chgtext .= &mt('Although institutional affiliations permitted to create accounts were changed, self creation of accounts is not currently permitted for any authentication types.');
+ }
+ }
}
} else {
if ($cancreate{$type} eq 'none') {