/** * Comment on an activity item. * * @since 2.0.0 * @access public */ public function Comment() { $this->Permission('Garden.Profiles.Edit'); $Session = Gdn::Session(); $this->Form->SetModel($this->ActivityModel); $NewActivityID = 0; // Form submitted if ($this->Form->IsPostBack()) { $Body = $this->Form->GetValue('Body', ''); $ActivityID = $this->Form->GetValue('ActivityID', ''); if (is_numeric($ActivityID) && $ActivityID > 0) { $ActivityComment = array('ActivityID' => $ActivityID, 'Body' => $Body, 'Format' => 'Text'); $ID = $this->ActivityModel->Comment($ActivityComment); if ($ID == SPAM || $ID == UNAPPROVED) { $this->StatusMessage = T('ActivityCommentRequiresApproval', 'Your comment will appear after it is approved.'); $this->Render('Blank', 'Utility'); return; } $this->Form->SetValidationResults($this->ActivityModel->ValidationResults()); if ($this->Form->ErrorCount() > 0) { throw new Exception($this->ActivityModel->Validation->ResultsText()); $this->ErrorMessage($this->Form->Errors()); } } } // Redirect back to the sending location if this isn't an ajax request if ($this->_DeliveryType === DELIVERY_TYPE_ALL) { $Target = $this->Form->GetValue('Return'); if (!$Target) { $Target = '/activity'; } Redirect($Target); } else { // Load the newly added comment. $this->SetData('Comment', $this->ActivityModel->GetComment($ID)); // Set it in the appropriate view. $this->View = 'comment'; } // And render $this->Render(); }