'.&mt($item->{'header'}->[0]->{'col1'}).'
- '.&mt($item->{'header'}->[0]->{'col2'}).'
+ '.&mt($item->{'header'}->[0]->{'col2'}).'
';
$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);
+ if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') ||
+ ($action eq 'usermodification') || ($action eq 'defaults') || ($action eq 'coursedefaults') ||
+ ($action eq 'selfenrollment') || ($action eq 'usersessions') || ($action eq 'ssl') ||
+ ($action eq 'directorysrch') || ($action eq 'trust') || ($action eq 'helpsettings') ||
+ ($action eq 'contacts')) {
+ $output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal);
} elsif ($action eq 'coursecategories') {
- $output .= &print_coursecategories('top',$dom,$item,$settings,\$rowtotal);
- } else {
+ $output .= $item->{'print'}->('top',$dom,$item,$settings,\$rowtotal);
+ } elsif ($action eq 'login') {
+ if ($numheaders == 4) {
+ $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')) {
+ $output .= &print_quotas($dom,$settings,\$rowtotal,$action);
+ } elsif ($action eq 'rolecolors') {
$output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
}
$output .= '
@@ -447,15 +846,98 @@ sub print_config_box {
- '.&mt($item->{'header'}->[1]->{'col1'}).' ';
- $output .= '
+ '.&mt($item->{'header'}->[1]->{'col1'}).'
'.&mt($item->{'header'}->[1]->{'col2'}).'
';
$rowtotal ++;
- if ($action eq 'autoupdate') {
- $output .= &print_autoupdate('bottom',$dom,$settings,\$rowtotal);
- } elsif ($action eq 'usercreation') {
- $output .= &print_usercreation('middle',$dom,$settings,\$rowtotal).'
+ if (($action eq 'autoupdate') || ($action eq 'usercreation') ||
+ ($action eq 'selfcreation') || ($action eq 'selfenrollment') ||
+ ($action eq 'usersessions') || ($action eq 'coursecategories') ||
+ ($action eq 'trust') || ($action eq 'contacts') || ($action eq 'defaults')) {
+ if ($action eq 'coursecategories') {
+ $output .= &print_coursecategories('middle',$dom,$item,$settings,\$rowtotal);
+ $colspan = ' colspan="2"';
+ } elsif ($action eq 'trust') {
+ $output .= $item->{'print'}->('shared',$dom,$settings,\$rowtotal);
+ } else {
+ $output .= $item->{'print'}->('middle',$dom,$settings,\$rowtotal);
+ }
+ if ($action eq 'trust') {
+ $output .= '
+
+
+ ';
+ my @trusthdrs = qw(2 3 4 5 6 7);
+ my @prefixes = qw(enroll othcoau coaurem domroles catalog reqcrs);
+ for (my $i=0; $i<@trusthdrs; $i++) {
+ $output .= '
+
+
+
+
+ '.&mt($item->{'header'}->[$trusthdrs[$i]]->{'col1'}).'
+ '.&mt($item->{'header'}->[$trusthdrs[$i]]->{'col2'}).' '.
+ $item->{'print'}->($prefixes[$i],$dom,$settings,\$rowtotal).'
+
+
+ ';
+ }
+ $output .= '
+
+
+
+
+ '.&mt($item->{'header'}->[8]->{'col1'}).'
+ '.&mt($item->{'header'}->[8]->{'col2'}).' '.
+ $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
+ } else {
+ $output .= '
+
+
+
+
+
+
+
+ '.&mt($item->{'header'}->[2]->{'col1'}).'
+ '.&mt($item->{'header'}->[2]->{'col2'}).'
+ '."\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') ||
+ ($action eq 'defaults') || ($action eq 'directorysrch') ||
+ ($action eq 'helpsettings')) {
+ $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
+ } elsif ($action eq 'ssl') {
+ $output .= $item->{'print'}->('connto',$dom,$settings,\$rowtotal).'
+
+
+
+
+
+
+
+ '.&mt($item->{'header'}->[2]->{'col1'}).'
+ '.&mt($item->{'header'}->[2]->{'col2'}).' '.
+ $item->{'print'}->('connfrom',$dom,$settings,\$rowtotal).'
+
+
+
+
+
+
+
+ '.&mt($item->{'header'}->[3]->{'col1'}).'
+ '.&mt($item->{'header'}->[3]->{'col2'}).' '.
+ $item->{'print'}->('bottom',$dom,$settings,\$rowtotal);
+ } elsif ($action eq 'login') {
+ if ($numheaders == 4) {
+ $output .= &print_login('page',$dom,$confname,$phase,$settings,\$rowtotal).'
@@ -464,11 +946,37 @@ sub print_config_box {
'.&mt($item->{'header'}->[2]->{'col1'}).'
- '.&mt($item->{'header'}->[2]->{'col2'}).' '.
- &print_usercreation('bottom',$dom,$settings,\$rowtotal);
+ '.&mt($item->{'header'}->[2]->{'col2'}).' '.
+ &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal);
+ $rowtotal ++;
+ } 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);
$rowtotal ++;
- } elsif ($action eq 'usermodification') {
- $output .= &print_usermodification('middle',$dom,$settings,\$rowtotal).'
+ $output .= &print_studentcode($settings,\$rowtotal).'
@@ -477,13 +985,34 @@ sub print_config_box {
'.&mt($item->{'header'}->[2]->{'col1'}).'
- '.&mt($item->{'header'}->[2]->{'col2'}).' '.
-
- &print_usermodification('bottom',$dom,$settings,\$rowtotal);
+ '.&mt($item->{'header'}->[2]->{'col2'}).' '.
+ &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).'
+
+
+
+
+
+
+
+ '.&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 'coursecategories') {
- $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal);
- } else {
+ } elsif ($action eq 'rolecolors') {
$output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
@@ -492,9 +1021,9 @@ sub print_config_box {
- '.
+ '.
&mt($item->{'header'}->[2]->{'col1'}).'
- '.
+ '.
&mt($item->{'header'}->[2]->{'col2'}).'
'.
&print_rolecolors($phase,'author',$dom,$confname,$settings,\$rowtotal).'
@@ -517,57 +1046,56 @@ sub print_config_box {
';
- if (($action eq 'login') || ($action eq 'directorysrch')) {
+ if ($action eq 'login') {
$output .= '
'.&mt($item->{'header'}->[0]->{'col1'}).' ';
} elsif ($action eq 'serverstatuses') {
$output .= '
- '.&mt($item->{'header'}->[0]->{'col1'}).
+ '.&mt($item->{'header'}->[0]->{'col1'}).
' ('.&mt('Automatic access for Dom. Coords.').') ';
} else {
$output .= '
- '.&mt($item->{'header'}->[0]->{'col1'}).' ';
+ '.&mt($item->{'header'}->[0]->{'col1'}).' ';
}
if (defined($item->{'header'}->[0]->{'col3'})) {
- $output .= ''.
+ $output .= ' '.
&mt($item->{'header'}->[0]->{'col2'});
if ($action eq 'serverstatuses') {
$output .= ' ('.&mt('user1:domain1,user2:domain2 etc.').' )';
}
} else {
- $output .= ' '.
+ $output .= ' '.
&mt($item->{'header'}->[0]->{'col2'});
}
$output .= ' ';
if ($item->{'header'}->[0]->{'col3'}) {
- $output .= ''.
- &mt($item->{'header'}->[0]->{'col3'});
+ if (defined($item->{'header'}->[0]->{'col4'})) {
+ $output .= ' '.
+ &mt($item->{'header'}->[0]->{'col3'});
+ } else {
+ $output .= ' '.
+ &mt($item->{'header'}->[0]->{'col3'});
+ }
if ($action eq 'serverstatuses') {
$output .= ' ('.&mt('IP1,IP2 etc.').' )';
}
$output .= ' ';
}
+ if ($item->{'header'}->[0]->{'col4'}) {
+ $output .= ''.
+ &mt($item->{'header'}->[0]->{'col4'});
+ }
$output .= ' ';
$rowtotal ++;
- if ($action eq 'login') {
- $output .= &print_login($dom,$confname,$phase,$settings,\$rowtotal);
- } elsif ($action eq 'quotas') {
+ if ($action eq 'quotas') {
$output .= &print_quotas($dom,$settings,\$rowtotal,$action);
- } elsif ($action eq 'autoenroll') {
- $output .= &print_autoenroll($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 'autoenroll') || ($action eq 'autocreate') ||
+ ($action eq 'serverstatuses') || ($action eq 'loadbalancing') ||
+ ($action eq 'ltitools') || ($action eq 'lti')) {
+ $output .= $item->{'print'}->($dom,$settings,\$rowtotal);
} elsif ($action eq 'scantron') {
$output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal);
- } elsif ($action eq 'serverstatuses') {
- $output .= &print_serverstatuses($dom,$settings,\$rowtotal);
- } elsif ($action eq 'requestcourses') {
- $output .= &print_quotas($dom,$settings,\$rowtotal,$action);
}
}
$output .= '
@@ -578,262 +1106,379 @@ sub print_config_box {
return ($output,$rowtotal);
}
-sub print_header {
- my ($r,$phase) = @_;
- my $alert = &mt('You must select at least one functionality type to display.');
- my $js = '
-
-';
- my $additem;
- if ($phase eq 'pickactions') {
- my %loaditems = (
- 'onload' => "javascript:getViewportDims(document.$phase.width,document.$phase.height);setDisplayColumns();setFormElements(document.pickactions);",
- );
- $additem = {'add_entries' => \%loaditems,};
- } else {
- my %loaditems = (
- 'onload' => "javascript:getViewportDims(document.$phase.width,document.$phase.height);",
- );
- $additem = {'add_entries' => \%loaditems,};
- }
- $r->print(&Apache::loncommon::start_page('View/Modify Domain Settings',
- $js,$additem));
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('Domain Settings'));
- $r->print('
-
-');
- $r->print(''.&Apache::loncommon::end_page());
- }
- return;
-}
-
sub print_login {
- my ($dom,$confname,$phase,$settings,$rowtotal) = @_;
+ my ($caller,$dom,$confname,$phase,$settings,$rowtotal) = @_;
+ my ($css_class,$datatable);
my %choices = &login_choices();
- my %defaultchecked = (
- 'coursecatalog' => 'on',
- 'adminmail' => 'off',
- 'newuser' => 'off',
- );
- my @toggles = ('coursecatalog','adminmail','newuser');
- my (%checkedon,%checkedoff);
- foreach my $item (@toggles) {
- if ($defaultchecked{$item} eq 'on') {
- $checkedon{$item} = ' checked="checked" ';
- $checkedoff{$item} = ' ';
- } elsif ($defaultchecked{$item} eq 'off') {
- $checkedoff{$item} = ' checked="checked" ';
- $checkedon{$item} = ' ';
+
+ if ($caller eq 'service') {
+ my %servers = &Apache::lonnet::internet_dom_servers($dom);
+ my $choice = $choices{'disallowlogin'};
+ $css_class = ' class="LC_odd_row"';
+ $datatable .= ''.$choice.' '.
+ ''.$choices{'hostid'}.' '.
+ ''.$choices{'server'}.' '.
+ ''.$choices{'serverpath'}.' '.
+ ''.$choices{'custompath'}.' '.
+ ''.$choices{'exempt'}.' '."\n";
+ my %disallowed;
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'loginvia'}) eq 'HASH') {
+ %disallowed = %{$settings->{'loginvia'}};
+ }
}
- }
- my $loginheader = 'image';
- my @images = ('img','logo','domlogo','login');
- my @logintext = ('textcol','bgcol');
- my @bgs = ('pgbg','mainbg','sidebg');
- my @links = ('link','alink','vlink');
- my %designhash = &Apache::loncommon::get_domainconf($dom);
- my %defaultdesign = %Apache::loncommon::defaultdesign;
- my (%is_custom,%designs);
- my %defaults = (
- font => $defaultdesign{'login.font'},
- );
- foreach my $item (@images) {
- $defaults{$item} = $defaultdesign{'login.'.$item};
- $defaults{'showlogo'}{$item} = 1;
- }
- foreach my $item (@bgs) {
- $defaults{'bgs'}{$item} = $defaultdesign{'login.'.$item};
- }
- foreach my $item (@logintext) {
- $defaults{'logintext'}{$item} = $defaultdesign{'login.'.$item};
- }
- foreach my $item (@links) {
- $defaults{'links'}{$item} = $defaultdesign{'login.'.$item};
- }
- if (ref($settings) eq 'HASH') {
+ foreach my $lonhost (sort(keys(%servers))) {
+ my $direct = 'selected="selected"';
+ if (ref($disallowed{$lonhost}) eq 'HASH') {
+ if ($disallowed{$lonhost}{'server'} ne '') {
+ $direct = '';
+ }
+ }
+ $datatable .= ''.$servers{$lonhost}.' '.
+ ''.
+ ''.$choices{'directlogin'}.
+ ' ';
+ foreach my $hostid (sort(keys(%servers))) {
+ next if ($servers{$hostid} eq $servers{$lonhost});
+ my $selected = '';
+ if (ref($disallowed{$lonhost}) eq 'HASH') {
+ if ($hostid eq $disallowed{$lonhost}{'server'}) {
+ $selected = 'selected="selected"';
+ }
+ }
+ $datatable .= ''.
+ $servers{$hostid}.' ';
+ }
+ $datatable .= ' '.
+ '';
+ foreach my $path ('','/','/adm/login','/adm/roles','custom') {
+ my $pathname = $path;
+ if ($path eq 'custom') {
+ $pathname = &mt('Custom Path').' ->';
+ }
+ my $selected = '';
+ if (ref($disallowed{$lonhost}) eq 'HASH') {
+ if ($path eq $disallowed{$lonhost}{'serverpath'}) {
+ $selected = 'selected="selected"';
+ }
+ } elsif ($path eq '') {
+ $selected = 'selected="selected"';
+ }
+ $datatable .= ''.$pathname.' ';
+ }
+ $datatable .= ' ';
+ my ($custom,$exempt);
+ if (ref($disallowed{$lonhost}) eq 'HASH') {
+ $custom = $disallowed{$lonhost}{'custompath'};
+ $exempt = $disallowed{$lonhost}{'exempt'};
+ }
+ $datatable .= ' '.
+ ' '.
+ ' ';
+ }
+ $datatable .= '
';
+ return $datatable;
+ } elsif ($caller eq 'page') {
+ my %defaultchecked = (
+ 'coursecatalog' => 'on',
+ 'helpdesk' => 'on',
+ 'adminmail' => 'off',
+ 'newuser' => 'off',
+ );
+ my @toggles = ('coursecatalog','adminmail','helpdesk','newuser');
+ my (%checkedon,%checkedoff);
foreach my $item (@toggles) {
- if ($settings->{$item} eq '1') {
- $checkedon{$item} = ' checked="checked" ';
+ if ($defaultchecked{$item} eq 'on') {
+ $checkedon{$item} = ' checked="checked" ';
$checkedoff{$item} = ' ';
- } elsif ($settings->{$item} eq '0') {
- $checkedoff{$item} = ' checked="checked" ';
+ } elsif ($defaultchecked{$item} eq 'off') {
+ $checkedoff{$item} = ' checked="checked" ';
$checkedon{$item} = ' ';
}
}
+ my @images = ('img','logo','domlogo','login');
+ my @logintext = ('textcol','bgcol');
+ my @bgs = ('pgbg','mainbg','sidebg');
+ my @links = ('link','alink','vlink');
+ my %designhash = &Apache::loncommon::get_domainconf($dom);
+ my %defaultdesign = %Apache::loncommon::defaultdesign;
+ my (%is_custom,%designs);
+ my %defaults = (
+ font => $defaultdesign{'login.font'},
+ );
foreach my $item (@images) {
- if (defined($settings->{$item})) {
- $designs{$item} = $settings->{$item};
- $is_custom{$item} = 1;
- }
- if (defined($settings->{'showlogo'}{$item})) {
- $designs{'showlogo'}{$item} = $settings->{'showlogo'}{$item};
- }
+ $defaults{$item} = $defaultdesign{'login.'.$item};
+ $defaults{'showlogo'}{$item} = 1;
}
- foreach my $item (@logintext) {
- if ($settings->{$item} ne '') {
- $designs{'logintext'}{$item} = $settings->{$item};
- $is_custom{$item} = 1;
- }
+ foreach my $item (@bgs) {
+ $defaults{'bgs'}{$item} = $defaultdesign{'login.'.$item};
}
- if ($settings->{'loginheader'} ne '') {
- $loginheader = $settings->{'loginheader'};
+ foreach my $item (@logintext) {
+ $defaults{'logintext'}{$item} = $defaultdesign{'login.'.$item};
}
- if ($settings->{'font'} ne '') {
- $designs{'font'} = $settings->{'font'};
- $is_custom{'font'} = 1;
+ foreach my $item (@links) {
+ $defaults{'links'}{$item} = $defaultdesign{'login.'.$item};
}
- foreach my $item (@bgs) {
- if ($settings->{$item} ne '') {
- $designs{'bgs'}{$item} = $settings->{$item};
- $is_custom{$item} = 1;
+ if (ref($settings) eq 'HASH') {
+ foreach my $item (@toggles) {
+ if ($settings->{$item} eq '1') {
+ $checkedon{$item} = ' checked="checked" ';
+ $checkedoff{$item} = ' ';
+ } elsif ($settings->{$item} eq '0') {
+ $checkedoff{$item} = ' checked="checked" ';
+ $checkedon{$item} = ' ';
+ }
}
- }
- foreach my $item (@links) {
- if ($settings->{$item} ne '') {
- $designs{'links'}{$item} = $settings->{$item};
- $is_custom{$item} = 1;
+ foreach my $item (@images) {
+ if (defined($settings->{$item})) {
+ $designs{$item} = $settings->{$item};
+ $is_custom{$item} = 1;
+ }
+ if (defined($settings->{'showlogo'}{$item})) {
+ $designs{'showlogo'}{$item} = $settings->{'showlogo'}{$item};
+ }
+ }
+ foreach my $item (@logintext) {
+ if ($settings->{$item} ne '') {
+ $designs{'logintext'}{$item} = $settings->{$item};
+ $is_custom{$item} = 1;
+ }
+ }
+ if ($settings->{'font'} ne '') {
+ $designs{'font'} = $settings->{'font'};
+ $is_custom{'font'} = 1;
+ }
+ foreach my $item (@bgs) {
+ if ($settings->{$item} ne '') {
+ $designs{'bgs'}{$item} = $settings->{$item};
+ $is_custom{$item} = 1;
+ }
+ }
+ foreach my $item (@links) {
+ if ($settings->{$item} ne '') {
+ $designs{'links'}{$item} = $settings->{$item};
+ $is_custom{$item} = 1;
+ }
+ }
+ } else {
+ if ($designhash{$dom.'.login.font'} ne '') {
+ $designs{'font'} = $designhash{$dom.'.login.font'};
+ $is_custom{'font'} = 1;
+ }
+ foreach my $item (@images) {
+ if ($designhash{$dom.'.login.'.$item} ne '') {
+ $designs{$item} = $designhash{$dom.'.login.'.$item};
+ $is_custom{$item} = 1;
+ }
+ }
+ foreach my $item (@bgs) {
+ if ($designhash{$dom.'.login.'.$item} ne '') {
+ $designs{'bgs'}{$item} = $designhash{$dom.'.login.'.$item};
+ $is_custom{$item} = 1;
+ }
+ }
+ foreach my $item (@links) {
+ if ($designhash{$dom.'.login.'.$item} ne '') {
+ $designs{'links'}{$item} = $designhash{$dom.'.login.'.$item};
+ $is_custom{$item} = 1;
+ }
}
}
- } else {
- if ($designhash{$dom.'.login.font'} ne '') {
- $designs{'font'} = $designhash{$dom.'.login.font'};
- $is_custom{'font'} = 1;
+ my %alt_text = &Apache::lonlocal::texthash ( img => 'Log-in banner',
+ logo => 'Institution Logo',
+ domlogo => 'Domain Logo',
+ login => 'Login box');
+ my $itemcount = 1;
+ foreach my $item (@toggles) {
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .=
+ ''.$choices{$item}.
+ ' '.
+ ' '.&mt('Yes').
+ ' '.&mt('No').' '.
+ ' ';
+ $itemcount ++;
+ }
+ $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal,\@logintext);
+ $datatable .= '
';
+ } elsif ($caller eq 'help') {
+ my ($defaulturl,$defaulttype,%url,%type,%lt,%langchoices);
+ my $switchserver = &check_switchserver($dom,$confname);
+ my $itemcount = 1;
+ $defaulturl = '/adm/loginproblems.html';
+ $defaulttype = 'default';
+ %lt = &Apache::lonlocal::texthash (
+ del => 'Delete?',
+ rep => 'Replace:',
+ upl => 'Upload:',
+ default => 'Default',
+ custom => 'Custom',
+ );
+ %langchoices = &Apache::lonlocal::texthash(&get_languages_hash());
+ my @currlangs;
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'helpurl'}) eq 'HASH') {
+ foreach my $key (sort(keys(%{$settings->{'helpurl'}}))) {
+ next if ($settings->{'helpurl'}{$key} eq '');
+ $url{$key} = $settings->{'helpurl'}{$key}.'?inhibitmenu=yes';
+ $type{$key} = 'custom';
+ unless ($key eq 'nolang') {
+ push(@currlangs,$key);
+ }
+ }
+ } elsif ($settings->{'helpurl'} ne '') {
+ $type{'nolang'} = 'custom';
+ $url{'nolang'} = $settings->{'helpurl'}.'?inhibitmenu=yes';
+ }
+ }
+ foreach my $lang ('nolang',sort(@currlangs)) {
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .= '';
+ if ($url{$lang} eq '') {
+ $url{$lang} = $defaulturl;
+ }
+ if ($type{$lang} eq '') {
+ $type{$lang} = $defaulttype;
+ }
+ $datatable .= '';
+ if ($lang eq 'nolang') {
+ $datatable .= &mt('Log-in help page if no specific language file: [_1]',
+ &Apache::loncommon::modal_link($url{$lang},$lt{$type{$lang}},600,500));
+ } else {
+ $datatable .= &mt('Log-in help page for language: [_1] is [_2]',
+ $langchoices{$lang},
+ &Apache::loncommon::modal_link($url{$lang},$lt{$type{$lang}},600,500));
+ }
+ $datatable .= ' '."\n".
+ '';
+ if ($type{$lang} eq 'custom') {
+ $datatable .= ''.
+ ' '.
+ $lt{'del'}.' '.$lt{'rep'}.' ';
+ } else {
+ $datatable .= $lt{'upl'};
+ }
+ $datatable .=' ';
+ if ($switchserver) {
+ $datatable .= &mt('Upload to library server: [_1]',$switchserver);
+ } else {
+ $datatable .= ' ';
+ }
+ $datatable .= ' ';
+ $itemcount ++;
}
- foreach my $item (@images) {
- if ($designhash{$dom.'.login.'.$item} ne '') {
- $designs{$item} = $designhash{$dom.'.login.'.$item};
- $is_custom{$item} = 1;
+ my @addlangs;
+ foreach my $lang (sort(keys(%langchoices))) {
+ next if ((grep(/^\Q$lang\E$/,@currlangs)) || ($lang eq 'x_chef'));
+ push(@addlangs,$lang);
+ }
+ if (@addlangs > 0) {
+ my %toadd;
+ map { $toadd{$_} = $langchoices{$_} ; } @addlangs;
+ $toadd{''} = &mt('Select');
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .= ''.
+ &mt('Add log-in help page for a specific language:').' '.
+ &Apache::loncommon::select_form('','loginhelpurl_add_lang',\%toadd).
+ ' '.$lt{'upl'}.' ';
+ if ($switchserver) {
+ $datatable .= &mt('Upload to library server: [_1]',$switchserver);
+ } else {
+ $datatable .= ' ';
}
+ $datatable .= ' ';
+ $itemcount ++;
}
- foreach my $item (@bgs) {
- if ($designhash{$dom.'.login.'.$item} ne '') {
- $designs{'bgs'}{$item} = $designhash{$dom.'.login.'.$item};
- $is_custom{$item} = 1;
+ $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.' '.
+ ' ';
}
- my %alt_text = &Apache::lonlocal::texthash ( img => 'Log-in banner',
- logo => 'Institution Logo',
- domlogo => 'Domain Logo',
- login => 'Login box');
- my $itemcount = 1;
- my ($css_class,$datatable);
- foreach my $item (@toggles) {
- $css_class = $itemcount%2?' class="LC_odd_row"':'';
- $datatable .=
- ''.$choices{$item}.
- ' '.
- ' '.&mt('Yes').
- ' '.&mt('No').' '.
- ' ';
- $itemcount ++;
- }
- $datatable .= &display_color_options($dom,$confname,$phase,'login',$itemcount,\%choices,\%is_custom,\%defaults,\%designs,\@images,\@bgs,\@links,\%alt_text,$rowtotal,\@logintext,$loginheader);
- $datatable .= '
';
return $datatable;
}
sub login_choices {
my %choices =
&Apache::lonlocal::texthash (
- coursecatalog => 'Display Course Catalog link?',
- adminmail => "Display Administrator's E-mail Address?",
- newuser => "Link to create a user account",
- img => "Header",
- logo => "Main Logo",
- domlogo => "Domain Logo",
- login => "Log-in Header",
- textcol => "Text color",
- bgcol => "Box color",
- bgs => "Background colors",
- links => "Link colors",
- font => "Font color",
- pgbg => "Header",
- mainbg => "Page",
- sidebg => "Login box",
- link => "Link",
- alink => "Active link",
- vlink => "Visited link",
+ 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:",
+ serverpath => "Path",
+ custompath => "Custom",
+ exempt => "Exempt IP(s)",
+ directlogin => "No redirect",
+ newuser => "Link to create a user account",
+ img => "Header",
+ logo => "Main Logo",
+ domlogo => "Domain Logo",
+ login => "Log-in Header",
+ textcol => "Text color",
+ bgcol => "Box color",
+ bgs => "Background colors",
+ links => "Link colors",
+ font => "Font color",
+ pgbg => "Header",
+ mainbg => "Page",
+ sidebg => "Login box",
+ link => "Link",
+ alink => "Active link",
+ vlink => "Visited link",
+ headtag => "Custom markup",
+ action => "Action",
+ current => "Current",
);
return %choices;
}
@@ -848,16 +1493,7 @@ sub print_rolecolors {
my %designhash = &Apache::loncommon::get_domainconf($dom);
my %defaultdesign = %Apache::loncommon::defaultdesign;
my (%is_custom,%designs);
- my %defaults = (
- img => $defaultdesign{$role.'.img'},
- font => $defaultdesign{$role.'.font'},
- );
- foreach my $item (@bgs) {
- $defaults{'bgs'}{$item} = $defaultdesign{$role.'.'.$item};
- }
- foreach my $item (@links) {
- $defaults{'links'}{$item} = $defaultdesign{$role.'.'.$item};
- }
+ my %defaults = &role_defaults($role,\@bgs,\@links,\@images);
if (ref($settings) eq 'HASH') {
if (ref($settings->{$role}) eq 'HASH') {
if ($settings->{$role}->{'img'} ne '') {
@@ -868,6 +1504,10 @@ sub print_rolecolors {
$designs{'font'} = $settings->{$role}->{'font'};
$is_custom{'font'} = 1;
}
+ if ($settings->{$role}->{'fontmenu'} ne '') {
+ $designs{'fontmenu'} = $settings->{$role}->{'fontmenu'};
+ $is_custom{'fontmenu'} = 1;
+ }
foreach my $item (@bgs) {
if ($settings->{$role}->{$item} ne '') {
$designs{'bgs'}{$item} = $settings->{$role}->{$item};
@@ -886,6 +1526,10 @@ sub print_rolecolors {
$designs{img} = $designhash{$dom.'.'.$role.'.img'};
$is_custom{'img'} = 1;
}
+ if ($designhash{$dom.'.'.$role.'.fontmenu'} ne '') {
+ $designs{fontmenu} = $designhash{$dom.'.'.$role.'.fontmenu'};
+ $is_custom{'fontmenu'} = 1;
+ }
if ($designhash{$dom.'.'.$role.'.font'} ne '') {
$designs{font} = $designhash{$dom.'.'.$role.'.font'};
$is_custom{'font'} = 1;
@@ -910,24 +1554,78 @@ 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,$loginheader) = @_;
+ $images,$bgs,$links,$alt_text,$rowtotal,$logintext) = @_;
+ my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
my $css_class = $itemcount%2?' class="LC_odd_row"':'';
my $datatable = ''.
''.$choices->{'font'}.' ';
if (!$is_custom->{'font'}) {
- $datatable .= ''.&mt('Default in use:').' '.$defaults->{'font'}.' ';
+ $datatable .= ''.&mt('Default in use:').' '.$defaults->{'font'}.' ';
} else {
$datatable .= ' ';
}
- my $fontlink = &color_pick($phase,$role,'font',$choices->{'font'},$designs->{'font'});
+ my $current_color = $designs->{'font'} ? $designs->{'font'} : $defaults->{'font'};
+
$datatable .= ''.
- ' '.$fontlink.
- ' '.
- ' ';
+ ' '.
+ ' ';
+ unless ($role eq 'login') {
+ $datatable .= ''.
+ ''.$choices->{'fontmenu'}.' ';
+ if (!$is_custom->{'fontmenu'}) {
+ $datatable .= ''.&mt('Default in use:').' '.$defaults->{'fontmenu'}.' ';
+ } else {
+ $datatable .= ' ';
+ }
+ $current_color = $designs->{'fontmenu'} ?
+ $designs->{'fontmenu'} : $defaults->{'fontmenu'};
+ $datatable .= ''.
+ ' '.
+ ' ';
+ }
my $switchserver = &check_switchserver($dom,$confname);
foreach my $img (@{$images}) {
$itemcount ++;
@@ -938,11 +1636,10 @@ sub display_color_options {
if ($role eq 'login') {
if ($img eq 'login') {
$login_hdr_pick =
- &login_header_options($img,$role,$defaults,$is_custom,$choices,
- $loginheader);
+ &login_header_options($img,$role,$defaults,$is_custom,$choices);
$logincolors =
&login_text_colors($img,$role,$logintext,$phase,$choices,
- $designs);
+ $designs,$defaults);
} elsif ($img ne 'domlogo') {
$datatable.= &logo_display_options($img,$defaults,$designs);
}
@@ -975,19 +1672,20 @@ sub display_color_options {
$showfile = $imgfile;
my $imgdir = $1;
my $filename = $2;
- if (-e "/home/httpd/html/$imgdir/tn-".$filename) {
+ if (-e "$londocroot/$imgdir/tn-".$filename) {
$showfile = "/$imgdir/tn-".$filename;
} else {
- my $input = "/home/httpd/html".$imgfile;
- my $output = '/home/httpd/html/'.$imgdir.'/tn-'.$filename;
+ my $input = $londocroot.$imgfile;
+ my $output = "$londocroot/$imgdir/tn-".$filename;
if (!-e $output) {
my ($width,$height) = &thumb_dimensions();
my ($fullwidth,$fullheight) = &check_dimensions($input);
if ($fullwidth ne '' && $fullheight ne '') {
if ($fullwidth > $width && $fullheight > $height) {
my $size = $width.'x'.$height;
- system("convert -sample $size $input $output");
- $showfile = '/'.$imgdir.'/tn-'.$filename;
+ my @args = ('convert','-sample',$size,$input,$output);
+ system({$args[0]} @args);
+ $showfile = "/$imgdir/tn-".$filename;
}
}
}
@@ -1016,22 +1714,24 @@ sub display_color_options {
}
$datatable .= '';
if ($img eq 'login') {
- $datatable .= $login_hdr_pick;
- }
+ $datatable .= $login_hdr_pick;
+ }
$datatable .= &image_changes($is_custom->{$img},$alt_text->{$img},$img_import,
$showfile,$fullsize,$role,$img,$imgfile,$logincolors);
} else {
- $datatable .= ' '.
- &mt('Upload:');
+ $datatable .= ' '.
+ &mt('Upload:').' ';
}
} else {
- $datatable .= ' '.
- &mt('Upload:');
+ $datatable .= ' '.
+ &mt('Upload:').' ';
}
if ($switchserver) {
$datatable .= &mt('Upload to library server: [_1]',$switchserver);
} else {
- $datatable .=' ';
+ if ($img ne 'login') { # suppress file selection for Log-in header
+ $datatable .=' ';
+ }
}
$datatable .= ' ';
}
@@ -1042,7 +1742,7 @@ sub display_color_options {
my $bgs_def;
foreach my $item (@{$bgs}) {
if (!$is_custom->{$item}) {
- $bgs_def .= ''.$choices->{$item}.' '.$defaults->{'bgs'}{$item}.' ';
+ $bgs_def .= ''.$choices->{$item}.' '.$defaults->{'bgs'}{$item}.' ';
}
}
if ($bgs_def) {
@@ -1052,13 +1752,14 @@ sub display_color_options {
}
$datatable .= ''.
' ';
@@ -1069,7 +1770,7 @@ sub display_color_options {
my $links_def;
foreach my $item (@{$links}) {
if (!$is_custom->{$item}) {
- $links_def .= ''.$choices->{$item}.''.$defaults->{'links'}{$item}.' ';
+ $links_def .= ''.$choices->{$item}.''.$defaults->{'links'}{$item}.' ';
}
}
if ($links_def) {
@@ -1080,13 +1781,12 @@ sub display_color_options {
$datatable .= ''.
'';
foreach my $item (@{$links}) {
- $datatable .= ''."\n".
- &color_pick($phase,$role,$item,$choices->{$item},
- $designs->{'links'}{$item});
+ my $color = $designs->{'links'}{$item} ? $designs->{'links'}{$item} : $defaults->{'links'}{$item};
+ $datatable .= ' '.$choices->{$item}."\n";
if ($designs->{'links'}{$item}) {
- $datatable.=' ';
+ $datatable.=' ';
}
- $datatable .= ' ';
}
$$rowtotal += $itemcount;
@@ -1120,20 +1820,10 @@ sub logo_display_options {
}
sub login_header_options {
- my ($img,$role,$defaults,$is_custom,$choices,$loginheader) = @_;
- my $image_checked = ' checked="checked" ';
- my $text_checked = ' ';
- if ($loginheader eq 'text') {
- $image_checked = ' ';
- $text_checked = ' checked="checked" ';
- }
- my $output = ' '.
- &mt('use image').' '.
- ' '.&mt('use text').' '."\n";
+ my ($img,$role,$defaults,$is_custom,$choices) = @_;
+ my $output = '';
if ((!$is_custom->{'textcol'}) || (!$is_custom->{'bgcol'})) {
- $output .= &mt('Text default(s)').': ';
+ $output .= &mt('Text default(s):').' ';
if (!$is_custom->{'textcol'}) {
$output .= $choices->{'textcol'}.': '.$defaults->{'logintext'}{'textcol'}.
' ';
@@ -1150,17 +1840,13 @@ sub login_header_options {
}
sub login_text_colors {
- my ($img,$role,$logintext,$phase,$choices,$designs) = @_;
+ my ($img,$role,$logintext,$phase,$choices,$designs,$defaults) = @_;
my $color_menu = ' ';
return $color_menu;
@@ -1169,80 +1855,30 @@ sub login_text_colors {
sub image_changes {
my ($is_custom,$alt_text,$img_import,$showfile,$fullsize,$role,$img,$imgfile,$logincolors) = @_;
my $output;
- if (!$is_custom) {
+ if ($img eq 'login') {
+ $output = ''.$logincolors; # suppress image for Log-in header
+ } elsif (!$is_custom) {
if ($img ne 'domlogo') {
- $output .= &mt('Default image:').' ';
+ $output = &mt('Default image:').' ';
} else {
- $output .= &mt('Default in use:').' ';
+ $output = &mt('Default in use:').' ';
}
}
- if ($img_import) {
- $output .= ' ';
- }
- $output .= ' ';
- if ($is_custom) {
- $output .= ''.$logincolors.''.
- ' '.&mt('Delete?').
- ' '.&mt('Replace:').' ';
- } else {
- $output .= ' '.$logincolors.&mt('Upload:').' ';
- }
- return $output;
-}
-
-sub color_pick {
- my ($phase,$role,$item,$desc,$curcol) = @_;
- my $link = ''.$desc.' ';
- return $link;
-}
-
-sub color_pick_js {
- my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
- my $output = <<"ENDCOL";
- function pclose() {
- parmwin=window.open("/adm/rat/empty.html","LONCAPAparms","height=350,width=350,scrollbars=no,menubar=no");
- parmwin.close();
- }
-
- $pjump_def
-
- function psub() {
- pclose();
- if (document.parmform.pres_marker.value!='') {
- if (document.parmform.pres_type.value!='') {
- eval('document.display.'+
- document.parmform.pres_marker.value+
- '.value=document.parmform.pres_value.value;');
- }
- } else {
- document.parmform.pres_value.value='';
- document.parmform.pres_marker.value='';
+ if ($img ne 'login') {
+ if ($img_import) {
+ $output .= ' ';
}
- }
-
- function get_id (span_id) {
- if (document.getElementById) {
- return document.getElementById(span_id);
+ $output .= ' ';
+ if ($is_custom) {
+ $output .= ''.$logincolors.''.
+ ' '.&mt('Delete?').
+ ' '.&mt('Replace:').' ';
+ } else {
+ $output .= ' '.$logincolors.&mt('Upload:').' ';
}
- if (document.all) {
- return document.all[span_id];
- }
- return false;
}
-
- function colchg_span (span_id_str,new_color_item) {
- var span_ref = get_id(span_id_str);
- if (span_ref.style) { span_ref = span_ref.style; }
- span_ref.background = new_color_item.value;
- span_ref.backgroundColor = new_color_item.value;
- span_ref.bgColor = new_color_item.value;
- }
-
-ENDCOL
return $output;
}
@@ -1254,26 +1890,37 @@ sub print_quotas {
} else {
$context = $action;
}
- my ($datatable,$defaultquota,@usertools);
+ my ($datatable,$defaultquota,$authorquota,@usertools,@options,%validations);
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
my $typecount = 0;
- my $css_class;
+ my ($css_class,%titles);
if ($context eq 'requestcourses') {
- @usertools = ('official','unofficial');
+ @usertools = ('official','unofficial','community','textbook','placement','lti');
+ @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();
} else {
- @usertools = ('aboutme','blog','portfolio');
+ @usertools = ('aboutme','blog','webdav','portfolio');
+ %titles = &tool_titles();
}
- my %titles = &tool_titles();
if (ref($types) eq 'ARRAY') {
foreach my $type (@{$types}) {
- my $currdefquota;
- unless ($context eq 'requestcourses') {
+ my ($currdefquota,$currauthorquota);
+ 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})) {
@@ -1282,45 +1929,137 @@ sub print_quotas {
$datatable .= ' '.
''.$usertypes->{$type}.' '.
'';
+ if ($context eq 'requestcourses') {
+ $datatable .= '';
}
$datatable .= ' ';
- unless ($context eq 'requestcourses') {
+ unless (($context eq 'requestcourses') ||
+ ($context eq 'requestauthor')) {
$datatable .=
- ''.
+ ' '.
+ ''.&mt('Portfolio').': '.
' Mb ';
+ '" size="5" />'.(' ' x 2).
+ ''.&mt('Authoring').': '.
+ ' ';
}
$datatable .= ' ';
}
}
}
- unless ($context eq 'requestcourses') {
+ 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 ++;
@@ -1328,66 +2067,905 @@ sub print_quotas {
$datatable .= ''.
''.$othertitle.' '.
'';
+ if ($context eq 'requestcourses') {
+ $datatable .= '';
}
$datatable .= ' ';
- unless ($context eq 'requestcourses') {
- $datatable .= ''.
+ unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+ $datatable .= ' '.
+ ''.&mt('Portfolio').': '.
' Mb ';
+ $defaultquota.'" size="5" />'.(' ' x2).
+ ''.&mt('Authoring').': '.
+ ' ';
}
$datatable .= ' ';
$typecount ++;
$css_class = $typecount%2?' class="LC_odd_row"':'';
$datatable .= ''.
- ' '.&mt('LON-CAPA Advanced Users').' '.
- ' ';
+ ''.&mt('LON-CAPA Advanced Users').' ';
+ if ($context eq 'requestcourses') {
+ $datatable .= &mt('(overrides affiliation, if set)').
+ ' '.
+ ''.
+ '';
+ }
+ $datatable .= ' ';
$$rowtotal += $typecount;
return $datatable;
}
+sub print_requestmail {
+ my ($dom,$action,$settings,$rowtotal,$customcss,$rowstyle) = @_;
+ my ($now,$datatable,%currapp);
+ $now = time;
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'notify'}) eq 'HASH') {
+ if ($settings->{'notify'}{'approval'} ne '') {
+ map {$currapp{$_}=1;} split(/,/,$settings->{'notify'}{'approval'});
+ }
+ }
+ }
+ my $numinrow = 2;
+ my $css_class;
+ if ($$rowtotal%2) {
+ $css_class = 'LC_odd_row';
+ }
+ if ($customcss) {
+ $css_class .= " $customcss";
+ }
+ $css_class =~ s/^\s+//;
+ if ($css_class) {
+ $css_class = ' class="'.$css_class.'"';
+ }
+ if ($rowstyle) {
+ $css_class .= ' style="'.$rowstyle.'"';
+ }
+ my $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');
+ }
+ $datatable = ''.
+ ' '.$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 .=' ';
+ return $datatable;
+}
+
+sub print_studentcode {
+ my ($settings,$rowtotal) = @_;
+ my $rownum = 0;
+ my ($output,%current);
+ my @crstypes = ('official','unofficial','community','textbook','placement','lti');
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'uniquecode'}) eq 'HASH') {
+ foreach my $type (@crstypes) {
+ $current{$type} = $settings->{'uniquecode'}{$type};
+ }
+ }
+ }
+ $output .= ''.
+ ''.&mt('Generate unique six character code as course identifier?').' '.
+ '';
+ foreach my $type (@crstypes) {
+ my $check = ' ';
+ if ($current{$type}) {
+ $check = ' checked="checked" ';
+ }
+ $output .= ''.
+ ' '.
+ &mt($type).' '.(' 'x2).' ';
+ }
+ $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 = ' ';
+ }
+ }
+ }
+ my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$type".'_'."$key','$type'".');"';
+ $datatable .= ''
+ .'';
+ for (my $k=0; $k<=$maxnum; $k++) {
+ my $vpos = $k+1;
+ my $selstr;
+ if ($k == $i) {
+ $selstr = ' selected="selected" ';
+ }
+ $datatable .= ''.$vpos.' ';
+ }
+ $datatable .= ' '.(' 'x2).
+ ' '.
+ &mt('Delete?').' '.
+ ''.
+ ''.&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('Delete?').' '.
+ ' '.&mt('Replace:').' ';
+ }
+ if ($switchserver) {
+ $datatable .= &mt('Upload to library server: [_1]',$switchserver);
+ } else {
+ $datatable .= ' ';
+ }
+ }
+ $datatable .= ' '.
+ ''.&mt('LON-CAPA course:').' '.
+ $coursetitle.' '."\n";
+ $itemcount ++;
+ }
+ }
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$type"."_addbook_pos','$type'".');"';
+ $datatable .= ''."\n".
+ ' '."\n".
+ '';
+ for (my $k=0; $k<$maxnum+1; $k++) {
+ my $vpos = $k+1;
+ my $selstr;
+ if ($k == $maxnum) {
+ $selstr = ' selected="selected" ';
+ }
+ $datatable .= ''.$vpos.' ';
+ }
+ $datatable .= ' '."\n".
+ ' '.&mt('Add').' '."\n".
+ ''.
+ ''.&mt('Subject:').' '."\n".
+ (' 'x2).
+ ''.&mt('Title:').' '."\n".
+ (' 'x2);
+ if ($type eq 'textbooks') {
+ $datatable .= ''.&mt('Publisher:').' '."\n".
+ (' 'x2).
+ ''.&mt('Author(s):').' '."\n".
+ (' 'x2).
+ ''.&mt('Image:').' ';
+ if ($switchserver) {
+ $datatable .= &mt('Upload to library server: [_1]',$switchserver);
+ } else {
+ $datatable .= ' ';
+ }
+ $datatable .= ' '."\n";
+ }
+ $datatable .= ''.&mt('LON-CAPA course:').' '.
+ &Apache::loncommon::select_dom_form($env{'request.role.domain'},$type.'_addbook_cdom').
+ ' '.
+ &Apache::loncommon::selectcourse_link
+ ('display',$type.'_addbook_cnum',$type.'_addbook_cdom',undef,undef,undef,'Course').
+ ' '."\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
+}
+
+sub ltitools_javascript {
+ my ($settings) = @_;
+ my $togglejs = <itools_toggle_js();
+ unless (ref($settings) eq 'HASH') {
+ return $togglejs;
+ }
+ my (%ordered,$total,%jstext);
+ $total = 0;
+ foreach my $item (keys(%{$settings})) {
+ if (ref($settings->{$item}) eq 'HASH') {
+ my $num = $settings->{$item}{'order'};
+ $ordered{$num} = $item;
+ }
+ }
+ $total = scalar(keys(%{$settings}));
+ my @jsarray = ();
+ foreach my $item (sort {$a <=> $b } (keys(%ordered))) {
+ push(@jsarray,$ordered{$item});
+ }
+ my $jstext = ' var ltitools = Array('."'".join("','",@jsarray)."'".');'."\n";
+ return <<"ENDSCRIPT";
+
+
+$togglejs
+
+ENDSCRIPT
+}
+
+sub ltitools_toggle_js {
+ return <<"ENDSCRIPT";
+
+
+ENDSCRIPT
+}
+
+sub lti_javascript {
+ my ($settings) = @_;
+ my $togglejs = <i_toggle_js();
+ unless (ref($settings) eq 'HASH') {
+ return $togglejs;
+ }
+ my (%ordered,$total,%jstext);
+ $total = 0;
+ foreach my $item (keys(%{$settings})) {
+ if (ref($settings->{$item}) eq 'HASH') {
+ my $num = $settings->{$item}{'order'};
+ $ordered{$num} = $item;
+ }
+ }
+ $total = scalar(keys(%{$settings}));
+ my @jsarray = ();
+ foreach my $item (sort {$a <=> $b } (keys(%ordered))) {
+ push(@jsarray,$ordered{$item});
+ }
+ my $jstext = ' var lti = Array('."'".join("','",@jsarray)."'".');'."\n";
+ return <<"ENDSCRIPT";
+
+
+$togglejs
+
+ENDSCRIPT
+}
+
+sub lti_toggle_js {
+ my %lcauthparmtext = &Apache::lonlocal::texthash (
+ localauth => 'Local auth argument',
+ krb => 'Kerberos domain',
+ );
+ return <<"ENDSCRIPT";
+
+
+ENDSCRIPT
+}
+
sub print_autoenroll {
my ($dom,$settings,$rowtotal) = @_;
my $autorun = &Apache::lonnet::auto_run(undef,$dom),
- my ($defdom,$runon,$runoff);
+ my ($defdom,$runon,$runoff,$coownerson,$coownersoff,$failsafe);
if (ref($settings) eq 'HASH') {
if (exists($settings->{'run'})) {
if ($settings->{'run'} eq '0') {
@@ -1406,9 +2984,24 @@ sub print_autoenroll {
$runon = ' ';
}
}
+ if (exists($settings->{'co-owners'})) {
+ if ($settings->{'co-owners'} eq '0') {
+ $coownersoff = ' checked="checked" ';
+ $coownerson = ' ';
+ } else {
+ $coownerson = ' checked="checked" ';
+ $coownersoff = ' ';
+ }
+ } else {
+ $coownersoff = ' checked="checked" ';
+ $coownerson = ' ';
+ }
if (exists($settings->{'sender_domain'})) {
$defdom = $settings->{'sender_domain'};
}
+ if (exists($settings->{'autofailsafe'})) {
+ $failsafe = $settings->{'autofailsafe'};
+ }
} else {
if ($autorun) {
$runon = ' checked="checked" ';
@@ -1436,8 +3029,20 @@ sub print_autoenroll {
&mt('username').': '.
' '.&mt('domain').
- ': '.$domform.'';
- $$rowtotal += 2;
+ ': '.$domform.''.
+ ''.
+ ''.&mt('Automatically assign co-ownership').' '.
+ ''.
+ ' '.&mt('Yes').' '.
+ ' '.&mt('No').' '.
+ ' '.
+ ''.&mt('Failsafe for no drops when institutional data missing').' '.
+ ''.
+ ' ';
+ $$rowtotal += 4;
return $datatable;
}
@@ -1479,9 +3084,17 @@ sub print_autoupdate {
$classlistsoff.'value="0" />'.&mt('No').''.
'';
$$rowtotal += 2;
+ } elsif ($position eq 'middle') {
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+ my $numinrow = 3;
+ my $locknamesettings;
+ $datatable .= &insttypes_row($settings,$types,$usertypes,
+ $dom,$numinrow,$othertitle,
+ 'lockablenames',$rowtotal);
+ $$rowtotal ++;
} else {
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
- my @fields = ('lastname','firstname','middlename','gen',
+ my @fields = ('lastname','firstname','middlename','generation',
'permanentemail','id');
my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
my $numrows = 0;
@@ -1502,196 +3115,3485 @@ sub print_autoupdate {
return $datatable;
}
-sub print_directorysrch {
+sub print_autocreate {
my ($dom,$settings,$rowtotal) = @_;
- my $srchon = ' ';
- my $srchoff = ' checked="checked" ';
- my ($exacton,$containson,$beginson);
- my $localon = ' ';
- my $localoff = ' checked="checked" ';
+ my (%createon,%createoff,%currhash);
+ my @types = ('xml','req');
if (ref($settings) eq 'HASH') {
- if ($settings->{'available'} eq '1') {
- $srchon = $srchoff;
- $srchoff = ' ';
- }
- if ($settings->{'localonly'} eq '1') {
- $localon = $localoff;
- $localoff = ' ';
- }
- if (ref($settings->{'searchtypes'}) eq 'ARRAY') {
- foreach my $type (@{$settings->{'searchtypes'}}) {
- if ($type eq 'exact') {
+ foreach my $item (@types) {
+ $createoff{$item} = ' checked="checked" ';
+ $createon{$item} = ' ';
+ if (exists($settings->{$item})) {
+ if ($settings->{$item}) {
+ $createon{$item} = ' checked="checked" ';
+ $createoff{$item} = ' ';
+ }
+ }
+ }
+ if ($settings->{'xmldc'} ne '') {
+ $currhash{$settings->{'xmldc'}} = 1;
+ }
+ } else {
+ foreach my $item (@types) {
+ $createoff{$item} = ' checked="checked" ';
+ $createon{$item} = ' ';
+ }
+ }
+ $$rowtotal += 2;
+ my $numinrow = 2;
+ my $datatable=''.
+ ''.&mt('Create pending official courses from XML files').' '.
+ ''.
+ ' '.&mt('Yes').' '.
+ ' '.&mt('No').' '.
+ ' '.
+ ''.&mt('Create pending requests for official courses (if validated)').' '.
+ ''.
+ ' '.&mt('Yes').' '.
+ ' '.&mt('No').' ';
+ my ($numdc,$dctable,$rows) = &active_dc_picker($dom,$numinrow,'radio',
+ 'autocreate_xmldc',%currhash);
+ $datatable .= ' ';
+ if ($numdc > 1) {
+ $datatable .= &mt('Course creation processed as: (choose Dom. Coord.)').
+ ' ';
+ } else {
+ $datatable .= &mt('Course creation processed as:').
+ ' ';
+ }
+ $datatable .= $dctable.' ';
+ $$rowtotal += $rows;
+ return $datatable;
+}
+
+sub print_directorysrch {
+ my ($position,$dom,$settings,$rowtotal) = @_;
+ my $datatable;
+ if ($position eq 'top') {
+ my $instsrchon = ' ';
+ my $instsrchoff = ' checked="checked" ';
+ my ($exacton,$containson,$beginson);
+ my $instlocalon = ' ';
+ my $instlocaloff = ' checked="checked" ';
+ if (ref($settings) eq 'HASH') {
+ if ($settings->{'available'} eq '1') {
+ $instsrchon = $instsrchoff;
+ $instsrchoff = ' ';
+ }
+ if ($settings->{'localonly'} eq '1') {
+ $instlocalon = $instlocaloff;
+ $instlocaloff = ' ';
+ }
+ if (ref($settings->{'searchtypes'}) eq 'ARRAY') {
+ foreach my $type (@{$settings->{'searchtypes'}}) {
+ if ($type eq 'exact') {
+ $exacton = ' checked="checked" ';
+ } elsif ($type eq 'contains') {
+ $containson = ' checked="checked" ';
+ } elsif ($type eq 'begins') {
+ $beginson = ' checked="checked" ';
+ }
+ }
+ } else {
+ if ($settings->{'searchtypes'} eq 'exact') {
$exacton = ' checked="checked" ';
- } elsif ($type eq 'contains') {
+ } elsif ($settings->{'searchtypes'} eq 'contains') {
$containson = ' checked="checked" ';
- } elsif ($type eq 'begins') {
- $beginson = ' checked="checked" ';
+ } elsif ($settings->{'searchtypes'} eq 'specify') {
+ $exacton = ' checked="checked" ';
+ $containson = ' checked="checked" ';
+ }
+ }
+ }
+ my ($searchtitles,$titleorder) = &sorted_searchtitles();
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+
+ my $numinrow = 4;
+ my $cansrchrow = 0;
+ $datatable=''.
+ ''.&mt('Institutional directory search available?').' '.
+ ''.
+ ' '.&mt('Yes').' '.
+ ' '.&mt('No').' '.
+ ' '.
+ ''.&mt('Other domains can search institution?').' '.
+ ''.
+ ' '.&mt('Yes').' '.
+ ' '.&mt('No').' '.
+ ' ';
+ $$rowtotal += 2;
+ if (ref($usertypes) eq 'HASH') {
+ if (keys(%{$usertypes}) > 0) {
+ $datatable .= &insttypes_row($settings,$types,$usertypes,$dom,
+ $numinrow,$othertitle,'cansearch',
+ $rowtotal);
+ $cansrchrow = 1;
+ }
+ }
+ if ($cansrchrow) {
+ $$rowtotal ++;
+ $datatable .= '';
+ } else {
+ $datatable .= ' ';
+ }
+ $datatable .= ''.&mt('Supported search methods').
+ ' ';
+ $$rowtotal ++;
+ if ($cansrchrow) {
+ $datatable .= '';
} else {
- if ($settings->{'searchtypes'} eq 'exact') {
- $exacton = ' checked="checked" ';
- } elsif ($settings->{'searchtypes'} eq 'contains') {
- $containson = ' checked="checked" ';
- } elsif ($settings->{'searchtypes'} eq 'specify') {
- $exacton = ' checked="checked" ';
- $containson = ' checked="checked" ';
+ $datatable .= ' ';
+ }
+ $datatable .= ''.&mt('Search latitude').' '.
+ ''.
+ ''.
+ ' '.&mt('Exact match').
+ ' '.
+ ' '.&mt('Begins with').
+ ' '.
+ ' '.&mt('Contains').
+ ' ';
+ $$rowtotal ++;
+ } else {
+ my $domsrchon = ' checked="checked" ';
+ my $domsrchoff = ' ';
+ my $domlocalon = ' ';
+ my $domlocaloff = ' checked="checked" ';
+ if (ref($settings) eq 'HASH') {
+ if ($settings->{'lclocalonly'} eq '1') {
+ $domlocalon = $domlocaloff;
+ $domlocaloff = ' ';
+ }
+ if ($settings->{'lcavailable'} eq '0') {
+ $domsrchoff = $domsrchon;
+ $domsrchon = ' ';
+ }
+ }
+ $datatable=''.
+ ''.&mt('LON-CAPA directory search available?').' '.
+ ''.
+ ' '.&mt('Yes').' '.
+ ' '.&mt('No').' '.
+ ' '.
+ ''.&mt('Other domains can search LON-CAPA domain?').' '.
+ ''.
+ ' '.&mt('Yes').' '.
+ ' '.&mt('No').' '.
+ ' ';
+ $$rowtotal += 2;
+ }
+ return $datatable;
+}
+
+sub print_contacts {
+ my ($position,$dom,$settings,$rowtotal) = @_;
+ my $datatable;
+ my @contacts = ('adminemail','supportemail');
+ my (%checked,%to,%otheremails,%bccemails,%includestr,%includeloc,%currfield,
+ $maxsize,$fields,$fieldtitles,$fieldoptions,$possoptions,@mailings);
+ if ($position eq 'top') {
+ if (ref($settings) eq 'HASH') {
+ foreach my $item (@contacts) {
+ if (exists($settings->{$item})) {
+ $to{$item} = $settings->{$item};
+ }
}
}
+ } elsif ($position eq 'middle') {
+ @mailings = ('errormail','packagesmail','lonstatusmail','requestsmail',
+ 'updatesmail','idconflictsmail');
+ foreach my $type (@mailings) {
+ $otheremails{$type} = '';
+ }
+ } else {
+ @mailings = ('helpdeskmail','otherdomsmail');
+ foreach my $type (@mailings) {
+ $otheremails{$type} = '';
+ }
+ $bccemails{'helpdeskmail'} = '';
+ $bccemails{'otherdomsmail'} = '';
+ $includestr{'helpdeskmail'} = '';
+ $includestr{'otherdomsmail'} = '';
+ ($fields,$fieldtitles,$fieldoptions,$possoptions) = &helpform_fields();
}
- my ($searchtitles,$titleorder) = &sorted_searchtitles();
- my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+ if (ref($settings) eq 'HASH') {
+ unless ($position eq 'top') {
+ foreach my $type (@mailings) {
+ if (exists($settings->{$type})) {
+ if (ref($settings->{$type}) eq 'HASH') {
+ foreach my $item (@contacts) {
+ if ($settings->{$type}{$item}) {
+ $checked{$type}{$item} = ' checked="checked" ';
+ }
+ }
+ $otheremails{$type} = $settings->{$type}{'others'};
+ if (($type eq 'helpdeskmail') || ($type eq 'otherdomsmail')) {
+ $bccemails{$type} = $settings->{$type}{'bcc'};
+ if ($settings->{$type}{'include'} ne '') {
+ ($includeloc{$type},$includestr{$type}) = split(/:/,$settings->{$type}{'include'},2);
+ $includestr{$type} = &unescape($includestr{$type});
+ }
+ }
+ }
+ } elsif ($type eq 'lonstatusmail') {
+ $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" ';
+ }
+ }
+ }
+ if ($position eq 'bottom') {
+ foreach my $type (@mailings) {
+ $bccemails{$type} = $settings->{$type}{'bcc'};
+ if ($settings->{$type}{'include'} ne '') {
+ ($includeloc{$type},$includestr{$type}) = split(/:/,$settings->{$type}{'include'},2);
+ $includestr{$type} = &unescape($includestr{$type});
+ }
+ }
+ if (ref($settings->{'helpform'}) eq 'HASH') {
+ if (ref($fields) eq 'ARRAY') {
+ foreach my $field (@{$fields}) {
+ $currfield{$field} = $settings->{'helpform'}{$field};
+ }
+ }
+ if (exists($settings->{'helpform'}{'maxsize'})) {
+ $maxsize = $settings->{'helpform'}{'maxsize'};
+ } else {
+ $maxsize = '1.0';
+ }
+ } else {
+ if (ref($fields) eq 'ARRAY') {
+ foreach my $field (@{$fields}) {
+ $currfield{$field} = 'yes';
+ }
+ }
+ $maxsize = '1.0';
+ }
+ }
+ } else {
+ if ($position eq 'top') {
+ $to{'supportemail'} = $Apache::lonnet::perlvar{'lonSupportEMail'};
+ $to{'adminemail'} = $Apache::lonnet::perlvar{'lonAdmEMail'};
+ $checked{'errormail'}{'adminemail'} = ' checked="checked" ';
+ $checked{'packagesmail'}{'adminemail'} = ' checked="checked" ';
+ $checked{'lonstatusmail'}{'adminemail'} = ' checked="checked" ';
+ $checked{'requestsmail'}{'adminemail'} = ' checked="checked" ';
+ $checked{'updatesmail'}{'adminemail'} = ' checked="checked" ';
+ $checked{'idconflictsmail'}{'adminemail'} = ' checked="checked" ';
+ } elsif ($position eq 'bottom') {
+ $checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" ';
+ $checked{'otherdomsmail'}{'supportemail'} = ' checked="checked" ';
+ if (ref($fields) eq 'ARRAY') {
+ foreach my $field (@{$fields}) {
+ $currfield{$field} = 'yes';
+ }
+ }
+ $maxsize = '1.0';
+ }
+ }
+ my ($titles,$short_titles) = &contact_titles();
+ my $rownum = 0;
+ my $css_class;
+ if ($position eq 'top') {
+ foreach my $item (@contacts) {
+ $css_class = $rownum%2?' class="LC_odd_row"':'';
+ $datatable .= ''.
+ ''.$titles->{$item}.
+ ' '.
+ ' ';
+ $rownum ++;
+ }
+ } elsif ($position eq 'bottom') {
+ $css_class = $rownum%2?' class="LC_odd_row"':'';
+ $datatable .= ''.
+ ''.&mt('Extra helpdesk form fields:').' '.
+ &mt('(e-mail, subject, and description always shown)').
+ ' ';
+ if ((ref($fields) eq 'ARRAY') && (ref($fieldtitles) eq 'HASH') &&
+ (ref($fieldoptions) eq 'HASH') && (ref($possoptions) eq 'HASH')) {
+ $datatable .= '';
+ }
+ $datatable .= ' '."\n";
+ $rownum ++;
+ }
+ unless ($position eq 'top') {
+ foreach my $type (@mailings) {
+ $css_class = $rownum%2?' class="LC_odd_row"':'';
+ $datatable .= ''.
+ ''.
+ $titles->{$type}.': '.
+ '';
+ if (($type eq 'helpdeskmail') || ($type eq 'otherdomsmail')) {
+ $datatable .= ''.&mt('E-mail recipient(s)').' ';
+ }
+ $datatable .= '';
+ foreach my $item (@contacts) {
+ $datatable .= ''.
+ ' '.$short_titles->{$item}.
+ ' ';
+ }
+ $datatable .= ' '.&mt('Others').': '.
+ ' ';
+ my %locchecked;
+ if (($type eq 'helpdeskmail') || ($type eq 'otherdomsmail')) {
+ foreach my $loc ('s','b') {
+ if ($includeloc{$type} eq $loc) {
+ $locchecked{$loc} = ' checked="checked"';
+ last;
+ }
+ }
+ $datatable .= ' '.&mt('Bcc:').(' 'x6).
+ ' '.
+ ''.&mt('Optional added text').' '.
+ &mt('Text automatically added to e-mail:').' '.
+ ' '.
+ ''.&mt('Location:').' '.
+ ' '.&mt('in subject').' '.
+ (' 'x2).
+ ' '.&mt('in body').' '.
+ ' ';
+ }
+ $datatable .= ' '."\n";
+ $rownum ++;
+ }
+ }
+ if ($position eq 'middle') {
+ 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;
+ } elsif ($position eq 'bottom') {
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+ my (@posstypes,%usertypeshash);
+ if (ref($types) eq 'ARRAY') {
+ @posstypes = @{$types};
+ }
+ if (@posstypes) {
+ if (ref($usertypes) eq 'HASH') {
+ %usertypeshash = %{$usertypes};
+ }
+ my @overridden;
+ my $numinrow = 4;
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'overrides'}) eq 'HASH') {
+ foreach my $key (sort(keys(%{$settings->{'overrides'}}))) {
+ if (ref($settings->{'overrides'}{$key}) eq 'HASH') {
+ push(@overridden,$key);
+ foreach my $item (@contacts) {
+ if ($settings->{'overrides'}{$key}{$item}) {
+ $checked{'override_'.$key}{$item} = ' checked="checked" ';
+ }
+ }
+ $otheremails{'override_'.$key} = $settings->{'overrides'}{$key}{'others'};
+ $bccemails{'override_'.$key} = $settings->{'overrides'}{$key}{'bcc'};
+ $includeloc{'override_'.$key} = '';
+ $includestr{'override_'.$key} = '';
+ if ($settings->{'overrides'}{$key}{'include'} ne '') {
+ ($includeloc{'override_'.$key},$includestr{'override_'.$key}) =
+ split(/:/,$settings->{'overrides'}{$key}{'include'},2);
+ $includestr{'override_'.$key} = &unescape($includestr{'override_'.$key});
+ }
+ }
+ }
+ }
+ }
+ my $customclass = 'LC_helpdesk_override';
+ my $optionsprefix = 'LC_options_helpdesk_';
- my $numinrow = 4;
- my $cansrchrow = 0;
- my $datatable=''.
- ''.&mt('Directory search available?').' '.
- ''.
- ' '.&mt('Yes').' '.
- ' '.&mt('No').' '.
- ' '.
- ''.&mt('Other domains can search?').' '.
- ''.
- ' '.&mt('Yes').' '.
- ' '.&mt('No').' '.
- ' ';
- $$rowtotal += 2;
- if (ref($usertypes) eq 'HASH') {
- if (keys(%{$usertypes}) > 0) {
- $datatable .= &users_cansearch_row($settings,$types,$usertypes,$dom,
- $numinrow,$othertitle);
- $cansrchrow = 1;
+ my $onclicktypes = "toggleHelpdeskRow(this.form,'overrides','$customclass','$optionsprefix');";
+
+ $datatable .= &insttypes_row($settings,$types,$usertypes,$dom,
+ $numinrow,$othertitle,'overrides',
+ \$rownum,$onclicktypes,$customclass);
+ $rownum ++;
+ $usertypeshash{'default'} = $othertitle;
+ foreach my $status (@posstypes) {
+ my $css_class;
+ if ($rownum%2) {
+ $css_class = 'LC_odd_row ';
+ }
+ $css_class .= $customclass;
+ my $rowid = $optionsprefix.$status;
+ my $hidden = 1;
+ my $currstyle = 'display:none';
+ if (grep(/^\Q$status\E$/,@overridden)) {
+ $currstyle = 'display:table-row';
+ $hidden = 0;
+ }
+ my $key = 'override_'.$status;
+ $datatable .= &overridden_helpdesk($checked{$key},$otheremails{$key},$bccemails{$key},
+ $includeloc{$key},$includestr{$key},$status,$rowid,
+ $usertypeshash{$status},$css_class,$currstyle,
+ \@contacts,$short_titles);
+ unless ($hidden) {
+ $rownum ++;
+ }
+ }
}
}
- if ($cansrchrow) {
+ $$rowtotal += $rownum;
+ return $datatable;
+}
+
+sub overridden_helpdesk {
+ my ($checked,$otheremails,$bccemails,$includeloc,$includestr,$type,$rowid,
+ $typetitle,$css_class,$rowstyle,$contacts,$short_titles) = @_;
+ my $class = 'LC_left_item';
+ if ($css_class) {
+ $css_class = ' class="'.$css_class.'"';
+ }
+ if ($rowid) {
+ $rowid = ' id="'.$rowid.'"';
+ }
+ if ($rowstyle) {
+ $rowstyle = ' style="'.$rowstyle.'"';
+ }
+ my ($output,$description);
+ $description = &mt('Helpdesk requests from: [_1] in this domain (overrides default)',"$typetitle ");
+ $output = ''.
+ "$description \n".
+ ''.
+ ''.&mt('E-mail recipient(s)').' '.
+ '';
+ if (ref($contacts) eq 'ARRAY') {
+ foreach my $item (@{$contacts}) {
+ my $check;
+ if (ref($checked) eq 'HASH') {
+ $check = $checked->{$item};
+ }
+ my $title;
+ if (ref($short_titles) eq 'HASH') {
+ $title = $short_titles->{$item};
+ }
+ $output .= ''.
+ ' '.$title.' ';
+ }
+ }
+ $output .= ' '.&mt('Others').': '.
+ ' ';
+ my %locchecked;
+ foreach my $loc ('s','b') {
+ if ($includeloc eq $loc) {
+ $locchecked{$loc} = ' checked="checked"';
+ last;
+ }
+ }
+ $output .= ' '.&mt('Bcc:').(' 'x6).
+ ' '.
+ ''.&mt('Optional added text').' '.
+ &mt('Text automatically added to e-mail:').' '.
+ ' '.
+ ''.&mt('Location:').' '.
+ ' '.&mt('in subject').' '.
+ (' 'x2).
+ ' '.&mt('in body').' '.
+ ' '.
+ ' '."\n";
+ return $output;
+}
+
+sub contacts_javascript {
+ return <<"ENDSCRIPT";
+
+
+
+ENDSCRIPT
+}
+
+sub print_helpsettings {
+ my ($position,$dom,$settings,$rowtotal) = @_;
+ my $confname = $dom.'-domainconfig';
+ my $formname = 'display';
+ my ($datatable,$itemcount);
+ if ($position eq 'top') {
+ $itemcount = 1;
+ my (%choices,%defaultchecked,@toggles);
+ $choices{'submitbugs'} = &mt('Display link to: [_1]?',
+ &Apache::loncommon::modal_link('http://bugs.loncapa.org',
+ &mt('LON-CAPA bug tracker'),600,500));
+ %defaultchecked = ('submitbugs' => 'on');
+ @toggles = ('submitbugs');
+ ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
+ \%choices,$itemcount);
$$rowtotal ++;
- $datatable .= '';
} else {
- $datatable .= ' ';
+ my $css_class;
+ my %existing=&Apache::lonnet::dump('roles',$dom,$confname,'rolesdef_');
+ my (%customroles,%ordered,%current);
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'adhoc'}) eq 'HASH') {
+ %current = %{$settings->{'adhoc'}};
+ }
+ }
+ my $count = 0;
+ foreach my $key (sort(keys(%existing))) {
+ if ($key=~/^rolesdef\_(\w+)$/) {
+ my $rolename = $1;
+ my (%privs,$order);
+ ($privs{'system'},$privs{'domain'},$privs{'course'}) = split(/\_/,$existing{$key});
+ $customroles{$rolename} = \%privs;
+ if (ref($current{$rolename}) eq 'HASH') {
+ $order = $current{$rolename}{'order'};
+ }
+ if ($order eq '') {
+ $order = $count;
+ }
+ $ordered{$order} = $rolename;
+ $count++;
+ }
+ }
+ my $maxnum = scalar(keys(%ordered));
+ my @roles_by_num = ();
+ foreach my $item (sort {$a <=> $b } (keys(%ordered))) {
+ push(@roles_by_num,$item);
+ }
+ my $context = 'domprefs';
+ my $crstype = 'Course';
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+ my @accesstypes = ('all','dh','da','none');
+ my ($numstatustypes,@jsarray);
+ if (ref($types) eq 'ARRAY') {
+ if (@{$types} > 0) {
+ $numstatustypes = scalar(@{$types});
+ push(@accesstypes,'status');
+ @jsarray = ('bystatus');
+ }
+ }
+ my %domhelpdesk = &Apache::lonnet::get_active_domroles($dom,['dh','da']);
+ if (keys(%domhelpdesk)) {
+ push(@accesstypes,('inc','exc'));
+ push(@jsarray,('notinc','notexc'));
+ }
+ my $hiddenstr = join("','",@jsarray);
+ my $context = 'domprefs';
+ my $crstype = 'Course';
+ my $prefix = 'helproles_';
+ my $add_class = 'LC_hidden';
+ foreach my $num (@roles_by_num) {
+ my $role = $ordered{$num};
+ my ($desc,$access,@statuses);
+ if (ref($current{$role}) eq 'HASH') {
+ $desc = $current{$role}{'desc'};
+ $access = $current{$role}{'access'};
+ if (ref($current{$role}{'insttypes'}) eq 'ARRAY') {
+ @statuses = @{$current{$role}{'insttypes'}};
+ }
+ }
+ if ($desc eq '') {
+ $desc = $role;
+ }
+ my $identifier = 'custhelp'.$num;
+ my %full=();
+ my %levels= (
+ course => {},
+ domain => {},
+ system => {},
+ );
+ my %levelscurrent=(
+ course => {},
+ domain => {},
+ system => {},
+ );
+ &Apache::lonuserutils::custom_role_privs($customroles{$role},\%full,\%levels,\%levelscurrent);
+ my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype);
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $chgstr = ' onchange="javascript:reorderHelpRoles(this.form,'."'helproles_".$num."_pos'".');"';
+ $datatable .= ' '.$role.' '.
+ '';
+ for (my $k=0; $k<=$maxnum; $k++) {
+ my $vpos = $k+1;
+ my $selstr;
+ if ($k == $num) {
+ $selstr = ' selected="selected" ';
+ }
+ $datatable .= ''.$vpos.' ';
+ }
+ $datatable .= ' '.(' 'x2).
+ ' '.
+ ' '.
+ ''.&mt('Role name').' '.
+ &mt('Name shown to users:').
+ ' '.
+ ' '.
+ &helpdeskroles_access($dom,$prefix,$num,$add_class,$current{$role},\@accesstypes,
+ $othertitle,$usertypes,$types,\%domhelpdesk).
+ ''.
+ ''.&mt('Role privileges').&adhocbutton($prefix,$num,'privs','show').' '.
+ &Apache::lonuserutils::custom_role_table($crstype,\%full,\%levels,
+ \%levelscurrent,$identifier,
+ 'LC_hidden',$prefix.$num.'_privs').
+ ' ';
+ $itemcount ++;
+ }
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $newcust = 'custhelp'.$count;
+ my (%privs,%levelscurrent);
+ my %full=();
+ my %levels= (
+ course => {},
+ domain => {},
+ system => {},
+ );
+ &Apache::lonuserutils::custom_role_privs(\%privs,\%full,\%levels,\%levelscurrent);
+ my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype);
+ my $chgstr = ' onchange="javascript:reorderHelpRoles(this.form,'."'helproles_".$count."_pos'".');"';
+ $datatable .= ''.
+ ' '."\n".
+ '';
+ for (my $k=0; $k<$maxnum+1; $k++) {
+ my $vpos = $k+1;
+ my $selstr;
+ if ($k == $maxnum) {
+ $selstr = ' selected="selected" ';
+ }
+ $datatable .= ''.$vpos.' ';
+ }
+ $datatable .= ' '."\n".
+ ' '. &mt('Add').
+ ' '.
+ ''.&mt('Role name').' '.
+ ''.
+ &mt('Internal name:').
+ ' '.
+ ' '.(' 'x4).
+ ''.
+ &mt('Name shown to users:').
+ ' '.
+ ' '.
+ &helpdeskroles_access($dom,$prefix,$count,'',undef,\@accesstypes,$othertitle,
+ $usertypes,$types,\%domhelpdesk).
+ ''.&mt('Role privileges').' '.
+ &Apache::lonuserutils::custom_role_header($context,$crstype,
+ \@templateroles,$newcust).
+ &Apache::lonuserutils::custom_role_table('Course',\%full,\%levels,
+ \%levelscurrent,$newcust).
+ ' '.
+ &helpsettings_javascript(\@roles_by_num,$maxnum,$hiddenstr,$formname).
+ ' ';
+ $count ++;
+ $$rowtotal += $count;
}
- $datatable .= ''.&mt('Supported search methods').
- ' ';
- foreach my $title (@{$titleorder}) {
- if (defined($searchtitles->{$title})) {
- my $check = ' ';
- if (ref($settings) eq 'HASH') {
- if (ref($settings->{'searchby'}) eq 'ARRAY') {
- if (grep(/^\Q$title\E$/,@{$settings->{'searchby'}})) {
- $check = ' checked="checked" ';
+ return $datatable;
+}
+
+sub adhocbutton {
+ my ($prefix,$num,$field,$visibility) = @_;
+ my %lt = &Apache::lonlocal::texthash(
+ show => 'Show details',
+ hide => 'Hide details',
+ );
+ return ''.(' 'x10).
+ ' '.(' 'x2).' '.(' 'x2);
+}
+
+sub helpsettings_javascript {
+ my ($roles_by_num,$total,$hiddenstr,$formname) = @_;
+ return unless(ref($roles_by_num) eq 'ARRAY');
+ my %html_js_lt = &Apache::lonlocal::texthash(
+ show => 'Show details',
+ hide => 'Hide details',
+ );
+ &html_escape(\%html_js_lt);
+ my $jstext = ' var helproles = Array('."'".join("','",@{$roles_by_num})."'".');'."\n";
+ return <<"ENDSCRIPT";
+
+
+ENDSCRIPT
+}
+
+sub helpdeskroles_access {
+ my ($dom,$prefix,$num,$add_class,$current,$accesstypes,$othertitle,
+ $usertypes,$types,$domhelpdesk) = @_;
+ return unless ((ref($accesstypes) eq 'ARRAY') && (ref($domhelpdesk) eq 'HASH'));
+ my %lt = &Apache::lonlocal::texthash(
+ 'rou' => 'Role usage',
+ 'whi' => 'Which helpdesk personnel may use this role?',
+ 'all' => 'All with domain helpdesk or helpdesk assistant role',
+ 'dh' => 'All with domain helpdesk role',
+ 'da' => 'All with domain helpdesk assistant role',
+ 'none' => 'None',
+ 'status' => 'Determined based on institutional status',
+ 'inc' => 'Include all, but exclude specific personnel',
+ 'exc' => 'Exclude all, but include specific personnel',
+ );
+ my %usecheck = (
+ all => ' checked="checked"',
+ );
+ my %displaydiv = (
+ status => 'none',
+ inc => 'none',
+ exc => 'none',
+ priv => 'block',
+ );
+ my $output;
+ if (ref($current) eq 'HASH') {
+ if (($current->{'access'} ne '') && ($current->{'access'} ne 'all')) {
+ if (grep(/^\Q$current->{access}\E$/,@{$accesstypes})) {
+ $usecheck{$current->{access}} = $usecheck{'all'};
+ delete($usecheck{'all'});
+ if ($current->{access} =~ /^(status|inc|exc)$/) {
+ my $access = $1;
+ $displaydiv{$access} = 'inline';
+ } elsif ($current->{access} eq 'none') {
+ $displaydiv{'priv'} = 'none';
+ }
+ }
+ }
+ }
+ $output = ''.$lt{'rou'}.' '.
+ ''.$lt{'whi'}.'
';
+ foreach my $access (@{$accesstypes}) {
+ $output .= ' '.
+ $lt{$access}.' ';
+ if ($access eq 'status') {
+ $output .= '
'.
+ &Apache::lonuserutils::adhoc_status_types($dom,$prefix,$num,$current->{$access},
+ $othertitle,$usertypes,$types).
+ '
';
+ } elsif (($access eq 'inc') && (keys(%{$domhelpdesk}) > 0)) {
+ $output .= ''.
+ &Apache::lonuserutils::adhoc_staff($access,$prefix,$num,$current->{$access},$domhelpdesk).
+ '
';
+ } elsif (($access eq 'exc') && (keys(%{$domhelpdesk}) > 0)) {
+ $output .= ''.
+ &Apache::lonuserutils::adhoc_staff($access,$prefix,$num,$current->{$access},$domhelpdesk).
+ '
';
+ }
+ $output .= '';
+ }
+ $output .= ' ';
+ return $output;
+}
+
+sub radiobutton_prefs {
+ my ($settings,$toggles,$defaultchecked,$choices,$itemcount,$onclick,
+ $additional,$align) = @_;
+ return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') &&
+ (ref($choices) eq 'HASH'));
+
+ my (%checkedon,%checkedoff,$datatable,$css_class);
+
+ foreach my $item (@{$toggles}) {
+ if ($defaultchecked->{$item} eq 'on') {
+ $checkedon{$item} = ' checked="checked" ';
+ $checkedoff{$item} = ' ';
+ } elsif ($defaultchecked->{$item} eq 'off') {
+ $checkedoff{$item} = ' checked="checked" ';
+ $checkedon{$item} = ' ';
+ }
+ }
+ if (ref($settings) eq 'HASH') {
+ foreach my $item (@{$toggles}) {
+ if ($settings->{$item} eq '1') {
+ $checkedon{$item} = ' checked="checked" ';
+ $checkedoff{$item} = ' ';
+ } elsif ($settings->{$item} eq '0') {
+ $checkedoff{$item} = ' checked="checked" ';
+ $checkedon{$item} = ' ';
+ }
+ }
+ }
+ if ($onclick) {
+ $onclick = ' onclick="'.$onclick.'"';
+ }
+ foreach my $item (@{$toggles}) {
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .=
+ ' '.
+ ''.$choices->{$item}.
+ ' ';
+ if ($align eq 'left') {
+ $datatable .= '';
+ } else {
+ $datatable .= ' ';
+ }
+ $datatable .=
+ ''.
+ ' '.&mt('Yes').
+ ' '.&mt('No').' '.
+ ' '.$additional.
+ ' '.
+ ' ';
+ $itemcount ++;
+ }
+ return ($datatable,$itemcount);
+}
+
+sub print_ltitools {
+ my ($dom,$settings,$rowtotal) = @_;
+ my $rownum = 0;
+ my $css_class;
+ my $itemcount = 1;
+ my $maxnum = 0;
+ my %ordered;
+ if (ref($settings) eq 'HASH') {
+ foreach my $item (keys(%{$settings})) {
+ if (ref($settings->{$item}) eq 'HASH') {
+ my $num = $settings->{$item}{'order'};
+ $ordered{$num} = $item;
+ }
+ }
+ }
+ my $confname = $dom.'-domainconfig';
+ my $switchserver = &check_switchserver($dom,$confname);
+ my $maxnum = scalar(keys(%ordered));
+ my $datatable;
+ my %lt = <itools_names();
+ my @courseroles = ('cc','in','ta','ep','st');
+ my @ltiroles = qw(Instructor ContentDeveloper TeachingAssistant Learner);
+ my @fields = ('fullname','firstname','lastname','email','roles','user');
+ if (keys(%ordered)) {
+ my @items = sort { $a <=> $b } keys(%ordered);
+ for (my $i=0; $i<@items; $i++) {
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $item = $ordered{$items[$i]};
+ my ($title,$key,$secret,$url,$lifetime,$imgsrc,%sigsel);
+ if (ref($settings->{$item}) eq 'HASH') {
+ $title = $settings->{$item}->{'title'};
+ $url = $settings->{$item}->{'url'};
+ $key = $settings->{$item}->{'key'};
+ $secret = $settings->{$item}->{'secret'};
+ $lifetime = $settings->{$item}->{'lifetime'};
+ my $image = $settings->{$item}->{'image'};
+ if ($image ne '') {
+ $imgsrc = ' ';
+ }
+ if ($settings->{$item}->{'sigmethod'} eq 'HMAC-256') {
+ $sigsel{'HMAC-256'} = ' selected="selected"';
+ } else {
+ $sigsel{'HMAC-SHA1'} = ' selected="selected"';
+ }
+ }
+ my $chgstr = ' onchange="javascript:reorderLTITools(this.form,'."'ltitools_".$item."'".');"';
+ $datatable .= ''
+ .'';
+ for (my $k=0; $k<=$maxnum; $k++) {
+ my $vpos = $k+1;
+ my $selstr;
+ if ($k == $i) {
+ $selstr = ' selected="selected" ';
+ }
+ $datatable .= ''.$vpos.' ';
+ }
+ $datatable .= ' '.(' 'x2).
+ ' '.
+ &mt('Delete?').' '.
+ ''.
+ ''.&mt('Required settings').' '.
+ ''.$lt{'title'}.': '.
+ (' 'x2).
+ ''.$lt{'version'}.':'.
+ '1.1 '.
+ (' 'x2).
+ ''.$lt{'msgtype'}.':'.
+ 'Launch '.
+ (' 'x2).
+ ''.$lt{'sigmethod'}.':'.
+ 'HMAC-SHA1 '.
+ 'HMAC-SHA256 '.
+ ' '.
+ ''.$lt{'url'}.': '.
+ (' 'x2).
+ ''.$lt{'key'}.':'.
+ ' '.
+ (' 'x2).
+ ''.$lt{'lifetime'}.':'.
+ ' '.
+ (' 'x2).
+ ''.$lt{'secret'}.':'.
+ ' '.
+ ' '.&mt('Visible input').' '.
+ ' '.
+ ' '.
+ ''.&mt('Optional settings').' '.
+ ''.&mt('Display target:');
+ my %currdisp;
+ if (ref($settings->{$item}->{'display'}) eq 'HASH') {
+ if ($settings->{$item}->{'display'}->{'target'} eq 'window') {
+ $currdisp{'window'} = ' checked="checked"';
+ } elsif ($settings->{$item}->{'display'}->{'target'} eq 'tab') {
+ $currdisp{'tab'} = ' checked="checked"';
+ } else {
+ $currdisp{'iframe'} = ' checked="checked"';
+ }
+ if ($settings->{$item}->{'display'}->{'width'} =~ /^(\d+)$/) {
+ $currdisp{'width'} = $1;
+ }
+ if ($settings->{$item}->{'display'}->{'height'} =~ /^(\d+)$/) {
+ $currdisp{'height'} = $1;
+ }
+ $currdisp{'linktext'} = $settings->{$item}->{'display'}->{'linktext'};
+ $currdisp{'explanation'} = $settings->{$item}->{'display'}->{'explanation'};
+ } else {
+ $currdisp{'iframe'} = ' checked="checked"';
+ }
+ foreach my $disp ('iframe','tab','window') {
+ $datatable .= ' '.
+ $lt{$disp}.' '.(' 'x2);
+ }
+ $datatable .= (' 'x4);
+ foreach my $dimen ('width','height') {
+ $datatable .= ''.$lt{$dimen}.' '.
+ ' '.
+ (' 'x2);
+ }
+ $datatable .= ' '.
+ ''.$lt{'linktext'}.' '.
+ '
'.
+ ''.$lt{'explanation'}.' '.
+ '
';
+ my %units = (
+ 'passback' => 'days',
+ 'roster' => 'seconds',
+ );
+ foreach my $extra ('passback','roster') {
+ my $validsty = 'none';
+ my $currvalid;
+ my $checkedon = '';
+ my $checkedoff = ' checked="checked"';
+ if ($settings->{$item}->{$extra}) {
+ $checkedon = $checkedoff;
+ $checkedoff = '';
+ $validsty = 'inline-block';
+ if ($settings->{$item}->{$extra.'valid'} =~ /^\d+\.?\d*$/) {
+ $currvalid = $settings->{$item}->{$extra.'valid'};
+ }
+ }
+ my $onclick = ' onclick="toggleLTITools(this.form,'."'$extra','$i'".');"';
+ $datatable .= ''.$lt{$extra}.' '.
+ ' '.
+ &mt('No').' '.(' 'x2).
+ ' '.
+ &mt('Yes').'
'.
+ '
';
+ }
+ $datatable .= ''.$lt{'icon'}.': ';
+ if ($imgsrc) {
+ $datatable .= $imgsrc.
+ ' '.&mt('Delete?').' '.
+ ' '.&mt('Replace:').' ';
+ } else {
+ $datatable .= '('.&mt('if larger than 21x21 pixels, image will be scaled').') ';
+ }
+ if ($switchserver) {
+ $datatable .= &mt('Upload to library server: [_1]',$switchserver);
+ } else {
+ $datatable .= ' ';
+ }
+ $datatable .= ' ';
+ my (%checkedfields,%rolemaps,$userincdom);
+ if (ref($settings->{$item}) eq 'HASH') {
+ if (ref($settings->{$item}->{'fields'}) eq 'HASH') {
+ %checkedfields = %{$settings->{$item}->{'fields'}};
+ }
+ $userincdom = $settings->{$item}->{'incdom'};
+ if (ref($settings->{$item}->{'roles'}) eq 'HASH') {
+ %rolemaps = %{$settings->{$item}->{'roles'}};
+ $checkedfields{'roles'} = 1;
+ }
+ }
+ $datatable .= ''.&mt('User data sent on launch').' '.
+ '';
+ my $userfieldstyle = 'display:none;';
+ my $seluserdom = '';
+ my $unseluserdom = ' selected="selected"';
+ foreach my $field (@fields) {
+ my ($checked,$onclick,$id,$spacer);
+ if ($checkedfields{$field}) {
+ $checked = ' checked="checked"';
+ }
+ if ($field eq 'user') {
+ $id = ' id="ltitools_user_field_'.$i.'"';
+ $onclick = ' onclick="toggleLTITools(this.form,'."'$field','$i'".')"';
+ if ($checked) {
+ $userfieldstyle = 'display:inline-block';
+ if ($userincdom) {
+ $seluserdom = $unseluserdom;
+ $unseluserdom = '';
+ }
}
+ } else {
+ $spacer = (' ' x2);
}
+ $datatable .= ''.
+ ' '.
+ $lt{$field}.' '.$spacer;
+ }
+ $datatable .= ' ';
+ $datatable .= ''.
+ ' : '.
+ ''.
+ ''.&mt('Select').' '.
+ ''.&mt('username').' '.
+ ''.&mt('username:domain').' '.
+ '
';
+ $datatable .= ' '.
+ ''.&mt('Role mapping').' ';
+ my %courseconfig;
+ if (ref($settings->{$item}) eq 'HASH') {
+ if (ref($settings->{$item}->{'crsconf'}) eq 'HASH') {
+ %courseconfig = %{$settings->{$item}->{'crsconf'}};
+ }
+ }
+ $datatable .= ''.&mt('Configurable in course').' ';
+ foreach my $item ('label','title','target','linktext','explanation','append') {
+ my $checked;
+ if ($courseconfig{$item}) {
+ $checked = ' checked="checked"';
+ }
+ $datatable .= ''.
+ ' '.
+ $lt{'crs'.$item}.' '.(' ' x2)."\n";
+ }
+ $datatable .= ' '.
+ ''.&mt('Custom items sent on launch').' '.
+ ' '."\n";
+ $itemcount ++;
}
}
- $datatable .= '
';
- $$rowtotal ++;
- if ($cansrchrow) {
- $datatable .= '';
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $chgstr = ' onchange="javascript:reorderLTITools(this.form,'."'ltitools_add_pos'".');"';
+ $datatable .= ' '."\n".
+ ' '."\n".
+ '';
+ for (my $k=0; $k<$maxnum+1; $k++) {
+ my $vpos = $k+1;
+ my $selstr;
+ if ($k == $maxnum) {
+ $selstr = ' selected="selected" ';
+ }
+ $datatable .= ''.$vpos.' ';
+ }
+ $datatable .= ' '."\n".
+ ' '.&mt('Add').' '."\n".
+ ''.
+ ''.&mt('Required settings').' '.
+ ''.$lt{'title'}.': '."\n".
+ (' 'x2).
+ ''.$lt{'version'}.':'.
+ '1.1 '."\n".
+ (' 'x2).
+ ''.$lt{'msgtype'}.':'.
+ 'Launch '.
+ ''.$lt{'sigmethod'}.':'.
+ 'HMAC-SHA1 '.
+ 'HMAC-SHA256 '.
+ ' '.
+ ''.$lt{'url'}.': '."\n".
+ (' 'x2).
+ ''.$lt{'key'}.': '."\n".
+ (' 'x2).
+ ''.$lt{'lifetime'}.': '."\n".
+ (' 'x2).
+ ''.$lt{'secret'}.': '.
+ ' '.&mt('Visible input').' '."\n".
+ ' '.
+ ''.&mt('Optional settings').' '.
+ ''.&mt('Display target:');
+ my %defaultdisp;
+ $defaultdisp{'iframe'} = ' checked="checked"';
+ foreach my $disp ('iframe','tab','window') {
+ $datatable .= ' '.
+ $lt{$disp}.' '.(' 'x2);
+ }
+ $datatable .= (' 'x4);
+ foreach my $dimen ('width','height') {
+ $datatable .= ''.$lt{$dimen}.' '.
+ ' '.
+ (' 'x2);
+ }
+ $datatable .= ' '.
+ ''.$lt{'linktext'}.' '.
+ '
'.
+ ''.$lt{'explanation'}.' '.
+ ''.
+ '
';
+ my %units = (
+ 'passback' => 'days',
+ 'roster' => 'seconds',
+ );
+ my %defaulttimes = (
+ 'passback' => '7',
+ 'roster' => '300',
+ );
+ foreach my $extra ('passback','roster') {
+ my $onclick = ' onclick="toggleLTITools(this.form,'."'$extra','add'".');"';
+ $datatable .= ''.$lt{$extra}.' '.
+ ' '.
+ &mt('No').' '.(' 'x2).''.
+ ' '.
+ &mt('Yes').'
'.
+ '
';
+ }
+ $datatable .= ''.$lt{'icon'}.': '.
+ '('.&mt('if larger than 21x21 pixels, image will be scaled').') ';
+ if ($switchserver) {
+ $datatable .= &mt('Upload to library server: [_1]',$switchserver);
} else {
- $datatable .= '';
+ $datatable .= ' ';
}
- $datatable .= ''.&mt('Search latitude').' '.
- ''.
- ''.
- ' '.&mt('Exact match').
- ' '.
- ' '.&mt('Begins with').
- ' '.
- ' '.&mt('Contains').
- ' ';
- $$rowtotal ++;
+ $datatable .= ' '.
+ ''.&mt('User data sent on launch').' '.
+ '';
+ foreach my $field (@fields) {
+ my ($id,$onclick,$spacer);
+ if ($field eq 'user') {
+ $id = ' id="ltitools_user_field_add"';
+ $onclick = ' onclick="toggleLTITools(this.form,'."'$field','add'".')"';
+ } else {
+ $spacer = (' ' x2);
+ }
+ $datatable .= ''.
+ ' '.
+ $lt{$field}.' '.$spacer;
+ }
+ $datatable .= ' '.
+ ''.
+ ' : '.
+ ''.
+ ''.&mt('Select').' '.
+ ''.&mt('username').' '.
+ ''.&mt('username:domain').' '.
+ '
';
+ $datatable .= ''.&mt('Role mapping').' ';
+ foreach my $role (@courseroles) {
+ my ($checked,$checkednone);
+ $datatable .= ''.
+ &Apache::lonnet::plaintext($role,'Course').' '.
+ ''.
+ ''.&mt('Select').' ';
+ foreach my $ltirole (@ltiroles) {
+ $datatable .= ''.$ltirole.' ';
+ }
+ $datatable .= ' ';
+ }
+ $datatable .= '
'.
+ ''.&mt('Configurable in course').' ';
+ foreach my $item ('label','title','target','linktext','explanation','append') {
+ $datatable .= ''.
+ ' '.
+ $lt{'crs'.$item}.' '.(' ' x2)."\n";
+ }
+ $datatable .= ' '.
+ ''.&mt('Custom items sent on launch').' '.
+ ' '."\n".
+ ' '."\n".
+ ' '."\n";
+ $itemcount ++;
return $datatable;
}
-sub print_contacts {
+sub ltitools_names {
+ my %lt = &Apache::lonlocal::texthash(
+ 'title' => 'Title',
+ 'version' => 'Version',
+ 'msgtype' => 'Message Type',
+ 'sigmethod' => 'Signature Method',
+ 'url' => 'URL',
+ 'key' => 'Key',
+ 'lifetime' => 'Nonce lifetime (s)',
+ 'secret' => 'Secret',
+ 'icon' => 'Icon',
+ 'user' => 'User',
+ 'fullname' => 'Full Name',
+ 'firstname' => 'First Name',
+ 'lastname' => 'Last Name',
+ 'email' => 'E-mail',
+ 'roles' => 'Role',
+ 'window' => 'Window',
+ 'tab' => 'Tab',
+ 'iframe' => 'iFrame',
+ 'height' => 'Height',
+ 'width' => 'Width',
+ 'linktext' => 'Default Link Text',
+ 'explanation' => 'Default Explanation',
+ 'passback' => 'Tool can return grades:',
+ 'roster' => 'Tool can retrieve roster:',
+ 'crstarget' => 'Display target',
+ 'crslabel' => 'Course label',
+ 'crstitle' => 'Course title',
+ 'crslinktext' => 'Link Text',
+ 'crsexplanation' => 'Explanation',
+ 'crsappend' => 'Provider URL',
+ );
+ return %lt;
+}
+
+sub print_lti {
my ($dom,$settings,$rowtotal) = @_;
+ my $itemcount = 1;
+ my $maxnum = 0;
+ my $css_class;
+ my %ordered;
+ if (ref($settings) eq 'HASH') {
+ foreach my $item (keys(%{$settings})) {
+ if (ref($settings->{$item}) eq 'HASH') {
+ my $num = $settings->{$item}{'order'};
+ $ordered{$num} = $item;
+ }
+ }
+ }
+ my $maxnum = scalar(keys(%ordered));
my $datatable;
- my @contacts = ('adminemail','supportemail');
- my (%checked,%to,%otheremails);
- my @mailings = ('errormail','packagesmail','helpdeskmail');
- foreach my $type (@mailings) {
- $otheremails{$type} = '';
+ my %lt = <i_names();
+ if (keys(%ordered)) {
+ my @items = sort { $a <=> $b } keys(%ordered);
+ for (my $i=0; $i<@items; $i++) {
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $item = $ordered{$items[$i]};
+ my ($key,$secret,$lifetime,$consumer,$current);
+ if (ref($settings->{$item}) eq 'HASH') {
+ $key = $settings->{$item}->{'key'};
+ $secret = $settings->{$item}->{'secret'};
+ $lifetime = $settings->{$item}->{'lifetime'};
+ $consumer = $settings->{$item}->{'consumer'};
+ $current = $settings->{$item};
+ }
+ my $chgstr = ' onchange="javascript:reorderLTI(this.form,'."'lti_pos_".$item."'".');"';
+ $datatable .= ''
+ .'';
+ for (my $k=0; $k<=$maxnum; $k++) {
+ my $vpos = $k+1;
+ my $selstr;
+ if ($k == $i) {
+ $selstr = ' selected="selected" ';
+ }
+ $datatable .= ''.$vpos.' ';
+ }
+ $datatable .= ' '.(' 'x2).
+ ' '.
+ &mt('Delete?').' '.
+ ''.
+ ''.&mt('Required settings').' '.
+ ''.$lt{'consumer'}.
+ ': '.
+ (' 'x2).
+ ''.$lt{'version'}.':'.
+ '1.1 '.
+ (' 'x2).
+ ''.$lt{'lifetime'}.': '.
+ ' '.
+ ''.$lt{'key'}.
+ ': '.
+ (' 'x2).
+ ''.$lt{'secret'}.':'.
+ ' '.
+ ' '.&mt('Visible input').' '.
+ ' '.
+ ' '.<i_options($i,$current,$itemcount,%lt).' ';
+ $itemcount ++;
+ }
}
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $chgstr = ' onchange="javascript:reorderLTI(this.form,'."'lti_pos_add'".');"';
+ $datatable .= ''."\n".
+ ' '."\n".
+ '';
+ for (my $k=0; $k<$maxnum+1; $k++) {
+ my $vpos = $k+1;
+ my $selstr;
+ if ($k == $maxnum) {
+ $selstr = ' selected="selected" ';
+ }
+ $datatable .= ''.$vpos.' ';
+ }
+ $datatable .= ' '."\n".
+ ' '.&mt('Add').' '."\n".
+ ''.
+ ''.&mt('Required settings').' '.
+ ''.$lt{'consumer'}.
+ ': '."\n".
+ (' 'x2).
+ ''.$lt{'version'}.':'.
+ '1.1 '."\n".
+ (' 'x2).
+ ''.$lt{'lifetime'}.': '."\n".
+ ' '.
+ ''.$lt{'key'}.': '."\n".
+ (' 'x2).
+ ''.$lt{'secret'}.': '.
+ ' '.&mt('Visible input').' '."\n".
+ ' '.<i_options('add',undef,$itemcount,%lt).
+ ' '."\n".
+ ' '."\n";
+ $$rowtotal ++;
+ return $datatable;;
+}
+
+sub lti_names {
+ my %lt = &Apache::lonlocal::texthash(
+ 'version' => 'LTI Version',
+ 'url' => 'URL',
+ 'key' => 'Key',
+ 'lifetime' => 'Nonce lifetime (s)',
+ 'consumer' => 'LTI Consumer',
+ 'secret' => 'Secret',
+ 'email' => 'Email address',
+ 'sourcedid' => 'User ID',
+ 'other' => 'Other',
+ 'passback' => 'Can return grades to Consumer:',
+ 'roster' => 'Can retrieve roster from Consumer:',
+ 'topmenu' => 'Display LON-CAPA page header',
+ 'inlinemenu'=> 'Display LON-CAPA inline menu',
+ );
+ return %lt;
+}
+
+sub lti_options {
+ my ($num,$current,$itemcount,%lt) = @_;
+ my (%checked,%rolemaps,$crssecsrc,$userfield,$cidfield);
+ $checked{'mapuser'}{'sourcedid'} = ' checked="checked"';
+ $checked{'mapcrs'}{'course_offering_sourcedid'} = ' checked="checked"';
+ $checked{'makecrs'}{'N'} = ' checked="checked"';
+ $checked{'mapcrstype'} = {};
+ $checked{'makeuser'} = {};
+ $checked{'selfenroll'} = {};
+ $checked{'crssec'} = {};
+ $checked{'crssecsrc'} = {};
+ $checked{'lcauth'} = {};
+ $checked{'menuitem'} = {};
+ if ($num eq 'add') {
+ $checked{'lcauth'}{'lti'} = ' checked="checked"';
+ }
+ my $userfieldsty = 'none';
+ my $crsfieldsty = 'none';
+ my $crssecfieldsty = 'none';
+ my $secsrcfieldsty = 'none';
+ my $passbacksty = 'none';
+ my $lcauthparm;
+ my $lcauthparmstyle = 'display:none';
+ my $lcauthparmtext;
+ my $menusty;
+ my $numinrow = 4;
+ my %menutitles = <imenu_titles();
+
+ if (ref($current) eq 'HASH') {
+ if (($current->{'mapuser'} ne '') && ($current->{'mapuser'} ne 'lis_person_sourcedid')) {
+ $checked{'mapuser'}{'sourcedid'} = '';
+ if ($current->{'mapuser'} eq 'lis_person_contact_email_primary') {
+ $checked{'mapuser'}{'email'} = ' checked="checked"';
+ } else {
+ $checked{'mapuser'}{'other'} = ' checked="checked"';
+ $userfield = $current->{'mapuser'};
+ $userfieldsty = 'inline-block';
+ }
+ }
+ if (($current->{'mapcrs'} ne '') && ($current->{'mapcrs'} ne 'course_offering_sourcedid')) {
+ $checked{'mapcrs'}{'course_offering_sourcedid'} = '';
+ if ($current->{'mapcrs'} eq 'context_id') {
+ $checked{'mapcrs'}{'context_id'} = ' checked="checked"';
+ } else {
+ $checked{'mapcrs'}{'other'} = ' checked="checked"';
+ $cidfield = $current->{'mapcrs'};
+ $crsfieldsty = 'inline-block';
+ }
+ }
+ if (ref($current->{'mapcrstype'}) eq 'ARRAY') {
+ foreach my $type (@{$current->{'mapcrstype'}}) {
+ $checked{'mapcrstype'}{$type} = ' checked="checked"';
+ }
+ }
+ if ($current->{'makecrs'}) {
+ $checked{'makecrs'}{'Y'} = ' checked="checked"';
+ }
+ if (ref($current->{'makeuser'}) eq 'ARRAY') {
+ foreach my $role (@{$current->{'makeuser'}}) {
+ $checked{'makeuser'}{$role} = ' checked="checked"';
+ }
+ }
+ if ($current->{'lcauth'} =~ /^(internal|localauth|krb4|krb5|lti)$/) {
+ $checked{'lcauth'}{$1} = ' checked="checked"';
+ unless (($current->{'lcauth'} eq 'lti') || ($current->{'lcauth'} eq 'internal')) {
+ $lcauthparm = $current->{'lcauthparm'};
+ $lcauthparmstyle = 'display:table-row';
+ if ($current->{'lcauth'} eq 'localauth') {
+ $lcauthparmtext = &mt('Local auth argument');
+ } else {
+ $lcauthparmtext = &mt('Kerberos domain');
+ }
+ }
+ }
+ if (ref($current->{'selfenroll'}) eq 'ARRAY') {
+ foreach my $role (@{$current->{'selfenroll'}}) {
+ $checked{'selfenroll'}{$role} = ' checked="checked"';
+ }
+ }
+ if (ref($current->{'maproles'}) eq 'HASH') {
+ %rolemaps = %{$current->{'maproles'}};
+ }
+ if ($current->{'section'} ne '') {
+ $checked{'crssec'}{'Y'} = ' checked="checked"';
+ $crssecfieldsty = 'inline-block';
+ if ($current->{'section'} eq 'course_section_sourcedid') {
+ $checked{'crssecsrc'}{'sourcedid'} = ' checked="checked"';
+ } else {
+ $checked{'crssecsrc'}{'other'} = ' checked="checked"';
+ $crssecsrc = $current->{'section'};
+ $secsrcfieldsty = 'inline-block';
+ }
+ } else {
+ $checked{'crssec'}{'N'} = ' checked="checked"';
+ }
+ if ($current->{'topmenu'}) {
+ $checked{'topmenu'}{'Y'} = ' checked="checked"';
+ } else {
+ $checked{'topmenu'}{'N'} = ' checked="checked"';
+ }
+ if ($current->{'inlinemenu'}) {
+ $checked{'inlinemenu'}{'Y'} = ' checked="checked"';
+ } else {
+ $checked{'inlinemenu'}{'N'} = ' checked="checked"';
+ }
+ if (($current->{'topmenu'}) || ($current->{'inlinemenu'})) {
+ $menusty = 'inline-block';
+ if (ref($current->{'lcmenu'}) eq 'ARRAY') {
+ foreach my $item (@{$current->{'lcmenu'}}) {
+ if (exists($menutitles{$item})) {
+ $checked{'menuitem'}{$item} = ' checked="checked"';
+ }
+ }
+ }
+ } else {
+ $menusty = 'none';
+ }
+ } else {
+ $checked{'makecrs'}{'N'} = ' checked="checked"';
+ $checked{'crssec'}{'N'} = ' checked="checked"';
+ $checked{'topmenu'}{'N'} = ' checked="checked"';
+ $checked{'inlinemenu'}{'Y'} = ' checked="checked"';
+ $checked{'menuitem'}{'grades'} = ' checked="checked"';
+ $menusty = 'inline-block';
+ }
+ my @coursetypes = ('official','unofficial','community','textbook','placement','lti');
+ my %coursetypetitles = &Apache::lonlocal::texthash (
+ official => 'Official',
+ unofficial => 'Unofficial',
+ community => 'Community',
+ textbook => 'Textbook',
+ placement => 'Placement Test',
+ lti => 'LTI Provider',
+ );
+ my @authtypes = ('internal','krb4','krb5','localauth');
+ my %shortauth = (
+ internal => 'int',
+ krb4 => 'krb4',
+ krb5 => 'krb5',
+ localauth => 'loc'
+ );
+ my %authnames = &authtype_names();
+ my @ltiroles = qw(Learner Instructor ContentDeveloper TeachingAssistant Mentor Member Manager Administrator);
+ my @lticourseroles = qw(Learner Instructor TeachingAssistant Mentor);
+ my @courseroles = ('cc','in','ta','ep','st');
+ my $onclickuser = ' onclick="toggleLTI(this.form,'."'user','$num'".');"';
+ my $onclickcrs = ' onclick="toggleLTI(this.form,'."'crs','$num'".');"';
+ my $onclicksec = ' onclick="toggleLTI(this.form,'."'sec','$num'".');"';
+ my $onclicksecsrc = ' onclick="toggleLTI(this.form,'."'secsrc','$num'".')"';
+ my $onclicklcauth = ' onclick="toggleLTI(this.form,'."'lcauth','$num'".')"';
+ my $onclickmenu = ' onclick="toggleLTI(this.form,'."'lcmenu','$num'".');"';
+ my $output = ''.&mt('Mapping users').' '.
+ ''.&mt('LON-CAPA username').': ';
+ foreach my $option ('sourcedid','email','other') {
+ $output .= ' '.$lt{$option}.' '.
+ ($option eq 'other' ? '' : (' 'x2) );
+ }
+ $output .= '
'.
+ ''.
+ '
'.
+ ''.&mt('Mapping course roles').' ';
+ foreach my $ltirole (@lticourseroles) {
+ my ($selected,$selectnone);
+ if ($rolemaps{$ltirole} eq '') {
+ $selectnone = ' selected="selected"';
+ }
+ $output .= ''.$ltirole.' '.
+ ''.
+ ''.&mt('Select').' ';
+ foreach my $role (@courseroles) {
+ unless ($selectnone) {
+ if ($rolemaps{$ltirole} eq $role) {
+ $selected = ' selected="selected"';
+ } else {
+ $selected = '';
+ }
+ }
+ $output .= ''.
+ &Apache::lonnet::plaintext($role,'Course').
+ ' ';
+ }
+ $output .= ' ';
+ }
+ $output .= '
'.
+ ''.&mt('Roles which may create user accounts').' ';
+ foreach my $ltirole (@ltiroles) {
+ $output .= ' '.$ltirole.' ';
+ }
+ $output .= ' '.
+ ''.&mt('New user accounts created for LTI users').' '.
+ ''.
+ &modifiable_userdata_row('lti','instdata_'.$num,$current,$numinrow,$itemcount).
+ '
'.
+ ' '.
+ ''.&mt('Mapping courses').' '.
+ ''.
+ &mt('Unique course identifier').': ';
+ foreach my $option ('course_offering_sourcedid','context_id','other') {
+ $output .= ' '.$option.' '.
+ ($option eq 'other' ? '' : (' 'x2) );
+ }
+ $output .= '
'.
+ ' '.
+ '
'.
+ ''.&mt('LON-CAPA course type(s)').': ';
+ foreach my $type (@coursetypes) {
+ $output .= ' '.$coursetypetitles{$type}.' '.
+ (' 'x2);
+ }
+ $output .= ' '.
+ ''.&mt('Creating courses').' '.
+ ''.&mt('Course created (if absent) on Instructor access').': '.
+ ' '.&mt('No').' '.(' 'x2).
+ ' '.&mt('Yes').' '.
+ ' '.
+ ''.&mt('Roles which may self-enroll').' ';
+ foreach my $lticrsrole (@lticourseroles) {
+ $output .= ' '.$lticrsrole.' ';
+ }
+ $output .= ' '.
+ ''.&mt('Course options').' '.
+ ''.&mt('Assign users to sections').': '.
+ ' '.&mt('No').' '.(' 'x2).
+ ' '.&mt('Yes').'
'.
+ ''.
+ ' '.
+ '
';
+ my ($pb1p1chk,$pb1p0chk,$onclickpb);
+ foreach my $extra ('roster','passback') {
+ my $checkedon = '';
+ my $checkedoff = ' checked="checked"';
+ if ($extra eq 'passback') {
+ $pb1p1chk = ' checked="checked"';
+ $pb1p0chk = '';
+ $onclickpb = ' onclick="toggleLTI(this.form,'."'passback','$num'".');"';
+ } else {
+ $onclickpb = '';
+ }
+ if (ref($current) eq 'HASH') {
+ if (($current->{$extra})) {
+ $checkedon = $checkedoff;
+ $checkedoff = '';
+ if ($extra eq 'passback') {
+ $passbacksty = 'inline-block';
+ }
+ if ($current->{'passbackformat'} eq '1.0') {
+ $pb1p0chk = ' checked="checked"';
+ $pb1p1chk = '';
+ }
+ }
+ }
+ $output .= $lt{$extra}.' '.
+ ' '.
+ &mt('No').' '.(' 'x2).
+ ' '.
+ &mt('Yes').' ';
+ }
+ $output .= ''.
+ ''.&mt('Grade format').
+ ' '.
+ &mt('Outcomes Service (1.1)').' '.(' 'x2).
+ ' '.
+ &mt('Outcomes Extension (1.0)').'
'.
+ ''.&mt('Course defaults (Course Coordinator can override)').' '.
+ ''.$lt{'topmenu'}.': '.
+ ' '.&mt('No').' '.(' 'x2).
+ ' '.&mt('Yes').'
'.
+ '
'.
+ ''.$lt{'inlinemenu'}.': '.
+ ' '.&mt('No').' '.(' 'x2).
+ ' '.&mt('Yes').'
';
+ $output .='
'.
+ ' ';
+# ''.&mt('Assigning author roles').' ';
+#
+# $output .= ' '.
+# ''.&mt('Assigning domain roles').' ';
+ return $output;
+}
+
+sub ltimenu_titles {
+ return &Apache::lonlocal::texthash(
+ fullname => 'Full name',
+ coursetitle => 'Course title',
+ role => 'Role',
+ logout => 'Logout',
+ grades => 'Grades',
+ );
+}
+
+sub print_coursedefaults {
+ my ($position,$dom,$settings,$rowtotal) = @_;
+ my ($css_class,$datatable,%checkedon,%checkedoff,%defaultchecked,@toggles);
+ my $itemcount = 1;
+ my %choices = &Apache::lonlocal::texthash (
+ canuse_pdfforms => 'Course/Community users can create/upload PDF forms',
+ uploadquota => 'Default quota for files uploaded directly to course/community using Course Editor (MB)',
+ anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys',
+ coursecredits => 'Credits can be specified for courses',
+ uselcmath => 'Math preview uses LON-CAPA previewer (javascript) in place of DragMath (Java)',
+ usejsme => 'Molecule editor uses JSME (HTML5) in place of JME (Java)',
+ texengine => 'Default method to display mathematics',
+ postsubmit => 'Disable submit button/keypress following student submission',
+ canclone => "People who may clone a course (besides course's owner and coordinators)",
+ mysqltables => 'Lifetime (s) of "Temporary" MySQL tables (student performance data) on homeserver',
+ );
+ my %staticdefaults = (
+ texengine => 'MathJax',
+ anonsurvey_threshold => 10,
+ uploadquota => 500,
+ postsubmit => 60,
+ mysqltables => 172800,
+ );
+ if ($position eq 'top') {
+ %defaultchecked = (
+ 'canuse_pdfforms' => 'off',
+ 'uselcmath' => 'on',
+ 'usejsme' => 'on',
+ 'canclone' => 'none',
+ );
+ @toggles = ('canuse_pdfforms','uselcmath','usejsme');
+ my $deftex = $staticdefaults{'texengine'};
+ if (ref($settings) eq 'HASH') {
+ if ($settings->{'texengine'}) {
+ if ($settings->{'texengine'} =~ /^(MathJax|mimetex|tth)$/) {
+ $deftex = $settings->{'texengine'};
+ }
+ }
+ }
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $mathdisp = ''.
+ ''.$choices{'texengine'}.
+ ' '.
+ ''."\n";
+ my %texoptions = (
+ MathJax => 'MathJax',
+ mimetex => &mt('Convert to Images'),
+ tth => &mt('TeX to HTML'),
+ );
+ foreach my $renderer ('MathJax','mimetex','tth') {
+ my $selected = '';
+ if ($renderer eq $deftex) {
+ $selected = ' selected="selected"';
+ }
+ $mathdisp .= ''.$texoptions{$renderer}.' '."\n";
+ }
+ $mathdisp .= ' '."\n";
+ $itemcount ++;
+ ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
+ \%choices,$itemcount);
+ $datatable = $mathdisp.$datatable;
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .=
+ ''.
+ ''.$choices{'canclone'}.
+ ' ';
+ my $currcanclone = 'none';
+ my $onclick;
+ my @cloneoptions = ('none','domain');
+ my %clonetitles = (
+ none => 'No additional course requesters',
+ domain => "Any course requester in course's domain",
+ instcode => 'Course requests for official courses ...',
+ );
+ my (%codedefaults,@code_order,@posscodes);
+ if (&Apache::lonnet::auto_instcode_defaults($dom,\%codedefaults,
+ \@code_order) eq 'ok') {
+ if (@code_order > 0) {
+ push(@cloneoptions,'instcode');
+ $onclick = ' onclick="toggleDisplay(this.form,'."'cloneinstcode'".');"';
+ }
+ }
+ if (ref($settings) eq 'HASH') {
+ if ($settings->{'canclone'}) {
+ if (ref($settings->{'canclone'}) eq 'HASH') {
+ if (ref($settings->{'canclone'}{'instcode'}) eq 'ARRAY') {
+ if (@code_order > 0) {
+ $currcanclone = 'instcode';
+ @posscodes = @{$settings->{'canclone'}{'instcode'}};
+ }
+ }
+ } elsif ($settings->{'canclone'} eq 'domain') {
+ $currcanclone = $settings->{'canclone'};
+ }
+ }
+ }
+ foreach my $option (@cloneoptions) {
+ my ($checked,$additional);
+ if ($currcanclone eq $option) {
+ $checked = ' checked="checked"';
+ }
+ if ($option eq 'instcode') {
+ if (@code_order) {
+ my $show = 'none';
+ if ($checked) {
+ $show = 'block';
+ }
+ $additional = '
'.
+ &mt('Institutional codes for new and cloned course have identical:').
+ ' ';
+ foreach my $item (@code_order) {
+ my $codechk;
+ if ($checked) {
+ if (grep(/^\Q$item\E$/,@posscodes)) {
+ $codechk = ' checked="checked"';
+ }
+ }
+ $additional .= ''.
+ ' '.
+ $item.' ';
+ }
+ $additional .= (' 'x2).'('.&mt('check as many as needed').')';
+ }
+ }
+ $datatable .=
+ ' '.$clonetitles{$option}.
+ ' '.$additional.' ';
+ }
+ $datatable .= ' '.
+ ' ';
+ $itemcount ++;
+ } else {
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ my ($currdefresponder,%defcredits,%curruploadquota,%deftimeout,%currmysql);
+ my $currusecredits = 0;
+ my $postsubmitclient = 1;
+ my @types = ('official','unofficial','community','textbook','placement');
+ 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 (ref($settings->{'mysqltables'}) eq 'HASH') {
+ foreach my $type (keys(%{$settings->{'mysqltables'}})) {
+ $currmysql{$type} = $settings->{'mysqltables'}{$type};
+ }
+ } else {
+ foreach my $type (@types) {
+ $currmysql{$type} = $staticdefaults{'mysqltables'};
+ }
+ }
+ } else {
+ foreach my $type (@types) {
+ $deftimeout{$type} = $staticdefaults{'postsubmit'};
+ }
+ }
+ if (!$currdefresponder) {
+ $currdefresponder = $staticdefaults{'anonsurvey_threshold'};
+ } elsif ($currdefresponder < 1) {
+ $currdefresponder = 1;
+ }
+ foreach my $type (@types) {
+ if ($curruploadquota{$type} eq '') {
+ $curruploadquota{$type} = $staticdefaults{'uploadquota'};
+ }
+ }
+ $datatable .=
+ ''.
+ $choices{'anonsurvey_threshold'}.
+ ' '.
+ ''.
+ ' '.
+ ' '."\n";
+ $itemcount ++;
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .= ''.
+ $choices{'uploadquota'}.
+ ' '.
+ ''.
+ ' '."\n";
+ $itemcount ++;
+ my $onclick = "toggleDisplay(this.form,'credits');";
+ my $display = 'none';
+ if ($currusecredits) {
+ $display = 'block';
+ }
+ my $additional = ''.
+ '
'.&mt('Default credits').' '."\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').'
'.
+ '
'.&mt('Enter 0 to remain disabled until page reload.').' '.
+ '
'."\n";
+ %defaultchecked = ('postsubmit' => 'on');
+ @toggles = ('postsubmit');
+ $current = {
+ 'postsubmit' => $postsubmitclient,
+ };
+ ($table,$itemcount) =
+ &radiobutton_prefs($current,\@toggles,\%defaultchecked,
+ \%choices,$itemcount,$onclick,$additional,'left');
+ $datatable .= $table;
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .= ''.
+ $choices{'mysqltables'}.
+ ' '.
+ ''.
+ ' '."\n";
+ $itemcount ++;
+
+ }
+ $$rowtotal += $itemcount;
+ return $datatable;
+}
+
+sub print_selfenrollment {
+ my ($position,$dom,$settings,$rowtotal) = @_;
+ my ($css_class,$datatable);
+ my $itemcount = 1;
+ my @types = ('official','unofficial','community','textbook','placement');
+ 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}.' '.
+ ''.
+ ' ';
+ }
+ } 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') {
- foreach my $item (@contacts) {
- if (exists($settings->{$item})) {
- $to{$item} = $settings->{$item};
+ 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 .= ''.
+ $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 .= ''.
+ ' '.$field.
+ ' ';
+ }
+ } elsif ($item eq 'markup') {
+ $datatable .= '';
+ }
+ $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;
+ }
}
}
- foreach my $type (@mailings) {
- if (exists($settings->{$type})) {
- if (ref($settings->{$type}) eq 'HASH') {
- foreach my $item (@contacts) {
- if ($settings->{$type}{$item}) {
- $checked{$type}{$item} = ' checked="checked" ';
+ 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 .= '';
+ if ($numdc > 1) {
+ $datatable .= &mt('Course creation processed as: (choose Dom. Coord.)');
+ } else {
+ $datatable .= &mt('Course creation processed as: ');
+ }
+ $datatable .= ' '.$dctable.' ';
+ $itemcount ++;
+ }
+ if (ref($rowtotal)) {
+ $$rowtotal += $itemcount;
+ }
+ return $datatable;
+}
+
+sub print_usersessions {
+ my ($position,$dom,$settings,$rowtotal) = @_;
+ my ($css_class,$datatable,$itemcount,%checked,%choices);
+ my (%by_ip,%by_location,@intdoms,@instdoms);
+ &build_location_hashes(\@intdoms,\%by_ip,\%by_location,\@instdoms);
+
+ my @alldoms = &Apache::lonnet::all_domains();
+ my %serverhomes = %Apache::lonnet::serverhomeIDs;
+ my %servers = &Apache::lonnet::internet_dom_servers($dom);
+ my %altids = &id_for_thisdom(%servers);
+ if ($position eq 'top') {
+ if (keys(%serverhomes) > 1) {
+ my %spareid = ¤t_offloads_to($dom,$settings,\%servers);
+ my $curroffloadnow;
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'offloadnow'}) eq 'HASH') {
+ $curroffloadnow = $settings->{'offloadnow'};
+ }
+ }
+ $datatable .= &spares_row($dom,\%servers,\%spareid,\%serverhomes,\%altids,$curroffloadnow,$rowtotal);
+ } else {
+ $datatable .= ''.
+ &mt('Nothing to set here, as the cluster to which this domain belongs only contains one server.').
+ ' ';
+ }
+ } else {
+ my %titles = &usersession_titles();
+ my ($prefix,@types);
+ if ($position eq 'bottom') {
+ $prefix = 'remote';
+ @types = ('version','excludedomain','includedomain');
+ } else {
+ $prefix = 'hosted';
+ @types = ('excludedomain','includedomain');
+ }
+ ($datatable,$itemcount) = &rules_by_location($settings,$prefix,\%by_location,\%by_ip,\@types,\%titles);
+ }
+ $$rowtotal += $itemcount;
+ return $datatable;
+}
+
+sub rules_by_location {
+ my ($settings,$prefix,$by_location,$by_ip,$types,$titles) = @_;
+ my ($datatable,$itemcount,$css_class);
+ if (keys(%{$by_location}) == 0) {
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable = ''.
+ &mt('Nothing to set here, as the cluster to which this domain belongs only contains one institution.').
+ ' ';
+ $itemcount = 1;
+ } else {
+ $itemcount = 0;
+ my $numinrow = 5;
+ my (%current,%checkedon,%checkedoff);
+ my @locations = sort(keys(%{$by_location}));
+ foreach my $type (@{$types}) {
+ $checkedon{$type} = '';
+ $checkedoff{$type} = ' checked="checked"';
+ }
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{$prefix}) eq 'HASH') {
+ foreach my $key (keys(%{$settings->{$prefix}})) {
+ $current{$key} = $settings->{$prefix}{$key};
+ if ($key eq 'version') {
+ if ($current{$key} ne '') {
+ $checkedon{$key} = ' checked="checked"';
+ $checkedoff{$key} = '';
}
+ } elsif (ref($current{$key}) eq 'ARRAY') {
+ $checkedon{$key} = ' checked="checked"';
+ $checkedoff{$key} = '';
}
- $otheremails{$type} = $settings->{$type}{'others'};
}
}
}
+ foreach my $type (@{$types}) {
+ next if ($type ne 'version' && !@locations);
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .= '
+ '.$titles->{$type}.'
+
+ '.&mt('Not in use').'
+ '.&mt('In use').' ';
+ if ($type eq 'version') {
+ my @lcversions = &Apache::lonnet::all_loncaparevs();
+ my $selector = '';
+ foreach my $version (@lcversions) {
+ my $selected = '';
+ if ($current{'version'} eq $version) {
+ $selected = ' selected="selected"';
+ }
+ $selector .= ' '.$version.' ';
+ }
+ $selector .= ' ';
+ $datatable .= &mt('remote server must be version: [_1] or later',$selector);
+ } else {
+ $datatable.= ' '.(' 'x2).
+ ' '.
+ "\n".
+ '
';
+ $itemcount ++;
+ }
+ }
+ return ($datatable,$itemcount);
+}
+
+sub print_ssl {
+ my ($position,$dom,$settings,$rowtotal) = @_;
+ my ($css_class,$datatable);
+ my $itemcount = 1;
+ if ($position eq 'top') {
+ my $primary_id = &Apache::lonnet::domain($dom,'primary');
+ my $intdom = &Apache::lonnet::internet_dom($primary_id);
+ my $same_institution;
+ if ($intdom ne '') {
+ my $internet_names = &Apache::lonnet::get_internet_names($Apache::lonnet::perlvar{'lonHostID'});
+ if (ref($internet_names) eq 'ARRAY') {
+ if (grep(/^\Q$intdom\E$/,@{$internet_names})) {
+ $same_institution = 1;
+ }
+ }
+ }
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable = '';
+ if ($same_institution) {
+ my %domservers = &Apache::lonnet::get_servers($dom);
+ $datatable .= &LONCAPA::SSL::print_certstatus(\%domservers,'web','domprefs');
+ } else {
+ $datatable .= &mt("You need to be logged into one of your own domain's servers to display information about the status of LON-CAPA SSL certificates.");
+ }
+ $datatable .= ' ';
+ $itemcount ++;
} else {
- $to{'supportemail'} = $Apache::lonnet::perlvar{'lonSupportEMail'};
- $to{'adminemail'} = $Apache::lonnet::perlvar{'lonAdmEMail'};
- $checked{'errormail'}{'adminemail'} = ' checked="checked" ';
- $checked{'packagesmail'}{'adminemail'} = ' checked="checked" ';
- $checked{'helpdeskmail'}{'supportemail'} = ' checked="checked" ';
+ my %titles = &ssl_titles();
+ my (%by_ip,%by_location,@intdoms,@instdoms);
+ &build_location_hashes(\@intdoms,\%by_ip,\%by_location,\@instdoms);
+ my @alldoms = &Apache::lonnet::all_domains();
+ my %serverhomes = %Apache::lonnet::serverhomeIDs;
+ my @domservers = &Apache::lonnet::get_servers($dom);
+ my %servers = &Apache::lonnet::internet_dom_servers($dom);
+ my %altids = &id_for_thisdom(%servers);
+ if (($position eq 'connto') || ($position eq 'connfrom')) {
+ my $legacy;
+ unless (ref($settings) eq 'HASH') {
+ my $name;
+ if ($position eq 'connto') {
+ $name = 'loncAllowInsecure';
+ } else {
+ $name = 'londAllowInsecure';
+ }
+ my $primarylibserv = &Apache::lonnet::domain($dom,'primary');
+ my @ids=&Apache::lonnet::current_machine_ids();
+ if (($primarylibserv ne '') && (!grep(/^\Q$primarylibserv\E$/,@ids))) {
+ my %what = (
+ $name => 1,
+ );
+ my ($result,$returnhash) =
+ &Apache::lonnet::get_remote_globals($primarylibserv,\%what);
+ if ($result eq 'ok') {
+ if (ref($returnhash) eq 'HASH') {
+ $legacy = $returnhash->{$name};
+ }
+ }
+ } else {
+ $legacy = $Apache::lonnet::perlvar{$name};
+ }
+ }
+ foreach my $type ('dom','intdom','other') {
+ my %checked;
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .= ''.$titles{$type}.' '.
+ '';
+ my $skip;
+ if ($type eq 'dom') {
+ unless (keys(%servers) > 1) {
+ $datatable .= &mt('Nothing to set here, as there are no other servers/VMs');
+ $skip = 1;
+ }
+ }
+ if ($type eq 'intdom') {
+ unless (@instdoms > 1) {
+ $datatable .= &mt('Nothing to set here, as there are no other domains for this institution');
+ $skip = 1;
+ }
+ } elsif ($type eq 'other') {
+ if (keys(%by_location) == 0) {
+ $datatable .= &mt('Nothing to set here, as there are no other institutions');
+ $skip = 1;
+ }
+ }
+ unless ($skip) {
+ $checked{'yes'} = ' checked="checked"';
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{$position}) eq 'HASH') {
+ if ($settings->{$position}->{$type} =~ /^(no|req)$/) {
+ $checked{$1} = $checked{'yes'};
+ delete($checked{'yes'});
+ }
+ }
+ } else {
+ if ($legacy == 0) {
+ $checked{'req'} = $checked{'yes'};
+ delete($checked{'yes'});
+ }
+ }
+ foreach my $option ('no','yes','req') {
+ $datatable .= ''.
+ ' '.$titles{$option}.
+ ' '.(' 'x2);
+ }
+ }
+ $datatable .= ' ';
+ $itemcount ++;
+ }
+ } else {
+ my $prefix = 'replication';
+ my @types = ('certreq','nocertreq');
+ if (keys(%by_location) == 0) {
+ $datatable .= ''.
+ &mt('Nothing to set here, as there are no other institutions').
+ ' ';
+ $itemcount ++;
+ } else {
+ ($datatable,$itemcount) =
+ &rules_by_location($settings,$prefix,\%by_location,\%by_ip,\@types,\%titles);
+ }
+ }
}
- my ($titles,$short_titles) = &contact_titles();
- my $rownum = 0;
+ $$rowtotal += $itemcount;
+ return $datatable;
+}
+
+sub ssl_titles {
+ return &Apache::lonlocal::texthash (
+ dom => 'LON-CAPA servers/VMs from same domain',
+ intdom => 'LON-CAPA servers/VMs from same "internet" domain',
+ other => 'External LON-CAPA servers/VMs',
+ connto => 'Connections to other servers',
+ connfrom => 'Connections from other servers',
+ replication => 'Replicating content to other institutions',
+ certreq => 'Client certificate required, but specific domains exempt',
+ nocertreq => 'No client certificate required, except for specific domains',
+ no => 'SSL not used',
+ yes => 'SSL Optional (used if available)',
+ req => 'SSL Required',
+ );
+}
+
+sub print_trust {
+ my ($prefix,$dom,$settings,$rowtotal) = @_;
+ my ($css_class,$datatable,%checked,%choices);
+ my (%by_ip,%by_location,@intdoms,@instdoms);
+ &build_location_hashes(\@intdoms,\%by_ip,\%by_location,\@instdoms);
+ my $itemcount = 1;
+ my %titles = &trust_titles();
+ my @types = ('exc','inc');
+ if ($prefix eq 'top') {
+ $prefix = 'content';
+ } elsif ($prefix eq 'bottom') {
+ $prefix = 'msg';
+ }
+ ($datatable,$itemcount) = &rules_by_location($settings,$prefix,\%by_location,\%by_ip,\@types,\%titles);
+ $$rowtotal += $itemcount;
+ return $datatable;
+}
+
+sub trust_titles {
+ return &Apache::lonlocal::texthash(
+ content => "Access to this domain's content by others",
+ shared => "Access to other domain's content by this domain",
+ enroll => "Enrollment in this domain's courses by others",
+ othcoau => "Co-author roles in this domain for others",
+ coaurem => "Co-author roles for this domain's users elsewhere",
+ domroles => "Domain roles in this domain assignable to others",
+ catalog => "Course Catalog for this domain displayed elsewhere",
+ reqcrs => "Requests for creation of courses in this domain by others",
+ msg => "Users in other domains can send messages to this domain",
+ exc => "Allow all, but exclude specific domains",
+ inc => "Deny all, but include specific domains",
+ );
+}
+
+sub build_location_hashes {
+ my ($intdoms,$by_ip,$by_location,$instdoms) = @_;
+ return unless((ref($intdoms) eq 'ARRAY') && (ref($by_ip) eq 'HASH') &&
+ (ref($by_location) eq 'HASH') && (ref($instdoms) eq 'ARRAY'));
+ my %iphost = &Apache::lonnet::get_iphost();
+ my $primary_id = &Apache::lonnet::domain($env{'request.role.domain'},'primary');
+ my $primary_ip = &Apache::lonnet::get_host_ip($primary_id);
+ if (ref($iphost{$primary_ip}) eq 'ARRAY') {
+ foreach my $id (@{$iphost{$primary_ip}}) {
+ my $intdom = &Apache::lonnet::internet_dom($id);
+ unless(grep(/^\Q$intdom\E$/,@{$intdoms})) {
+ push(@{$intdoms},$intdom);
+ }
+ }
+ }
+ foreach my $ip (keys(%iphost)) {
+ if (ref($iphost{$ip}) eq 'ARRAY') {
+ foreach my $id (@{$iphost{$ip}}) {
+ my $location = &Apache::lonnet::internet_dom($id);
+ if ($location) {
+ if (grep(/^\Q$location\E$/,@{$intdoms})) {
+ my $dom = &Apache::lonnet::host_domain($id);
+ unless (grep(/^\Q$dom\E/,@{$instdoms})) {
+ push(@{$instdoms},$dom);
+ }
+ next;
+ }
+ if (ref($by_ip->{$ip}) eq 'ARRAY') {
+ unless(grep(/^\Q$location\E$/,@{$by_ip->{$ip}})) {
+ push(@{$by_ip->{$ip}},$location);
+ }
+ } else {
+ $by_ip->{$ip} = [$location];
+ }
+ }
+ }
+ }
+ }
+ foreach my $ip (sort(keys(%{$by_ip}))) {
+ if (ref($by_ip->{$ip}) eq 'ARRAY') {
+ @{$by_ip->{$ip}} = sort(@{$by_ip->{$ip}});
+ my $first = $by_ip->{$ip}->[0];
+ if (ref($by_location->{$first}) eq 'ARRAY') {
+ unless (grep(/^\Q$ip\E$/,@{$by_location->{$first}})) {
+ push(@{$by_location->{$first}},$ip);
+ }
+ } else {
+ $by_location->{$first} = [$ip];
+ }
+ }
+ }
+ return;
+}
+
+sub current_offloads_to {
+ my ($dom,$settings,$servers) = @_;
+ my (%spareid,%otherdomconfigs);
+ if (ref($servers) eq 'HASH') {
+ foreach my $lonhost (sort(keys(%{$servers}))) {
+ my $gotspares;
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'spares'}) eq 'HASH') {
+ if (ref($settings->{'spares'}{$lonhost}) eq 'HASH') {
+ $spareid{$lonhost}{'primary'} = $settings->{'spares'}{$lonhost}{'primary'};
+ $spareid{$lonhost}{'default'} = $settings->{'spares'}{$lonhost}{'default'};
+ $gotspares = 1;
+ }
+ }
+ }
+ unless ($gotspares) {
+ my $gotspares;
+ my $serverhomeID =
+ &Apache::lonnet::get_server_homeID($servers->{$lonhost});
+ my $serverhomedom =
+ &Apache::lonnet::host_domain($serverhomeID);
+ if ($serverhomedom ne $dom) {
+ if (ref($otherdomconfigs{$serverhomedom} eq 'HASH')) {
+ if (ref($otherdomconfigs{$serverhomedom}{'usersessions'}) eq 'HASH') {
+ if (ref($otherdomconfigs{$serverhomedom}{'usersessions'}{'spares'}) eq 'HASH') {
+ $spareid{$lonhost}{'primary'} = $otherdomconfigs{$serverhomedom}{'usersessions'}{'spares'}{'primary'};
+ $spareid{$lonhost}{'default'} = $otherdomconfigs{$serverhomedom}{'usersessions'}{'spares'}{'default'};
+ $gotspares = 1;
+ }
+ }
+ } else {
+ $otherdomconfigs{$serverhomedom} =
+ &Apache::lonnet::get_dom('configuration',['usersessions'],$serverhomedom);
+ if (ref($otherdomconfigs{$serverhomedom}) eq 'HASH') {
+ if (ref($otherdomconfigs{$serverhomedom}{'usersessions'}) eq 'HASH') {
+ if (ref($otherdomconfigs{$serverhomedom}{'usersessions'}{'spares'}) eq 'HASH') {
+ if (ref($otherdomconfigs{$serverhomedom}{'usersessions'}{'spares'}{$lonhost}) eq 'HASH') {
+ $spareid{$lonhost}{'primary'} = $otherdomconfigs{$serverhomedom}{'usersessions'}{'spares'}{'primary'};
+ $spareid{$lonhost}{'default'} = $otherdomconfigs{$serverhomedom}{'usersessions'}{'spares'}{'default'};
+ $gotspares = 1;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ unless ($gotspares) {
+ if ($lonhost eq $Apache::lonnet::perlvar{'lonHostID'}) {
+ $spareid{$lonhost}{'primary'} = $Apache::lonnet::spareid{'primary'};
+ $spareid{$lonhost}{'default'} = $Apache::lonnet::spareid{'default'};
+ } else {
+ my $server_hostname = &Apache::lonnet::hostname($lonhost);
+ my $server_homeID = &Apache::lonnet::get_server_homeID($server_hostname);
+ if ($server_homeID eq $Apache::lonnet::perlvar{'lonHostID'}) {
+ $spareid{$lonhost}{'primary'} = $Apache::lonnet::spareid{'primary'};
+ $spareid{$lonhost}{'default'} = $Apache::lonnet::spareid{'default'};
+ } else {
+ my %what = (
+ spareid => 1,
+ );
+ my ($result,$returnhash) =
+ &Apache::lonnet::get_remote_globals($lonhost,\%what);
+ if ($result eq 'ok') {
+ if (ref($returnhash) eq 'HASH') {
+ if (ref($returnhash->{'spareid'}) eq 'HASH') {
+ $spareid{$lonhost}{'primary'} = $returnhash->{'spareid'}->{'primary'};
+ $spareid{$lonhost}{'default'} = $returnhash->{'spareid'}->{'default'};
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return %spareid;
+}
+
+sub spares_row {
+ my ($dom,$servers,$spareid,$serverhomes,$altids,$curroffloadnow,$rowtotal) = @_;
my $css_class;
- foreach my $item (@contacts) {
- $rownum ++;
- $css_class = $rownum%2?' class="LC_odd_row"':'';
- $datatable .= ''.
- ''.$titles->{$item}.
- ' '.
- ' ';
+ my $numinrow = 4;
+ my $itemcount = 1;
+ my $datatable;
+ my %typetitles = &sparestype_titles();
+ if ((ref($servers) eq 'HASH') && (ref($spareid) eq 'HASH') && (ref($altids) eq 'HASH')) {
+ foreach my $server (sort(keys(%{$servers}))) {
+ my $serverhome = &Apache::lonnet::get_server_homeID($servers->{$server});
+ my ($othercontrol,$serverdom);
+ if ($serverhome ne $server) {
+ $serverdom = &Apache::lonnet::host_domain($serverhome);
+ $othercontrol = &mt('Session offloading controlled by domain: [_1]',''.$serverdom.' ');
+ } else {
+ $serverdom = &Apache::lonnet::host_domain($server);
+ if ($serverdom ne $dom) {
+ $othercontrol = &mt('Session offloading controlled by domain: [_1]',''.$serverdom.' ');
+ }
+ }
+ next unless (ref($spareid->{$server}) eq 'HASH');
+ my $checkednow;
+ if (ref($curroffloadnow) eq 'HASH') {
+ if ($curroffloadnow->{$server}) {
+ $checkednow = ' checked="checked"';
+ }
+ }
+ $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
+ $datatable .= '
+
+ '.
+ &mt('[_1] when busy, offloads to:'
+ ,''.$server.' ').' '.
+ ''."\n".
+ ' '.
+ ' '.&mt('Switch active users on next access').' '.
+ "\n";
+ my (%current,%canselect);
+ my @choices =
+ &possible_newspares($server,$spareid->{$server},$serverhomes,$altids);
+ foreach my $type ('primary','default') {
+ if (ref($spareid->{$server}) eq 'HASH') {
+ if (ref($spareid->{$server}{$type}) eq 'ARRAY') {
+ my @spares = @{$spareid->{$server}{$type}};
+ if (@spares > 0) {
+ if ($othercontrol) {
+ $current{$type} = join(', ',@spares);
+ } else {
+ $current{$type} .= '';
+ }
+ }
+ }
+ if ($current{$type} eq '') {
+ $current{$type} = &mt('None specified');
+ }
+ if ($othercontrol) {
+ if ($type eq 'primary') {
+ $canselect{$type} = $othercontrol;
+ }
+ } else {
+ $canselect{$type} =
+ &mt('Add new [_1]'.$type.'[_2]:','',' ').' '.
+ ''."\n".
+ ''.&mt('Select').' '."\n";
+ if (@choices > 0) {
+ foreach my $lonhost (@choices) {
+ $canselect{$type} .= ''.$lonhost.' '."\n";
+ }
+ }
+ $canselect{$type} .= ' '."\n";
+ }
+ } else {
+ $current{$type} = &mt('Could not be determined');
+ if ($type eq 'primary') {
+ $canselect{$type} = $othercontrol;
+ }
+ }
+ if ($type eq 'default') {
+ $datatable .= ' ';
+ }
+ $datatable .= ''.$typetitles{$type}.' '."\n".
+ ''.$current{$type}.' '."\n".
+ ''.$canselect{$type}.' '."\n";
+ }
+ $itemcount ++;
+ }
}
- foreach my $type (@mailings) {
- $rownum ++;
- $css_class = $rownum%2?' class="LC_odd_row"':'';
- $datatable .= ''.
- ''.
- $titles->{$type}.': '.
- ''.
- '';
- foreach my $item (@contacts) {
- $datatable .= ''.
- ' '.$short_titles->{$item}.
- ' ';
- }
- $datatable .= ' '.&mt('Others').': '.
- ' '.
- ' '."\n";
+ $$rowtotal += $itemcount;
+ return $datatable;
+}
+
+sub possible_newspares {
+ my ($server,$currspares,$serverhomes,$altids) = @_;
+ my $serverhostname = &Apache::lonnet::hostname($server);
+ my %excluded;
+ if ($serverhostname ne '') {
+ %excluded = (
+ $serverhostname => 1,
+ );
}
- $$rowtotal += $rownum;
+ if (ref($currspares) eq 'HASH') {
+ foreach my $type (keys(%{$currspares})) {
+ if (ref($currspares->{$type}) eq 'ARRAY') {
+ if (@{$currspares->{$type}} > 0) {
+ foreach my $curr (@{$currspares->{$type}}) {
+ my $hostname = &Apache::lonnet::hostname($curr);
+ $excluded{$hostname} = 1;
+ }
+ }
+ }
+ }
+ }
+ my @choices;
+ if ((ref($serverhomes) eq 'HASH') && (ref($altids) eq 'HASH')) {
+ if (keys(%{$serverhomes}) > 1) {
+ foreach my $name (sort(keys(%{$serverhomes}))) {
+ unless ($excluded{$name}) {
+ if (exists($altids->{$serverhomes->{$name}})) {
+ push(@choices,$altids->{$serverhomes->{$name}});
+ } else {
+ push(@choices,$serverhomes->{$name});
+ }
+ }
+ }
+ }
+ }
+ return sort(@choices);
+}
+
+sub print_loadbalancing {
+ my ($dom,$settings,$rowtotal) = @_;
+ my $primary_id = &Apache::lonnet::domain($dom,'primary');
+ my $intdom = &Apache::lonnet::internet_dom($primary_id);
+ my $numinrow = 1;
+ my $datatable;
+ my %servers = &Apache::lonnet::internet_dom_servers($dom);
+ my (%currbalancer,%currtargets,%currrules,%existing);
+ if (ref($settings) eq 'HASH') {
+ %existing = %{$settings};
+ }
+ if ((keys(%servers) > 1) || (keys(%existing) > 0)) {
+ &get_loadbalancers_config(\%servers,\%existing,\%currbalancer,
+ \%currtargets,\%currrules);
+ } else {
+ return;
+ }
+ my ($othertitle,$usertypes,$types) =
+ &Apache::loncommon::sorted_inst_types($dom);
+ my $rownum = 8;
+ if (ref($types) eq 'ARRAY') {
+ $rownum += scalar(@{$types});
+ }
+ my @css_class = ('LC_odd_row','LC_even_row');
+ my $balnum = 0;
+ my $islast;
+ my (@toshow,$disabledtext);
+ if (keys(%currbalancer) > 0) {
+ @toshow = sort(keys(%currbalancer));
+ if (scalar(@toshow) < scalar(keys(%servers)) + 1) {
+ push(@toshow,'');
+ }
+ } else {
+ @toshow = ('');
+ $disabledtext = &mt('No existing load balancer');
+ }
+ foreach my $lonhost (@toshow) {
+ if ($balnum == scalar(@toshow)-1) {
+ $islast = 1;
+ } else {
+ $islast = 0;
+ }
+ my $cssidx = $balnum%2;
+ my $targets_div_style = 'display: none';
+ my $disabled_div_style = 'display: block';
+ my $homedom_div_style = 'display: none';
+ $datatable .= ''.
+ ''.
+ '';
+ if ($lonhost eq '') {
+ $datatable .= '';
+ if (keys(%currbalancer) > 0) {
+ $datatable .= &mt('Add balancer:');
+ } else {
+ $datatable .= &mt('Enable balancer:');
+ }
+ $datatable .= ' '.
+ ''."\n".
+ ''.&mt('None').
+ ' '."\n";
+ foreach my $server (sort(keys(%servers))) {
+ next if ($currbalancer{$server});
+ $datatable .= ''.$server.' '."\n";
+ }
+ $datatable .=
+ ' '."\n".
+ ' '."\n";
+ } else {
+ $datatable .= ''.$lonhost.' '.
+ ' '.
+ &mt('Stop balancing').' '.
+ ' ';
+ $targets_div_style = 'display: block';
+ $disabled_div_style = 'display: none';
+ if ($dom eq &Apache::lonnet::host_domain($lonhost)) {
+ $homedom_div_style = 'display: block';
+ }
+ }
+ $datatable .= '
'.
+ ''.$disabledtext.'
'."\n".
+ ''.&mt('Offloads to:').' ';
+ my ($numspares,@spares) = &count_servers($lonhost,%servers);
+ my @sparestypes = ('primary','default');
+ my %typetitles = &sparestype_titles();
+ my %hostherechecked = (
+ no => ' checked="checked"',
+ );
+ foreach my $sparetype (@sparestypes) {
+ my $targettable;
+ for (my $i=0; $i<$numspares; $i++) {
+ my $checked;
+ if (ref($currtargets{$lonhost}) eq 'HASH') {
+ if (ref($currtargets{$lonhost}{$sparetype}) eq 'ARRAY') {
+ if (grep(/^\Q$spares[$i]\E$/,@{$currtargets{$lonhost}{$sparetype}})) {
+ $checked = ' checked="checked"';
+ }
+ }
+ }
+ my ($chkboxval,$disabled);
+ if (($lonhost ne '') && (exists($servers{$lonhost}))) {
+ $chkboxval = $spares[$i];
+ }
+ if (exists($currbalancer{$spares[$i]})) {
+ $disabled = ' disabled="disabled"';
+ }
+ $targettable .=
+ '
'.
+ ' '.$chkboxval.
+ ' ';
+ my $rem = $i%($numinrow);
+ if ($rem == 0) {
+ if (($i > 0) && ($i < $numspares-1)) {
+ $targettable .= ' ';
+ }
+ if ($i < $numspares-1) {
+ $targettable .= '';
+ }
+ }
+ }
+ if ($targettable ne '') {
+ my $rem = $numspares%($numinrow);
+ my $colsleft = $numinrow - $rem;
+ if ($colsleft > 1 ) {
+ $targettable .= ''.
+ ' ';
+ } elsif ($colsleft == 1) {
+ $targettable .= ' ';
+ }
+ $datatable .= ''.$typetitles{$sparetype}.' '.
+ ' ';
+ }
+ $hostherechecked{$sparetype} = '';
+ if (ref($currtargets{$lonhost}) eq 'HASH') {
+ if (ref($currtargets{$lonhost}{$sparetype}) eq 'ARRAY') {
+ if (grep(/^\Q$lonhost\E$/,@{$currtargets{$lonhost}{$sparetype}})) {
+ $hostherechecked{$sparetype} = ' checked="checked"';
+ $hostherechecked{'no'} = '';
+ }
+ }
+ }
+ }
+ $datatable .= &mt('Hosting on balancer itself').' '.
+ ' '.&mt('No').' ';
+ foreach my $sparetype (@sparestypes) {
+ $datatable .= ''.$typetitles{$sparetype}.
+ ' ';
+ }
+ $datatable .= ' '.
+ &loadbalancing_rules($dom,$intdom,$currrules{$lonhost},
+ $othertitle,$usertypes,$types,\%servers,
+ \%currbalancer,$lonhost,
+ $targets_div_style,$homedom_div_style,
+ $css_class[$cssidx],$balnum,$islast);
+ $$rowtotal += $rownum;
+ $balnum ++;
+ }
+ $datatable .= ' ';
return $datatable;
}
+sub get_loadbalancers_config {
+ my ($servers,$existing,$currbalancer,$currtargets,$currrules) = @_;
+ return unless ((ref($servers) eq 'HASH') &&
+ (ref($existing) eq 'HASH') && (ref($currbalancer) eq 'HASH') &&
+ (ref($currtargets) eq 'HASH') && (ref($currrules) eq 'HASH'));
+ if (keys(%{$existing}) > 0) {
+ my $oldlonhost;
+ foreach my $key (sort(keys(%{$existing}))) {
+ if ($key eq 'lonhost') {
+ $oldlonhost = $existing->{'lonhost'};
+ $currbalancer->{$oldlonhost} = 1;
+ } elsif ($key eq 'targets') {
+ if ($oldlonhost) {
+ $currtargets->{$oldlonhost} = $existing->{'targets'};
+ }
+ } elsif ($key eq 'rules') {
+ if ($oldlonhost) {
+ $currrules->{$oldlonhost} = $existing->{'rules'};
+ }
+ } elsif (ref($existing->{$key}) eq 'HASH') {
+ $currbalancer->{$key} = 1;
+ $currtargets->{$key} = $existing->{$key}{'targets'};
+ $currrules->{$key} = $existing->{$key}{'rules'};
+ }
+ }
+ } else {
+ my ($balancerref,$targetsref) =
+ &Apache::lonnet::get_lonbalancer_config($servers);
+ if ((ref($balancerref) eq 'HASH') && (ref($targetsref) eq 'HASH')) {
+ foreach my $server (sort(keys(%{$balancerref}))) {
+ $currbalancer->{$server} = 1;
+ $currtargets->{$server} = $targetsref->{$server};
+ }
+ }
+ }
+ return;
+}
+
+sub loadbalancing_rules {
+ my ($dom,$intdom,$currrules,$othertitle,$usertypes,$types,$servers,
+ $currbalancer,$lonhost,$targets_div_style,$homedom_div_style,
+ $css_class,$balnum,$islast) = @_;
+ my $output;
+ my $num = 0;
+ my ($alltypes,$othertypes,$titles) =
+ &loadbalancing_titles($dom,$intdom,$usertypes,$types);
+ if ((ref($alltypes) eq 'ARRAY') && (ref($titles) eq 'HASH')) {
+ foreach my $type (@{$alltypes}) {
+ $num ++;
+ my $current;
+ if (ref($currrules) eq 'HASH') {
+ $current = $currrules->{$type};
+ }
+ if (($type eq '_LC_external') || ($type eq '_LC_internetdom')) {
+ if ($dom ne &Apache::lonnet::host_domain($lonhost)) {
+ $current = '';
+ }
+ }
+ $output .= &loadbalance_rule_row($type,$titles->{$type},$current,
+ $servers,$currbalancer,$lonhost,$dom,
+ $targets_div_style,$homedom_div_style,
+ $css_class,$balnum,$num,$islast);
+ }
+ }
+ return $output;
+}
+
+sub loadbalancing_titles {
+ my ($dom,$intdom,$usertypes,$types) = @_;
+ my %othertypes = (
+ '_LC_adv' => &mt('Advanced users from [_1]',$dom),
+ '_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 @available;
+ if (ref($types) eq 'ARRAY') {
+ @available = @{$types};
+ }
+ unless (grep(/^default$/,@available)) {
+ push(@available,'default');
+ }
+ unshift(@alltypes,@available);
+ my %titles;
+ foreach my $type (@alltypes) {
+ if ($type =~ /^_LC_/) {
+ $titles{$type} = $othertypes{$type};
+ } elsif ($type eq 'default') {
+ $titles{$type} = &mt('All users from [_1]',$dom);
+ if (ref($types) eq 'ARRAY') {
+ if (@{$types} > 0) {
+ $titles{$type} = &mt('Other users from [_1]',$dom);
+ }
+ }
+ } elsif (ref($usertypes) eq 'HASH') {
+ $titles{$type} = $usertypes->{$type};
+ }
+ }
+ return (\@alltypes,\%othertypes,\%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 %ruletitles = &offloadtype_text();
+ if (($type eq '_LC_ipchangesso') || ($type eq '_LC_ipchange')) {
+ @rulenames = ('balancer','offloadedto','specific');
+ } else {
+ @rulenames = ('default','homeserver');
+ if ($type eq '_LC_external') {
+ push(@rulenames,'externalbalancer');
+ } else {
+ push(@rulenames,'specific');
+ }
+ push(@rulenames,'none');
+ }
+ my $style = $targets_div_style;
+ if (($type eq '_LC_external') || ($type eq '_LC_internetdom')) {
+ $style = $homedom_div_style;
+ }
+ my $space;
+ if ($islast && $num == 1) {
+ $space = '
';
+ }
+ my $output =
+ ''.$space.
+ ''.$title.'
'."\n".
+ ''.$space.
+ ''."\n";
+ for (my $i=0; $i<@rulenames; $i++) {
+ my $rule = $rulenames[$i];
+ my ($checked,$extra);
+ if ($rulenames[$i] eq 'default') {
+ $rule = '';
+ }
+ if ($rulenames[$i] eq 'specific') {
+ if (ref($servers) eq 'HASH') {
+ my $default;
+ if (($current ne '') && (exists($servers->{$current}))) {
+ $checked = ' checked="checked"';
+ }
+ unless ($checked) {
+ $default = ' selected="selected"';
+ }
+ $extra =
+ ': '."\n".
+ ' '."\n";
+ foreach my $server (sort(keys(%{$servers}))) {
+ if (ref($currbalancer) eq 'HASH') {
+ next if (exists($currbalancer->{$server}));
+ }
+ my $selected;
+ if ($server eq $current) {
+ $selected = ' selected="selected"';
+ }
+ $extra .= ''.$server.' ';
+ }
+ $extra .= ' ';
+ }
+ } elsif ($rule eq $current) {
+ $checked = ' checked="checked"';
+ }
+ $output .= ''.
+ ' ';
+ if (($rulenames[$i] eq 'specific') && ($type =~ /^_LC_ipchange/)) {
+ $output .= $ruletitles{'particular'};
+ } else {
+ $output .= $ruletitles{$rulenames[$i]};
+ }
+ $output .= ' '.$extra.' '."\n";
+ }
+ $output .= '
'."\n";
+ return $output;
+}
+
+sub offloadtype_text {
+ my %ruletitles = &Apache::lonlocal::texthash (
+ 'default' => 'Offloads to default destinations',
+ 'homeserver' => "Offloads to user's home server",
+ '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;
+}
+
+sub sparestype_titles {
+ my %typestitles = &Apache::lonlocal::texthash (
+ 'primary' => 'primary',
+ 'default' => 'default',
+ );
+ return %typestitles;
+}
+
sub contact_titles {
my %titles = &Apache::lonlocal::texthash (
- 'supportemail' => 'Support E-mail address',
- 'adminemail' => 'Default Server Admin E-mail address',
- 'errormail' => 'Error reports to be e-mailed to',
- 'packagesmail' => 'Package update alerts to be e-mailed to',
- 'helpdeskmail' => 'Helpdesk requests to be e-mailed to'
+ 'supportemail' => 'Support E-mail address',
+ 'adminemail' => 'Default Server Admin E-mail address',
+ 'errormail' => 'Error reports to be e-mailed to',
+ 'packagesmail' => 'Package update alerts to be e-mailed to',
+ 'helpdeskmail' => "Helpdesk requests from all users in this domain",
+ 'otherdomsmail' => 'Helpdesk requests from users in other (unconfigured) domains',
+ 'lonstatusmail' => 'E-mail from nightly status check (warnings/errors)',
+ 'requestsmail' => 'E-mail from course requests requiring approval',
+ 'updatesmail' => 'E-mail from nightly check of LON-CAPA module integrity/updates',
+ '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',
@@ -1700,16 +6602,84 @@ sub contact_titles {
return (\%titles,\%short_titles);
}
+sub helpform_fields {
+ my %titles = &Apache::lonlocal::texthash (
+ 'username' => 'Name',
+ 'user' => 'Username/domain',
+ 'phone' => 'Phone',
+ 'cc' => 'Cc e-mail',
+ 'course' => 'Course Details',
+ 'section' => 'Sections',
+ 'screenshot' => 'File upload',
+ );
+ my @fields = ('username','phone','user','course','section','cc','screenshot');
+ my %possoptions = (
+ username => ['yes','no','req'],
+ phone => ['yes','no','req'],
+ user => ['yes','no'],
+ cc => ['yes','no'],
+ course => ['yes','no'],
+ section => ['yes','no'],
+ screenshot => ['yes','no'],
+ );
+ my %fieldoptions = &Apache::lonlocal::texthash (
+ 'yes' => 'Optional',
+ 'req' => 'Required',
+ 'no' => "Not shown",
+ );
+ return (\@fields,\%titles,\%fieldoptions,\%possoptions);
+}
+
sub tool_titles {
my %titles = &Apache::lonlocal::texthash (
- aboutme => 'Personal Home Page',
+ aboutme => 'Personal web page',
blog => 'Blog',
+ webdav => 'WebDAV',
portfolio => 'Portfolio',
- official => 'Official courses (with institutional codes)', unofficial => 'Unofficial courses',
+ official => 'Official courses (with institutional codes)',
+ unofficial => 'Unofficial courses',
+ community => 'Communities',
+ textbook => 'Textbook courses',
+ placement => 'Placement tests',
+ );
+ return %titles;
+}
+
+sub courserequest_titles {
+ my %titles = &Apache::lonlocal::texthash (
+ official => 'Official',
+ unofficial => 'Unofficial',
+ community => 'Communities',
+ textbook => 'Textbook',
+ placement => 'Placement tests',
+ lti => 'LTI Provider',
+ norequest => 'Not allowed',
+ approval => 'Approval by DC',
+ validate => 'With validation',
+ autolimit => 'Numerical limit',
+ unlimited => '(blank for unlimited)',
);
return %titles;
}
+sub authorrequest_titles {
+ my %titles = &Apache::lonlocal::texthash (
+ norequest => 'Not allowed',
+ approval => 'Approval by Dom. Coord.',
+ 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).',
+ );
+ return %conditions;
+}
+
+
sub print_usercreation {
my ($position,$dom,$settings,$rowtotal) = @_;
my $numinrow = 4;
@@ -1735,42 +6705,22 @@ 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','selfcreate');
+ my @creators = ('author','course','requestcrs');
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'}})) {
@@ -1782,10 +6732,8 @@ sub print_usercreation {
my $rownum = 0;
foreach my $item (@creators) {
$rownum ++;
- if ($item ne 'selfcreate') {
- if ($checked{$item} eq '') {
- $checked{$item} = 'any';
- }
+ if ($checked{$item} eq '') {
+ $checked{$item} = 'any';
}
my $css_class;
if ($rownum%2) {
@@ -1795,31 +6743,19 @@ sub print_usercreation {
}
$datatable .= ''.
''.$lt{$item}.
- ' ';
- 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'));
- }
+ ' ';
+ my @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 ($item eq 'selfcreate') {
- $type = 'checkbox';
- if (grep(/^\Q$option\E$/,@selfcreate)) {
- $check = ' checked="checked" ';
- }
- } else {
- if ($checked{$item} eq $option) {
- $check = ' checked="checked" ';
- }
+ if ($checked{$item} eq $option) {
+ $check = ' checked="checked" ';
}
$datatable .= ''.
' '.
+ ''.&mt('Mapping of Shibboleth environment variable names to user data fields (SSO auth)').' '.
+ ''."\n".
+ ' ';
+ $$rowtotal ++;
+ } elsif ($position eq 'middle') {
+ my %domconf = &Apache::lonnet::get_dom('configuration',['usermodification'],$dom);
+ my @posstypes;
+ if (ref($types) eq 'ARRAY') {
+ @posstypes = @{$types};
+ }
+ unless (grep(/^default$/,@posstypes)) {
+ push(@posstypes,'default');
+ }
+ my %usertypeshash;
+ if (ref($usertypes) eq 'HASH') {
+ %usertypeshash = %{$usertypes};
+ }
+ $usertypeshash{'default'} = $othertitle;
+ foreach my $status (@posstypes) {
+ $datatable .= &modifiable_userdata_row('selfcreate',$status,$domconf{'usermodification'},
+ $numinrow,$$rowtotal,\%usertypeshash);
+ $$rowtotal ++;
+ }
+ } else {
+ my %choices = &Apache::lonlocal::texthash (
+ 'cancreate_email' => 'Non-institutional username (via e-mail verification)',
+ );
+ my @toggles = sort(keys(%choices));
+ my %defaultchecked = (
+ 'cancreate_email' => 'off',
+ );
+ my $customclass = 'LC_selfcreate_email';
+ my $classprefix = 'LC_canmodify_emailusername_';
+ my $optionsprefix = 'LC_options_emailusername_';
+ my $display = 'none';
+ my $rowstyle = 'display:none';
+ if (grep(/^\Qemail\E$/,@selfcreate)) {
+ $display = 'block';
+ $rowstyle = 'display:table-row';
+ }
+ my $onclick = "toggleRows(this.form,'cancreate_email','selfassign','$customclass','$classprefix','$optionsprefix');";
+ ($datatable,$$rowtotal) = &radiobutton_prefs(\%radiohash,\@toggles,\%defaultchecked,
+ \%choices,$$rowtotal,$onclick);
+ $datatable .= &print_requestmail($dom,'selfcreation',$createsettings,$rowtotal,$customclass,
+ $rowstyle);
+ $$rowtotal ++;
+ $datatable .= &captcha_choice('cancreate',$createsettings,$$rowtotal,$customclass,
+ $rowstyle);
+ $$rowtotal ++;
+ my (@ordered,@posstypes,%usertypeshash);
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+ my ($emailrules,$emailruleorder) =
+ &Apache::lonnet::inst_userrules($dom,'email');
+ my $primary_id = &Apache::lonnet::domain($dom,'primary');
+ my $intdom = &Apache::lonnet::internet_dom($primary_id);
+ if (ref($types) eq 'ARRAY') {
+ @posstypes = @{$types};
+ }
+ if (@posstypes) {
+ unless (grep(/^default$/,@posstypes)) {
+ push(@posstypes,'default');
+ }
+ if (ref($usertypes) eq 'HASH') {
+ %usertypeshash = %{$usertypes};
+ }
+ my $currassign;
+ if (ref($domdefaults{'inststatusguest'}) eq 'ARRAY') {
+ $currassign = {
+ selfassign => $domdefaults{'inststatusguest'},
+ };
+ @ordered = @{$domdefaults{'inststatusguest'}};
+ } else {
+ $currassign = { selfassign => [] };
+ }
+ my $onclicktypes = "toggleDataRow(this.form,'selfassign','$customclass','$optionsprefix',);".
+ "toggleDataRow(this.form,'selfassign','$customclass','$classprefix',1);";
+ $datatable .= &insttypes_row($currassign,$types,$usertypes,$dom,
+ $numinrow,$othertitle,'selfassign',
+ $rowtotal,$onclicktypes,$customclass,
+ $rowstyle);
+ $$rowtotal ++;
+ $usertypeshash{'default'} = $othertitle;
+ foreach my $status (@posstypes) {
+ my $css_class;
+ if ($$rowtotal%2) {
+ $css_class = 'LC_odd_row ';
+ }
+ $css_class .= $customclass;
+ my $rowid = $optionsprefix.$status;
+ my $hidden = 1;
+ my $currstyle = 'display:none';
+ if (grep(/^\Q$status\E$/,@ordered)) {
+ $currstyle = $rowstyle;
+ $hidden = 0;
+ }
+ $datatable .= &noninst_users($processing,$emailverified,$emailoptions,$emaildomain,
+ $emailrules,$emailruleorder,$settings,$status,$rowid,
+ $usertypeshash{$status},$css_class,$currstyle,$intdom);
+ unless ($hidden) {
+ $$rowtotal ++;
+ }
+ }
+ } else {
+ my $css_class;
+ if ($$rowtotal%2) {
+ $css_class = 'LC_odd_row ';
+ }
+ $css_class .= $customclass;
+ $usertypeshash{'default'} = $othertitle;
+ $datatable .= &noninst_users($processing,$emailverified,$emailoptions,$emaildomain,
+ $emailrules,$emailruleorder,$settings,'default','',
+ $othertitle,$css_class,$rowstyle,$intdom);
+ $$rowtotal ++;
+ }
+ my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info();
+ $numinrow = 1;
+ if (@posstypes) {
+ foreach my $status (@posstypes) {
+ my $rowid = $classprefix.$status;
+ my $datarowstyle = 'display:none';
+ if (grep(/^\Q$status\E$/,@ordered)) {
+ $datarowstyle = $rowstyle;
+ }
+ $datatable .= &modifiable_userdata_row('cancreate','emailusername_'.$status,$settings,
+ $numinrow,$$rowtotal,\%usertypeshash,$infofields,
+ $infotitles,$rowid,$customclass,$datarowstyle);
+ unless ($datarowstyle eq 'display:none') {
+ $$rowtotal ++;
+ }
+ }
+ } else {
+ $datatable .= &modifiable_userdata_row('cancreate','emailusername_default',$settings,
+ $numinrow,$$rowtotal,\%usertypeshash,$infofields,
+ $infotitles,'',$customclass,$rowstyle);
+ }
+ }
+ return $datatable;
+}
+
+sub selfcreate_javascript {
+ return <<"ENDSCRIPT";
+
+
+
+ENDSCRIPT
+}
+
+sub noninst_users {
+ my ($processing,$emailverified,$emailoptions,$emaildomain,$emailrules,
+ $emailruleorder,$settings,$type,$rowid,$typetitle,$css_class,$rowstyle,$intdom) = @_;
+ my $class = 'LC_left_item';
+ if ($css_class) {
+ $css_class = ' class="'.$css_class.'"';
+ }
+ if ($rowid) {
+ $rowid = ' id="'.$rowid.'"';
+ }
+ if ($rowstyle) {
+ $rowstyle = ' style="'.$rowstyle.'"';
+ }
+ my ($output,$description);
+ if ($type eq 'default') {
+ $description = &mt('Requests for: [_1]',$typetitle);
+ } else {
+ $description = &mt('Requests for: [_1] (status self-reported)',$typetitle);
+ }
+ $output = ''.
+ "$description \n".
+ ''.
+ '';
+ my %headers = &Apache::lonlocal::texthash(
+ approve => 'Processing',
+ email => 'E-mail',
+ username => 'Username',
+ );
+ foreach my $item ('approve','email','username') {
+ $output .= ''.$headers{$item}.' ';
+ }
+ $output .= ' ';
+ foreach my $item ('approve','email','username') {
+ $output .= '';
+ my (%choices,@options,$hashref,$defoption,$name,$onclick,$hascustom);
+ if ($item eq 'approve') {
+ %choices = &Apache::lonlocal::texthash (
+ automatic => 'Automatically approved',
+ approval => 'Queued for approval',
+ );
+ @options = ('automatic','approval');
+ $hashref = $processing;
+ $defoption = 'automatic';
+ $name = 'cancreate_emailprocess_'.$type;
+ } elsif ($item eq 'email') {
+ %choices = &Apache::lonlocal::texthash (
+ any => 'Any e-mail',
+ inst => 'Institutional only',
+ noninst => 'Non-institutional only',
+ custom => 'Custom restrictions',
+ );
+ @options = ('any','inst','noninst');
+ my $showcustom;
+ if (ref($emailrules) eq 'HASH') {
+ if (keys(%{$emailrules}) > 0) {
+ push(@options,'custom');
+ $showcustom = 'cancreate_emailrule';
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'email_rule'}) eq 'ARRAY') {
+ foreach my $rule (@{$settings->{'email_rule'}}) {
+ if (exists($emailrules->{$rule})) {
+ $hascustom ++;
+ }
+ }
+ } elsif (ref($settings->{'email_rule'}) eq 'HASH') {
+ if (ref($settings->{'email_rule'}{$type}) eq 'ARRAY') {
+ foreach my $rule (@{$settings->{'email_rule'}{$type}}) {
+ if (exists($emailrules->{$rule})) {
+ $hascustom ++;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ $onclick = ' onclick="toggleEmailOptions(this.form,'."'cancreate_emailoptions','$showcustom',".
+ "'cancreate_emaildomain','$type'".');"';
+ $hashref = $emailoptions;
+ $defoption = 'any';
+ $name = 'cancreate_emailoptions_'.$type;
+ } elsif ($item eq 'username') {
+ %choices = &Apache::lonlocal::texthash (
+ all => 'Same as e-mail',
+ first => 'Omit @domain',
+ free => 'Free to choose',
+ );
+ @options = ('all','first','free');
+ $hashref = $emailverified;
+ $defoption = 'all';
+ $name = 'cancreate_usernameoptions_'.$type;
+ }
+ foreach my $option (@options) {
+ my $checked;
+ if (ref($hashref) eq 'HASH') {
+ if ($type eq '') {
+ if (!exists($hashref->{'default'})) {
+ if ($option eq $defoption) {
+ $checked = ' checked="checked"';
+ }
+ } else {
+ if ($hashref->{'default'} eq $option) {
+ $checked = ' checked="checked"';
+ }
+ }
+ } else {
+ if (!exists($hashref->{$type})) {
+ if ($option eq $defoption) {
+ $checked = ' checked="checked"';
+ }
+ } else {
+ if ($hashref->{$type} eq $option) {
+ $checked = ' checked="checked"';
+ }
+ }
+ }
+ } elsif (($item eq 'email') && ($hascustom)) {
+ if ($option eq 'custom') {
+ $checked = ' checked="checked"';
+ }
+ } elsif ($option eq $defoption) {
+ $checked = ' checked="checked"';
+ }
+ $output .= ''.
+ ' '.
+ $choices{$option}.' ';
+ if ($item eq 'email') {
+ if ($option eq 'custom') {
+ my $id = 'cancreate_emailrule_'.$type;
+ my $display = 'none';
+ if ($checked) {
+ $display = 'inline';
+ }
+ my $numinrow = 2;
+ $output .= ''.
+ ''.&mt('Disallow').' '.
+ &user_formats_row('email',$settings,$emailrules,
+ $emailruleorder,$numinrow,'',$type);
+ '
';
+ } elsif (($option eq 'inst') || ($option eq 'noninst')) {
+ my %text = &Apache::lonlocal::texthash (
+ inst => 'must end:',
+ noninst => 'cannot end:',
+ );
+ my $value;
+ if (ref($emaildomain) eq 'HASH') {
+ if (ref($emaildomain->{$type}) eq 'HASH') {
+ $value = $emaildomain->{$type}->{$option};
+ }
+ }
+ if ($value eq '') {
+ $value = '@'.$intdom;
+ }
+ my $condition = 'cancreate_emaildomain_'.$option.'_'.$type;
+ my $display = 'none';
+ if ($checked) {
+ $display = 'inline';
+ }
+ $output .= ''.
+ ''.$text{$option}.' '.
+ ' '.
+ '
';
+ }
+ }
+ }
+ $output .= ' '."\n";
+ }
+ $output .= "
\n";
+ return $output;
+}
+
+sub captcha_choice {
+ my ($context,$settings,$itemcount,$customcss,$rowstyle) = @_;
+ my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext,
+ $vertext,$currver);
+ my %lt = &captcha_phrases();
+ $keyentry = 'hidden';
+ if ($context eq 'cancreate') {
+ $rowname = &mt('CAPTCHA validation');
+ } elsif ($context eq 'login') {
+ $rowname = &mt('"Contact helpdesk" CAPTCHA validation');
+ }
+ if (ref($settings) eq 'HASH') {
+ if ($settings->{'captcha'}) {
+ $checked{$settings->{'captcha'}} = ' checked="checked"';
+ } else {
+ $checked{'original'} = ' checked="checked"';
+ }
+ if ($settings->{'captcha'} eq 'recaptcha') {
+ $pubtext = $lt{'pub'};
+ $privtext = $lt{'priv'};
+ $keyentry = 'text';
+ $vertext = $lt{'ver'};
+ $currver = $settings->{'recaptchaversion'};
+ if ($currver ne '2') {
+ $currver = 1;
+ }
+ }
+ if (ref($settings->{'recaptchakeys'}) eq 'HASH') {
+ $currpub = $settings->{'recaptchakeys'}{'public'};
+ $currpriv = $settings->{'recaptchakeys'}{'private'};
+ }
+ } else {
+ $checked{'original'} = ' checked="checked"';
+ }
+ my $css_class;
+ if ($itemcount%2) {
+ $css_class = 'LC_odd_row';
+ }
+ if ($customcss) {
+ $css_class .= " $customcss";
+ }
+ $css_class =~ s/^\s+//;
+ if ($css_class) {
+ $css_class = ' class="'.$css_class.'"';
+ }
+ if ($rowstyle) {
+ $css_class .= ' style="'.$rowstyle.'"';
+ }
+ my $output = ''.
+ ''.$rowname.' '."\n".
+ ''."\n".
+ ' ';
+ return $output;
+}
+
sub user_formats_row {
- my ($type,$settings,$rules,$ruleorder,$numinrow,$rowcount) = @_;
+ my ($type,$settings,$rules,$ruleorder,$numinrow,$rowcount,$status) = @_;
my $output;
my %text = (
'username' => 'new usernames',
'id' => 'IDs',
- 'email' => 'self-created accounts (e-mail)',
);
- my $css_class = $rowcount%2?' class="LC_odd_row"':'';
- $output = ''.
- '';
- if ($type eq 'email') {
- $output .= &mt("Formats disallowed for $text{$type}: ");
- } else {
- $output .= &mt("Format rules to check for $text{$type}: ");
+ unless ($type eq 'email') {
+ my $css_class = $rowcount%2?' class="LC_odd_row"':'';
+ $output = ''.
+ ''.
+ &mt("Format rules to check for $text{$type}: ").
+ ' ';
}
- $output .= ''.
- ' ';
+ $output .= '
';
+ unless ($type eq 'email') {
+ $output .= ' ';
+ }
return $output;
}
@@ -1940,24 +7479,34 @@ sub usercreation_types {
my %lt = &Apache::lonlocal::texthash (
author => 'When adding a co-author',
course => 'When adding a user to a course',
- selfcreate => 'User creates own account',
+ requestcrs => 'When requesting a course',
any => 'Any',
official => 'Institutional only ',
unofficial => 'Non-institutional only',
- email => 'E-mail address',
- login => 'Institutional Login',
- sso => 'SSO',
none => 'None',
);
return %lt;
}
+sub selfcreation_types {
+ my %lt = &Apache::lonlocal::texthash (
+ selfcreate => 'User creates own account',
+ any => 'Any',
+ official => 'Institutional only ',
+ unofficial => 'Non-institutional only',
+ email => 'E-mail address',
+ login => 'Institutional Login',
+ sso => 'SSO',
+ );
+}
+
sub authtype_names {
my %lt = &Apache::lonlocal::texthash(
int => 'Internal',
krb4 => 'Kerberos 4',
krb5 => 'Kerberos 5',
loc => 'Local',
+ lti => 'LTI',
);
return %lt;
}
@@ -1984,7 +7533,7 @@ sub print_usermodification {
$$rowtotal ++;
$rowcount ++;
}
- } elsif ($position eq 'middle') {
+ } elsif ($position eq 'bottom') {
$context = 'course';
$rowcount = 0;
foreach my $role ('st','ep','ta','in','cr') {
@@ -1993,84 +7542,245 @@ sub print_usermodification {
$$rowtotal ++;
$rowcount ++;
}
- } elsif ($position eq 'bottom') {
- $context = 'selfcreate';
- my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
- $usertypes->{'default'} = $othertitle;
- if (ref($types) eq 'ARRAY') {
- push(@{$types},'default');
- $usertypes->{'default'} = $othertitle;
- foreach my $status (@{$types}) {
- $datatable .= &modifiable_userdata_row($context,$status,$settings,
- $numinrow,$rowcount,$usertypes);
- $$rowtotal ++;
- $rowcount ++;
- }
- }
}
return $datatable;
}
sub print_defaults {
- my ($dom,$rowtotal) = @_;
- my @items = ('auth_def','auth_arg_def','lang_def','timezone_def',
- 'datelocale_def');
- my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
- my $titles = &defaults_titles();
+ my ($position,$dom,$settings,$rowtotal) = @_;
my $rownum = 0;
- my ($datatable,$css_class);
- foreach my $item (@items) {
- if ($rownum%2) {
- $css_class = '';
+ my ($datatable,$css_class,$titles);
+ unless ($position eq 'bottom') {
+ $titles = &defaults_titles($dom);
+ }
+ if ($position eq 'top') {
+ my @items = ('auth_def','auth_arg_def','lang_def','timezone_def',
+ 'datelocale_def','portal_def');
+ my %defaults;
+ if (ref($settings) eq 'HASH') {
+ %defaults = %{$settings};
} else {
- $css_class = ' class="LC_odd_row" ';
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
+ foreach my $item (@items) {
+ $defaults{$item} = $domdefaults{$item};
+ }
}
- $datatable .= ''.
- ''.$titles->{$item}.
- ' ';
- if ($item eq 'auth_def') {
- my @authtypes = ('internal','krb4','krb5','localauth');
- my %shortauth = (
- internal => 'int',
- krb4 => 'krb4',
- krb5 => 'krb5',
- localauth => 'loc'
- );
- my %authnames = &authtype_names();
- foreach my $auth (@authtypes) {
- my $checked = ' ';
- if ($domdefaults{$item} eq $auth) {
- $checked = ' checked="checked" ';
- }
- $datatable .= ' '.
- $authnames{$shortauth{$auth}}.' ';
+ foreach my $item (@items) {
+ if ($rownum%2) {
+ $css_class = '';
+ } else {
+ $css_class = ' class="LC_odd_row" ';
+ }
+ $datatable .= ' '.
+ ''.$titles->{$item}.
+ ' ';
+ if ($item eq 'auth_def') {
+ my @authtypes = ('internal','krb4','krb5','localauth','lti');
+ my %shortauth = (
+ internal => 'int',
+ krb4 => 'krb4',
+ krb5 => 'krb5',
+ localauth => 'loc',
+ lti => 'lti',
+ );
+ my %authnames = &authtype_names();
+ foreach my $auth (@authtypes) {
+ my $checked = ' ';
+ if ($defaults{$item} eq $auth) {
+ $checked = ' checked="checked" ';
+ }
+ $datatable .= ' '.
+ $authnames{$shortauth{$auth}}.' ';
+ }
+ } elsif ($item eq 'timezone_def') {
+ my $includeempty = 1;
+ $datatable .= &Apache::loncommon::select_timezone($item,$defaults{$item},undef,$includeempty);
+ } elsif ($item eq 'datelocale_def') {
+ my $includeempty = 1;
+ $datatable .= &Apache::loncommon::select_datelocale($item,$defaults{$item},undef,$includeempty);
+ } elsif ($item eq 'lang_def') {
+ my $includeempty = 1;
+ $datatable .= &Apache::loncommon::select_language($item,$defaults{$item},$includeempty);
+ } else {
+ my $size;
+ if ($item eq 'portal_def') {
+ $size = ' size="25"';
+ }
+ $datatable .= ' ';
+ }
+ $datatable .= ' ';
+ $rownum ++;
+ }
+ } elsif ($position eq 'middle') {
+ my @items = ('intauth_cost','intauth_check','intauth_switch');
+ my %defaults;
+ if (ref($settings) eq 'HASH') {
+ %defaults = %{$settings};
+ if ($defaults{'intauth_cost'} !~ /^\d+$/) {
+ $defaults{'intauth_cost'} = 10;
+ }
+ if ($defaults{'intauth_check'} !~ /^(0|1|2)$/) {
+ $defaults{'intauth_check'} = 0;
+ }
+ if ($defaults{'intauth_switch'} !~ /^(0|1|2)$/) {
+ $defaults{'intauth_switch'} = 0;
}
- } elsif ($item eq 'timezone_def') {
- my $includeempty = 1;
- $datatable .= &Apache::loncommon::select_timezone($item,$domdefaults{$item},undef,$includeempty);
- } elsif ($item eq 'datelocale_def') {
- my $includeempty = 1;
- $datatable .= &Apache::loncommon::select_datelocale($item,$domdefaults{$item},undef,$includeempty);
} else {
- $datatable .= ' ';
+ %defaults = (
+ 'intauth_cost' => 10,
+ 'intauth_check' => 0,
+ 'intauth_switch' => 0,
+ );
+ }
+ foreach my $item (@items) {
+ if ($rownum%2) {
+ $css_class = '';
+ } else {
+ $css_class = ' class="LC_odd_row" ';
+ }
+ $datatable .= ''.
+ ''.$titles->{$item}.
+ ' ';
+ if ($item eq 'intauth_switch') {
+ my @options = (0,1,2);
+ my %optiondesc = &Apache::lonlocal::texthash (
+ 0 => 'No',
+ 1 => 'Yes',
+ 2 => 'Yes, and copy existing passwd file to passwd.bak file',
+ );
+ $datatable .= '';
+ } elsif ($item eq 'intauth_check') {
+ my @options = (0,1,2);
+ my %optiondesc = &Apache::lonlocal::texthash (
+ 0 => 'No',
+ 1 => 'Yes, allow login then update passwd file using default cost (if higher)',
+ 2 => 'Yes, disallow login if stored cost is less than domain default',
+ );
+ $datatable .= '';
+ } else {
+ $datatable .= ' ';
+ }
+ $datatable .= ' ';
+ $rownum ++;
+ }
+ } else {
+ my %defaults;
+ if (ref($settings) eq 'HASH') {
+ if ((ref($settings->{'inststatusorder'}) eq 'ARRAY') && (ref($settings->{'inststatustypes'}) eq 'HASH')) {
+ my $maxnum = @{$settings->{'inststatusorder'}};
+ for (my $i=0; $i<$maxnum; $i++) {
+ $css_class = $rownum%2?' class="LC_odd_row"':'';
+ my $item = $settings->{'inststatusorder'}->[$i];
+ my $title = $settings->{'inststatustypes'}->{$item};
+ my $chgstr = ' onchange="javascript:reorderTypes(this.form,'."'$item'".');"';
+ $datatable .= ''.
+ ''.
+ '';
+ for (my $k=0; $k<=$maxnum; $k++) {
+ my $vpos = $k+1;
+ my $selstr;
+ if ($k == $i) {
+ $selstr = ' selected="selected" ';
+ }
+ $datatable .= ''.$vpos.' ';
+ }
+ $datatable .= ' '.&mt('Internal ID:').' '.$item.' '.
+ ' '.
+ &mt('delete').' '.
+ ''.&mt('Name displayed:').
+ ' '.
+ ' ';
+ }
+ $css_class = $rownum%2?' class="LC_odd_row"':'';
+ my $chgstr = ' onchange="javascript:reorderTypes(this.form,'."'addinststatus_pos'".');"';
+ $datatable .= ''.
+ '';
+ for (my $k=0; $k<=$maxnum; $k++) {
+ my $vpos = $k+1;
+ my $selstr;
+ if ($k == $maxnum) {
+ $selstr = ' selected="selected" ';
+ }
+ $datatable .= ''.$vpos.' ';
+ }
+ $datatable .= ' '.&mt('Internal ID:').
+ ' '.
+ ' '.&mt('(new)').
+ ''.
+ &mt('Name displayed:').
+ ' '.
+ ' '."\n";
+ $rownum ++;
+ }
}
- $datatable .= ' ';
- $rownum ++;
}
$$rowtotal += $rownum;
return $datatable;
}
+sub get_languages_hash {
+ my %langchoices;
+ foreach my $id (&Apache::loncommon::languageids()) {
+ my $code = &Apache::loncommon::supportedlanguagecode($id);
+ if ($code ne '') {
+ $langchoices{$code} = &Apache::loncommon::plainlanguagedescription($id);
+ }
+ }
+ return %langchoices;
+}
+
sub defaults_titles {
+ my ($dom) = @_;
my %titles = &Apache::lonlocal::texthash (
'auth_def' => 'Default authentication type',
'auth_arg_def' => 'Default authentication argument',
'lang_def' => 'Default language',
'timezone_def' => 'Default timezone',
'datelocale_def' => 'Default locale for dates',
+ 'portal_def' => 'Portal/Default URL',
+ 'intauth_cost' => 'Encryption cost for bcrypt (positive integer)',
+ 'intauth_check' => 'Check bcrypt cost if authenticated',
+ 'intauth_switch' => 'Existing crypt-based switched to bcrypt on authentication',
);
+ if ($dom) {
+ my $uprimary_id = &Apache::lonnet::domain($dom,'primary');
+ my $uint_dom = &Apache::lonnet::internet_dom($uprimary_id);
+ my $protocol = $Apache::lonnet::protocol{$uprimary_id};
+ $protocol = 'http' if ($protocol ne 'https');
+ if ($uint_dom) {
+ $titles{'portal_def'} .= ' '.&mt('(for example: [_1])',$protocol.'://loncapa.'.
+ $uint_dom);
+ }
+ }
return (\%titles);
}
@@ -2081,8 +7791,8 @@ sub print_scantronformat {
%confhash);
my $switchserver = &check_switchserver($dom,$confname);
my %lt = &Apache::lonlocal::texthash (
- default => 'Default scantron format file error',
- custom => 'Custom scantron format file error',
+ default => 'Default bubblesheet format file error',
+ custom => 'Custom bubblesheet format file error',
);
my %scantronfiles = (
default => 'default.tab',
@@ -2155,7 +7865,7 @@ sub print_scantronformat {
}
}
} else {
- $error{'default'} = &mt("Unable to copy default scantron formatfile to domain's RES space: [_1]",$switchserver);
+ $error{'default'} = &mt("Unable to copy default bubblesheet formatfile to domain's RES space: [_1]",$switchserver);
}
}
if (ref($settings) eq 'HASH') {
@@ -2183,14 +7893,14 @@ sub print_scantronformat {
$datatable .= ''.&mt('Default in use:').' '.
'';
if ($scantronurl) {
- $datatable .= ''.
- &mt('Default scantron format file').' ';
+ $datatable .= &Apache::loncommon::modal_link($scantronurl,&mt('Default bubblesheet format file'),600,500,
+ undef,undef,undef,undef,'background-color:#ffffff');
} else {
$datatable = &mt('File unavailable for display');
}
$datatable .= ' ';
if (keys(%error) == 0) {
- $datatable .= '';
+ $datatable .= ' ';
if (!$switchserver) {
$datatable .= &mt('Upload:').' ';
}
@@ -2209,11 +7919,12 @@ sub print_scantronformat {
}
$datatable .= ' '.$errorstr.' ';
} elsif ($scantronurl) {
+ my $link = &Apache::loncommon::modal_link($scantronurl,&mt('Custom bubblesheet format file'),600,500,
+ undef,undef,undef,undef,'background-color:#ffffff');
$datatable .= ' '.
- ''.
- &mt('Custom scantron format file').' '.
- ' '.&mt('Delete?').' '.
+ $link.
+ ' '.&mt('Delete?').' '.
' '.
&mt('Replace:').' ';
}
@@ -2240,7 +7951,7 @@ sub legacy_scantronformat {
&publishlogo($r,'copy',$legacyfile,$dom,$confname,'scantron',
'','',$newfile);
if ($result ne 'ok') {
- $error = &mt("An error occurred publishing the [_1] scantron format file in RES space. Error was: [_2].",$newfile,$result);
+ $error = &mt("An error occurred publishing the [_1] bubblesheet format file in RES space. Error was: [_2].",$newfile,$result);
}
}
return ($url,$error);
@@ -2250,10 +7961,62 @@ sub print_coursecategories {
my ($position,$dom,$hdritem,$settings,$rowtotal) = @_;
my $datatable;
if ($position eq 'top') {
+ my (%checked);
+ my @catitems = ('unauth','auth');
+ my @cattypes = ('std','domonly','codesrch','none');
+ $checked{'unauth'} = 'std';
+ $checked{'auth'} = 'std';
+ if (ref($settings) eq 'HASH') {
+ foreach my $type (@cattypes) {
+ if ($type eq $settings->{'unauth'}) {
+ $checked{'unauth'} = $type;
+ }
+ if ($type eq $settings->{'auth'}) {
+ $checked{'auth'} = $type;
+ }
+ }
+ }
+ my %lt = &Apache::lonlocal::texthash (
+ unauth => 'Catalog type for unauthenticated users',
+ auth => 'Catalog type for authenticated users',
+ none => 'No catalog',
+ std => 'Standard catalog',
+ domonly => 'Domain-only catalog',
+ codesrch => "Code search form",
+ );
+ my $itemcount = 0;
+ foreach my $item (@catitems) {
+ my $css_class = $itemcount%2? ' class="LC_odd_row"':'';
+ $datatable .= ''.
+ ''.$lt{$item}.' '.
+ '';
+ foreach my $type (@cattypes) {
+ my $ischecked;
+ if ($checked{$item} eq $type) {
+ $ischecked=' checked="checked"';
+ }
+ $datatable .= ''.
+ ' '.$lt{$type}.' ';
+ }
+ $datatable .= ' ';
+ $itemcount ++;
+ }
+ $$rowtotal += $itemcount;
+ } elsif ($position eq 'middle') {
my $toggle_cats_crs = ' ';
my $toggle_cats_dom = ' checked="checked" ';
my $can_cat_crs = ' ';
my $can_cat_dom = ' checked="checked" ';
+ my $toggle_catscomm_comm = ' ';
+ my $toggle_catscomm_dom = ' checked="checked" ';
+ my $can_catcomm_comm = ' ';
+ my $can_catcomm_dom = ' checked="checked" ';
+ my $toggle_catsplace_place = ' ';
+ my $toggle_catsplace_dom = ' checked="checked" ';
+ my $can_catplace_place = ' ';
+ my $can_catplace_dom = ' checked="checked" ';
+
if (ref($settings) eq 'HASH') {
if ($settings->{'togglecats'} eq 'crs') {
$toggle_cats_crs = $toggle_cats_dom;
@@ -2263,14 +8026,36 @@ sub print_coursecategories {
$can_cat_crs = $can_cat_dom;
$can_cat_dom = ' ';
}
+ if ($settings->{'togglecatscomm'} eq 'comm') {
+ $toggle_catscomm_comm = $toggle_catscomm_dom;
+ $toggle_catscomm_dom = ' ';
+ }
+ if ($settings->{'categorizecomm'} eq 'comm') {
+ $can_catcomm_comm = $can_catcomm_dom;
+ $can_catcomm_dom = ' ';
+ }
+ if ($settings->{'togglecatsplace'} eq 'place') {
+ $toggle_catsplace_place = $toggle_catsplace_dom;
+ $toggle_catsplace_dom = ' ';
+ }
+ if ($settings->{'categorizeplace'} eq 'place') {
+ $can_catplace_place = $can_catplace_dom;
+ $can_catplace_dom = ' ';
+ }
}
my %title = &Apache::lonlocal::texthash (
- togglecats => 'Show/Hide a course in the catalog',
- categorize => 'Assign a category to a course',
+ togglecats => 'Show/Hide a course in catalog',
+ togglecatscomm => 'Show/Hide a community in catalog',
+ togglecatsplace => 'Show/Hide a placement test in catalog',
+ categorize => 'Assign a category to a course',
+ categorizecomm => 'Assign a category to a community',
+ categorizeplace => 'Assign a category to a placement test',
);
my %level = &Apache::lonlocal::texthash (
- dom => 'Set in "Modify Course" (Domain)',
- crs => 'Set in "Modify Parameters" (Course)',
+ dom => 'Set in Domain',
+ crs => 'Set in Course',
+ comm => 'Set in Community',
+ place => 'Set in Placement Test',
);
$datatable = ''.
''.$title{'togglecats'}.' '.
@@ -2286,8 +8071,36 @@ sub print_coursecategories {
$can_cat_dom.' value="dom" />'.$level{'dom'}.' '.
' '.$level{'crs'}.' '.
+ ' '.
+ ''.$title{'togglecatscomm'}.' '.
+ ''.
+ ' '.$level{'dom'}.' '.
+ ' '.$level{'comm'}.' '.
+ ' '.
+ ''.$title{'categorizecomm'}.' '.
+ ''.
+ ' '.$level{'dom'}.' '.
+ ' '.$level{'comm'}.' '.
+ ' '.
+ ''.$title{'togglecatsplace'}.' '.
+ ''.
+ ' '.$level{'dom'}.' '.
+ ' '.$level{'place'}.' '.
+ ' '.
+ ''.$title{'categorizeplace'}.' '.
+ ''.
+ ' '.$level{'dom'}.' '.
+ ' '.$level{'place'}.' '.
' ';
- $$rowtotal += 2;
+ $$rowtotal += 6;
} else {
my $css_class;
my $itemcount = 1;
@@ -2309,7 +8122,18 @@ sub print_coursecategories {
if (ref($cats[0]) eq 'ARRAY') {
my $numtop = @{$cats[0]};
my $maxnum = $numtop;
- if ((!grep(/^instcode$/,@{$cats[0]})) || ($cathash->{'instcode::0'} eq '')) {
+ my %default_names = (
+ instcode => &mt('Official courses'),
+ communities => &mt('Communities'),
+ placement => &mt('Placement Tests'),
+ );
+
+ if ((!grep(/^instcode$/,@{$cats[0]})) ||
+ ($cathash->{'instcode::0'} eq '') ||
+ (!grep(/^communities$/,@{$cats[0]})) ||
+ ($cathash->{'communities::0'} eq '') ||
+ (!grep(/^placement$/,@{$cats[0]})) ||
+ ($cathash->{'placement::0'} eq '')) {
$maxnum ++;
}
my $lastidx;
@@ -2329,18 +8153,38 @@ sub print_coursecategories {
}
$datatable .= ''.$vpos.' ';
}
- $datatable .= '';
- if ($parent eq 'instcode') {
- $datatable .= ''.&mt('Official courses')
- .' ('
- .&mt('with institutional codes').') '
- .' '
- .&mt('Display').' '
- .' '
- .&mt('Do not display').' ';
+ $datatable .= '';
+ if ($parent eq 'instcode' || $parent eq 'communities' || $parent eq 'placement') {
+ $datatable .= ''
+ .$default_names{$parent}.' ';
+ if ($parent eq 'instcode') {
+ $datatable .= '('
+ .&mt('with institutional codes')
+ .') ';
+ } else {
+ $datatable .= '';
+ }
+ $datatable .= ' ';
} else {
$datatable .= $parent
- .' '
+ .' '.&mt('Delete').' ';
}
my $depth = 1;
@@ -2365,33 +8209,40 @@ sub print_coursecategories {
.' '
.''."\n";
$itemcount ++;
- if ((!grep(/^instcode$/,@{$cats[0]})) || ($cathash->{'instcode::0'} eq '')) {
- $css_class = $itemcount%2?' class="LC_odd_row"':'';
- my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','instcode_pos','$lastidx'".');"';
- $datatable .= ''.
- '';
- for (my $k=0; $k<=$maxnum; $k++) {
- my $vpos = $k+1;
- my $selstr;
- if ($k == $maxnum) {
- $selstr = ' selected="selected" ';
+ foreach my $default ('instcode','communities','placement') {
+ if ((!grep(/^\Q$default\E$/,@{$cats[0]})) || ($cathash->{$default.'::0'} eq '')) {
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','$default"."_pos','$lastidx'".');"';
+ $datatable .= ''.
+ '';
+ for (my $k=0; $k<=$maxnum; $k++) {
+ my $vpos = $k+1;
+ my $selstr;
+ if ($k == $maxnum) {
+ $selstr = ' selected="selected" ';
+ }
+ $datatable .= ''.$vpos.' ';
}
- $datatable .= ''.$vpos.' ';
+ $datatable .= ' '.
+ ''.
+ $default_names{$default}.' ';
+ if ($default eq 'instcode') {
+ $datatable .= '('
+ .&mt('with institutional codes').') ';
+ }
+ $datatable .= ' '
+ .' '
+ .&mt('Display').' '
+ .' '
+ .&mt('Do not display').' ';
}
- $datatable .= ' '
- .&mt('Official courses').' '.'('
- .&mt('with institutional codes').') '
- .' '
- .&mt('Display').' '
- .' '
- .&mt('Do not display').' ';
}
}
} else {
$datatable .= &initialize_categories($itemcount);
}
} else {
- $datatable .= ''.$hdritem->{'header'}->[0]->{'col2'}.' '
+ $datatable .= ''.$hdritem->{'header'}->[1]->{'col2'}.' '
.&initialize_categories($itemcount);
}
$$rowtotal += $itemcount;
@@ -2439,7 +8290,7 @@ sub print_serverstatuses {
''.
' '.
- ''."\n";
+ ' '."\n";
}
$$rowtotal += $rownum;
return $datatable;
@@ -2447,8 +8298,104 @@ sub print_serverstatuses {
sub serverstatus_pages {
return ('userstatus','lonstatus','loncron','server-status','codeversions',
- 'clusterstatus','metadata_keywords','metadata_harvest',
- 'takeoffline','takeonline','showenv');
+ 'checksums','clusterstatus','certstatus','metadata_keywords',
+ 'metadata_harvest','takeoffline','takeonline','showenv','toggledebug',
+ 'ping','domconf','uniquecodes','diskusage','coursecatalog');
+}
+
+sub defaults_javascript {
+ my ($settings) = @_;
+ my $intauthcheck = &mt('Warning: disallowing login for an authenticated user if the stored cost is less than the default will require a password reset by/for the user.');
+ my $intauthcost = &mt('Warning: bcrypt encryption cost for internal authentication must be an integer.');
+ &js_escape(\$intauthcheck);
+ &js_escape(\$intauthcost);
+ my $intauthjs = <<"ENDSCRIPT";
+
+function warnIntAuth(field) {
+ if (field.name == 'intauth_check') {
+ if (field.value == '2') {
+ alert('$intauthcheck');
+ }
+ }
+ if (field.name == 'intauth_cost') {
+ field.value.replace(/\s/g,'');
+ if (field.value != '') {
+ var regexdigit=/^\\d+\$/;
+ if (!regexdigit.test(field.value)) {
+ alert('$intauthcost');
+ }
+ }
+ }
+ return;
+}
+
+ENDSCRIPT
+
+ if (ref($settings) ne 'HASH') {
+ return &Apache::lonhtmlcommon::scripttag($intauthjs);
+ }
+ if ((ref($settings->{'inststatusorder'}) eq 'ARRAY') && (ref($settings->{'inststatustypes'}) eq 'HASH')) {
+ my $maxnum = scalar(@{$settings->{'inststatusorder'}});
+ if ($maxnum eq '') {
+ $maxnum = 0;
+ }
+ $maxnum ++;
+ my $jstext = ' var inststatuses = Array('."'".join("','",@{$settings->{'inststatusorder'}})."'".');';
+ return <<"ENDSCRIPT";
+
+
+ENDSCRIPT
+ } else {
+ return &Apache::lonhtmlcommon::scripttag($intauthjs);
+ }
}
sub coursecategories_javascript {
@@ -2473,13 +8420,21 @@ sub coursecategories_javascript {
$jstext = ' var categories = Array(1);'."\n".
' categories[0] = Array("instcode_pos");'."\n";
}
+ my $instcode_reserved = &mt('The name: [_1] is a reserved category.','"instcode"');
+ my $communities_reserved = &mt('The name: [_1] is a reserved category.','"communities"');
+ my $placement_reserved = &mt('The name: [_1] is a reserved category.','"placement"');
+ 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(\$placement_reserved);
+ &js_escape(\$choose_again);
$output = <<"ENDSCRIPT";
ENDSCRIPT
@@ -2539,27 +8512,48 @@ ENDSCRIPT
sub initialize_categories {
my ($itemcount) = @_;
- my $datatable;
- my $css_class = $itemcount%2?' class="LC_odd_row"':'';
- my $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','instcode_pos','0'".');"';
-
- $datatable = ''
- .'1 '
- .'2 '
- .&mt('Official courses (with institutional codes)')
- .' '
- .' '
- .&mt('Display').' '
- .' '.&mt('Do not display')
+ my ($datatable,$css_class,$chgstr);
+ my %default_names = (
+ instcode => 'Official courses (with institutional codes)',
+ communities => 'Communities',
+ placement => 'Placement Tests',
+ );
+ my %selnum = (
+ instcode => '0',
+ communities => '1',
+ placement => '2',
+ );
+ my %selected;
+ foreach my $default ('instcode','communities','placement') {
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','$default"."_pos','0'".');"';
+ map { $selected{$selnum{$_}} = '' } keys(%selnum);
+ $selected{$selnum{$default}} = ' selected="selected"';
+ $datatable .= ''
+ .''
+ .'1 '
+ .'2 '
+ .'3 '
+ .'4 '
+ .$default_names{$default}
+ .' '
+ .' '
+ .&mt('Display').' '
+ .' '.&mt('Do not display')
.' ';
- $itemcount ++;
+ $itemcount ++;
+ }
$css_class = $itemcount%2?' class="LC_odd_row"':'';
$chgstr = ' onchange="javascript:reorderCats(this.form,'."'','addcategory_pos','0'".');"';
$datatable .= ''
- .'1 '
- .'2 '
- .&mt('Add category').' '.&mt('Name:')
- .' ';
+ .''
+ .'1 '
+ .'2 '
+ .'3 '
+ .'4 '
+ .&mt('Add category').' '.&mt('Name:')
+ .' '
+ .' ';
return $datatable;
}
@@ -2572,7 +8566,7 @@ sub build_category_rows {
if (ref($cats->[$depth]{$parent}) eq 'ARRAY') {
my $numchildren = @{$cats->[$depth]{$parent}};
my $css_class = $itemcount%2?' class="LC_odd_row"':'';
- $text .= '';
+ $text .= '';
my ($idxnum,$parent_name,$parent_item);
my $higher = $depth - 1;
if ($higher == 0) {
@@ -2614,7 +8608,7 @@ sub build_category_rows {
pop(@{$path});
}
} else {
- $text .= &mt('Add subcategory:').' '.&mt('Add subcategory:').' ';
+ $text .= ''.&mt('Add subcategory:').' ';
}
}
}
@@ -2646,14 +8640,30 @@ sub build_category_rows {
}
sub modifiable_userdata_row {
- my ($context,$role,$settings,$numinrow,$rowcount,$usertypes) = @_;
- my $rolename;
- if ($context eq 'selfcreate') {
+ my ($context,$item,$settings,$numinrow,$rowcount,$usertypes,$fieldsref,$titlesref,
+ $rowid,$customcss,$rowstyle) = @_;
+ my ($role,$rolename,$statustype);
+ $role = $item;
+ if ($context eq 'cancreate') {
+ if ($item =~ /^(emailusername)_(.+)$/) {
+ $role = $1;
+ $statustype = $2;
+ if (ref($usertypes) eq 'HASH') {
+ if ($usertypes->{$statustype}) {
+ $rolename = &mt('Data provided by [_1]',$usertypes->{$statustype});
+ } else {
+ $rolename = &mt('Data provided by user');
+ }
+ }
+ }
+ } elsif ($context eq 'selfcreate') {
if (ref($usertypes) eq 'HASH') {
$rolename = $usertypes->{$role};
} else {
$rolename = $role;
}
+ } elsif ($context eq 'lti') {
+ $rolename = &mt('Institutional data used (if available)');
} else {
if ($role eq 'cr') {
$rolename = &mt('Custom role');
@@ -2661,29 +8671,76 @@ sub modifiable_userdata_row {
$rolename = &Apache::lonnet::plaintext($role);
}
}
- my @fields = ('lastname','firstname','middlename','generation',
- 'permanentemail','id');
- my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
+ my (@fields,%fieldtitles);
+ if (ref($fieldsref) eq 'ARRAY') {
+ @fields = @{$fieldsref};
+ } else {
+ @fields = ('lastname','firstname','middlename','generation',
+ 'permanentemail','id');
+ }
+ if ((ref($titlesref) eq 'HASH')) {
+ %fieldtitles = %{$titlesref};
+ } else {
+ %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
+ }
my $output;
- my $css_class = $rowcount%2?' class="LC_odd_row"':'';
- $output = ''.
+ my $css_class;
+ if ($rowcount%2) {
+ $css_class = 'LC_odd_row';
+ }
+ if ($customcss) {
+ $css_class .= " $customcss";
+ }
+ $css_class =~ s/^\s+//;
+ if ($css_class) {
+ $css_class = ' class="'.$css_class.'"';
+ }
+ if ($rowstyle) {
+ $css_class .= ' style="'.$rowstyle.'"';
+ }
+ if ($rowid) {
+ $rowid = ' id="'.$rowid.'"';
+ }
+ $output = ' '.
''.$rolename.' '.
'';
my $rem;
my %checks;
+ my %current;
if (ref($settings) eq 'HASH') {
- if (ref($settings->{$context}) eq 'HASH') {
+ my $hashref;
+ if ($context eq 'lti') {
+ if (ref($settings) eq 'HASH') {
+ $hashref = $settings->{'instdata'};
+ }
+ } elsif (ref($settings->{$context}) eq 'HASH') {
if (ref($settings->{$context}->{$role}) eq 'HASH') {
- foreach my $field (@fields) {
- if ($settings->{$context}->{$role}->{$field}) {
+ $hashref = $settings->{'lti_instdata'};
+ }
+ if ($role eq 'emailusername') {
+ if ($statustype) {
+ if (ref($settings->{$context}->{$role}->{$statustype}) eq 'HASH') {
+ $hashref = $settings->{$context}->{$role}->{$statustype};
+ }
+ }
+ }
+ }
+ if (ref($hashref) eq 'HASH') {
+ foreach my $field (@fields) {
+ if ($hashref->{$field}) {
+ if ($role eq 'emailusername') {
+ $checks{$field} = $hashref->{$field};
+ } else {
$checks{$field} = ' checked="checked" ';
}
}
}
}
}
- for (my $i=0; $i<@fields; $i++) {
- my $rem = $i%($numinrow);
+
+ my $total = scalar(@fields);
+ for (my $i=0; $i<$total; $i++) {
+ $rem = $i%($numinrow);
if ($rem == 0) {
if ($i > 0) {
$output .= '';
@@ -2691,24 +8748,51 @@ sub modifiable_userdata_row {
$output .= '';
}
my $check = ' ';
- if (exists($checks{$fields[$i]})) {
- $check = $checks{$fields[$i]}
- } else {
- if ($role eq 'st') {
- if (ref($settings) ne 'HASH') {
- $check = ' checked="checked" ';
+ unless ($role eq 'emailusername') {
+ if (exists($checks{$fields[$i]})) {
+ $check = $checks{$fields[$i]}
+ } elsif ($context ne 'lti') {
+ if ($role eq 'st') {
+ if (ref($settings) ne 'HASH') {
+ $check = ' checked="checked" ';
+ }
}
}
}
$output .= ''.
- ''.
- ' '.$fieldtitles{$fields[$i]}.
- ' ';
- $rem = @fields%($numinrow);
+ '';
+ my $prefix = 'canmodify';
+ if ($role eq 'emailusername') {
+ unless ($checks{$fields[$i]} =~ /^(required|optional)$/) {
+ $checks{$fields[$i]} = 'omit';
+ }
+ foreach my $option ('required','optional','omit') {
+ my $checked='';
+ if ($checks{$fields[$i]} eq $option) {
+ $checked='checked="checked" ';
+ }
+ $output .= ''.
+ ' '.
+ &mt($option).' '.(' ' x2);
+ }
+ $output .= ''.$fieldtitles{$fields[$i]}.' ';
+ } else {
+ if ($context eq 'lti') {
+ $prefix = 'lti';
+ }
+ $output .= ''.
+ ' '.$fieldtitles{$fields[$i]}.
+ ' ';
+ }
+ $output .= ' ';
+ }
+ $rem = $total%$numinrow;
+ my $colsleft;
+ if ($rem) {
+ $colsleft = $numinrow - $rem;
}
- my $colsleft = $numinrow - $rem;
- if ($colsleft > 1 ) {
+ if ($colsleft > 1) {
$output .= ''.
' ';
} elsif ($colsleft == 1) {
@@ -2718,11 +8802,44 @@ sub modifiable_userdata_row {
return $output;
}
-sub users_cansearch_row {
- my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle) = @_;
- my $output = ' '.
- ''.&mt('Users allowed to search').' ('.$dom.')'.
- ' ';
+sub insttypes_row {
+ my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle,$context,$rowtotal,$onclick,
+ $customcss,$rowstyle) = @_;
+ my %lt = &Apache::lonlocal::texthash (
+ cansearch => 'Users allowed to search',
+ statustocreate => 'Institutional affiliation(s) able to create own account (login/SSO)',
+ lockablenames => 'User preference to lock name',
+ selfassign => 'Self-reportable affiliations',
+ overrides => "Override domain's helpdesk settings based on requester's affiliation",
+ );
+ my $showdom;
+ if ($context eq 'cansearch') {
+ $showdom = ' ('.$dom.')';
+ }
+ my $class = 'LC_left_item';
+ if ($context eq 'statustocreate') {
+ $class = 'LC_right_item';
+ }
+ my $css_class;
+ if ($$rowtotal%2) {
+ $css_class = 'LC_odd_row';
+ }
+ if ($customcss) {
+ $css_class .= ' '.$customcss;
+ }
+ $css_class =~ s/^\s+//;
+ if ($css_class) {
+ $css_class = ' class="'.$css_class.'"';
+ }
+ if ($rowstyle) {
+ $css_class .= ' style="'.$rowstyle.'"';
+ }
+ if ($onclick) {
+ $onclick = 'onclick="'.$onclick.'" ';
+ }
+ my $output = ''.
+ ''.$lt{$context}.$showdom.
+ ' ';
+ $output .= '
';
return $output;
}
@@ -2841,17 +8981,25 @@ sub usertype_update_row {
}
sub modify_login {
- my ($r,$dom,$confname,%domconfig) = @_;
- my ($resulttext,$errors,$colchgtext,%changes,%colchanges);
- my %title = ( coursecatalog => 'Display course catalog',
- adminmail => 'Display administrator E-mail address',
- newuser => 'Link for visitors to create a user account',
- loginheader => 'Log-in box header');
- my @offon = ('off','on');
- my %loginhash;
+ my ($r,$dom,$confname,$lastactref,%domconfig) = @_;
+ my ($resulttext,$errors,$colchgtext,%changes,%colchanges,%newfile,%newurl,
+ %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');
+ if (ref($domconfig{login}) eq 'HASH') {
+ if (ref($domconfig{login}{loginvia}) eq 'HASH') {
+ foreach my $lonhost (keys(%{$domconfig{login}{loginvia}})) {
+ $curr_loginvia{$lonhost} = $domconfig{login}{loginvia}{$lonhost};
+ }
+ }
+ }
($errors,%colchanges) = &modify_colors($r,$dom,$confname,['login'],
\%domconfig,\%loginhash);
- my @toggles = ('coursecatalog','adminmail','newuser');
+ my @toggles = ('coursecatalog','adminmail','helpdesk','newuser');
foreach my $item (@toggles) {
$loginhash{login}{$item} = $env{'form.'.$item};
}
@@ -2860,12 +9008,252 @@ sub modify_login {
$colchgtext = &display_colorchgs($dom,\%colchanges,['login'],
\%loginhash);
}
+
+ my %servers = &Apache::lonnet::internet_dom_servers($dom);
+ my %domservers = &Apache::lonnet::get_servers($dom);
+ my @loginvia_attribs = ('serverpath','custompath','exempt');
+ if (keys(%servers) > 1) {
+ foreach my $lonhost (keys(%servers)) {
+ next if ($env{'form.'.$lonhost.'_server'} eq $lonhost);
+ if (ref($curr_loginvia{$lonhost}) eq 'HASH') {
+ if ($env{'form.'.$lonhost.'_server'} eq $curr_loginvia{$lonhost}{'server'}) {
+ $loginhash{login}{loginvia}{$lonhost}{'server'} = $curr_loginvia{$lonhost}{'server'};
+ } elsif ($curr_loginvia{$lonhost}{'server'} ne '') {
+ if (defined($servers{$env{'form.'.$lonhost.'_server'}})) {
+ $loginhash{login}{loginvia}{$lonhost}{'server'} = $env{'form.'.$lonhost.'_server'};
+ $changes{'loginvia'}{$lonhost} = 1;
+ } else {
+ $loginhash{login}{loginvia}{$lonhost}{'server'} = '';
+ $changes{'loginvia'}{$lonhost} = 1;
+ }
+ } else {
+ if (defined($servers{$env{'form.'.$lonhost.'_server'}})) {
+ $loginhash{login}{loginvia}{$lonhost}{'server'} = $env{'form.'.$lonhost.'_server'};
+ $changes{'loginvia'}{$lonhost} = 1;
+ }
+ }
+ if ($loginhash{login}{loginvia}{$lonhost}{'server'} eq '') {
+ foreach my $item (@loginvia_attribs) {
+ $loginhash{login}{loginvia}{$lonhost}{$item} = '';
+ }
+ } else {
+ foreach my $item (@loginvia_attribs) {
+ my $new = $env{'form.'.$lonhost.'_'.$item};
+ if (($item eq 'serverpath') && ($new eq 'custom')) {
+ $env{'form.'.$lonhost.'_custompath'} =~ s/\s+//g;
+ if ($env{'form.'.$lonhost.'_custompath'} eq '') {
+ $new = '/';
+ }
+ }
+ if (($item eq 'custompath') &&
+ ($env{'form.'.$lonhost.'_serverpath'} ne 'custom')) {
+ $new = '';
+ }
+ if ($new ne $curr_loginvia{$lonhost}{$item}) {
+ $changes{'loginvia'}{$lonhost} = 1;
+ }
+ if ($item eq 'exempt') {
+ $new = &check_exempt_addresses($new);
+ }
+ $loginhash{login}{loginvia}{$lonhost}{$item} = $new;
+ }
+ }
+ } else {
+ if (defined($servers{$env{'form.'.$lonhost.'_server'}})) {
+ $loginhash{login}{loginvia}{$lonhost}{'server'} = $env{'form.'.$lonhost.'_server'};
+ $changes{'loginvia'}{$lonhost} = 1;
+ foreach my $item (@loginvia_attribs) {
+ my $new = $env{'form.'.$lonhost.'_'.$item};
+ if (($item eq 'serverpath') && ($new eq 'custom')) {
+ if ($env{'form.'.$lonhost.'_custompath'} eq '') {
+ $new = '/';
+ }
+ }
+ if (($item eq 'custompath') &&
+ ($env{'form.'.$lonhost.'_serverpath'} ne 'custom')) {
+ $new = '';
+ }
+ $loginhash{login}{loginvia}{$lonhost}{$item} = $new;
+ }
+ }
+ }
+ }
+ }
+
+ my $servadm = $r->dir_config('lonAdmEMail');
+ my %langchoices = &Apache::lonlocal::texthash(&get_languages_hash());
+ if (ref($domconfig{'login'}) eq 'HASH') {
+ if (ref($domconfig{'login'}{'helpurl'}) eq 'HASH') {
+ foreach my $lang (sort(keys(%{$domconfig{'login'}{'helpurl'}}))) {
+ if ($lang eq 'nolang') {
+ push(@currlangs,$lang);
+ } elsif (defined($langchoices{$lang})) {
+ push(@currlangs,$lang);
+ } else {
+ next;
+ }
+ }
+ }
+ }
+ my @delurls = &Apache::loncommon::get_env_multiple('form.loginhelpurl_del');
+ if (@currlangs > 0) {
+ foreach my $lang (@currlangs) {
+ if (grep(/^\Q$lang\E$/,@delurls)) {
+ $changes{'helpurl'}{$lang} = 1;
+ } elsif ($env{'form.loginhelpurl_'.$lang.'.filename'}) {
+ $changes{'helpurl'}{$lang} = 1;
+ $newfile{$lang} = $env{'form.loginhelpurl_'.$lang.'.filename'};
+ push(@newlangs,$lang);
+ } else {
+ $loginhash{'login'}{'helpurl'}{$lang} = $domconfig{'login'}{'helpurl'}{$lang};
+ }
+ }
+ }
+ unless (grep(/^nolang$/,@currlangs)) {
+ if ($env{'form.loginhelpurl_nolang.filename'}) {
+ $changes{'helpurl'}{'nolang'} = 1;
+ $newfile{'nolang'} = $env{'form.loginhelpurl_nolang.filename'};
+ push(@newlangs,'nolang');
+ }
+ }
+ if ($env{'form.loginhelpurl_add_lang'}) {
+ if ((defined($langchoices{$env{'form.loginhelpurl_add_lang'}})) &&
+ ($env{'form.loginhelpurl_add_file.filename'})) {
+ $newfile{$env{'form.loginhelpurl_add_lang'}} = $env{'form.loginhelpurl_add_file.filename'};
+ $addedfile = $env{'form.loginhelpurl_add_lang'};
+ }
+ }
+ if ((@newlangs > 0) || ($addedfile)) {
+ my $error;
+ my ($configuserok,$author_ok,$switchserver) = &config_check($dom,$confname,$servadm);
+ if ($configuserok eq 'ok') {
+ if ($switchserver) {
+ $error = &mt("Upload of custom help file is not permitted to this server: [_1]",$switchserver);
+ } elsif ($author_ok eq 'ok') {
+ my @allnew = @newlangs;
+ if ($addedfile ne '') {
+ push(@allnew,$addedfile);
+ }
+ foreach my $lang (@allnew) {
+ my $formelem = 'loginhelpurl_'.$lang;
+ if ($lang eq $env{'form.loginhelpurl_add_lang'}) {
+ $formelem = 'loginhelpurl_add_file';
+ }
+ (my $result,$newurl{$lang}) = &publishlogo($r,'upload',$formelem,$dom,$confname,
+ "help/$lang",'','',$newfile{$lang});
+ if ($result eq 'ok') {
+ $loginhash{'login'}{'helpurl'}{$lang} = $newurl{$lang};
+ $changes{'helpurl'}{$lang} = 1;
+ } 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)) &&
+ (!grep(/^\Q$lang\E$/,@delurls))) {
+ $loginhash{'login'}{'helpurl'}{$lang} = $domconfig{'login'}{'helpurl'}{$lang};
+ }
+ }
+ }
+ } else {
+ $error = &mt("Upload of custom log-in help file(s) failed because an author role could not be assigned to a Domain Configuration user ([_1]) in domain: [_2]. Error was: [_3].",$confname,$dom,$author_ok);
+ }
+ } else {
+ $error = &mt("Upload of custom log-in help file(s) failed because a Domain Configuration user ([_1]) could not be created in domain: [_2]. Error was: [_3].",$confname,$dom,$configuserok);
+ }
+ if ($error) {
+ &Apache::lonnet::logthis($error);
+ $errors .= ''.$error.' ';
+ }
+ }
+
+ my (%currheadtagurls,%currexempt,@newhosts,%newheadtagurls,%possexempt);
+ if (ref($domconfig{'login'}) eq 'HASH') {
+ if (ref($domconfig{'login'}{'headtag'}) eq 'HASH') {
+ foreach my $lonhost (keys(%{$domconfig{'login'}{'headtag'}})) {
+ if ($domservers{$lonhost}) {
+ if (ref($domconfig{'login'}{'headtag'}{$lonhost}) eq 'HASH') {
+ $currheadtagurls{$lonhost} = $domconfig{'login'}{'headtag'}{$lonhost}{'url'};
+ $currexempt{$lonhost} = $domconfig{'login'}{'headtag'}{$lonhost}{'exempt'};
+ }
+ }
+ }
+ }
+ }
+ my @delheadtagurls = &Apache::loncommon::get_env_multiple('form.loginheadtag_del');
+ foreach my $lonhost (sort(keys(%domservers))) {
+ if (grep(/^\Q$lonhost\E$/,@delheadtagurls)) {
+ $changes{'headtag'}{$lonhost} = 1;
+ } else {
+ if ($env{'form.loginheadtagexempt_'.$lonhost}) {
+ $possexempt{$lonhost} = &check_exempt_addresses($env{'form.loginheadtagexempt_'.$lonhost});
+ }
+ if ($env{'form.loginheadtag_'.$lonhost.'.filename'}) {
+ push(@newhosts,$lonhost);
+ } elsif ($currheadtagurls{$lonhost}) {
+ $loginhash{'login'}{'headtag'}{$lonhost}{'url'} = $currheadtagurls{$lonhost};
+ if ($currexempt{$lonhost}) {
+ if ((!exists($possexempt{$lonhost})) || ($possexempt{$lonhost} ne $currexempt{$lonhost})) {
+ $changes{'headtag'}{$lonhost} = 1;
+ }
+ } elsif ($possexempt{$lonhost}) {
+ $changes{'headtag'}{$lonhost} = 1;
+ }
+ if ($possexempt{$lonhost}) {
+ $loginhash{'login'}{'headtag'}{$lonhost}{'exempt'} = $possexempt{$lonhost};
+ }
+ }
+ }
+ }
+ if (@newhosts) {
+ my $error;
+ my ($configuserok,$author_ok,$switchserver) = &config_check($dom,$confname,$servadm);
+ if ($configuserok eq 'ok') {
+ if ($switchserver) {
+ $error = &mt("Upload of custom markup is not permitted to this server: [_1]",$switchserver);
+ } elsif ($author_ok eq 'ok') {
+ foreach my $lonhost (@newhosts) {
+ my $formelem = 'loginheadtag_'.$lonhost;
+ (my $result,$newheadtagurls{$lonhost}) = &publishlogo($r,'upload',$formelem,$dom,$confname,
+ "login/headtag/$lonhost",'','',
+ $env{'form.loginheadtag_'.$lonhost.'.filename'});
+ if ($result eq 'ok') {
+ $loginhash{'login'}{'headtag'}{$lonhost}{'url'} = $newheadtagurls{$lonhost};
+ $changes{'headtag'}{$lonhost} = 1;
+ if ($possexempt{$lonhost}) {
+ $loginhash{'login'}{'headtag'}{$lonhost}{'exempt'} = $possexempt{$lonhost};
+ }
+ } else {
+ my $puberror = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",
+ $newheadtagurls{$lonhost},$result);
+ $errors .= ''.$puberror.' ';
+ if ((grep(/^\Q$lonhost\E$/,keys(%currheadtagurls))) &&
+ (!grep(/^\Q$lonhost\E$/,@delheadtagurls))) {
+ $loginhash{'login'}{'headtag'}{$lonhost} = $currheadtagurls{$lonhost};
+ }
+ }
+ }
+ } else {
+ $error = &mt("Upload of custom markup file(s) failed because an author role could not be assigned to a Domain Configuration user ([_1]) in domain: [_2]. Error was: [_3].",$confname,$dom,$author_ok);
+ }
+ } else {
+ $error = &mt("Upload of custom markup file(s) failed because a Domain Configuration user ([_1]) could not be created in domain: [_2]. Error was: [_3].",$confname,$dom,$configuserok);
+ }
+ if ($error) {
+ &Apache::lonnet::logthis($error);
+ $errors .= ''.$error.' ';
+ }
+ }
+ &process_captcha('login',\%changes,$loginhash{'login'},$domconfig{'login'});
+
+ my $defaulthelpfile = '/adm/loginproblems.html';
+ my $defaulttext = &mt('Default in use');
+
my $putresult = &Apache::lonnet::put_dom('configuration',\%loginhash,
$dom);
if ($putresult eq 'ok') {
- my @toggles = ('coursecatalog','adminmail','newuser');
+ my @toggles = ('coursecatalog','adminmail','helpdesk','newuser');
my %defaultchecked = (
'coursecatalog' => 'on',
+ 'helpdesk' => 'on',
'adminmail' => 'off',
'newuser' => 'off',
);
@@ -2891,21 +9279,131 @@ sub modify_login {
}
}
}
- if (($domconfig{'login'}{'loginheader'} eq 'text') &&
- ($env{'form.loginheader'} eq 'image')) {
- $changes{'loginheader'} = 1;
- } elsif (($domconfig{'login'}{'loginheader'} eq '' ||
- $domconfig{'login'}{'loginheader'} eq 'image') &&
- ($env{'form.loginheader'} eq 'text')) {
- $changes{'loginheader'} = 1;
- }
}
if (keys(%changes) > 0 || $colchgtext) {
&Apache::loncommon::devalidate_domconfig_cache($dom);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domainconfig'} = 1;
+ }
$resulttext = &mt('Changes made:').'';
foreach my $item (sort(keys(%changes))) {
- if ($item eq 'loginheader') {
- $resulttext .= ''.&mt("$title{$item} set to $env{'form.loginheader'}").' ';
+ if ($item eq 'loginvia') {
+ if (ref($changes{$item}) eq 'HASH') {
+ $resulttext .= ''.&mt('Log-in page availability:').'';
+ foreach my $lonhost (sort(keys(%{$changes{$item}}))) {
+ if (defined($servers{$loginhash{login}{loginvia}{$lonhost}{'server'}})) {
+ if (ref($loginhash{login}{loginvia}{$lonhost}) eq 'HASH') {
+ my $protocol = $Apache::lonnet::protocol{$env{'form.'.$lonhost.'_server'}};
+ $protocol = 'http' if ($protocol ne 'https');
+ my $target = $protocol.'://'.$servers{$env{'form.'.$lonhost.'_server'}};
+
+ if ($loginhash{login}{loginvia}{$lonhost}{'serverpath'} eq 'custom') {
+ $target .= $loginhash{login}{loginvia}{$lonhost}{'custompath'};
+ } else {
+ $target .= $loginhash{login}{loginvia}{$lonhost}{'serverpath'};
+ }
+ $resulttext .= ''.&mt('Server: [_1] log-in page redirects to [_2].',$servers{$lonhost},''.$target.' ');
+ if ($loginhash{login}{loginvia}{$lonhost}{'exempt'} ne '') {
+ $resulttext .= ' '.&mt('No redirection for clients from following IPs:').' '.$loginhash{login}{loginvia}{$lonhost}{'exempt'};
+ }
+ $resulttext .= ' ';
+ } else {
+ $resulttext .= ''.&mt('Server: [_1] has standard log-in page.',$lonhost).' ';
+ }
+ } else {
+ $resulttext .= ''.&mt('Server: [_1] has standard log-in page.',$servers{$lonhost}).' ';
+ }
+ }
+ $resulttext .= ' ';
+ }
+ } elsif ($item eq 'helpurl') {
+ if (ref($changes{$item}) eq 'HASH') {
+ foreach my $lang (sort(keys(%{$changes{$item}}))) {
+ if (grep(/^\Q$lang\E$/,@delurls)) {
+ my ($chg,$link);
+ $link = &Apache::loncommon::modal_link($defaulthelpfile,$defaulttext,600,500);
+ if ($lang eq 'nolang') {
+ $chg = &mt('custom log-in help file removed for no preferred language; [_1]',$link);
+ } else {
+ $chg = &mt('custom log-in help file removed for specific language: [_1]; [_2]',$langchoices{$lang},$link);
+ }
+ $resulttext .= ''.$chg.' ';
+ } else {
+ my $chg;
+ if ($lang eq 'nolang') {
+ $chg = &mt('custom log-in help file for no preferred language');
+ } else {
+ $chg = &mt('custom log-in help file for specific language: [_1]',$langchoices{$lang});
+ }
+ $resulttext .= ''.&Apache::loncommon::modal_link(
+ $loginhash{'login'}{'helpurl'}{$lang}.
+ '?inhibitmenu=yes',$chg,600,500).
+ ' ';
+ }
+ }
+ }
+ } elsif ($item eq 'headtag') {
+ if (ref($changes{$item}) eq 'HASH') {
+ foreach my $lonhost (sort(keys(%{$changes{$item}}))) {
+ if (grep(/^\Q$lonhost\E$/,@delheadtagurls)) {
+ $resulttext .= ''.&mt('custom markup file removed for [_1]',$domservers{$lonhost}).' ';
+ } elsif (ref($loginhash{'login'}{'headtag'}{$lonhost}) eq 'HASH') {
+ $resulttext .= ''.&mt('custom markup').' '.&mt('(for [_1])',$servers{$lonhost}).' ';
+ if ($possexempt{$lonhost}) {
+ $resulttext .= &mt('not included for client IP(s): [_1]',$possexempt{$lonhost});
+ } else {
+ $resulttext .= &mt('included for any client IP');
+ }
+ $resulttext .= ' ';
+ }
+ }
+ }
+ } elsif ($item eq 'captcha') {
+ if (ref($loginhash{'login'}) eq 'HASH') {
+ my $chgtxt;
+ if ($loginhash{'login'}{$item} eq 'notused') {
+ $chgtxt .= &mt('No CAPTCHA validation in use for helpdesk form.');
+ } else {
+ my %captchas = &captcha_phrases();
+ if ($captchas{$loginhash{'login'}{$item}}) {
+ $chgtxt .= &mt("Validation for helpdesk form set to $captchas{$loginhash{'login'}{$item}}.");
+ } else {
+ $chgtxt .= &mt('Validation for helpdesk form set to unknown type.');
+ }
+ }
+ $resulttext .= ''.$chgtxt.' ';
+ }
+ } elsif ($item eq 'recaptchakeys') {
+ if (ref($loginhash{'login'}) eq 'HASH') {
+ my ($privkey,$pubkey);
+ if (ref($loginhash{'login'}{$item}) eq 'HASH') {
+ $pubkey = $loginhash{'login'}{$item}{'public'};
+ $privkey = $loginhash{'login'}{$item}{'private'};
+ }
+ my $chgtxt .= &mt('ReCAPTCHA keys changes').'';
+ if (!$pubkey) {
+ $chgtxt .= ''.&mt('Public key deleted').' ';
+ } else {
+ $chgtxt .= ''.&mt('Public key set to [_1]',$pubkey).' ';
+ }
+ if (!$privkey) {
+ $chgtxt .= ''.&mt('Private key deleted').' ';
+ } else {
+ $chgtxt .= ''.&mt('Private key set to [_1]',$privkey).' ';
+ }
+ $chgtxt .= ' ';
+ $resulttext .= ''.$chgtxt.' ';
+ }
+ } elsif ($item eq 'recaptchaversion') {
+ if (ref($loginhash{'login'}) eq 'HASH') {
+ if ($loginhash{'login'}{'captcha'} eq 'recaptcha') {
+ $resulttext .= ''.&mt('ReCAPTCHA for helpdesk form set to version [_1]',$loginhash{'login'}{'recaptchaversion'}).
+ ' ';
+ }
+ }
} else {
$resulttext .= ''.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").' ';
}
@@ -2925,6 +9423,27 @@ sub modify_login {
return $resulttext;
}
+sub check_exempt_addresses {
+ my ($iplist) = @_;
+ $iplist =~ s/^\s+//;
+ $iplist =~ s/\s+$//;
+ my @poss_ips = split(/\s*[,:]\s*/,$iplist);
+ my (@okips,$new);
+ foreach my $ip (@poss_ips) {
+ if ($ip =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) {
+ if (($1 <= 255) && ($2 <= 255) && ($3 <= 255) && ($4 <= 255)) {
+ push(@okips,$ip);
+ }
+ }
+ }
+ if (@okips > 0) {
+ $new = join(',',@okips);
+ } else {
+ $new = '';
+ }
+ return $new;
+}
+
sub color_font_choices {
my %choices =
&Apache::lonlocal::texthash (
@@ -2933,6 +9452,7 @@ sub color_font_choices {
links => "Link colors",
images => "Images",
font => "Font color",
+ fontmenu => "Font menu",
pgbg => "Page",
tabbg => "Header",
sidebg => "Border",
@@ -2944,7 +9464,7 @@ sub color_font_choices {
}
sub modify_rolecolors {
- my ($r,$dom,$confname,$roles,%domconfig) = @_;
+ my ($r,$dom,$confname,$roles,$lastactref,%domconfig) = @_;
my ($resulttext,%rolehash);
$rolehash{'rolecolors'} = {};
if (ref($domconfig{'rolecolors'}) ne 'HASH') {
@@ -2959,6 +9479,9 @@ sub modify_rolecolors {
if ($putresult eq 'ok') {
if (keys(%changes) > 0) {
&Apache::loncommon::devalidate_domconfig_cache($dom);
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domainconfig'} = 1;
+ }
$resulttext = &display_colorchgs($dom,\%changes,$roles,
$rolehash{'rolecolors'});
} else {
@@ -2984,6 +9507,7 @@ sub modify_colors {
my @images;
my $servadm = $r->dir_config('lonAdmEMail');
my $errors;
+ my %defaults;
foreach my $role (@{$roles}) {
if ($role eq 'login') {
%choices = &login_choices();
@@ -2996,11 +9520,48 @@ sub modify_colors {
@bgs = ('pgbg','mainbg','sidebg');
} else {
@images = ('img');
- @bgs = ('pgbg','tabbg','sidebg');
+ @bgs = ('pgbg','tabbg','sidebg');
+ }
+ my %defaults = &role_defaults($role,\@bgs,\@links,\@images,\@logintext);
+ unless ($env{'form.'.$role.'_font'} eq $defaults{'font'}) {
+ $confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
+ }
+ if ($role eq 'login') {
+ foreach my $item (@logintext) {
+ $env{'form.'.$role.'_'.$item} = lc($env{'form.'.$role.'_'.$item});
+ if ($env{'form.'.$role.'_'.$item} =~ /^\w+/) {
+ $env{'form.'.$role.'_'.$item} = '#'.$env{'form.'.$role.'_'.$item};
+ }
+ unless ($env{'form.'.$role.'_'.$item} eq lc($defaults{'logintext'}{$item})) {
+ $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
+ }
+ }
+ } else {
+ $env{'form.'.$role.'_fontmenu'} = lc($env{'form.'.$role.'_fontmenu'});
+ if ($env{'form.'.$role.'_fontmenu'} =~ /^\w+/) {
+ $env{'form.'.$role.'_fontmenu'} = '#'.$env{'form.'.$role.'_fontmenu'};
+ }
+ unless($env{'form.'.$role.'_fontmenu'} eq lc($defaults{'fontmenu'})) {
+ $confhash->{$role}{'fontmenu'} = $env{'form.'.$role.'_fontmenu'};
+ }
+ }
+ foreach my $item (@bgs) {
+ $env{'form.'.$role.'_'.$item} = lc($env{'form.'.$role.'_'.$item});
+ if ($env{'form.'.$role.'_'.$item} =~ /^\w+/) {
+ $env{'form.'.$role.'_'.$item} = '#'.$env{'form.'.$role.'_'.$item};
+ }
+ unless ($env{'form.'.$role.'_'.$item} eq lc($defaults{'bgs'}{$item})) {
+ $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
+ }
}
- $confhash->{$role}{'font'} = $env{'form.'.$role.'_font'};
- foreach my $item (@bgs,@links,@logintext) {
- $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
+ foreach my $item (@links) {
+ $env{'form.'.$role.'_'.$item} = lc($env{'form.'.$role.'_'.$item});
+ if ($env{'form.'.$role.'_'.$item} =~ /^\w+/) {
+ $env{'form.'.$role.'_'.$item} = '#'.$env{'form.'.$role.'_'.$item};
+ }
+ unless ($env{'form.'.$role.'_'.$item} eq lc($defaults{'links'}{$item})) {
+ $confhash->{$role}{$item} = $env{'form.'.$role.'_'.$item};
+ }
}
my ($configuserok,$author_ok,$switchserver) =
&config_check($dom,$confname,$servadm);
@@ -3112,6 +9673,17 @@ sub modify_colors {
$changes{$role}{'font'} = 1;
}
}
+ if ($role ne 'login') {
+ 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}) {
@@ -3241,7 +9813,7 @@ sub display_colorchgs {
} else {
my $newitem = $confhash->{$role}{$item};
if ($key eq 'images') {
- $newitem = ' ';
+ $newitem = ' ';
}
$resulttext .= ''.&mt("$choices{$item} set to [_1]",$newitem).' ';
}
@@ -3323,7 +9895,7 @@ sub check_authorstatus {
sub publishlogo {
my ($r,$action,$formname,$dom,$confname,$subdir,$thumbwidth,$thumbheight,$savefileas) = @_;
- my ($output,$fname,$logourl);
+ my ($output,$fname,$logourl,$madethumb);
if ($action eq 'upload') {
$fname=$env{'form.'.$formname.'.filename'};
chop($env{'form.'.$formname});
@@ -3337,15 +9909,17 @@ sub publishlogo {
# See if there is anything left
unless ($fname) { return ('error: no uploaded file'); }
$fname="$subdir/$fname";
- my $filepath='/home/'.$confname.'/public_html';
+ my $docroot=$r->dir_config('lonDocRoot');
+ my $filepath="$docroot/priv";
+ my $relpath = "$dom/$confname";
my ($fnamepath,$file,$fetchthumb);
$file=$fname;
if ($fname=~m|/|) {
($fnamepath,$file) = ($fname =~ m|^(.*)/([^/]+)$|);
}
- my @parts=split(/\//,$filepath.'/'.$fnamepath);
+ my @parts=split(/\//,"$filepath/$relpath/$fnamepath");
my $count;
- for ($count=4;$count<=$#parts;$count++) {
+ for ($count=5;$count<=$#parts;$count++) {
$filepath.="/$parts[$count]";
if ((-e $filepath)!=1) {
mkdir($filepath,02770);
@@ -3355,25 +9929,25 @@ sub publishlogo {
if ($file=~/\.(\w+)$/ &&
(&Apache::loncommon::fileembstyle($1) eq 'hdn')) {
$output =
- &mt('Invalid file extension ([_1]) - reserved for LONCAPA use.',$1);
+ &mt('Invalid file extension ([_1]) - reserved for internal use.',$1);
} elsif ($file=~/\.(\w+)$/ &&
!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('File name not allowed - rename the file to remove the number immediately before the file extension([_1]) and re-upload.',$2);
+ $output = &mt('Filename 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('File name is a directory name - rename the file and re-upload');
+ $output = &mt('Filename is a directory name - rename the file and re-upload');
} else {
my $source = $filepath.'/'.$file;
my $logfile;
- if (!open($logfile,">>$source".'.log')) {
- return (&mt('No write permission to Construction Space'));
+ if (!open($logfile,">>",$source.'.log')) {
+ return (&mt('No write permission to Authoring Space'));
}
print $logfile
"\n================= Publish ".localtime()." ================\n".
$env{'user.name'}.':'.$env{'user.domain'}."\n";
# Save the file
- if (!open(FH,'>'.$source)) {
+ if (!open(FH,">",$source)) {
&Apache::lonnet::logthis('Failed to create '.$source);
return (&mt('Failed to create file'));
}
@@ -3392,7 +9966,6 @@ $env{'user.name'}.':'.$env{'user.domain'
close(FH);
chmod(0660, $source); # Permissions to rw-rw---.
- my $docroot=$r->dir_config('lonDocRoot');
my $targetdir=$docroot.'/res/'.$dom.'/'.$confname .'/'.$fnamepath;
my $copyfile=$targetdir.'/'.$file;
@@ -3415,8 +9988,15 @@ $env{'user.name'}.':'.$env{'user.domain'
if (copy($source,$copyfile)) {
print $logfile "\nCopied original source to ".$copyfile."\n";
$output = 'ok';
- &write_metadata($dom,$confname,$formname,$targetdir,$file,$logfile);
$logourl = '/res/'.$dom.'/'.$confname.'/'.$fname;
+ push(@{$modified_urls},[$copyfile,$source]);
+ my $metaoutput =
+ &write_metadata($dom,$confname,$formname,$targetdir,$file,$logfile);
+ unless ($registered_cleanup) {
+ my $handlers = $r->get_handlers('PerlCleanupHandler');
+ $r->set_handlers('PerlCleanupHandler' => [\¬ifysubscribed,@{$handlers}]);
+ $registered_cleanup=1;
+ }
} else {
print $logfile "\nUnable to write ".$copyfile.':'.$!."\n";
$output = &mt('Failed to copy file to RES space').", $!";
@@ -3428,14 +10008,23 @@ $env{'user.name'}.':'.$env{'user.domain'
if ($fullwidth ne '' && $fullheight ne '') {
if ($fullwidth > $thumbwidth && $fullheight > $thumbheight) {
my $thumbsize = $thumbwidth.'x'.$thumbheight;
- system("convert -sample $thumbsize $inputfile $outfile");
+ my @args = ('convert','-sample',$thumbsize,$inputfile,$outfile);
+ system({$args[0]} @args);
chmod(0660, $filepath.'/tn-'.$file);
if (-e $outfile) {
my $copyfile=$targetdir.'/tn-'.$file;
if (copy($outfile,$copyfile)) {
print $logfile "\nCopied source to ".$copyfile."\n";
- &write_metadata($dom,$confname,$formname,
- $targetdir,'tn-'.$file,$logfile);
+ my $thumb_metaoutput =
+ &write_metadata($dom,$confname,$formname,
+ $targetdir,'tn-'.$file,$logfile);
+ push(@{$modified_urls},[$copyfile,$outfile]);
+ unless ($registered_cleanup) {
+ my $handlers = $r->get_handlers('PerlCleanupHandler');
+ $r->set_handlers('PerlCleanupHandler' => [\¬ifysubscribed,@{$handlers}]);
+ $registered_cleanup=1;
+ }
+ $madethumb = 1;
} else {
print $logfile "\nUnable to write ".$copyfile.
':'.$!."\n";
@@ -3448,7 +10037,7 @@ $env{'user.name'}.':'.$env{'user.domain'
$output = $versionresult;
}
}
- return ($output,$logourl);
+ return ($output,$logourl,$madethumb);
}
sub logo_versioning {
@@ -3500,30 +10089,79 @@ sub write_metadata {
{
print $logfile "\nWrite metadata file for ".$targetdir.'/'.$file;
my $mfh;
- unless (open($mfh,'>'.$targetdir.'/'.$file.'.meta')) {
+ if (open($mfh,">",$targetdir.'/'.$file.'.meta')) {
+ foreach (sort(keys(%metadatafields))) {
+ unless ($_=~/\./) {
+ my $unikey=$_;
+ $unikey=~/^([A-Za-z]+)/;
+ my $tag=$1;
+ $tag=~tr/A-Z/a-z/;
+ print $mfh "\n\<$tag";
+ foreach (split(/\,/,$metadatakeys{$unikey})) {
+ my $value=$metadatafields{$unikey.'.'.$_};
+ $value=~s/\"/\'\'/g;
+ print $mfh ' '.$_.'="'.$value.'"';
+ }
+ print $mfh '>'.
+ &HTML::Entities::encode($metadatafields{$unikey},'<>&"')
+ .''.$tag.'>';
+ }
+ }
+ $output = 'ok';
+ print $logfile "\nWrote metadata";
+ close($mfh);
+ } else {
+ print $logfile "\nFailed to open metadata file";
$output = &mt('Could not write metadata');
}
- foreach (sort keys %metadatafields) {
- unless ($_=~/\./) {
- my $unikey=$_;
- $unikey=~/^([A-Za-z]+)/;
- my $tag=$1;
- $tag=~tr/A-Z/a-z/;
- print $mfh "\n\<$tag";
- foreach (split(/\,/,$metadatakeys{$unikey})) {
- my $value=$metadatafields{$unikey.'.'.$_};
- $value=~s/\"/\'\'/g;
- print $mfh ' '.$_.'="'.$value.'"';
- }
- print $mfh '>'.
- &HTML::Entities::encode($metadatafields{$unikey},'<>&"')
- .''.$tag.'>';
- }
- }
- $output = 'ok';
- print $logfile "\nWrote metadata";
- close($mfh);
}
+ return $output;
+}
+
+sub notifysubscribed {
+ foreach my $targetsource (@{$modified_urls}){
+ next unless (ref($targetsource) eq 'ARRAY');
+ my ($target,$source)=@{$targetsource};
+ if ($source ne '') {
+ if (open(my $logfh,">>",$source.'.log')) {
+ print $logfh "\nCleanup phase: Notifications\n";
+ my @subscribed=&subscribed_hosts($target);
+ foreach my $subhost (@subscribed) {
+ print $logfh "\nNotifying host ".$subhost.':';
+ my $reply=&Apache::lonnet::critical('update:'.$target,$subhost);
+ print $logfh $reply;
+ }
+ my @subscribedmeta=&subscribed_hosts("$target.meta");
+ foreach my $subhost (@subscribedmeta) {
+ print $logfh "\nNotifying host for metadata only ".$subhost.':';
+ my $reply=&Apache::lonnet::critical('update:'.$target.'.meta',
+ $subhost);
+ print $logfh $reply;
+ }
+ print $logfh "\n============ Done ============\n";
+ close($logfh);
+ }
+ }
+ }
+ return OK;
+}
+
+sub subscribed_hosts {
+ my ($target) = @_;
+ my @subscribed;
+ if (open(my $fh,"<","$target.subscription")) {
+ while (my $subline=<$fh>) {
+ if ($subline =~ /^($match_lonid):/) {
+ my $host = $1;
+ if ($host ne $Apache::lonnet::perlvar{'lonHostID'}) {
+ unless (grep(/^\Q$host\E$/,@subscribed)) {
+ push(@subscribed,$host);
+ }
+ }
+ }
+ }
+ }
+ return @subscribed;
}
sub check_switchserver {
@@ -3536,69 +10174,396 @@ 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;
}
-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 ($r,$dom,$action,$lastactref,%domconfig) = @_;
+ my ($context,@usertools,@options,%validations,%titles,%confhash,%toolshash,
+ %limithash,$toolregexp,%conditions,$resulttext,%changes,$confname,$configuserok,
+ $author_ok,$switchserver,$errors,$validationitemsref,$validationnamesref,
+ $validationfieldsref);
if ($action eq 'quotas') {
$context = 'tools';
- } else {
+ } else {
$context = $action;
}
if ($context eq 'requestcourses') {
- @usertools = ('official','unofficial');
+ @usertools = ('official','unofficial','community','textbook','placement','lti');
+ @options =('norequest','approval','validate','autolimit');
+ %validations = &Apache::lonnet::auto_courserequest_checks($dom);
+ %titles = &courserequest_titles();
+ $toolregexp = join('|',@usertools);
+ %conditions = &courserequest_conditions();
+ $confname = $dom.'-domainconfig';
+ my $servadm = $r->dir_config('lonAdmEMail');
+ ($configuserok,$author_ok,$switchserver) = &config_check($dom,$confname,$servadm);
+ ($validationitemsref,$validationnamesref,$validationfieldsref) =
+ &Apache::loncoursequeueadmin::requestcourses_validation_types();
+ } elsif ($context eq 'requestauthor') {
+ @usertools = ('author');
+ %titles = &authorrequest_titles();
} else {
- @usertools = ('aboutme','blog','portfolio');
+ @usertools = ('aboutme','blog','webdav','portfolio');
+ %titles = &tool_titles();
}
- my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
- my ($resulttext,%changes);
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
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};
+ }
+ }
+ } elsif ($context eq 'requestauthor') {
+ if ($key =~ /^\Qform.authorreq_\E(.+)$/) {
+ $confhash{$1} = $env{$key};
+ }
+ } else {
if ($key =~ /^form\.quota_(.+)$/) {
$confhash{'defaultquota'}{$1} = $env{$key};
+ } elsif ($key =~ /^form\.authorquota_(.+)$/) {
+ $confhash{'authorquota'}{$1} = $env{$key};
+ } elsif ($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') {
+ if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+ my @approvalnotify = &Apache::loncommon::get_env_multiple('form.'.$context.'notifyapproval');
+ @approvalnotify = sort(@approvalnotify);
+ $confhash{'notify'}{'approval'} = join(',',@approvalnotify);
+ my @crstypes = ('official','unofficial','community','textbook','placement','lti');
+ my @hasuniquecode = &Apache::loncommon::get_env_multiple('form.uniquecode');
+ foreach my $type (@hasuniquecode) {
+ if (grep(/^\Q$type\E$/,@crstypes)) {
+ $confhash{'uniquecode'}{$type} = 1;
+ }
+ }
+ my (%newbook,%allpos);
+ if ($context eq 'requestcourses') {
+ foreach my $type ('textbooks','templates') {
+ @{$allpos{$type}} = ();
+ my $invalid;
+ if ($type eq 'textbooks') {
+ $invalid = &mt('Invalid LON-CAPA course for textbook');
+ } else {
+ $invalid = &mt('Invalid LON-CAPA course for template');
+ }
+ if ($env{'form.'.$type.'_addbook'}) {
+ if (($env{'form.'.$type.'_addbook_cnum'} =~ /^$match_courseid$/) &&
+ ($env{'form.'.$type.'_addbook_cdom'} =~ /^$match_domain$/)) {
+ if (&Apache::lonnet::homeserver($env{'form.'.$type.'_addbook_cnum'},
+ $env{'form.'.$type.'_addbook_cdom'}) eq 'no_host') {
+ $errors .= ''.$invalid.' ';
+ } else {
+ $newbook{$type} = $env{'form.'.$type.'_addbook_cdom'}.'_'.$env{'form.'.$type.'_addbook_cnum'};
+ my $position = $env{'form.'.$type.'_addbook_pos'};
+ $position =~ s/\D+//g;
+ if ($position ne '') {
+ $allpos{$type}[$position] = $newbook{$type};
+ }
+ }
+ } else {
+ $errors .= ''.$invalid.' ';
+ }
+ }
+ }
+ }
+ if (ref($domconfig{$action}) eq 'HASH') {
+ if (ref($domconfig{$action}{'notify'}) eq 'HASH') {
+ if ($domconfig{$action}{'notify'}{'approval'} ne $confhash{'notify'}{'approval'}) {
+ $changes{'notify'}{'approval'} = 1;
+ }
+ } else {
+ if ($confhash{'notify'}{'approval'}) {
+ $changes{'notify'}{'approval'} = 1;
+ }
+ }
+ if (ref($domconfig{$action}{'uniquecode'}) eq 'HASH') {
+ if (ref($confhash{'uniquecode'}) eq 'HASH') {
+ foreach my $crstype (keys(%{$domconfig{$action}{'uniquecode'}})) {
+ unless ($confhash{'uniquecode'}{$crstype}) {
+ $changes{'uniquecode'} = 1;
+ }
+ }
+ unless ($changes{'uniquecode'}) {
+ foreach my $crstype (keys(%{$confhash{'uniquecode'}})) {
+ unless ($domconfig{$action}{'uniquecode'}{$crstype}) {
+ $changes{'uniquecode'} = 1;
+ }
+ }
+ }
+ } else {
+ $changes{'uniquecode'} = 1;
+ }
+ } elsif (ref($confhash{'uniquecode'}) eq 'HASH') {
+ $changes{'uniquecode'} = 1;
+ }
+ if ($context eq 'requestcourses') {
+ foreach my $type ('textbooks','templates') {
+ if (ref($domconfig{$action}{$type}) eq 'HASH') {
+ my %deletions;
+ my @todelete = &Apache::loncommon::get_env_multiple('form.'.$type.'_del');
+ if (@todelete) {
+ map { $deletions{$_} = 1; } @todelete;
+ }
+ my %imgdeletions;
+ my @todeleteimages = &Apache::loncommon::get_env_multiple('form.'.$type.'_image_del');
+ if (@todeleteimages) {
+ map { $imgdeletions{$_} = 1; } @todeleteimages;
+ }
+ my $maxnum = $env{'form.'.$type.'_maxnum'};
+ for (my $i=0; $i<=$maxnum; $i++) {
+ my $itemid = $env{'form.'.$type.'_id_'.$i};
+ my ($key) = ($itemid =~ /^\Q$type\E_(\w+)$/);
+ if (ref($domconfig{$action}{$type}{$key}) eq 'HASH') {
+ if ($deletions{$key}) {
+ if ($domconfig{$action}{$type}{$key}{'image'}) {
+ #FIXME need to obsolete item in RES space
+ }
+ next;
+ } else {
+ my $newpos = $env{'form.'.$itemid};
+ $newpos =~ s/\D+//g;
+ foreach my $item ('subject','title','publisher','author') {
+ next if ((($item eq 'author') || ($item eq 'publisher')) &&
+ ($type eq 'templates'));
+ $confhash{$type}{$key}{$item} = $env{'form.'.$type.'_'.$item.'_'.$i};
+ if ($domconfig{$action}{$type}{$key}{$item} ne $confhash{$type}{$key}{$item}) {
+ $changes{$type}{$key} = 1;
+ }
+ }
+ $allpos{$type}[$newpos] = $key;
+ }
+ if ($imgdeletions{$key}) {
+ $changes{$type}{$key} = 1;
+ #FIXME need to obsolete item in RES space
+ } elsif ($env{'form.'.$type.'_image_'.$i.'.filename'}) {
+ my ($cdom,$cnum) = split(/_/,$key);
+ if (&Apache::lonnet::homeserver($cnum,$cdom) eq 'no_host') {
+ $errors .= ''.&mt('Image not saved: could not find textbook course').' ';
+ } else {
+ my ($imgurl,$error) = &process_textbook_image($r,$dom,$confname,$type.'_image_'.$i,
+ $cdom,$cnum,$type,$configuserok,
+ $switchserver,$author_ok);
+ if ($imgurl) {
+ $confhash{$type}{$key}{'image'} = $imgurl;
+ $changes{$type}{$key} = 1;
+ }
+ if ($error) {
+ &Apache::lonnet::logthis($error);
+ $errors .= ''.$error.' ';
+ }
+ }
+ } elsif ($domconfig{$action}{$type}{$key}{'image'}) {
+ $confhash{$type}{$key}{'image'} =
+ $domconfig{$action}{$type}{$key}{'image'};
+ }
+ }
+ }
+ }
+ }
+ }
+ } else {
+ if ($confhash{'notify'}{'approval'}) {
+ $changes{'notify'}{'approval'} = 1;
+ }
+ if (ref($confhash{'uniquecode'} eq 'HASH')) {
+ $changes{'uniquecode'} = 1;
+ }
+ }
+ if ($context eq 'requestcourses') {
+ foreach my $type ('textbooks','templates') {
+ if ($newbook{$type}) {
+ $changes{$type}{$newbook{$type}} = 1;
+ foreach my $item ('subject','title','publisher','author') {
+ next if ((($item eq 'author') || ($item eq 'publisher')) &&
+ ($type eq 'template'));
+ $env{'form.'.$type.'_addbook_'.$item} =~ s/(`)/'/g;
+ if ($env{'form.'.$type.'_addbook_'.$item}) {
+ $confhash{$type}{$newbook{$type}}{$item} = $env{'form.'.$type.'_addbook_'.$item};
+ }
+ }
+ if ($type eq 'textbooks') {
+ if ($env{'form.'.$type.'_addbook_image.filename'} ne '') {
+ my ($cdom,$cnum) = split(/_/,$newbook{$type});
+ if (&Apache::lonnet::homeserver($cnum,$cdom) eq 'no_host') {
+ $errors .= ''.&mt('Image not saved: could not find textbook course').' ';
+ } else {
+ my ($imageurl,$error) =
+ &process_textbook_image($r,$dom,$confname,$type.'_addbook_image',$cdom,$cnum,$type,
+ $configuserok,$switchserver,$author_ok);
+ if ($imageurl) {
+ $confhash{$type}{$newbook{$type}}{'image'} = $imageurl;
+ }
+ if ($error) {
+ &Apache::lonnet::logthis($error);
+ $errors .= ''.$error.' ';
+ }
+ }
+ }
+ }
+ }
+ if (@{$allpos{$type}} > 0) {
+ my $idx = 0;
+ foreach my $item (@{$allpos{$type}}) {
+ if ($item ne '') {
+ $confhash{$type}{$item}{'order'} = $idx;
+ if (ref($domconfig{$action}) eq 'HASH') {
+ if (ref($domconfig{$action}{$type}) eq 'HASH') {
+ if (ref($domconfig{$action}{$type}{$item}) eq 'HASH') {
+ if ($domconfig{$action}{$type}{$item}{'order'} ne $idx) {
+ $changes{$type}{$item} = 1;
+ }
+ }
+ }
+ }
+ $idx ++;
+ }
+ }
+ }
+ }
+ if (ref($validationitemsref) eq 'ARRAY') {
+ foreach my $item (@{$validationitemsref}) {
+ if ($item eq 'fields') {
+ my @changed;
+ @{$confhash{'validation'}{$item}} = &Apache::loncommon::get_env_multiple('form.requestcourses_validation_'.$item);
+ if (@{$confhash{'validation'}{$item}} > 0) {
+ @{$confhash{'validation'}{$item}} = sort(@{$confhash{'validation'}{$item}});
+ }
+ if (ref($domconfig{'requestcourses'}) eq 'HASH') {
+ if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
+ if (ref($domconfig{'requestcourses'}{'validation'}{$item}) eq 'ARRAY') {
+ @changed = &Apache::loncommon::compare_arrays($confhash{'validation'}{$item},
+ $domconfig{'requestcourses'}{'validation'}{$item});
+ } else {
+ @changed = @{$confhash{'validation'}{$item}};
+ }
+ } else {
+ @changed = @{$confhash{'validation'}{$item}};
+ }
+ } else {
+ @changed = @{$confhash{'validation'}{$item}};
+ }
+ if (@changed) {
+ if ($confhash{'validation'}{$item}) {
+ $changes{'validation'}{$item} = join(', ',@{$confhash{'validation'}{$item}});
+ } else {
+ $changes{'validation'}{$item} = &mt('None');
+ }
+ }
+ } else {
+ $confhash{'validation'}{$item} = $env{'form.requestcourses_validation_'.$item};
+ if ($item eq 'markup') {
+ if ($env{'form.requestcourses_validation_'.$item}) {
+ $env{'form.requestcourses_validation_'.$item} =~ s/[\n\r\f]+/\s/gs;
+ }
+ }
+ if (ref($domconfig{'requestcourses'}) eq 'HASH') {
+ if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
+ if ($domconfig{'requestcourses'}{'validation'}{$item} ne $confhash{'validation'}{$item}) {
+ $changes{'validation'}{$item} = $confhash{'validation'}{$item};
+ }
+ } else {
+ if ($confhash{'validation'}{$item} ne '') {
+ $changes{'validation'}{$item} = $confhash{'validation'}{$item};
+ }
+ }
+ } else {
+ if ($confhash{'validation'}{$item} ne '') {
+ $changes{'validation'}{$item} = $confhash{'validation'}{$item};
+ }
+ }
+ }
+ }
+ }
+ if ($env{'form.validationdc'}) {
+ my $newval = $env{'form.validationdc'};
+ my %domcoords = &Apache::lonnet::get_active_domroles($dom,['dc']);
+ if (exists($domcoords{$newval})) {
+ $confhash{'validation'}{'dc'} = $newval;
+ }
+ }
+ if (ref($confhash{'validation'}) eq 'HASH') {
+ if (ref($domconfig{'requestcourses'}) eq 'HASH') {
+ if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
+ if ($domconfig{'requestcourses'}{'validation'}{'dc'}) {
+ unless ($confhash{'validation'}{'dc'} eq $domconfig{'requestcourses'}{'validation'}{'dc'}) {
+ if ($confhash{'validation'}{'dc'} eq '') {
+ $changes{'validation'}{'dc'} = &mt('None');
+ } else {
+ $changes{'validation'}{'dc'} = $confhash{'validation'}{'dc'};
+ }
+ }
+ } elsif ($confhash{'validation'}{'dc'} ne '') {
+ $changes{'validation'}{'dc'} = $confhash{'validation'}{'dc'};
+ }
+ } elsif ($confhash{'validation'}{'dc'} ne '') {
+ $changes{'validation'}{'dc'} = $confhash{'validation'}{'dc'};
+ }
+ } elsif ($confhash{'validation'}{'dc'} ne '') {
+ $changes{'validation'}{'dc'} = $confhash{'validation'}{'dc'};
+ }
+ } else {
+ if (ref($domconfig{'requestcourses'}) eq 'HASH') {
+ if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
+ if ($domconfig{'requestcourses'}{'validation'}{'dc'}) {
+ $changes{'validation'}{'dc'} = &mt('None');
+ }
+ }
+ }
+ }
+ }
+ } else {
$confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'};
+ $confhash{'authorquota'}{'default'} = $env{'form.authorquota'};
}
foreach my $item (@usertools) {
foreach my $type (@{$types},'default','_LC_adv') {
- if (grep(/^\Q$type\E$/,@{$toolshash{$item}})) {
- $confhash{$item}{$type} = 1;
+ my $unset;
+ if ($context eq 'requestcourses') {
+ $unset = '0';
+ if ($type eq '_LC_adv') {
+ $unset = '';
+ }
+ if ($confhash{$item}{$type} eq 'autolimit') {
+ $confhash{$item}{$type} .= '=';
+ unless ($limithash{$item}{$type} =~ /\D/) {
+ $confhash{$item}{$type} .= $limithash{$item}{$type};
+ }
+ }
+ } elsif ($context eq 'requestauthor') {
+ $unset = '0';
+ if ($type eq '_LC_adv') {
+ $unset = '';
+ }
} 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') {
+ if ($action eq 'requestauthor') {
+ if ($domconfig{$action}{$type} ne $confhash{$type}) {
+ $changes{$type} = 1;
+ }
+ } elsif (ref($domconfig{$action}{$item}) eq 'HASH') {
if ($domconfig{$action}{$item}{$type} ne $confhash{$item}{$type}) {
$changes{$item}{$type} = 1;
}
} else {
if ($context eq 'requestcourses') {
- if ($confhash{$item}{$type}) {
+ if ($confhash{$item}{$type} ne $unset) {
$changes{$item}{$type} = 1;
}
} else {
@@ -3609,9 +10574,13 @@ sub modify_quotas {
}
} else {
if ($context eq 'requestcourses') {
- if ($confhash{$item}{$type}) {
+ if ($confhash{$item}{$type} ne $unset) {
$changes{$item}{$type} = 1;
}
+ } elsif ($context eq 'requestauthor') {
+ if ($confhash{$type} ne $unset) {
+ $changes{$type} = 1;
+ }
} else {
if (!$confhash{$item}{$type}) {
$changes{$item}{$type} = 1;
@@ -3620,7 +10589,7 @@ sub modify_quotas {
}
}
}
- unless ($context eq 'requestcourses') {
+ unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
if (ref($domconfig{'quotas'}) eq 'HASH') {
if (ref($domconfig{'quotas'}{'defaultquota'}) eq 'HASH') {
foreach my $key (keys(%{$domconfig{'quotas'}{'defaultquota'}})) {
@@ -3643,6 +10612,17 @@ sub modify_quotas {
}
}
}
+ if (ref($domconfig{'quotas'}{'authorquota'}) eq 'HASH') {
+ foreach my $key (keys(%{$domconfig{'quotas'}{'authorquota'}})) {
+ if (exists($confhash{'authorquota'}{$key})) {
+ if ($confhash{'authorquota'}{$key} ne $domconfig{'quotas'}{'authorquota'}{$key}) {
+ $changes{'authorquota'}{$key} = 1;
+ }
+ } else {
+ $confhash{'authorquota'}{$key} = $domconfig{'quotas'}{'authorquota'}{$key};
+ }
+ }
+ }
}
if (ref($confhash{'defaultquota'}) eq 'HASH') {
foreach my $key (keys(%{$confhash{'defaultquota'}})) {
@@ -3661,12 +10641,33 @@ sub modify_quotas {
}
}
}
+ if (ref($confhash{'authorquota'}) eq 'HASH') {
+ foreach my $key (keys(%{$confhash{'authorquota'}})) {
+ if (ref($domconfig{'quotas'}) eq 'HASH') {
+ if (ref($domconfig{'quotas'}{'authorquota'}) eq 'HASH') {
+ if (!exists($domconfig{'quotas'}{'authorquota'}{$key})) {
+ $changes{'authorquota'}{$key} = 1;
+ }
+ } else {
+ $changes{'authorquota'}{$key} = 1;
+ }
+ } else {
+ $changes{'authorquota'}{$key} = 1;
+ }
+ }
+ }
}
- foreach my $key (keys(%confhash)) {
- $domdefaults{$key} = $confhash{$key};
+ if ($context eq 'requestauthor') {
+ $domdefaults{'requestauthor'} = \%confhash;
+ } else {
+ foreach my $key (keys(%confhash)) {
+ unless (($context eq 'requestcourses') && (($key eq 'textbooks') || ($key eq 'templates'))) {
+ $domdefaults{$key} = $confhash{$key};
+ }
+ }
}
-
+
my %quotahash = (
$action => { %confhash }
);
@@ -3676,9 +10677,12 @@ sub modify_quotas {
if (keys(%changes) > 0) {
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
-
+ if (ref($lastactref) eq 'HASH') {
+ $lastactref->{'domdefaults'} = 1;
+ }
$resulttext = &mt('Changes made:').'