--- loncom/interface/loncommon.pm 2008/03/03 10:50:26 1.643 +++ loncom/interface/loncommon.pm 2009/05/01 01:07:55 1.800 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.643 2008/03/03 10:50:26 foxr Exp $ +# $Id: loncommon.pm,v 1.800 2009/05/01 01:07:55 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -61,12 +61,15 @@ use POSIX qw(strftime mktime); use Apache::lonmenu(); use Apache::lonenc(); use Apache::lonlocal; +use Apache::lonnet(); use HTML::Entities; use Apache::lonhtmlcommon(); use Apache::loncoursedata(); use Apache::lontexconvert(); use Apache::lonclonecourse(); use LONCAPA qw(:DEFAULT :match); +use DateTime::TimeZone; +use DateTime::Locale::Catalog; # ---------------------------------------------- Designs use vars qw(%defaultdesign); @@ -84,25 +87,40 @@ my $readit; =pod -=head1 Server Side incliude with retries: +=head1 Server Side include with retries: =over 4 -=item * ssi_with_retries(resource, retries form) +=item * &ssi_with_retries(resource,retries form) Performs an ssi with some number of retries. Retries continue either until the result is ok or until the retry count supplied by the caller is exhausted. Inputs: + +=over 4 + resource - Identifies the resource to insert. + retries - Count of the number of retries allowed. + form - Hash that identifies the rendering options. -Returns: +=back + +Returns: + +=over 4 + content - The content of the response. If retries were exhausted this is empty. + response - The response from the last attempt (which may or may not have been successful. +=back + +=back + =cut sub ssi_with_retries { @@ -118,6 +136,9 @@ sub ssi_with_retries { do { ($content, $response) = &Apache::lonnet::ssi($resource, %form); $ok = $response->is_success; + if (!$ok) { + &Apache::lonnet::logthis("Failed ssi_with_retries on $resource: ".$response->is_success.', '.$response->code.', '.$response->message); + } $retries--; } while (!$ok && ($retries > 0)); @@ -250,7 +271,7 @@ BEGIN { } } &Apache::lonnet::logthis( - "INFO: Read file types"); + "INFO: Read file types"); $readit=1; } # end of unless($readit) @@ -266,14 +287,14 @@ BEGIN { =over 4 -=item * browser_and_searcher_javascript () +=item * &browser_and_searcher_javascript() XXReturns a string containing javascript with two functions, C and C. Returned string does not contain EscriptE tags. -=item * openbrowser(formname,elementname,only,omit) [javascript] +=item * &openbrowser(formname,elementname,only,omit) [javascript] inputs: formname, elementname, only, omit @@ -286,7 +307,7 @@ with the given extension. Can be a comm Specifying 'omit' will restrict the browser to NOT displaying files with the given extension. Can be a comma separated list. -=item * opensearcher(formname, elementname) [javascript] +=item * &opensearcher(formname,elementname) [javascript] Inputs: formname, elementname @@ -371,7 +392,7 @@ sub storeresurl { unless ($resurl=~/^\/res/) { return 0; } $resurl=~s/\/$//; &Apache::lonnet::put('environment',{'lastresurl' => $resurl}); - &Apache::lonnet::appenv('environment.lastresurl' => $resurl); + &Apache::lonnet::appenv({'environment.lastresurl' => $resurl}); return 1; } @@ -385,9 +406,9 @@ sub studentbrowser_javascript { || ($env{'request.role'}=~/^(au|dc|su)/) ) { return ''; } return (<<'ENDSTDBRW'); - +ENDAUTHORBRW +} + sub coursebrowser_javascript { my ($domainfilter,$sec_element,$formname)=@_; my $crs_or_grp_alert = &mt('Please select the type of LON-CAPA entity - Course or Group - for which you wish to add/modify a user role'); my $output = ' - block and html for two