--- loncom/interface/londocs.pm 2006/06/26 22:31:56 1.233
+++ loncom/interface/londocs.pm 2006/11/12 06:29:33 1.248
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.233 2006/06/26 22:31:56 albertel Exp $
+# $Id: londocs.pm,v 1.248 2006/11/12 06:29:33 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,16 +33,15 @@ use Apache::Constants qw(:common :http);
use Apache::imsexport;
use Apache::lonnet;
use Apache::loncommon;
-use Apache::lonratedt;
-use Apache::lonratsrv;
+use LONCAPA::map();
+use Apache::lonratedt();
use Apache::lonxml;
-use Apache::loncreatecourse;
+use Apache::lonclonecourse;
use Apache::lonnavmaps;
use HTML::Entities;
use GDBM_File;
use Apache::lonlocal;
use Cwd;
-use lib '/home/httpd/lib/perl/';
use LONCAPA;
my $iconpath;
@@ -58,7 +57,7 @@ my $hadchanges;
my %help=();
-# Mapread read maps into lonratedt::global arrays
+# Mapread read maps into LONCAPA::map:: global arrays
# @order and @resources, determines status
# sets @order - pointer to resources in right order
# sets @resources - array with the resources with correct idx
@@ -67,15 +66,15 @@ my %help=();
sub mapread {
my ($coursenum,$coursedom,$map)=@_;
return
- &Apache::lonratedt::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
- $map);
+ &LONCAPA::map::mapread('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
+ $map);
}
sub storemap {
my ($coursenum,$coursedom,$map)=@_;
my ($outtext,$errtext)=
- &Apache::lonratedt::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
- $map,1);
+ &LONCAPA::map::storemap('/uploaded/'.$coursedom.'/'.$coursenum.'/'.
+ $map,1);
if ($errtext) { return ($errtext,2); }
$hadchanges=1;
@@ -186,13 +185,13 @@ sub dumpcourse {
$r->print('
'.$_.' => '.$newfilename.': ');
if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
- print $fh &Apache::loncreatecourse::rewritefile(
- &Apache::loncreatecourse::readfile($env{'request.course.id'},$_),
+ print $fh &Apache::lonclonecourse::rewritefile(
+ &Apache::lonclonecourse::readfile($env{'request.course.id'},$_),
(%replacehash,$crs => '')
);
} else {
print $fh
- &Apache::loncreatecourse::readfile($env{'request.course.id'},$_);
+ &Apache::lonclonecourse::readfile($env{'request.course.id'},$_);
}
$fh->close();
} else {
@@ -230,15 +229,17 @@ sub dumpcourse {
$r->print('
'.&mt('Internal Filename').' | '.&mt('Title').' | '.&mt('Save as ...').' | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
'.$_.' | '); my ($ext)=($_=~/\.(\w+)$/); my $title=$hash{'title_'.$hash{ 'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}}; $title=~s/:/:/g; $r->print(''.($title?$title:' ').' | '); - unless ($title) { + if (!$title) { $title=$_; + } else { + $title=~s|/|_|g; } $title=~s/\.(\w+)$//; $title=&clean($title); @@ -929,13 +930,13 @@ sub group_import { } } if ($url) { - my $idx = &Apache::lonratedt::getresidx($url); - $Apache::lonratedt::order[$#Apache::lonratedt::order+1]=$idx; + my $idx = &LONCAPA::map::getresidx($url); + $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx; my $ext = 'false'; if ($url=~/^http:\/\//) { $ext = 'true'; } $url =~ s/:/\:/g; $name =~ s/:/\:/g; - $Apache::lonratedt::resources[$idx] = + $LONCAPA::map::resources[$idx] = join ':', ($name, $url, $ext, 'normal', 'res'); } } @@ -959,6 +960,9 @@ sub breadcrumbs { '&markedcopy_title='. &escape($env{'form.markedcopy_title'}); } + my $randompick=-1; + my $isencrypted=0; + my $ishidden=0; while (@folders) { my $folder=shift(@folders); my $foldername=shift(@folders); @@ -966,16 +970,154 @@ sub breadcrumbs { $folderpath.=$folder.'&'.$foldername; my $url='/adm/coursedocs?folderpath='. &escape($folderpath); + my $name=&unescape($foldername); +# randompick number, hidden, encrypted is appended with ":"s to the foldername + $name=~s/\:(\d*)\:(\w*)\:(\w*)$//; + if ($1 ne '') { + $randompick=$1; + } else { + $randompick=-1; + } + if ($2) { $ishidden=1; } + if ($3) { $isencrypted=1; } &Apache::lonhtmlcommon::add_breadcrumb( {'href'=>$url.$cpinfo, - 'title'=>&unescape($foldername), + 'title'=>$name, 'text'=>''. - &unescape($foldername).'' + $name.'' }); - - } - return &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp'); + return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp', + 'LC_docs_path'),$randompick,$ishidden,$isencrypted); +} + +sub log_docs { + return &Apache::lonnet::instructor_log('docslog',@_); +} + +{ + my @oldresources=(); + my @oldorder=(); + my $parmidx; + my %parmaction=(); + my %parmvalue=(); + + sub snapshotbefore { + @oldresources=@LONCAPA::map::resources; + @oldorder=@LONCAPA::map::order; + $parmidx=undef; + %parmaction=(); + %parmvalue=(); + } + + sub remember_parms { + my ($idx,$parameter,$action,$value)=@_; + $parmidx=$idx; + $parmaction{$parameter}=$action; + $parmvalue{$parameter}=$value; + } + + sub log_differences { + my $r=shift; + my %storehash=('folder' => $env{'form.folder'}); + if ($parmidx) { + $storehash{'parameter_idx'}=$parmidx; + $storehash{'parameter_res'}=$oldresources[$parmidx]; + foreach my $parm (keys %parmaction) { + $storehash{'parameter_action_'.$parm}=$parmaction{$parm}; + $storehash{'parameter_value_'.$parm}=$parmvalue{$parm}; + } + } + my $maxidx=$#oldresources; + if ($#LONCAPA::map::resources>$#oldresources) { + $maxidx=$#LONCAPA::map::resources; + } + for (my $idx=0; $idx<=$maxidx; $idx++) { + if ($LONCAPA::map::resources[$idx] ne $oldresources[$idx]) { + $storehash{'before_resources_'.$idx}=$oldresources[$idx]; + $storehash{'after_resources_'.$idx}=$LONCAPA::map::resources[$idx]; + } + if ($LONCAPA::map::order[$idx] ne $oldorder[$idx]) { + $storehash{'before_order_'.$idx}=$oldorder[$idx]; + $storehash{'after_order_'.$idx}=$LONCAPA::map::order[$idx]; + $storehash{'before_order_res_'.$idx}=$oldresources[$idx]; + $storehash{'after_order_res_'.$idx}=$LONCAPA::map::resources[$idx]; + } + } + &log_docs(\%storehash); + } +} + + +# +# Docs Change Log +# +sub docs_change_log { + my ($r)=@_; + $r->print(&Apache::loncommon::start_page('Course Document Change Log')); + $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Document Change Log')); + + my %docslog=&Apache::lonnet::dump('nohist_docslog', + $env{'course.'.$env{'request.course.id'}.'.domain'}, + $env{'course.'.$env{'request.course.id'}.'.num'}); + + if ((keys(%docslog))[0]=~/^error\:/) { undef(%docslog); } + + $r->print(''); + $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row(). + ''.&mt('Time').' | '.&mt('User').' | '.&mt('Extent').' | '.&mt('Users').' | '. + &mt('Parameter').' | '.&mt('Part').' | '.&mt('New Value').' | '.&mt('Announce').' | '. + &Apache::loncommon::end_data_table_header_row()); + my $shown=0; + foreach my $id (sort { $docslog{$b}{'exe_time'}<=>$docslog{$a}{'exe_time'} } (keys(%docslog))) { + my @changes=keys(%{$docslog{$id}{'logentry'}}); + my $count = 0; + my $time = + &Apache::lonlocal::locallocaltime($docslog{$id}{'exe_time'}); + my $plainname = + &Apache::loncommon::plainname($docslog{$id}{'exe_uname'}, + $docslog{$id}{'exe_udom'}); + my $about_me_link = + &Apache::loncommon::aboutmewrapper($plainname, + $docslog{$id}{'exe_uname'}, + $docslog{$id}{'exe_udom'}); + my $send_msg_link=''; + if ((($docslog{$id}{'exe_uname'} ne $env{'user.name'}) + || ($docslog{$id}{'exe_udom'} ne $env{'user.domain'}))) { + $send_msg_link =''.$time.' | +'.$about_me_link.
+ ' '.$docslog{$id}{'exe_uname'}. + ':'.$docslog{$id}{'exe_udom'}.''. + $send_msg_link.' | ');
+
+ $r->print(&Apache::loncommon::end_data_table_row());
+ $shown++;
+ if (!($env{'form.show'} eq &mt('all')
+ || $shown<=$env{'form.show'})) { last; }
+ }
+ $r->print(&Apache::loncommon::end_data_table());
+ $r->print(&Apache::loncommon::end_page());
}
sub editor {
@@ -988,19 +1130,20 @@ sub editor {
}
($errtext,$fatal)=
&mapread($coursenum,$coursedom,$folder.'.'.$container);
- if ($#Apache::lonratedt::order<1) {
- my $idx=&Apache::lonratedt::getresidx();
+ if ($#LONCAPA::map::order<1) {
+ my $idx=&LONCAPA::map::getresidx();
if ($idx<=0) { $idx=1; }
- $Apache::lonratedt::order[0]=$idx;
- $Apache::lonratedt::resources[$idx]='';
+ $LONCAPA::map::order[0]=$idx;
+ $LONCAPA::map::resources[$idx]='';
}
if (defined($env{'form.markcopy'})) {
# Mark for copying
- my ($title,$url)=split(':',$Apache::lonratedt::resources[$Apache::lonratedt::order[$env{'form.markcopy'}]]);
+ my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]);
$env{'form.markedcopy_title'}=$title;
$env{'form.markedcopy_url'}=$url;
}
- $r->print(&breadcrumbs($folder));
+ my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted)=&breadcrumbs($folder);
+ $r->print($breadcrumbtrail);
if ($fatal) {
$r->print('