Merge commit 'v7.10.15' into 8
Conflicts: docs/gotcha.txt docs/previousVersion.sql docs/templates.txt lib/WebGUI.pm lib/WebGUI/Asset.pm lib/WebGUI/Asset/Event.pm lib/WebGUI/Asset/File.pm lib/WebGUI/Asset/MapPoint.pm lib/WebGUI/Asset/RichEdit.pm lib/WebGUI/Asset/Sku/Product.pm lib/WebGUI/Asset/Snippet.pm lib/WebGUI/Asset/Story.pm lib/WebGUI/Asset/Template.pm lib/WebGUI/Asset/Template/TemplateToolkit.pm lib/WebGUI/Asset/Wobject/Calendar.pm lib/WebGUI/Asset/Wobject/Carousel.pm lib/WebGUI/Asset/Wobject/Collaboration.pm lib/WebGUI/Asset/Wobject/Dashboard.pm lib/WebGUI/Asset/Wobject/DataForm.pm lib/WebGUI/Asset/Wobject/Folder.pm lib/WebGUI/Asset/Wobject/Map.pm lib/WebGUI/Asset/Wobject/Search.pm lib/WebGUI/Asset/Wobject/Shelf.pm lib/WebGUI/Asset/Wobject/StockData.pm lib/WebGUI/Asset/Wobject/StoryTopic.pm lib/WebGUI/Asset/Wobject/SyndicatedContent.pm lib/WebGUI/Asset/Wobject/Thingy.pm lib/WebGUI/Asset/Wobject/WeatherData.pm lib/WebGUI/AssetClipboard.pm lib/WebGUI/AssetCollateral/DataForm/Entry.pm lib/WebGUI/AssetExportHtml.pm lib/WebGUI/AssetLineage.pm lib/WebGUI/AssetMetaData.pm lib/WebGUI/AssetTrash.pm lib/WebGUI/AssetVersioning.pm lib/WebGUI/Auth.pm lib/WebGUI/Cache/CHI.pm lib/WebGUI/Content/AssetManager.pm lib/WebGUI/Fork/ProgressBar.pm lib/WebGUI/Form/JsonTable.pm lib/WebGUI/Form/TimeField.pm lib/WebGUI/Form/Zipcode.pm lib/WebGUI/Group.pm lib/WebGUI/International.pm lib/WebGUI/Macro/AssetProxy.pm lib/WebGUI/Macro/FileUrl.pm lib/WebGUI/Operation/SSO.pm lib/WebGUI/Operation/User.pm lib/WebGUI/Role/Asset/Subscribable.pm lib/WebGUI/Shop/Cart.pm lib/WebGUI/Shop/Transaction.pm lib/WebGUI/Shop/TransactionItem.pm lib/WebGUI/Test.pm lib/WebGUI/URL/Content.pm lib/WebGUI/URL/Uploads.pm lib/WebGUI/User.pm lib/WebGUI/Workflow/Activity/ExtendCalendarRecurrences.pm lib/WebGUI/Workflow/Activity/SendNewsletters.pm lib/WebGUI/i18n/English/Asset.pm lib/WebGUI/i18n/English/WebGUI.pm sbin/installClass.pl sbin/rebuildLineage.pl sbin/search.pl sbin/testEnvironment.pl t/Asset/Asset.t t/Asset/AssetClipboard.t t/Asset/AssetLineage.t t/Asset/AssetMetaData.t t/Asset/Event.t t/Asset/File.t t/Asset/File/Image.t t/Asset/Post/notification.t t/Asset/Sku.t t/Asset/Story.t t/Asset/Template.t t/Asset/Wobject/Collaboration/templateVariables.t t/Asset/Wobject/Collaboration/unarchiveAll.t t/Asset/Wobject/Shelf.t t/Auth.t t/Macro/EditableToggle.t t/Macro/FilePump.t t/Shop/Cart.t t/Shop/Transaction.t t/Storage.t t/User.t t/Workflow.t
This commit is contained in:
commit
277faae8a1
783 changed files with 32041 additions and 25495 deletions
|
|
@ -44,6 +44,8 @@ This package provides a mechanism for storing and retrieving files that are not
|
|||
$store = WebGUI::Storage->createTemp($self->session);
|
||||
$store = WebGUI::Storage->get($self->session,$id);
|
||||
|
||||
$exists = WebGUI::Storage->storageExists($session, $id);
|
||||
|
||||
$filename = $store->addFileFromFilesystem($pathToFile);
|
||||
$filename = $store->addFileFromFormPost($formVarName,$attachmentLimit);
|
||||
$filename = $store->addFileFromHashref($filename,$hashref);
|
||||
|
|
@ -304,7 +306,10 @@ sub addFileFromFilesystem {
|
|||
if (! defined $pathToFile) {
|
||||
return undef;
|
||||
}
|
||||
##Handle UTF-8 filenames.
|
||||
$pathToFile = Encode::encode_utf8($pathToFile);
|
||||
$pathToFile = Cwd::realpath($pathToFile); # trace any symbolic links
|
||||
$pathToFile = Encode::decode_utf8($pathToFile);
|
||||
if (-d $pathToFile) {
|
||||
$self->session->log->error($pathToFile." is a directory, not a file.");
|
||||
return undef;
|
||||
|
|
@ -370,6 +375,7 @@ sub addFileFromFormPost {
|
|||
return $filename;
|
||||
}
|
||||
my $clientFilename = $upload->filename;
|
||||
$clientFilename = Encode::decode_utf8($clientFilename);
|
||||
next
|
||||
unless $clientFilename;
|
||||
next
|
||||
|
|
@ -1078,7 +1084,7 @@ sub getFiles {
|
|||
callback => sub {
|
||||
my $obj = shift;
|
||||
my $rel = $obj->relative($dir);
|
||||
my $str = $rel->stringify;
|
||||
my $str = Encode::decode_utf8($rel->stringify);
|
||||
if (! $showAll ) {
|
||||
return if $str =~ /^thumb-/;
|
||||
return if $str =~ /^\./;
|
||||
|
|
@ -1704,36 +1710,34 @@ sub setPrivileges {
|
|||
}
|
||||
}
|
||||
|
||||
my $public;
|
||||
for my $user (@{ $privs{users} }) {
|
||||
if ($user eq '1') {
|
||||
$public = 1;
|
||||
}
|
||||
}
|
||||
for my $group (@{ $privs{groups} }) {
|
||||
if ($group eq '1' || $group eq '7') {
|
||||
$public = 1;
|
||||
}
|
||||
}
|
||||
my $accessFile = JSON->new->encode( \%privs );
|
||||
return $self->writeAccess( %privs );
|
||||
}
|
||||
|
||||
my $dirObj = $self->getPathClassDir();
|
||||
return undef if ! defined $dirObj;
|
||||
$dirObj->recurse(
|
||||
callback => sub {
|
||||
my $obj = shift;
|
||||
return unless $obj->is_dir;
|
||||
my $rel = $obj->relative($dirObj);
|
||||
|
||||
if ($public) {
|
||||
$self->deleteFile($rel->file('.wgaccess')->stringify);
|
||||
}
|
||||
else {
|
||||
$self->addFileFromScalar($rel->file('.wgaccess')->stringify, $accessFile);
|
||||
}
|
||||
}
|
||||
);
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 storageExists ( $session, $storageId )
|
||||
|
||||
Class method to determine if a storage location exists. This can't be done
|
||||
with C<get> since it will create it if it doesn't exist. Returns true if the
|
||||
storage directory exists.
|
||||
|
||||
=head3 $session
|
||||
|
||||
A session object, used to find the uploadsPath location
|
||||
|
||||
=head3 $storageId
|
||||
|
||||
A WebGUI::Storage GUID.
|
||||
|
||||
=cut
|
||||
|
||||
sub storageExists {
|
||||
my ($class, $session, $storageId) = @_;
|
||||
my $hexId = $session->id->toHex($storageId);
|
||||
my @parts = ($hexId =~ m/^((.{2})(.{2}).+)/)[1,2,0];
|
||||
my $dir = Path::Class::Dir->new($session->config->get('uploadsPath'), @parts);
|
||||
return (-e $dir->stringify && -d _ ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1808,6 +1812,19 @@ sub tar {
|
|||
return $temp;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 trash ( )
|
||||
|
||||
Set this storage location as trashed
|
||||
|
||||
=cut
|
||||
|
||||
sub trash {
|
||||
my ( $self ) = @_;
|
||||
return $self->writeAccess( state => "trash" );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 untar ( filename [, storage ] )
|
||||
|
|
@ -1867,5 +1884,64 @@ sub getDirectoryId {
|
|||
return $self->{_pathParts}[2];
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 writeAccess( pairs )
|
||||
|
||||
Write the given pairs to the wgaccess files in this storage location.
|
||||
|
||||
If the storage location should be public, will remove all wgaccess files.
|
||||
|
||||
Possible keys:
|
||||
|
||||
users - an arrayref of userIds to allow access to
|
||||
groups - an arrayref of groupIds to allow access to
|
||||
assets - an arrayref of assetIds to validate permissions against
|
||||
state - a string describing a special state.
|
||||
valid values: "trash" - storage location is trashed
|
||||
|
||||
|
||||
=cut
|
||||
|
||||
sub writeAccess {
|
||||
my ( $self, %privs ) = @_;
|
||||
|
||||
my $public;
|
||||
if ( $privs{users} ) {
|
||||
for my $user (@{ $privs{users} }) {
|
||||
if ($user eq '1') {
|
||||
$public = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $privs{groups} ) {
|
||||
for my $group (@{ $privs{groups} }) {
|
||||
if ($group eq '1' || $group eq '7') {
|
||||
$public = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
my $accessFile = JSON->new->encode( \%privs );
|
||||
|
||||
my $dirObj = $self->getPathClassDir();
|
||||
return undef if ! defined $dirObj;
|
||||
$dirObj->recurse(
|
||||
callback => sub {
|
||||
my $obj = shift;
|
||||
return unless $obj->is_dir;
|
||||
my $rel = $obj->relative($dirObj);
|
||||
|
||||
if ($public) {
|
||||
$self->deleteFile($rel->file('.wgaccess')->stringify);
|
||||
}
|
||||
else {
|
||||
$self->addFileFromScalar($rel->file('.wgaccess')->stringify, $accessFile);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue