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

version 1.287, 2007/07/07 00:53:24 version 1.291, 2007/07/13 23:08:07
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;
       }
  }   }
     }      }
  }   }
Line 1785  sub entryline { Line 1812  sub entryline {
         my $copylink='&nbsp;';          my $copylink='&nbsp;';
         my $cutlink='&nbsp;';          my $cutlink='&nbsp;';
   
    my $skip_confirm = 0;
    if ( $folder =~ /^supplemental/
        || ($url =~ m{( /smppg$
       |/syllabus$
       |/aboutme$
       |/navmaps$
       |/bulletinboard$
       |\.html$
       |^/adm/wrapper/ext)}x)) {
       $skip_confirm = 1;
    }
   
  if (!$nocopy) {   if (!$nocopy) {
     $copylink=(<<ENDCOPY);      $copylink=(<<ENDCOPY);
 <a href='javascript:markcopy("$esc_path","$index","$renametitle","$container","$symb","$folder");' class="LC_docs_copy">$lt{'cp'}</a>  <a href='javascript:markcopy("$esc_path","$index","$renametitle","$container","$symb","$folder");' class="LC_docs_copy">$lt{'cp'}</a>
Line 1792  ENDCOPY Line 1831  ENDCOPY
         }          }
  if (!$nocut) {   if (!$nocut) {
     $cutlink=(<<ENDCUT);      $cutlink=(<<ENDCUT);
 <a href='javascript:cutres("$esc_path","$index","$renametitle","$container","$symb","$folder");' class="LC_docs_cut">$lt{'ct'}</a>  <a href='javascript:cutres("$esc_path","$index","$renametitle","$container","$symb","$folder",$skip_confirm);' class="LC_docs_cut">$lt{'ct'}</a>
 ENDCUT  ENDCUT
         }          }
  $form_start = (<<END);   $form_start = (<<END);
Line 1824  END Line 1863  END
    $form_end     $form_end
 </td>  </td>
 <td class="LC_docs_entry_commands">  <td class="LC_docs_entry_commands">
    <a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_remove">$lt{'rm'}</a>     <a href='javascript:removeres("$esc_path","$index","$renametitle","$container","$symb",$skip_confirm);' class="LC_docs_remove">$lt{'rm'}</a>
 $cutlink  $cutlink
    <a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a>     <a href='javascript:changename("$esc_path","$index","$renametitle","$container","$symb");' class="LC_docs_rename">$lt{'rn'}</a>
 $copylink  $copylink
Line 3236  function changename(folderpath,index,old Line 3275  function changename(folderpath,index,old
     }      }
 }  }
   
 function removeres(folderpath,index,oldtitle,container,pagesymb) {  function removeres(folderpath,index,oldtitle,container,pagesymb,skip_confirm) {
     if (confirm('WARNING: Removing a resource makes associated grades and scores inaccessible!\\nRemove "'+oldtitle+'"?')) {      if (skip_confirm || confirm('WARNING: Removing a resource makes associated grades and scores inaccessible!\\nRemove "'+oldtitle+'"?')) {
  this.document.forms.renameform.markcopy.value=-1;   this.document.forms.renameform.markcopy.value=-1;
  this.document.forms.renameform.cmd.value='del_'+index;   this.document.forms.renameform.cmd.value='del_'+index;
         if (container == 'sequence') {          if (container == 'sequence') {
Line 3251  function removeres(folderpath,index,oldt Line 3290  function removeres(folderpath,index,oldt
     }      }
 }  }
   
 function cutres(folderpath,index,oldtitle,container,pagesymb,folder) {  function cutres(folderpath,index,oldtitle,container,pagesymb,folder,skip_confirm) {
     if (confirm('WARNING: Cutting a resource makes associated grades and scores inaccessible!\\nGrades remain inaccessible if resource is pasted into another folder.\\nCut "'+oldtitle+'"?')) {      if (skip_confirm || confirm('WARNING: Cutting a resource makes associated grades and scores inaccessible!\\nGrades remain inaccessible if resource is pasted into another folder.\\nCut "'+oldtitle+'"?')) {
  this.document.forms.renameform.cmd.value='cut_'+index;   this.document.forms.renameform.cmd.value='cut_'+index;
  this.document.forms.renameform.markcopy.value=index;   this.document.forms.renameform.markcopy.value=index;
  this.document.forms.renameform.copyfolder.value=folder+'.'+container;   this.document.forms.renameform.copyfolder.value=folder+'.'+container;

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


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