public static function create($data) { try { $comment = new self(); $db = \Difra\MySQL::getInstance(); $comment->module = $db->escape($data['module']); $comment->moduleId = $db->escape($data['moduleId']); $comment->replyId = $db->escape($data['replyId']); $comment->text = $db->escape($data['text']); $comment->user = $db->escape($data['user']); $comment->save(); ////// отправка письма о новом комменте $comment->sendMail(); } catch (\Difra\Exception $ex) { throw new \Difra\Exception('Failed to create new comment: ' . $ex->getMessage()); } return $comment; }
/** * Resend mail. */ public function resend() { if (!$this->id || !in_array($this->status, ['sent', 'deleted'])) { throw new \LogicException('Mail can not be resend'); } $copied = new self(); $copied->userTo = $this->userTo; $copied->emailFrom = $this->emailFrom; $copied->nameFrom = $this->nameFrom; $copied->emailTo = $this->emailTo; $copied->nameTo = $this->nameTo; $copied->mailAction = $this->mailAction; $copied->mailObjects = $this->mailObjects; if ($copied->sendMail()) { return $copied; } else { return false; } }