/** * Replying to the message of given ID. * @param integer $id * @return string|\yii\web\Response */ public function actionReply($id = null) { $model = new Message(); $podiumUser = new PodiumUser(); $reply = Message::findOne(['id' => $id, 'receiver_id' => $podiumUser->getId()]); if ($reply) { $model->topic = Message::re() . ' ' . $reply->topic; if ($model->load(Yii::$app->request->post())) { if ($model->validate()) { if (!$podiumUser->isIgnoredBy($model->receiver_id)) { $model->replyto = $reply->id; if ($model->send()) { $this->success('Message has been sent.'); return $this->redirect(['inbox']); } } else { $this->error('Sorry! This member ignores you so you can not send the message.'); } } } $model->receiver_id = $reply->sender_id; return $this->render('reply', ['model' => $model, 'reply' => $reply]); } else { $this->error('Sorry! We can not find the message with the given ID.'); return $this->redirect(['inbox']); } }