How annoying that you can't see the title/subject to which a comment refers. I recall a few other forum posts to the same effect. Well, now you can, with this very easy mod for those with an owned license.
In \includes\functions_comments.php, locate and replace the following two functions:
function renderCommentGrids() PHP Code:
function renderCommentGrids($commenttype)
{
global $_SWIFT, $dbCore, $infomessage;
if ($_GET["do"] == "delete" && !empty($_GET["commentid"]))
{
$infomessage = $_SWIFT["language"]["commentdelconfirm"];
deleteComments(array($_GET["commentid"]));
} else if ($_GET["do"] == "approve" && !empty($_GET["commentid"])) {
$infomessage = $_SWIFT["language"]["commentstatusconfirm"];
approveComments(array($_GET["commentid"]));
} else if ($_GET["do"] == "unapprove" && !empty($_GET["commentid"])) {
$infomessage = $_SWIFT["language"]["commentstatusconfirm"];
unapproveComments(array($_GET["commentid"]));
}
if (!empty($_REQUEST["updatecomment"])) {
$infomessage = sprintf($_SWIFT["language"]["commentupdconfirm"], htmlspecialchars($_REQUEST["updatecomment"]));
}
$commenturl = getCommentURL($commenttype);
$commentslist = array();
$dbCore->query('SELECT * FROM `'. TABLE_PREFIX .'comments` AS comments LEFT JOIN `'. TABLE_PREFIX .'commentdata` AS commentsdata ON (comments.commentid = commentsdata.commentid) WHERE comments.commenttype = \''. intval($commenttype) .'\' AND comments.isapproved = \'0\' ORDER BY comments.dateline ASC;');
while ($dbCore->nextRecord())
{
$commentslist[] = $dbCore->Record;
}
if (count($commentslist))
{
printMainTableHeader($_SWIFT["language"]["unapprovedcomments"]);
$colarray[0]["align"] = "left";
$colarray[0]["nowrap"] = true;
$colarray[0]["value"] = $_SWIFT["language"]["fullname"];
$colarray[1]["align"] = "center";
$colarray[1]["width"] = "200";
$colarray[1]["value"] = $_SWIFT["language"]["email"];
$colarray[2]["align"] = "center";
$colarray[2]["width"] = "160";
$colarray[2]["value"] = $_SWIFT["language"]["date"];
$colarray[3]["align"] = "center";
$colarray[3]["width"] = "70";
$colarray[3]["value"] = "Source";
$colarray[4]["align"] = "left";
$colarray[4]["width"] = "200";
$colarray[4]["value"] = "Article/Item";
$colarray[5]["align"] = "center";
$colarray[5]["width"] = "250";
$colarray[5]["value"] = $_SWIFT["language"]["options"];
printDataRow($colarray, "tabletitlerow");
foreach ($commentslist as $key=>$record)
{
$colarray = array();
$colarray[0]["align"] = "left";
$colarray[0]["value"] = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td width="1" align="left"><img src="'. $_SWIFT["themepath"] .'icon_commentunappr.gif" /></td><td><span class="smalltext"> '.htmlspecialchars($record["fullname"]).'</span></td></tr></table>';
$colarray[1]["align"] = "center";
$colarray[1]["value"] = htmlspecialchars($record["email"]);
$colarray[2]["align"] = "center";
$colarray[2]["value"] = edate($_SWIFT["settings"]["dt_datetimeformat"], $record["dateline"]);
/* MOD: Show comment reference title, with link to reference
by Matthew Arciniega
*/
$colarray[3]["align"] = "center";
$colarray[4]["align"] = "left";
$colarray[4]["nowrap"] = "nowrap";
switch (intval($record["commenttype"])) {
case COMMENT_NEWS:
$colarray[3]["value"] = "News";
$type = "news";
$idstring = "newsid";
$viewitemURL = $_SWIFT["swiftpath"].'staff/index.php?_m=news&_a=editnews&newsid='.$record["typeid"];
$subject = 'subject';
break;
case COMMENT_KNOWLEDGEBASE:
$colarray[3]["value"] = "KB";
$type = "kbarticles";
$idstring = "kbarticleid";
$viewitemURL = 'javascript:popupDataWindow("'.$_SWIFT["swiftpath"].'staff/index.php?_m=knowledgebase&_a=preview&kbarticleid='.$record["typeid"].'")';
$subject = 'subject';
break;
case COMMENT_DOWNLOADS:
$colarray[3]["value"] = "DL";
$type = "downloaditems";
$idstring = "downloaditemid";
$viewitemURL = $_SWIFT["swiftpath"].'staff/index.php?_m=downloads&_a=editfile&downloaditemid='.$record["typeid"];
$subject = 'title';
break;
case COMMENT_TROUBLESHOOTER:
$colarray[3]["value"] = "TS";
$type = "troublshootercat";
$idstring = "troublshootercatid";
$viewitemURL = $_SWIFT["swiftpath"].'staff/index.php?_m=troubleshooter&_a=editcategory&troubleshootercatid='.$record["typeid"];
$subject = 'title';
break;
}
$dbCore->query("
SELECT `".$type."`.`".$subject."`
FROM `". TABLE_PREFIX ."comments` AS `comments`
LEFT JOIN `". TABLE_PREFIX .$type."` AS `".$type."` ON `comments`.`typeid` = `".$type."`.`".$idstring."`
WHERE `".$type."`.`".$idstring."` = '".$record["typeid"]."';
");
while ($dbCore->nextRecord())
{
$colarray[4]["value"] = '<a href="'.$viewitemURL.'" title="View this article/item">'.$dbCore->Record[$subject].'</a>';
}
/* END MOD */
$colarray[5]["align"] = "center";
$colarray[5]["value"] = '<a href="'.$commenturl.'&do=approve&commentid='. $record["commentid"] .'" title="'. $_SWIFT["language"]["edit"] .'"><img src="'. $_SWIFT["themepath"] .'icon_approvecomment.gif" border="0"> '. $_SWIFT["language"]["approve"] .'</a> <a href="index.php?_m=core&_a=editcomment&commentid='. $record["commentid"] .'" title="'. $_SWIFT["language"]["edit"] .'"><img src="'. $_SWIFT["themepath"] .'icon_edit.gif" border="0"> '. $_SWIFT["language"]["edit"] .'</a> <a onClick="javascript:doConfirm(\''. $_SWIFT["language"]["actionconfirm"] .'\', \''. $commenturl .'&do=delete&commentid='. $record["commentid"] .'\');" href="#" title="'. $_SWIFT["language"]["delete"] .'"><img src="'. $_SWIFT["themepath"] .'icon_delete.gif" border="0"> '. $_SWIFT["language"]["delete"] .'</a> ';
printDataRow($colarray);
$colarray = array();
$colarray[0]["align"] = "left";
$colarray[0]["colspan"] = "6";
$colarray[0]["value"] = nl2br(htmlspecialchars($record["contents"]));
printDataRow($colarray);
}
printMainTableFooter();
echo "<BR />";
}
$options["recordsperpage"] = "5";
$options["sortby"] = "comments.dateline";
$options["sortorder"] = "desc";
$options["massaction"][0]["title"] = $_SWIFT["language"]["delete"];
$options["massaction"][0]["callback"] = "_maDeleteComments";
$options["massaction"][1]["title"] = $_SWIFT["language"]["unapprove"];
$options["massaction"][1]["callback"] = "_maUnapproveComments";
$options["idname"] = "commentid";
$options["quicksearch"] = true;
$options["advancedsearch"][0]["title"] = $_SWIFT["language"]["fullname"];
$options["advancedsearch"][0]["query"] = 'SELECT * FROM `'. TABLE_PREFIX .'comments` AS comments WHERE comments.fullname LIKE \'%$_searchstr%\' AND `commenttype` = \''. intval($commenttype) .'\' AND `isapproved` = \'1\' $_sortjoin;';
$options["advancedsearch"][1]["title"] = $_SWIFT["language"]["email"];
$options["advancedsearch"][1]["query"] = 'SELECT * FROM `'. TABLE_PREFIX .'comments` AS comments WHERE comments.email LIKE \'%$_searchstr%\' AND `commenttype` = \''. intval($commenttype) .'\' AND `isapproved` = \'1\' $_sortjoin;';
$options["advancedsearch"][2]["title"] = $_SWIFT["language"]["contents"];
$options["advancedsearch"][2]["query"] = 'SELECT * FROM `'. TABLE_PREFIX .'comments` AS comments LEFT JOIN `'. TABLE_PREFIX .'commentdata` AS commentdata ON (comments.commentid = commentdata.commentid) WHERE comments.fullname LIKE \'%$_searchstr%\' AND `commenttype` = \''. intval($commenttype) .'\' AND `isapproved` = \'1\' $_sortjoin;';
$options["callback"] = "_commentFields";
$fields[0]["name"] = "comments.fullname";
$fields[0]["title"] = $_SWIFT["language"]["fullname"];
$fields[0]["width"] = "";
$fields[0]["nowrap"] = "nowrap";
$fields[1]["name"] = "comments.email";
$fields[1]["title"] = $_SWIFT["language"]["email"];
$fields[1]["width"] = "200";
$fields[1]["align"] = "center";
$fields[1]["nowrap"] = "nowrap";
$fields[2]["name"] = "comments.dateline";
$fields[2]["title"] = $_SWIFT["language"]["date"];
$fields[2]["width"] = "160";
$fields[2]["align"] = "center";
/* MOD: Show comment reference title, with link to reference
by Matthew Arciniega
*/
$fields[3]["name"] = "comments.type";
$fields[3]["title"] = "Source";
$fields[3]["width"] = "70";
$fields[3]["align"] = "center";
$fields[3]["type"] = "custom";
$fields[4]["name"] = "comments.item";
$fields[4]["title"] = "Article/Item";
$fields[4]["width"] = "";
$fields[4]["align"] = "left";
$fields[4]["nowrap"] = "nowrap";
$fields[4]["type"] = "custom";
/* END MOD */
$fields[5]["type"] = "custom";
$fields[5]["name"] = "options";
$fields[5]["title"] = $_SWIFT["language"]["options"];
$fields[5]["width"] = "250";
$fields[5]["align"] = "center";
$grid = new Grid();
$grid->start("comments", $_SWIFT["language"]["approvedcomments"], '
SELECT * FROM `'. TABLE_PREFIX .'comments` AS comments
WHERE `commenttype` = \''. intval($commenttype) .'\'
AND `isapproved` = \'1\' $_sortjoin;
', '
SELECT COUNT(*) AS totalitems FROM `'. TABLE_PREFIX .'comments`
WHERE `commenttype` = \''. intval($commenttype) .'\'
AND `isapproved` = \'1\';
', '
SELECT * FROM `'. TABLE_PREFIX .'comments` AS comments
LEFT JOIN `'. TABLE_PREFIX .'commentdata` AS commentdata
ON (comments.commentid = commentdata.commentid)
WHERE comments.fullname LIKE \'%$_searchstr%\'
AND `commenttype` = \''. intval($commenttype) .'\'
AND `isapproved` = \'1\' $_sortjoin;', $fields, $options);
global $infomessage;
printInfoBox($infomessage);
printErrorBox($errormessage);
$grid->display("comments");
echo '<BR /><span class="smalltext">'. $_SWIFT["language"]["legend"] .' <img src="'. $_SWIFT["themepath"] .'icon_commentunappr.gif" border="0" /> '. $_SWIFT["language"]["unapprovedcomments"].'</span>';
}
function _commentFields() PHP Code:
function _commentFields($arg)
{
global $_SWIFT, $dbCore;
$record = &$arg[0];
$fields = &$arg[1];
$commenturl = getCommentURL($record["commenttype"]);
$record["comments.dateline"] = edate($_SWIFT["settings"]["dt_datetimeformat"], $record["dateline"]);
$record["comments.fullname"] = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><span class="smalltext"> '.htmlspecialchars($record["fullname"]).'</span></td></tr></table>';
$record["comments.email"] = htmlspecialchars($record["email"]);
/* MOD: Show comment reference title, with link to reference
by Matthew Arciniega
*/
switch (intval($record["commenttype"])) {
case COMMENT_NEWS:
$record["comments.type"] = "News";
$type = "news";
$idstring = "newsid";
$viewitemURL = $_SWIFT["swiftpath"].'staff/index.php?_m=news&_a=editnews&newsid='.$record["typeid"];
$subject = 'subject';
break;
case COMMENT_KNOWLEDGEBASE:
$record["comments.type"] = "KB";
$type = "kbarticles";
$idstring = "kbarticleid";
$viewitemURL = 'javascript:popupDataWindow("'.$_SWIFT["swiftpath"].'staff/index.php?_m=knowledgebase&_a=preview&kbarticleid='.$record["typeid"].'")';
$subject = 'subject';
break;
case COMMENT_DOWNLOADS:
$record["comments.type"] = "DL";
$type = "downloaditems";
$idstring = "downloaditemid";
$viewitemURL = $_SWIFT["swiftpath"].'staff/index.php?_m=downloads&_a=editfile&downloaditemid='.$record["typeid"];
$subject = 'title';
break;
case COMMENT_TROUBLESHOOTER:
$record["comments.type"] = "TS";
$type = "troublshootercat";
$idstring = "troublshootercatid";
$viewitemURL = $_SWIFT["swiftpath"].'staff/index.php?_m=troubleshooter&_a=editcategory&troubleshootercatid='.$record["typeid"];
$subject = 'tile';
break;
}
$dbCore->query("
SELECT `".$type."`.`".$subject."`
FROM `". TABLE_PREFIX ."comments` AS `comments`
LEFT JOIN `". TABLE_PREFIX .$type."` AS `".$type."` ON `comments`.`typeid` = `".$type."`.`".$idstring."`
WHERE `".$type."`.`".$idstring."` = '".$record["typeid"]."';
");
while ($dbCore->nextRecord())
{
$record["comments.item"] = '<a href="'.$viewitemURL.'" title="View this article/item">'.$dbCore->Record[$subject].'</a>';
}
/* END MOD */
$record["options"] = '<a href="'.$commenturl.'&do=unapprove&commentid='. $record["commentid"] .'" title="'. $_SWIFT["language"]["edit"] .'"><img src="'. $_SWIFT["themepath"] .'icon_unapprovecomment.gif" border="0"> '. $_SWIFT["language"]["unapprove"] .'</a> <a href="index.php?_m=core&_a=editcomment&commentid='. $record["commentid"] .'" title="'. $_SWIFT["language"]["edit"] .'"><img src="'. $_SWIFT["themepath"] .'icon_edit.gif" border="0"> '. $_SWIFT["language"]["edit"] .'</a> <a onClick="javascript:doConfirm(\''. $_SWIFT["language"]["actionconfirm"] .'\', \''. $commenturl .'&do=delete&commentid='. $record["commentid"] .'\');" href="#" title="'. $_SWIFT["language"]["delete"] .'"><img src="'. $_SWIFT["themepath"] .'icon_delete.gif" border="0"> '. $_SWIFT["language"]["delete"] .'</a> ';
return $record;
}
There's code duplication which I could have avoided, by exporting to a special function, but it didn't seem worth the bother.
This has only been test with my well-modded v3.20.02, but I believe it will work fine with newer v3.x releases.