rfe: let package import inherit permissions
This commit is contained in:
parent
7b21d656ef
commit
79e88a867a
5 changed files with 43 additions and 10 deletions
|
|
@ -1,4 +1,5 @@
|
|||
7.6.0
|
||||
- rfe: let package import inherit permissions
|
||||
- added fieldsets around form controls with multiple elements
|
||||
- rfe: Town Hall: Menu title in search results
|
||||
- rfe: Process Macros in HTTP Proxy's URL
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ A hash reference containing the exported data.
|
|||
sub importAssetData {
|
||||
my $self = shift;
|
||||
my $data = shift;
|
||||
my $options = shift || {};
|
||||
my $error = $self->session->errorHandler;
|
||||
my $id = $data->{properties}{assetId};
|
||||
my $class = $data->{properties}{className};
|
||||
|
|
@ -140,6 +141,12 @@ sub importAssetData {
|
|||
|
||||
my $asset;
|
||||
my $revisionExists = WebGUI::Asset->assetExists($self->session, $id, $class, $version);
|
||||
my %properties = %{ $data->{properties} };
|
||||
if ($options->{inheritPermissions}) {
|
||||
delete $properties{ownerUserId};
|
||||
delete $properties{groupIdView};
|
||||
delete $properties{groupIdEdit};
|
||||
}
|
||||
if ($revisionExists) { # update an existing revision
|
||||
$asset = WebGUI::Asset->new($self->session, $id, $class, $version);
|
||||
$error->info("Updating an existing revision of asset $id");
|
||||
|
|
@ -162,7 +169,13 @@ sub importAssetData {
|
|||
}
|
||||
else { # add an entirely new asset
|
||||
$error->info("Adding $id that didn't previously exist.");
|
||||
$asset = $self->addChild($data->{properties}, $id, $version, {skipAutoCommitWorkflows => 1});
|
||||
my %properties = %{ $data->{properties} };
|
||||
if ($options->{inheritPermissions}) {
|
||||
$properties{ownerUserId} = $self->get('ownerUserId');
|
||||
$properties{groupIdView} = $self->get('groupIdView');
|
||||
$properties{groupIdEdit} = $self->get('groupIdEdit');
|
||||
}
|
||||
$asset = $self->addChild(\%properties, $id, $version, {skipAutoCommitWorkflows => 1});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -205,6 +218,7 @@ A reference to a WebGUI::Storage object that contains a webgui package file.
|
|||
sub importPackage {
|
||||
my $self = shift;
|
||||
my $storage = shift;
|
||||
my $options = shift;
|
||||
my $decompressed = $storage->untar($storage->getFiles->[0]);
|
||||
return undef
|
||||
if $storage->getErrorCount;
|
||||
|
|
@ -215,7 +229,7 @@ sub importPackage {
|
|||
foreach my $file (sort(@{$decompressed->getFiles})) {
|
||||
next unless ($decompressed->getFileExtension($file) eq "json");
|
||||
$error->info("Found data file $file");
|
||||
my $data = eval{
|
||||
my $data = eval {
|
||||
JSON->new->utf8->relaxed(1)->decode($decompressed->getFileContentsAsScalar($file))
|
||||
};
|
||||
if ($@ || $data->{properties}{assetId} eq "" || $data->{properties}{className} eq "" || $data->{properties}{revisionDate} eq "") {
|
||||
|
|
@ -228,7 +242,7 @@ sub importPackage {
|
|||
$decompressed->untar($storageId.".storage", $assetStorage);
|
||||
}
|
||||
my $asset = $assets{$data->{properties}{parentId}} || $self;
|
||||
my $newAsset = $asset->importAssetData($data);
|
||||
my $newAsset = $asset->importAssetData($data, $options);
|
||||
$newAsset->importAssetCollateralData($data);
|
||||
$assets{$newAsset->getId} = $newAsset;
|
||||
# First imported asset must be the "package"
|
||||
|
|
@ -302,6 +316,7 @@ sub www_importPackage {
|
|||
my $self = shift;
|
||||
return $self->session->privilege->insufficient() unless ($self->canEdit && $self->session->user->isInGroup(4));
|
||||
my $storage = WebGUI::Storage->createTemp($self->session);
|
||||
my $inheritPermissions = $self->session->form->process('inheritPermissions');
|
||||
|
||||
##This is a hack. It should use the WebGUI::Form::File API to insulate
|
||||
##us from future form name changes.
|
||||
|
|
@ -309,7 +324,7 @@ sub www_importPackage {
|
|||
|
||||
my $error = "";
|
||||
if ($storage->getFileExtension($storage->getFiles->[0]) eq "wgpkg") {
|
||||
$error = $self->importPackage($storage);
|
||||
$error = $self->importPackage($storage, {inheritPermissions => $inheritPermissions});
|
||||
}
|
||||
if (!blessed $error) {
|
||||
my $i18n = WebGUI::International->new($self->session, "Asset");
|
||||
|
|
|
|||
|
|
@ -520,11 +520,16 @@ ENDHTML
|
|||
.$session->icon->export("func=exportPackage",$asset->get("url"))
|
||||
.'<br />';
|
||||
}
|
||||
$output .= '<br />'.WebGUI::Form::formHeader($session, {action=>$currentAsset->getUrl})
|
||||
.WebGUI::Form::hidden($session, {name=>"func", value=>"importPackage"})
|
||||
.'<input type="file" name="packageFile" size="10" style="font-size: 10px;" />'
|
||||
.WebGUI::Form::submit($session, {value=>$i18n->get("import"), extras=>'style="font-size: 10px;"'})
|
||||
.WebGUI::Form::formFooter($session);
|
||||
$output .= '<br />'
|
||||
. WebGUI::Form::formHeader($session, {action=>$currentAsset->getUrl})
|
||||
. WebGUI::Form::hidden($session, {name=>"func", value=>"importPackage"})
|
||||
. '<div><input type="file" name="packageFile" size="30" style="font-size: 10px;" /></div>'
|
||||
. '<div style="font-size: 10px">'
|
||||
. WebGUI::Form::checkbox($session, { label => $i18n->get('inherit parent permissions'), checked => 1, name => 'inheritPermissions', value => 1 })
|
||||
. ' ' . WebGUI::Form::submit($session, { value=>$i18n->get("import"), 'extras' => ' ' })
|
||||
. '</div>'
|
||||
. WebGUI::Form::formFooter($session)
|
||||
;
|
||||
$output .= ' </fieldset></div>';
|
||||
|
||||
### Clearing div
|
||||
|
|
|
|||
|
|
@ -66,6 +66,9 @@ sub definition {
|
|||
defaultValue=>{
|
||||
defaultValue=> undef
|
||||
},
|
||||
label => {
|
||||
defaultValue => undef,
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
|
@ -122,7 +125,11 @@ sub toHtml {
|
|||
$value = defined $value ? $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($value))) : '';
|
||||
my $checkedText = $self->get("checked") ? ' checked="checked"' : '';
|
||||
my $idText = $self->get('id') ? ' id="'.$self->get('id').'" ' : '';
|
||||
return '<input type="checkbox" name="'.($self->get("name")||'').'" value="'.$value.'"'.$idText.$checkedText.' '.($self->get("extras")||'').' />';
|
||||
my $control = '<input type="checkbox" name="'.($self->get("name")||'').'" value="'.$value.'"'.$idText.$checkedText.' '.($self->get("extras")||'').' />';
|
||||
if ($self->get('label')) {
|
||||
return "<label>$control" . $self->get('label') . '</label>';
|
||||
}
|
||||
return $control;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1115,6 +1115,11 @@ Couldn't open %-s because %-s <br />
|
|||
context => q{Error message in Asset.pm},
|
||||
},
|
||||
|
||||
'inherit parent permissions' => {
|
||||
message => q{Inherit parent's permissions}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue