Refactor code for updating storage location file permissions into a Role.
This commit is contained in:
parent
abaeab36e0
commit
90facc46a9
4 changed files with 60 additions and 60 deletions
|
|
@ -55,26 +55,8 @@ 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);
|
||||
}
|
||||
}
|
||||
with 'WebGUI::AssetRole::SetStoragePermissions';
|
||||
|
||||
use WebGUI::Storage;
|
||||
use WebGUI::SQL;
|
||||
|
|
|
|||
|
|
@ -75,27 +75,7 @@ property content => (
|
|||
|
||||
with 'WebGUI::AssetRole::AlwaysHidden';
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
with 'WebGUI::AssetRole::SetStoragePermissions';
|
||||
|
||||
|
||||
use WebGUI::Asset::Template;
|
||||
|
|
|
|||
|
|
@ -72,27 +72,8 @@ sub _set_storageId {
|
|||
sub _storageid_deleteFileUrl {
|
||||
return shift->session->url->page("func=deleteFile;filename=");
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
with 'WebGUI::AssetRole::SetStoragePermissions';
|
||||
|
||||
use WebGUI::Storage;
|
||||
use WebGUI::HTML;
|
||||
|
|
|
|||
57
lib/WebGUI/AssetRole/SetStoragePermissions.pm
Normal file
57
lib/WebGUI/AssetRole/SetStoragePermissions.pm
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
package WebGUI::AssetRole::SetStoragePermissions;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=cut
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::AssetRole::SetStoragePermissions
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Provide methods for the triggers on ownerUserId, groupIdEdit and groupIdView that update
|
||||
the file permissions on storage locations for an Asset.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
with WebGUI::AssetRole::SetStoragePermissions;
|
||||
|
||||
=cut
|
||||
|
||||
use Moose::Role;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
Loading…
Add table
Add a link
Reference in a new issue