lots of bug fixes

This commit is contained in:
JT Smith 2004-09-06 21:28:55 +00:00
parent fd0413c746
commit b4498138fb
12 changed files with 67 additions and 45 deletions

View file

@ -1,6 +1,11 @@
6.2.1 6.2.1
- Fixed a GUID quoting bug in WebGUI.pm setCollateral. - Fixed a GUID quoting bug in WebGUI.pm setCollateral.
- Fixed all sorts of GUID related bugs in the Forums.
- Fixed a bug in the Message Board wobject that caused users not to be able
to do anything useful on the message board.
- Fixed a version check problem in Syndicated Content wobject.
- Fixed some GUID problems in the scheduler plug-ins.
- Fixed some epoch bugs in the scheduler plug-ins.
6.2.0 6.2.0

View file

@ -81,7 +81,7 @@ The unique identifier to check privileges against. Defaults to the current user.
sub canEdit { sub canEdit {
my ($self, $userId) = @_; my ($self, $userId) = @_;
$userId = $session{user}{userId} unless ($userId); $userId = $session{user}{userId} unless ($userId);
return ($self->getThread->getForum->isModerator || ($self->get("userId") == $userId && $userId != 1 return ($self->getThread->getForum->isModerator || ($self->get("userId") eq $userId && $userId != 1
&& $self->getThread->getForum->get("editTimeout") > (WebGUI::DateTime::time() - $self->get("dateOfPost")))); && $self->getThread->getForum->get("editTimeout") > (WebGUI::DateTime::time() - $self->get("dateOfPost"))));
} }
@ -108,7 +108,7 @@ sub canView {
return 1; return 1;
} elsif ($self->get("status") eq "deleted") { } elsif ($self->get("status") eq "deleted") {
return 0; return 0;
} elsif ($self->get("status") eq "denied" && $userId == $self->get("userId")) { } elsif ($self->get("status") eq "denied" && $userId eq $self->get("userId")) {
return 1; return 1;
} elsif ($self->getThread->getForum->isModerator) { } elsif ($self->getThread->getForum->isModerator) {
return 1; return 1;
@ -231,7 +231,7 @@ If the user ID equals 1 (visitor) then an IP address is used to distinguish the
sub hasRated { sub hasRated {
my ($self, $userId, $ipAddress) = @_; my ($self, $userId, $ipAddress) = @_;
$userId = $session{user}{userId} unless ($userId); $userId = $session{user}{userId} unless ($userId);
return 1 if ($userId != 1 && $userId == $self->get("userId")); # is poster return 1 if ($userId != 1 && $userId eq $self->get("userId")); # is poster
$ipAddress = $session{env}{REMOTE_ADDR} unless ($ipAddress); $ipAddress = $session{env}{REMOTE_ADDR} unless ($ipAddress);
my ($flag) = WebGUI::SQL->quickArray("select count(*) from forumPostRating where forumPostId=" my ($flag) = WebGUI::SQL->quickArray("select count(*) from forumPostRating where forumPostId="
.quote($self->get("forumPostId"))." and ((userId=".quote($userId)." and userId<>1) or (userId=1 and .quote($self->get("forumPostId"))." and ((userId=".quote($userId)." and userId<>1) or (userId=1 and
@ -434,7 +434,7 @@ Sets the status of this post to approved.
sub setStatusApproved { sub setStatusApproved {
my ($self) = @_; my ($self) = @_;
$self->set({status=>'approved'}); $self->set({status=>'approved'});
$self->getThread->setStatusApproved if ($self->getThread->get("rootPostId") == $self->get("forumPostId")); $self->getThread->setStatusApproved if ($self->getThread->get("rootPostId") eq $self->get("forumPostId"));
if ($self->isReply) { if ($self->isReply) {
$self->getThread->incrementReplies($self->get("dateOfPost"),$self->get("forumPostId")); $self->getThread->incrementReplies($self->get("dateOfPost"),$self->get("forumPostId"));
} }
@ -452,7 +452,7 @@ Sets the status of this post to archived.
sub setStatusArchived { sub setStatusArchived {
my ($self) = @_; my ($self) = @_;
$self->set({status=>'archived'}); $self->set({status=>'archived'});
$self->getThread->setStatusArchived if ($self->getThread->get("rootPostId") == $self->get("forumPostId")); $self->getThread->setStatusArchived if ($self->getThread->get("rootPostId") eq $self->get("forumPostId"));
if ($self->isReply) { if ($self->isReply) {
$self->getThread->incrementReplies($self->get("dateOfPost"),$self->get("forumPostId")); $self->getThread->incrementReplies($self->get("dateOfPost"),$self->get("forumPostId"));
} }
@ -470,7 +470,7 @@ sub setStatusDeleted {
my ($self) = @_; my ($self) = @_;
$self->set({status=>'deleted'}); $self->set({status=>'deleted'});
$self->getThread->decrementReplies; $self->getThread->decrementReplies;
$self->getThread->setStatusDeleted if ($self->getThread->get("rootPostId") == $self->get("forumPostId")); $self->getThread->setStatusDeleted if ($self->getThread->get("rootPostId") eq $self->get("forumPostId"));
my ($id, $date) = WebGUI::SQL->quickArray("select forumPostId,dateOfPost from forumPost where forumThreadId=" my ($id, $date) = WebGUI::SQL->quickArray("select forumPostId,dateOfPost from forumPost where forumThreadId="
.quote($self->get("forumThreadId"))." and status='approved'"); .quote($self->get("forumThreadId"))." and status='approved'");
$self->getThread->setLastPost($date,$id); $self->getThread->setLastPost($date,$id);
@ -487,7 +487,7 @@ Sets the status of this post to denied.
sub setStatusDenied { sub setStatusDenied {
my ($self) = @_; my ($self) = @_;
$self->set({status=>'denied'}); $self->set({status=>'denied'});
$self->getThread->setStatusDenied if ($self->getThread->get("rootPostId") == $self->get("forumPostId")); $self->getThread->setStatusDenied if ($self->getThread->get("rootPostId") eq $self->get("forumPostId"));
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
@ -501,7 +501,7 @@ Sets the status of this post to pending.
sub setStatusPending { sub setStatusPending {
my ($self) = @_; my ($self) = @_;
$self->set({status=>'pending'}); $self->set({status=>'pending'});
$self->getThread->setStatusPending if ($self->getThread->get("rootPostId") == $self->get("forumPostId")); $self->getThread->setStatusPending if ($self->getThread->get("rootPostId") eq $self->get("forumPostId"));
} }

View file

@ -1162,7 +1162,7 @@ sub getForumTemplateVars {
foreach my $thread (@$threads) { foreach my $thread (@$threads) {
my $root = WebGUI::Forum::Post->new($thread->{rootPostId}); my $root = WebGUI::Forum::Post->new($thread->{rootPostId});
my $last; my $last;
if ($thread->{rootPostId} == $thread->{lastPostId}) { #saves the lookup if it's the same id if ($thread->{rootPostId} eq $thread->{lastPostId}) { #saves the lookup if it's the same id
$last = $root; $last = $root;
} else { } else {
$last = WebGUI::Forum::Post->new($thread->{lastPostId}); $last = WebGUI::Forum::Post->new($thread->{lastPostId});
@ -1418,12 +1418,12 @@ sub notifySubscribers {
my %subscribers; my %subscribers;
my $sth = WebGUI::SQL->read("select userId from forumThreadSubscription where forumThreadId=".quote($thread->get("forumThreadId"))); my $sth = WebGUI::SQL->read("select userId from forumThreadSubscription where forumThreadId=".quote($thread->get("forumThreadId")));
while (my ($userId) = $sth->array) { while (my ($userId) = $sth->array) {
$subscribers{$userId} = $userId unless ($userId == $post->get("userId")); # make sure we don't send unnecessary messages $subscribers{$userId} = $userId unless ($userId eq $post->get("userId")); # make sure we don't send unnecessary messages
} }
$sth->finish; $sth->finish;
$sth = WebGUI::SQL->read("select userId from forumSubscription where forumId=".quote($forum->get("forumId"))); $sth = WebGUI::SQL->read("select userId from forumSubscription where forumId=".quote($forum->get("forumId")));
while (my ($userId) = $sth->array) { while (my ($userId) = $sth->array) {
$subscribers{$userId} = $userId unless ($userId == $post->get("userId")); # make sure we don't send unnecessary messages $subscribers{$userId} = $userId unless ($userId eq $post->get("userId")); # make sure we don't send unnecessary messages
} }
$sth->finish; $sth->finish;
my %lang; my %lang;
@ -1569,7 +1569,7 @@ A post object.
sub setPostApproved { sub setPostApproved {
my ($caller, $post) = @_; my ($caller, $post) = @_;
$post->setStatusApproved; $post->setStatusApproved;
unless ($session{user}{userId} == $post->get("userId")) { unless ($session{user}{userId} eq $post->get("userId")) {
WebGUI::MessageLog::addInternationalizedEntry($post->get("userId"),'',formatThreadURL($caller->{callback},$post->get("forumPostId")),579); WebGUI::MessageLog::addInternationalizedEntry($post->get("userId"),'',formatThreadURL($caller->{callback},$post->get("forumPostId")),579);
} }
notifySubscribers($post,$post->getThread,$post->getThread->getForum,$caller); notifySubscribers($post,$post->getThread,$post->getThread->getForum,$caller);
@ -2504,7 +2504,7 @@ sub www_viewThread {
my $post = WebGUI::Forum::Post->new($postId); my $post = WebGUI::Forum::Post->new($postId);
return WebGUI::Privilege::insufficient() unless ($post->getThread->getForum->canView); return WebGUI::Privilege::insufficient() unless ($post->getThread->getForum->canView);
my $var = getThreadTemplateVars($caller, $post); my $var = getThreadTemplateVars($caller, $post);
if ($post->get("forumPostId") == $post->getThread->get("rootPostId") && !$post->canView) { if ($post->get("forumPostId") eq $post->getThread->get("rootPostId") && !$post->canView) {
return www_viewForum($caller, $post->getThread->getForum->get("forumId")); return www_viewForum($caller, $post->getThread->getForum->get("forumId"));
} else { } else {
return WebGUI::Template::process($post->getThread->getForum->get("threadTemplateId"),"Forum/Thread", $var); return WebGUI::Template::process($post->getThread->getForum->get("threadTemplateId"),"Forum/Thread", $var);

View file

@ -261,9 +261,9 @@ sub www_view {
my $caller; my $caller;
my $sth = WebGUI::SQL->read("select * from MessageBoard_forums where wobjectId=".quote($_[0]->get("wobjectId"))." order by sequenceNumber"); my $sth = WebGUI::SQL->read("select * from MessageBoard_forums where wobjectId=".quote($_[0]->get("wobjectId"))." order by sequenceNumber");
while (my $forumMeta = $sth->hashRef) { while (my $forumMeta = $sth->hashRef) {
my $callback = WebGUI::URL::page("func=view&wid=".$_[0]->get("wobjectId")); my $callback = WebGUI::URL::page("func=view&wid=".$_[0]->get("wobjectId")."&forumId=".$forumMeta->{forumId});
if ($session{form}{forumOp}) { if ($session{form}{forumOp}) {
if ($session{form}{forumId} == $forumMeta->{forumId}) { if ($session{form}{forumId} eq $forumMeta->{forumId}) {
$caller = { $caller = {
callback=>$callback, callback=>$callback,
title=>$forumMeta->{title}, title=>$forumMeta->{title},
@ -305,7 +305,7 @@ sub www_view {
'forum.lastPost.user.name' => $lastPost->get("username"), 'forum.lastPost.user.name' => $lastPost->get("username"),
'forum.lastPost.user.alias' => WebGUI::User->new($lastPost->get("userId"))->profileField("alias"), 'forum.lastPost.user.alias' => WebGUI::User->new($lastPost->get("userId"))->profileField("alias"),
'forum.lastPost.user.profile' => WebGUI::Forum::UI::formatUserProfileURL($lastPost->get("userId")), 'forum.lastPost.user.profile' => WebGUI::Forum::UI::formatUserProfileURL($lastPost->get("userId")),
'forum.lastPost.user.isVisitor' => ($lastPost->get("userId") == 1), 'forum.lastPost.user.isVisitor' => ($lastPost->get("userId") eq 1),
'forum.user.canView' => $forum->canView, 'forum.user.canView' => $forum->canView,
'forum.user.canPost' => $forum->canPost 'forum.user.canPost' => $forum->canPost
}); });

View file

@ -25,6 +25,9 @@ use WebGUI::Session;
use WebGUI::Wobject; use WebGUI::Wobject;
use XML::RSSLite; use XML::RSSLite;
use LWP::UserAgent; use LWP::UserAgent;
use WebGUI::ErrorHandler;
my $hasEncode=1;
eval " use Encode qw(from_to); "; $hasEncode=0 if $@;
our @ISA = qw(WebGUI::Wobject); our @ISA = qw(WebGUI::Wobject);
@ -44,7 +47,8 @@ sub new {
rssUrl=>{}, rssUrl=>{},
maxHeadlines=>{}, maxHeadlines=>{},
}, },
-useTemplate=>1 -useTemplate=>1,
-useMetaData=>1
); );
bless $self, $class; bless $self, $class;
} }
@ -181,11 +185,24 @@ sub _get_rss_data {
my $ua = LWP::UserAgent->new(timeout => 5); my $ua = LWP::UserAgent->new(timeout => 5);
my $response = $ua->get($url); my $response = $ua->get($url);
if (!$response->is_success()) { if (!$response->is_success()) {
warn("Error retrieving url '$url': " . WebGUI::ErrorHandler::warn("Error retrieving url '$url': " .
$response->status_line()); $response->status_line());
return undef; return undef;
} }
my $xml = $response->content(); my $xml = $response->content();
# Convert encoding if needed / Perl 5.8.0 or up required.
if ($] >= 5.008 && $hasEncode) {
$xml =~ /<\?xml.*?encoding=['"](\S+)['"]/i;
my $xmlEncoding = $1;
my $encoding = WebGUI::International::getLanguage($session{page}{languageId},"charset");
if (lc($xmlEncoding) ne lc($encoding)) {
eval { from_to($xml, $xmlEncoding, $encoding) };
WebGUI::ErrorHandler::warn($@) if ($@);
}
}
# there is no encode_entities_numeric that I can find, so I am # there is no encode_entities_numeric that I can find, so I am
# commenting this out. -hal # commenting this out. -hal
@ -197,7 +214,7 @@ sub _get_rss_data {
XML::RSSLite::parseXML($rss_lite, \$xml); XML::RSSLite::parseXML($rss_lite, \$xml);
}; };
if ($@) { if ($@) {
warn("error parsing rss for url $url"); WebGUI::ErrorHandler::warn("error parsing rss for url $url");
} }
# make sure that the {channel} points to the channel # make sure that the {channel} points to the channel
@ -208,10 +225,10 @@ sub _get_rss_data {
$rss_lite = {channel => $rss_lite}; $rss_lite = {channel => $rss_lite};
if (!($rss->{channel} = if (!($rss->{channel} =
_find_record($rss_lite, qr/^channel$/))) { _find_record($rss_lite, qr/^channel$/))) {
warn("unable to find channel info for url $url"); WebGUI::ErrorHandler::warn("unable to find channel info for url $url");
} }
if (!($rss->{items} = _find_record($rss_lite, qr/^items?$/))) { if (!($rss->{items} = _find_record($rss_lite, qr/^items?$/))) {
warn("unable to find item info for url $url"); WebGUI::ErrorHandler::warn("unable to find item info for url $url");
$rss->{items} = []; $rss->{items} = [];
} }
@ -329,6 +346,7 @@ sub _view_single_feed {
} }
sub www_view { sub www_view {
$_[0]->logView() if ($session{setting}{passiveProfilingEnabled});
my $maxHeadlines = $_[0]->get("maxHeadlines") || 1000000; my $maxHeadlines = $_[0]->get("maxHeadlines") || 1000000;
my @urls = split(/\s+/,$_[0]->get("rssUrl")); my @urls = split(/\s+/,$_[0]->get("rssUrl"));

View file

@ -270,7 +270,7 @@ sub www_copy {
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_deleteFile { sub www_deleteFile {
my ($owner) = WebGUI::SQL->quickArray("select userId from USS_submission where USS_submissionId=".quote($session{form}{sid})); my ($owner) = WebGUI::SQL->quickArray("select userId from USS_submission where USS_submissionId=".quote($session{form}{sid}));
if ($owner == $session{user}{userId} || WebGUI::Grouping::isInGroup($_[0]->get("groupToApprove"))) { if ($owner eq $session{user}{userId} || WebGUI::Grouping::isInGroup($_[0]->get("groupToApprove"))) {
$_[0]->setCollateral("USS_submission","USS_submissionId",{ $_[0]->setCollateral("USS_submission","USS_submissionId",{
$session{form}{file}=>'', $session{form}{file}=>'',
USS_submissionId=>$session{form}{sid} USS_submissionId=>$session{form}{sid}
@ -284,7 +284,7 @@ sub www_deleteFile {
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_deleteSubmission { sub www_deleteSubmission {
my ($owner) = WebGUI::SQL->quickArray("select userId from USS_submission where USS_submissionId=".quote($session{form}{sid})); my ($owner) = WebGUI::SQL->quickArray("select userId from USS_submission where USS_submissionId=".quote($session{form}{sid}));
if ($owner == $session{user}{userId} || WebGUI::Grouping::isInGroup($_[0]->get("groupToApprove"))) { if ($owner eq $session{user}{userId} || WebGUI::Grouping::isInGroup($_[0]->get("groupToApprove"))) {
return $_[0]->confirm(WebGUI::International::get(17,$_[0]->get("namespace")), return $_[0]->confirm(WebGUI::International::get(17,$_[0]->get("namespace")),
WebGUI::URL::page('func=deleteSubmissionConfirm&wid='.$session{form}{wid}.'&sid='.$session{form}{sid})); WebGUI::URL::page('func=deleteSubmissionConfirm&wid='.$session{form}{wid}.'&sid='.$session{form}{sid}));
} else { } else {
@ -295,7 +295,7 @@ sub www_deleteSubmission {
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_deleteSubmissionConfirm { sub www_deleteSubmissionConfirm {
my ($owner, $forumId, $pageId) = WebGUI::SQL->quickArray("select userId,forumId,pageId from USS_submission where USS_submissionId=".quote($session{form}{sid})); my ($owner, $forumId, $pageId) = WebGUI::SQL->quickArray("select userId,forumId,pageId from USS_submission where USS_submissionId=".quote($session{form}{sid}));
if ($owner == $session{user}{userId} || WebGUI::Grouping::isInGroup($_[0]->get("groupToApprove"))) { if ($owner eq $session{user}{userId} || WebGUI::Grouping::isInGroup($_[0]->get("groupToApprove"))) {
my ($inUseElsewhere) = WebGUI::SQL->quickArray("select count(*) from USS_submission where forumId=".quote($forumId)); my ($inUseElsewhere) = WebGUI::SQL->quickArray("select count(*) from USS_submission where forumId=".quote($forumId));
unless ($inUseElsewhere > 1) { unless ($inUseElsewhere > 1) {
my $forum = WebGUI::Forum->new($forumId); my $forum = WebGUI::Forum->new($forumId);
@ -425,7 +425,7 @@ sub www_editSubmission {
$var{'submission.isNew'} = 1; $var{'submission.isNew'} = 1;
} }
return WebGUI::Privilege::insufficient() unless (WebGUI::Grouping::isInGroup($_[0]->get("groupToContribute")) return WebGUI::Privilege::insufficient() unless (WebGUI::Grouping::isInGroup($_[0]->get("groupToContribute"))
|| $submission->{userId} == $session{user}{userId} || $submission->{userId} eq $session{user}{userId}
|| WebGUI::Grouping::isInGroup($_[0]->get("groupToApprove"))); || WebGUI::Grouping::isInGroup($_[0]->get("groupToApprove")));
$var{'link.header.label'} = WebGUI::International::get(90,$_[0]->get("namespace")); $var{'link.header.label'} = WebGUI::International::get(90,$_[0]->get("namespace"));
$var{'question.header.label'} = WebGUI::International::get(84,$_[0]->get("namespace")); $var{'question.header.label'} = WebGUI::International::get(84,$_[0]->get("namespace"));
@ -600,7 +600,7 @@ sub www_editSubmission {
sub www_editSubmissionSave { sub www_editSubmissionSave {
my ($submission, %hash, $file, $u); my ($submission, %hash, $file, $u);
$submission = $_[0]->getCollateral("USS_submission","USS_submissionId",$session{form}{sid}); $submission = $_[0]->getCollateral("USS_submission","USS_submissionId",$session{form}{sid});
if ($submission->{userId} == $session{user}{userId} if ($submission->{userId} eq $session{user}{userId}
|| ($submission->{USS_submissionId} eq "new" || ($submission->{USS_submissionId} eq "new"
&& WebGUI::Grouping::isInGroup($_[0]->get("groupToContribute"))) && WebGUI::Grouping::isInGroup($_[0]->get("groupToContribute")))
|| WebGUI::Grouping::isInGroup($_[0]->get("groupToApprove"))) { || WebGUI::Grouping::isInGroup($_[0]->get("groupToApprove"))) {
@ -794,7 +794,7 @@ sub www_view {
"submission.image"=>$imageURL, "submission.image"=>$imageURL,
"submission.date"=>epochToHuman($page->[$i]->{dateSubmitted}), "submission.date"=>epochToHuman($page->[$i]->{dateSubmitted}),
"submission.date.updated"=>epochToHuman($page->[$i]->{dateUpdated}), "submission.date.updated"=>epochToHuman($page->[$i]->{dateUpdated}),
"submission.currentUser"=>($session{user}{userId} == $page->[$i]->{userId} && $session{user}{userId} != 1), "submission.currentUser"=>($session{user}{userId} eq $page->[$i]->{userId} && $session{user}{userId} != 1),
"submission.userProfile"=>WebGUI::URL::page('op=viewProfile&uid='.$page->[$i]->{userId}), "submission.userProfile"=>WebGUI::URL::page('op=viewProfile&uid='.$page->[$i]->{userId}),
"submission.edit.url"=>WebGUI::URL::page($quickurl.'editSubmission'), "submission.edit.url"=>WebGUI::URL::page($quickurl.'editSubmission'),
"submission.secondColumn"=>(($i+1)%2==0), "submission.secondColumn"=>(($i+1)%2==0),
@ -877,7 +877,7 @@ sub www_viewSubmission {
my $submission = $self->getCollateral("USS_submission","USS_submissionId",$submissionId); my $submission = $self->getCollateral("USS_submission","USS_submissionId",$submissionId);
return "" unless ($submission->{USS_submissionId}); return "" unless ($submission->{USS_submissionId});
return "" unless ($submission->{status} eq 'Approved' || return "" unless ($submission->{status} eq 'Approved' ||
($submission->{userId} == $session{user}{userId} && $session{user}{userId} != 1) || ($submission->{userId} eq $session{user}{userId} && $session{user}{userId} != 1) ||
WebGUI::Grouping::isInGroup($self->getValue("groupToApprove"))); WebGUI::Grouping::isInGroup($self->getValue("groupToApprove")));
my $parentsPage = WebGUI::Page->new($self->get("pageId")); my $parentsPage = WebGUI::Page->new($self->get("pageId"));
my $callback = WebGUI::URL::gateway($parentsPage->get("urlizedTitle"),"func=viewSubmission&amp;wid=".$self->wid."&amp;sid=".$submission->{USS_submissionId}); my $callback = WebGUI::URL::gateway($parentsPage->get("urlizedTitle"),"func=viewSubmission&amp;wid=".$self->wid."&amp;sid=".$submission->{USS_submissionId});
@ -930,7 +930,7 @@ sub www_viewSubmission {
$var{"next.url"} = WebGUI::URL::gateway($nextPage->get("urlizedTitle")); $var{"next.url"} = WebGUI::URL::gateway($nextPage->get("urlizedTitle"));
} }
$var{"next.label"} = WebGUI::International::get(59,$self->get("namespace")); $var{"next.label"} = WebGUI::International::get(59,$self->get("namespace"));
$var{canEdit} = (($submission->{userId} == $session{user}{userId} || WebGUI::Grouping::isInGroup($self->get("groupToApprove"))) && $session{user}{userId} != 1); $var{canEdit} = (($submission->{userId} eq $session{user}{userId} || WebGUI::Grouping::isInGroup($self->get("groupToApprove"))) && $session{user}{userId} != 1);
$var{"delete.url"} = WebGUI::URL::gateway($parentsPage->get("urlizedTitle"),'func=deleteSubmission&wid='.$self->wid.'&sid='.$submissionId); $var{"delete.url"} = WebGUI::URL::gateway($parentsPage->get("urlizedTitle"),'func=deleteSubmission&wid='.$self->wid.'&sid='.$submissionId);
$var{"delete.label"} = WebGUI::International::get(37,$self->get("namespace")); $var{"delete.label"} = WebGUI::International::get(37,$self->get("namespace"));
$var{"edit.url"} = WebGUI::URL::gateway($parentsPage->get("urlizedTitle"),'func=editSubmission&wid='.$self->wid.'&sid='.$submissionId); $var{"edit.url"} = WebGUI::URL::gateway($parentsPage->get("urlizedTitle"),'func=editSubmission&wid='.$self->wid.'&sid='.$submissionId);

View file

@ -22,14 +22,13 @@ sub process {
my $a = WebGUI::SQL->read("select forumId,archiveAfter,masterForumId from forum"); my $a = WebGUI::SQL->read("select forumId,archiveAfter,masterForumId from forum");
while (my $forum = $a->hashRef) { while (my $forum = $a->hashRef) {
if ($forum->{masterForumId}) { if ($forum->{masterForumId}) {
($forum->{archiveAfter}) = WebGUI::SQL->quickArray("select archiveAfter from forum where masterForumId=$forum->{masterForumId}"); ($forum->{archiveAfter}) = WebGUI::SQL->quickArray("select archiveAfter from forum where masterForumId=".quote($forum->{masterForumId}));
} }
my $archiveDate = $epoch - $forum->{archiveAfter}; my $archiveDate = $epoch - $forum->{archiveAfter};
my $b = WebGUI::SQL->read("select forumThreadId from forumThread where forumId=".$forum->{forumId} my $b = WebGUI::SQL->read("select forumThreadId from forumThread where forumId=".quote($forum->{forumId})." and lastPostDate<$archiveDate");
." and lastPostDate<$archiveDate");
while (my ($threadId) = $b->array) { while (my ($threadId) = $b->array) {
WebGUI::SQL->write("update forumPost set status='archived' where status='approved' and forumThreadId=$threadId"); 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=$threadId"); WebGUI::SQL->write("update forumThread set status='archived' where status='approved' and forumThreadId=".quote($threadId));
} }
$b->finish; $b->finish;
} }

View file

@ -23,10 +23,10 @@ sub process {
WebGUI::ErrorHandler::audit("moving expired clipboard items to trash"); WebGUI::ErrorHandler::audit("moving expired clipboard items to trash");
WebGUI::SQL->write("update page set parentId=3, bufferPrevId=2, bufferDate=" .time() WebGUI::SQL->write("update page set parentId=3, bufferPrevId=2, bufferDate=" .WebGUI::DateTime::time()
." where parentId=2 and bufferDate < ". $expireDate ); ." where parentId=2 and bufferDate < ". $expireDate );
WebGUI::SQL->write("update wobject set pageId=3, bufferPrevId=2, bufferDate=" .time() WebGUI::SQL->write("update wobject set pageId=3, bufferPrevId=2, bufferDate=" .WebGUI::DateTime::time()
." where pageId=2 and bufferDate < ". $expireDate ); ." where pageId=2 and bufferDate < ". $expireDate );
} }
} }

View file

@ -23,10 +23,10 @@ sub process {
while (my $data = $sth->hashRef) { while (my $data = $sth->hashRef) {
if ($data->{dbCacheTimeout} > 0) { if ($data->{dbCacheTimeout} > 0) {
# there is no need to wait deleteOffset days for expired external group cache data # there is no need to wait deleteOffset days for expired external group cache data
WebGUI::SQL->write("delete from groupings where groupId=$data->{groupId} and expireDate < ".time()); WebGUI::SQL->write("delete from groupings where groupId=".quote($data->{groupId})." and expireDate < ".WebGUI::DateTime::time());
} else { } else {
WebGUI::SQL->write("delete from groupings where groupId=$data->{groupId} and expireDate < " WebGUI::SQL->write("delete from groupings where groupId=".quote($data->{groupId})." and expireDate < "
.(time()-(86400*$data->{deleteOffset}))); .(WebGUI::DateTime::time()-(86400*$data->{deleteOffset})));
} }
} }
$sth->finish; $sth->finish;

View file

@ -17,7 +17,7 @@ use WebGUI::SQL;
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub process { sub process {
my $epoch = time(); my $epoch = WebGUI::DateTime::time();
my $sth = WebGUI::SQL->read("select sessionId from userSession where expires<".$epoch); my $sth = WebGUI::SQL->read("select sessionId from userSession where expires<".$epoch);
while (my ($sessionId) = $sth->array) { while (my ($sessionId) = $sth->array) {
WebGUI::Session::end($sessionId); WebGUI::Session::end($sessionId);

View file

@ -22,13 +22,13 @@ sub process {
my (%properties, $base, $extended, $b, $w, $cmd, $purgeDate, $a, $pageId); my (%properties, $base, $extended, $b, $w, $cmd, $purgeDate, $a, $pageId);
tie %properties, 'Tie::CPHash'; tie %properties, 'Tie::CPHash';
$purgeDate = (time()-(86400*$session{config}{DeleteExpiredTrash_offset})); $purgeDate = (WebGUI::DateTime::time()-(86400*$session{config}{DeleteExpiredTrash_offset}));
# Delete wobjects # Delete wobjects
$b = WebGUI::SQL->read("select * from wobject where pageId=3 and bufferDate<" . $purgeDate); $b = WebGUI::SQL->read("select * from wobject where pageId=3 and bufferDate<" . $purgeDate);
while ($base = $b->hashRef) { while ($base = $b->hashRef) {
$extended = WebGUI::SQL->quickHashRef("select * from ".$base->{namespace}." $extended = WebGUI::SQL->quickHashRef("select * from ".$base->{namespace}."
where wobjectId=".$base->{wobjectId}); where wobjectId=".quote($base->{wobjectId}));
%properties = (%{$base}, %{$extended}); %properties = (%{$base}, %{$extended});
$cmd = "WebGUI::Wobject::".$properties{namespace}; $cmd = "WebGUI::Wobject::".$properties{namespace};
$w = $cmd->new(\%properties); $w = $cmd->new(\%properties);
@ -44,7 +44,7 @@ sub process {
WebGUI::ErrorHandler::audit("purging expired page ". $pageId ." from trash"); WebGUI::ErrorHandler::audit("purging expired page ". $pageId ." from trash");
WebGUI::Operation::Trash::_recursePageTree($pageId); WebGUI::Operation::Trash::_recursePageTree($pageId);
WebGUI::Operation::Trash::_purgeWobjects($pageId); WebGUI::Operation::Trash::_purgeWobjects($pageId);
WebGUI::SQL->write("delete from page where pageId=$pageId"); WebGUI::SQL->write("delete from page where pageId=".quote($pageId));
} }
$a->finish; $a->finish;
} }

View file

@ -27,7 +27,7 @@ sub process {
while (my $group = $a->hashRef) { while (my $group = $a->hashRef) {
my $start = $now + (86400 * $group->{expireNotifyOffset}); my $start = $now + (86400 * $group->{expireNotifyOffset});
my $end = $start + 86400; my $end = $start + 86400;
my $b = WebGUI::SQL->read("select userId from groupings where groupId=".$group->{groupId}." and my $b = WebGUI::SQL->read("select userId from groupings where groupId=".quote($group->{groupId})." and
expireDate>=".$start." and expireDate<=".$end); expireDate>=".$start." and expireDate<=".$end);
while (my ($userId) = $b->array) { while (my ($userId) = $b->array) {
WebGUI::MessageLog::addEntry($userId,"",WebGUI::International::get(867),$group->{expireNotifyMessage}); WebGUI::MessageLog::addEntry($userId,"",WebGUI::International::get(867),$group->{expireNotifyMessage});