public function comment($Comment)
{
$Comment['InsertUserID'] = Gdn::session()->UserID;
$Comment['DateInserted'] = Gdn_Format::toDateTime();
$Comment['InsertIPAddress'] = ipEncode(Gdn::request()->ipAddress());
$this->Validation->applyRule('ActivityID', 'Required');
$this->Validation->applyRule('Body', 'Required');
$this->Validation->applyRule('DateInserted', 'Required');
$this->Validation->applyRule('InsertUserID', 'Required');
$this->EventArguments['Comment'] =& $Comment;
$this->fireEvent('BeforeSaveComment');
if ($this->validate($Comment)) {
$Activity = $this->getID($Comment['ActivityID'], DATASET_TYPE_ARRAY);
Gdn::controller()->json('Activity', $Activity);
$_ActivityID = $Comment['ActivityID'];
// Check to see if this is a shared activity/notification.
if ($CommentActivityID = val('CommentActivityID', $Activity['Data'])) {
Gdn::controller()->json('CommentActivityID', $CommentActivityID);
$Comment['ActivityID'] = $CommentActivityID;
}
// Check for spam.
$Spam = SpamModel::isSpam('ActivityComment', $Comment);
if ($Spam) {
return SPAM;
}
// Check for approval
$ApprovalRequired = checkRestriction('Vanilla.Approval.Require');
if ($ApprovalRequired && !val('Verified', Gdn::session()->User)) {
LogModel::insert('Pending', 'ActivityComment', $Comment);
return UNAPPROVED;
}
$ID = $this->SQL->insert('ActivityComment', $Comment);
if ($ID) {
// Check to see if this comment bumps the activity.
if ($Activity && val('Bump', $Activity['Data'])) {
$this->SQL->put('Activity', ['DateUpdated' => $Comment['DateInserted']], ['ActivityID' => $Activity['ActivityID']]);
if ($_ActivityID != $Comment['ActivityID']) {
$this->SQL->put('Activity', ['DateUpdated' => $Comment['DateInserted']], ['ActivityID' => $_ActivityID]);
}
}
// Send a notification to the original person.
if (val('ActivityType', $Activity) === 'WallPost') {
$this->notifyWallComment($Comment, $Activity);
}
}
return $ID;
}
return false;
}