version 1.301, 2023/03/28 23:17:16
|
version 1.304, 2024/06/01 22:25:23
|
Line 1825 sub phasetwo {
|
Line 1825 sub phasetwo {
|
$env{'user.domain'}; |
$env{'user.domain'}; |
$metadatafields{'authorspace'}=$cuname.':'.$cudom; |
$metadatafields{'authorspace'}=$cuname.':'.$cudom; |
$metadatafields{'domain'}=$cudom; |
$metadatafields{'domain'}=$cudom; |
|
|
|
my $crsauthor; |
|
if ($env{'request.course.id'}) { |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
if ($distarget =~ m{^/res/$cdom/$cnum}) { |
|
$crsauthor = 1; |
|
my $default_rights = "/res/$cdom/$cnum/default.rights"; |
|
unless ($distarget eq $default_rights) { |
|
$metadatafields{'copyright'} = 'custom'; |
|
$metadatafields{'customdistributionfile'} = $default_rights; |
|
} |
|
} |
|
} |
|
|
my $allkeywords=$env{'form.addkey'}; |
my $allkeywords=$env{'form.addkey'}; |
if (exists($env{'form.keywords'})) { |
if (exists($env{'form.keywords'})) { |
if (ref($env{'form.keywords'})) { |
if (ref($env{'form.keywords'})) { |
Line 1907 sub phasetwo {
|
Line 1921 sub phasetwo {
|
$metadatafields{'url'} = $distarget; |
$metadatafields{'url'} = $distarget; |
$metadatafields{'version'} = 'current'; |
$metadatafields{'version'} = 'current'; |
|
|
my $crsauthor; |
|
if ($env{'request.course.id'}) { |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
if ($distarget =~ m{^/res/$cdom/$cnum}) { |
|
$crsauthor = 1; |
|
} |
|
} |
|
unless ($crsauthor) { |
unless ($crsauthor) { |
my ($error,$success) = &store_metadata(%metadatafields); |
my ($error,$success) = &store_metadata(%metadatafields); |
if ($success) { |
if ($success) { |
Line 2123 sub phasetwo {
|
Line 2129 sub phasetwo {
|
|
|
# ------------------------------------------------------------- Trigger updates |
# ------------------------------------------------------------- Trigger updates |
push(@{$modified_urls},[$target,$source]); |
push(@{$modified_urls},[$target,$source]); |
unless ($registered_cleanup) { |
¬ify_in_cleanup($r); |
my $handlers = $r->get_handlers('PerlCleanupHandler'); |
|
$r->set_handlers('PerlCleanupHandler' => [\¬ify,@{$handlers}]); |
|
$registered_cleanup=1; |
|
} |
|
|
|
# ---------------------------------------------------------- Clear local caches |
# ---------------------------------------------------------- Clear local caches |
my $thisdistarget=$target; |
my $thisdistarget=$target; |
Line 2183 sub phasetwo {
|
Line 2185 sub phasetwo {
|
} |
} |
} |
} |
|
|
|
sub notify_in_cleanup { |
|
my ($r) = @_; |
|
unless ($registered_cleanup) { |
|
my $handlers = $r->get_handlers('PerlCleanupHandler'); |
|
$r->set_handlers('PerlCleanupHandler' => [\¬ify,@{$handlers}]); |
|
$registered_cleanup=1; |
|
} |
|
} |
|
|
# =============================================================== Notifications |
# =============================================================== Notifications |
sub notify { |
sub notify { |
# --------------------------------------------------- Send update notifications |
# --------------------------------------------------- Send update notifications |
Line 2282 sub batchpublish {
|
Line 2293 sub batchpublish {
|
######################################### |
######################################### |
|
|
sub publishdirectory { |
sub publishdirectory { |
my ($r,$fn,$thisdisfn,$nokeyref)=@_; |
my ($r,$fn,$thisdisfn,$nokeyref,$crsauthor)=@_; |
$fn=~s/\/+/\//g; |
$fn=~s/\/+/\//g; |
$thisdisfn=~s/\/+/\//g; |
$thisdisfn=~s/\/+/\//g; |
my $thisdisresdir=$thisdisfn; |
my $thisdisresdir=$thisdisfn; |
Line 2323 sub publishdirectory {
|
Line 2334 sub publishdirectory {
|
&checkbox('excludemodmeta','exclude files with modified metadata'). |
&checkbox('excludemodmeta','exclude files with modified metadata'). |
'</fieldset>'. |
'</fieldset>'. |
'<fieldset><legend>'.&mt('Actions').'</legend>'. |
'<fieldset><legend>'.&mt('Actions').'</legend>'. |
&checkbox('obsolete','make file(s) obsolete').'<br />'. |
&checkbox('obsolete','make file(s) obsolete').'<br />'); |
&common_access('dist',&mt('apply common copyright/distribution'), |
unless ($crsauthor) { |
['default','domain','public','custom']).'<br />'. |
$r->print(&common_access('dist',&mt('apply common copyright/distribution'), |
&common_access('source',&mt('apply common source availability'), |
['default','domain','public','custom']).'<br />'); |
|
} |
|
$r->print(&common_access('source',&mt('apply common source availability'), |
['closed','open']). |
['closed','open']). |
'</fieldset>' |
'</fieldset>' |
); |
); |
Line 2342 sub publishdirectory {
|
Line 2355 sub publishdirectory {
|
my %commonaccess; |
my %commonaccess; |
map { $commonaccess{$_} = 1; } &Apache::loncommon::get_env_multiple('form.commonaccess'); |
map { $commonaccess{$_} = 1; } &Apache::loncommon::get_env_multiple('form.commonaccess'); |
unless ($lock) { $lock=&Apache::lonnet::set_lock(&mt('Publishing [_1]',$fn)); } |
unless ($lock) { $lock=&Apache::lonnet::set_lock(&mt('Publishing [_1]',$fn)); } |
|
if ($lock) { |
|
¬ify_in_cleanup($r); |
|
} |
# actually publish things |
# actually publish things |
opendir(DIR,$fn); |
opendir(DIR,$fn); |
my @files=sort(readdir(DIR)); |
my @files=sort(readdir(DIR)); |
Line 2350 sub publishdirectory {
|
Line 2366 sub publishdirectory {
|
$cuid,$cgid,$crdev,$csize, |
$cuid,$cgid,$crdev,$csize, |
$catime,$cmtime,$cctime, |
$catime,$cmtime,$cctime, |
$cblksize,$cblocks)=stat($fn.'/'.$filename); |
$cblksize,$cblocks)=stat($fn.'/'.$filename); |
|
|
my $extension=''; |
my $extension=''; |
if ($filename=~/\.(\w+)$/) { $extension=$1; } |
if ($filename=~/\.(\w+)$/) { $extension=$1; } |
if ($cmode&$dirptr) { |
if ($cmode&$dirptr) { |
if (($filename!~/^\./) && ($env{'form.pubrec'})) { |
if (($filename!~/^\./) && ($env{'form.pubrec'})) { |
&publishdirectory($r,$fn.'/'.$filename,$thisdisfn.'/'.$filename,$nokeyref); |
&publishdirectory($r,$fn.'/'.$filename,$thisdisfn.'/'.$filename,$nokeyref,$crsauthor); |
} |
} |
} elsif ((&Apache::loncommon::fileembstyle($extension) ne 'hdn') && |
} elsif ((&Apache::loncommon::fileembstyle($extension) ne 'hdn') && |
($filename!~/^[\#\.]/) && ($filename!~/\~$/)) { |
($filename!~/^[\#\.]/) && ($filename!~/\~$/)) { |
Line 2598 sub handler {
|
Line 2614 sub handler {
|
|
|
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
|
|
# Breadcrumbs |
# Breadcrumbs |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
|
my $crumbtext = 'Authoring Space'; |
|
my $crumbhref = &Apache::loncommon::authorspace($fn); |
|
my $crsauthor; |
|
if ($env{'request.course.id'}) { |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
if ($crumbhref eq "/priv/$cdom/$cnum/") { |
|
$crumbtext = 'Course Authoring Space'; |
|
$crsauthor = 1; |
|
} |
|
} |
&Apache::lonhtmlcommon::add_breadcrumb({ |
&Apache::lonhtmlcommon::add_breadcrumb({ |
'text' => 'Authoring Space', |
'text' => $crumbtext, |
'href' => &Apache::loncommon::authorspace($fn), |
'href' => $crumbhref, |
}); |
}); |
&Apache::lonhtmlcommon::add_breadcrumb({ |
&Apache::lonhtmlcommon::add_breadcrumb({ |
'text' => 'Resource Publication', |
'text' => 'Resource Publication', |
Line 2673 END
|
Line 2700 END
|
|
|
if ($fn=~/\/$/) { |
if ($fn=~/\/$/) { |
# -------------------------------------------------------- This is a directory |
# -------------------------------------------------------- This is a directory |
&publishdirectory($r,$docroot.$fn,$thisdisfn,$nokeyref); |
&publishdirectory($r,$docroot.$fn,$thisdisfn,$nokeyref,$crsauthor); |
$r->print( |
$r->print( |
'<br /><br />'. |
'<br /><br />'. |
&Apache::lonhtmlcommon::actionbox([ |
&Apache::lonhtmlcommon::actionbox([ |