Diff for /loncom/interface/lonsource.pm between versions 1.31 and 1.33

version 1.31, 2013/06/07 16:07:46 version 1.33, 2015/05/23 18:10:02
Line 52  sub make_link { Line 52  sub make_link {
 sub stage_2 {  sub stage_2 {
     my ($r, $filename, $listname) = @_;      my ($r, $filename, $listname) = @_;
     my ($author)=($filename=~/\/res\/[^\/]+\/([^\/]+)\//);      my ($author)=($filename=~/\/res\/[^\/]+\/([^\/]+)\//);
     $r->print(&Apache::loncommon::start_page('Copy Problem Source Code to Authoring Space')      $r->print(&Apache::loncommon::start_page('Copy Problem Source Code to Authoring Space',undef,
                                                {'only_body' => 1,})
              .&mt('Please enter the directory that you would like the source code to go into.')               .&mt('Please enter the directory that you would like the source code to go into.')
              .'<p>'               .'<p>'
              .&mt('Note: the path is in reference to the root of your Authoring Space,'               .&mt('Note: the path is in reference to the root of your Authoring Space,'
Line 64  sub stage_2 { Line 65  sub stage_2 {
               <input type="hidden" name="action" value="copy_stage" />                <input type="hidden" name="action" value="copy_stage" />
               <input type="text" size="50" name="newpath" value="/'.&mt('shared_source').'/'.$author.'" />&nbsp;                <input type="text" size="50" name="newpath" value="/'.&mt('shared_source').'/'.$author.'" />&nbsp;
               <input type="submit" value="'.&mt('Copy').'" />                <input type="submit" value="'.&mt('Copy').'" />
               </form>');                </form>'.
                 &Apache::loncommon::end_page());
     return OK;      return OK;
 }  }
   
Line 101  sub copy_stage { Line 103  sub copy_stage {
     my ($uname,$udom)= &Apache::lonnet::constructaccess($path_to_new_file);      my ($uname,$udom)= &Apache::lonnet::constructaccess($path_to_new_file);
   
     if (!$uname || !$udom) {      if (!$uname || !$udom) {
  $r->print(&Apache::loncommon::start_page('Not Allowed'));   $r->print(&Apache::loncommon::start_page('Not Allowed',undef,{'only_body' => 1}));
  $r->print(&mt('Not allowed to create file [_1]', $path_to_new_file));   $r->print(&mt('Not allowed to create file [_1]', $path_to_new_file));
  $r->print(&Apache::loncommon::end_page());   $r->print(&Apache::loncommon::end_page());
  return;   return;
     }      }
   
     #allowed      #allowed
     $r->print(&Apache::loncommon::start_page('Copying Source'));      $r->print(&Apache::loncommon::start_page('Copying Source',undef,{'only_body' => 1}));
     my $result = &Apache::loncfile::exists($uname, $udom, $path_to_new_file);      my $result = &Apache::loncfile::exists($uname, $udom, $path_to_new_file);
     $r->print($result);      $r->print($result);
     if(($result) && ($result =~ m|published|) ) {      if(($result) && ($result =~ m|published|) ) {
Line 124  sub copy_stage { Line 126  sub copy_stage {
   
 sub confirm {  sub confirm {
     my ($r, $newpath, $filename, $path_to_new_file) = @_;      my ($r, $newpath, $filename, $path_to_new_file) = @_;
     $r->print("<b>Press delete to remove file and replace it with a copy of the source you are viewing</b><br /><br / >");      $r->print('<b>'.&mt('Press delete to remove file and replace it with a copy of the source you are viewing.').'</b><br /><br />');
     $r->print('<form name="delete_confirm" action="/adm/source" target="_parent" method="post">      $r->print('<form name="delete_confirm" action="/adm/source" target="_parent" method="post">
               <input type="hidden" name="filename" value="'.$filename.'" />                <input type="hidden" name="filename" value="'.$filename.'" />
               <input type="hidden" name="path" value="'.$path_to_new_file.'" />                <input type="hidden" name="path" value="'.$path_to_new_file.'" />
Line 143  sub delete_copy_file { Line 145  sub delete_copy_file {
                  .'</span><br />'                   .'</span><br />'
                  .&mt('Please use the code view in previous window to use shared code.')                   .&mt('Please use the code view in previous window to use shared code.')
                  .'<br /><br />');                   .'<br /><br />');
         $r->print('<input type="button" value="Close Window" name="close"'          $r->print('<form name="delete_done" action="/adm/source" target="_parent" method="post">'
                    .'<input type="button" value="'.&mt('Close Window').'" name="close"'
                  .' onclick="window.close()" />'                   .' onclick="window.close()" />'
                  .'</p>');                   .'</p>');
     } else {      } else {
           $r->print(&Apache::loncommon::start_page('Copying Source',undef,{'only_body' => 1}));
         if(-e $path_to_new_file) {          if(-e $path_to_new_file) {
             unless(unlink($path_to_new_file)) {              unless(unlink($path_to_new_file)) {
                 $r->print('<p class="LC_error"">'.&mt('Error:').' '.$!.'</p>');                  $r->print('<p class="LC_error"">'.&mt('Error:').' '.$!.'</p>');
                 return 0;                  return 0;
             }              }
         } else {          } else {
             $r->print('<p class="LC_error">'.&mt('No such file').'</p></form>');              $r->print('<p class="LC_error">'.&mt('No such file').'</p>');
             return 0;              return 0;
         }          }
         &copy_file($r, $newpath, $filename, $path_to_new_file);          &copy_file($r, $newpath, $filename, $path_to_new_file);
           $r->print(&Apache::loncommon::end_page());
     }      }
 }  }
   
 sub copy_file {  sub copy_file {
     my ($r, $newpath, $filename, $path_to_new_file) = @_;      my ($r, $newpath, $filename, $path_to_new_file) = @_;
     $r->print("<b>Creating directories</b>");      $r->print('<b>'.&mt('Creating directories').'</b>');
   
 #Figure out if we are author or co-author  #Figure out if we are author or co-author
     my ($role,$author_name,$domain)=&copy_author();      my ($role,$author_name,$domain)=&copy_author();
Line 188  sub copy_file { Line 193  sub copy_file {
         } else { } #Just move along          } else { } #Just move along
   
     }      }
     $r->print("<br /><b>Copying File</b>");      $r->print('<br /><b>'.&mt('Copying File').'</b>');
     my $problem_filename = $Apache::lonnet::perlvar{'lonDocRoot'}.$filename;      my $problem_filename = $Apache::lonnet::perlvar{'lonDocRoot'}.$filename;
     my $file_output = &includemeta(&Apache::lonnet::getfile($problem_filename),$filename);      my $file_output = &includemeta(&Apache::lonnet::getfile($problem_filename),$filename);
     my $fs=Apache::File->new(">$path_to_new_file");      my $fs=Apache::File->new(">$path_to_new_file");
Line 196  sub copy_file { Line 201  sub copy_file {
         print $fs $file_output;          print $fs $file_output;
     }      }
     $r->print("<br /><br />");      $r->print("<br /><br />");
     $r->print('<input type="button" value="Close Window" name="close" onclick="window.close()" />');      $r->print('<form name="copied_file" action="/adm/source" target="_parent" method="post">'
                 .'<input type="button" value="'
                 .&mt('Close Window').'" name="close" onclick="window.close()" />'
                 .'</form>');
     #Some 1.3'ish feature is to include the derivative feature, will go here..'      #Some 1.3'ish feature is to include the derivative feature, will go here..'
 }  }
   

Removed from v.1.31  
changed lines
  Added in v.1.33


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