migrated message board
This commit is contained in:
parent
949ea2d6cf
commit
3aaac188f8
6 changed files with 149 additions and 420 deletions
|
|
@ -237,6 +237,7 @@ WebGUI::SQL->write("drop table forumPostAttachment");
|
|||
WebGUI::SQL->write("drop table forumSubscription");
|
||||
WebGUI::SQL->write("drop table forumThread");
|
||||
WebGUI::SQL->write("drop table forumThreadSubscription");
|
||||
WebGUI::SQL->write("drop table MessageBoard_forums");
|
||||
|
||||
# start migrating non-wobject stuff into assets
|
||||
my %migration;
|
||||
|
|
@ -829,6 +830,7 @@ print "\tDeleting files which are no longer used.\n" unless ($quiet);
|
|||
#rmtree("../../lib/DBIx/Tree");
|
||||
#unlink("../../lib/WebGUI/Help/WobjectProxy.pm");
|
||||
#unlink("../../lib/WebGUI/i18n/English/WobjectProxy.pm");
|
||||
#unlink("../../lib/WebGUI/Wobject/MessageBoard.pm");
|
||||
#unlink("../../lib/WebGUI/Wobject/WobjectProxy.pm");
|
||||
#rmtree("../../www/extras/wobject/WobjectProxy");
|
||||
|
||||
|
|
@ -866,6 +868,7 @@ $conf->set("assets"=>[
|
|||
'WebGUI::Asset::Wobject::Survey',
|
||||
'WebGUI::Asset::Wobject::Product',
|
||||
'WebGUI::Asset::Wobject::Collaboration',
|
||||
'WebGUI::Asset::Wobject::MessageBoard',
|
||||
'WebGUI::Asset::Redirect',
|
||||
'WebGUI::Asset::Template',
|
||||
'WebGUI::Asset::FilePile',
|
||||
|
|
@ -1074,8 +1077,8 @@ sub walkTree {
|
|||
print "\t\t\tMigrating forum for Article ".$wobject->{wobjectId}."\n" unless ($quiet);
|
||||
$rank++;
|
||||
migrateForum($wobject->{forumId},$pageId,$pageLineage,$rank, $wobject->{title},$wobject->{description},
|
||||
$wobject->{startDate}, $wobject->{endDate}, $wobject->{ownerId}, $wobject->{groupIdView},
|
||||
$wobject->{groupIdView},$page->{styleId}, $page->{printableStyleId});
|
||||
$wobject->{startDate}, $wobject->{endDate}, $wobject->{ownerId}, $wobject->{groupIdEdit},
|
||||
$page->{styleId}, $page->{printableStyleId});
|
||||
}
|
||||
rmtree($session{config}{uploadsPath}.'/'.$wobject->{wobjectId});
|
||||
} elsif ($wobject->{namespace} eq "SiteMap") {
|
||||
|
|
@ -1212,7 +1215,15 @@ sub walkTree {
|
|||
WebGUI::SQL->write("update WobjectProxy set description=".quote($wobject->{description})." where
|
||||
assetId=".quote($wobjectId));
|
||||
} elsif ($wobject->{namespace} eq "MessageBoard") {
|
||||
# migrate forums
|
||||
my $forums = WebGUI::SQL->read("select forumId, title, description from MessageBoard_forums where wobjectId=".quote($wobject->{wobjectId})." order by sequenceNumber");
|
||||
my $i = 1;
|
||||
while (my ($fid, $title, $desc) = $forums->array) {
|
||||
migrateForum($fid,$wobjectId,$wobjectLineage,$i, $title,$desc,
|
||||
$wobject->{startDate}, $wobject->{endDate}, $wobject->{ownerId}, $wobject->{groupIdEdit},
|
||||
$page->{styleId}, $page->{printableStyleId});
|
||||
$i++;
|
||||
}
|
||||
$forums->finish;
|
||||
} elsif (isIn($wobject->{namespace}, qw(DataForm Poll))) {
|
||||
print "\t\t\tMigrating wobject collateral data\n" unless ($quiet);
|
||||
foreach my $table (qw(DataForm_entry DataForm_entryData DataForm_field DataForm_tab Poll_answer)) {
|
||||
|
|
@ -1261,7 +1272,6 @@ sub migrateForum {
|
|||
my $startDate = shift;
|
||||
my $endDate = shift;
|
||||
my $userId = shift;
|
||||
my $viewGroup = shift;
|
||||
my $editGroup = shift;
|
||||
my $styleId = shift;
|
||||
my $printId = shift;
|
||||
|
|
@ -1291,6 +1301,7 @@ sub migrateForum {
|
|||
$data->{postsPerPage} = $master->{postsPerPage};
|
||||
$data->{usePreview} = $master->{usePreview};
|
||||
}
|
||||
my $viewGroup = $data->{groupToView};
|
||||
my $newId = WebGUI::SQL->setRow("asset","assetId",{
|
||||
assetId=>"new",
|
||||
parentId=>$newParentId,
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ assets = WebGUI::Asset::File::Image, \
|
|||
WebGUI::Asset::Wobject::Article, \
|
||||
WebGUI::Asset::Wobject::Navigation, \
|
||||
WebGUI::Asset::Wobject::Survey, \
|
||||
WebGUI::Asset::Wobject::MessageBoard, \
|
||||
WebGUI::Asset::FilePile
|
||||
|
||||
assetContainers = WebGUI::Asset::Wobject::Layout, \
|
||||
|
|
|
|||
132
lib/WebGUI/Asset/Wobject/MessageBoard.pm
Normal file
132
lib/WebGUI/Asset/Wobject/MessageBoard.pm
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
package WebGUI::Asset::Wobject::MessageBoard;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2005 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Asset::Wobject;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
||||
our @ISA = qw(WebGUI::Asset::Wobject);
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $definition = shift;
|
||||
push(@{$definition}, {
|
||||
tableName=>'MessageBoard',
|
||||
className=>'WebGUI::Asset::Wobject::MessageBoard',
|
||||
properties=>{
|
||||
templateId =>{
|
||||
fieldType=>"template",
|
||||
defaultValue=>'PBtmpl0000000000000047'
|
||||
},
|
||||
}
|
||||
});
|
||||
return $class->SUPER::definition($definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getEditForm {
|
||||
my $self = shift;
|
||||
my $tabform = $self->SUPER::getEditForm();
|
||||
$tabform->getTab("display")->template(
|
||||
-value=>$self->getValue('templateId'),
|
||||
-namespace=>"MessageBoard"
|
||||
);
|
||||
return $tabform;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getName {
|
||||
return WebGUI::International::get(2,"MessageBoard");
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub view {
|
||||
my $self = shift;
|
||||
my %var;
|
||||
my $count = 1;
|
||||
my @forum_loop;
|
||||
my $children = $self->getLineage(["children"],{includeOnlyClasses=>["WebGUI::Asset::Wobject::Collaboration"]});
|
||||
foreach my $child (@{$children}) {
|
||||
next unless ($child->canView);
|
||||
if ($count == 1) {
|
||||
$var{'default.listing'} = $child->view;
|
||||
$var{'default.description'} = $child->get("description");
|
||||
$var{'default.title'} = $child->get("title");
|
||||
$var{'default.controls'} = $child->getToolbar;
|
||||
}
|
||||
my %lastPostVars;
|
||||
my $lastPost = WebGUI::Asset::Wobject::MessageBoard->newByDynamicClass($child->get("lastPostId"));
|
||||
if (defined $lastPost) {
|
||||
%lastPostVars = (
|
||||
'forum.lastPost.url' => $lastPost->getUrl,
|
||||
'forum.lastPost.date' => WebGUI::DateTime::epochToHuman($lastPost->get("dateSubmitted"),"%z"),
|
||||
'forum.lastPost.time' => WebGUI::DateTime::epochToHuman($lastPost->get("dateSubmitted"),"%z"),
|
||||
'forum.lastPost.epoch' => $lastPost->get("dateSubmitted"),
|
||||
'forum.lastPost.subject' => $lastPost->get("title"),
|
||||
'forum.lastPost.user.id' => $lastPost->get("ownerUserId"),
|
||||
'forum.lastPost.user.name' => $lastPost->get("username"),
|
||||
'forum.lastPost.user.alias' => $lastPost->get("username"),
|
||||
'forum.lastPost.user.profile' => $lastPost->getPosterProfileUrl,
|
||||
'forum.lastPost.user.isVisitor' => ($lastPost->get("ownerUserId") eq '1')
|
||||
);
|
||||
}
|
||||
push(@forum_loop, {
|
||||
%lastPostVars,
|
||||
'forum.controls' => $child->getToolbar,
|
||||
'forum.count' => $count,
|
||||
'forum.title' => $child->get('title'),
|
||||
'forum.description' => $child->get("description"),
|
||||
'forum.replies' => $child->get("replies"),
|
||||
'forum.rating' => $child->get("rating"),
|
||||
'forum.views' => $child->get("views"),
|
||||
'forum.threads' => $child->get("threads"),
|
||||
'forum.url' => $child->getUrl,
|
||||
'forum.user.canView' => $child->canView,
|
||||
'forum.user.canPost' => $child->canPost
|
||||
});
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
$var{'forum.add.url'} = $self->getUrl("func=add&class=WebGUI::Asset::Wobject::Collaboration");
|
||||
$var{'forum.add.label'} = WebGUI::International::get(75,"MessageBoard");
|
||||
$var{'title.label'} = WebGUI::International::get(99);
|
||||
$var{'views.label'} = WebGUI::International::get(514);
|
||||
$var{'rating.label'} = WebGUI::International::get(1020);
|
||||
$var{'threads.label'} = WebGUI::International::get(1036);
|
||||
$var{'replies.label'} = WebGUI::International::get(1016);
|
||||
$var{'lastpost.label'} = WebGUI::International::get(1017);
|
||||
$var{areMultipleForums} = ($count > 2);
|
||||
$var{forum_loop} = \@forum_loop;
|
||||
return $self->processTemplate(\%var,$self->get("templateId"));
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
my $self = shift;
|
||||
return $self->getAdminConsole->render(WebGUI::Privilege::insufficient()) unless $self->canEdit;
|
||||
$self->getAdminConsole->setHelp("message board add/edit");
|
||||
return $self->getAdminConsole->render($self->getEditForm->print,WebGUI::International::get("6","MessageBoard"));
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
||||
|
|
@ -5,10 +5,6 @@ our $HELP = {
|
|||
title => '61',
|
||||
body => '71',
|
||||
related => [
|
||||
{
|
||||
tag => 'forum add/edit',
|
||||
namespace => 'MessageBoard'
|
||||
},
|
||||
{
|
||||
tag => 'message board template',
|
||||
namespace => 'MessageBoard'
|
||||
|
|
@ -23,54 +19,12 @@ our $HELP = {
|
|||
title => '73',
|
||||
body => '74',
|
||||
related => [
|
||||
{
|
||||
tag => 'forum notification template',
|
||||
namespace => 'WebGUI'
|
||||
},
|
||||
{
|
||||
tag => 'forum post form template',
|
||||
namespace => 'WebGUI'
|
||||
},
|
||||
{
|
||||
tag => 'forum post template',
|
||||
namespace => 'WebGUI'
|
||||
},
|
||||
{
|
||||
tag => 'forum search template',
|
||||
namespace => 'WebGUI'
|
||||
},
|
||||
{
|
||||
tag => 'forum template',
|
||||
namespace => 'WebGUI'
|
||||
},
|
||||
{
|
||||
tag => 'forum thread template',
|
||||
namespace => 'WebGUI'
|
||||
},
|
||||
{
|
||||
tag => 'message board add/edit',
|
||||
namespace => 'MessageBoard'
|
||||
},
|
||||
{
|
||||
tag => 'wobject template',
|
||||
namespace => 'WebGUI'
|
||||
}
|
||||
]
|
||||
},
|
||||
'forum add/edit' => {
|
||||
title => '78',
|
||||
body => '79',
|
||||
related => [
|
||||
{
|
||||
tag => 'forum discussion properties',
|
||||
namespace => 'WebGUI'
|
||||
},
|
||||
{
|
||||
tag => 'message board add/edit',
|
||||
namespace => 'MessageBoard'
|
||||
}
|
||||
]
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -1,330 +0,0 @@
|
|||
package WebGUI::Wobject::MessageBoard;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2005 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use Tie::CPHash;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::Forum;
|
||||
use WebGUI::Forum::UI;
|
||||
use WebGUI::HTML;
|
||||
use WebGUI::HTMLForm;
|
||||
use WebGUI::Icon;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::URL;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Wobject;
|
||||
use WebGUI::User;
|
||||
|
||||
our @ISA = qw(WebGUI::Wobject);
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _formatControls {
|
||||
my $controls = deleteIcon("func=deleteForumConfirm&wid=".$_[0]->get("wobjectId")."&forumId=".$_[1],'',
|
||||
WebGUI::International::get(76,$_[0]->get("namespace")))
|
||||
.editIcon("func=editForum&wid=".$_[0]->get("wobjectId")."&forumId=".$_[1])
|
||||
.moveUpIcon("func=moveForumUp&wid=".$_[0]->get("wobjectId")."&forumId=".$_[1])
|
||||
.moveDownIcon("func=moveForumDown&wid=".$_[0]->get("wobjectId")."&forumId=".$_[1]);
|
||||
return $controls;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getIndexerParams {
|
||||
my $self = shift;
|
||||
my $now = shift;
|
||||
return {
|
||||
MessageBoard => {
|
||||
sql => "select MessageBoard_forums.title,
|
||||
MessageBoard_forums.description,
|
||||
MessageBoard_forums.wobjectId as wid,
|
||||
wobject.namespace as namespace,
|
||||
wobject.addedBy as ownerId,
|
||||
page.urlizedTitle as urlizedTitle,
|
||||
page.languageId as languageId,
|
||||
page.pageId as pageId,
|
||||
page.groupIdView as page_groupIdView,
|
||||
wobject.groupIdView as wobject_groupIdView,
|
||||
7 as wobject_special_groupIdView
|
||||
from MessageBoard_forums, wobject, page
|
||||
where MessageBoard_forums.wobjectId = wobject.wobjectId
|
||||
and wobject.pageId = page.pageId
|
||||
and wobject.startDate < $now
|
||||
and wobject.endDate > $now
|
||||
and page.startDate < $now
|
||||
and page.endDate > $now",
|
||||
fieldsToIndex => ["title", "description"],
|
||||
contentType => 'wobject',
|
||||
url => '$data{urlizedTitle}."#".$data{wid}',
|
||||
headerShortcut => 'select title from MessageBoard_forums where wobjectId = \'$data{wid}\'',
|
||||
bodyShortcut => 'select description from MessageBoard_forums where wobjectId = \'$data{wid}\'',
|
||||
},
|
||||
MessageBoard_Forum => {
|
||||
sql => "select forumPost.forumPostId,
|
||||
forumPost.username,
|
||||
forumPost.subject,
|
||||
forumPost.message,
|
||||
forumPost.userId as ownerId,
|
||||
forumThread.forumId as forumId,
|
||||
MessageBoard_forums.wobjectId,
|
||||
wobject.namespace as namespace,
|
||||
wobject.wobjectId as wid,
|
||||
page.urlizedTitle as urlizedTitle,
|
||||
page.languageId as languageId,
|
||||
page.pageId as pageId,
|
||||
page.groupIdView as page_groupIdView,
|
||||
wobject.groupIdView as wobject_groupIdView,
|
||||
forum.groupToView as wobject_special_groupIdView
|
||||
from forum, forumPost, forumThread, MessageBoard_forums, wobject, page
|
||||
where forumPost.forumThreadId = forumThread.forumThreadId
|
||||
and forumThread.forumId = MessageBoard_forums.forumId
|
||||
and forumThread.forumId = forum.forumId
|
||||
and MessageBoard_forums.wobjectId = wobject.wobjectId
|
||||
and wobject.pageId = page.pageId
|
||||
and wobject.startDate < $now
|
||||
and wobject.endDate > $now
|
||||
and page.startDate < $now
|
||||
and page.endDate > $now",
|
||||
fieldsToIndex => ["username", "subject", "message"],
|
||||
contentType => 'discussion',
|
||||
url => 'WebGUI::URL::append($data{urlizedTitle},"func=view&wid=$data{wid}&forumOp=viewThread&forumPostId=$data{forumPostId}&forumId=$data{forumId}")',
|
||||
headerShortcut => 'select subject from forumPost where forumPostId = \'$data{forumPostId}\'',
|
||||
bodyShortcut => 'select message from forumPost where forumPostId = \'$data{forumPostId}\'',
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub name {
|
||||
return WebGUI::International::get(2,$_[0]->get("namespace"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $property = shift;
|
||||
my $self = WebGUI::Wobject->new(
|
||||
-properties=>$property,
|
||||
-useTemplate=>1,
|
||||
-useMetaData=>1
|
||||
);
|
||||
bless $self, $class;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub purge {
|
||||
my $sth = WebGUI::SQL->read("select forumId from MessageBoard_forums where wobjectId=".quote($_[0]->get("wobjectId")));
|
||||
while (my ($forumId) = $sth->array) {
|
||||
my ($inUseElsewhere) = WebGUI::SQL->quickArray("select count(*) from MessageBoard_forums where forumId=".quote($forumId));
|
||||
unless ($inUseElsewhere > 1) {
|
||||
my $forum = WebGUI::Forum->new($forumId);
|
||||
$forum->purge;
|
||||
}
|
||||
}
|
||||
$sth->finish;
|
||||
WebGUI::SQL->write("delete from MessageBoard_forums where wobjectId=".quote($_[0]->get("wobjectId")));
|
||||
$_[0]->SUPER::purge();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteForumConfirm {
|
||||
return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit);
|
||||
my ($inUseElsewhere) = WebGUI::SQL->quickArray("select count(*) from MessageBoard_forums where forumId=".quote($session{form}{forumId}));
|
||||
unless ($inUseElsewhere > 1) {
|
||||
my $forum = WebGUI::Forum->new($session{form}{forumId});
|
||||
$forum->purge;
|
||||
}
|
||||
WebGUI::SQL->write("delete from MessageBoard_forums where forumId=".quote($session{form}{forumId})." and wobjectId=".quote($_[0]->get("wobjectId")));
|
||||
return "";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_edit {
|
||||
my $properties = WebGUI::HTMLForm->new;
|
||||
return $_[0]->SUPER::www_edit(
|
||||
-properties=>$properties->printRowsOnly,
|
||||
-headingId=>6,
|
||||
-helpId=>"message board add/edit"
|
||||
);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editForum {
|
||||
return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit);
|
||||
my $forumMeta;
|
||||
if ($session{form}{forumId} ne "new") {
|
||||
$forumMeta = WebGUI::SQL->quickHashRef("select title,description from MessageBoard_forums where forumId=".quote($session{form}{forumId}));
|
||||
}
|
||||
my $forum = WebGUI::Forum->new($session{form}{forumId});
|
||||
my $f = WebGUI::HTMLForm->new;
|
||||
$f->hidden(
|
||||
-name=>"wid",
|
||||
-value=>$_[0]->get("wobjectId")
|
||||
);
|
||||
$f->hidden(
|
||||
-name=>"func",
|
||||
-value=>"editForumSave"
|
||||
);
|
||||
$f->text(
|
||||
-name=>"title",
|
||||
-value=>$forumMeta->{title},
|
||||
-label=>WebGUI::International::get(99)
|
||||
);
|
||||
$f->HTMLArea(
|
||||
-name=>"description",
|
||||
-value=>$forumMeta->{description},
|
||||
-label=>WebGUI::International::get(85)
|
||||
);
|
||||
$f->raw(WebGUI::Forum::UI::forumProperties($forum->get("forumId")));
|
||||
if($session{form}{forumId} ne "new"){
|
||||
my ($sth, $data, %MBoards);
|
||||
tie %MBoards, "Tie::IxHash";
|
||||
$MBoards{0} = WebGUI::International::get(92, $_[0]->get("namespace"));
|
||||
$sth = WebGUI::SQL->read("SELECT wobject.wobjectId, wobject.title as wobjectTitle, page.title as pageTitle FROM wobject LEFT JOIN page using(pageId) WHERE wobject.namespace='MessageBoard' and page.pageId NOT IN ('2','3','4','5') AND wobject.wobjectId!=".quote($_[0]->get("wobjectId"))." order by page.title ASC");
|
||||
while ($data = $sth->hashRef){
|
||||
$MBoards{$data->{wobjectId}} = $data->{pageTitle}." - ".$data->{wobjectTitle};
|
||||
}
|
||||
$f->selectList(
|
||||
-name=>"toMBoardId",
|
||||
-label=>WebGUI::International::get(90, $_[0]->get("namespace")),
|
||||
-subtext=>WebGUI::International::get(91, $_[0]->get("namespace")),
|
||||
-options=>\%MBoards,
|
||||
-value=>[$session{form}{toMBoardId}]
|
||||
);
|
||||
}
|
||||
|
||||
$f->submit;
|
||||
return $_[0]->adminConsole($f->print,'77','forum add/edit');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editForumSave {
|
||||
return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit);
|
||||
my $forumId = WebGUI::Forum::UI::forumPropertiesSave();
|
||||
if ($session{form}{forumId} eq "new") {
|
||||
my ($seq) = WebGUI::SQL->quickArray("select max(sequenceNumber) from MessageBoard_forums where wobjectId=".quote($_[0]->get("wobjectId")));
|
||||
$seq++;
|
||||
WebGUI::SQL->write("insert into MessageBoard_forums (wobjectId, forumId, title, description, sequenceNumber) values ("
|
||||
.quote($_[0]->get("wobjectId")).", ".quote($forumId).", ".quote($session{form}{title}).", ".quote($session{form}{description})
|
||||
.", ".$seq.")");
|
||||
}elsif($session{form}{toMBoardId} ne 0){
|
||||
# WebGUI::SQL->write("update MessageBoard_forums set wobjectId=".quote($session{form}{toMBoardId})." where forumId=".quote($forumId)." and wobjectId=".quote($_[0]->get("wobjectId")));
|
||||
WebGUI::SQL->write("update MessageBoard_forums set wobjectId=".quote($session{form}{toMBoardId}).", title=".quote($session{form}{title}).", description="
|
||||
.quote($session{form}{description})." where forumId=".quote($forumId)." and wobjectId=".quote($_[0]->get("wobjectId")));
|
||||
|
||||
}else{
|
||||
WebGUI::SQL->write("update MessageBoard_forums set title=".quote($session{form}{title}).", description="
|
||||
.quote($session{form}{description})." where forumId=".quote($forumId)." and wobjectId=".quote($_[0]->get("wobjectId")));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_moveForumDown {
|
||||
return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit);
|
||||
$_[0]->moveCollateralDown("MessageBoard_forums","forumId",$session{form}{forumId});
|
||||
return "";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_moveForumUp {
|
||||
return WebGUI::Privilege::insufficient() unless ($_[0]->canEdit);
|
||||
$_[0]->moveCollateralUp("MessageBoard_forums","forumId",$session{form}{forumId});
|
||||
return "";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
$_[0]->logView() if ($session{setting}{passiveProfilingEnabled});
|
||||
my %var;
|
||||
my $count = 1;
|
||||
my @forum_loop;
|
||||
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")."&forumId=".$forumMeta->{forumId});
|
||||
if ($session{form}{forumOp}) {
|
||||
if ($session{form}{forumId} eq $forumMeta->{forumId}) {
|
||||
$caller = {
|
||||
callback=>$callback,
|
||||
title=>$forumMeta->{title},
|
||||
description=>$forumMeta->{description},
|
||||
forumId=>$forumMeta->{forumId}
|
||||
};
|
||||
}
|
||||
} else {
|
||||
my $forum = WebGUI::Forum->new($forumMeta->{forumId});
|
||||
next unless ($forum->canView);
|
||||
if ($count == 1) {
|
||||
$var{'default.listing'} = WebGUI::Forum::UI::www_viewForum({
|
||||
callback=>$callback,
|
||||
title=>$forumMeta->{title},
|
||||
description=>$forumMeta->{description},
|
||||
forumId=>$forumMeta->{forumId}
|
||||
},$forumMeta->{forumId});
|
||||
$var{'default.description'} = $forumMeta->{description};
|
||||
$var{'default.title'} = $forumMeta->{title};
|
||||
$var{'default.controls'} = $_[0]->_formatControls($forum->get("forumId"));
|
||||
}
|
||||
my $lastPost = WebGUI::Forum::Post->new($forum->get("lastPostId"));
|
||||
push(@forum_loop, {
|
||||
'forum.controls' => $_[0]->_formatControls($forum->get("forumId")),
|
||||
'forum.count' => $count,
|
||||
'forum.title' => $forumMeta->{title},
|
||||
'forum.description' => $forumMeta->{description},
|
||||
'forum.replies' => $forum->get("replies"),
|
||||
'forum.rating' => $forum->get("rating"),
|
||||
'forum.views' => $forum->get("views"),
|
||||
'forum.threads' => $forum->get("threads"),
|
||||
'forum.url' => WebGUI::Forum::UI::formatForumURL($callback,$forum->get("forumId")),
|
||||
'forum.lastPost.url' => WebGUI::Forum::UI::formatThreadURL($callback,$lastPost->get("forumPostId")),
|
||||
'forum.lastPost.date' => WebGUI::Forum::UI::formatPostDate($lastPost->get("dateOfPost")),
|
||||
'forum.lastPost.time' => WebGUI::Forum::UI::formatPostTime($lastPost->get("dateOfPost")),
|
||||
'forum.lastPost.epoch' => $lastPost->get("dateOfPost"),
|
||||
'forum.lastPost.subject' => $lastPost->get("subject"),
|
||||
'forum.lastPost.user.id' => $lastPost->get("userId"),
|
||||
'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") eq 1),
|
||||
'forum.user.canView' => $forum->canView,
|
||||
'forum.user.canPost' => $forum->canPost
|
||||
});
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
$sth->finish;
|
||||
if ($session{form}{forumOp}) {
|
||||
return WebGUI::Forum::UI::forumOp($caller);
|
||||
} else {
|
||||
$var{title} = $_[0]->get("title");
|
||||
$var{description} = $_[0]->get("description");
|
||||
$var{'forum.add.url'} = WebGUI::URL::page("func=editForum&forumId=new&wid=".$_[0]->get("wobjectId"));
|
||||
$var{'forum.add.label'} = WebGUI::International::get(75,$_[0]->get("namespace"));
|
||||
$var{'title.label'} = WebGUI::International::get(99);
|
||||
$var{'views.label'} = WebGUI::International::get(514);
|
||||
$var{'rating.label'} = WebGUI::International::get(1020);
|
||||
$var{'threads.label'} = WebGUI::International::get(1036);
|
||||
$var{'replies.label'} = WebGUI::International::get(1016);
|
||||
$var{'lastpost.label'} = WebGUI::International::get(1017);
|
||||
$var{areMultipleForums} = ($count > 2);
|
||||
$var{forum_loop} = \@forum_loop;
|
||||
return $_[0]->processTemplate($_[0]->get("templateId"),\%var);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
@ -177,38 +177,11 @@ A conditional indicating whether there is more than one forum.
|
|||
lastUpdated => 1066584548
|
||||
},
|
||||
|
||||
'78' => {
|
||||
message => q|Forum, Add/Edit|,
|
||||
lastUpdated => 1066584480
|
||||
},
|
||||
|
||||
'2' => {
|
||||
message => q|Message Board|,
|
||||
lastUpdated => 1031514049
|
||||
},
|
||||
|
||||
'79' => {
|
||||
message => q|A message board can contain one or more forums. The following is the list of properties attached to each forum.
|
||||
|
||||
<p>
|
||||
|
||||
<b>Title</b><br>
|
||||
The title of the forum.
|
||||
<p>
|
||||
|
||||
<b>Description</b><br>
|
||||
The description of the forum.
|
||||
<p>
|
||||
|
||||
|,
|
||||
lastUpdated => 1100231810
|
||||
},
|
||||
|
||||
'77' => {
|
||||
message => q|Edit Forum|,
|
||||
lastUpdated => 1066061199
|
||||
},
|
||||
|
||||
'73' => {
|
||||
message => q|Message Board Template|,
|
||||
lastUpdated => 1066584179
|
||||
|
|
@ -217,18 +190,6 @@ The description of the forum.
|
|||
'76' => {
|
||||
message => q|Are you certain you wish to delete this forum and all the posts it contains?|,
|
||||
lastUpdated => 1066055963
|
||||
},
|
||||
'90' => {
|
||||
message => q|Move Forum|,
|
||||
lastUpdated =>1093435103
|
||||
},
|
||||
'91' => {
|
||||
message => q|<br>Select the Message Board you want to move the forum to.|,
|
||||
lastUpdated =>1093435103
|
||||
},
|
||||
'92' => {
|
||||
message => q|--- No Change ---|,
|
||||
lastUpdated =>1093435103
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue