Skip to content

Instantly share code, notes, and snippets.

@perlDreamer
Created June 22, 2010 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perlDreamer/449230 to your computer and use it in GitHub Desktop.
Save perlDreamer/449230 to your computer and use it in GitHub Desktop.
diff --git a/lib/WebGUI/AssetClipboard.pm b/lib/WebGUI/AssetClipboard.pm
index b0f43d7..bbf2200 100644
--- a/lib/WebGUI/AssetClipboard.pm
+++ b/lib/WebGUI/AssetClipboard.pm
@@ -173,6 +173,7 @@ sub getAssetsInClipboard {
{
statesToInclude => ["clipboard"],
returnObjects => 1,
+ statusToInclude => [qw/approved pending archived/],
whereClause => $limit,
}
);
diff --git a/lib/WebGUI/AssetLineage.pm b/lib/WebGUI/AssetLineage.pm
index 6ae6d19..89ffb63 100644
--- a/lib/WebGUI/AssetLineage.pm
+++ b/lib/WebGUI/AssetLineage.pm
@@ -370,7 +370,8 @@ A string containing as asset class to join in. There is no real reason to use a
=head4 whereClause
-A string containing extra where clause information for the query.
+A string containing extra WHERE clause information for the query. The AND conjunction will be added internally, so the clause
+should not start with AND.
=head4 orderByClause
diff --git a/lib/WebGUI/AssetTrash.pm b/lib/WebGUI/AssetTrash.pm
index b66f008..58112dc 100644
--- a/lib/WebGUI/AssetTrash.pm
+++ b/lib/WebGUI/AssetTrash.pm
@@ -57,39 +57,20 @@ sub getAssetsInTrash {
my $self = shift;
my $limitToUser = shift;
my $userId = shift || $self->session->user->userId;
- my @assets;
my $limit;
if ($limitToUser) {
- $limit = "and asset.stateChangedBy=".$self->session->db->quote($userId);
+ $limit = "asset.stateChangedBy=".$self->session->db->quote($userId);
}
- my $sth = $self->session->db->read("
- select
- asset.assetId,
- assetData.revisionDate,
- asset.className
- from
- asset
- left join
- assetData on asset.assetId=assetData.assetId
- where
- asset.state='trash'
- and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId)
- $limit
- group by
- assetData.assetId
- order by
- assetData.title desc
- ");
- while (my ($id, $date, $class) = $sth->array) {
- my $asset = WebGUI::Asset->new($self->session,$id,$class,$date);
- if ($asset){
- push(@assets, $asset);
- }else{
- $self->session->errorHandler->error("AssetTrash::getAssetsInTrash - failed to instanciate asset with assetId $id, className $class, and revisionDate $date");
- }
- }
- $sth->finish;
- return \@assets;
+ my $root = WebGUI::Asset->getRoot($self->session);
+ return $root->getLineage(
+ ["descendants", ],
+ {
+ statesToInclude => ["trash"],
+ statusToInclude => [qw/approved pending archived/],
+ returnObjects => 1,
+ whereClause => $limit,
+ }
+ );
}
#----------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment