--- loncom/interface/lonrequestcourse.pm 2018/03/23 01:01:21 1.103 +++ loncom/interface/lonrequestcourse.pm 2019/07/25 20:23:52 1.107 @@ -1,7 +1,7 @@ # The LearningOnline Network # Request a course # -# $Id: lonrequestcourse.pm,v 1.103 2018/03/23 01:01:21 raeburn Exp $ +# $Id: lonrequestcourse.pm,v 1.107 2019/07/25 20:23:52 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -119,6 +119,10 @@ use Apache::loncoursequeueadmin; use Apache::lonuserutils; use LONCAPA qw(:DEFAULT :match); +my $registered_flush; +my $registered_instcats; +my $modified_dom; + sub handler { my ($r) = @_; &Apache::loncommon::content_type($r,'text/html'); @@ -127,6 +131,10 @@ sub handler { return OK; } + $registered_flush = 0; + $registered_instcats = 0; + $modified_dom = ''; + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['action','showdom','cnum','state','crstype','queue','tabs']); &Apache::lonhtmlcommon::clear_breadcrumbs(); @@ -3371,14 +3379,14 @@ sub get_course_dom { return $env{'user.domain'}; } } - my (@possible_doms,%willtrust,%trustchecked); + my (@possible_doms,%willtrust); foreach my $type (@{$types}) { my $dom_str = $env{'environment.reqcrsotherdom.'.$type}; if ($dom_str ne '') { my @domains = split(',',$dom_str); foreach my $entry (@domains) { my ($extdom,$extopt) = split(':',$entry); - unless ($trustchecked{$extdom}) { + unless (exists($willtrust{$extdom})) { $willtrust{$extdom} = &Apache::lonnet::will_trust('reqcrs',$env{'user.domain'},$extdom); } if ($willtrust{$extdom}) { @@ -3887,6 +3895,24 @@ sub process_request { } $output .= '

'; $creationresult = 'created'; + # Flush the course logs so reverse user roles immediately updated + unless ($registered_flush) { + my $handlers = $r->get_handlers('PerlCleanupHandler'); + $r->set_handlers('PerlCleanupHandler' => [\&Apache::lonnet::flushcourselogs,@{$handlers}]); + $registered_flush=1; + } + if ($instcode ne '') { + &Apache::lonnet::devalidate_cache_new('instcats',$dom); + # Update cache of self-cataloging courses on institution's server(s). + if (&Apache::lonnet::shared_institution($dom)) { + unless ($registered_instcats) { + my $handlers = $r->get_handlers('PerlCleanupHandler'); + $r->set_handlers('PerlCleanupHandler' => [\&devalidate_remote_instcats,@{$handlers}]); + $registered_instcats=1; + $modified_dom = $dom; + } + } + } } else { $output = ''; if ($crstype eq 'community') { @@ -4022,6 +4048,22 @@ sub process_request { } } +sub devalidate_remote_instcats { + if ($modified_dom ne '') { + my %servers = &Apache::lonnet::internet_dom_servers($modified_dom); + my %thismachine; + map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids(); + if (keys(%servers)) { + foreach my $server (keys(%servers)) { + next if ($thismachine{$server}); + &Apache::lonnet::remote_devalidate_cache($server,['instcats:'.$modified_dom]); + } + } + $modified_dom = ''; + } + return; +} + sub custom_formitems { my ($preprocess,$customhash) = @_; return unless ((ref($preprocess) eq 'HASH') && (ref($customhash) eq 'HASH')); @@ -4330,9 +4372,10 @@ sub pending_validation_form { $buttontext = &mt('Create course'); } } + my $hostname = &Apache::lonnet::hostname($lonhost); my $protocol = $Apache::lonnet::protocol{$lonhost}; $protocol = 'http' if ($protocol ne 'https'); - my $crscreator = $protocol.'://'.&Apache::lonnet::hostname($lonhost).'/cgi-bin/createpending.pl'; + my $crscreator = $protocol.'://'.$hostname.'/cgi-bin/createpending.pl'; $output .= ''."\n". ''."\n". ''."\n". @@ -5098,6 +5141,9 @@ sub process_textbook_request { } else { $details->{dateshift} = ''; } + } elsif (($reqtype eq 'textbook') || ($reqtype eq 'template')) { + $details->{datemode} = 'delete'; + $details->{dateshift} = ''; } if ($details->{dateshift} ne '') { $details->{dateshift} =~ s/[^\d\.]+//g;