# $Id: phorum-article-feedback.code.txt,v 1.3 2003-07-21 20:18:55 dan Exp $
# Copyright (c) 1998-2003 DVL Software Limited
#
# Dan Langille - supporting php code for phorum article comments
#
# Use this code as you see fit, but retain the above notices.
# start of configuration items
#
# Set the following items appropriate to your situation
#
# the name of the table in question
#
$commentTableName = "article_feedback";
$Forum_ID = 3;
#
# end of configuration items
function diary_BannerForum($ForumName, $article_id) {
#
# create a header for the forum...
#
GLOBAL $diary_nocomments;
echo '
';
if ($article_id) {
diary_BannerSection($ForumName . ' - ' . comment_LinkToArticle($article_id, $DB));
} else {
diary_BannerSection($ForumName);
}
echo '
';
}
function comment_ShowArticleCommentCount($commentTableName, $Forum_ID, $ArticleID, $db) {
#
# show how many comments there are on this article
#
#
# note that this function
$sql = "select count(*) as count
from $commentTableName"."_xref
where article_id = $ArticleID";
# echo "comment_ShowArticleCommentCount sql = $sql";
$result = mysql_query($sql, $db) or die("comment count query failed: " . mysql_error());
$myrow = mysql_fetch_array($result);
echo 'This article has ';
switch ($myrow["count"]) {
case 0:
echo 'no comments.';
break;
case 1:
echo 'one comment.';
break;
default:
echo $myrow["count"] . ' comments';
}
if ($myrow["count"] > 0) {
# when was the last comment?
#
# to be written...
}
echo " [ read";
echo " | write ]";
echo ' |
';
}
function comment_LinkToArticle($ArticleID) {
GLOBAL $q;
GLOBAL $DB;
#
# you may have to customize this function
#
# create the URL needed to link back to the article. Include the article
# name in the link.
# This function will mostly likely require customization for each website
# as the article filename and title fetch method will be unique.
#
$sql = "select filename, name
from articles
where id = $ArticleID";
$q->query($DB, $sql);
$myrow = $q->getrow();
$link = '' . $myrow["name"] . '';
return $link;
}
?>