updating discussion
This commit is contained in:
parent
4b66502e4c
commit
44b35c3412
4 changed files with 82 additions and 9 deletions
|
|
@ -159,4 +159,5 @@ delete from international where languageId=1 and namespace='WebGUI' and internat
|
|||
insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1018,1,'WebGUI','Start a new thread.', 1065279960,'Add a new line of discussion to a forum.');
|
||||
delete from international where languageId=1 and namespace='WebGUI' and internationalId=1020;
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated,context) values (1020,1,'WebGUI','Rating', 1065280882,'How useful/interesting a user thinks another poster\'s post is.');
|
||||
alter table forumThread add column status varchar(30) not null default 'approved';
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,13 @@ sub addView {
|
|||
$self->getThread->addView;
|
||||
}
|
||||
|
||||
sub canEdit {
|
||||
my ($self, $userId) = @_;
|
||||
$userId = $session{user}{userId} unless ($userId);
|
||||
return ($self->getThread->getForum->isModerator || ($self->get("userId") == $userId && $userId != 1
|
||||
&& $self->getThread->getForum->get("editTimeout") < (WebGUI::DateTime::time() - $self->get("dateOfPost"))));
|
||||
}
|
||||
|
||||
sub create {
|
||||
my ($self, $data) = @_;
|
||||
$data->{dateOfPost} = WebGUI::DateTime::time();
|
||||
|
|
@ -54,6 +61,7 @@ sub getThread {
|
|||
sub incrementViews {
|
||||
my ($self) = @_;
|
||||
WebGUI::SQL->write("update forumPost set views=views+1 where forumPostId=".$self->get("forumPostId"));
|
||||
$self->getThread->incrementViews;
|
||||
}
|
||||
|
||||
sub isMarkedRead {
|
||||
|
|
@ -89,16 +97,25 @@ sub set {
|
|||
sub setStatusApproved {
|
||||
my ($self) = @_;
|
||||
$self->set({status=>'approved'});
|
||||
$self->getThread->setStatusApproved if ($self->getThread->get("rootPostId") == $self->get("forumPostId"));
|
||||
}
|
||||
|
||||
sub setStatusDeleted {
|
||||
my ($self) = @_;
|
||||
$self->set({status=>'deleted'});
|
||||
$self->getThread->setStatusDeleted if ($self->getThread->get("rootPostId") == $self->get("forumPostId"));
|
||||
}
|
||||
|
||||
sub setStatusDenied {
|
||||
my ($self) = @_;
|
||||
$self->set({status=>'denied'});
|
||||
$self->getThread->setStatusDenied if ($self->getThread->get("rootPostId") == $self->get("forumPostId"));
|
||||
}
|
||||
|
||||
sub setStatusPending {
|
||||
my ($self) = @_;
|
||||
$self->set({status=>'pending'});
|
||||
$self->getThread->setStatusPending if ($self->getThread->get("rootPostId") == $self->get("forumPostId"));
|
||||
}
|
||||
|
||||
sub unmarkRead {
|
||||
|
|
|
|||
|
|
@ -82,6 +82,11 @@ sub isLocked {
|
|||
return $self->get("isLocked");
|
||||
}
|
||||
|
||||
sub incrementViews {
|
||||
my ($self) = @_;
|
||||
WebGUI::SQL->write("update forumThread set views=views+1 where forumThreadId=".$self->get("forumThreadId"));
|
||||
}
|
||||
|
||||
sub isSticky {
|
||||
my ($self) = @_;
|
||||
return $self->get("isSticky");
|
||||
|
|
@ -100,11 +105,6 @@ sub lock {
|
|||
$self->set({isLocked=>1});
|
||||
}
|
||||
|
||||
sub stick {
|
||||
my ($self) = @_;
|
||||
$self->set({isSticky=>1});
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, $forumThreadId) = @_;
|
||||
my $properties = WebGUI::SQL->getRow("forumThread","forumThreadId",$forumThreadId);
|
||||
|
|
@ -122,6 +122,31 @@ sub set {
|
|||
$self->{_properties} = $data;
|
||||
}
|
||||
|
||||
sub setStatusApproved {
|
||||
my ($self) = @_;
|
||||
$self->set({status=>'approved'});
|
||||
}
|
||||
|
||||
sub setStatusDeleted {
|
||||
my ($self) = @_;
|
||||
$self->set({status=>'deleted'});
|
||||
}
|
||||
|
||||
sub setStatusDenied {
|
||||
my ($self) = @_;
|
||||
$self->set({status=>'denied'});
|
||||
}
|
||||
|
||||
sub setStatusPending {
|
||||
my ($self) = @_;
|
||||
$self->set({status=>'pending'});
|
||||
}
|
||||
|
||||
sub stick {
|
||||
my ($self) = @_;
|
||||
$self->set({isSticky=>1});
|
||||
}
|
||||
|
||||
sub subscribe {
|
||||
my ($self, $userId) = @_;
|
||||
$userId = $session{user}{userId} unless ($userId);
|
||||
|
|
|
|||
|
|
@ -101,8 +101,7 @@ sub _getPostTemplateVars {
|
|||
$var->{'post.status.label'} = WebGUI::International::get(553);
|
||||
$var->{'post.isLocked'} = $thread->isLocked;
|
||||
$var->{'post.isModerator'} = $forum->isModerator;
|
||||
$var->{'post.canEdit'} = ($forum->isModerator || ($post->get("userId") == $session{user}{userId}
|
||||
&& $session{user}{userId} != 1 && $forum->get("editTimeout") < (WebGUI::DateTime::time()-$post->get("dateOfPost"))));
|
||||
$var->{'post.canEdit'} = $post->canEdit($session{user}{userId});
|
||||
$var->{'post.user.isVisitor'} = ($post->get("userId") == 1);
|
||||
$var->{'post.user.label'} = WebGUI::International::get(244);
|
||||
$var->{'post.user.name'} = $post->get("username");
|
||||
|
|
@ -202,9 +201,40 @@ sub viewForum {
|
|||
return WebGUI::Template::process(WebGUI::Template::get(1,"Forum"), \%var);
|
||||
}
|
||||
|
||||
sub www_deleteThread {
|
||||
sub www_approvePost {
|
||||
my ($callback) = @_;
|
||||
|
||||
my $post = WebGUI::Forum::Post->new($session{form}{forumPostId});
|
||||
return WebGUI::Privilege::insufficient() unless ($post->getThread->getForum->isModerator);
|
||||
$post->setStatusApproved;
|
||||
return www_viewThread($callback);
|
||||
}
|
||||
|
||||
sub www_deletePost {
|
||||
my ($callback) = @_;
|
||||
my $post = WebGUI::Forum::Post->new($session{form}{forumPostId});
|
||||
return WebGUI::Privilege::insufficient() unless ($post->canEdit);
|
||||
my $output = '<h1>'.WebGUI::International::get(42).'</h1>';
|
||||
$output .= WebGUI::International::get(401).'<p>';
|
||||
$output .= '<div align="center"><a href="'.WebGUI::URL::append($callback,"forumOp=deletePostConfirm&forumPostId="
|
||||
.$session{form}{forumPostId}).'">'.WebGUI::International::get(44).'</a>';
|
||||
$output .= ' <a href="'.$callback.'">'.WebGUI::International::get(45).'</a></div>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
sub www_deletePostConfirm {
|
||||
my ($callback) = @_;
|
||||
my $post = WebGUI::Forum::Post->new($session{form}{forumPostId});
|
||||
return WebGUI::Privilege::insufficient() unless ($post->getThread->getForum->isModerator);
|
||||
$post->setStatusDeleted;
|
||||
return viewForum($callback,$post->getThread->get("forumId"));
|
||||
}
|
||||
|
||||
sub www_denyPost {
|
||||
my ($callback) = @_;
|
||||
my $post = WebGUI::Forum::Post->new($session{form}{forumPostId});
|
||||
return WebGUI::Privilege::insufficient() unless ($post->canEdit($session{user}{userId}));
|
||||
$post->setStatusDenied;
|
||||
return www_viewThread($callback);
|
||||
}
|
||||
|
||||
sub www_nextThread {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue