check only one best answer
jackmaessen
✭✭✭
This is all about a plugin @hgtonight made a while ago, called MarkV. I am trying to make it possible that if a user has hit the anchor for "Best answer" ( a big green V), he cannot hit another anchor on another comment as "Best answer".
Her is some code of the plugin:
protected function AddMarkV($Sender) {
$Discussion = $Sender->EventArguments['Discussion'];
$Session = Gdn::Session();
$Comment = $Sender->EventArguments['Comment'];
if($Session->UserID == $Discussion->InsertUserID || $Session->CheckPermission('Garden.Moderation.Manage')) {
if ($Comment->MarkV) {
echo Anchor("", 'discussion/markv/' . $Comment->CommentID, 'Hijack img-swap on');
// if already hit an anchor, all other anchors in the comments should be blocked until the V is disabled; then you can hit again an anchor on a comment
}
else {
echo Anchor("", 'discussion/markv/' . $Comment->CommentID, 'Hijack img-swap');
}
}
else {
if ($Comment->MarkV) {
echo Wrap("", 'div', array('class' => 'Hijack img-swap on'));
}
else {
echo Wrap("", 'div', array('class' => 'Hijack img-swap'));
}
}
}
I think i have to do something with this line but i do not know where to put it exactly $Sender->CommentModel->SetField($Comment->CommentID, 'MarkV', !$Comment->MarkV);
0