gracefully handle Collaborations having no lastPostId in the MessageBoard asset

This commit is contained in:
Scott Walters 2012-10-27 02:00:57 -04:00
parent 9a45ff4b91
commit fab70d71c7
2 changed files with 18 additions and 15 deletions

View file

@ -15,6 +15,7 @@
- fixed #12384: Click and drag reordering does not work in IE9
- fixed: MessageBoard tolerates Collaboration children not yet having a value for lastPostId
- on invalid proceed method in call to editSave, warn and recover rather than run time error
- gracefully handle Collaborations having no lastPostId in the MessageBoard asset
7.10.26
- fixed: Template diagnostics when called without a session asset.

View file

@ -129,21 +129,23 @@ sub view {
$first = $child;
}
my %lastPostVars;
my $lastPost = WebGUI::Asset::Wobject::MessageBoard->newByDynamicClass($self->session, $child->get("lastPostId"));
if (defined $lastPost) {
%lastPostVars = (
'forum.lastPost.url' => $lastPost->getUrl,
'forum.lastPost.date' => $self->session->datetime->epochToHuman($lastPost->get("creationDate"),"%z"),
'forum.lastPost.time' => $self->session->datetime->epochToHuman($lastPost->get("creationDate"),"%Z"),
'forum.lastPost.epoch' => $lastPost->get("creationDate"),
'forum.lastPost.subject' => $lastPost->get("title"),
'forum.lastPost.user.hasRead' => $lastPost->getThread->isMarkedRead,
'forum.lastPost.user.id' => $lastPost->get("ownerUserId"),
'forum.lastPost.user.name' => $lastPost->get("username"),
'forum.lastPost.user.alias' => $lastPost->get("username"),
'forum.lastPost.user.profile' => $lastPost->getPosterProfileUrl,
'forum.lastPost.user.isVisitor' => ($lastPost->get("ownerUserId") eq '1')
);
if( $child->get('lastPostId') ) {
my $lastPost = WebGUI::Asset::Wobject::MessageBoard->newByDynamicClass($self->session, $child->get("lastPostId"));
if (defined $lastPost) {
%lastPostVars = (
'forum.lastPost.url' => $lastPost->getUrl,
'forum.lastPost.date' => $self->session->datetime->epochToHuman($lastPost->get("creationDate"),"%z"),
'forum.lastPost.time' => $self->session->datetime->epochToHuman($lastPost->get("creationDate"),"%Z"),
'forum.lastPost.epoch' => $lastPost->get("creationDate"),
'forum.lastPost.subject' => $lastPost->get("title"),
'forum.lastPost.user.hasRead' => $lastPost->getThread->isMarkedRead,
'forum.lastPost.user.id' => $lastPost->get("ownerUserId"),
'forum.lastPost.user.name' => $lastPost->get("username"),
'forum.lastPost.user.alias' => $lastPost->get("username"),
'forum.lastPost.user.profile' => $lastPost->getPosterProfileUrl,
'forum.lastPost.user.isVisitor' => ($lastPost->get("ownerUserId") eq '1')
);
}
}
push(@forum_loop, {