Diff for /loncom/interface/londocs.pm between versions 1.287 and 1.290

version 1.287, 2007/07/07 00:53:24 version 1.290, 2007/07/13 00:29:21
Line 932  sub group_import { Line 932  sub group_import {
             }              }
         }          }
  if ($url) {   if ($url) {
     if (!$residx) {      if (!$residx 
  $residx = &LONCAPA::map::getresidx($url);   || defined($LONCAPA::map::zombies[$residx])) {
  $LONCAPA::map::order[$#LONCAPA::map::order+1]=$residx;   $residx = &LONCAPA::map::getresidx($url,$residx);
    push(@LONCAPA::map::order, $residx);
     }      }
     my $ext = 'false';      my $ext = 'false';
     if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }      if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
Line 1241  ENDPASTE Line 1242  ENDPASTE
     $r->print('</p></form>');      $r->print('</p></form>');
 }  }
   
   sub do_paste_from_buffer {
       my ($coursenum,$coursedom,$folder,$container) = @_;
   # paste resource to end of list
       my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'});
       my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'});
   # Maps need to be copied first
       if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) {
    $title=&mt('Copy of').' '.$title;
    my $newid=$$.time;
    $url=~/^(.+)\.(\w+)$/;
    my $newurl=$1.$newid.'.'.$2;
    my $storefn=$newurl;
    $storefn=~s{^/\w+/$match_domain/$match_username/}{};
    &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
      &Apache::lonnet::getfile($url));
    $url = $newurl;
       }
   # published maps can only exists once, so remove it from paste buffer when done
       if (($url=~/\.(page|sequence)$/) && ($url=~m {^/res/})) {
    &Apache::lonnet::delenv('docs\\.markedcopy');
       }
       if ($url=~ m{/smppg$}) {
    my $db_name = &Apache::lonsimplepage::get_db_name($url);
    if ($db_name =~ /^smppage_/) {
       #simple pages, need to copy the db contents to a new one.
       my %contents=&Apache::lonnet::dump($db_name,$coursedom,$coursenum);
       my $now = time();
       $db_name =~ s{_\d*$ }{_$now}x;
       my $result=&Apache::lonnet::put($db_name,\%contents,
       $coursedom,$coursenum);
       $url =~ s{/(\d*)/smppg$ }{/$now/smppg}x; 
       $title=&mt('Copy of').' '.$title;
    }
       }
       $title = &LONCAPA::map::qtunescape($title);
       my $ext='false';
       if ($url=~m{^http(|s)://}) { $ext='true'; }
       $url       = &LONCAPA::map::qtunescape($url);
   # Now insert the URL at the bottom
       my $newidx = &LONCAPA::map::getresidx($url);
       $LONCAPA::map::resources[$newidx]= $title.':'.$url.':'.$ext.':normal:res';
       push(@LONCAPA::map::order, $newidx);
   # Store the result
       return &storemap($coursenum,$coursedom,$folder.'.'.$container);
   }
   
 sub editor {  sub editor {
     my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$which)=@_;      my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$which)=@_;
     my $errtext='';      my $errtext='';
Line 1347  sub editor { Line 1394  sub editor {
     }      }
           
     if ($env{'form.pastemarked'}) {      if ($env{'form.pastemarked'}) {
 # paste resource to end of list   my ($errtext,$fatal) =
                 my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'});      &do_paste_from_buffer($coursenum,$coursedom,$folder,
  my $title=&LONCAPA::map::qtescape($env{'docs.markedcopy_title'});    $container);
 # Maps need to be copied first  
  if (($url=~/\.(page|sequence)$/) || ($url=~/^\/uploaded\//)) {  
     $title=&mt('Copy of').' '.$title;  
                     my $newid=$$.time;  
     $url=~/^(.+)\.(\w+)$/;  
     my $newurl=$1.$newid.'.'.$2;  
     my $storefn=$newurl;  
                     $storefn=~s{^/\w+/$match_domain/$match_username/}{};  
     &Apache::lonclonecourse::writefile  
  ($env{'request.course.id'},$storefn,  
  &Apache::lonnet::getfile($url));  
     $url=$newurl;  
  }  
  $title = &LONCAPA::map::qtunescape($title);  
  my $ext='false';  
  if ($url=~m{^http(|s)://}) { $ext='true'; }  
  $url   = &LONCAPA::map::qtunescape($url);  
 # Now insert the URL at the bottom  
                 my $newidx=&LONCAPA::map::getresidx($url);  
  $LONCAPA::map::resources[$newidx]=  
     $title.':'.$url.':'.$ext.':normal:res';  
  $LONCAPA::map::order[1+$#LONCAPA::map::order]=$newidx;  
 # Store the result  
  ($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.'.$container);  
  if ($fatal) {   if ($fatal) {
     $r->print('<p><span class="LC_error">'.$errtext.'</span></p>');      $r->print('<p><span class="LC_error">'.$errtext.'</span></p>');
     return;      return;
  }   }
   
     }      }
             $r->print($upload_output);              $r->print($upload_output);
     if ($env{'form.cmd'}) {      if ($env{'form.cmd'}) {
Line 1770  sub entryline { Line 1792  sub entryline {
  my $nocopy=0;   my $nocopy=0;
         my $nocut=0;          my $nocut=0;
         if ($url=~/\.(page|sequence)$/) {          if ($url=~/\.(page|sequence)$/) {
     foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url))) {      if ($url =~ m{/res/}) {
  my ($title,$url,$ext,$type)=split(/\:/,$_);   # no copy for published maps
  if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) {   $nocopy = 1;
     $nocopy=1;      } else {
     last;   foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url))) {
       my ($title,$url,$ext,$type)=split(/\:/,$_);
       if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) {
    $nocopy=1;
    last;
       }
  }   }
     }      }
  }   }

Removed from v.1.287  
changed lines
  Added in v.1.290


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>