Diff for /loncom/interface/londocs.pm between versions 1.161 and 1.164

version 1.161, 2004/12/23 17:50:42 version 1.164, 2005/01/08 06:42:15
Line 132  sub dumpbutton { Line 132  sub dumpbutton {
     }      }
 }  }
   
   sub clean {
       my ($title)=@_;
       $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
       return $title;
   }
 # -------------------------------------------------------- Actually dump course  # -------------------------------------------------------- Actually dump course
   
 sub dumpcourse {  sub dumpcourse {
Line 149  sub dumpcourse { Line 154  sub dumpcourse {
  my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'});   my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'});
  $r->print('<h3>'.&mt('Copying Files').'</h3>');   $r->print('<h3>'.&mt('Copying Files').'</h3>');
  my $title=$ENV{'form.authorfolder'};   my $title=$ENV{'form.authorfolder'};
  $title=~s/[^\w\/]+/\_/g;   $title=&clean($title);
  my %replacehash=();   my %replacehash=();
  foreach (keys %ENV) {   foreach (keys %ENV) {
     if ($_=~/^form\.namefor\_(.+)/) {      if ($_=~/^form\.namefor\_(.+)/) {
Line 160  sub dumpcourse { Line 165  sub dumpcourse {
  $crs=~s/\_/\//g;   $crs=~s/\_/\//g;
  foreach (keys %replacehash) {   foreach (keys %replacehash) {
     my $newfilename=$title.'/'.$replacehash{$_};      my $newfilename=$title.'/'.$replacehash{$_};
     $newfilename=~s/[^\w\/\.\/]+/\_/g;      $newfilename=&clean($newfilename);
     my @dirs=split(/\//,$newfilename);      my @dirs=split(/\//,$newfilename);
     my $path='/home/'.$ca.'/public_html';      my $path='/home/'.$ca.'/public_html';
     my $makepath=$path;      my $makepath=$path;
Line 214  sub dumpcourse { Line 219  sub dumpcourse {
  }   }
  my $title=$origcrsdata{'description'};   my $title=$origcrsdata{'description'};
  $title=~s/\s+/\_/gs;   $title=~s/\s+/\_/gs;
  $title=~s/\W//gs;   $title=&clean($title);
  $r->print('<h3>'.&mt('Folder in Construction Space').'</h3><input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');   $r->print('<h3>'.&mt('Folder in Construction Space').'</h3><input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
  &tiehash();   &tiehash();
  $r->print('<h3>'.&mt('Filenames in Construction Space').'</h3><table border="2"><tr><th>'.&mt('Internal Filename').'</th><th>'.&mt('Title').'</th><th>'.&mt('Save as ...').'</th></tr>');   $r->print('<h3>'.&mt('Filenames in Construction Space').'</h3><table border="2"><tr><th>'.&mt('Internal Filename').'</th><th>'.&mt('Title').'</th><th>'.&mt('Save as ...').'</th></tr>');
Line 223  sub dumpcourse { Line 228  sub dumpcourse {
     my ($ext)=($_=~/\.(\w+)$/);      my ($ext)=($_=~/\.(\w+)$/);
     my $title=$hash{'title_'.$hash{      my $title=$hash{'title_'.$hash{
  'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}};   'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}};
       $title=~s/&colon;/:/g;
     $r->print('<td>'.($title?$title:'&nbsp;').'</td>');      $r->print('<td>'.($title?$title:'&nbsp;').'</td>');
     unless ($title) {      unless ($title) {
  $title=$_;   $title=$_;
     }      }
     $title=~s/\.(\w+)$//;      $title=~s/\.(\w+)$//;
     $title=~s/[^\w\/]+/\_/gs;      $title=&clean($title);
     $title.='.'.$ext;      $title.='.'.$ext;
     $r->print("\n<td><input type='text' size='60' name='namefor_".$_."' value='".$title."' /></td></tr>\n");      $r->print("\n<td><input type='text' size='60' name='namefor_".$_."' value='".$title."' /></td></tr>\n");
  }   }
Line 705  sub process_content { Line 711  sub process_content {
         if ($contents) {          if ($contents) {
             $$content_file = &store_template($contents,$tempexport,$count,$content_type);              $$content_file = &store_template($contents,$tempexport,$count,$content_type);
         }          }
     } elsif ($symb =~ m-uploaded/$cdom/$cnum-) {  
         $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');  
     } elsif ($symb =~ m-\.(sequence|page)___\d+___uploaded/$cdom/$cnum/-) {      } elsif ($symb =~ m-\.(sequence|page)___\d+___uploaded/$cdom/$cnum/-) {
         $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');          $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
     } elsif ($symb =~ m-\.(sequence|page)___\d+___([^/])/([^/])-) {      } elsif ($symb =~ m-\.(sequence|page)___\d+___([^/]+)/([^/]+)-) {
         my $coauth = $3.':'.$2.':ca';  
         my $canedit = 0;          my $canedit = 0;
         if ($2 eq $ENV{'user.domain'} && $3 eq $ENV{'user.name'})  {          if ($2 eq $ENV{'user.domain'} && $3 eq $ENV{'user.name'})  {
             $canedit= 1;              $canedit= 1;
Line 720  sub process_content { Line 723  sub process_content {
         } else {          } else {
             $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'noedit');              $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'noedit');
         }          }
       } elsif ($symb =~ m-uploaded/$cdom/$cnum-) {
           $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'uploaded');
     }      }
     if (@uploads > 0) {      if (@uploads > 0) {
         foreach my $item (@uploads) {          foreach my $item (@uploads) {
Line 761  sub replicate_content { Line 766  sub replicate_content {
         if ($copiedfile = Apache::File->new('>'.$destination)) {          if ($copiedfile = Apache::File->new('>'.$destination)) {
             my $content;              my $content;
             if ($caller eq 'resource') {              if ($caller eq 'resource') {
                 $content = &Apache::lonnet::getfile($url);                  $content = &Apache::lonnet::getfile('/home/httpd/html/res/'.$url);
                 if ($content eq -1) {                  if ($content eq -1) {
                     $$message = 'Could not copy file '.$filename;                      $$message = 'Could not copy file '.$filename;
                 } else {                  } else {
                     &extract_media($content,$count,$tempexport,$href,'resource');                      &extract_media($content,$count,$tempexport,$href,'resource');
                     $repstatus = 'ok';                      $repstatus = 'ok';
                 }                  }
             } elsif ($caller eq 'noedit' || $caller eq 'uploaded' || $caller eq 'templateupload') {              } elsif ($caller eq 'uploaded' || $caller eq 'templateupload') {
                 my $rtncode;                  my $rtncode;
                 $repstatus = &Apache::lonnet::getuploaded('GET',$url,$cdom,$cnum,\$content,$rtncode);                  $repstatus = &Apache::lonnet::getuploaded('GET',$url,$cdom,$cnum,\$content,$rtncode);
                 if ($repstatus eq 'ok') {                  if ($repstatus eq 'ok') {
Line 778  sub replicate_content { Line 783  sub replicate_content {
                 } else {                  } else {
                     $$message = 'Could not render '.$url.' server message - '.$rtncode;                      $$message = 'Could not render '.$url.' server message - '.$rtncode;
                 }                  }
               } elsif ($caller eq 'noedit') {
   # Need to render the resource without the LON-CAPA Internal header and the Post discussion footer, and then set $content equal to this. 
                   $repstatus = 'ok';
                   $content = 'Not the owner of this resource'; 
             }              }
             if ($repstatus eq 'ok') {              if ($repstatus eq 'ok') {
                 print $copiedfile $content;                  print $copiedfile $content;

Removed from v.1.161  
changed lines
  Added in v.1.164


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