package WebGUI::Widget::MessageBoard;
our $namespace = "MessageBoard";
#-------------------------------------------------------------------
# WebGUI is Copyright 2001 Plain Black Software.
#-------------------------------------------------------------------
# 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::Discussion;
use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
use WebGUI::Widget;
#-------------------------------------------------------------------
sub _getBoardProperties {
my (%board);
tie %board, 'Tie::CPHash';
%board = WebGUI::SQL->quickHash("select * from widget, MessageBoard where widget.widgetId=MessageBoard.widgetId and widget.widgetId=$_[0]",$session{dbh});
return %board;
}
#-------------------------------------------------------------------
sub purge {
WebGUI::SQL->write("delete from discussion where widgetId=$_[0]",$_[1]);
WebGUI::SQL->write("delete from MessageBoard where widgetId=$_[0]",$_[1]);
purgeWidget($_[0],$_[1]);
}
#-------------------------------------------------------------------
sub widgetName {
return WebGUI::International::get(223);
}
#-------------------------------------------------------------------
sub www_add {
my ($output, %hash, @array);
tie %hash, "Tie::IxHash";
if (WebGUI::Privilege::canEditPage()) {
$output = '
';
$output .= '
';
$output .= '| ';
$html .= ''.WebGUI::International::get(238).' '.$message{username}.' '; $html .= "".WebGUI::International::get(239)." ".epochToHuman($message{dateOfPost},"%w, %c %D, %y at %H:%n%p")." "; $html .= "".WebGUI::International::get(240)." ".$message{widgetId}."-".$message{rid}."-".$message{pid}."-".$message{messageId}." "; $html .= ' | ';
$html .= '';
$html .= ''.WebGUI::International::get(236).' '; if ((time()-$message{dateOfPost}) < 3600*$board{editTimeout} && $message{'userId'} eq $session{user}{userId}) { $html .= ''.WebGUI::International::get(235).' '; } $html .= ''.WebGUI::International::get(242).' '; @data = WebGUI::SQL->quickArray("select max(messageId) from discussion where widgetId=$message{widgetId} and pid=0 and messageId<$message{rid}",$session{dbh}); if ($data[0] ne "") { $html .= '« '.WebGUI::International::get(241).' '; # } else { # $html .= '« '.WebGUI::International::get(241).' '; } @data = WebGUI::SQL->quickArray("select min(messageId) from discussion where widgetId=$message{widgetId} and pid=0 and messageId>$message{rid}",$session{dbh}); if ($data[0] ne "") { $html .= ''.WebGUI::International::get(243).' » '; # } else { # $html .= WebGUI::International::get(243).' » '; } $html .= ' |
| '; $html .= $message{message}; $html .= ' |
| '.WebGUI::International::get(229).' | '.WebGUI::International::get(244).' | '.WebGUI::International::get(245).' |
| '.$data[2].' | '.epochToHuman($data[3],"%M/%D %H:%n%p").' |
'; } if ($board{processMacros}) { $html = WebGUI::Macro::process($html); } $html .= '
| '.WebGUI::International::get(246).' |
| '.WebGUI::International::get(229).' | '.WebGUI::International::get(244).' | '.WebGUI::International::get(247).' | '.WebGUI::International::get(248).' | '.WebGUI::International::get(249).' |
| '.substr($data[1],0,30).' | '.$data[2].' | '.epochToHuman($data[3],"%M/%D %H:%n%p").' | '.$replies.' | '.substr($last[3],0,30).' @ '.epochToHuman($last[1],"%M/%D %H:%n%p").' by '.$last[2].' |