Add overrides for groupIdEdit, groupIdView and ownerUserId.
This commit is contained in:
parent
95b93fb5dd
commit
622a20877a
1 changed files with 27 additions and 26 deletions
|
|
@ -40,7 +40,14 @@ property storageId => (
|
|||
noFormPost => 1,
|
||||
fieldType => 'hidden',
|
||||
default => '',
|
||||
trigger => \&_set_storageId,
|
||||
);
|
||||
sub _set_storageId {
|
||||
my ($self, $new, $old) = @_;
|
||||
if ($new ne $old) {
|
||||
$self->setStorageLocation;
|
||||
}
|
||||
}
|
||||
property templateId => (
|
||||
fieldType => 'template',
|
||||
default => 'PBtmpl0000000000000024',
|
||||
|
|
@ -48,6 +55,26 @@ property templateId => (
|
|||
hoverHelp => ['file template description', 'Asset_File'],
|
||||
namespace => "FileAsset",
|
||||
);
|
||||
sub _set_ownerUserId {
|
||||
my ($self, $new, $old) = @_;
|
||||
if ($new ne $old) {
|
||||
$self->getStorageLocation->setPrivileges($self->ownerUserId, $self->groupIdView, $self->groupIdEdit);
|
||||
}
|
||||
}
|
||||
|
||||
sub _set_groupIdView {
|
||||
my ($self, $new, $old) = @_;
|
||||
if ($new ne $old) {
|
||||
$self->getStorageLocation->setPrivileges($self->ownerUserId, $self->groupIdView, $self->groupIdEdit);
|
||||
}
|
||||
}
|
||||
|
||||
sub _set_groupIdEdit {
|
||||
my ($self, $new, $old) = @_;
|
||||
if ($new ne $old) {
|
||||
$self->getStorageLocation->setPrivileges($self->ownerUserId, $self->groupIdView, $self->groupIdEdit);
|
||||
}
|
||||
}
|
||||
|
||||
use WebGUI::Storage;
|
||||
use WebGUI::SQL;
|
||||
|
|
@ -531,32 +558,6 @@ sub setStorageLocation {
|
|||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 update
|
||||
|
||||
We override the update method from WebGUI::Asset in order to handle file system privileges.
|
||||
|
||||
=cut
|
||||
|
||||
sub update {
|
||||
my $self = shift;
|
||||
my %before = (
|
||||
owner => $self->ownerUserId,
|
||||
view => $self->groupIdView,
|
||||
edit => $self->groupIdEdit,
|
||||
storageId => $self->storageId,
|
||||
);
|
||||
$self->SUPER::update(@_);
|
||||
##update may have entered a new storageId. Reset the cached one just in case.
|
||||
if ($self->storageId ne $before{storageId}) {
|
||||
$self->setStorageLocation;
|
||||
}
|
||||
if ($self->ownerUserId ne $before{owner} || $self->groupIdEdit ne $before{edit} || $self->groupIdView ne $before{view}) {
|
||||
$self->getStorageLocation->setPrivileges($self->ownerUserId, $self->groupIdView, $self->groupIdEdit);
|
||||
}
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 updatePropertiesFromStorage ( )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue