version 1.180, 2023/07/14 18:01:23
|
version 1.183, 2024/01/10 20:07:37
|
Line 36 use Apache::Constants qw(:common :http :
|
Line 36 use Apache::Constants qw(:common :http :
|
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lonhtmlcommon(); |
use Apache::lonhtmlcommon(); |
use Apache::londiff(); |
use Apache::londiff(); |
|
use Apache::lonpublisher(); |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonmsg; |
use Apache::lonmsg; |
use Apache::lonmenu; |
use Apache::lonmenu; |
Line 86 sub handler {
|
Line 87 sub handler {
|
my $linkdir='/priv'.$thisdisfn; # Full URL name of constr space. |
my $linkdir='/priv'.$thisdisfn; # Full URL name of constr space. |
|
|
my $cstr = 'author'; |
my $cstr = 'author'; |
my ($crsauthor,$crstype); |
my ($crsauthor,$crstype,$crstoplevel,$cdom,$cnum); |
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
if ($thisdisfn =~ m{^/\Q$cdom/$cnum\E}) { |
if ($thisdisfn =~ m{^/\Q$cdom/$cnum\E}) { |
$crsauthor = 1; |
$crsauthor = 1; |
$cstr = 'course'; |
$cstr = 'course'; |
$crstype = &Apache::loncommon::course_type(); |
$crstype = &Apache::loncommon::course_type(); |
|
$crstoplevel = "$docroot/priv/$cdom/$cnum"; |
} |
} |
} |
} |
|
|
Line 108 sub handler {
|
Line 110 sub handler {
|
|
|
&startpage($r, $uname, $udom, $thisdisfn, $current_disk_usage, $disk_quota, $crsauthor); |
&startpage($r, $uname, $udom, $thisdisfn, $current_disk_usage, $disk_quota, $crsauthor); |
|
|
|
my @files; |
if (!-d $fn) { |
if (!-d $fn) { |
if (-e $fn) { |
if (($crsauthor) && ($fn eq $crstoplevel)) { |
$r->print('<p class="LC_info">'.&mt('Requested item is a file not a directory.').'</p>'); |
my $path = "$docroot/priv/$cdom/$cnum"; |
|
my $rightsfile = 'default.rights'; |
|
my $sourcerights = "$path/$rightsfile"; |
|
&Apache::loncommon::crsauthor_rights($rightsfile,$path,$docroot,$cnum,$cdom); |
|
my $targetrights = $docroot."/res/$cdom/$cnum/$rightsfile"; |
|
if ((-e $sourcerights) && (-e "$sourcerights.meta")) { |
|
if (!-e "$docroot/res/$cdom") { |
|
mkdir("$docroot/res/$cdom",0755); |
|
} |
|
if (!-e "$docroot/res/$cdom/$cnum") { |
|
mkdir("$docroot/res/$cdom/$cnum",0755); |
|
} |
|
if ((-e "$docroot/res/$cdom/$cnum") && (!-e $targetrights)) { |
|
my $nokeyref = &Apache::lonpublisher::getnokey($r->dir_config('lonIncludes')); |
|
my $output = &Apache::lonpublisher::batchpublish($r,$sourcerights,$targetrights,$nokeyref,1); |
|
} |
|
} else { |
|
$r->print('<p class="LC_info">'.&mt('The requested subdirectory does not exist.').'</p>'); |
|
return OK; |
|
} |
} else { |
} else { |
$r->print('<p class="LC_info">'.&mt('The requested subdirectory does not exist.').'</p>'); |
if (-e $fn) { |
|
$r->print('<p class="LC_info">'.&mt('Requested item is a file not a directory.').'</p>'); |
|
} else { |
|
$r->print('<p class="LC_info">'.&mt('The requested subdirectory does not exist.').'</p>'); |
|
} |
|
$r->print(&Apache::loncommon::end_page()); |
|
return OK; |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
|
return OK; |
|
} |
|
my @files; |
|
if (opendir(DIR,$fn)) { |
|
@files = grep(!/^\.+$/,readdir(DIR)); |
|
closedir(DIR); |
|
} else { |
} else { |
$r->print('<p class="LC_error">'.&mt('Could not open directory.').'</p>'); |
if (opendir(DIR,$fn)) { |
$r->print(&Apache::loncommon::end_page()); |
@files = grep(!/^\.+$/,readdir(DIR)); |
return OK; |
closedir(DIR); |
|
} else { |
|
$r->print('<p class="LC_error">'.&mt('Could not open directory.').'</p>'); |
|
$r->print(&Apache::loncommon::end_page()); |
|
return OK; |
|
} |
} |
} |
|
|
# Put out actions for directory, browse/upload + new file page. |
# Put out actions for directory, browse/upload + new file page. |
Line 315 my $result = "<script type=\"text/javasc
|
Line 341 my $result = "<script type=\"text/javasc
|
} |
} |
|
|
# Print the sorted resources |
# Print the sorted resources |
|
my %editors = &Apache::loncommon::permitted_editors(); |
foreach my $filename (@sorted_files) { |
foreach my $filename (@sorted_files) { |
if ($filehash->{$filename}->{"cmode"}&$dirptr) { # Directories |
if ($filehash->{$filename}->{"cmode"}&$dirptr) { # Directories |
&putdirectory($r, $thisdisfn, $linkdir, $filename, |
&putdirectory($r, $thisdisfn, $linkdir, $filename, |
Line 328 my $result = "<script type=\"text/javasc
|
Line 355 my $result = "<script type=\"text/javasc
|
$filehash->{$filename}->{"linkfilename"}, |
$filehash->{$filename}->{"linkfilename"}, |
$filehash->{$filename}->{"fulltitle"}, |
$filehash->{$filename}->{"fulltitle"}, |
$filehash->{$filename}->{"status"}, |
$filehash->{$filename}->{"status"}, |
$filehash->{$filename}->{"pubstatus"}); |
$filehash->{$filename}->{"pubstatus"}, |
|
\%editors); |
} |
} |
} |
} |
|
|
Line 923 sub getStatus {
|
Line 951 sub getStatus {
|
sub putresource { |
sub putresource { |
my ($r, $udom, $uname, $filename, $thisdisfn, $resdir, |
my ($r, $udom, $uname, $filename, $thisdisfn, $resdir, |
$targetdir, $linkdir, $crsauthor, $cmtime, $size, |
$targetdir, $linkdir, $crsauthor, $cmtime, $size, |
$numres, $linkfilename, $title, $status, $pubstatus) = @_; |
$numres, $linkfilename, $title, $status, $pubstatus, |
|
$editors) = @_; |
&Apache::lonnet::devalidate_cache_new('meta',$targetdir.'/'.$filename); |
&Apache::lonnet::devalidate_cache_new('meta',$targetdir.'/'.$filename); |
|
|
my $editlink=''; |
my $editlink=''; |
my $editlink2=''; |
my $editlink2=''; |
if ($filename=~/\.(xml|html|htm|xhtml|xhtm|sty)$/) { |
if ($filename=~/\.(xml|html|htm|xhtml|xhtm|sty|txt|css|js)$/) { |
$editlink=' <br />(<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=edit">'.&mt('Edit').'</a>)'; |
$editlink=' <br />(<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=edit">'.&mt('Edit').'</a>)'; |
} |
} |
if ($filename=~/$LONCAPA::assess_re/) { |
if ($filename=~/$LONCAPA::assess_re/) { |
$editlink=' (<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=editxml">'.&mt('EditXML').'</a>)'; |
if ($editors->{'xml'}) { |
$editlink2=' <br />(<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=edit">'.&mt('Edit').'</a>)'; |
$editlink=' (<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=editxml">'.&mt('EditXML').'</a>)'; |
|
} |
|
if ($editors->{'edit'}) { |
|
$editlink2=' <br />(<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=edit">'.&mt('Edit').'</a>)'; |
|
} |
} |
} |
if ($filename=~/\.(xml|html|htm|xhtml|xhtm)$/ || $filename=~/$LONCAPA::assess_re/) { |
if ($filename=~/\.(xml|html|htm|xhtml|xhtm)$/ || $filename=~/$LONCAPA::assess_re/) { |
if ($env{'browser.type'} ne 'explorer' || $env{'browser.version'} > 9) { |
if (($editors->{'daxe'}) && |
|
($env{'browser.type'} ne 'explorer' || $env{'browser.version'} > 9)) { |
my $daxeurl = '/daxepage'.$linkdir.'/'.$filename; |
my $daxeurl = '/daxepage'.$linkdir.'/'.$filename; |
$editlink .= ' (<a href="'.$daxeurl.'" target="_blank">Daxe</a>)'; |
$editlink .= ' (<a href="'.$daxeurl.'">Daxe</a>)'; |
} |
} |
} |
} |
if ($filename=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm|sty)$/) { |
if ($filename=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm|sty)$/) { |