--- loncom/interface/londocs.pm 2003/10/28 00:31:02 1.89 +++ loncom/interface/londocs.pm 2004/02/04 20:53:54 1.102 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.89 2003/10/28 00:31:02 www Exp $ +# $Id: londocs.pm,v 1.102 2004/02/04 20:53:54 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -402,33 +402,34 @@ sub entryline { $renametitle=~s/\"\;/\\\"/g; my $line=''; # Edit commands - if ($allowed) { - $line.=(< 'Move Up', + 'dw' => 'Move Down', + 'rm' => 'Remove', + 'rn' => 'Rename'); + $line.=(< +$lt{ +$lt{
-UP
-DOWN
-Remove +$lt{'rm'} -Rename +$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; @@ -450,8 +451,7 @@ END if ($isfolder) { $url.='&foldername='. &Apache::lonnet::escape($foldertitle); } $line.=''. + '">'. "$title"; return $line; } @@ -506,11 +506,12 @@ 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)) { if ($Apache::lonxml::errorcount) { - $r->print(''. + $r->print(''. $Apache::lonxml::errorcount.' '. &mt('error(s)').' '); } @@ -534,7 +535,11 @@ sub checkonthis { } elsif ($result==HTTP_SERVICE_UNAVAILABLE) { $r->print(''.&mt('connection down').''); } elsif ($result==HTTP_NOT_FOUND) { - $r->print(''.&mt('not found').''); + unless ($url=~/\$/) { + $r->print(''.&mt('not found').''); + } else { + $r->print(''.&mt('unable to verify variable URL').''); + } } else { $r->print(''.&mt('access denied').''); } @@ -572,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=''; @@ -582,9 +585,63 @@ 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; + $changes{$src}=1; + } + } } else { # show documents which changed %changes=&Apache::lonnet::dump @@ -618,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{$_}). + &Apache::lonlocal::locallocaltime( + &Apache::lonnet::metadata($root.'.'.$extension, + 'lastrevisiondate') + ). ''. $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; @@ -684,27 +758,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; @@ -712,7 +799,6 @@ sub handler { $r->send_http_header; return OK if $r->header_only; - &Apache::lonlocal::clearreroutetrans(); # --------------------------------------------- Initialize help topics for this foreach ('Adding_Course_Doc','Main_Course_Documents', 'Adding_External_Resource','Navigate_Content', @@ -850,6 +936,21 @@ function makebulboard() { } } +function makeabout() { + var user=prompt("Enter user\@domain for User's 'About Me' Page"); + if (user) { + var comp=new Array(); + comp=user.split('\@'); + if ((typeof(comp[0])!=undefined) && (typeof(comp[1])!=undefined)) { + if ((comp[0]) && (comp[1])) { + this.document.forms.newaboutsomeone.importdetail.value= + 'About '+user+'=/adm/'+comp[1]+'/'+comp[0]+'/aboutme'; + this.document.forms.newaboutsomeone.submit(); + } + } + } +} + function finishpick() { var title=this.document.forms.extimport.title.value; var url=this.document.forms.extimport.url.value; @@ -883,7 +984,9 @@ ENDNEWSCRIPT # -------------------------------------------------------------------- Body tag $r->print(''. &Apache::loncommon::bodytag('Course Documents','',$events, - '','',$showdoc)); + '','',$showdoc). + &Apache::loncommon::help_open_faq(273). + &Apache::loncommon::help_open_bug('RAT')); unless ($showdoc) { # ----------------------------------------------------------------------------- my %lt=&Apache::lonlocal::texthash( @@ -904,7 +1007,11 @@ ENDNEWSCRIPT 'sipr' => 'Simple Problem', 'scuf' => 'Score Upload Form', 'bull' => 'Bulletin Board', - 'mypi' => 'My Personal Info' + 'mypi' => 'My Personal Info', + 'abou' => 'About User', + 'file' => 'File', + 'title' => 'Title', + 'comment' => 'Comment' ); # ----------------------------------------------------------------------------- if ($allowed) { @@ -934,7 +1041,7 @@ $dumpbut ENDCOURSEVERIFY $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc', - 'Editing the Table of Contents for your Course')); + &mt('Editing the Table of Contents for your Course'))); } # --------------------------------------------------------- Standard documents $r->print(''); @@ -952,15 +1059,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'; @@ -971,11 +1070,11 @@ $help{'Caching'}.'');
$lt{'spec'}
-File:
+$lt{'file'}:

-Title:
+$lt{'title'}:
@@ -1094,6 +1193,15 @@ value="$plainname=/adm/$udom/$uname/abou $help{'My Personal Info'}
+
+ + + + + + +
ENDFORM @@ -1121,7 +1229,7 @@ ENDFORM
-
Comment:
+
$lt{'comment'}:
@@ -1207,7 +1315,7 @@ ENDSUPFORM &entryline(0,&mt("Click to download or use your browser's Save Link function"),$showdoc).'

'); } } - $r->print(&Apache::lonlocal::endreroutetrans().''); + $r->print(''); return OK; }