Diff for /loncom/interface/londocs.pm between versions 1.158 and 1.163

version 1.158, 2004/12/23 14:00:58 version 1.163, 2005/01/08 06:34:30
Line 214  sub dumpcourse { Line 214  sub dumpcourse {
  }   }
  my $title=$origcrsdata{'description'};   my $title=$origcrsdata{'description'};
  $title=~s/\s+/\_/gs;   $title=~s/\s+/\_/gs;
  $title=~s/\W//gs;   $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
  $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 223  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=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
     $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 242  sub dumpcourse { Line 243  sub dumpcourse {
 # ------------------------------------------------------ Generate "export" button  # ------------------------------------------------------ Generate "export" button
   
 sub exportbutton {  sub exportbutton {
       return '';
     return '</td><td bgcolor="#DDDDCC">'.      return '</td><td bgcolor="#DDDDCC">'.
             '<input type="submit" name="exportcourse" value="'.              '<input type="submit" name="exportcourse" value="'.
             &mt('Export Course to IMS').'" />'.              &mt('Export Course to IMS').'" />'.
Line 486  sub create_ims_store { Line 488  sub create_ims_store {
     if (!-e $$tempexport) {      if (!-e $$tempexport) {
         mkdir($$tempexport,0700);          mkdir($$tempexport,0700);
     }      }
       if (!-e "$$tempexport/resources") {
           mkdir("$$tempexport/resources",0700);
       }
 # open manifest file  # open manifest file
     my $manifest = '/imsmanifest.xml';      my $manifest = '/imsmanifest.xml';
     my $manifestfilename = $$tempexport.$manifest;      my $manifestfilename = $$tempexport.$manifest;
Line 609  sub build_package { Line 614  sub build_package {
                             }                              }
                             my %extras = (                              my %extras = (
                                           caller => 'imsexport',                                            caller => 'imsexport',
                                           tempexport => $tempexport,                                            tempexport => $tempexport.'/resources',
                                           count => $count                                            count => $count
                                          );                                           );
                             my $discresult = &Apache::lonfeedback::list_discussion($mode,undef,$ressymb,\%extras);                              my $discresult = &Apache::lonfeedback::list_discussion($mode,undef,$ressymb,\%extras);
Line 655  sub process_content { Line 660  sub process_content {
     my $content_type;      my $content_type;
     my $message;      my $message;
 # find where user is author or co-author  # find where user is author or co-author
     my %roleshash = &Apache::lonnet::get_my_roles();  
     my @uploads = ();      my @uploads = ();
     if ($curRes->is_sequence()) {      if ($curRes->is_sequence()) {
         $content_type = 'sequence';          $content_type = 'sequence';
Line 702  sub process_content { Line 706  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;
         } elsif (defined($roleshash{$coauth})) {  
             if ($roleshash{$coauth} =~ /(\d+):(\d+)/) {  
                 if (($1 < time || $1 == 0) && ($2 == 0 || $2 >= time)) {  
                     $canedit = 1;  
                 }  
             } elsif ($roleshash{$coauth} eq ':') {  
                 $canedit = 1;  
             }  
         }          }
         if ($canedit) {          if ($canedit) {
             $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'resource');              $$content_file = &replicate_content($cdom,$cnum,$tempexport,$symb,$count,\$message,$href,'resource');
         } 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) {
             my $uploadmsg = '';              my $uploadmsg = '';
             &replicate_content($cdom,$cnum,$tempexport,$item,$count,\$uploadmsg,$href,'uploaded');              &replicate_content($cdom,$cnum,$tempexport,$item,$count,\$uploadmsg,$href,'templateupload');
             if ($uploadmsg) {              if ($uploadmsg) {
                 $$copyresult .= $uploadmsg."\n";                  $$copyresult .= $uploadmsg."\n";
             }              }
Line 742  sub process_content { Line 737  sub process_content {
   
 sub replicate_content {  sub replicate_content {
     my ($cdom,$cnum,$tempexport,$symb,$count,$message,$href,$caller) = @_;      my ($cdom,$cnum,$tempexport,$symb,$count,$message,$href,$caller) = @_;
     my ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);      my ($map,$ind,$url);
     my $feedurl = &Apache::lonnet::clutter($url);      if ($caller eq 'templateupload') {
           $url = $symb;
           $url =~ s#//#/#g;
       } else { 
           ($map,$ind,$url)=&Apache::lonnet::decode_symb($symb);
       }
     my $content;      my $content;
     my $filename;      my $filename;
     my $repstatus;      my $repstatus;
Line 762  sub replicate_content { Line 761  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') {              } 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 779  sub replicate_content { Line 778  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;
Line 788  sub replicate_content { Line 791  sub replicate_content {
             $$message = 'Could not open destination file for '.$filename."\n";              $$message = 'Could not open destination file for '.$filename."\n";
         }          }
     } else {      } else {
         $$message = 'Could not determine name of file for '.$url."\n";          $$message = 'Could not determine name of file for '.$symb."\n";
     }      }
     if ($repstatus eq 'ok') {      if ($repstatus eq 'ok') {
         $content_name = $count.'/'.$filename;          $content_name = $count.'/'.$filename;
Line 808  sub extract_media { Line 811  sub extract_media {
 sub store_template {  sub store_template {
     my ($contents,$tempexport,$count,$content_type) = @_;      my ($contents,$tempexport,$count,$content_type) = @_;
     if ($contents) {      if ($contents) {
         my $destination = $tempexport.'/resources/'.$count.'/'.$content_type.'.xml';          if ($tempexport) {
         my $storetemplate;              if (!-e $tempexport.'/resources') {
         if ($storetemplate = Apache::File->new('>'.$destination)) {                  mkdir($tempexport.'/resources',0700);
             print $storetemplate $contents;              }
             close($storetemplate);              if (!-e $tempexport.'/resources/'.$count) {
                   mkdir($tempexport.'/resources/'.$count,0700);
               }
               my $destination = $tempexport.'/resources/'.$count.'/'.$content_type.'.xml';
               my $storetemplate;
               if ($storetemplate = Apache::File->new('>'.$destination)) {
                   print $storetemplate $contents;
                   close($storetemplate);
               }
               if ($content_type eq 'external') {
                   return $count.'/'.$content_type.'.html';
               } else {
                   return $count.'/'.$content_type.'.xml';
               }
         }          }
         return $count.'/'.$content_type.'.xml';  
     }      }
 }  }
   

Removed from v.1.158  
changed lines
  Added in v.1.163


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