Added a "views" counter to discussions and user submissions.

This commit is contained in:
JT Smith 2002-05-29 02:13:42 +00:00
parent 30999c9982
commit 057b523210
4 changed files with 37 additions and 23 deletions

View file

@ -187,7 +187,7 @@ sub www_showMessage {
#-------------------------------------------------------------------
sub www_view {
my ($sth, @data, $html, $i, $pn, $lastId, @last, $replies);
my ($sth, %data, $html, $i, $pn, $lastId, @last, $replies);
if ($session{form}{pn} < 1) {
$pn = 0;
} else {
@ -204,26 +204,29 @@ sub www_view {
$html .= '<tr><td class="tableHeader">'.WebGUI::International::get(229).'</td>
<td class="tableHeader">'.WebGUI::International::get(15,$namespace).'</td>
<td class="tableHeader">'.WebGUI::International::get(18,$namespace).'</td>
<td class="tableHeader">'.WebGUI::International::get(514).'</td>
<td class="tableHeader">'.WebGUI::International::get(19,$namespace).'</td>
<td class="tableHeader">'.WebGUI::International::get(20,$namespace).'</td></tr>';
$sth = WebGUI::SQL->read("select messageId,subject,username,dateOfPost,userId
$sth = WebGUI::SQL->read("select messageId,subject,username,dateOfPost,userId,views
from discussion where wobjectId=".$_[0]->get("wobjectId")." and pid=0 order by messageId desc");
while (@data = $sth->array) {
$data[1] = WebGUI::HTML::filter($data[1],'all');
while (%data = $sth->hash) {
$data{subject} = WebGUI::Discussion::formatSubject($data{subject});
if ($i >= ($_[0]->get("messagesPerPage")*$pn) && $i < ($_[0]->get("messagesPerPage")*($pn+1))) {
@last = WebGUI::SQL->quickArray("select messageId,dateOfPost,username,subject,userId
from discussion where wobjectId=".$_[0]->get("wobjectId")." and rid=$data[0] order by dateOfPost desc");
from discussion where wobjectId=".$_[0]->get("wobjectId")." and rid=$data{messageId} order by dateOfPost desc");
$last[3] = WebGUI::HTML::filter($last[3],'all');
($replies) = WebGUI::SQL->quickArray("select count(*) from discussion where rid=$data[0]");
$replies -= 1;
($replies) = WebGUI::SQL->quickArray("select count(*) from discussion where rid=$data{messageId}");
$replies--;
$html .= '<tr><td class="tableData"><a
href="'.WebGUI::URL::page('func=showMessage&mid='.$data[0].'&wid='.$_[0]->get("wobjectId"))
.'">'.substr($data[1],0,30).'</a></td>
<td class="tableData"><a href="'.WebGUI::URL::page('op=viewProfile&uid='.$data[4]).'">'.$data[2].'</a></td>
<td class="tableData">'.epochToHuman($data[3],"%z %Z").'</td>
href="'.WebGUI::URL::page('func=showMessage&mid='.$data{messageId}.'&wid='.$_[0]->get("wobjectId"))
.'">'.substr($data{subject},0,30).'</a></td>
<td class="tableData"><a href="'.WebGUI::URL::page('op=viewProfile&uid='.$data{userId}).'">'.$data{username}.'</a></td>
<td class="tableData">'.epochToHuman($data{dateOfPost},"%z %Z").'</td>
<td class="tableData">'.$data{views}.'</td>
<td class="tableData">'.$replies.'</td>
<td class="tableData"><span style="font-size: 8pt;"><a
href="'.WebGUI::URL::page('func=showMessage&mid='.$last[0].'&wid='.$_[0]->get("wobjectId")).'">'.substr($last[3],0,30).'</a>
href="'.WebGUI::URL::page('func=showMessage&mid='.$last[0].'&wid='.$_[0]->get("wobjectId")).'">'
.substr($last[3],0,30).'</a>
@ '.epochToHuman($last[1],"%z %Z").' by <a href="'.WebGUI::URL::page('op=viewProfile&uid='.$last[4]).'">'.$last[2].'</a>
</span></td></tr>';
}

View file

@ -559,6 +559,7 @@ sub www_view {
sub www_viewSubmission {
my ($output, %submission, $file, $replies);
tie %submission, 'Tie::CPHash';
WebGUI::SQL->write("update UserSubmission_submission set views=views+1 where submissionId=$session{form}{sid}");
%submission = WebGUI::SQL->quickHash("select * from UserSubmission_submission where submissionId=$session{form}{sid}");
$submission{title} = WebGUI::HTML::filter($submission{title},'all');
$submission{content} = WebGUI::HTML::filter($submission{content},$session{setting}{filterContributedHTML});
@ -570,7 +571,8 @@ sub www_viewSubmission {
$output .= '<b>'.WebGUI::International::get(22,$namespace).'</b> <a href="'.
WebGUI::URL::page('op=viewProfile&uid='.$submission{userId}).'">'.$submission{username}.'</a><br>';
$output .= '<b>'.WebGUI::International::get(23,$namespace).'</b> '.epochToHuman($submission{dateSubmitted},"%z %Z")."<br>";
$output .= '<b>'.WebGUI::International::get(14,$namespace).':</b> '.$submissionStatus{$submission{status}};
$output .= '<b>'.WebGUI::International::get(14,$namespace).':</b> '.$submissionStatus{$submission{status}}.'<br>';
$output .= '<b>'.WebGUI::International::get(514).':</b> '.$submission{views}.'<br>';
$output .= '</td><td rowspan="2" class="tableMenu" nowrap valign="top">';
#---menu
if ($submission{userId} == $session{user}{userId} && WebGUI::Privilege::isInGroup($_[0]->get("groupToApprove"))) {