ActivityModel::deleteComment PHP Method

deleteComment() public method

Delete an activity comment.
Since: 2.1
public deleteComment ( integer $ID ) : Gdn_DataSet
$ID integer
return Gdn_DataSet
    public function deleteComment($ID)
    {
        return $this->SQL->delete('ActivityComment', ['ActivityCommentID' => $ID]);
    }

Usage Example

 public function deleteComment($ID, $TK, $Target = '')
 {
     $session = Gdn::session();
     if (!$session->validateTransientKey($TK)) {
         throw permissionException();
     }
     if (!is_numeric($ID)) {
         throw Gdn_UserException('Invalid ID');
     }
     $comment = $this->ActivityModel->getComment($ID);
     if (!$comment) {
         throw notFoundException('Comment');
     }
     $activity = $this->ActivityModel->getID(val('ActivityID', $comment));
     if (!$activity) {
         throw notFoundException('Activity');
     }
     if (!$this->ActivityModel->canDelete($activity)) {
         throw permissionException();
     }
     $this->ActivityModel->deleteComment($ID);
     if ($this->deliveryType() === DELIVERY_TYPE_ALL) {
         redirect($Target);
     }
     $this->render('Blank', 'Utility', 'Dashboard');
 }