couple of last minute bug fixes

This commit is contained in:
JT Smith 2005-03-19 22:47:29 +00:00
parent dac3c8f402
commit d0181c10ba
4 changed files with 26 additions and 24 deletions

View file

@ -1428,7 +1428,7 @@ sub getNextChildRank {
#-------------------------------------------------------------------
=head getPackageList ( )
=head2 getPackageList ( )
Returns an array of hashes containing title, assetId, and className for all assets defined as packages.
@ -1716,7 +1716,7 @@ sub new {
Returns a new Asset object based upon the className. Returns a "notFoundPage" Asset if className is not specified and can't be looked up.
=assetId
=head3 assetId
Must be a valid assetId

View file

@ -188,6 +188,7 @@ Returns a thread object for the next (newer) thread in the same forum.
sub getNextThread {
my $self = shift;
unless (exists $self->{_next}) {
my $sortBy = $self->getParent->getValue("sortBy");
$self->{_next} = WebGUI::Asset::Post->newByPropertyHashRef(
WebGUI::SQL->quickHashRef("
select *
@ -197,12 +198,12 @@ sub getNextThread {
where asset.parentId=".quote($self->get("parentId"))."
and asset.state='published'
and asset.className='WebGUI::Asset::Post::Thread'
and ".$self->getParent->getValue("sortBy").">".quote($self->get($self->getParent->getValue("sortBy")))."
and ".$sortBy.">".quote($self->get($sortBy))."
and (
Post.status in ('approved','archived')
or (asset.ownerUserId=".quote($session{user}{userId})." and asset.ownerUserId<>'1')
)
order by ".$self->getParent->getValue("sortBy")." asc
order by ".$sortBy." asc
",WebGUI::SQL->getSlave)
);
delete $self->{_next} unless ($self->{_next}->{_properties}{className} =~ /Thread/);
@ -223,6 +224,7 @@ Returns a thread object for the previous (older) thread in the same forum.
sub getPreviousThread {
my $self = shift;
unless (exists $self->{_previous}) {
my $sortBy = $self->getParent->getValue("sortBy");
$self->{_previous} = WebGUI::Asset::Post->newByPropertyHashRef(
WebGUI::SQL->quickHashRef(" select *
from Thread
@ -231,12 +233,12 @@ sub getPreviousThread {
where asset.parentId=".quote($self->get("parentId"))."
and asset.state='published'
and asset.className='WebGUI::Asset::Post::Thread'
and ".$self->getParent->getValue("sortBy")."<".quote($self->get($self->getParent->getValue("sortBy")))."
and ".$sortBy."<".quote($self->get($sortBy))."
and (
Post.status in ('approved','archived')
or (asset.ownerUserId=".quote($session{user}{userId})." and asset.ownerUserId<>'1')
)
order by ".$self->getParent->getValue("sortBy")." desc ",WebGUI::SQL->getSlave)
order by ".$sortBy." desc ",WebGUI::SQL->getSlave)
);
delete $self->{_previous} unless ($self->{_previous}->{_properties}{className} =~ /Thread/);
};

View file

@ -811,19 +811,21 @@ sub unsubscribe {
sub view {
my $self = shift;
my $scratchSortBy = $self->getId."_sortBy";
my $scratchSortDir = $self->getId."_sortDir";
if($session{scratch}{$scratchSortBy} ne $session{form}{sortBy}){
WebGUI::Session::setScratch($scratchSortBy,$session{form}{sortBy});
WebGUI::Session::setScratch($scratchSortDir, "desc");
}else{
my $sortDir;
if($session{scratch}{$scratchSortDir} eq "asc"){
$sortDir = "desc";
}else{
$sortDir = "asc";
my $scratchSortOrder = $self->getId."_sortDir";
my $sortBy = $session{form}{sortBy} || $session{scratch}{$scratchSortBy} || $self->get("sortBy");
my $sortOrder = $session{scratch}{$scratchSortOrder} || $self->get("sortOrder");
if ($sortBy ne $session{scratch}{$scratchSortBy}) {
WebGUI::Session::setScratch($scratchSortBy,$session{form}{sortBy});
} elsif ($session{form}{sortBy}) {
if ($sortOrder eq "asc") {
$sortOrder = "desc";
} else {
$sortOrder = "asc";
}
WebGUI::Session::setScratch($scratchSortDir, $sortDir);
}
WebGUI::Session::setScratch($scratchSortOrder, $sortOrder);
}
$sortBy ||= "dateUpdated";
$sortOrder ||= "desc";
my %var;
$var{'user.canPost'} = $self->canPost;
$var{"add.url"} = $self->getNewThreadUrl;
@ -834,7 +836,7 @@ sub view {
$var{'sortby.title.url'} = $self->getSortByUrl("title");
$var{'sortby.username.url'} = $self->getSortByUrl("username");
$var{'sortby.date.url'} = $self->getSortByUrl("dateSubmitted");
$var{'sortby.lastreply.url'} = $self->getSortByUrl("lastreply");
$var{'sortby.lastreply.url'} = $self->getSortByUrl("dateUpdated");
$var{'sortby.views.url'} = $self->getSortByUrl("views");
$var{'sortby.replies.url'} = $self->getSortByUrl("replies");
$var{'sortby.rating.url'} = $self->getSortByUrl("rating");
@ -847,16 +849,12 @@ sub view {
$constraints .= " or Post.status='pending'";
}
$constraints .= ")";
my $sortBy = $self->getValue("sortBy");
if ($sortBy eq "lastreply") {
$sortBy = "Thread.lastPostDate";
}
my $sql = "select *
from Thread
left join asset on Thread.assetId=asset.assetId
left join Post on Post.assetId=asset.assetId
where asset.parentId=".quote($self->getId)." and asset.state='published' and asset.className='WebGUI::Asset::Post::Thread' and $constraints
order by ".$sortBy." ".$self->getValue("sortOrder");
order by ".$sortBy." ".$sortOrder;
my $p = WebGUI::Paginator->new($self->getUrl,$self->get("threadsPerPage"));
$self->appendPostListTemplateVars(\%var, $sql, $p);
$self->appendTemplateLabels(\%var);