--- loncom/interface/londocs.pm 2003/10/28 00:57:50 1.90 +++ loncom/interface/londocs.pm 2003/11/04 19:18:16 1.94 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.90 2003/10/28 00:57:50 www Exp $ +# $Id: londocs.pm,v 1.94 2003/11/04 19:18:16 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -510,6 +510,7 @@ sub checkonthis { &Apache::lonxml::xmlparse($r,'web', &Apache::lonnet::getfile( &Apache::lonnet::filelocation('',$url))); + undef($Apache::lonhomework::parsing_a_problem); $ENV{'request.filename'}=$oldpath; if (($Apache::lonxml::errorcount) || ($Apache::lonxml::warningcount)) { @@ -576,8 +577,6 @@ sub checkversions { my $r=shift; $r->print('Check Versions'. &Apache::loncommon::bodytag('Check Course Document Versions')); - $hashtied=0; - &tiehash(); my $header=''; my $startsel=''; my $monthsel=''; @@ -586,9 +585,57 @@ sub checkversions { my $allsel=''; my %changes=(); my $starttime=0; + my $haschanged=0; + my %setversions=&Apache::lonnet::dump('resourceversions', + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); + + $hashtied=0; + &tiehash(); + my %newsetversions=(); + if ($ENV{'form.setmostrecent'}) { + $haschanged=1; + foreach (keys %hash) { + if ($_=~/^ids\_(\/res\/.+)$/) { + $newsetversions{$1}='mostrecent'; + } + } + } elsif ($ENV{'form.setcurrent'}) { + $haschanged=1; + foreach (keys %hash) { + if ($_=~/^ids\_(\/res\/.+)$/) { + my $getvers=&Apache::lonnet::getversion($1); + if ($getvers>0) { + $newsetversions{$1}=$getvers; + } + } + } + } elsif ($ENV{'form.setversions'}) { + $haschanged=1; + foreach (keys %ENV) { + if ($_=~/^form\.set_version_(.+)$/) { + my $src=$1; + &Apache::lonnet::logthis('Found: '.$1.' '.$ENV{$_}); + if (($ENV{$_}) && ($ENV{$_} ne $setversions{$src})) { + $newsetversions{$src}=$ENV{$_}; + } + } + } + } + if ($haschanged) { + if (&Apache::lonnet::put('resourceversions',\%newsetversions, + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}) eq 'ok') { + $r->print('

'.&mt('Your Version Settings have been Stored').'

'); + } else { + $r->print('

'.&mt('An Error Occured while Attempting to Store your Version Settings').'

'); + } + &changewarning($r,''); + } if ($ENV{'form.timerange'} eq 'all') { # show all documents $header=&mt('All Documents in Course'); + $allsel=1; foreach (keys %hash) { if ($_=~/^ids\_(\/res\/.+)$/) { my $src=$1; @@ -628,21 +675,30 @@ sub checkversions { $header=&mt('No content modifications yet.'); } } + %setversions=&Apache::lonnet::dump('resourceversions', + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); my %lt=&Apache::lonlocal::texthash ('st' => 'Version changes since start of Course', 'lm' => 'Version changes since last Month', 'lw' => 'Version changes since last Week', 'sy' => 'Version changes since Yesterday', - 'al' => 'All Resources', + 'al' => 'All Resources (possibly large output)', 'sd' => 'Display', 'fi' => 'File', 'md' => 'Modification Date', 'mr' => 'Most recently published Version', 've' => 'Version used in Course', - 'vu' => 'Set Version to be used in Course', + 'vu' => 'Set Version to be used in Course', +'sv' => 'Set Versions to be used in Course according to Selections below', +'sm' => 'Keep all Resources up-to-date with most recent Versions (default)', +'sc' => 'Set all Resource Versions to current Version (Fix Versions)', 'di' => 'Differences'); $r->print(< + + +
- - +

$header

+ ENDHEADERS - foreach (keys %changes) { + foreach (sort keys %changes) { if ($changes{$_}>$starttime) { my ($root,$extension)=($_=~/^(.*)\.(\w+)$/); my $currentversion=&Apache::lonnet::getversion($_); + if ($currentversion<0) { + $currentversion=&mt('Could not be determined.'); + } my $linkurl=&Apache::lonnet::clutter($_); $r->print( - ''); + $r->print(''); } } - $r->print('
$lt{'fi'}$lt{'md'}$lt{'mr'} $lt{'ve'}$lt{'vu'}$lt{'di'}
'.$linkurl. + '
'. + &Apache::lonnet::gettitle($linkurl). + '
'.$linkurl. '
'. &Apache::lonlocal::locallocaltime($changes{$_}). ''. $currentversion.''); # Used in course my $usedversion=$hash{'version_'.$linkurl}; - if ($usedversion) { + if (($usedversion) && ($usedversion ne 'mostrecent')) { $r->print($usedversion); } else { $r->print($currentversion); } $r->print(''); # Set version - $r->print(&Apache::loncommon::select_form($usedversion, + $r->print(&Apache::loncommon::select_form($setversions{$linkurl}, 'set_version_'.$linkurl, ('' => '', - 'current' => 'current', + 'mostrecent' => 'most recent', map {$_,$_} (1..$currentversion)))); - $r->print(''); + $r->print('
    '); my $lastold=1; for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) { my $url=$root.'.'.$prevvers.'.'.$extension; @@ -694,27 +755,40 @@ ENDHEADERS } for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) { my $url=$root.'.'.$prevvers.'.'.$extension; - $r->print(''.&mt('Version').' '.$prevvers.' ('. + $r->print('
  • '.&mt('Version').' '.$prevvers.' ('. &Apache::lonlocal::locallocaltime(&Apache::lonnet::metadata($url,'lastrevisiondate')). - ')'); + ')'); if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') { $r->print(' '.&mt('Diffs').''); } - $r->print('
    '); + $r->print('
  • '); } - $r->print('
'); + $r->print(''); $r->print('

'.&mt('Done').'.

'); &untiehash(); } +sub changewarning { + my ($r,$postexec)=@_; + $r->print( +''. +'
'. +'

'. +&mt('Changes will become active for your current session after'). +' '.&mt(', or the next time you log in.'). +$help{'Caching'}.'

'); +} + # ================================================================ Main Handler sub handler { my $r = shift; @@ -962,15 +1036,7 @@ ENDCOURSEVERIFY $hadchanges=0; &editor($r,$coursenum,$coursedom,$folder,$allowed); if ($hadchanges) { - $r->print( -''. -'
'. -'

'. -&mt('Changes will become active for your current session after'). -' '.&mt(', or the next time you log in.'). -$help{'Caching'}.'

'); + &changewarning($r,$postexec); } my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. '.sequence';