From ae2acfffd8c3d57db9738013fe0abad90b329fa1 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Wed, 16 Mar 2005 01:23:58 +0000 Subject: [PATCH] many bug fixes --- docs/changelog/6.x.x.txt | 20 +++++ docs/previousVersion.sql | 7 -- docs/upgrades/upgrade_6.5.1-6.5.2.pl | 104 ++++++++++++++++++++++ docs/upgrades/upgrade_6.5.1-6.5.2.sql | 5 +- lib/WebGUI/Asset/Post.pm | 19 ++-- lib/WebGUI/Asset/Post/Thread.pm | 3 +- lib/WebGUI/Asset/Wobject/Collaboration.pm | 13 ++- lib/WebGUI/Asset/Wobject/MessageBoard.pm | 8 ++ lib/WebGUI/Operation/Replacements.pm | 8 +- lib/WebGUI/Style.pm | 4 +- lib/WebGUI/i18n/English/Collaboration.pm | 2 +- sbin/Hourly/ArchiveOldPosts.pm | 18 ++-- 12 files changed, 177 insertions(+), 34 deletions(-) create mode 100644 docs/upgrades/upgrade_6.5.1-6.5.2.pl diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index fdb6458e6..d60f345a0 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -1,3 +1,23 @@ +6.5.2 + - Fixed a caching bug in the collaboration system that wouldn't allow you to + view other posts if you were in threaded mode. + - fix [ 1160969 ] 6.5.x plainblack.com - Second edit of Post fails + - fix [ 1161571 ] 6.5.0, pagination on view forum always returns page 1 + - fix [ 1163780 ] Pagination not working for Thread in Nested view + - fix [ 1163761 ] session from 10.0.0.2 in create.sql + - fix [ 1160971 ] 6.5.x - Use Preview setting ignored in collaboration + systems + - fix [ 1159395 ] Rating causes Problem with request + - fix [ 1150169 ] archive posts + - fix [ 1149830 ] Collaboration System privileges not correct + - fix [ 1157197 ] content filters shows only word to be replaced + - fix [ 1088201 ] Deleted discussion thread negatively offsets reply count + - fix [ 1162056 ] No default template for Data Form with no tabs + - fix [ 1029170 ] Forum: Sorting thread by date + - Fixed a sort by last reply crash bug. + - fix [ 1160947 ] Make page printable does not work + + 6.5.1 - Fixed a bug in the lineage tree that caused funky ranks to be created when pasting assets. diff --git a/docs/previousVersion.sql b/docs/previousVersion.sql index 7352b5099..f730b780f 100644 --- a/docs/previousVersion.sql +++ b/docs/previousVersion.sql @@ -2733,8 +2733,6 @@ CREATE TABLE userLoginLog ( -- -INSERT INTO userLoginLog VALUES ('3','success',1109989498,'10.0.0.2','Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050225 Firefox/1.0.1'); -INSERT INTO userLoginLog VALUES ('3','success',1109989768,'10.0.0.2','Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050225 Firefox/1.0.1'); -- -- Table structure for table `userProfileCategory` @@ -2869,11 +2867,6 @@ CREATE TABLE userSession ( -- -INSERT INTO userSession VALUES ('82WNZSBtGILYo',1109992028,1109988428,0,'66.196.91.102','1'); -INSERT INTO userSession VALUES ('19y/YcYUDLoHw',1109991892,1109988292,0,'68.142.251.125','1'); -INSERT INTO userSession VALUES ('24jJHPg295S56',1109990899,1109987299,0,'68.142.250.47','1'); -INSERT INTO userSession VALUES ('32eqpqD/QNpew',1109993461,1109989861,0,'10.0.0.2','3'); -INSERT INTO userSession VALUES ('68RJ6HMaKCbp6',1110383374,1110379774,0,'','1'); -- -- Table structure for table `userSessionScratch` diff --git a/docs/upgrades/upgrade_6.5.1-6.5.2.pl b/docs/upgrades/upgrade_6.5.1-6.5.2.pl new file mode 100644 index 000000000..8565cbe28 --- /dev/null +++ b/docs/upgrades/upgrade_6.5.1-6.5.2.pl @@ -0,0 +1,104 @@ +#!/usr/bin/perl + +use lib "../../lib"; +use Getopt::Long; +use strict; +use WebGUI::Session; +use WebGUI::Asset; + +my $configFile; +my $quiet; + +GetOptions( + 'configFile=s'=>\$configFile, + 'quiet'=>\$quiet +); + +WebGUI::Session::open("../..",$configFile); + +#-------------------------------------------- +print "\tAdding data form template\n" unless ($quiet); +my $template = < + +

+
+ +

+
+ + +
    + +
  • + +
+
+ + +

+ + + + + + + + +

+ + + + + + + + + + +
+ + + + + + + + + + + + + * + +
+ +
+
+
+ + +STOP +my $importNode = WebGUI::Asset->getImportNode; +$importNode->addChild({ + className=>"WebGUI::Asset::Template", + template=>$template, + namespace=>"DataForm", + title=>'Default DataForm', + menuTitle=>'Default DataForm', + ownerUserId=>'3', + groupIdView=>'7', + groupIdEdit=>'4', + isHidden=>1 + }, 'PBtmpl0000000000000141' +); + + + +WebGUI::Session::close(); + + diff --git a/docs/upgrades/upgrade_6.5.1-6.5.2.sql b/docs/upgrades/upgrade_6.5.1-6.5.2.sql index 80f5af671..520373181 100644 --- a/docs/upgrades/upgrade_6.5.1-6.5.2.sql +++ b/docs/upgrades/upgrade_6.5.1-6.5.2.sql @@ -1,3 +1,4 @@ insert into webguiVersion values ('6.5.2','upgrade',unix_timestamp()); - - +update template set template = '\">

\r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n\r\n
\r\n\r\n\r\n

\r\n\r\n

' where assetId='PBtmpl0000000000000029'; +update asset set endDate=32472169200 where endDate=9223372036854775807; +alter table asset change endDate endDate bigint(20) not null default 32472169200; diff --git a/lib/WebGUI/Asset/Post.pm b/lib/WebGUI/Asset/Post.pm index cebaed41f..66c5a9669 100644 --- a/lib/WebGUI/Asset/Post.pm +++ b/lib/WebGUI/Asset/Post.pm @@ -629,8 +629,6 @@ sub processPropertiesFromFormPost { } %data = ( ownerUserId => $session{user}{userId}, - groupIdView => $self->getThread->getParent->get("groupIdView"), - groupIdEdit => $self->getThread->getParent->get("groupIdEdit"), isHidden => 1, dateSubmitted=>time() ); @@ -638,7 +636,11 @@ sub processPropertiesFromFormPost { $self->getThread->lock if ($session{form}{'lock'}); $self->getThread->stick if ($session{form}{stick}); } + } else { + $data{ownerUserId} = $session{form}{userId}; } + $data{groupIdView} =$self->getThread->getParent->get("groupIdView"); + $data{groupIdEdit} = $self->getThread->getParent->get("groupIdEdit"); $data{startDate} = $self->getThread->getParent->get("startDate") unless ($session{form}{startDate}); $data{endDate} = $self->getThread->getParent->get("endDate") unless ($session{form}{endDate}); ($data{synopsis}, $data{content}) = $self->getSynopsisAndContentFromFormPost; @@ -832,14 +834,13 @@ sub www_edit { value=>$session{form}{class} }); $var{'isNewPost'} = 1; + $content = $session{form}{content}; + $title = $session{form}{title}; if ($session{form}{class} eq "WebGUI::Asset::Post") { # new reply $self->{_thread} = $self->getParent->getThread; return WebGUI::Privilege::insufficient() unless ($self->getThread->canReply); $var{isReply} = 1; - if ($session{form}{content} || $session{form}{title}) { - $content = $session{form}{content}; - $title = $session{form}{title}; - } else { + unless ($session{form}{content} || $session{form}{title}) { $content = "[quote]".$self->getParent->get("content")."[/quote]" if ($session{form}{withQuote}); $title = $self->getParent->get("title"); $title = "Re: ".$title unless ($title =~ /^Re:/); @@ -873,6 +874,10 @@ sub www_edit { .WebGUI::Form::hidden({ name=>"func", value=>"edit" + }) + .WebGUI::Form::hidden({ + name=>"userId", + value=>$self->getValue("ownerUserId") }); $var{isEdit} = 1; $content = $self->getValue("content"); @@ -993,7 +998,7 @@ sub www_view { my $self = shift; $self->markRead; $self->incrementViews; - return $self->getThread->www_view; + return $self->getThread->www_view($self->getId); } diff --git a/lib/WebGUI/Asset/Post/Thread.pm b/lib/WebGUI/Asset/Post/Thread.pm index 08aa78a71..4351a0d94 100644 --- a/lib/WebGUI/Asset/Post/Thread.pm +++ b/lib/WebGUI/Asset/Post/Thread.pm @@ -728,6 +728,7 @@ sub www_unsubscribe { #------------------------------------------------------------------- sub www_view { my $self = shift; + my $postId = shift; return WebGUI::Privilege::noAccess() unless $self->canView; my $cache; my $output; @@ -742,7 +743,7 @@ sub www_view { not $session{var}{adminOn} ); if ($useCache) { - $cache = WebGUI::Cache->new("cspost_".$self->getId."_".$session{user}{userId}); + $cache = WebGUI::Cache->new("cspost_".($postId||$self->getId)."_".$session{user}{userId}."_".$session{scratch}{discussionLayout}."_".$session{form}{pn}); $output = $cache->get; } unless ($output) { diff --git a/lib/WebGUI/Asset/Wobject/Collaboration.pm b/lib/WebGUI/Asset/Wobject/Collaboration.pm index a77e2f44a..9e944dcf3 100644 --- a/lib/WebGUI/Asset/Wobject/Collaboration.pm +++ b/lib/WebGUI/Asset/Wobject/Collaboration.pm @@ -530,7 +530,7 @@ sub getEditForm { ); $tabform->getTab("properties")->yesNo( -name=>"usePreview", - -label=>WebGUI::International::get('preview', 'Collaboration'), + -label=>WebGUI::International::get('use preview', 'Collaboration'), -value=>$self->getValue("usePreview") ); $tabform->getTab("security")->yesNo( @@ -737,9 +737,10 @@ Calculates the rating of this forum from its threads and stores the new value in sub recalculateRating { my $self = shift; my ($count) = WebGUI::SQL->quickArray("select count(*) from Thread left join asset on Thread.assetId=asset.assetId - where asset.parentId=".quote($self->getId)." and Thread.rating>0"); + left join Post on Thread.assetId=Post.assetId where asset.parentId=".quote($self->getId)." and Post.rating>0"); $count = $count || 1; - my ($sum) = WebGUI::SQL->quickArray("select sum(Thread.rating) from Thread left join asset on Thread.assetId=asset.assetId where asset.parentId=".quote($self->getId)." and Thread.rating>0"); + my ($sum) = WebGUI::SQL->quickArray("select sum(Post.rating) from Thread left join asset on Thread.assetId=asset.assetId + left join Post on Thread.assetId=Post.assetId where asset.parentId=".quote($self->getId)." and Post.rating>0"); my $average = round($sum/$count); $self->update({rating=>$average}); } @@ -835,12 +836,16 @@ 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 ".$self->getValue("sortBy")." ".$self->getValue("sortOrder"); + order by ".$sortBy." ".$self->getValue("sortOrder"); my $p = WebGUI::Paginator->new($self->getUrl,$self->get("threadsPerPage")); $self->appendPostListTemplateVars(\%var, $sql, $p); $self->appendTemplateLabels(\%var); diff --git a/lib/WebGUI/Asset/Wobject/MessageBoard.pm b/lib/WebGUI/Asset/Wobject/MessageBoard.pm index 6969302ae..34c37850d 100644 --- a/lib/WebGUI/Asset/Wobject/MessageBoard.pm +++ b/lib/WebGUI/Asset/Wobject/MessageBoard.pm @@ -50,6 +50,14 @@ sub getEditForm { } +#------------------------------------------------------------------- +sub getIcon { + my $self = shift; + my $small = shift; + return $session{config}{extrasURL}.'/assets/small/messageBoard.gif' if ($small); + return $session{config}{extrasURL}.'/assets/messageBoard.gif'; +} + #------------------------------------------------------------------- sub getName { return WebGUI::International::get(2,"MessageBoard"); diff --git a/lib/WebGUI/Operation/Replacements.pm b/lib/WebGUI/Operation/Replacements.pm index b6656912b..2f5d87566 100644 --- a/lib/WebGUI/Operation/Replacements.pm +++ b/lib/WebGUI/Operation/Replacements.pm @@ -89,11 +89,15 @@ sub www_editReplacementSave { sub www_listReplacements { return WebGUI::Privilege::adminOnly() unless (WebGUI::Grouping::isInGroup(3)); my $output = ''; - my $sth = WebGUI::SQL->read("select replacementId,searchFor from replacements order by searchFor"); + $output .= ''; + my $sth = WebGUI::SQL->read("select replacementId,searchFor,replaceWith from replacements order by searchFor"); while (my $data = $sth->hashRef) { $output .= ''; - $output .= ''; + $data->{replaceWith} =~ s/\&/\&\;/g; + $data->{replaceWith} =~ s/\{replaceWith} =~ s/\>/\>\;/g; + $output .= ''; } $sth->finish; $output .= '
'.WebGUI::International::get(1050).''.WebGUI::International::get(1051).'
'.deleteIcon("op=deleteReplacement&replacementId=".$data->{replacementId}) .editIcon("op=editReplacement&replacementId=".$data->{replacementId}).''.$data->{searchFor}.'
'.$data->{searchFor}.''.$data->{replaceWith}.'
'; diff --git a/lib/WebGUI/Style.pm b/lib/WebGUI/Style.pm index f97643e9e..269f6bb08 100644 --- a/lib/WebGUI/Style.pm +++ b/lib/WebGUI/Style.pm @@ -109,8 +109,8 @@ sub process { my %var; $var{'body.content'} = shift; my $templateId = shift; - if ($session{page}{makePrintable}) { - $templateId = $session{page}{printableStyleId}; + if ($session{page}{makePrintable} && exists $session{asset}) { + $templateId = $session{asset}->get("printableStyleTemplateId"); } elsif ($session{scratch}{personalStyleId} ne "") { $templateId = $session{scratch}{personalStyleId}; } elsif ($session{page}{useEmptyStyle}) { diff --git a/lib/WebGUI/i18n/English/Collaboration.pm b/lib/WebGUI/i18n/English/Collaboration.pm index c9e9bbf24..ef744c476 100644 --- a/lib/WebGUI/i18n/English/Collaboration.pm +++ b/lib/WebGUI/i18n/English/Collaboration.pm @@ -406,7 +406,7 @@ our $I18N = { lastUpdated => 1109698614, }, - 'preview' => { + 'use preview' => { message => q|Use preview?|, lastUpdated => 1109698614, }, diff --git a/sbin/Hourly/ArchiveOldPosts.pm b/sbin/Hourly/ArchiveOldPosts.pm index 14bdd0a3d..7c22ef05a 100644 --- a/sbin/Hourly/ArchiveOldPosts.pm +++ b/sbin/Hourly/ArchiveOldPosts.pm @@ -12,21 +12,23 @@ package Hourly::ArchiveOldPosts; use strict; +use WebGUI::Asset::Post; use WebGUI::DateTime; use WebGUI::Session; use WebGUI::SQL; #----------------------------------------- sub process { - return ""; # disabled for the time being my $epoch = WebGUI::DateTime::time(); - my $a = WebGUI::SQL->read("select assetId,archiveAfter,masterForumId from forum"); - while (my $forum = $a->hashRef) { - my $archiveDate = $epoch - $forum->{archiveAfter}; - my $b = WebGUI::SQL->read("select forumThreadId from forumThread where forumId=".quote($forum->{forumId})." and lastPostDate<$archiveDate"); - while (my ($threadId) = $b->array) { - WebGUI::SQL->write("update forumPost set status='archived' where status='approved' and forumThreadId=".quote($threadId)); - WebGUI::SQL->write("update forumThread set status='archived' where status='approved' and forumThreadId=".quote($threadId)); + my $a = WebGUI::SQL->read("select asset.lineage,Collaboration.archiveAfter from Collaboration left join asset on Collaboration.assetId=asset.assetId"); + while (my ($lineage, $archiveAfter) = $a->array) { + my $archiveDate = $epoch - $archiveAfter; + my $sql = "select * from Post left join asset on Post.assetId=asset.assetId left join Thread on Thread.assetId=Post.assetId + where Post.dateUpdated<$archiveDate and Post.status='approved' and asset.lineage like ".quote($lineage."%"); + my $b = WebGUI::SQL->read($sql); + while (my $properties = $b->hashRef) { + my $post = WebGUI::Asset::Post->newByPropertyHashRef($properties); + $post->setStatusArchived; } $b->finish; }