/** * Viewing the received message of given ID. * @param integer $id * @return string|\yii\web\Response */ public function actionViewReceived($id = null) { $model = MessageReceiver::find()->where(['and', ['id' => $id, 'receiver_id' => User::loggedId()], ['!=', 'receiver_status', MessageReceiver::STATUS_DELETED]])->limit(1)->one(); if (empty($model)) { $this->error(Yii::t('podium/flash', 'Sorry! We can not find the message with the given ID.')); return $this->redirect(['messages/inbox']); } $model->markRead(); return $this->render('view', ['model' => $model->message, 'type' => 'received', 'id' => $model->id]); }
/** * Viewing the received message of given ID. * @param integer $id * @return string|\yii\web\Response */ public function actionViewReceived($id = null) { $model = MessageReceiver::find()->where(['and', ['id' => $id, 'receiver_id' => User::loggedId()], ['!=', 'receiver_status', MessageReceiver::STATUS_DELETED]])->limit(1)->one(); if (empty($model)) { $this->error(Yii::t('podium/flash', 'Sorry! We can not find the message with the given ID.')); return $this->redirect(['messages/inbox']); } if ($model->receiver_status == Message::STATUS_NEW) { $model->receiver_status = Message::STATUS_READ; if ($model->save()) { Cache::getInstance()->deleteElement('user.newmessages', $model->receiver_id); } } return $this->render('view', ['model' => $model->message, 'type' => 'received', 'id' => $model->id]); }