--- loncom/publisher/lonpublisher.pm 2003/06/30 17:13:08 1.123 +++ loncom/publisher/lonpublisher.pm 2003/09/22 00:48:32 1.134 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Publication Handler # -# $Id: lonpublisher.pm,v 1.123 2003/06/30 17:13:08 albertel Exp $ +# $Id: lonpublisher.pm,v 1.134 2003/09/22 00:48:32 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -82,6 +82,26 @@ invocation by F: ErrorDocument 500 /adm/errorhandler +=head1 OVERVIEW + +Authors can only write-access the C space. They can +copy resources into the resource area through the publication step, +and move them back through a recover step. Authors do not have direct +write-access to their resource space. + +During the publication step, several events will be +triggered. Metadata is gathered, where a wizard manages default +entries on a hierarchical per-directory base: The wizard imports the +metadata (including access privileges and royalty information) from +the most recent published resource in the current directory, and if +that is not available, from the next directory above, etc. The Network +keeps all previous versions of a resource and makes them available by +an explicit version number, which is inserted between the file name +and extension, for example C, while the most recent +version does not carry a version number (C). Servers +subscribing to a changed resource are notified that a new version is +available. + =head1 DESCRIPTION B takes the proper steps to add resources to the LON-CAPA @@ -122,6 +142,7 @@ use DBI; use Apache::lonnet(); use Apache::loncommon(); use Apache::lonmysql; +use Apache::lonlocal; use vars qw(%metadatafields %metadatakeys); my %addid; @@ -304,6 +325,7 @@ string which presents the form field (fo ######################################### sub textfield { my ($title,$name,$value)=@_; + $title=&mt($title); my $uctitle=uc($title); return "\n

$uctitle:". "


". @@ -317,6 +339,7 @@ sub hiddenfield { sub selectbox { my ($title,$name,$value,$functionref,@idlist)=@_; + $title=&mt($title); my $uctitle=uc($title); $value=(split(/\s*,\s*/,$value))[-1]; my $selout="\n

$uctitle:". @@ -698,8 +721,9 @@ sub fix_ids_and_indices { } if (!$endtag) { if ($token->[4]=~m:/>$:) { $endtag=' /'; }; } $outstring.='<'.$tag.$newparmstring.$endtag.'>'; - if ($lctag eq 'm') { - $outstring.=&get_all_text_unbalanced('/m',\@parser); + if ($lctag eq 'm' || $lctag eq 'script' + || $lctag eq 'display' || $lctag eq 'tex') { + $outstring.=&get_all_text_unbalanced('/'.$lctag,\@parser); } } elsif ($token->[0] eq 'E') { if ($token->[2]) { @@ -815,7 +839,7 @@ sub publish { return ('No write permission to user directory, FAIL',1); } print $logfile -"\n\n================= Publish ".localtime()." Phase One ================\n"; +"\n\n================= Publish ".localtime()." Phase One ================\n".$ENV{'user.name'}.'@'.$ENV{'user.domain'}."\n"; if (($style eq 'ssi') || ($style eq 'rat') || ($style eq 'prv')) { # ------------------------------------------------------- This needs processing @@ -910,6 +934,9 @@ sub publish { $metadatafields{'author'}=~s/\s+/ /g; $metadatafields{'author'}=~s/\s+$//; $metadatafields{'owner'}=$cuname.'@'.$cudom; + $metadatafields{'modifyinguser'}=$ENV{'user.name'}.'@'. + $ENV{'user.domain'}; + $metadatafields{'authorspace'}=$cuname.'@'.$cudom; # ------------------------------------------------ Check out directory hierachy @@ -950,11 +977,12 @@ sub publish { # -------------------------------------------------- Parse content for metadata if (($style eq 'ssi') || ($style eq 'prv')) { - my $oldenv=$ENV{'request.uri'}; - - $ENV{'request.uri'}=$target; - $allmeta=Apache::lonxml::xmlparse(undef,'meta',$content); - $ENV{'request.uri'}=$oldenv; + my $dir=$source; + $dir=~s-/[^/]*$--; + my $file=$source; + $file=(split('/',$file))[-1]; + $source=&Apache::lonnet::hreflocation($dir,$file); + $allmeta=&Apache::lonnet::ssi_body($source,('grade_target' => 'meta')); &metaeval($allmeta); } @@ -1231,7 +1259,7 @@ sub phasetwo { return 0; } print $logfile - "\n================= Publish ".localtime()." Phase Two ================\n"; + "\n================= Publish ".localtime()." Phase Two ================\n".$ENV{'user.name'}.'@'.$ENV{'user.domain'}."\n"; %metadatafields=(); %metadatakeys=(); @@ -1338,7 +1366,7 @@ sub phasetwo { closedir(DIR); $maxversion++; $r->print('

Creating old version '.$maxversion.'

'); - print $logfile "\nCreating old version ".$maxversion; + print $logfile "\nCreating old version ".$maxversion."\n"; my $copyfile=$srcd.'/'.$srcf.'.'.$maxversion.'.'.$srct; @@ -1468,6 +1496,8 @@ sub phasetwo { sub batchpublish { my ($r,$srcfile,$targetfile)=@_; + #publication pollutes %ENV with form.* values + my %oldENV=%ENV; $srcfile=~s/\/+/\//g; $targetfile=~s/\/+/\//g; my $thisdisfn=$srcfile; @@ -1503,6 +1533,7 @@ sub batchpublish { &phasetwo($r,$srcfile,$targetfile,$thisembstyle,$thisdistarget,1); $r->print('

'); } + %ENV=%oldENV; return ''; } @@ -1543,7 +1574,7 @@ sub publishdirectory { $ruid,$rgid,$rrdev,$rsize, $ratime,$rmtime,$rctime, $rblksize,$rblocks)=stat($resdir.'/'.$filename); - if ($rmtime<$cmtime) { + if (($rmtime<$cmtime) || ($ENV{'form.forcerepub'})) { # previously published, modified now $publishthis=1; } @@ -1721,17 +1752,25 @@ unless ($ENV{'form.phase'} eq 'two') { if ($fn=~/\/$/) { # -------------------------------------------------------- This is a directory &publishdirectory($r,$fn,$thisdisfn); + $r->print('
Done
Return to Directory'); + } else { # ---------------------- Evaluate individual file, and then output information. $thisfn=~/\.(\w+)$/; my $thistype=$1; my $thisembstyle=&Apache::loncommon::fileembstyle($thistype); - $r->print('

Publishing '. - &Apache::loncommon::filedescription($thistype).' '. - ''.$thisdisfn. - '

Target: '.$thisdistarget.'
'); + &Apache::loncommon::filedescription($thistype).' '); + + $r->print(< +$thisdisfn +ENDCAPTION + $r->print( + 'Target: '.$thisdistarget.'
'); if (($cuname ne $ENV{'user.name'}) || ($cudom ne $ENV{'user.domain'})) { $r->print('

Co-Author: '.$cuname.' at '.$cudom. @@ -1739,9 +1778,10 @@ unless ($ENV{'form.phase'} eq 'two') { } if (&Apache::loncommon::fileembstyle($thistype) eq 'ssi') { - $r->print('
Diffs with Current Version
'); + $r->print(< +Diffs with Current Version
+ENDDIFF } # ------------------ Publishing from $thisfn to $thistarget with $thisembstyle. @@ -1766,5 +1806,7 @@ __END__ =back +=back + =cut