version 1.20, 2007/08/28 22:46:32
|
version 1.24, 2009/08/13 11:00:38
|
Line 1
|
Line 1
|
# The LearningOnline Network with CAPA |
# The LearningOnline Network with CAPA |
# Souce Code handler |
# Source Code handler |
# |
# |
# $Id$ |
# $Id$ |
# |
# |
Line 52 sub make_link {
|
Line 52 sub make_link {
|
sub stage_2 { |
sub stage_2 { |
my ($r, $filename, $author, $listname) = @_; |
my ($r, $filename, $author, $listname) = @_; |
my ($uname, $udom) = &Apache::loncacc::constructaccess('/~'.$author.'/',$r->dir_config('lonDefDomain')); |
my ($uname, $udom) = &Apache::loncacc::constructaccess('/~'.$author.'/',$r->dir_config('lonDefDomain')); |
$r->print(&Apache::loncommon::start_page('Problem source code moving operation')); |
$r->print(&Apache::loncommon::start_page('Copy Problem Source Code to Construction Space') |
$r->print("Please enter the directory that you would like the source code to go into, a default has also been provided <br />"); |
.&mt('Please enter the directory that you would like the source code to go into.') |
$r->print("Also note, the path is in reference to the root of your construction space, and new directories will be automatically created. <br /><br />"); |
.'<p>' |
|
.&mt('Note: the path is in reference to the root of your construction space,' |
|
.' and new directories will be automatically created.') |
|
.'</p>'); |
$r->print('<form name="copy" action="/adm/source" target="_parent" method="post"> |
$r->print('<form name="copy" 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="listname" value="'.$listname.'" /> |
<input type="hidden" name="listname" value="'.$listname.'" /> |
<input type="hidden" name="action" value="copy_stage" /> |
<input type="hidden" name="action" value="copy_stage" /> |
<input type="text" size="50" name="newpath" value="/shared_source/'.$author.'" /> |
<input type="text" size="50" name="newpath" value="/'.&mt('shared_source').'/'.$author.'" /> |
<input type="submit" value="Copy" /> |
<input type="submit" value="'.&mt('Copy').'" /> |
</form>'); |
</form>'); |
return OK; |
return OK; |
} |
} |
Line 126 sub confirm {
|
Line 129 sub confirm {
|
sub delete_copy_file { |
sub delete_copy_file { |
my ($r, $author_name, $newpath, $filename, $path_to_new_file, $type) = @_; |
my ($r, $author_name, $newpath, $filename, $path_to_new_file, $type) = @_; |
if($type eq '1') { |
if($type eq '1') { |
$r->print("<b>Cannot delete non-obsolete published file</b><br />Please |
$r->print('<p><span class="LC_warning">' |
use the code view in previous window to use shared code<br /><br />"); |
.&mt('Cannot delete non-obsolete published file.') |
$r->print('<input type="button" value="Close Window" name="close" onClick="window.close()" />'); |
.'</span><br />' |
|
.&mt('Please use the code view in previous window to use shared code.') |
|
.'<br /><br />'); |
|
$r->print('<input type="button" value="Close Window" name="close"' |
|
.' onclick="window.close()" />' |
|
.'</p>'); |
} else { |
} else { |
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('<font color="red">'.&mt('Error').': '.$!.'</font>'); |
$r->print('<p class="LC_error"">'.&mt('Error:').' '.$!.'</p>'); |
return 0; |
return 0; |
} |
} |
} else { |
} else { |
$r->print('<p> '.&mt('No such file').'. </p></form>'); |
$r->print('<p class="LC_error">'.&mt('No such file').'</p></form>'); |
return 0; |
return 0; |
} |
} |
©_file($r, $author_name, $newpath, $filename, $path_to_new_file); |
©_file($r, $author_name, $newpath, $filename, $path_to_new_file); |
Line 155 sub copy_file {
|
Line 163 sub copy_file {
|
|
|
else { |
else { |
unless(mkdir($path, 02770)) { |
unless(mkdir($path, 02770)) { |
$r->print('<font color="red">'.&mt('Error').': '.$!.'</font>'); |
$r->print('<p class="LC_error">'.&mt('Error:').' '.$!.'</p>'); |
return 0; |
return 0; |
} |
} |
unless(chmod(02770, ($path))) { |
unless(chmod(02770, ($path))) { |
$r->print('<font color="red"> '.&mt('Error').': '.$!.'</font>'); |
$r->print('<p class="LC_error"> '.&mt('Error:').' '.$!.'</p>'); |
return 0; |
return 0; |
} |
} |
} |
} |
Line 174 sub copy_file {
|
Line 182 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('<input type="button" value="Close Window" name="close" onclick="window.close()" />'); |
#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..' |
} |
} |
|
|
Line 250 sub handler {
|
Line 258 sub handler {
|
&delete_copy_file($r, $env{'form.author'}, $env{'form.newpath'}, $env{'form.filename'}, $env{'form.path'}, '0'); |
&delete_copy_file($r, $env{'form.author'}, $env{'form.newpath'}, $env{'form.filename'}, $env{'form.path'}, '0'); |
} else { |
} else { |
$r->print('<form name="copy" action="/adm/source" target="_parent" method="post"> |
$r->print('<form name="copy" action="/adm/source" target="_parent" method="post"> |
<input type="button" value="Close Window" name="close" onClick="window.close()" /> |
<input type="button" value="'.&mt('Close Window').'" name="close" onclick="window.close()" /> |
<input type="hidden" name="filename" value="'.$filename.'" /> |
<input type="hidden" name="filename" value="'.$filename.'" /> |
<input type="hidden" name="listname" value="'.$listname.'" /> |
<input type="hidden" name="listname" value="'.$listname.'" /> |
<input type="hidden" name="action" value="stage2" /> |
<input type="hidden" name="action" value="stage2" /> |
<input type="submit" value="Copy to CSTR" /> |
<input type="submit" value="'.&mt('Copy to Construction Space').'" /> |
</form>'); |
</form>'); |
$r->print('<hr />'); |
$r->print('<hr />'); |
&print_item($r, $env{'form.filename'}); |
&print_item($r, $env{'form.filename'}); |