Kayako logo
Modifications & Extensions Modifications, extensions and guides for your Kayako help desk software.


Kayako develops robust helpdesk software, live chat and real-time visitor monitoring software.
Kayako is trusted by more than 30,000 organizations, including a number of Fortune 500 companies and government institutions.
Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  (#1) Old
Matthew Offline
Member
 
Matthew's Avatar
 
Posts: 270
Join Date: Oct 2007
Location: Jakarta, Indonesia
Show item/article title (with link) in Comments table - 12-06-2009, 10:26 AM

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">&nbsp;'.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(&quot;'.$_SWIFT["swiftpath"].'staff/index.php?_m=knowledgebase&_a=preview&kbarticleid='.$record["typeid"].'&quot;)';
                    
$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">&nbsp;'$_SWIFT["language"]["approve"] .'</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="index.php?_m=core&_a=editcomment&commentid='$record["commentid"] .'" title="'$_SWIFT["language"]["edit"] .'"><img src="'$_SWIFT["themepath"] .'icon_edit.gif" border="0">&nbsp;'$_SWIFT["language"]["edit"] .'</a>&nbsp;&nbsp;&nbsp;&nbsp;<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">&nbsp;'$_SWIFT["language"]["delete"] .'</a>&nbsp;';
            
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">&nbsp;'.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(&quot;'.$_SWIFT["swiftpath"].'staff/index.php?_m=knowledgebase&_a=preview&kbarticleid='.$record["typeid"].'&quot;)';
            
$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">&nbsp;'$_SWIFT["language"]["unapprove"] .'</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="index.php?_m=core&_a=editcomment&commentid='$record["commentid"] .'" title="'$_SWIFT["language"]["edit"] .'"><img src="'$_SWIFT["themepath"] .'icon_edit.gif" border="0">&nbsp;'$_SWIFT["language"]["edit"] .'</a>&nbsp;&nbsp;&nbsp;&nbsp;<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">&nbsp;'$_SWIFT["language"]["delete"] .'</a>&nbsp;';

    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.
Attached Images
File Type: png kbcomments1.png (47.1 KB, 41 views)


Matthew Arciniega
Free: Ticket List & Search | Dept. Display Names
Free: Outlook/HTML Tickets| Staff Parser Log
Tutorials: SLA System
| Template Groups
KSS v3.20.02 | PHP: 5.2.6 | MySQL: 5.0.58 | CentOS 4
   
Reply With Quote
  (#2) Old
Jamie Edwards Offline
Operations Manager
 
Jamie Edwards's Avatar
 
Posts: 7,373
Join Date: Jan 2006
Location: England, UK
12-06-2009, 10:33 AM

Hi Matthew,

Thanks for sharing this. It is indeed a niggle. Coincidentally, was already being fixed by Pranav, for 3.60.00 which is due out soon: Kayako Bug Tracker - Viewing Issue #820 - Comments on Download section

We'll be repeating the fix across the knowledgebase, troubleshooter and news area.


Jamie Edwards (jamie.edwards ]at[ kayako.com)
----------------------------------------------------------------
---

Last edited by Jamie Edwards; 12-06-2009 at 10:33 AM.
   
Reply With Quote
  (#3) Old
Matthew Offline
Member
 
Matthew's Avatar
 
Posts: 270
Join Date: Oct 2007
Location: Jakarta, Indonesia
12-06-2009, 11:04 AM

I didn't mention that when you click on a KB title, the article will open up in a separate window. For other item types, clicking the title takes you to an editing screen.

Jamie, glad to hear it's being fixed.


Matthew Arciniega
Free: Ticket List & Search | Dept. Display Names
Free: Outlook/HTML Tickets| Staff Parser Log
Tutorials: SLA System
| Template Groups
KSS v3.20.02 | PHP: 5.2.6 | MySQL: 5.0.58 | CentOS 4

Last edited by Matthew; 13-06-2009 at 06:12 AM.
   
Reply With Quote
  (#4) Old
supportskins Offline
Senior Member
 
supportskins's Avatar
 
Posts: 5,247
Join Date: Aug 2006
Location: Mumbai, India
12-06-2009, 11:44 AM

Great mod. Alot of other clients who do not wish to upgrade or cant upgrade can use it. Great share!



Professional and Affordable Kayako Skins - Specialists in Kayako Skinning & Customization - Professional Paid Support
Our Skins and Services - http://www.supportskins.com/store/ - NEW SKIN ADDED!!
SupportSkins.com - http://www.supportskins.com/
   
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Creating Tables Danym SupportSuite, eSupport and LiveResponse 1 03-11-2006 10:22 AM



Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78