1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Apps\Model\Admin\Feedback; |
4
|
|
|
|
5
|
|
|
use Apps\ActiveRecord\FeedbackAnswer; |
6
|
|
|
use Apps\ActiveRecord\FeedbackPost; |
7
|
|
|
use Apps\Model\Front\Feedback\FormAnswerAdd as FrontAnswer; |
8
|
|
|
use Ffcms\Core\App; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class FormAnswerAdd. Extend front model add answer |
12
|
|
|
* @package Apps\Model\Admin\Feedback |
13
|
|
|
*/ |
14
|
|
|
class FormAnswerAdd extends FrontAnswer |
15
|
|
|
{ |
16
|
|
|
public function make() |
17
|
|
|
{ |
18
|
|
|
// update readed marker |
19
|
|
|
$this->_post->readed = 1; |
20
|
|
|
$this->_post->save(); |
21
|
|
|
|
22
|
|
|
// add new answer row in database |
23
|
|
|
$record = new FeedbackAnswer(); |
24
|
|
|
$record->feedback_id = $this->_post->id; |
25
|
|
|
$record->name = App::$Security->strip_tags($this->name); |
26
|
|
|
$record->email = App::$Security->strip_tags($this->email); |
27
|
|
|
$record->message = App::$Security->strip_tags($this->message); |
28
|
|
|
$record->user_id = $this->_userId; |
29
|
|
|
$record->is_admin = 1; |
30
|
|
|
|
31
|
|
|
$record->ip = $this->_ip; |
32
|
|
|
$record->save(); |
33
|
|
|
|
34
|
|
|
// send email notification |
35
|
|
|
$this->sendEmail($record->getFeedbackPost()); |
|
|
|
|
36
|
|
|
|
37
|
|
|
// unset message data |
38
|
|
|
$this->message = null; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Send notification to post owner |
43
|
|
|
* @param FeedbackPost $record |
44
|
|
|
* @throws \Ffcms\Core\Exception\SyntaxException |
45
|
|
|
*/ |
46
|
|
View Code Duplication |
public function sendEmail($record) |
|
|
|
|
47
|
|
|
{ |
48
|
|
|
// prepare email template |
49
|
|
|
$template = App::$View->render('feedback/mail/newanswer', [ |
50
|
|
|
'record' => $record |
51
|
|
|
]); |
52
|
|
|
|
53
|
|
|
// get website default email |
54
|
|
|
$sender = App::$Properties->get('adminEmail'); |
55
|
|
|
|
56
|
|
|
// build swift mailer handler |
57
|
|
|
$mailMessage = \Swift_Message::newInstance(App::$Translate->get('Feedback', 'New answer in request #%id%', ['id' => $record->id])) |
58
|
|
|
->setFrom([$sender]) |
59
|
|
|
->setTo([$record->email]) |
60
|
|
|
->setBody($template, 'text/html'); |
61
|
|
|
// send message over swift instance |
62
|
|
|
App::$Mailer->send($mailMessage); |
|
|
|
|
63
|
|
|
} |
64
|
|
|
} |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: