--- loncom/interface/domainprefs.pm 2013/05/11 22:08:27 1.160.6.18
+++ loncom/interface/domainprefs.pm 2012/10/30 10:39:02 1.174
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.160.6.18 2013/05/11 22:08:27 raeburn Exp $
+# $Id: domainprefs.pm,v 1.174 2012/10/30 10:39:02 foxr 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
@@ -210,13 +210,15 @@ sub handler {
'quotas','autoenroll','autoupdate','autocreate',
'directorysrch','usercreation','usermodification',
'contacts','defaults','scantron','coursecategories',
- 'serverstatuses','requestcourses','coursedefaults',
- 'usersessions','loadbalancing','requestauthor'],$dom);
+ 'serverstatuses','requestcourses','helpsettings',
+ 'coursedefaults','usersessions','loadbalancing',
+ 'requestauthor'],$dom);
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
'autoupdate','autocreate','directorysrch','contacts',
'usercreation','usermodification','scantron',
'requestcourses','requestauthor','coursecategories',
- 'serverstatuses','coursedefaults','usersessions');
+ 'serverstatuses','helpsettings',
+ 'coursedefaults','usersessions');
my %existing;
if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
%existing = %{$domconfig{'loadbalancing'}};
@@ -353,12 +355,26 @@ sub handler {
col3 => 'Specific IPs',
}],
},
- 'coursedefaults' =>
+ 'helpsettings' =>
+ {text => 'Help page settings',
+ help => 'Domain_Configuration_Help_Settings',
+ header => [{col1 => 'Help Settings (logged-in users)',
+ col2 => 'Value'}],
+ },
+ 'coursedefaults' =>
{text => 'Course/Community defaults',
help => 'Domain_Configuration_Course_Defaults',
- header => [{col1 => 'Defaults which can be overridden for each course by a DC',
+ header => [{col1 => 'Defaults which can be overridden in each course by a CC',
+ col2 => 'Value',},
+ {col1 => 'Defaults which can be overridden for each course by a DC',
col2 => 'Value',},],
},
+ 'privacy' =>
+ {text => 'User Privacy',
+ help => 'Domain_Configuration_User_Privacy',
+ header => [{col1 => 'Setting',
+ col2 => 'Value',}],
+ },
'usersessions' =>
{text => 'User session hosting/offloading',
help => 'Domain_Configuration_User_Sessions',
@@ -370,11 +386,11 @@ sub handler {
col2 => 'Rules'}],
},
'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'},
],
},
@@ -391,6 +407,8 @@ sub handler {
};
}
+
+
my @roles = ('student','coordinator','author','admin');
my @actions = &Apache::loncommon::get_env_multiple('form.actions');
&Apache::lonhtmlcommon::add_breadcrumb
@@ -401,8 +419,7 @@ sub handler {
if ($phase eq 'process') {
&Apache::lonconfigsettings::make_changes($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,\@roles);
} elsif ($phase eq 'display') {
- my $js = &recaptcha_js().
- &credits_js();
+ my $js = &recaptcha_js();
if ((keys(%servers) > 1) || (keys(%existing) > 0)) {
my ($othertitle,$usertypes,$types) =
&Apache::loncommon::sorted_inst_types($dom);
@@ -414,34 +431,6 @@ sub handler {
}
&Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,$js);
} else {
-# check if domconfig user exists for the domain.
- my $servadm = $r->dir_config('lonAdmEMail');
- my ($configuserok,$author_ok,$switchserver) =
- &config_check($dom,$confname,$servadm);
- unless ($configuserok eq 'ok') {
- &Apache::lonconfigsettings::print_header($r,$phase,$context);
- $r->print(&mt('The domain configuration user "[_1]" has yet to be created.',
- $confname).
- ' '
- );
- if ($switchserver) {
- $r->print(&mt('Ordinarily, that domain configuration user is created when the ./UPDATE script is run to install LON-CAPA for the first time.').
- ' '.
- &mt('However, that does not apply when new domains are added to a multi-domain server, and ./UPDATE has not been run recently.').
- ' '.
- &mt('The "[_1]" user can be created automatically when a Domain Coordinator visits the web-based "Set domain configuration" screen, in a session hosted on the primary library server.',$confname).
- ' '.
- &mt('To do that now, use the following link: [_1]',$switchserver)
- );
- } else {
- $r->print(&mt('To create that user from the command line run the ./UPDATE script found in the top level directory of the extracted LON-CAPA tarball.').
- ' '.
- &mt('Once that is done, you will be able to use the web-based "Set domain configuration" to configure the domain')
- );
- }
- $r->print(&Apache::loncommon::end_page());
- return OK;
- }
if (keys(%domconfig) == 0) {
my $primarylibserv = &Apache::lonnet::domain($dom,'primary');
my @ids=&Apache::lonnet::current_machine_ids();
@@ -475,6 +464,7 @@ sub handler {
}
}
}
+
&Apache::lonconfigsettings::display_choices($r,$phase,$context,\@prefs_order,\%prefs);
}
return OK;
@@ -520,6 +510,8 @@ sub process_changes {
$output = &modify_quotas($dom,$action,%domconfig);
} elsif ($action eq 'requestauthor') {
$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,%domconfig);
} elsif ($action eq 'usersessions') {
@@ -534,6 +526,7 @@ 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);
}
@@ -552,7 +545,7 @@ sub print_config_box {
if ($numheaders > 1) {
my $colspan = '';
my $rightcolspan = '';
- if (($action eq 'rolecolors') || ($action eq 'coursecategories') ||
+ if (($action eq 'rolecolors') || ($action eq 'coursecategories') ||
(($action eq 'login') && ($numheaders < 3))) {
$colspan = ' colspan="2"';
}
@@ -591,6 +584,8 @@ sub print_config_box {
$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 .= '
@@ -680,6 +675,8 @@ sub print_config_box {
'.&mt($item->{'header'}->[2]->{'col2'}).' '.
&print_usersessions('bottom',$dom,$settings,\$rowtotal);
$rowtotal ++;
+ } elsif ($action eq 'coursedefaults') {
+ $output .= &print_coursedefaults('bottom',$dom,$settings,\$rowtotal);
} elsif ($action eq 'rolecolors') {
$output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
@@ -776,8 +773,6 @@ sub print_config_box {
$output .= &print_helpsettings($dom,$confname,$settings,\$rowtotal);
} elsif ($action eq 'loadbalancing') {
$output .= &print_loadbalancing($dom,$settings,\$rowtotal);
- } elsif ($action eq 'coursedefaults') {
- $output .= &print_coursedefaults('bottom',$dom,$settings,\$rowtotal);
}
}
$output .= '
@@ -820,7 +815,7 @@ sub print_login {
''.
''.$choices{'directlogin'}.
' ';
- foreach my $hostid (sort(keys(%servers))) {
+ foreach my $hostid (keys(%servers)) {
next if ($servers{$hostid} eq $servers{$lonhost});
my $selected = '';
if (ref($disallowed{$lonhost}) eq 'HASH') {
@@ -863,11 +858,10 @@ sub print_login {
} elsif ($caller eq 'page') {
my %defaultchecked = (
'coursecatalog' => 'on',
- 'helpdesk' => 'on',
'adminmail' => 'off',
'newuser' => 'off',
);
- my @toggles = ('coursecatalog','adminmail','helpdesk','newuser');
+ my @toggles = ('coursecatalog','adminmail','newuser');
my (%checkedon,%checkedoff);
foreach my $item (@toggles) {
if ($defaultchecked{$item} eq 'on') {
@@ -1083,7 +1077,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:",
@@ -1197,7 +1190,10 @@ sub display_color_options {
$images,$bgs,$links,$alt_text,$rowtotal,$logintext) = @_;
my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
my $css_class = $itemcount%2?' class="LC_odd_row"':'';
- my $datatable = ''.
+ my $js = "\n";
+ my $datatable = $js . ' '.
''.$choices->{'font'}.' ';
if (!$is_custom->{'font'}) {
$datatable .= ''.&mt('Default in use:').' '.$defaults->{'font'}.' ';
@@ -1208,7 +1204,7 @@ sub display_color_options {
$datatable .= ''.
' '.
+ ' value="'.$current_color.'" /> '.
' ';
unless ($role eq 'login') {
$datatable .= ''.
@@ -1218,11 +1214,11 @@ sub display_color_options {
} else {
$datatable .= ' ';
}
- $current_color = $designs->{'fontmenu'} ?
- $designs->{'fontmenu'} : $defaults->{'fontmenu'};
+ $current_color = $designs->{'fontmenu'} ?
+ $designs->{'fontmenu'} : $defaults->{'fontmenu'};
$datatable .= ''.
' '.
' ';
}
@@ -1352,9 +1348,11 @@ sub display_color_options {
$datatable .= ''.
'';
+
foreach my $item (@{$bgs}) {
+# my $link = &color_pick($phase,$role,$item,$choices->{$item},$designs->{'bgs'}{$item});
$datatable .= '';
- my $color = $designs->{'bgs'}{$item} ? $designs->{'bgs'}{$item} : $defaults->{'bgs'}{$item};
+ my $color = $designs->{'bgs'}{$item} ? $designs->{'bgs'}{$item} : $defaults->{'bgs'}{$item};
if ($designs->{'bgs'}{$item}) {
$datatable .= ' ';
}
@@ -1380,7 +1378,7 @@ sub display_color_options {
$datatable .= ' '.
'';
foreach my $item (@{$links}) {
- my $color = $designs->{'link'}{$item} ? $designs->{'link'}{$item} : $defaults->{'links'}{$item};
+ my $color = $designs->{'link'}{$item} ? $designs->{'link'}{$item} : $defaults->{'links'}{$item};
$datatable .= ''."\n";
if ($designs->{'links'}{$item}) {
@@ -1516,7 +1514,7 @@ sub print_quotas {
} 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();
@@ -1907,16 +1905,35 @@ sub print_quotas {
sub print_requestmail {
my ($dom,$action,$settings,$rowtotal) = @_;
- my ($now,$datatable,%currapp,$rows);
+ 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;
+ 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') {
@@ -1927,12 +1944,42 @@ sub print_requestmail {
$datatable = ' '.
' '.$text.' '.
' ';
- my ($numdc,$table,$rows) = &active_dc_picker($dom,$numinrow,'checkbox',
- 'reqapprovalnotify',%currapp);
- if ($numdc > 0) {
- $datatable .= $table;
+ if (@domcoord > 0) {
+ $datatable .= '';
} else {
$datatable .= &mt('There are no active Domain Coordinators');
+ $rows ++;
}
$datatable .=' ';
$$rowtotal += $rows;
@@ -2087,7 +2134,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) {
@@ -2100,9 +2148,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" ';
@@ -2110,7 +2156,6 @@ sub print_autocreate {
}
}
$$rowtotal += 2;
- my $numinrow = 2;
my $datatable=''.
''.&mt('Create pending official courses from XML files').' '.
''.
@@ -2125,16 +2170,15 @@ sub print_autocreate {
$createon{'req'}.' value="1" />'.&mt('Yes').' '.
' '.&mt('No').' ';
- my ($numdc,$dctable,$rows) = &active_dc_picker($dom,$numinrow,'radio',
- 'autocreate_xmldc',%currhash);
+ my ($numdc,$dctable) = &active_dc_picker($dom,$curr_dc);
if ($numdc > 1) {
$datatable .= ' '.
&mt('Course creation processed as: (choose Dom. Coord.)').
' '.$dctable.' ';
+ $$rowtotal ++ ;
} else {
$datatable .= $dctable.'';
}
- $$rowtotal += $rows;
return $datatable;
}
@@ -2257,7 +2301,7 @@ sub print_contacts {
my @contacts = ('adminemail','supportemail');
my (%checked,%to,%otheremails,%bccemails);
my @mailings = ('errormail','packagesmail','lonstatusmail','helpdeskmail',
- 'requestsmail','updatesmail');
+ 'requestsmail');
foreach my $type (@mailings) {
$otheremails{$type} = '';
}
@@ -2293,7 +2337,6 @@ sub print_contacts {
$checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" ';
$checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" ';
$checked{'requestsmail'}{'adminemail'} = ' checked="checked" ';
- $checked{'updatesmail'}{'adminemail'} = ' checked="checked" ';
}
my ($titles,$short_titles) = &contact_titles();
my $rownum = 0;
@@ -2353,8 +2396,7 @@ sub print_helpsettings {
}
sub radiobutton_prefs {
- my ($settings,$toggles,$defaultchecked,$choices,$itemcount,$onclick,
- $additional) = @_;
+ my ($settings,$toggles,$defaultchecked,$choices,$itemcount) = @_;
return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') &&
(ref($choices) eq 'HASH'));
@@ -2380,22 +2422,17 @@ sub radiobutton_prefs {
}
}
}
- if ($onclick) {
- $onclick = ' onclick="'.$onclick.'"';
- }
foreach my $item (@{$toggles}) {
$css_class = $itemcount%2?' class="LC_odd_row"':'';
$datatable .=
- ''.
- ''.$choices->{$item}.
+ ''.$choices->{$item}.
' '.
''.
' '.&mt('Yes').
+ $item.'" '.$checkedon{$item}.' value="1" />'.&mt('Yes').
' '.&mt('No').' '.
- ' '.$additional.
- ' '.
+ $checkedoff{$item}.' value="0" />'.&mt('No').''.
+ ''.
' ';
$itemcount ++;
}
@@ -2404,31 +2441,28 @@ sub radiobutton_prefs {
sub print_coursedefaults {
my ($position,$dom,$settings,$rowtotal) = @_;
- my ($css_class,$datatable,%checkedon,%checkedoff,%defaultchecked,@toggles);
+ my ($css_class,$datatable);
my $itemcount = 1;
- my %choices = &Apache::lonlocal::texthash (
- canuse_pdfforms => 'Course/Community users can create/upload PDF forms',
- anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys',
- coursecredits => 'Credits can be specified for courses',
- );
if ($position eq 'top') {
+ my (%checkedon,%checkedoff,%choices,%defaultchecked,@toggles);
+ %choices =
+ &Apache::lonlocal::texthash (
+ canuse_pdfforms => 'Course/Community users can create/upload PDF forms',
+ );
%defaultchecked = ('canuse_pdfforms' => 'off');
- @toggles = ('canuse_pdfforms');
+ @toggles = ('canuse_pdfforms',);
($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
\%choices,$itemcount);
+ $$rowtotal += $itemcount;
} else {
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
- my ($currdefresponder,$def_official_credits,$def_unofficial_credits);
- my $currusecredits = 0;
+ 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->{'coursecredits'}) eq 'HASH') {
- $def_official_credits = $settings->{'coursecredits'}->{'official'};
- $def_unofficial_credits = $settings->{'coursecredits'}->{'unofficial'};
- if (($def_official_credits ne '') || ($def_unofficial_credits ne '')) {
- $currusecredits = 1;
- }
- }
}
if (!$currdefresponder) {
$currdefresponder = 10;
@@ -2436,41 +2470,13 @@ sub print_coursedefaults {
$currdefresponder = 1;
}
$datatable .=
- ''.
- $choices{'anonsurvey_threshold'}.
+ ''.$choices{'anonsurvey_threshold'}.
' '.
''.
' '.
- ' '."\n";
- $itemcount ++;
- my $onclick = 'toggleCredits(this.form);';
- my $display = 'none';
- if ($currusecredits) {
- $display = 'block';
- }
- my $additional = ''.
- ''.
- &mt('Default credits for official courses [_1]',
- ' ').
- ' '.
- ''.
- &mt('Default credits for unofficial courses [_1]',
- ' ').
- '
'."\n";
- %defaultchecked = ('coursecredits' => 'off');
- @toggles = ('coursecredits');
- my $current = {
- 'coursecredits' => $currusecredits,
- };
- (my $table,$itemcount) =
- &radiobutton_prefs($current,\@toggles,\%defaultchecked,
- \%choices,$itemcount,$onclick,$additional);
- $datatable .= $table;
+ ' ';
}
- $$rowtotal += $itemcount;
return $datatable;
}
@@ -2761,10 +2767,7 @@ sub spares_row {
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
$datatable .= '
- '.
- &mt('[_1] when busy, offloads to:'
- ,''.$server.' ').
- "\n";
+ '.$server.' when busy, offloads to: '."\n";
my (%current,%canselect);
my @choices =
&possible_newspares($server,$spareid->{$server},$serverhomes,$altids);
@@ -2931,7 +2934,7 @@ sub print_loadbalancing {
''.
'';
if ($lonhost eq '') {
- $datatable .= '';
+ $datatable .= '';
if (keys(%currbalancer) > 0) {
$datatable .= &mt('Add balancer:');
} else {
@@ -2947,7 +2950,7 @@ sub print_loadbalancing {
next if ($currbalancer{$server});
$datatable .= ''.$server.' '."\n";
}
- $datatable .=
+ $datatable .=
''."\n".
' '."\n";
} else {
@@ -2986,7 +2989,7 @@ sub print_loadbalancing {
if (exists($currbalancer{$spares[$i]})) {
$disabled = ' disabled="disabled"';
}
- $targettable .=
+ $targettable .=
'
'.$chkboxval.
' ';
@@ -3013,6 +3016,7 @@ sub print_loadbalancing {
' ';
}
}
+ my $cssidx = $balnum%2;
$datatable .= ' '.
&loadbalancing_rules($dom,$intdom,$currrules{$lonhost},
$othertitle,$usertypes,$types,\%servers,
@@ -3070,7 +3074,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}) {
@@ -3142,7 +3146,7 @@ sub loadbalance_rule_row {
if ($islast && $num == 1) {
$space = '
';
}
- my $output =
+ my $output =
''.$space.
''.$title.'
'."\n".
''.$space.
@@ -3162,7 +3166,7 @@ sub loadbalance_rule_row {
unless ($checked) {
$default = ' selected="selected"';
}
- $extra =
+ $extra =
': '."\n".
@@ -3221,7 +3225,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',
);
my %short_titles = &Apache::lonlocal::texthash (
adminemail => 'Admin E-mail address',
@@ -3264,12 +3267,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;
}
@@ -3503,9 +3506,9 @@ sub captcha_choice {
#
# Note: If reCAPTCHA is to be used for LON-CAPA servers in a domain, a domain coordinator should visit:
# https://www.google.com/recaptcha and generate a Public and Private key. For domains with multiple
-# servers a single key pair will be used for all servers, so the internet domain (e.g., yourcollege.edu)
+# servers a single key pair will be used for all servers, so the internet domain (e.g., yourcollege.edu)
# specified for use with the key should be broad enough to accommodate all servers in the LON-CAPA domain.
-#
+#
$output .= ' '."\n".
''."\n".
''.$pubtext.' '."\n".
@@ -4184,7 +4187,7 @@ sub print_serverstatuses {
sub serverstatus_pages {
return ('userstatus','lonstatus','loncron','server-status','codeversions',
- 'checksums','clusterstatus','metadata_keywords','metadata_harvest',
+ 'clusterstatus','metadata_keywords','metadata_harvest',
'takeoffline','takeonline','showenv','toggledebug','ping','domconf');
}
@@ -4639,7 +4642,6 @@ sub modify_login {
%curr_loginvia,%loginhash,@currlangs,@newlangs,$addedfile,%title,@offon);
%title = ( coursecatalog => 'Display course catalog',
adminmail => 'Display administrator E-mail address',
- helpdesk => 'Display "Contact Helpdesk" link',
newuser => 'Link for visitors to create a user account',
loginheader => 'Log-in box header');
@offon = ('off','on');
@@ -4652,7 +4654,7 @@ sub modify_login {
}
($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
\%domconfig,\%loginhash);
- my @toggles = ('coursecatalog','adminmail','helpdesk','newuser');
+ my @toggles = ('coursecatalog','adminmail','newuser');
foreach my $item (@toggles) {
$loginhash{login}{$item} = $env{'form.'.$item};
}
@@ -4814,7 +4816,7 @@ sub modify_login {
} else {
my $puberror = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$newfile{$lang},$result);
$errors .= ''.$puberror.' ';
- if ((grep(/^\Q$lang\E$/,@currlangs)) &&
+ if ((grep(/^\Q$lang\E$/,@currlangs)) &&
(!grep(/^\Q$lang\E$/,@delurls))) {
$loginhash{'login'}{'helpurl'}{$lang} = $domconfig{'login'}{'helpurl'}{$lang};
@@ -4840,10 +4842,9 @@ sub modify_login {
my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
$dom);
if ($putresult eq 'ok') {
- my @toggles = ('coursecatalog','adminmail','helpdesk','newuser');
+ my @toggles = ('coursecatalog','adminmail','newuser');
my %defaultchecked = (
'coursecatalog' => 'on',
- 'helpdesk' => 'on',
'adminmail' => 'off',
'newuser' => 'off',
);
@@ -4931,7 +4932,7 @@ sub modify_login {
}
} elsif ($item eq 'captcha') {
if (ref($loginhash{'login'}) eq 'HASH') {
- my $chgtxt;
+ my $chgtxt;
if ($loginhash{'login'}{$item} eq 'notused') {
$chgtxt .= &mt('No CAPTCHA validation in use for helpdesk form.');
} else {
@@ -5409,7 +5410,7 @@ sub publishlogo {
# See if there is anything left
unless ($fname) { return ('error: no uploaded file'); }
$fname="$subdir/$fname";
- my $docroot=$r->dir_config('lonDocRoot');
+ my $docroot=$r->dir_config('lonDocRoot');
my $filepath="$docroot/priv";
my $relpath = "$dom/$confname";
my ($fnamepath,$file,$fetchthumb);
@@ -5417,7 +5418,7 @@ sub publishlogo {
if ($fname=~m|/|) {
($fnamepath,$file) = ($fname =~ m|^(.*)/([^/]+)$|);
}
- my @parts=split(/\//,"$filepath/$relpath/$fnamepath");
+ my @parts=split(/\//,"$filepath/$relpath/$fnamepath");
my $count;
for ($count=5;$count<=$#parts;$count++) {
$filepath.="/$parts[$count]";
@@ -5434,9 +5435,9 @@ sub publishlogo {
!defined(&Apache::loncommon::fileembstyle($1))) {
$output = &mt('Unrecognized file extension ([_1]) - rename the file with a proper extension and re-upload.',$1);
} elsif ($file=~/\.(\d+)\.(\w+)$/) {
- $output = &mt('Filename not allowed - rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2);
+ $output = &mt('File name not allowed - rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2);
} elsif (-d "$filepath/$file") {
- $output = &mt('Filename is a directory name - rename the file and re-upload');
+ $output = &mt('File name is a directory name - rename the file and re-upload');
} else {
my $source = $filepath.'/'.$file;
my $logfile;
@@ -5588,7 +5589,7 @@ sub write_metadata {
print $logfile "\nWrite metadata file for ".$targetdir.'/'.$file;
my $mfh;
if (open($mfh,'>'.$targetdir.'/'.$file.'.meta')) {
- foreach (sort(keys(%metadatafields))) {
+ foreach (sort keys %metadatafields) {
unless ($_=~/\./) {
my $unikey=$_;
$unikey=~/^([A-Za-z]+)/;
@@ -5672,7 +5673,7 @@ sub check_switchserver {
my @ids=&Apache::lonnet::current_machine_ids();
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
if (!$allowed) {
- $switchserver=''.&mt('Switch Server').' ';
+ $switchserver=''.&mt('Switch Server').' ';
}
return $switchserver;
}
@@ -5683,7 +5684,7 @@ sub modify_quotas {
%limithash,$toolregexp,%conditions,$resulttext,%changes);
if ($action eq 'quotas') {
$context = 'tools';
- } else {
+ } else {
$context = $action;
}
if ($context eq 'requestcourses') {
@@ -5873,7 +5874,7 @@ sub modify_quotas {
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
$resulttext = &mt('Changes made:').'';
- unless (($context eq 'requestcourses') ||
+ unless (($context eq 'requestcourses') ||
($context eq 'requestauthor')) {
if (ref($changes{'defaultquota'}) eq 'HASH') {
$resulttext .= ''.&mt('Portfolio default quotas').'';
@@ -5894,7 +5895,7 @@ sub modify_quotas {
my (%haschgs,%inconf);
if ($context eq 'requestauthor') {
%haschgs = %changes;
- %inconf = %confhash;
+ %inconf = %confhash;
} else {
if (ref($changes{$item}) eq 'HASH') {
%haschgs = %{$changes{$item}};
@@ -5908,7 +5909,7 @@ sub modify_quotas {
&Apache::lonnet::usertools_access($env{'user.name'},
$env{'user.domain'},
$item,'reload',$context);
- if (($context eq 'requestcourses') ||
+ if (($context eq 'requestcourses') ||
($context eq 'requestauthor')) {
if ($env{'environment.canrequest.'.$item} ne $newacc) {
$newenv{'environment.canrequest.'.$item} = $newacc;
@@ -6319,16 +6320,13 @@ sub modify_autocreate {
foreach my $item (@types) {
if ($changes{$item}) {
my $newtxt = $offon[$newvals{$item}];
- $resulttext .= ''.
- &mt("$title{$item} set to [_1]$newtxt [_2]",
- '',' ').
- ' ';
+ $resulttext .= ''.&mt("$title{$item} set to [_1]$newtxt [_2]",'',' ').' ';
}
}
if ($changes{'xmldc'}) {
my ($dcname,$dcdom) = split(':',$newvals{'xmldc'});
my $newtxt = &Apache::loncommon::plainname($dcname,$dcdom);
- $resulttext .= ''.&mt("$title{'xmldc'} set to [_1]",''.$newtxt.' ').' ';
+ $resulttext .= ''.&mt("$title{'xmldc'} set to [_1]$newtxt [_2]",'',' ').' ';
}
$resulttext .= ' ';
} else {
@@ -6474,11 +6472,7 @@ sub modify_directorysrch {
} else {
$chgtext =~ s/\; $//;
}
- $resulttext .=
- ' '.
- &mt("Users from domain '[_1]' permitted to search the institutional directory set to: [_2]",
- ''.$dom.' ',$chgtext).
- ' ';
+ $resulttext .= ''.&mt("Users from domain '[_1] ' permitted to search the institutional directory set to: [_2]",$dom,$chgtext).' ';
}
}
}
@@ -6506,7 +6500,7 @@ sub modify_directorysrch {
}
}
$chgtext =~ s/\; $//;
- $resulttext .= ''.&mt($title{'searchtypes'}.' set to: "[_1]"',$chgtext).' ';
+ $resulttext .= ''.&mt("$title{'searchtypes'} set to: \"[_1]\"",$chgtext).' ';
}
$resulttext .= ' ';
} else {
@@ -6530,7 +6524,7 @@ sub modify_contacts {
my (%others,%to,%bcc);
my @contacts = ('supportemail','adminemail');
my @mailings = ('errormail','packagesmail','helpdeskmail','lonstatusmail',
- 'requestsmail','updatesmail');
+ 'requestsmail');
foreach my $type (@mailings) {
@{$newsetting{$type}} =
&Apache::loncommon::get_env_multiple('form.'.$type);
@@ -6586,7 +6580,6 @@ sub modify_contacts {
$default{'helpdeskmail'} = 'supportemail';
$default{'lonstatusmail'} = 'adminemail';
$default{'requestsmail'} = 'adminemail';
- $default{'updatesmail'} = 'adminemail';
foreach my $item (@contacts) {
if ($to{$item} ne $default{$item}) {
$changes{$item} = 1;
@@ -6941,7 +6934,7 @@ sub modify_usercreation {
if ($captchas{$cancreate{$type}}) {
$chgtext .= &mt("Validation for self-creation screen set to $captchas{$cancreate{$type}}.");
} else {
- $chgtext .= &mt('Validation for self-creation screen set to unknown type.');
+ $chgtext .= &mt('Validation for self-creation screen set to unknown type.');
}
}
} elsif ($type eq 'recaptchakeys') {
@@ -7069,7 +7062,7 @@ sub process_captcha {
$newsettings->{'captcha'} = 'original';
}
if ($current->{'captcha'} ne $newsettings->{'captcha'}) {
- if ($container eq 'cancreate') {
+ if ($container eq 'cancreate') {
if (ref($changes->{'cancreate'}) eq 'ARRAY') {
push(@{$changes->{'cancreate'}},'captcha');
} elsif (!defined($changes->{'cancreate'})) {
@@ -7093,12 +7086,10 @@ sub process_captcha {
if (ref($current->{'recaptchakeys'}) eq 'HASH') {
$currpub = $current->{'recaptchakeys'}{'public'};
$currpriv = $current->{'recaptchakeys'}{'private'};
- unless ($newsettings->{'captcha'} eq 'recaptcha') {
- $newsettings->{'recaptchakeys'} = {
- public => '',
- private => '',
- }
- }
+ $newsettings->{'recaptchakeys'} = {
+ public => '',
+ private => '',
+ }
}
if (($newpub ne $currpub) || ($newpriv ne $currpriv)) {
if ($container eq 'cancreate') {
@@ -7108,7 +7099,7 @@ sub process_captcha {
$changes->{'cancreate'} = ['recaptchakeys'];
}
} else {
- $changes->{'recaptchakeys'} = 1;
+ $changes->{'recaptchakeys'} = 1;
}
}
return;
@@ -7792,8 +7783,8 @@ sub modify_helpsettings {
} elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) {
$changes{$item} = 1;
}
- }
- if (($env{'form.'.$item} eq '0') || ($env{'form.'.$item} eq '1')) {
+ }
+ if (($env{'form.'.$item} eq '0') || ($env{'form.'.$item} eq '1')) {
$helphash{'helpsettings'}{$item} = $env{'form.'.$item};
}
}
@@ -7829,6 +7820,7 @@ sub modify_coursedefaults {
my ($dom,%domconfig) = @_;
my ($resulttext,$errors,%changes,%defaultshash);
my %defaultchecked = ('canuse_pdfforms' => 'off');
+ my @offon = ('off','on');
my @toggles = ('canuse_pdfforms');
$defaultshash{'coursedefaults'} = {};
@@ -7845,7 +7837,7 @@ sub modify_coursedefaults {
if (($domconfig{'coursedefaults'}{$item} eq '') &&
($env{'form.'.$item} eq '0')) {
$changes{$item} = 1;
- } elsif ($domconfig{'coursedefaults'}{$item} ne $env{'form.'.$item}) {
+ } elsif ($domconfig{'coursdefaults'}{$item} ne $env{'form.'.$item}) {
$changes{$item} = 1;
}
} elsif ($defaultchecked{$item} eq 'off') {
@@ -7870,42 +7862,14 @@ sub modify_coursedefaults {
$changes{'anonsurvey_threshold'} = 1;
}
}
- my $officialcreds = $env{'form.official_credits'};
- $officialcreds =~ s/^[^\d\.]//g;
- my $unofficialcreds = $env{'form.unofficial_credits'};
- $unofficialcreds =~ s/^[^\d\.]//g;
- if (ref($domconfig{'coursedefaults'}{'coursecredits'} ne 'HASH') &&
- ($env{'form.coursecredits'} eq '1')) {
- $changes{'coursecredits'} = 1;
- } else {
- if (($domconfig{'coursedefaults'}{'coursecredits'}{'official'} ne $officialcreds) ||
- ($domconfig{'coursedefaults'}{'coursecredits'}{'unofficial'} ne $unofficialcreds)) {
- $changes{'coursecredits'} = 1;
- }
- }
- $defaultshash{'coursedefaults'}{'coursecredits'} = {
- official => $officialcreds,
- unofficial => $unofficialcreds,
- }
}
my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
$dom);
if ($putresult eq 'ok') {
- my %domdefaults;
if (keys(%changes) > 0) {
- if (($changes{'canuse_pdfforms'}) || ($changes{'coursecredits'})) {
- %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
- if ($changes{'canuse_pdfforms'}) {
- $domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'};
- }
- if ($changes{'coursecredits'}) {
- if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') {
- $domdefaults{'officialcredits'} =
- $defaultshash{'coursedefaults'}{'coursecredits'}{'official'};
- $domdefaults{'unofficialcredits'} =
- $defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'};
- }
- }
+ if ($changes{'canuse_pdfforms'}) {
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+ $domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'};
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
}
@@ -7919,21 +7883,6 @@ sub modify_coursedefaults {
}
} elsif ($item eq 'anonsurvey_threshold') {
$resulttext .= ''.&mt('Responder count required for display of anonymous survey submissions set to [_1].',$defaultshash{'coursedefaults'}{'anonsurvey_threshold'}).' ';
- } elsif ($item eq 'coursecredits') {
- if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') {
- if (($domdefaults{'officialcredits'} eq '') &&
- ($domdefaults{'unofficialcredits'} eq '')) {
- $resulttext .= ''.&mt('Student credits not in use for courses in this domain').' ';
- } else {
- $resulttext .= ''.&mt('Student credits can be set per course by a Domain Coordinator, with the following defaults applying:').''.
- ''.&mt('Official courses: [_1]',$defaultshash{'coursedefaults'}{'coursecredits'}{'official'}).' '.
- ''.&mt('Unofficial courses: [_1]',$defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'}).' '.
- ' '.
- ' ';
- }
- } else {
- $resulttext .= ''.&mt('Student credits not in use for courses in this domain').' ';
- }
}
}
$resulttext .= '';
@@ -8242,7 +8191,7 @@ sub modify_loadbalancing {
if ($balancer eq '') {
next;
}
- if (!exists($servers{$balancer})) {
+ if (!exists($servers{$balancer})) {
if (exists($currbalancer{$balancer})) {
push(@{$changes{'delete'}},$balancer);
}
@@ -8293,14 +8242,14 @@ sub modify_loadbalancing {
}
} else {
if (ref($defaultshash{'loadbalancing'}{$balancer}) eq 'HASH') {
- foreach my $sparetype (@sparestypes) {
+ foreach my $sparetype (@sparestypes) {
if (ref($defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype}) eq 'ARRAY') {
if (@{$defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype}} > 0) {
$changes{'curr'}{$balancer}{'targets'} = 1;
}
}
}
- }
+ }
}
my $ishomedom;
if (&Apache::lonnet::host_domain($balancer) eq $dom) {
@@ -8309,7 +8258,7 @@ sub modify_loadbalancing {
if (ref($alltypes) eq 'ARRAY') {
foreach my $type (@{$alltypes}) {
my $rule;
- unless ((($type eq '_LC_external') || ($type eq '_LC_internetdom')) &&
+ unless ((($type eq '_LC_external') || ($type eq '_LC_internetdom')) &&
(!$ishomedom)) {
$rule = $env{'form.loadbalancing_rules_'.$i.'_'.$type};
}
@@ -8334,7 +8283,7 @@ sub modify_loadbalancing {
}
my $putresult = &Apache::lonnet::put_dom('configuration',
\%defaultshash,$dom);
-
+
if ($putresult eq 'ok') {
if (keys(%changes) > 0) {
if (ref($changes{'delete'}) eq 'ARRAY') {
@@ -8344,7 +8293,7 @@ sub modify_loadbalancing {
}
}
if (ref($changes{'add'}) eq 'ARRAY') {
- foreach my $balancer (sort(@{$changes{'add'}})) {
+ foreach my $balancer (sort(@{$changes{'add'}})) {
$resulttext .= ''.&mt('Load Balancing enabled for: [_1]',$balancer);
}
}
@@ -8390,7 +8339,7 @@ sub modify_loadbalancing {
} else {
$balancetext = &mt('offload to [_1]',$defaultshash{'loadbalancing'}{$balancer}{'rules'}{$type});
}
- $resulttext .= ' '.&mt('Load Balancer: [_1] -- balancing for [_2] set to - "[_3]"',$balancer,$titles->{$type},$balancetext).' ';
+ $resulttext .= ''.&mt('Load Balancer: [_1] -- balancing for [_2] set to - "[_3]"',$balancer,$titles->{$type},$balancetext).' ';
}
}
}
@@ -8450,7 +8399,7 @@ sub recurse_cat_deletes {
delete($coursecategories->{$subitem});
$deletions->{$subitem} = 1;
&recurse_cat_deletes($subitem,$coursecategories,$deletions);
- }
+ }
}
}
return;
@@ -8458,94 +8407,72 @@ sub recurse_cat_deletes {
sub get_active_dcs {
my ($dom) = @_;
- my $now = time;
- my %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc'],$now,$now);
+ my %dompersonnel = &Apache::lonnet::get_domain_roles($dom,['dc']);
my %domcoords;
my $numdcs = 0;
+ my $now = time;
foreach my $server (keys(%dompersonnel)) {
foreach my $user (sort(keys(%{$dompersonnel{$server}}))) {
my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,$user);
- $domcoords{$uname.':'.$udom} = $dompersonnel{$server}{$user};
+ my ($end,$start) = split(':',$dompersonnel{$server}{$user});
+ if (($end eq '') || ($end == 0) || ($end > $now)) {
+ if ($start <= $now) {
+ $domcoords{$uname.':'.$udom} = $dompersonnel{$server}{$user};
+ }
+ }
}
}
return %domcoords;
}
sub active_dc_picker {
- my ($dom,$numinrow,$inputtype,$name,%currhash) = @_;
+ my ($dom,$curr_dc) = @_;
my %domcoords = &get_active_dcs($dom);
- my @domcoord = keys(%domcoords);
- if (keys(%currhash)) {
- foreach my $dc (keys(%currhash)) {
- unless (exists($domcoords{$dc})) {
- push(@domcoord,$dc);
- }
- }
- }
- @domcoord = sort(@domcoord);
- my $numdcs = scalar(@domcoord);
- my $rows = 0;
- my $table;
+ my @dcs = sort(keys(%domcoords));
+ my $numdcs = scalar(@dcs);
+ my $datatable;
+ my $numinrow = 2;
if ($numdcs > 1) {
- $table = '';
+ } elsif (@dcs) {
+ $datatable .= ' ';
}
- return ($numdcs,$table,$rows);
+ return ($numdcs,$datatable);
}
sub usersession_titles {
@@ -8617,7 +8544,7 @@ sub lonbalance_targets_js {
}
&get_loadbalancers_config($servers,\%existing,\%currbalancer,
\%currtargets,\%currrules);
- my $balancers = join("','",sort(keys(%currbalancer)));
+ my $balancers = join("','",sort(keys(%currbalancer)));
return <<"END";
-
-END
-
-}
-
-sub credits_js {
- return <<"END";
-
-