Add fine-grained export controls. You can now specify whether you want specific
assets to be exportable. If any of an asset's parents aren't exportable, that asset also won't be exportable.
This commit is contained in:
parent
ba44d57e9f
commit
7accc3c57f
6 changed files with 53 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 --------------------------------
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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<br />") 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)));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1027,6 +1027,16 @@ Couldn't open %-s because %-s <br />
|
|||
lastUpdated => 1160773957,
|
||||
},
|
||||
|
||||
'make asset exportable' => {
|
||||
message => q|Make this asset exportable?|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'make asset exportable description' => {
|
||||
message => q|<p>Will this asset be exportable? This asset, and all of its parent assets, must be exportable for this asset to be exported.</p>|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue