+
+$lt{'rm'}
+
+$lt{'rn'}
END
}
# Figure out what kind of a resource this is
my ($extension)=($url=~/\.(\w+)$/);
my $uploaded=($url=~/^\/*uploaded\//);
- my $icon='unknown';
- if (-e "/home/httpd/html/adm/lonIcons/$extension.gif") {
- $icon=$extension;
- }
+ my $icon=&Apache::loncommon::icon($url);
my $isfolder=0;
if ($uploaded) {
if ($extension eq 'sequence') {
- $icon='folder_closed';
+ $icon=$iconpath.'/folder_closed.gif';
$url=~/\/(\w+)\.sequence/;
$url='/adm/coursedocs?folder='.$1;
$isfolder=1;
@@ -278,8 +479,7 @@ END
if ($isfolder) { $url.='&foldername='.
&Apache::lonnet::escape($foldertitle); }
$line.='
'.''.
+ &mt('Return to DOCS').'');
+}
+
+# -------------------------------------------------------------- Check Versions
+
+sub checkversions {
+ my $r=shift;
+ $r->print('Check Versions'.
+ &Apache::loncommon::bodytag('Check Course Document Versions'));
+ my $header='';
+ my $startsel='';
+ my $monthsel='';
+ my $weeksel='';
+ my $daysel='';
+ 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;
+ $changes{$src}=1;
+ }
+ }
+ } else {
+# show documents which changed
+ %changes=&Apache::lonnet::dump
+ ('versionupdate',$ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+ $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+ my $firstkey=(keys %changes)[0];
+ unless ($firstkey=~/^error\:/) {
+ unless ($ENV{'form.timerange'}) {
+ $ENV{'form.timerange'}=604800;
+ }
+ my $seltext=&mt('during the last').' '.$ENV{'form.timerange'}.' '
+ .&mt('seconds');
+ if ($ENV{'form.timerange'}==-1) {
+ $seltext='since start of course';
+ $startsel='selected';
+ $ENV{'form.timerange'}=time;
+ }
+ $starttime=time-$ENV{'form.timerange'};
+ if ($ENV{'form.timerange'}==2592000) {
+ $seltext=&mt('during the last month').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
+ $monthsel='selected';
+ } elsif ($ENV{'form.timerange'}==604800) {
+ $seltext=&mt('during the last week').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
+ $weeksel='selected';
+ } elsif ($ENV{'form.timerange'}==86400) {
+ $seltext=&mt('since yesterday').' ('.&Apache::lonlocal::locallocaltime($starttime).')';
+ $daysel='selected';
+ }
+ $header=&mt('Content changed').' '.$seltext;
+ } else {
+ $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 (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',
+'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 (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(
+ '
');
+ my $lastold=1;
+ for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
+ my $url=$root.'.'.$prevvers.'.'.$extension;
+ if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
+ $starttime) {
+ $lastold=$prevvers;
+ }
+ }
+ #
+ # Code to figure out how many version entries should go in
+ # each of the four columns
+ my $entries_per_col = 0;
+ my $num_entries = ($currentversion-$lastold);
+ if ($num_entries % 4 == 0) {
+ $entries_per_col = $num_entries/4;
+ } else {
+ $entries_per_col = $num_entries/4 + 1;
+ }
+ my $entries_count = 0;
+ $r->print('
');
- my $lastold=1;
- for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
- my $url=$root.'.'.$prevvers.'.'.$extension;
- if (&Apache::lonnet::metadata($url,'lastrevisiondate')<
- $starttime) {
- $lastold=$prevvers;
- }
- }
- for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
- my $url=$root.'.'.$prevvers.'.'.$extension;
- $r->print('Version '.$prevvers.' ('.
- localtime(&Apache::lonnet::metadata($url,'lastrevisiondate')).
- ')');
- if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
- $r->print(' Diffs');
- }
- $r->print(' ');
- }
- $r->print('
');
- }
- }
- $r->print('
');
- $r->print('
Done.
');
- } else {
- $r->print('
No content modifications yet.
');
- }
- &untiehash();
+ &checkversions($r);
+ } elsif ($ENV{'form.dumpcourse'}) {
+ &dumpcourse($r);
} else {
# is this a standard course?
@@ -513,7 +897,6 @@ ENDHEADERS
my $script='';
my $allowed;
my $events='';
- my $buttons='';
my $showdoc=0;
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['folder','foldername']);
@@ -525,7 +908,7 @@ ENDHEADERS
$forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
# does this user have privileges to post, etc?
- $allowed=&Apache::lonnet::allowed('srm',$ENV{'request.course.id'});
+ $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
if ($allowed) {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
$script=&Apache::lonratedt::editscript('simple');
@@ -535,7 +918,6 @@ ENDHEADERS
$script=''.&Apache::lonmenu::registerurl(1,undef).''.
-'');
+ &changewarning($r,$postexec);
}
my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
'.sequence';
-
$r->print(<