fix a bug where updating the storageId in File Type assets did not update the cached storageLocation. Also fixed the Thumbnail Macro test

This commit is contained in:
Colin Kuskie 2006-12-09 06:05:26 +00:00
parent 332933337a
commit 2c246c06cc
6 changed files with 195 additions and 11 deletions

View file

@ -199,15 +199,11 @@ sub getIcon {
#-------------------------------------------------------------------
sub getStorageLocation {
my $self = shift;
unless (exists $self->{_storageLocation}) {
if ($self->get("storageId") eq "") {
$self->{_storageLocation} = WebGUI::Storage->create($self->session);
$self->update({storageId=>$self->{_storageLocation}->getId});
} else {
$self->{_storageLocation} = WebGUI::Storage->get($self->session,$self->get("storageId"));
}
$self->setStorageLocation;
}
return $self->{_storageLocation};
}
@ -313,6 +309,18 @@ sub setSize {
#-------------------------------------------------------------------
sub setStorageLocation {
my $self = shift;
if ($self->get("storageId") eq "") {
$self->{_storageLocation} = WebGUI::Storage->create($self->session);
$self->update({storageId=>$self->{_storageLocation}->getId});
} else {
$self->{_storageLocation} = WebGUI::Storage->get($self->session,$self->get("storageId"));
}
}
#-------------------------------------------------------------------
=head2 update
We override the update method from WebGUI::Asset in order to handle file system privileges.
@ -324,9 +332,14 @@ sub update {
my %before = (
owner => $self->get("ownerUserId"),
view => $self->get("groupIdView"),
edit => $self->get("groupIdEdit")
edit => $self->get("groupIdEdit"),
storageId => $self->get('storageId'),
);
$self->SUPER::update(@_);
##update may have entered a new storageId. Reset the cached one just in case.
if ($self->get("storageId") ne $before{storageId}) {
$self->setStorageLocation;
}
if ($self->get("ownerUserId") ne $before{owner} || $self->get("groupIdEdit") ne $before{edit} || $self->get("groupIdView") ne $before{view}) {
$self->getStorageLocation->setPrivileges($self->get("ownerUserId"),$self->get("groupIdView"),$self->get("groupIdEdit"));
}

View file

@ -148,11 +148,12 @@ sub getEditForm {
#-------------------------------------------------------------------
sub getStorageLocation {
my $self = shift;
unless (exists $self->{_storageLocation}) {
if ($self->get("storageId") eq "") {
$self->{_storageLocation} = WebGUI::Storage::Image->create($self->session);
$self->{_storageLocation} = WebGUI::Storage::Image->create($self->session);
$self->update({storageId=>$self->{_storageLocation}->getId});
} else {
$self->{_storageLocation} = WebGUI::Storage::Image->get($self->session,$self->get("storageId"));
@ -222,6 +223,18 @@ sub setSize {
return $self->SUPER::setSize($size);
}
#-------------------------------------------------------------------
sub setStorageLocation {
my $self = shift;
if ($self->get("storageId") eq "") {
$self->{_storageLocation} = WebGUI::Storage::Image->create($self->session);
$self->update({storageId=>$self->{_storageLocation}->getId});
} else {
$self->{_storageLocation} = WebGUI::Storage::Image->get($self->session,$self->get("storageId"));
}
}
#-------------------------------------------------------------------
sub view {
my $self = shift;