lots of bug fixes
This commit is contained in:
parent
fd0413c746
commit
b4498138fb
12 changed files with 67 additions and 45 deletions
|
|
@ -81,7 +81,7 @@ The unique identifier to check privileges against. Defaults to the current user.
|
|||
sub canEdit {
|
||||
my ($self, $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"))));
|
||||
}
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ sub canView {
|
|||
return 1;
|
||||
} elsif ($self->get("status") eq "deleted") {
|
||||
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;
|
||||
} elsif ($self->getThread->getForum->isModerator) {
|
||||
return 1;
|
||||
|
|
@ -231,7 +231,7 @@ If the user ID equals 1 (visitor) then an IP address is used to distinguish the
|
|||
sub hasRated {
|
||||
my ($self, $userId, $ipAddress) = @_;
|
||||
$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);
|
||||
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
|
||||
|
|
@ -434,7 +434,7 @@ Sets the status of this post to approved.
|
|||
sub setStatusApproved {
|
||||
my ($self) = @_;
|
||||
$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) {
|
||||
$self->getThread->incrementReplies($self->get("dateOfPost"),$self->get("forumPostId"));
|
||||
}
|
||||
|
|
@ -452,7 +452,7 @@ Sets the status of this post to archived.
|
|||
sub setStatusArchived {
|
||||
my ($self) = @_;
|
||||
$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) {
|
||||
$self->getThread->incrementReplies($self->get("dateOfPost"),$self->get("forumPostId"));
|
||||
}
|
||||
|
|
@ -470,7 +470,7 @@ sub setStatusDeleted {
|
|||
my ($self) = @_;
|
||||
$self->set({status=>'deleted'});
|
||||
$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="
|
||||
.quote($self->get("forumThreadId"))." and status='approved'");
|
||||
$self->getThread->setLastPost($date,$id);
|
||||
|
|
@ -487,7 +487,7 @@ Sets the status of this post to denied.
|
|||
sub setStatusDenied {
|
||||
my ($self) = @_;
|
||||
$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 {
|
||||
my ($self) = @_;
|
||||
$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"));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1162,7 +1162,7 @@ sub getForumTemplateVars {
|
|||
foreach my $thread (@$threads) {
|
||||
my $root = WebGUI::Forum::Post->new($thread->{rootPostId});
|
||||
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;
|
||||
} else {
|
||||
$last = WebGUI::Forum::Post->new($thread->{lastPostId});
|
||||
|
|
@ -1418,12 +1418,12 @@ sub notifySubscribers {
|
|||
my %subscribers;
|
||||
my $sth = WebGUI::SQL->read("select userId from forumThreadSubscription where forumThreadId=".quote($thread->get("forumThreadId")));
|
||||
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 = WebGUI::SQL->read("select userId from forumSubscription where forumId=".quote($forum->get("forumId")));
|
||||
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;
|
||||
my %lang;
|
||||
|
|
@ -1569,7 +1569,7 @@ A post object.
|
|||
sub setPostApproved {
|
||||
my ($caller, $post) = @_;
|
||||
$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);
|
||||
}
|
||||
notifySubscribers($post,$post->getThread,$post->getThread->getForum,$caller);
|
||||
|
|
@ -2504,7 +2504,7 @@ sub www_viewThread {
|
|||
my $post = WebGUI::Forum::Post->new($postId);
|
||||
return WebGUI::Privilege::insufficient() unless ($post->getThread->getForum->canView);
|
||||
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"));
|
||||
} else {
|
||||
return WebGUI::Template::process($post->getThread->getForum->get("threadTemplateId"),"Forum/Thread", $var);
|
||||
|
|
|
|||
|
|
@ -261,9 +261,9 @@ sub www_view {
|
|||
my $caller;
|
||||
my $sth = WebGUI::SQL->read("select * from MessageBoard_forums where wobjectId=".quote($_[0]->get("wobjectId"))." order by sequenceNumber");
|
||||
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}{forumId} == $forumMeta->{forumId}) {
|
||||
if ($session{form}{forumId} eq $forumMeta->{forumId}) {
|
||||
$caller = {
|
||||
callback=>$callback,
|
||||
title=>$forumMeta->{title},
|
||||
|
|
@ -305,7 +305,7 @@ sub www_view {
|
|||
'forum.lastPost.user.name' => $lastPost->get("username"),
|
||||
'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.isVisitor' => ($lastPost->get("userId") == 1),
|
||||
'forum.lastPost.user.isVisitor' => ($lastPost->get("userId") eq 1),
|
||||
'forum.user.canView' => $forum->canView,
|
||||
'forum.user.canPost' => $forum->canPost
|
||||
});
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@ use WebGUI::Session;
|
|||
use WebGUI::Wobject;
|
||||
use XML::RSSLite;
|
||||
use LWP::UserAgent;
|
||||
use WebGUI::ErrorHandler;
|
||||
my $hasEncode=1;
|
||||
eval " use Encode qw(from_to); "; $hasEncode=0 if $@;
|
||||
|
||||
our @ISA = qw(WebGUI::Wobject);
|
||||
|
||||
|
|
@ -44,7 +47,8 @@ sub new {
|
|||
rssUrl=>{},
|
||||
maxHeadlines=>{},
|
||||
},
|
||||
-useTemplate=>1
|
||||
-useTemplate=>1,
|
||||
-useMetaData=>1
|
||||
);
|
||||
bless $self, $class;
|
||||
}
|
||||
|
|
@ -181,11 +185,24 @@ sub _get_rss_data {
|
|||
my $ua = LWP::UserAgent->new(timeout => 5);
|
||||
my $response = $ua->get($url);
|
||||
if (!$response->is_success()) {
|
||||
warn("Error retrieving url '$url': " .
|
||||
WebGUI::ErrorHandler::warn("Error retrieving url '$url': " .
|
||||
$response->status_line());
|
||||
return undef;
|
||||
}
|
||||
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
|
||||
# commenting this out. -hal
|
||||
|
|
@ -197,7 +214,7 @@ sub _get_rss_data {
|
|||
XML::RSSLite::parseXML($rss_lite, \$xml);
|
||||
};
|
||||
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
|
||||
|
|
@ -208,10 +225,10 @@ sub _get_rss_data {
|
|||
$rss_lite = {channel => $rss_lite};
|
||||
if (!($rss->{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?$/))) {
|
||||
warn("unable to find item info for url $url");
|
||||
WebGUI::ErrorHandler::warn("unable to find item info for url $url");
|
||||
$rss->{items} = [];
|
||||
}
|
||||
|
||||
|
|
@ -329,6 +346,7 @@ sub _view_single_feed {
|
|||
}
|
||||
|
||||
sub www_view {
|
||||
$_[0]->logView() if ($session{setting}{passiveProfilingEnabled});
|
||||
my $maxHeadlines = $_[0]->get("maxHeadlines") || 1000000;
|
||||
|
||||
my @urls = split(/\s+/,$_[0]->get("rssUrl"));
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ sub www_copy {
|
|||
#-------------------------------------------------------------------
|
||||
sub www_deleteFile {
|
||||
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",{
|
||||
$session{form}{file}=>'',
|
||||
USS_submissionId=>$session{form}{sid}
|
||||
|
|
@ -284,7 +284,7 @@ sub www_deleteFile {
|
|||
#-------------------------------------------------------------------
|
||||
sub www_deleteSubmission {
|
||||
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")),
|
||||
WebGUI::URL::page('func=deleteSubmissionConfirm&wid='.$session{form}{wid}.'&sid='.$session{form}{sid}));
|
||||
} else {
|
||||
|
|
@ -295,7 +295,7 @@ sub www_deleteSubmission {
|
|||
#-------------------------------------------------------------------
|
||||
sub www_deleteSubmissionConfirm {
|
||||
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));
|
||||
unless ($inUseElsewhere > 1) {
|
||||
my $forum = WebGUI::Forum->new($forumId);
|
||||
|
|
@ -425,7 +425,7 @@ sub www_editSubmission {
|
|||
$var{'submission.isNew'} = 1;
|
||||
}
|
||||
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")));
|
||||
$var{'link.header.label'} = WebGUI::International::get(90,$_[0]->get("namespace"));
|
||||
$var{'question.header.label'} = WebGUI::International::get(84,$_[0]->get("namespace"));
|
||||
|
|
@ -600,7 +600,7 @@ sub www_editSubmission {
|
|||
sub www_editSubmissionSave {
|
||||
my ($submission, %hash, $file, $u);
|
||||
$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"
|
||||
&& WebGUI::Grouping::isInGroup($_[0]->get("groupToContribute")))
|
||||
|| WebGUI::Grouping::isInGroup($_[0]->get("groupToApprove"))) {
|
||||
|
|
@ -794,7 +794,7 @@ sub www_view {
|
|||
"submission.image"=>$imageURL,
|
||||
"submission.date"=>epochToHuman($page->[$i]->{dateSubmitted}),
|
||||
"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.edit.url"=>WebGUI::URL::page($quickurl.'editSubmission'),
|
||||
"submission.secondColumn"=>(($i+1)%2==0),
|
||||
|
|
@ -877,7 +877,7 @@ sub www_viewSubmission {
|
|||
my $submission = $self->getCollateral("USS_submission","USS_submissionId",$submissionId);
|
||||
return "" unless ($submission->{USS_submissionId});
|
||||
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")));
|
||||
my $parentsPage = WebGUI::Page->new($self->get("pageId"));
|
||||
my $callback = WebGUI::URL::gateway($parentsPage->get("urlizedTitle"),"func=viewSubmission&wid=".$self->wid."&sid=".$submission->{USS_submissionId});
|
||||
|
|
@ -930,7 +930,7 @@ sub www_viewSubmission {
|
|||
$var{"next.url"} = WebGUI::URL::gateway($nextPage->get("urlizedTitle"));
|
||||
}
|
||||
$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.label"} = WebGUI::International::get(37,$self->get("namespace"));
|
||||
$var{"edit.url"} = WebGUI::URL::gateway($parentsPage->get("urlizedTitle"),'func=editSubmission&wid='.$self->wid.'&sid='.$submissionId);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue