--- loncom/interface/londocs.pm 2007/05/02 01:33:48 1.272 +++ loncom/interface/londocs.pm 2007/06/28 23:26:46 1.278.2.1 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.272 2007/05/02 01:33:48 albertel Exp $ +# $Id: londocs.pm,v 1.278.2.1 2007/06/28 23:26:46 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -904,15 +904,16 @@ sub store_template { # Imports the given (name, url) resources into the course # coursenum, coursedom, and folder must precede the list sub group_import { - my $coursenum = shift; - my $coursedom = shift; - my $folder = shift; - my $container = shift; - my $caller = shift; - while (@_) { - my $name = shift; - my $url = shift; - if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) && ($caller eq 'londocs')) { + my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_; + + while (@files) { + my $name = shift(@files); + my $url = shift(@files); + #FIXME check if file exists before overwriting, might be restoring it + if (($url =~ m{^/uploaded/\Q$coursedom\E/\Q$coursenum\E/(default_\d+\.)(page|sequence)$}) + && ($caller eq 'londocs') + && (!&Apache::lonnet::stat_file($url))) { + my $errtext = ''; my $fatal = 0; my $newmapstr = ''."\n". @@ -936,8 +937,8 @@ sub group_import { $LONCAPA::map::order[$#LONCAPA::map::order+1]=$idx; my $ext = 'false'; if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; } - $url =~ &LONCAPA::map::qtunescape($url); - $name =~ &LONCAPA::map::qtunescape($name); + $url = &LONCAPA::map::qtunescape($url); + $name = &LONCAPA::map::qtunescape($name); $LONCAPA::map::resources[$idx] = join ':', ($name, $url, $ext, 'normal', 'res'); } @@ -966,6 +967,7 @@ sub breadcrumbs { my $randompick=-1; my $isencrypted=0; my $ishidden=0; + my $is_random_order=0; while (@folders) { my $folder=shift(@folders); my $foldername=shift(@folders); @@ -975,7 +977,7 @@ sub breadcrumbs { &escape($folderpath); my $name=&unescape($foldername); # randompick number, hidden, encrypted is appended with ":"s to the foldername - $name=~s/\:(\d*)\:(\w*)\:(\w*)$//; + $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//; if ($1 ne '') { $randompick=$1; } else { @@ -983,6 +985,7 @@ sub breadcrumbs { } if ($2) { $ishidden=1; } if ($3) { $isencrypted=1; } + if ($4 ne '') { $is_random_order = 1; } &Apache::lonhtmlcommon::add_breadcrumb( {'href'=>$url.$cpinfo, 'title'=>$name, @@ -994,7 +997,7 @@ sub breadcrumbs { } $plain=~s/\>\;\s*$//; return (&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0,'nohelp', - 'LC_docs_path'),$randompick,$ishidden,$isencrypted,$plain); + 'LC_docs_path'),$randompick,$ishidden,$isencrypted,$plain,$is_random_order); } sub log_docs { @@ -1085,6 +1088,7 @@ sub docs_change_log { my %lt=('hiddenresource' => 'Resources hidden', 'encrypturl' => 'URL hidden', 'randompick' => 'Randomly pick', + 'randomorder' => 'Randomly ordered', 'set' => 'set to', 'del' => 'deleted'); $r->print(&Apache::loncommon::display_filter(). @@ -1167,7 +1171,7 @@ sub docs_change_log { $r->print(''); if ($docslog{$id}{'logentry'}{'parameter_res'}) { $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':