newByDynamicClass changed to newById

This commit is contained in:
Colin Kuskie 2009-12-27 19:08:15 -08:00
parent 0fd922daed
commit 49bd7f5032
41 changed files with 94 additions and 94 deletions

View file

@ -197,7 +197,7 @@ sub www_view {
my @contribs = ();
foreach my $row ( @{$p->getPageData} ) {
my $assetId = $row->{assetId};
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
my $asset = WebGUI::Asset->newById( $session, $assetId );
my $props = $asset->get;
$props->{url} = $asset->getUrl;
if (ref $asset eq "WebGUI::Asset::Post") {

View file

@ -271,7 +271,7 @@ sub www_viewSales {
my $data = $row;
# Add asset properties to tmpl_vars.
my $asset = WebGUI::Asset->newByDynamicClass( $session, $row->{ assetId } );
my $asset = WebGUI::Asset->newById( $session, $row->{ assetId } );
$row = { %{ $row }, %{ $asset->get } } if $asset;
push @products, $row;

View file

@ -750,7 +750,7 @@ A reference to the current session.
sub getDefault {
my $class = shift;
my $session = shift;
return $class->newByDynamicClass($session, $session->setting->get("defaultPage"));
return $class->newById($session, $session->setting->get("defaultPage"));
}
@ -1056,7 +1056,7 @@ A reference to the current session.
sub getImportNode {
my $class = shift;
my $session = shift;
return WebGUI::Asset->newByDynamicClass($session, "PBasset000000000000002");
return WebGUI::Asset->newById($session, "PBasset000000000000002");
}
@ -1136,7 +1136,7 @@ A reference to the current session.
sub getMedia {
my $class = shift;
my $session = shift;
return WebGUI::Asset->newByDynamicClass($session, "PBasset000000000000003");
return WebGUI::Asset->newById($session, "PBasset000000000000003");
}
@ -1186,7 +1186,7 @@ A reference to the current session.
sub getNotFound {
my $class = shift;
my $session = shift;
return WebGUI::Asset->newByDynamicClass($session, $session->setting->get("notFoundPage"));
return WebGUI::Asset->newById($session, $session->setting->get("notFoundPage"));
}
@ -1206,7 +1206,7 @@ sub getPrototypeList {
my $userUiLevel = $session->user->profileField('uiLevel');
my @assets;
ID: foreach my $id (@prototypeIds) {
my $asset = WebGUI::Asset->newByDynamicClass($session, $id);
my $asset = WebGUI::Asset->newById($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"));
@ -1267,7 +1267,7 @@ A reference to the current session.
sub getTempspace {
my $class = shift;
my $session = shift;
return WebGUI::Asset->newByDynamicClass($session, "tempspace0000000000000");
return WebGUI::Asset->newById($session, "tempspace0000000000000");
}
@ -1592,7 +1592,7 @@ no revision date is available it will return undef.
#-------------------------------------------------------------------
=head2 newByDynamicClass ( session, assetId [ , revisionDate ] )
=head2 newById ( session, assetId [ , revisionDate ] )
Instances an existing Asset, by looking up the classname of the asset specified by the assetId, and then calling new.
Returns undef if it can't find the classname.
@ -1611,16 +1611,16 @@ A specific revision date for the asset to retrieve. If not specified, the most r
=cut
sub newByDynamicClass {
sub newById {
my $class = shift;
my $session = shift;
my $assetId = shift;
my $revisionDate = shift;
# Some code requires that these situations not die.
# confess "newByDynamicClass requires WebGUI::Session"
# confess "newById requires WebGUI::Session"
# unless $session && blessed $session eq 'WebGUI::Session';
# confess "newByDynamicClass requires assetId"
# confess "newById requires assetId"
# unless $assetId;
# So just return instead
return undef unless ( $session && blessed $session eq 'WebGUI::Session' )
@ -2109,7 +2109,7 @@ sub publish {
$self->session->db->write("update asset set state='published', stateChangedBy=".$self->session->db->quote($self->session->user->userId).", stateChanged=".$self->session->datetime->time()." where assetId in (".$idList.")");
foreach my $id (@{$assetIds}) {
my $asset = WebGUI::Asset->newByDynamicClass($self->session, $id);
my $asset = WebGUI::Asset->newById($self->session, $id);
if (defined $asset) {
$asset->purgeCache;
}

View file

@ -478,7 +478,7 @@ sub getEventNext {
return undef unless $events->[0];
return WebGUI::Asset->newByDynamicClass($self->session,$events->[0]);
return WebGUI::Asset->newById($self->session,$events->[0]);
}
@ -534,7 +534,7 @@ sub getEventPrev {
});
return undef unless $events->[0];
return WebGUI::Asset->newByDynamicClass($self->session,$events->[0]);
return WebGUI::Asset->newById($self->session,$events->[0]);
}
@ -1722,7 +1722,7 @@ sub processPropertiesFromFormPost {
});
for my $eventId (@{$events}) {
my $event = WebGUI::Asset->newByDynamicClass($session, $eventId);
my $event = WebGUI::Asset->newById($session, $eventId);
# Add a revision
$properties{ startDate } = $event->get("startDate");

View file

@ -541,7 +541,7 @@ sub makeShortcut {
croak "GalleryFile->makeShortcut: parentId must be defined"
unless $parentId;
my $parent = WebGUI::Asset->newByDynamicClass($session, $parentId)
my $parent = WebGUI::Asset->newById($session, $parentId)
|| croak "GalleryFile->makeShortcut: Could not instanciate asset '$parentId'";
my $shortcut
@ -1013,7 +1013,7 @@ sub www_makeShortcut {
my $albums = $self->getGallery->getAlbumIds;
my %albumOptions;
for my $assetId ( @$albums ) {
my $asset = WebGUI::Asset->newByDynamicClass($session, $assetId);
my $asset = WebGUI::Asset->newById($session, $assetId);
if ($asset->canAddFile) {
$albumOptions{ $assetId } = $asset->get("title");
}

View file

@ -591,7 +591,7 @@ sub getShortcutByCriteria {
$scratchId = "Shortcut_" . $assetId;
if($self->session->scratch->get($scratchId) && !$self->getValue("disableContentLock")) {
unless ($self->session->var->isAdminOn) {
return WebGUI::Asset->newByDynamicClass($self->session, $self->session->scratch->get($scratchId));
return WebGUI::Asset->newById($self->session, $self->session->scratch->get($scratchId));
}
}
}
@ -675,7 +675,7 @@ sub getShortcutByCriteria {
# Store the matching assetId in user scratch.
$self->session->scratch->set($scratchId,$id) if ($scratchId);
return WebGUI::Asset->newByDynamicClass($self->session, $id);
return WebGUI::Asset->newById($self->session, $id);
}
#-------------------------------------------------------------------
@ -688,7 +688,7 @@ Return the asset that this Shortcut points to.
sub getShortcutDefault {
my $self = shift;
return WebGUI::Asset->newByDynamicClass($self->session, $self->get("shortcutToAssetId"));
return WebGUI::Asset->newById($self->session, $self->get("shortcutToAssetId"));
}
#-------------------------------------------------------------------
@ -1163,7 +1163,7 @@ sub www_editOverride {
$params{label} = $params{label} || $i18n->get("Edit Field Directly");
$params{hoverHelp} = $params{hoverHelp} || $i18n->get("Use this field to edit the override using the native form handler for this field type");
if ($params{fieldType} eq 'template') {$params{namespace} = $params{namespace} || WebGUI::Asset->newByDynamicClass($self->session, $origValue)->get("namespace");}
if ($params{fieldType} eq 'template') {$params{namespace} = $params{namespace} || WebGUI::Asset->newById($self->session, $origValue)->get("namespace");}
$f->dynamicField(%params);
$f->textarea(

View file

@ -482,7 +482,7 @@ The sku attached to the object you wish to instanciate.
sub newBySku {
my ($class, $session, $sku) = @_;
my $assetId = $session->db->quickScalar("select assetId from sku where sku=?", [$sku]);
return WebGUI::Asset->newByDynamicClass($session, $assetId);
return WebGUI::Asset->newById($session, $assetId);
}
#-------------------------------------------------------------------

View file

@ -1794,7 +1794,7 @@ sub view {
$segment = $self->session->icon->delete('func=deleteAccessoryConfirm&aid='.$id,$self->get('url'),$i18n->get(2))
. $self->session->icon->moveUp('func=moveAccessoryUp&aid='.$id,$self->get('url'))
. $self->session->icon->moveDown('func=moveAccessoryDown&aid='.$id,$self->get('url'));
my $accessory = WebGUI::Asset->newByDynamicClass($session, $collateral->{accessoryAssetId});
my $accessory = WebGUI::Asset->newById($session, $collateral->{accessoryAssetId});
push(@accessoryloop,{
'accessory_URL' => $accessory->getUrl,
'accessory_title' => $accessory->getTitle,
@ -1811,7 +1811,7 @@ sub view {
$segment = $self->session->icon->delete('func=deleteRelatedConfirm&rid='.$id, $self->get('url'),$i18n->get(4))
. $self->session->icon->moveUp('func=moveRelatedUp&rid='.$id, $self->get('url'))
. $self->session->icon->moveDown('func=moveRelatedDown&rid='.$id, $self->get('url'));
my $related = WebGUI::Asset->newByDynamicClass($session, $collateral->{relatedAssetId});
my $related = WebGUI::Asset->newById($session, $collateral->{relatedAssetId});
push(@relatedloop,{
'relatedproduct_URL' => $related->getUrl,
'relatedproduct_title' => $related->getTitle,

View file

@ -393,7 +393,7 @@ sub getThingy {
"SELECT assetId FROM Thingy_things WHERE thingId=?",
[ $self->get('thingId') ],
);
return WebGUI::Asset->newByDynamicClass( $self->session, $thingyId );
return WebGUI::Asset->newById( $self->session, $thingyId );
}
#-------------------------------------------------------------------

View file

@ -424,7 +424,7 @@ sub processPropertiesFromFormPost {
my @attachments = $self->session->form->param("attachments");
my @tags = ();
foreach my $assetId (@attachments) {
my $asset = WebGUI::Asset->newByDynamicClass($self->session, $assetId);
my $asset = WebGUI::Asset->newById($self->session, $assetId);
if (defined $asset) {
unless ($asset->get("parentId") eq $self->getId) {
$asset->setParent($self);

View file

@ -711,7 +711,7 @@ sub getEvent {
# ? Perhaps use Stow to cache events ?
my $event = WebGUI::Asset->newByDynamicClass($self->session, $assetId);
my $event = WebGUI::Asset->newById($self->session, $assetId);
unless ( $event ) {
$self->session->errorHandler->warn("Event '$assetId' doesn't exist!");

View file

@ -338,7 +338,7 @@ sub view {
}
}
my $i = 1;
my $templateAsset = WebGUI::Asset->newByDynamicClass($self->session, $templateId) || WebGUI::Asset->getImportNode($self->session);
my $templateAsset = WebGUI::Asset->newById($self->session, $templateId) || WebGUI::Asset->getImportNode($self->session);
my $template = $templateAsset->get("template");
my $numPositions = 1;
foreach my $j (2..15) {

View file

@ -950,7 +950,7 @@ sub hasSpaceAvailable {
} );
for my $assetId ( @{ $fileIds } ) {
my $asset = WebGUI::Asset->newByDynamicClass( $self->session, $assetId );
my $asset = WebGUI::Asset->newById( $self->session, $assetId );
next unless $asset;
$spaceUsed += $asset->get( 'assetSize' );
@ -976,7 +976,7 @@ sub prepareView {
if ( $self->get("viewDefault") eq "album" && $self->get("viewAlbumAssetId") && $self->get("viewAlbumAssetId")
ne 'PBasset000000000000001') {
my $asset
= WebGUI::Asset->newByDynamicClass( $self->session, $self->get("viewAlbumAssetId") );
= WebGUI::Asset->newById( $self->session, $self->get("viewAlbumAssetId") );
if ($asset) {
$asset->prepareView;
$self->{_viewAsset} = $asset;
@ -1478,7 +1478,7 @@ sub www_search {
$p->appendTemplateVars( $var );
for my $result ( @{ $p->getPageData } ) {
my $asset = WebGUI::Asset->newByDynamicClass( $session, $result->{assetId} );
my $asset = WebGUI::Asset->newById( $session, $result->{assetId} );
push @{ $var->{search_results} }, {
%{ $asset->getTemplateVars },
isAlbum => $asset->isa( 'WebGUI::Asset::Wobject::GalleryAlbum' ),
@ -1514,7 +1514,7 @@ sub www_listFilesForUser {
# Get all the albums
my $albumIds = $self->getUserAlbumIds( $userId );
for my $albumId ( @$albumIds ) {
my $asset = WebGUI::Asset->newByDynamicClass( $session, $albumId );
my $asset = WebGUI::Asset->newById( $session, $albumId );
push @{ $var->{user_albums} }, $asset->getTemplateVars;
}
@ -1527,7 +1527,7 @@ sub www_listFilesForUser {
$p->appendTemplateVars( $var );
for my $fileId ( @{ $p->getPageData } ) {
my $asset = WebGUI::Asset->newByDynamicClass( $session, $fileId );
my $asset = WebGUI::Asset->newById( $session, $fileId );
push @{ $var->{user_files} }, $asset->getTemplateVars;
}
@ -1556,7 +1556,7 @@ sub www_listFilesForUserRss {
# Get all the albums
my $albumIds = $self->getUserAlbumIds( $userId );
for my $albumId ( @$albumIds ) {
my $asset = WebGUI::Asset->newByDynamicClass( $session, $albumId );
my $asset = WebGUI::Asset->newById( $session, $albumId );
my $assetVar = $asset->getTemplateVars;
for my $key ( qw( url ) ) {
@ -1569,7 +1569,7 @@ sub www_listFilesForUserRss {
# Get all the files
my $fileIds = $self->getUserFileIds( $userId );
for my $fileId ( @$fileIds ) {
my $asset = WebGUI::Asset->newByDynamicClass( $session, $fileId );
my $asset = WebGUI::Asset->newById( $session, $fileId );
my $assetVar = $asset->getTemplateVars;
for my $key ( qw( url ) ) {

View file

@ -198,7 +198,7 @@ sub appendTemplateVarsFileLoop {
my $session = $self->session;
for my $assetId (@$assetIds) {
my $asset = WebGUI::Asset->newByDynamicClass($session, $assetId);
my $asset = WebGUI::Asset->newById($session, $assetId);
# Set the parent
$asset->{_parent} = $self;
push @{$var->{file_loop}}, $asset->getTemplateVars;
@ -477,7 +477,7 @@ sub getNextAlbum {
return $self->{_nextAlbum} if $self->{_nextAlbum};
my $nextId = $self->getParent->getNextAlbumId( $self->getId );
return undef unless $nextId;
$self->{_nextAlbum } = WebGUI::Asset->newByDynamicClass( $self->session, $nextId );
$self->{_nextAlbum } = WebGUI::Asset->newById( $self->session, $nextId );
return $self->{_nextAlbum};
}
@ -495,7 +495,7 @@ sub getPreviousAlbum {
return $self->{_previousAlbum} if $self->{_previousAlbum};
my $previousId = $self->getParent->getPreviousAlbumId( $self->getId );
return undef unless $previousId;
$self->{_previousAlbum} = WebGUI::Asset->newByDynamicClass( $self->session, $previousId );
$self->{_previousAlbum} = WebGUI::Asset->newById( $self->session, $previousId );
return $self->{_previousAlbum};
}
@ -626,7 +626,7 @@ sub getThumbnailUrl {
# Try to get the asset
if ( $self->get("assetIdThumbnail") ) {
$asset = WebGUI::Asset->newByDynamicClass( $self->session, $self->get("assetIdThumbnail") );
$asset = WebGUI::Asset->newById( $self->session, $self->get("assetIdThumbnail") );
}
elsif ( $self->getFirstChild ) {
$asset = $self->getFirstChild;
@ -720,7 +720,7 @@ sub processFileSynopsis {
( my $assetId ) = $key =~ /^fileSynopsis_(.+)$/;
my $synopsis = $form->get( $key );
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
my $asset = WebGUI::Asset->newById( $session, $assetId );
if ( $asset->get("synopsis") ne $synopsis ) {
my $properties = $asset->get;
$properties->{ synopsis } = $synopsis;
@ -878,7 +878,7 @@ sub view_thumbnails {
# Add direct vars for the requested file
my $asset;
if ($fileId) {
$asset = WebGUI::Asset->newByDynamicClass( $session, $fileId );
$asset = WebGUI::Asset->newById( $session, $fileId );
}
# If no fileId given or fileId does not exist
if (!$asset) {
@ -1173,7 +1173,7 @@ sub www_edit {
elsif ( grep { $_ =~ /^promote-(.{22})$/ } $form->param ) {
my $assetId = ( grep { $_ =~ /^promote-(.{22})$/ } $form->param )[0];
$assetId =~ s/^promote-//;
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
my $asset = WebGUI::Asset->newById( $session, $assetId );
if ( $asset ) {
$asset->promote;
}
@ -1185,7 +1185,7 @@ sub www_edit {
elsif ( grep { $_ =~ /^demote-(.{22})$/ } $form->param ) {
my $assetId = ( grep { $_ =~ /^demote-(.{22})$/ } $form->param )[0];
$assetId =~ s/^demote-//;
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
my $asset = WebGUI::Asset->newById( $session, $assetId );
if ( $asset ) {
$asset->demote;
}
@ -1196,7 +1196,7 @@ sub www_edit {
elsif ( grep { $_ =~ /^delete-(.{22})$/ } $form->param ) {
my $assetId = ( grep { $_ =~ /^delete-(.{22})$/ } $form->param )[0];
$assetId =~ s/^delete-//;
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
my $asset = WebGUI::Asset->newById( $session, $assetId );
if ( $asset ) {
$asset->purge;
}

View file

@ -394,7 +394,7 @@ ENDHTML
ENDHTML
for my $pointId ( @{$pointIds} ) {
my $point = WebGUI::Asset->newByDynamicClass( $session, $pointId );
my $point = WebGUI::Asset->newById( $session, $pointId );
next unless $point;
$mapHtml .= sprintf ' points.push(%s);'."\n",
JSON->new->encode($point->getMapInfo),
@ -469,7 +469,7 @@ sub www_ajaxDeletePoint {
my $session = $self->session;
my $i18n = WebGUI::International->new( $session, 'Asset_Map' );
my $assetId = $session->form->get('assetId');
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
my $asset = WebGUI::Asset->newById( $session, $assetId );
$session->http->setMimeType('application/json');
return JSON->new->encode({error => $i18n->get('error delete unauthorized')})
unless $asset && $asset->canEdit;
@ -498,7 +498,7 @@ sub www_ajaxEditPoint {
} );
}
else {
$asset = WebGUI::Asset->newByDynamicClass( $session, $form->get('assetId') );
$asset = WebGUI::Asset->newById( $session, $form->get('assetId') );
}
my $output = $self->getEditPointTemplate->process( $asset->getTemplateVarsEditForm );
@ -537,7 +537,7 @@ sub www_ajaxEditPointSave {
} );
}
else {
$asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
$asset = WebGUI::Asset->newById( $session, $assetId );
return JSON->new->encode({message => $i18n->get("error edit unauthorized")})
unless $asset && $asset->canEdit;
$asset = $asset->addRevision;
@ -599,7 +599,7 @@ sub www_ajaxSetPointLocation {
$session->http->setMimeType("application/json");
my $assetId = $form->get('assetId');
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
my $asset = WebGUI::Asset->newById( $session, $assetId );
return JSON->new->encode({message => $i18n->get("error edit unauthorized")})
unless $asset && $asset->canEdit;
$asset->update( {

View file

@ -122,7 +122,7 @@ sub view {
$first = $child;
}
my %lastPostVars;
my $lastPost = WebGUI::Asset::Wobject::MessageBoard->newByDynamicClass($self->session, $child->get("lastPostId"));
my $lastPost = WebGUI::Asset::Wobject::MessageBoard->newById($self->session, $child->get("lastPostId"));
if (defined $lastPost) {
%lastPostVars = (
'forum.lastPost.url' => $lastPost->getUrl,

View file

@ -532,7 +532,7 @@ sub getProjectInstance {
return undef unless $projectId;
my ($assetId) = $db->quickArray("select assetId from PM_project where projectId=?",[$projectId]);
if($assetId) {
return WebGUI::Asset->newByDynamicClass($session,$assetId);
return WebGUI::Asset->newById($session,$assetId);
}
return undef;
}

View file

@ -187,7 +187,7 @@ sub view {
my %rules = (
keywords =>$keywords,
lineage =>[
WebGUI::Asset->newByDynamicClass($session,$self->getValue("searchRoot"))->get("lineage")
WebGUI::Asset->newById($session,$self->getValue("searchRoot"))->get("lineage")
],
);
my @classes = split("\n",$self->get("classLimiter"));

View file

@ -310,7 +310,7 @@ sub view {
my @productIds = List::MoreUtils::uniq(@childSkus, @{$keywordBasedAssetIds});
my @products = ();
PRODUCT: foreach my $id (@productIds) {
my $asset = WebGUI::Asset->newByDynamicClass($session, $id);
my $asset = WebGUI::Asset->newById($session, $id);
if (!defined $asset) {
$session->errorHandler->error(q|Couldn't instanciate SKU with assetId |.$id.q| on shelf with assetId |.$self->getId);
next PRODUCT;

View file

@ -264,7 +264,7 @@ sub exportAssetCollateral {
});
my $listOfStories = [];
STORYID: foreach my $storyId (@{ $storyIds }) {
my $story = WebGUI::Asset->newByDynamicClass($session, $storyId);
my $story = WebGUI::Asset->newById($session, $storyId);
next STORYID unless $story;
push @{ $listOfStories }, {
title => $story->getTitle,

View file

@ -103,7 +103,7 @@ sub getRssFeedItems {
});
my $storyData = [];
STORY: foreach my $storyId (@{ $storyIds }) {
my $story = WebGUI::Asset->newByDynamicClass($session, $storyId);
my $story = WebGUI::Asset->newById($session, $storyId);
next STORY unless $story;
push @{ $storyData }, $story->getRssData;
}

View file

@ -702,7 +702,7 @@ sub www_buildTimeTable {
#Build project list and task lists from project management app
my ($pmAssetId) = $db->quickArray("select a.assetId from PM_wobject a, asset b where a.assetId=b.assetId and b.state not like 'trash%'");
if($pmAssetId) {
$pmAsset = WebGUI::Asset->newByDynamicClass($session,$pmAssetId);
$pmAsset = WebGUI::Asset->newById($session,$pmAssetId);
my %pmProjectList = %{$pmAsset->getProjectList($user->userId)};
%projectList = WebGUI::Utility::sortHash((%projectList,%pmProjectList));
}

View file

@ -471,7 +471,7 @@ sub getRssFeedItems {
$self->appendRecentChanges( $vars, $self->get('itemsPerFeed') );
my $var = [];
foreach my $item ( @{ $vars->{recentChanges} } ) {
my $asset = WebGUI::Asset->newByDynamicClass( $self->session, $item->{assetId} );
my $asset = WebGUI::Asset->newById( $self->session, $item->{assetId} );
push @{ $var }, {
'link' => $asset->getUrl,
'guid' => $item->{ 'assetId' } . $asset->get( 'revisionDate' ),
@ -597,7 +597,7 @@ sub view {
# Get a random featured page
my $featuredIds = $self->getFeaturedPageIds;
my $featuredId = $featuredIds->[ int( rand @$featuredIds ) - 1 ];
my $featured = WebGUI::Asset->newByDynamicClass( $session, $featuredId );
my $featured = WebGUI::Asset->newById( $session, $featuredId );
if ( $featured ) {
$self->appendFeaturedPageVars( $var, $featured );
}
@ -628,7 +628,7 @@ sub www_byKeyword {
});
$p->setBaseUrl($self->getUrl("func=byKeyword;keyword=".$keyword));
foreach my $assetData (@{$p->getPageData}) {
my $asset = WebGUI::Asset->newByDynamicClass($self->session, $assetData->{assetId});
my $asset = WebGUI::Asset->newById($self->session, $assetData->{assetId});
next unless defined $asset;
push(@pages, {
title => $asset->getTitle,

View file

@ -120,7 +120,7 @@ sub uninstall {
### Remove all assets contained in the table
my $sth = $session->db->read("SELECT assetId FROM `$installDef->{tableName}`");
while ( my ($assetId) = $sth->array ) {
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
my $asset = WebGUI::Asset->newById( $session, $assetId );
$asset->purge;
}

View file

@ -238,7 +238,7 @@ sub exportAssetCollateral {
);
# open another session as the user doing the exporting...
my $selfdupe = WebGUI::Asset->newByDynamicClass( $exportSession, $self->getId );
my $selfdupe = WebGUI::Asset->newById( $exportSession, $self->getId );
# next, get the contents, open the file, and write the contents to the file.
my $fh = eval { $dest->open('>:utf8') };

View file

@ -196,7 +196,7 @@ sub paste {
my $assetId = shift;
my $outputSub = shift;
my $session = $self->session;
my $pastedAsset = WebGUI::Asset->newByDynamicClass($session,$assetId);
my $pastedAsset = WebGUI::Asset->newById($session,$assetId);
return 0 unless ($self->get("state") eq "published");
return 0 unless ($pastedAsset->canPaste()); ##Allow pasted assets to have a say about pasting.
@ -279,7 +279,7 @@ sub www_copyList {
my $session = $self->session;
return $self->session->privilege->insufficient() unless $self->canEdit && $session->form->validToken;
foreach my $assetId ($session->form->param("assetId")) {
my $asset = WebGUI::Asset->newByDynamicClass($session,$assetId);
my $asset = WebGUI::Asset->newById($session,$assetId);
if ($asset->canEdit) {
my $newAsset = $asset->duplicate({skipAutoCommitWorkflows => 1});
$newAsset->update({ title=>$newAsset->getTitle.' (copy)'});
@ -386,7 +386,7 @@ sub www_cutList {
my $session = $self->session;
return $session->privilege->insufficient() unless $self->canEdit && $session->form->validToken;
foreach my $assetId ($session->form->param("assetId")) {
my $asset = WebGUI::Asset->newByDynamicClass($session,$assetId);
my $asset = WebGUI::Asset->newById($session,$assetId);
if ($asset->canEdit && !$asset->get('isSystem')) {
$asset->cut;
}
@ -419,7 +419,7 @@ sub www_duplicateList {
my $session = $self->session;
return $session->privilege->insufficient() unless $self->canEdit && $session->form->validToken;
foreach my $assetId ($session->form->param("assetId")) {
my $asset = WebGUI::Asset->newByDynamicClass($session,$assetId);
my $asset = WebGUI::Asset->newById($session,$assetId);
if ($asset->canEdit) {
my $newAsset = $asset->duplicate;
$newAsset->update({ title=>$newAsset->getTitle.' (copy)'});

View file

@ -312,7 +312,7 @@ sub newFromHash {
my $session = $asset;
my $assetId = shift;
my $properties = shift;
$asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
$asset = WebGUI::Asset->newById( $session, $assetId );
$self = $class->new( $asset );
$self->setFromHash( $properties );
}

View file

@ -153,7 +153,7 @@ sub cascadeLineage {
else {
my $descendants = $self->session->db->read("SELECT assetId FROM asset WHERE lineage LIKE ?", [$newLineage . '%']);
while (my ($assetId, $lineage) = $descendants->array) {
my $asset = WebGUI::Asset->newByDynamicClass($self->session, $assetId);
my $asset = WebGUI::Asset->newById($self->session, $assetId);
if (defined $asset) {
$asset->purgeCache;
}
@ -725,7 +725,7 @@ sub getParent {
return $self if ($self->getId eq "PBasset000000000000001");
unless ( $self->{_parent} ) {
$self->{_parent} = WebGUI::Asset->newByDynamicClass($self->session,$self->get("parentId"));
$self->{_parent} = WebGUI::Asset->newById($self->session,$self->get("parentId"));
}
return $self->{_parent};
@ -1025,7 +1025,7 @@ Returns a www_manageAssets() method. Sets a new parent via the results of a form
sub www_setParent {
my $self = shift;
return $self->session->privilege->insufficient() unless $self->canEdit;
my $newParent = WebGUI::Asset->newByDynamicClass($self->session->form->process("assetId"));
my $newParent = WebGUI::Asset->newById($self->session->form->process("assetId"));
if (defined $newParent) {
my $success = $self->setParent($newParent);
return $self->session->privilege->insufficient() unless $success;
@ -1076,7 +1076,7 @@ sub www_setRanks {
$pb->start($i18n->get('Set Rank'), $session->url->extras('adminConsole/assets.gif'));
my @assetIds = $form->get( 'assetId' );
ASSET: for my $assetId ( @assetIds ) {
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
my $asset = WebGUI::Asset->newById( $session, $assetId );
next ASSET unless $asset;
my $rank = $form->get( $assetId . '_rank' );
next ASSET unless $rank; # There's no such thing as zero

View file

@ -92,7 +92,7 @@ sub getPackageList {
my @packageIds = $db->buildArray("select distinct assetId from assetData where isPackage=1");
my @assets;
ID: foreach my $id (@packageIds) {
my $asset = WebGUI::Asset->newByDynamicClass($session, $id);
my $asset = WebGUI::Asset->newById($session, $id);
next ID unless defined $asset;
next ID unless $asset->get('isPackage');
next ID unless ($asset->get('status') eq 'approved' || $asset->get('tagId') eq $session->scratch->get("versionTag"));
@ -283,7 +283,7 @@ sub www_deployPackage {
return $self->session->privilege->insufficient() unless ($self->canEdit && $self->session->user->isInGroup(4));
my $packageMasterAssetId = $self->session->form->param("assetId");
if (defined $packageMasterAssetId) {
my $packageMasterAsset = WebGUI::Asset->newByDynamicClass($self->session, $packageMasterAssetId);
my $packageMasterAsset = WebGUI::Asset->newById($self->session, $packageMasterAssetId);
unless ($packageMasterAsset->get('isPackage')) { #only deploy packages
$self->session->errorHandler->security('deploy an asset as a package which was not set as a package.');
return undef;

View file

@ -278,7 +278,7 @@ sub www_ajaxGetManagerPage {
my $p = getManagerPaginator( $session );
for my $assetId ( @{ $p->getPageData } ) {
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
my $asset = WebGUI::Asset->newById( $session, $assetId );
# Populate the required fields to fill in
my %fields = (
@ -550,14 +550,14 @@ sub www_search {
if ( $action eq "delete" ) { ##aka trash
for my $assetId ( @assetIds ) {
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
my $asset = WebGUI::Asset->newById( $session, $assetId );
next unless $asset;
$asset->trash;
}
}
elsif ( $action eq "cut" ) {
for my $assetId ( @assetIds ) {
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
my $asset = WebGUI::Asset->newById( $session, $assetId );
next unless $asset;
$asset->cut;
}
@ -565,7 +565,7 @@ sub www_search {
elsif ( $action eq "copy" ) {
for my $assetId ( @assetIds ) {
# Copy == Duplicate + Cut
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId);
my $asset = WebGUI::Asset->newById( $session, $assetId);
my $newAsset = $asset->duplicate( { skipAutoCommitWorkflows => 1 } );
$newAsset->update( { title => $newAsset->getTitle . ' (copy)' } );
$newAsset->cut;
@ -655,7 +655,7 @@ sub www_search {
my $count = 0;
for my $assetInfo ( @{ $p->getPageData } ) {
$count++;
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetInfo->{ assetId } );
my $asset = WebGUI::Asset->newById( $session, $assetInfo->{ assetId } );
# Populate the required fields to fill in
my %fields = (

View file

@ -118,8 +118,8 @@ Formats as a link.
sub getValueAsHtml {
my $self = shift;
# my $asset = WebGUI::Asset->newByDynamicClass($self->session,$self->getDefaultValue);
my $asset = WebGUI::Asset->newByDynamicClass($self->session,$self->getOriginalValue);
# my $asset = WebGUI::Asset->newById($self->session,$self->getDefaultValue);
my $asset = WebGUI::Asset->newById($self->session,$self->getOriginalValue);
if (defined $asset) {
return '<a href="'.$asset->getUrl.'">'.$asset->getTitle.'</a>';
}
@ -149,7 +149,7 @@ Renders an asset selector.
sub toHtml {
my $self = shift;
my $asset = WebGUI::Asset->newByDynamicClass($self->session, $self->getOriginalValue) || WebGUI::Asset->getRoot($self->session);
my $asset = WebGUI::Asset->newById($self->session, $self->getOriginalValue) || WebGUI::Asset->getRoot($self->session);
my $url = $asset->getUrl("op=formHelper;sub=assetTree;class=Asset;formId=".$self->get('id'));
$url .= ";classLimiter=".$self->get("class") if ($self->get("class"));
return WebGUI::Form::Hidden->new($self->session,

View file

@ -174,7 +174,7 @@ sub www_delete {
my $assetId = $session->form->param("assetId");
my @assetIds = $session->form->param("attachments");
if ($assetId ne "") {
my $asset = WebGUI::Asset->newByDynamicClass($session, $assetId);
my $asset = WebGUI::Asset->newById($session, $assetId);
if (defined $asset) {
if ($asset->canEdit) {
my $version = WebGUI::VersionTag->new($session, $asset->get("tagId"));
@ -246,7 +246,7 @@ sub www_show {
my $attachments = '';
my $attachmentsList = "attachments=".join(";attachments=", @assetIds) if (scalar(@assetIds));
foreach my $assetId (@assetIds) {
my $asset = WebGUI::Asset->newByDynamicClass($session, $assetId);
my $asset = WebGUI::Asset->newById($session, $assetId);
if (defined $asset) {
$attachments .= '<div class="attachment"><a href="'
.$url->page("op=formHelper;class=Attachments;sub=delete;maxAttachments=".$form->param("maxAttachments")

View file

@ -45,7 +45,7 @@ sub process {
my $t = ($session->errorHandler->canShowPerformanceIndicators()) ? [Time::HiRes::gettimeofday()] : undef;
my $asset;
if ($type eq 'assetId') {
$asset = WebGUI::Asset->newByDynamicClass($session, $identifier);
$asset = WebGUI::Asset->newById($session, $identifier);
}
else {
$asset = WebGUI::Asset->newByUrl($session,$identifier);

View file

@ -42,7 +42,7 @@ sub process {
my $children = $asset->getLineage(["children"]);
#randomize;
my $randomAssetId = $children->[int(rand(scalar(@{$children})))];
my $randomAsset = WebGUI::Asset->newByDynamicClass($session,$randomAssetId);
my $randomAsset = WebGUI::Asset->newById($session,$randomAssetId);
if (defined $randomAsset) {
if ($randomAsset->canView) {
$randomAsset->toggleToolbar;

View file

@ -174,7 +174,7 @@ Returns an instanciated WebGUI::Asset::Sku object for this cart item.
sub getSku {
my ($self) = @_;
my $asset = '';
$asset = WebGUI::Asset->newByDynamicClass($self->cart->session, $self->get("assetId"));
$asset = WebGUI::Asset->newById($self->cart->session, $self->get("assetId"));
$asset->applyOptions($self->get("options")) if $asset;
return $asset;
}

View file

@ -132,7 +132,7 @@ Returns an instanciated WebGUI::Asset::Sku object for this item.
sub getSku {
my ($self) = @_;
my $asset = WebGUI::Asset->newByDynamicClass($self->transaction->session, $self->get("assetId"));
my $asset = WebGUI::Asset->newById($self->transaction->session, $self->get("assetId"));
if (defined $asset) {
$asset->applyOptions($self->get("options"));
return $asset;

View file

@ -394,7 +394,7 @@ sub execute {
# If this event already exists, update
if ($assetId) {
$session->log->info( "Updating existing asset $assetId" );
my $event = WebGUI::Asset->newByDynamicClass($session,$assetId);
my $event = WebGUI::Asset->newById($session,$assetId);
if ($event) {
$event->update($properties);
@ -403,7 +403,7 @@ sub execute {
}
else {
$session->log->info( "Creating new Event!" );
my $calendar = WebGUI::Asset->newByDynamicClass($session,$feed->{assetId});
my $calendar = WebGUI::Asset->newById($session,$feed->{assetId});
my $event = $calendar->addChild($properties, undef, undef, { skipAutoCommitWorkflows => 1});
$feed->{added}++;
if ($recur) {
@ -425,7 +425,7 @@ sub execute {
}
for my $feedId (keys %$feedList) {
my $feed = $feedList->{$feedId};
my $calendar = WebGUI::Asset->newByDynamicClass($session, $feed->{assetId});
my $calendar = WebGUI::Asset->newById($session, $feed->{assetId});
my $feedData = $calendar->getFeed($feedId);
$feedData->{lastResult} = "Success! $feed->{added} added, $feed->{updated} updated, $feed->{errored} parsing errors";
$feedData->{lastUpdated} = $dt;

View file

@ -142,7 +142,7 @@ END_SQL
deleted => $self->get("deleteExpired"),
companyName => $self->session->setting->get("companyName"),
};
my $template = WebGUI::Asset->newByDynamicClass($self->session,$self->get('emailTemplateId'));
my $template = WebGUI::Asset->newById($self->session,$self->get('emailTemplateId'));
my $message = $template->processTemplate($var, $self->get("emailTemplateId"));
WebGUI::Macro::process($self->session,\$message);
my $mail = WebGUI::Mail::Send->create($self->session,{

View file

@ -132,7 +132,7 @@ sub execute {
my $asset;
if ( !$asset{$record->get('assetId')} ) {
$asset = $asset{$record->get('assetId')}
= WebGUI::Asset->newByDynamicClass( $self->session, $record->get('assetId') );
= WebGUI::Asset->newById( $self->session, $record->get('assetId') );
}
else {
$asset = $asset{$record->get('assetId')};

View file

@ -204,7 +204,7 @@ sub execute {
my $post = undef;
if ($message->{inReplyTo} && $message->{inReplyTo} =~ m/cs\-([\w_-]{22})\@/) {
my $id = $1;
my $repliedPost = WebGUI::Asset->newByDynamicClass($self->session, $id);
my $repliedPost = WebGUI::Asset->newById($self->session, $id);
if ($repliedPost
&& $repliedPost->isa('WebGUI::Asset::Post')
&& $repliedPost->getThread->getParent->getId eq $cs->getId) {

View file

@ -83,7 +83,7 @@ sub execute {
my $self = shift;
my $tag = shift;
my $instance = shift;
my $ancestor = WebGUI::Asset->newByDynamicClass( $self->session, $self->get( 'assetId' ) );
my $ancestor = WebGUI::Asset->newById( $self->session, $self->get( 'assetId' ) );
my $lineage = $ancestor->get( 'lineage' );
# Descendant has at least the ancestors lineage plus 6 more character
my $isDescendant = qr{^$lineage.{6}};