diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index f571a421e..c70f42a63 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -9,9 +9,10 @@ - fix: the fileImport script did not resize vertical images. (Martin Kamerbeek / Oqapi) - fix: TrashClipboard.pm (thanks to Erik Svanberg for the patch) - fix: Manage events in time tracker goofed up (perlDreamer Consulting, LLC) - - fix: Clipboard to trash (perlDreamer Consulting, LLC) + - fix: Clipboard to trash (and TrashClipboard Workflow Activity) (perlDreamer Consulting, LLC) - fix: Fixed the left column template, which still used the RawHeadTags macro. (perlDreamer Consulting, LLC) + - Fixed a bad module name in the updated WeatherData asset (perlDreamer Consulting, LLC) 7.3.11 - Added an option for enabling coverage tests to testCodebase.pl. diff --git a/lib/WebGUI/Asset/Wobject/WeatherData.pm b/lib/WebGUI/Asset/Wobject/WeatherData.pm index dd1f7a362..09c0d9867 100644 --- a/lib/WebGUI/Asset/Wobject/WeatherData.pm +++ b/lib/WebGUI/Asset/Wobject/WeatherData.pm @@ -15,7 +15,7 @@ package WebGUI::Asset::Wobject::WeatherData; =cut use strict; -use Weather::Com::Simple; +use Weather::Simple; use WebGUI::International; use base 'WebGUI::Asset::Wobject'; use WebGUI::Utility; diff --git a/lib/WebGUI/AssetClipboard.pm b/lib/WebGUI/AssetClipboard.pm index 1980b068b..f607b3e8b 100644 --- a/lib/WebGUI/AssetClipboard.pm +++ b/lib/WebGUI/AssetClipboard.pm @@ -89,18 +89,24 @@ sub duplicate { #------------------------------------------------------------------- -=head2 getAssetsInClipboard ( [limitToUser,userId] ) +=head2 getAssetsInClipboard ( [limitToUser,userId,expireTime] ) -Returns an array reference of title, assetId, and classname to the assets in the clipboard. +Returns an array reference of assets that are in the clipboard. Only assets that are committed +or that are under the current user's version tag are returned. =head3 limitToUser -If True, only return assets last updated by userId. +If True, only return assets last updated by userId, specified below. =head3 userId If not specified, uses current user. +=head3 expireTime + +If defined, then uses expireTime to limit returned assets to only include those +before expireTime. + =cut sub getAssetsInClipboard { @@ -108,34 +114,27 @@ sub getAssetsInClipboard { my $session = $self->session; my $limitToUser = shift; my $userId = shift || $session->user->userId; - my @assets; - my $limit; + my $expireTime = shift; + + my @limits = (); if ($limitToUser) { - $limit = "and asset.stateChangedBy=".$session->db->quote($userId); + push @limits, "asset.stateChangedBy=".$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='clipboard' - and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId and (assetData.status='approved' or assetData.tagId=?)) - $limit - group by - assetData.assetId - order by - assetData.title desc - ", [$session->scratch->get("versionTag")]); - while (my ($id, $date, $class) = $sth->array) { - push(@assets, WebGUI::Asset->new($session,$id,$class,$date)); - } - $sth->finish; - return \@assets; + if (defined $expireTime) { + push @limits, "stateChanged < ".$expireTime; + } + + my $limit = join ' and ', @limits; + + my $root = WebGUI::Asset->getRoot($self->session); + return $root->getLineage( + ["descendents", ], + { + statesToInclude => ["clipboard"], + returnObjects => 1, + whereClause => $limit, + } + ); } #------------------------------------------------------------------- diff --git a/lib/WebGUI/AssetLineage.pm b/lib/WebGUI/AssetLineage.pm index 23647020d..f842d2adf 100644 --- a/lib/WebGUI/AssetLineage.pm +++ b/lib/WebGUI/AssetLineage.pm @@ -422,7 +422,7 @@ sub getLineage { } ## finish up our where clause $where .= ' and ('.join(" or ",@whereModifiers).')' if (scalar(@whereModifiers)); - if (exists $rules->{whereClause}) { + if (exists $rules->{whereClause} && $rules->{whereClause}) { $where .= ' and ('.$rules->{whereClause}.')'; } # based upon all available criteria, let's get some assets diff --git a/lib/WebGUI/Workflow/Activity/TrashClipboard.pm b/lib/WebGUI/Workflow/Activity/TrashClipboard.pm index 7016de213..c50c8cbd4 100644 --- a/lib/WebGUI/Workflow/Activity/TrashClipboard.pm +++ b/lib/WebGUI/Workflow/Activity/TrashClipboard.pm @@ -17,6 +17,8 @@ package WebGUI::Workflow::Activity::TrashClipboard; use strict; use base 'WebGUI::Workflow::Activity'; +use WebGUI::Asset; +use WebGUI::AssetClipboard; =head1 NAME @@ -74,13 +76,12 @@ See WebGUI::Workflow::Activity::execute() for details. =cut sub execute { - my $self = shift; - my $expireDate = (time()-$self->get("trashAfter")); - my $sth = $self->session->db->read("select assetId,className from asset where state='clipboard' and stateChanged < ?", [$expireDate]); - while (my ($id, $class) = $sth->array) { - my $asset = WebGUI::Asset->new($self->session,$id,$class); + my $self = shift; + my $expireDate = (time()-$self->get("trashAfter")); + my $root = WebGUI::Asset->getRoot($self->session); + foreach my $asset ( @{ $root->getAssetsInClipboard('', '', $expireDate) } ) { $asset->trash; - } + } return $self->COMPLETE; }