Diff for /loncom/interface/londocs.pm between versions 1.75 and 1.79

version 1.75, 2003/09/08 19:21:10 version 1.79, 2003/09/15 17:58:21
Line 126  sub dumpbutton { Line 126  sub dumpbutton {
 sub dumpcourse {  sub dumpcourse {
     my $r=shift;      my $r=shift;
     $r->print('<html><head><title>Dump DOCS</title></head>'.      $r->print('<html><head><title>Dump DOCS</title></head>'.
         &Apache::loncommon::bodytag('Dump Course DOCS to Construction Space'));          &Apache::loncommon::bodytag('Dump Course DOCS to Construction Space').
         '<form name="dumpdoc" method="post">');
     my ($home,$other,%outhash)=&authorhosts();      my ($home,$other,%outhash)=&authorhosts();
     unless ($home) { return ''; }      unless ($home) { return ''; }
     if ($ENV{'form.authorspace'}) {      my $origcrsid=$ENV{'request.course.id'};
       my %origcrsdata=&Apache::lonnet::coursedescription($origcrsid);
       if (($ENV{'form.authorspace'}) && ($ENV{'form.authorfolder'}=~/\w/)) {
   # Do the dumping
  unless ($outhash{'home_'.$ENV{'form.authorspace'}}) { return ''; }   unless ($outhash{'home_'.$ENV{'form.authorspace'}}) { return ''; }
  my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'});   my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'});
    $r->print('<h3>Copying Files</h3>');
    my $title=$ENV{'form.authorfolder'};
    $title=~s/[^\w\/]+/\_/g;
    my %replacehash=();
    foreach (keys %ENV) {
       if ($_=~/^form\.namefor\_(.+)/) {
    $replacehash{$1}=$ENV{$_};
       }
    }
    my $crs='/uploaded/'.$ENV{'request.course.id'}.'/';
    $crs=~s/\_/\//g;
    foreach (keys %replacehash) {
       my $newfilename=$title.'/'.$replacehash{$_};
       $newfilename=~s/[^\w\/\.]+/\_/g;
       my @dirs=split(/\//,$newfilename);
       my $path='/home/'.$ca.'/public_html';
       my $makepath=$path;
       my $fail=0;
       for (my $i=0;$i<$#dirs;$i++) {
    $makepath.='/'.$dirs[$i];
    unless (-e $makepath) { 
       unless(mkdir($makepath,0777)) { $fail=1; } 
    }
       }
       $r->print('<br /><tt>'.$_.'</tt> => <tt>'.$newfilename.'</tt>: ');
       if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
    if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
       print $fh &Apache::loncreatecourse::rewritefile(
            &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_),
        (%replacehash,$crs => '')
       );
    } else {
       print $fh
            &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_);
          }
    $fh->close();
       } else {
    $fail=1;
       }
       if ($fail) {
    $r->print('<font color="red">fail</font>');
       } else {
    $r->print('<font color="green">ok</font>');
       }
    }
       } else {
   # Input form
    unless ($home==1) {
       $r->print(
         '<h3>Select the Construction Space</h3><select name="authorspace">');
    }
    foreach (sort keys %outhash) {
       if ($_=~/^home_(.+)$/) {
    if ($home==1) {
       $r->print(
     '<input type="hidden" name="authorspace" value="'.$1.'" />');
    } else {
       $r->print('<option value="'.$1.'">'.$_.'</option>');
    }
       }
    }
    unless ($home==1) {
       $r->print('</select>');
    }
    my $title=$origcrsdata{'description'};
    $title=~s/\s+/\_/gs;
    $title=~s/\W//gs;
    $r->print('<h3>Folder in Construction Space</h3><input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
    &tiehash();
    $r->print('<h3>Filenames in Construction Space</h3><table border="2"><tr><th>Internal Filename</th><th>Title</th><th>Save as ...</th></tr>');
    foreach (&Apache::loncreatecourse::crsdirlist($origcrsid,'userfiles')) {
       $r->print('<tr><td>'.$_.'</td>');
       my ($ext)=($_=~/\.(\w+)$/);
       my $title=$hash{'title_'.$hash{
    'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$_}};
       $r->print('<td>'.($title?$title:'&nbsp;').'</td>');
       unless ($title) {
    $title=$_;
       }
       $title=~s/\.(\w+)$//;
       $title=~s/\W+/\_/gs;
       $title.='.'.$ext;
       $r->print("\n<td><input type='text' size='60' name='namefor_".$_."' value='".$title."' /></td></tr>\n");
    }
    $r->print("</table>\n");
    &untiehash();
    $r->print(
     '<p><input type="submit" name="dumpcourse" value="Dump Course DOCS" /></p></form>');
     }      }
 }  }
   
   
 # Imports the given (name, url) resources into the course  # Imports the given (name, url) resources into the course
 # coursenum, coursedom, and folder must precede the list  # coursenum, coursedom, and folder must precede the list
 sub group_import {  sub group_import {
Line 618  sub handler { Line 711  sub handler {
        $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);         $forcesupplement=($ENV{'form.folder'}=~/^supplemental_/);
   
 # does this user have privileges to post, etc?  # does this user have privileges to post, etc?
        $allowed=&Apache::lonnet::allowed('srm',$ENV{'request.course.id'});         $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
        if ($allowed) {          if ($allowed) { 
          &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);           &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['cmd']);
          $script=&Apache::lonratedt::editscript('simple');            $script=&Apache::lonratedt::editscript('simple'); 

Removed from v.1.75  
changed lines
  Added in v.1.79


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