WebGUI 2.4.0 release

This commit is contained in:
JT Smith 2001-11-20 03:49:00 +00:00
parent 2a61818564
commit 6286f9bfaf
74 changed files with 2332 additions and 548 deletions

View file

@ -15,6 +15,7 @@ our $namespace = "MessageBoard";
use strict;
use Tie::CPHash;
use WebGUI::DateTime;
use WebGUI::Discussion;
use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Privilege;
@ -31,28 +32,9 @@ sub _getBoardProperties {
return %board;
}
#-------------------------------------------------------------------
sub _traverseReplyTree {
my ($sth, @data, $html, $depth, $i);
for ($i=0;$i<=$_[1];$i++) {
$depth .= "&nbsp;&nbsp;";
}
$sth = WebGUI::SQL->read("select messageId,subject,username,dateOfPost,userId from message where pid=$_[0] order by messageId", $session{dbh});
while (@data = $sth->array) {
$html .= '<tr';
if ($session{form}{mid} eq $data[0]) {
$html .= ' class="highlight"';
}
$html .= '><td class="tableData">'.$depth.'<a href="'.$session{page}{url}.'?func=showMessage&mid='.$data[0].'&wid='.$session{form}{wid}.'">'.substr($data[1],0,30).'</a></td><td class="tableData"><a href="'.$session{page}{url}.'?op=viewProfile&uid='.$data[4].'">'.$data[2].'</a></td><td class="tableData">'.epochToHuman($data[3],"%M/%D %H:%n%p").'</td></tr>';
$html .= _traverseReplyTree($data[0],$_[1]+1);
}
$sth->finish;
return $html;
}
#-------------------------------------------------------------------
sub purge {
WebGUI::SQL->write("delete from message where widgetId=$_[0]",$_[1]);
WebGUI::SQL->write("delete from discussion where widgetId=$_[0]",$_[1]);
WebGUI::SQL->write("delete from MessageBoard where widgetId=$_[0]",$_[1]);
purgeWidget($_[0],$_[1]);
}
@ -147,26 +129,14 @@ sub www_editSave {
#-------------------------------------------------------------------
sub www_editMessage {
my ($html, %board, %message);
tie %message, 'Tie::CPHash';
my (%board);
tie %board, 'Tie::CPHash';
%board = _getBoardProperties($session{form}{wid});
if (WebGUI::Privilege::isInGroup($board{groupToPost},$session{user}{userId})) {
%message = WebGUI::SQL->quickHash("select * from message where messageId=$session{form}{mid}",$session{dbh});
$html = '<h1>'.WebGUI::International::get(228).'</h1>';
$html .= '<form action="'.$session{page}{url}.'" method="post"><table>';
$html .= WebGUI::Form::hidden("func","editMessageSave");
$html .= WebGUI::Form::hidden("wid",$session{form}{wid});
$html .= WebGUI::Form::hidden("mid",$session{form}{mid});
$html .= '<tr><td class="formDescription">'.WebGUI::International::get(229).'</td><td>'.WebGUI::Form::text("subject",30,255,$message{subject}).'</td></tr>';
$html .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(230).'</td><td>'.WebGUI::Form::textArea("message",$message{message},50,6,1).'</td></tr>';
$html .= '<tr><td></td><td>'.WebGUI::Form::submit(WebGUI::International::get(62)).'</td></tr>';
$html .= '</table></form>';
$html .= www_showMessage();
return WebGUI::Discussion::editMessage();
} else {
$html = WebGUI::Privilege::insufficient();
return WebGUI::Privilege::insufficient();
}
return $html;
}
#-------------------------------------------------------------------
@ -175,14 +145,8 @@ sub www_editMessageSave {
tie %board, 'Tie::CPHash';
%board = _getBoardProperties($session{form}{wid});
if (WebGUI::Privilege::isInGroup($board{groupToPost},$session{user}{userId})) {
if ($session{form}{subject} eq "") {
$session{form}{subject} = WebGUI::International::get(232);
}
if ($session{form}{message} eq "") {
$session{form}{subject} .= ' '.WebGUI::International::get(233);
}
WebGUI::SQL->write("update message set subject=".quote($session{form}{subject}).", message=".quote("\n --- (Edited at ".localtime(time).") --- \n\n".$session{form}{message})." where messageId=$session{form}{mid}",$session{dbh});
return www_showMessage();
WebGUI::Discussion::editMessageSave();
return www_showMessage();
} else {
return WebGUI::Privilege::insufficient();
}
@ -190,39 +154,23 @@ sub www_editMessageSave {
#-------------------------------------------------------------------
sub www_postNewMessage {
my ($html, %board);
my (%board);
tie %board, 'Tie::CPHash';
%board = _getBoardProperties($session{form}{wid});
if (WebGUI::Privilege::isInGroup($board{groupToPost},$session{user}{userId})) {
$html = '<h1>'.WebGUI::International::get(231).'</h1>';
$html .= '<form action="'.$session{page}{url}.'" method="post"><table>';
$html .= WebGUI::Form::hidden("func","postNewMessageSave");
$html .= WebGUI::Form::hidden("wid",$session{form}{wid});
$html .= '<tr><td class="formDescription">'.WebGUI::International::get(229).'</td><td>'.WebGUI::Form::text("subject",30,255).'</td></tr>';
$html .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(230).'</td><td>'.WebGUI::Form::textArea("message",'',50,6,1).'</td></tr>';
$html .= '<tr><td></td><td>'.WebGUI::Form::submit(WebGUI::International::get(62)).'</td></tr>';
$html .= '</table></form>';
return WebGUI::Discussion::postNewMessage();
} else {
$html = WebGUI::Privilege::insufficient();
return WebGUI::Privilege::insufficient();
}
return $html;
}
#-------------------------------------------------------------------
sub www_postNewMessageSave {
my ($mid, %board);
my (%board);
tie %board, 'Tie::CPHash';
%board = _getBoardProperties($session{form}{wid});
if (WebGUI::Privilege::isInGroup($board{groupToPost},$session{user}{userId})) {
if ($session{form}{subject} eq "") {
$session{form}{subject} = WebGUI::International::get(232);
}
if ($session{form}{message} eq "") {
$session{form}{subject} .= ' '.WebGUI::International::get(233);
}
$mid = getNextId("messageId");
WebGUI::SQL->write("insert into message values ($mid, $mid, $session{form}{wid}, 0, $session{user}{userId}, ".quote($session{user}{username}).", ".quote($session{form}{subject}).", ".quote($session{form}{message}).", ".time().")",$session{dbh});
return "";
return WebGUI::Discussion::postNewMessageSave();
} else {
return WebGUI::Privilege::insufficient();
}
@ -230,43 +178,23 @@ sub www_postNewMessageSave {
#-------------------------------------------------------------------
sub www_postReply {
my ($html, %board, $subject);
my (%board);
tie %board, 'Tie::CPHash';
%board = _getBoardProperties($session{form}{wid});
if (WebGUI::Privilege::isInGroup($board{groupToPost},$session{user}{userId})) {
($subject) = WebGUI::SQL->quickArray("select subject from message where messageId=$session{form}{mid}", $session{dbh});
$subject = "Re: ".$subject;
$html = '<h1>'.WebGUI::International::get(234).'</h1>';
$html .= '<form action="'.$session{page}{url}.'" method="post"><table>';
$html .= WebGUI::Form::hidden("func","postReplySave");
$html .= WebGUI::Form::hidden("wid",$session{form}{wid});
$html .= WebGUI::Form::hidden("mid",$session{form}{mid});
$html .= '<tr><td class="formDescription">'.WebGUI::International::get(229).'</td><td>'.WebGUI::Form::text("subject",30,255,$subject).'</td></tr>';
$html .= '<tr><td class="formDescription" valign="top">'.WebGUI::International::get(230).'</td><td>'.WebGUI::Form::textArea("message",'',50,6,1).'</td></tr>';
$html .= '<tr><td></td><td>'.WebGUI::Form::submit(WebGUI::International::get(62)).'</td></tr>';
$html .= '</table></form>';
$html .= www_showMessage();
return WebGUI::Discussion::postReply();
} else {
$html = WebGUI::Privilege::insufficient();
return WebGUI::Privilege::insufficient();
}
return $html;
}
#-------------------------------------------------------------------
sub www_postReplySave {
my ($rid, %board, $mid);
my (%board);
tie %board, 'Tie::CPHash';
%board = _getBoardProperties($session{form}{wid});
if (WebGUI::Privilege::isInGroup($board{groupToPost},$session{user}{userId})) {
if ($session{form}{subject} eq "") {
$session{form}{subject} = WebGUI::International::get(232);
}
if ($session{form}{message} eq "") {
$session{form}{subject} .= ' '.WebGUI::International::get(233);
}
$mid = getNextId("messageId");
($rid) = WebGUI::SQL->quickArray("select rid from message where messageId=$session{form}{mid}",$session{dbh});
WebGUI::SQL->write("insert into message values ($mid, $rid, $session{form}{wid}, $session{form}{mid}, $session{user}{userId}, ".quote($session{user}{username}).", ".quote($session{form}{subject}).", ".quote($session{form}{message}).", ".time().")", $session{dbh});
WebGUI::Discussion::postReplySave();
return www_showMessage();
} else {
return WebGUI::Privilege::insufficient();
@ -278,7 +206,7 @@ sub www_showMessage {
my (@data, $html, %board, %message);
tie %message, 'Tie::CPHash';
tie %board, 'Tie::CPHash';
%message = WebGUI::SQL->quickHash("select * from message where messageId=$session{form}{mid}",$session{dbh});
%message = WebGUI::Discussion::getMessage($session{form}{mid});
%board = _getBoardProperties($session{form}{wid});
$html .= '<h1>'.$message{subject}.'</h1>';
$html .= '<table width="100%" cellpadding=3 cellspacing=1 border=0><tr><td class="tableHeader">';
@ -292,31 +220,30 @@ sub www_showMessage {
$html .= '<a href="'.$session{page}{url}.'?func=editMessage&mid='.$session{form}{mid}.'&wid='.$session{form}{wid}.'">'.WebGUI::International::get(235).'</a><br>';
}
$html .= '<a href="'.$session{page}{url}.'">'.WebGUI::International::get(242).'</a><br>';
@data = WebGUI::SQL->quickArray("select max(messageId) from message where widgetId=$message{widgetId} and pid=0 and messageId<$message{rid}",$session{dbh});
@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 .= '<a href="'.$session{page}{url}.'?func=showMessage&mid='.$data[0].'&wid='.$session{form}{wid}.'">&laquo; '.WebGUI::International::get(241).'</a><br>';
# } else {
# $html .= '&laquo; '.WebGUI::International::get(241).'</a><br>';
}
@data = WebGUI::SQL->quickArray("select min(messageId) from message where widgetId=$message{widgetId} and pid=0 and messageId>$message{rid}",$session{dbh});
@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 .= '<a href="'.$session{page}{url}.'?func=showMessage&mid='.$data[0].'&wid='.$session{form}{wid}.'">'.WebGUI::International::get(243).' &raquo;</a><br>';
# } else {
# $html .= WebGUI::International::get(243).' &raquo;<br>';
}
$html .= '</tr><tr><td class="tableData">';
$message{message} =~ s/\n/\<br\>/g;
$html .= $message{message};
$html .= '</td></tr></table>';
$html .= '<table border=0 cellpadding=2 cellspacing=1 width="100%">';
$html .= '<tr><td class="tableHeader">'.WebGUI::International::get(229).'</td><td class="tableHeader">'.WebGUI::International::get(244).'</td><td class="tableHeader">'.WebGUI::International::get(245).'</td></tr>';
@data = WebGUI::SQL->quickArray("select messageId,subject,username,dateOfPost,userId from message where messageId=$message{rid}",$session{dbh});
@data = WebGUI::SQL->quickArray("select messageId,subject,username,dateOfPost,userId from discussion where messageId=$message{rid}",$session{dbh});
$html .= '<tr';
if ($session{form}{mid} eq $message{rid}) {
$html .= ' class="highlight"';
}
$html .= '><td class="tableData"><a href="'.$session{page}{url}.'?func=showMessage&mid='.$data[0].'&wid='.$message{widgetId}.'">'.substr($data[1],0,30).'</a></td><td class="tableData"><a href="'.$session{page}{url}.'?op=viewProfile&uid='.$data[4].'">'.$data[2].'</a></td><td class="tableData">'.epochToHuman($data[3],"%M/%D %H:%n%p").'</td></tr>';
$html .= _traverseReplyTree($message{rid},1);
$html .= WebGUI::Discussion::traverseReplyTree($message{rid},1);
$html .= "</table>";
return $html;
}
@ -344,12 +271,12 @@ sub www_view {
$html .= '<table width="100%" cellpadding=3 cellspacing=0 border=0><tr><td align="right" valign="bottom" class="tableMenu"><a href="'.$session{page}{url}.'?func=postNewMessage&wid='.$_[0].'">'.WebGUI::International::get(246).'</a></td></tr></table>';
$html .= '<table border=0 cellpadding=2 cellspacing=1 width="100%">';
$html .= '<tr><td class="tableHeader">'.WebGUI::International::get(229).'</td><td class="tableHeader">'.WebGUI::International::get(244).'</td><td class="tableHeader">'.WebGUI::International::get(247).'</td><td class="tableHeader">'.WebGUI::International::get(248).'</td><td class="tableHeader">'.WebGUI::International::get(249).'</td></tr>';
#$sth = WebGUI::SQL->read("select messageId,subject,count(*)-1,username,dateOfPost,max(dateOfPost),max(messageId) from message where widgetId=$_[0] group by rid order by messageId desc", $session{dbh});
$sth = WebGUI::SQL->read("select messageId,subject,username,dateOfPost,userId from message where widgetId=$_[0] and pid=0 order by messageId desc", $session{dbh});
#$sth = WebGUI::SQL->read("select messageId,subject,count(*)-1,username,dateOfPost,max(dateOfPost),max(messageId) from discussion where widgetId=$_[0] group by rid order by messageId desc", $session{dbh});
$sth = WebGUI::SQL->read("select messageId,subject,username,dateOfPost,userId from discussion where widgetId=$_[0] and pid=0 order by messageId desc", $session{dbh});
while (@data = $sth->array) {
if ($i >= ($itemsPerPage*$pn) && $i < ($itemsPerPage*($pn+1))) {
@last = WebGUI::SQL->quickArray("select messageId,dateOfPost,username,subject,userId from message where widgetId=$_[0] and rid=$data[0] order by dateOfPost desc",$session{dbh});
($replies) = WebGUI::SQL->quickArray("select count(*)-1 from message where rid=$data[0]",$session{dbh});
@last = WebGUI::SQL->quickArray("select messageId,dateOfPost,username,subject,userId from discussion where widgetId=$_[0] and rid=$data[0] order by dateOfPost desc",$session{dbh});
($replies) = WebGUI::SQL->quickArray("select count(*)-1 from discussion where rid=$data[0]",$session{dbh});
$html .= '<tr><td class="tableData"><a href="'.$session{page}{url}.'?func=showMessage&mid='.$data[0].'&wid='.$_[0].'">'.substr($data[1],0,30).'</a></td><td class="tableData"><a href="'.$session{page}{url}.'?op=viewProfile&uid='.$data[4].'">'.$data[2].'</a></td><td class="tableData">'.epochToHuman($data[3],"%M/%D %H:%n%p").'</td><td class="tableData">'.$replies.'</td><td class="tableData"><span style="font-size: 8pt;"><a href="'.$session{page}{url}.'?func=showMessage&mid='.$last[0].'&wid='.$_[0].'">'.substr($last[3],0,30).'</a> @ '.epochToHuman($last[1],"%M/%D %H:%n%p").' by <a href="'.$session{page}{url}.'?op=viewProfile&uid='.$last[4].'">'.$last[2].'</a></span></td></tr>';
}
$i++;