diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt
index 897e5f34b..690bd3041 100644
--- a/docs/changelog/7.x.x.txt
+++ b/docs/changelog/7.x.x.txt
@@ -14,6 +14,7 @@
- Added ability for upgrade scripts to contain packages to deploy
- Fixed chdir problem in Storage -- more remain though
- Added a new plugin handler system that is both faster and more secure.
+ - Added switch for assets to determine whether they are exportable.
7.4.20
- fix: Assets with no committed versions may be left as orphans when parent is purged
diff --git a/docs/upgrades/upgrade_7.4.18-7.5.0.pl b/docs/upgrades/upgrade_7.4.18-7.5.0.pl
index c08072f1a..2f24d32e1 100644
--- a/docs/upgrades/upgrade_7.4.18-7.5.0.pl
+++ b/docs/upgrades/upgrade_7.4.18-7.5.0.pl
@@ -28,6 +28,7 @@ addGroupToEditPost($session);
installGalleryAsset($session);
installGalleryAlbumAsset($session);
installPhotoAsset($session);
+addIsExportable($session);
finish($session); # this line required
@@ -264,6 +265,15 @@ ENDSQL
print "DONE!\n" unless $quiet;
}
+#----------------------------------------------------------------------------
+# Add the isExportable property for all assets
+sub addIsExportable {
+ my $session = shift;
+ print "Adding isExportable flag for all assets (fine-grained export control)..." unless $quiet;
+ $session->db->write('alter table assetData add column isExportable int(11) not null default 0');
+ print "DONE!\n" unless $quiet;
+}
+
# --------------- DO NOT EDIT BELOW THIS LINE --------------------------------
#----------------------------------------------------------------------------
diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm
index df8745442..ac1b51ce3 100644
--- a/lib/WebGUI/Asset.pm
+++ b/lib/WebGUI/Asset.pm
@@ -451,6 +451,14 @@ sub definition {
fieldType=>'yesNo',
defaultValue=>0
},
+ isExportable=>{
+ tab=>'meta',
+ label=>$i18n->get('make asset exportable'),
+ hoverHelp=>$i18n->get('make asset exportable description'),
+ uiLevel=>9,
+ fieldType=>'yesNo',
+ defaultValue=>0,
+ },
status=>{
noFormPost=>1,
fieldType=>'hidden',
diff --git a/lib/WebGUI/AssetExportHtml.pm b/lib/WebGUI/AssetExportHtml.pm
index e96013d9f..206285230 100644
--- a/lib/WebGUI/AssetExportHtml.pm
+++ b/lib/WebGUI/AssetExportHtml.pm
@@ -109,7 +109,8 @@ sub _exportAsHtml {
$tempSession->close;
# We're going to walk up the URL branch, making the deepest paths first
- foreach my $assetId (@{$assetIds}) {
+ my $exportedCount = 0;
+ ASSET: foreach my $assetId (@{$assetIds}) {
my $assetSession = WebGUI::Session->open($self->session->config->getWebguiRoot, $self->session->config->getFilename);
$assetSession->user({userId=>$userId});
my $asset = WebGUI::Asset->newByDynamicClass($assetSession, $assetId);
@@ -128,6 +129,19 @@ sub _exportAsHtml {
}
my $path = $exportPath . '/'. $pathData->{'path'};
my $filename = $pathData->{'filename'};
+ my $pathWithFilename = $path.'/'.$filename;
+ $pathWithFilename =~ s{//}{/}g;
+
+ # if this asset isn't exportable, skip it.
+ my $parentAssets = $asset->getLineage(['ancestors'], { returnObjects => 1} );
+ for my $exportCheck(@{$parentAssets}, $asset) {
+ # don't count the root asset
+ next if $exportCheck->getUrl eq '/root';
+ unless ($exportCheck->get('isExportable')) {
+ $self->session->output->print("$pathWithFilename skipped, not exportable
") unless $quiet;
+ next ASSET;
+ }
+ }
# this is needed for symlinking
if ($asset->getId eq $defaultAssetId) {
@@ -143,8 +157,6 @@ sub _exportAsHtml {
}
# output which page we're exporting
- my $pathWithFilename = $path.'/'.$filename;
- $pathWithFilename =~ s{//}{/}g;
unless ($quiet) {
$self->session->output->print(sprintf($i18n->get('exporting page'), $pathWithFilename));
}
@@ -169,6 +181,7 @@ sub _exportAsHtml {
$assetSession->close;
$self->session->db->write("UPDATE asset SET lastExportedAs = ? WHERE assetId = ?", [$pathWithFilename, $asset->getId]);
$self->session->output->print($i18n->get('done')) unless $quiet;
+ $exportedCount++;
}
# symlink?
@@ -212,7 +225,7 @@ sub _exportAsHtml {
# Nothing. This is the default.
}
- return (1, sprintf($i18n->get('export information'), scalar(@{$assetIds}), ($self->session->datetime->time()-$startTime)));
+ return (1, sprintf($i18n->get('export information'), $exportedCount, ($self->session->datetime->time()-$startTime)));
}
#-------------------------------------------------------------------
diff --git a/lib/WebGUI/i18n/English/Asset.pm b/lib/WebGUI/i18n/English/Asset.pm
index c4585ae52..2e96cc69b 100644
--- a/lib/WebGUI/i18n/English/Asset.pm
+++ b/lib/WebGUI/i18n/English/Asset.pm
@@ -1027,6 +1027,16 @@ Couldn't open %-s because %-s
lastUpdated => 1160773957,
},
+ 'make asset exportable' => {
+ message => q|Make this asset exportable?|,
+ lastUpdated => 0,
+ },
+
+ 'make asset exportable description' => {
+ message => q|
Will this asset be exportable? This asset, and all of its parent assets, must be exportable for this asset to be exported.
|, + lastUpdated => 0, + }, + }; 1; diff --git a/t/Asset/Asset.t b/t/Asset/Asset.t index 038b2d59a..0af5bbad9 100644 --- a/t/Asset/Asset.t +++ b/t/Asset/Asset.t @@ -652,6 +652,13 @@ isa_ok(WebGUI::Asset->getNotFound($session), 'WebGUI::Asset', 'getNotFound: Retu $session->setting->set('notFoundPage', $origNotFoundPage); +################################################################ +# +# isExportable +# +################################################################ +is($rootAsset->get('isExportable'), 0, 'isExportable exists, defaults to 0'); + END: { $session->config->set( 'extrasURL', $origExtras); $session->config->set( 'uploadsURL', $origUploads);