public function getCommentId() { $id = $this->_record->id; if ($this->type === 'answer') { $id = $this->_record->getCommentPost()->id; } return $id; }
/** * Add comment answer to database and return active record object * @return CommentAnswer */ public function buildRecord() { $record = new CommentAnswer(); $record->comment_id = $this->replayTo; $record->user_id = $this->_userId; $record->guest_name = $this->guestName; $record->message = $this->message; $record->lang = App::$Request->getLanguage(); $record->ip = $this->ip; // check if premoderation is enabled and user is guest if ((bool) $this->_configs['guestModerate'] && $this->_userId < 1) { $record->moderate = 1; } $record->save(); // add notification for comment post owner $commentPost = $record->getCommentPost(); if ($commentPost !== null && (int) $commentPost->user_id !== 0 && (int) $commentPost->user_id !== $this->_userId) { $notify = new EntityAddNotification((int) $commentPost->user_id); $notify->add($commentPost->pathway, EntityAddNotification::MSG_ADD_COMMENTANSWER, ['snippet' => Text::snippet($this->message, 50), 'post' => Text::snippet($commentPost->message, 50)]); } return $record; }