more bug fixes
This commit is contained in:
parent
abf4076569
commit
a3e4cf1dd3
4 changed files with 46 additions and 27 deletions
|
|
@ -302,6 +302,14 @@ sub addAssetVersioning {
|
||||||
}
|
}
|
||||||
$sth->finish;
|
$sth->finish;
|
||||||
WebGUI::SQL->write("alter table FileAsset drop column olderVersions");
|
WebGUI::SQL->write("alter table FileAsset drop column olderVersions");
|
||||||
|
my $writeStatus = WebGUI::SQL->prepare("update assetData set status=? where assetId=? and revisionDate=?");
|
||||||
|
my $sth = WebGUI::SQL->read("select status,assetId,revisionDate from Post");
|
||||||
|
while (my ($status,$id,$version) = $sth->array) {
|
||||||
|
$writeStatus->execute([$status,$id,$version]);
|
||||||
|
}
|
||||||
|
$sth->finish;
|
||||||
|
$writeStatus->finish;
|
||||||
|
WebGUI::SQL->write('alter table Post drop column status');
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -139,11 +139,6 @@ sub definition {
|
||||||
fieldType=>"hidden",
|
fieldType=>"hidden",
|
||||||
defaultValue=>$session{form}{visitorUsername} || $session{user}{alias} || $session{user}{username}
|
defaultValue=>$session{form}{visitorUsername} || $session{user}{alias} || $session{user}{username}
|
||||||
},
|
},
|
||||||
status => {
|
|
||||||
noFormPost=>1,
|
|
||||||
fieldType=>"hidden",
|
|
||||||
defaultValue=>undef
|
|
||||||
},
|
|
||||||
rating => {
|
rating => {
|
||||||
noFormPost=>1,
|
noFormPost=>1,
|
||||||
fieldType=>"hidden",
|
fieldType=>"hidden",
|
||||||
|
|
|
||||||
|
|
@ -184,15 +184,18 @@ sub getNextThread {
|
||||||
select *
|
select *
|
||||||
from Thread
|
from Thread
|
||||||
left join asset on asset.assetId=Thread.assetId
|
left join asset on asset.assetId=Thread.assetId
|
||||||
left join Post on Post.assetId=asset.assetId
|
left join assetData on assetData.assetId=Thread.assetId and assetData.revisionDate=Thread.revisionDate
|
||||||
|
left join Post on Post.assetId=assetData.assetId and assetData.revisionDate=Post.revisionDate
|
||||||
where asset.parentId=".quote($self->get("parentId"))."
|
where asset.parentId=".quote($self->get("parentId"))."
|
||||||
and asset.state='published'
|
and asset.state='published'
|
||||||
and asset.className='WebGUI::Asset::Post::Thread'
|
and asset.className='WebGUI::Asset::Post::Thread'
|
||||||
and ".$sortBy.">".quote($self->get($sortBy))."
|
and ".$sortBy.">".quote($self->get($sortBy))."
|
||||||
and (
|
and (
|
||||||
Post.status in ('approved','archived')
|
assetData.status in ('approved','archived')
|
||||||
or (asset.ownerUserId=".quote($session{user}{userId})." and asset.ownerUserId<>'1')
|
or assetData.tagId=".quote($session{scratch}{versionTag})."
|
||||||
|
or (assetData.ownerUserId=".quote($session{user}{userId})." and assetData.ownerUserId<>'1')
|
||||||
)
|
)
|
||||||
|
group by assetData.assetId
|
||||||
order by ".$sortBy." asc
|
order by ".$sortBy." asc
|
||||||
",WebGUI::SQL->getSlave)
|
",WebGUI::SQL->getSlave)
|
||||||
);
|
);
|
||||||
|
|
@ -219,15 +222,18 @@ sub getPreviousThread {
|
||||||
WebGUI::SQL->quickHashRef(" select *
|
WebGUI::SQL->quickHashRef(" select *
|
||||||
from Thread
|
from Thread
|
||||||
left join asset on asset.assetId=Thread.assetId
|
left join asset on asset.assetId=Thread.assetId
|
||||||
left join Post on Post.assetId=asset.assetId
|
left join assetData on assetData.assetId=Thread.assetId and assetData.revisionDate=Thread.revisionDate
|
||||||
|
left join Post on Post.assetId=assetData.assetId and assetData.revisionDate=Post.revisionDate
|
||||||
where asset.parentId=".quote($self->get("parentId"))."
|
where asset.parentId=".quote($self->get("parentId"))."
|
||||||
and asset.state='published'
|
and asset.state='published'
|
||||||
and asset.className='WebGUI::Asset::Post::Thread'
|
and asset.className='WebGUI::Asset::Post::Thread'
|
||||||
and ".$sortBy."<".quote($self->get($sortBy))."
|
and ".$sortBy."<".quote($self->get($sortBy))."
|
||||||
and (
|
and (
|
||||||
Post.status in ('approved','archived')
|
assetData.status in ('approved','archived')
|
||||||
or (asset.ownerUserId=".quote($session{user}{userId})." and asset.ownerUserId<>'1')
|
or assetData.tagId=".quote($session{scratch}{versionTag})."
|
||||||
|
or (assetData.ownerUserId=".quote($session{user}{userId})." and assetData.ownerUserId<>'1')
|
||||||
)
|
)
|
||||||
|
group by assetData.assetId
|
||||||
order by ".$sortBy." desc ",WebGUI::SQL->getSlave)
|
order by ".$sortBy." desc ",WebGUI::SQL->getSlave)
|
||||||
);
|
);
|
||||||
delete $self->{_previous} unless ($self->{_previous}->{_properties}{className} =~ /Thread/);
|
delete $self->{_previous} unless ($self->{_previous}->{_properties}{className} =~ /Thread/);
|
||||||
|
|
@ -621,15 +627,18 @@ sub view {
|
||||||
|
|
||||||
my $p = WebGUI::Paginator->new($self->getUrl,$self->getParent->get("postsPerPage"));
|
my $p = WebGUI::Paginator->new($self->getUrl,$self->getParent->get("postsPerPage"));
|
||||||
my $sql = "select * from asset
|
my $sql = "select * from asset
|
||||||
left join Thread on Thread.assetId=asset.assetId
|
left join assetData on assetData.assetId=asset.assetId
|
||||||
left join Post on Post.assetId=asset.assetId
|
left join Thread on Thread.assetId=assetData.assetId and assetData.revisionDate=Thread.revisionDate
|
||||||
|
left join Post on Post.assetId=assetData.assetId and assetData.revisionDate=Post.revisionDate
|
||||||
where asset.lineage like ".quote($self->get("lineage").'%')
|
where asset.lineage like ".quote($self->get("lineage").'%')
|
||||||
." and asset.state='published'
|
." and asset.state='published'
|
||||||
and (
|
and (
|
||||||
Post.status in ('approved','archived')";
|
assetData.status in ('approved','archived')
|
||||||
$sql .= " or Post.status='pending'" if ($self->getParent->canModerate);
|
or assetData.tagId=".quote($session{scratch}{versionTag});
|
||||||
$sql .= " or (asset.ownerUserId=".quote($session{user}{userId})." and asset.ownerUserId<>'1')
|
$sql .= " or assetData.status='pending'" if ($self->getParent->canModerate);
|
||||||
|
$sql .= " or (assetData.ownerUserId=".quote($session{user}{userId})." and assetData.ownerUserId<>'1')
|
||||||
)
|
)
|
||||||
|
group by assetData.assetId
|
||||||
order by ";
|
order by ";
|
||||||
if ($layout eq "flat") {
|
if ($layout eq "flat") {
|
||||||
$sql .= "Post.dateSubmitted";
|
$sql .= "Post.dateSubmitted";
|
||||||
|
|
|
||||||
|
|
@ -898,17 +898,18 @@ sub view {
|
||||||
$var{"search.url"} = $self->getSearchUrl;
|
$var{"search.url"} = $self->getSearchUrl;
|
||||||
$var{"subscribe.url"} = $self->getSubscribeUrl;
|
$var{"subscribe.url"} = $self->getSubscribeUrl;
|
||||||
$var{"unsubscribe.url"} = $self->getUnsubscribeUrl;
|
$var{"unsubscribe.url"} = $self->getUnsubscribeUrl;
|
||||||
my $constraints = "(Post.status='approved' or (asset.ownerUserId=".quote($session{user}{userId})." and asset.ownerUserId<>'1')";
|
my $constraints = "(assetData.status='approved' or (assetData.ownerUserId=".quote($session{user}{userId})." and assetData.ownerUserId<>'1') or assetData.tagId=".quote($session{scratch}{versionTag});
|
||||||
if ($var{canModerate}) {
|
if ($var{canModerate}) {
|
||||||
$constraints .= " or Post.status='pending'";
|
$constraints .= " or assetData.status='pending'";
|
||||||
}
|
}
|
||||||
$constraints .= ")";
|
$constraints .= ")";
|
||||||
my $sql = "select *
|
my $sql = "select *
|
||||||
from Thread
|
from Thread
|
||||||
left join asset on Thread.assetId=asset.assetId
|
left join asset on Thread.assetId=asset.assetId
|
||||||
left join Post on Post.assetId=asset.assetId
|
left join Post on Post.assetId=Thread.assetId and Thread.revisionDate = Post.revisionDate
|
||||||
|
left join assetData on assetData.assetId=Thread.assetId and Thread.revisionDate = assetData.revisionDate
|
||||||
where asset.parentId=".quote($self->getId)." and asset.state='published' and asset.className='WebGUI::Asset::Post::Thread' and $constraints
|
where asset.parentId=".quote($self->getId)." and asset.state='published' and asset.className='WebGUI::Asset::Post::Thread' and $constraints
|
||||||
order by Thread.isSticky desc, ".$sortBy." ".$sortOrder;
|
group by assetData.assetId order by Thread.isSticky desc, ".$sortBy." ".$sortOrder;
|
||||||
my $p = WebGUI::Paginator->new($self->getUrl,$self->get("threadsPerPage"));
|
my $p = WebGUI::Paginator->new($self->getUrl,$self->get("threadsPerPage"));
|
||||||
$self->appendPostListTemplateVars(\%var, $sql, $p);
|
$self->appendPostListTemplateVars(\%var, $sql, $p);
|
||||||
$self->appendTemplateLabels(\%var);
|
$self->appendTemplateLabels(\%var);
|
||||||
|
|
@ -1031,14 +1032,16 @@ sub www_search {
|
||||||
# this is for trained professionals only and should not be attempted at home
|
# this is for trained professionals only and should not be attempted at home
|
||||||
my $sql = "select *
|
my $sql = "select *
|
||||||
from asset
|
from asset
|
||||||
left join Thread on Thread.assetId=asset.assetId
|
left join assetData on assetData.assetId=asset.assetId
|
||||||
left join Post on Post.assetId=asset.assetId
|
left join Thread on Thread.assetId=assetData.assetId and assetData.revisionDate = Thread.revisionDate
|
||||||
|
left join Post on Post.assetId=assetData.assetId and assetData.revisionDate = Post.revisionDate
|
||||||
where (asset.className='WebGUI::Asset::Post' or asset.className='WebGUI::Asset::Post::Thread')
|
where (asset.className='WebGUI::Asset::Post' or asset.className='WebGUI::Asset::Post::Thread')
|
||||||
and asset.lineage like ".quote($self->get("lineage").'%')."
|
and asset.lineage like ".quote($self->get("lineage").'%')."
|
||||||
and asset.assetId<>".quote($self->getId)."
|
and asset.assetId<>".quote($self->getId)."
|
||||||
and (
|
and (
|
||||||
Post.status in ('approved','archived')";
|
assetData.status in ('approved','archived')
|
||||||
$sql .= " or Post.status='pending'" if ($self->canModerate);
|
or assetData.tagId=".quote($session{scratch}{versionTag});
|
||||||
|
$sql .= " or assetData.status='pending'" if ($self->canModerate);
|
||||||
$sql .= " or (asset.ownerUserId=".quote($session{user}{userId})." and asset.ownerUserId<>'1')
|
$sql .= " or (asset.ownerUserId=".quote($session{user}{userId})." and asset.ownerUserId<>'1')
|
||||||
) ";
|
) ";
|
||||||
$sql .= " and ($all) " if ($all ne "");
|
$sql .= " and ($all) " if ($all ne "");
|
||||||
|
|
@ -1048,7 +1051,7 @@ sub www_search {
|
||||||
$sql .= " ($atLeastOne) " if ($atLeastOne ne "");
|
$sql .= " ($atLeastOne) " if ($atLeastOne ne "");
|
||||||
$sql .= " and " if ($sql ne "" && $without ne "");
|
$sql .= " and " if ($sql ne "" && $without ne "");
|
||||||
$sql .= " ($without) " if ($without ne "");
|
$sql .= " ($without) " if ($without ne "");
|
||||||
$sql .= " order by Post.dateSubmitted desc";
|
$sql .= " group by assetData.assetId order by Post.dateSubmitted desc";
|
||||||
my $p = WebGUI::Paginator->new($self->getUrl("func=search&doit=1"),$numResults);
|
my $p = WebGUI::Paginator->new($self->getUrl("func=search&doit=1"),$numResults);
|
||||||
$self->appendPostListTemplateVars(\%var, $sql, $p);
|
$self->appendPostListTemplateVars(\%var, $sql, $p);
|
||||||
}
|
}
|
||||||
|
|
@ -1130,9 +1133,13 @@ sub www_viewRSS {
|
||||||
my $sth = WebGUI::SQL->read("select *
|
my $sth = WebGUI::SQL->read("select *
|
||||||
from Thread
|
from Thread
|
||||||
left join asset on Thread.assetId=asset.assetId
|
left join asset on Thread.assetId=asset.assetId
|
||||||
left join Post on Post.assetId=asset.assetId
|
left join Post on Post.assetId=Thread.assetId and Thread.revisionDate=Post.revisionDate
|
||||||
|
left join assetData on assetData.assetId=Thread.assetId and Thread.revisionDate=assetData.revisionDate
|
||||||
where asset.parentId=".quote($self->getId)." and asset.state='published'
|
where asset.parentId=".quote($self->getId)." and asset.state='published'
|
||||||
and asset.className='WebGUI::Asset::Post::Thread' and Post.status='approved'
|
and asset.className='WebGUI::Asset::Post::Thread'
|
||||||
|
and (assetData.status='approved'
|
||||||
|
or assetData.tagId=".quote($session{scratch}{versionTag}).")
|
||||||
|
group by assetData.assetId
|
||||||
order by ".$self->getValue("sortBy")." ".$self->getValue("sortOrder"));
|
order by ".$self->getValue("sortBy")." ".$self->getValue("sortOrder"));
|
||||||
my $i = 1;
|
my $i = 1;
|
||||||
while (my $data = $sth->hashRef) {
|
while (my $data = $sth->hashRef) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue