--- loncom/interface/domainprefs.pm 2014/04/16 13:33:14 1.160.6.39
+++ loncom/interface/domainprefs.pm 2016/09/18 19:22:48 1.160.6.71
@@ -1,8 +1,8 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.160.6.39 2014/04/16 13:33:14 raeburn Exp $
-##
+# $Id: domainprefs.pm,v 1.160.6.71 2016/09/18 19:22:48 raeburn Exp $
+#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
@@ -215,7 +215,7 @@ sub handler {
'contacts','defaults','scantron','coursecategories',
'serverstatuses','requestcourses','coursedefaults',
'usersessions','loadbalancing','requestauthor',
- 'selfenrollment'],$dom);
+ 'selfenrollment','inststatus'],$dom);
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
'autoupdate','autocreate','directorysrch','contacts',
'usercreation','selfcreation','usermodification','scantron',
@@ -250,15 +250,19 @@ 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',
+ { text => 'Default authentication/language/timezone/portal/types',
help => 'Domain_Configuration_LangTZAuth',
header => [{col1 => 'Setting',
- col2 => 'Value'}],
+ col2 => 'Value'},
+ {col1 => 'Institutional user types',
+ col2 => 'Assignable to e-mail usernames'}],
print => \&print_defaults,
modify => \&modify_defaults,
},
@@ -367,6 +371,8 @@ sub handler {
col2 => 'Value'},
{col1 => 'Available textbooks',
col2 => ''},
+ {col1 => 'Available templates',
+ col2 => ''},
{col1 => 'Validation (not official courses)',
col2 => 'Value'},],
print => \&print_quotas,
@@ -385,7 +391,9 @@ sub handler {
'coursecategories' =>
{ text => 'Cataloging of courses/communities',
help => 'Domain_Configuration_Cataloging_Courses',
- header => [{col1 => 'Category settings',
+ header => [{col1 => 'Catalog type/availability',
+ col2 => '',},
+ {col1 => 'Category settings for standard catalog',
col2 => '',},
{col1 => 'Categories',
col2 => '',
@@ -457,6 +465,8 @@ 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,
@@ -479,7 +489,7 @@ sub handler {
}
} elsif ($phase eq 'display') {
my $js = &recaptcha_js().
- &credits_js();
+ &toggle_display_js();
if ((keys(%servers) > 1) || (keys(%existing) > 0)) {
my ($othertitle,$usertypes,$types) =
&Apache::loncommon::sorted_inst_types($dom);
@@ -602,7 +612,7 @@ sub process_changes {
} elsif ($action eq 'scantron') {
$output = &modify_scantron($r,$dom,$confname,$lastactref,%domconfig);
} elsif ($action eq 'coursecategories') {
- $output = &modify_coursecategories($dom,%domconfig);
+ $output = &modify_coursecategories($dom,$lastactref,%domconfig);
} elsif ($action eq 'serverstatuses') {
$output = &modify_serverstatuses($dom,%domconfig);
} elsif ($action eq 'requestcourses') {
@@ -627,8 +637,10 @@ sub print_config_box {
my $output;
if ($action eq 'coursecategories') {
$output = &coursecategories_javascript($settings);
+ } elsif ($action eq 'defaults') {
+ $output = &defaults_javascript($settings);
}
- $output .=
+ $output .=
'
'.
@@ -643,8 +655,8 @@ sub print_config_box {
if ($numheaders > 1) {
my $colspan = '';
my $rightcolspan = '';
- if (($action eq 'rolecolors') || ($action eq 'coursecategories') ||
- (($action eq 'login') && ($numheaders < 3))) {
+ if (($action eq 'rolecolors') || ($action eq 'defaults') ||
+ (($action eq 'login') && ($numheaders < 4))) {
$colspan = ' colspan="2"';
}
if ($action eq 'usersessions') {
@@ -660,13 +672,13 @@ sub print_config_box {
';
$rowtotal ++;
if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') ||
- ($action eq 'usermodification') || ($action eq 'selfenrollment') ||
- ($action eq 'usersessions')) {
+ ($action eq 'usermodification') || ($action eq 'defaults') || ($action eq 'coursedefaults') ||
+ ($action eq 'selfenrollment') || ($action eq 'usersessions')) {
$output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal);
} elsif ($action eq 'coursecategories') {
$output .= $item->{'print'}->('top',$dom,$item,$settings,\$rowtotal);
} elsif ($action eq 'login') {
- if ($numheaders == 3) {
+ if ($numheaders == 4) {
$colspan = ' colspan="2"';
$output .= &print_login('service',$dom,$confname,$phase,$settings,\$rowtotal);
} else {
@@ -691,8 +703,14 @@ sub print_config_box {
$rowtotal ++;
if (($action eq 'autoupdate') || ($action eq 'usercreation') ||
($action eq 'selfcreation') || ($action eq 'selfenrollment') ||
- ($action eq 'usersessions')) {
- $output .= $item->{'print'}->('middle',$dom,$settings,\$rowtotal).'
+ ($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 .= '
@@ -702,15 +720,18 @@ sub print_config_box {
'.&mt($item->{'header'}->[2]->{'col1'}).'
'.&mt($item->{'header'}->[2]->{'col2'}).'
- '."\n".
- $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
+ '."\n";
+ if ($action eq 'coursecategories') {
+ $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);
+ } else {
+ $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
+ }
$rowtotal ++;
- } elsif (($action eq 'usermodification') || ($action eq 'coursedefaults')) {
+ } elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') ||
+ ($action eq 'defaults')) {
$output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
- } elsif ($action eq 'coursecategories') {
- $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);
} elsif ($action eq 'login') {
- if ($numheaders == 3) {
+ if ($numheaders == 4) {
$output .= &print_login('page',$dom,$confname,$phase,$settings,\$rowtotal).'
@@ -726,9 +747,31 @@ sub print_config_box {
} else {
$output .= &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal);
}
+ $output .= '
+
+
+
+
+
+
+ ';
+ if ($numheaders == 4) {
+ $output .= '
+ '.&mt($item->{'header'}->[3]->{'col1'}).'
+ '.&mt($item->{'header'}->[3]->{'col2'}).'
+ ';
+ } else {
+ $output .= '
+ '.&mt($item->{'header'}->[2]->{'col1'}).'
+ '.&mt($item->{'header'}->[2]->{'col2'}).'
+ ';
+ }
+ $rowtotal ++;
+ $output .= &print_login('headtag',$dom,$confname,$phase,$settings,\$rowtotal);
} elsif ($action eq 'requestcourses') {
- $output .= &print_requestmail($dom,$action,$settings,\$rowtotal).
- &print_studentcode($settings,\$rowtotal).'
+ $output .= &print_requestmail($dom,$action,$settings,\$rowtotal);
+ $rowtotal ++;
+ $output .= &print_studentcode($settings,\$rowtotal).'
@@ -738,7 +781,18 @@ sub print_config_box {
'.&mt($item->{'header'}->[2]->{'col1'}).'
'.&mt($item->{'header'}->[2]->{'col2'}).' '.
- &print_textbookcourses($dom,$settings,\$rowtotal).'
+ &textbookcourses_javascript($settings).
+ &print_textbookcourses($dom,'textbooks',$settings,\$rowtotal).'
+
+
+
+
+
+
+
+ '.&mt($item->{'header'}->[3]->{'col1'}).'
+ '.&mt($item->{'header'}->[3]->{'col2'}).' '.
+ &print_textbookcourses($dom,'templates',$settings,\$rowtotal).'
@@ -746,12 +800,13 @@ sub print_config_box {
- '.&mt($item->{'header'}->[3]->{'col1'}).'
- '.&mt($item->{'header'}->[3]->{'col2'}).'
+ '.&mt($item->{'header'}->[4]->{'col1'}).'
+ '.&mt($item->{'header'}->[4]->{'col2'}).'
'.
&print_validation_rows('requestcourses',$dom,$settings,\$rowtotal);
} elsif ($action eq 'requestauthor') {
$output .= &print_requestmail($dom,$action,$settings,\$rowtotal);
+ $rowtotal ++;
} elsif ($action eq 'rolecolors') {
$output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
@@ -831,8 +886,7 @@ sub print_config_box {
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 'defaults') || ($action eq 'serverstatuses') ||
- ($action eq 'loadbalancing')) {
+ ($action eq 'contacts') || ($action eq 'serverstatuses') || ($action eq 'loadbalancing')) {
$output .= $item->{'print'}->($dom,$settings,\$rowtotal);
} elsif ($action eq 'scantron') {
$output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
@@ -1134,6 +1188,57 @@ sub print_login {
$itemcount ++;
}
$datatable .= &captcha_choice('login',$settings,$itemcount);
+ } elsif ($caller eq 'headtag') {
+ my %domservers = &Apache::lonnet::get_servers($dom);
+ my $choice = $choices{'headtag'};
+ $css_class = ' class="LC_odd_row"';
+ $datatable .= ' '.$choice.' '.
+ ' ';
}
return $datatable;
}
@@ -1167,6 +1272,9 @@ sub login_choices {
link => "Link",
alink => "Active link",
vlink => "Visited link",
+ headtag => "Custom markup",
+ action => "Action",
+ current => "Current",
);
return %choices;
}
@@ -2029,7 +2137,6 @@ sub print_requestmail {
$datatable .= &mt('There are no active Domain Coordinators');
}
$datatable .='';
- $$rowtotal += $rows;
return $datatable;
}
@@ -2038,9 +2145,11 @@ sub print_studentcode {
my $rownum = 0;
my ($output,%current);
my @crstypes = ('official','unofficial','community','textbook');
- if (ref($settings->{'uniquecode'}) eq 'HASH') {
- foreach my $type (@crstypes) {
- $current{$type} = $settings->{'uniquecode'}{$type};
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'uniquecode'}) eq 'HASH') {
+ foreach my $type (@crstypes) {
+ $current{$type} = $settings->{'uniquecode'}{$type};
+ }
}
}
$output .= ''.
@@ -2061,14 +2170,14 @@ sub print_studentcode {
}
sub print_textbookcourses {
- my ($dom,$settings,$rowtotal) = @_;
+ 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->{'textbooks'};
+ $bookshash = $settings->{$type};
}
my %ordered;
if (ref($bookshash) eq 'HASH') {
@@ -2082,7 +2191,7 @@ sub print_textbookcourses {
my $confname = $dom.'-domainconfig';
my $switchserver = &check_switchserver($dom,$confname);
my $maxnum = scalar(keys(%ordered));
- my $datatable = &textbookcourses_javascript(\%ordered);
+ my $datatable;
if (keys(%ordered)) {
my @items = sort { $a <=> $b } keys(%ordered);
for (my $i=0; $i<@items; $i++) {
@@ -2090,21 +2199,24 @@ sub print_textbookcourses {
my $key = $ordered{$items[$i]};
my %coursehash=&Apache::lonnet::coursedescription($key);
my $coursetitle = $coursehash{'description'};
- my ($subject,$title,$author,$image,$imgsrc,$cdom,$cnum);
+ my ($subject,$title,$author,$publisher,$image,$imgsrc,$cdom,$cnum);
if (ref($bookshash->{$key}) eq 'HASH') {
$subject = $bookshash->{$key}->{'subject'};
$title = $bookshash->{$key}->{'title'};
- $author = $bookshash->{$key}->{'author'};
- $image = $bookshash->{$key}->{'image'};
- if ($image ne '') {
- my ($path,$imagefile) = ($image =~ m{^(.+)/([^/]+)$});
- my $imagethumb = "$path/tn-".$imagefile;
- $imgsrc = ' ';
+ 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 = ' ';
+ }
}
}
- my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$key'".');"';
+ my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$type".'_'."$key','$type'".');"';
$datatable .= ' '
- .'';
+ .'';
for (my $k=0; $k<=$maxnum; $k++) {
my $vpos = $k+1;
my $selstr;
@@ -2114,39 +2226,43 @@ sub print_textbookcourses {
$datatable .= ''.$vpos.' ';
}
$datatable .= ' '.(' 'x2).
- ' '.
+ ' '.
&mt('Delete?').' '.
''.
- ''.&mt('Subject:').' '.
- (' 'x2).
- ''.&mt('Title:').' '.
+ ''.&mt('Subject:').' '.
(' 'x2).
- ''.&mt('Author(s):').' '.
- (' 'x2).
- ''.&mt('Thumbnail:');
- if ($image) {
- $datatable .= ''.
- $imgsrc.
- ' '.&mt('Delete?').' '.
- ' '.&mt('Replace:').' ';
- }
- if ($switchserver) {
- $datatable .= &mt('Upload to library server: [_1]',$switchserver);
- } else {
- $datatable .= ' ';
+ ''.&mt('Title:').' ';
+ if ($type eq 'textbooks') {
+ $datatable .= (' 'x2).
+ ''.&mt('Publisher:').' '.
+ (' 'x2).
+ ''.&mt('Author(s):').' '.
+ (' 'x2).
+ ''.&mt('Thumbnail:');
+ if ($image) {
+ $datatable .= ''.
+ $imgsrc.
+ ' '.&mt('Delete?').' '.
+ ' '.&mt('Replace:').' ';
+ }
+ if ($switchserver) {
+ $datatable .= &mt('Upload to library server: [_1]',$switchserver);
+ } else {
+ $datatable .= ' ';
+ }
}
- $datatable .= ' '.
+ $datatable .= ' '.
''.&mt('LON-CAPA course:').' '.
$coursetitle.' '."\n";
$itemcount ++;
}
}
$css_class = $itemcount%2?' class="LC_odd_row"':'';
- my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'addbook_pos'".');"';
+ my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$type"."_addbook_pos','$type'".');"';
$datatable .= ''."\n".
- ' '."\n".
- '';
+ ' '."\n".
+ '';
for (my $k=0; $k<$maxnum+1; $k++) {
my $vpos = $k+1;
my $selstr;
@@ -2156,26 +2272,30 @@ sub print_textbookcourses {
$datatable .= ''.$vpos.' ';
}
$datatable .= ' '."\n".
- ' '.&mt('Add').' '."\n".
+ ' '.&mt('Add').''."\n".
''.
- ''.&mt('Subject:').' '."\n".
- (' 'x2).
- ''.&mt('Title:').' '."\n".
- (' 'x2).
- ''.&mt('Author(s):').' '."\n".
+ ''.&mt('Subject:').' '."\n".
(' 'x2).
- ''.&mt('Image:').' ';
- if ($switchserver) {
- $datatable .= &mt('Upload to library server: [_1]',$switchserver);
- } else {
- $datatable .= ' ';
+ ''.&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'},'addbook_cdom').
- ' '.
+ &Apache::loncommon::select_dom_form($env{'request.role.domain'},$type.'_addbook_cdom').
+ ' '.
&Apache::loncommon::selectcourse_link
- ('display','addbook_cnum','addbook_cdom',undef,undef,undef,'Course');
+ ('display',$type.'_addbook_cnum',$type.'_addbook_cdom',undef,undef,undef,'Course');
' '."\n".
' '."\n";
$itemcount ++;
@@ -2183,23 +2303,42 @@ sub print_textbookcourses {
}
sub textbookcourses_javascript {
- my ($textbooks) = @_;
- return unless(ref($textbooks) eq 'HASH');
- my $num = scalar(keys(%{$textbooks}));
- my @jsarray;
- foreach my $item (sort {$a <=> $b } (keys(%{$textbooks}))) {
- push(@jsarray,$textbooks->{$item});
+ my ($settings) = @_;
+ return unless(ref($settings) eq 'HASH');
+ my (%ordered,%total,%jstext);
+ foreach my $type ('textbooks','templates') {
+ $total{$type} = 0;
+ if (ref($settings->{$type}) eq 'HASH') {
+ foreach my $item (keys(%{$settings->{$type}})) {
+ if (ref($settings->{$type}->{$item}) eq 'HASH') {
+ my $num = $settings->{$type}->{$item}{'order'};
+ $ordered{$type}{$num} = $item;
+ }
+ }
+ $total{$type} = scalar(keys(%{$settings->{$type}}));
+ }
+ my @jsarray = ();
+ foreach my $item (sort {$a <=> $b } (keys(%{$ordered{$type}}))) {
+ push(@jsarray,$ordered{$type}{$item});
+ }
+ $jstext{$type} = ' var '.$type.' = Array('."'".join("','",@jsarray)."'".');'."\n";
}
- my $jstext = ' var textbooks = Array('."'".join("','",@jsarray)."'".');'."\n";
return <<"ENDSCRIPT";
+
+ENDSCRIPT
+ }
}
sub coursecategories_javascript {
@@ -4876,9 +5506,12 @@ sub coursecategories_javascript {
$jstext = ' var categories = Array(1);'."\n".
' categories[0] = Array("instcode_pos");'."\n";
}
- my $instcode_reserved = &mt('The name: "instcode" is a reserved category');
- my $communities_reserved = &mt('The name: "communities" is a reserved category');
- my $choose_again = '\\n'.&mt('Please use a different name for the new top level category');
+ my $instcode_reserved = &mt('The name: [_1] is a reserved category.','"instcode"');
+ my $communities_reserved = &mt('The name: [_1] is a reserved category.','"communities"');
+ my $choose_again = "\n".&mt('Please use a different name for the new top level category.');
+ &js_escape(\$instcode_reserved);
+ &js_escape(\$communities_reserved);
+ &js_escape(\$choose_again);
$output = <<"ENDSCRIPT";