Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
189 views
in Q2A Core by

Dear community,

I want modify current answer-comment rules in a different way. Please guide me if you know how to do this.

Basically,

  • Post a Question -> any one can post (CURRENTLY I DONT NEED ANY MODIFICATIONS HERE)
  • Answer the Question  -> any one except q_owner (CURRENTLY I DONT NEED ANY MODIFICATIONS HERE - it can be set via admin setting) 
  • Comment the Question  -> no one  (CURRENTLY I DONT NEED ANY MODIFICATIONS HERE - it can be set via admin setting)
  • Comment the Answer -> only q_owner  (MODIFICATION NEEDED - only owner of question can comment the answers)
  • Comment the Answer Comment   -> only a_owner and c_owner (MODIFICATION NEEDED - only owner of answer and owner of comment can comment the answer comment)

 In the last rule, users cannot comment on their on comment.

I know the starting point is modifiying rules in in qa-include/pages/question-view.php. It seems that the following variables will be the key actors in this modification.

$rules['answerbutton']=

$rules['commentbutton']=

$rules['isbyuser']=

Q2A version: 1.7.5

1 Answer

+4 votes
by
selected by
 
Best answer

Kudos for doing some research yourself before asking the question :) I think you're nearly there.

For point #4 I think this should work:

$rules['commentbutton'] = $post['type'] == 'A' && $permiterror_post_c != 'level' && isset($parentpost) && $userid == $parentpost['userid'];

However I'm not clear on #5. "Comment the answer comment" isn't exactly a thing in Q2A. There are comments on the answer and that's it. If one user replies to another that's still a comment on the answer. If you only want the q_owner and a_owner to be able to add comments you can change the above line to this intead:

$rules['commentbutton'] = $post['type'] == 'A' && $permiterror_post_c != 'level' && ($userid == $post['userid'] || (isset($parentpost) && $userid == $parentpost['userid']));
by
@Scott you made it awesome. The last code you wrote works exactly like I wanted.  I knew that I am on the right way, and I was aware that I need to modify $rules['commentbutton'] statement at qa-include/pages/question-view.php however I havent heard about $parentpost variable before. Many thanks.

This modification is good, because if you set points for answering, then question owner sometimes answer its own question just to gain points. And this kind of stuff mess the site.

On the other hand, if any one can comment on answers a large conversation accumulates just on one answer, and it wont affect hotness. Because hotness is sensitive to answers, but not to comments.  So, I recommend this modification.
...