--- loncom/interface/londocs.pm 2003/09/05 18:11:26 1.73 +++ loncom/interface/londocs.pm 2003/10/22 19:47:52 1.87 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.73 2003/09/05 18:11:26 bowersj2 Exp $ +# $Id: londocs.pm,v 1.87 2003/10/22 19:47:52 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -35,8 +35,10 @@ use Apache::loncommon; use Apache::lonratedt; use Apache::lonratsrv; use Apache::lonxml; +use Apache::loncreatecourse; use HTML::Entities; use GDBM_File; +use Apache::lonlocal; my $iconpath; @@ -72,6 +74,162 @@ sub storemap { $map,1); } +# ----------------------------------------- Return hash with valid author names + +sub authorhosts { + my %outhash=(); + my $home=0; + my $other=0; + foreach (keys %ENV) { + if ($_=~/^user\.role\.(au|ca)\.(.+)$/) { + my $role=$1; + my $realm=$2; + my ($start,$end)=split(/\./,$ENV{$_}); + if (($start) && ($start>time)) { next; } + if (($end) && (time>$end)) { next; } + my $ca; my $cd; + if ($1 eq 'au') { + $ca=$ENV{'user.name'}; + $cd=$ENV{'user.domain'}; + } else { + ($cd,$ca)=($realm=~/^\/(\w+)\/(\w+)$/); + } + if (&Apache::lonnet::homeserver($ca,$cd) eq + $Apache::lonnet::perlvar{'lonHostID'}) { + $home++; + $outhash{'home_'.$ca.'@'.$cd}=1; + } else { + $outhash{'otherhome_'.$ca.'@'.$cd}= + &Apache::lonnet::homeserver($ca,$cd); + $other++; + } + } + } + return ($home,$other,%outhash); +} +# ------------------------------------------------------ Generate "dump" button + +sub dumpbutton { + my ($home,$other,%outhash)=&authorhosts(); + if ($home+$other==0) { return ''; } + my $output='
File | Modification Date | -Version | Differences | $lt{'fi'} | $lt{'md'} | $lt{'mr'} | +$lt{'ve'} | $lt{'vu'} | $lt{'di'} | ENDHEADERS foreach (keys %changes) { if ($changes{$_}>$starttime) { @@ -485,8 +641,12 @@ ENDHEADERS $r->print( '
---|---|---|---|---|---|---|---|
'.$linkurl. ' | '. - localtime($changes{$_}).' | '.$currentversion.' | '. - ''); + &Apache::lonlocal::locallocaltime($changes{$_}).' | '. + $currentversion.' | '); +# Used in course + $r->print(' | '); +# Set version + $r->print(' | ');
my $lastold=1;
for (my $prevvers=1;$prevvers<$currentversion;$prevvers++) {
my $url=$root.'.'.$prevvers.'.'.$extension;
@@ -498,14 +658,14 @@ ENDHEADERS
for (my $prevvers=$lastold;$prevvers<$currentversion;$prevvers++) {
my $url=$root.'.'.$prevvers.'.'.$extension;
$r->print('Version '.$prevvers.' ('.
- localtime(&Apache::lonnet::metadata($url,'lastrevisiondate')).
+ '">'.&mt('Version').' '.$prevvers.' ('.
+ &Apache::lonlocal::locallocaltime(&Apache::lonnet::metadata($url,'lastrevisiondate')).
')');
if (&Apache::loncommon::fileembstyle($extension) eq 'ssi') {
$r->print(' Diffs');
+ '">'.&mt('Diffs').'');
}
$r->print(' '); } @@ -513,11 +673,48 @@ ENDHEADERS } } $r->print(' |
No content modifications yet.
'); + $r->print(''.&mt('No content modifications yet.').'
'); } &untiehash(); +} + +# ================================================================ Main Handler +sub handler { + my $r = shift; + &Apache::loncommon::content_type($r,'text/html'); + $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', + 'Adding_Folders','Docs_Overview', 'Load_Map', + 'Supplemental', 'Score_Upload_Form', + 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive') { + $help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_); + } + # Composite help files + $help{'Syllabus'} = &Apache::loncommon::help_open_topic( + 'Docs_About_Syllabus,Docs_Editing_Templated_Pages'); + $help{'Simple Page'} = &Apache::loncommon::help_open_topic( + 'Docs_About_Simple_Page,Docs_Editing_Templated_Pages'); + $help{'Simple Problem'} = &Apache::loncommon::help_open_topic( + 'Option_Response_Simple'); + $help{'Bulletin Board'} = &Apache::loncommon::help_open_topic( + 'Docs_About_Bulletin_Board,Docs_Editing_Templated_Pages'); + $help{'My Personal Info'} = &Apache::loncommon::help_open_topic( + 'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages'); + $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching'); + + if ($ENV{'form.verify'}) { + &verifycontent($r); + } elsif ($ENV{'form.versions'}) { + &checkversions($r); + } elsif ($ENV{'form.dumpcourse'}) { + &dumpcourse($r); } else { # is this a standard course? @@ -538,7 +735,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'); @@ -663,9 +860,30 @@ ENDNEWSCRIPT &Apache::loncommon::bodytag('Course Documents','',$events, '','',$showdoc)); unless ($showdoc) { +# ----------------------------------------------------------------------------- + my %lt=&Apache::lonlocal::texthash( + 'uplm' => 'Upload a new main course document', + 'upls' => 'Upload a new supplemental course document', + 'impp' => 'Import a published document', + 'spec' => 'Special documents', + 'upld' => 'Upload Document', + 'srch' => 'Search', + 'impo' => 'Import', + 'selm' => 'Select Map', + 'load' => 'Load Map', + 'newf' => 'New Folder', + 'extr' => 'External Resource', + 'syll' => 'Syllabus', + 'navc' => 'Navigate Contents', + 'sipa' => 'Simple Page', + 'sipr' => 'Simple Problem', + 'scuf' => 'Score Upload Form', + 'bull' => 'Bulletin Board', + 'mypi' => 'My Personal Info' + ); +# ----------------------------------------------------------------------------- if ($allowed) { - $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc', - 'Editing the Table of Contents for your Course')); + my $dumpbut=&dumpbutton(); $r->print(<Main Course Documents'.
+ $r->print(''.&mt('Main Course Documents'). ($allowed?' '.$help{'Main_Course_Documents'}:'').''); my $folder=$ENV{'form.folder'}; unless ($folder=~/^default/) { $folder='default'; } @@ -701,18 +926,20 @@ ENDCOURSEVERIFY $r->print( ''. ''); } my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time. '.sequence'; - $r->print(<Upload a new main course document |
-Import a published document |
-Special documents |
+$lt{'uplm'} |
+$lt{'impp'} |
+$lt{'spec'} |
File: | @@ -724,7 +951,7 @@ Title: - + +"javascript:document.forms.simpleedit.folder.value='$folder';groupsearch()" value="$lt{'srch'}">
@@ -746,7 +973,7 @@ $help{'Importing_LON-CAPA_Resource'}
Supplemental Course Documents'.
+ ''.&mt('Supplemental Course Documents'). ($allowed?' '.$help{'Supplemental'}:'').''); my $folder=$ENV{'form.folder'}; unless ($folder=~/supplemental/) { $folder='supplemental'; } @@ -858,9 +1085,9 @@ ENDFORM $r->print(<Upload a new supplemental course document |
-Import a published document |
-Special documents |
+$lt{'upls'} |
+$lt{'impp'} |
+$lt{'spec'} |
@@ -883,15 +1110,15 @@ ENDFORM
+"javascript:document.forms.simpleedit.folder.value='$folder';groupsearch()" value="$lt{'srch'}">
$help{'Importing_LON-CAPA_Resource'}
+"javascript:document.forms.simpleedit.folder.value='$folder';groupimport();" value="$lt{'impo'}">$help{'Importing_LON-CAPA_Resource'}
|
+value="$lt{'selm'}">$help{'Load_Map'}
@@ -902,7 +1129,7 @@ value="Select Map">
$help{'Adding_Folders'}
+value="$lt{'newf'}" /> $help{'Adding_Folders'}
@@ -931,7 +1158,7 @@ $help{'Syllabus'}
| |
It is recommended that you use an up-to-date virus scanner before handling this file.
'. +&mt('It is recommended that you use an up-to-date virus scanner before handling this file.')."