Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
in Plugins by
edited by

Probably a question for gidgreen:

The history plugin catches the default 'c_post' event and defines if it is in_c_question (comment on question) or in_c_answer (comment on answer). However, it fails to identify a comment on comment.

I have described the issue here in detail: https://github.com/NoahY/q2a-history/issues/4

If somebody has a solution, I'd be glad to hear about! =)


PS: I receive a notification email of q2a that there is a comment on a comment, so there must be a way to find out... in qa-event-notify.php see c_commented_subject. It uses the array in the params called "thread", see foreach ($params['thread'] as $comment)

Another finding: qa-app-recalc.php → from line 316:
// For each comment thread, notify all previous comment authors of each comment in the thread (could get slow)
// ...

→ I somehow think that the best option would be just to add an in_c_question event for each user of the thread.

2 Answers

0 votes

Yes, $params['thread'] contains all the preceding comments. 

0 votes

Solution: In qa-history-check.php you need to add in the very end of the code block of if(in_array($event,$special)) { ... } the following:

// eetv: added logging for comments in thread
if($event=='c_post') {
    $oevent = 'in_c_comment';

    // check if we have more comments to the parent
    // DISTINCT: if a user has more than 1 comment just select him unique to inform him only once
    $precCommentsQuery = qa_db_query_sub('SELECT DISTINCT userid FROM `^posts`
                                WHERE `parentid` = #
                                AND `type` = "C"
                                AND `userid` IS NOT NULL

    while( ($comment = qa_db_read_one_assoc($precCommentsQuery,true)) !== null ) {
        $userid_CommThr = $comment['userid']; // unique

        // dont inform user that comments, and dont inform user that comments on his own question/answer
        if($userid_CommThr != $uid && $userid_CommThr != $pid) {
            $ohandle = $this->getHandleFromId($userid_CommThr);

            foreach ($params as $key => $value) {
                $paramstring.=(strlen($paramstring) ? "\t" : '').$key.'='.$this->value_to_text($value);

                'INSERT INTO ^eventlog (datetime, ipaddress, userid, handle, cookieid, event, params) '.
                'VALUES (NOW(), $, $, $, #, $, $)',
                qa_remote_ip_address(), $userid_CommThr, $ohandle, $cookieid, $oevent, $paramstring
} // end in_c_comment


see also: https://github.com/NoahY/q2a-history/issues/4