fix change status

This commit is contained in:
vision 2015-06-02 11:43:54 +03:00
parent 2458ca9069
commit 961af1bb4b

View file

@ -134,10 +134,13 @@ class MyMessages extends Component {
*/
protected function changeStatusMessage($id, $status) {
$model = Messages::findOne($id);
$current_user_id = \Yii::$app->user->identity->id;
if(!$model) {
throw new EceptionMessages('Message not found.');
}
if($model->from_id != $current_user_id && $model->whom_id != $current_user_id) {
throw new EceptionMessages('Message not found for this user.');
}
$model->status = $status;
return $this->saveData($model, self::EVENT_STATUS);
}