diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index a331d106f..89e31748a 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -6,6 +6,7 @@ - fixed: displaying performance profile data only to an allowed IP address. - fixed #10528: Thingy css error - fixed: Performance improvements with getting the list of asset packages. + - fixed: Performance improvements with getting the list of content prototypes. 7.7.10 - Made a change to LDAP auth that adds an OR to that query so that it also searches for a row with fieldData REGEXP '^uid=(value-from-ldap-directory-server),'. (Wes Morgan) diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 47b019269..3d71043b9 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -1279,6 +1279,32 @@ sub getNotFound { } +#------------------------------------------------------------------- + +=head2 getPrototypeList ( ) + +Returns an array of all assets that the user can view and edit that are prototypes. + +=cut + +sub getPrototypeList { + my $self = shift; + my $session = $self->session; + my $db = $session->db; + my @prototypeIds = $db->buildArray("select distinct assetId from assetData where isPrototype=1"); + my $userUiLevel = $session->user->profileField('uiLevel'); + my @assets; + ID: foreach my $id (@prototypeIds) { + my $asset = WebGUI::Asset->newByDynamicClass($session, $id); + next ID unless defined $asset; + next ID unless $asset->get('isPrototype'); + next ID unless ($asset->get('status') eq 'approved' || $asset->get('tagId') eq $session->scratch->get("versionTag")); + push @assets, $asset; + } + return \@assets; + +} + #------------------------------------------------------------------- =head2 getRoot ( session ) diff --git a/lib/WebGUI/Macro/AdminBar.pm b/lib/WebGUI/Macro/AdminBar.pm index b868fc502..cb5cfe065 100644 --- a/lib/WebGUI/Macro/AdminBar.pm +++ b/lib/WebGUI/Macro/AdminBar.pm @@ -146,15 +146,10 @@ sub process { } # prototypes - my $sth = $session->db->read("select asset.className,asset.assetId,assetData.revisionDate from asset - left join assetData on asset.assetId=assetData.assetId - where assetData.isPrototype=1 and asset.state='published' and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId) - group by assetData.assetId"); - while (my ($class, $id, $date) = $sth->array) { - my $prototype = WebGUI::Asset->new($session,$id,$class,$date); + foreach my $prototype (@{ $session->asset->getPrototypeList }) { next unless ($prototype->canView && $prototype->canAdd($session) && $prototype->getUiLevel <= $userUiLevel); $categories{prototypes}{items}{$prototype->getTitle} = { - url => $asset->getUrl("func=add;class=".$class.";prototype=".$prototype->getId), + url => $asset->getUrl("func=add;class=".$prototype->get('className').";prototype=".$prototype->getId), icon => $prototype->getIcon(1), }; }