/** * @param type - тип фотки: photo, club * @param photoId * * @return json: likes, views, rating_all, isFavorite, isLike, permission * * якщо permission true - показувати */ public function actionGetInfo() { $post = Yii::$app->request->post(); $photoId = $post['photoId']; $type = $post['type']; if ($type == 'photo') { $response = Photo::getViewsLikesFavorites($photoId); $response['photoSrc'] = '/photo' . $photoId; } elseif ($type == 'club') { $response = ClubPhoto::getViewsLikes($photoId); $response['photoSrc'] = '/club-photo' . $photoId; } if (Yii::$app->user->isGuest) { $response['permission'] = false; } else { $response['permission'] = !(Yii::$app->user->getId() == $response['id_author']); } echo json_encode($response); }