Пример #1
0
 public static function getComments($user_id, $type, $limit, $contentId, $contentType)
 {
     if ($contentId) {
         $date = (new Query())->select('date_time')->from('comments_' . $contentType)->where(['id' => $contentId])->scalar();
     }
     if ($type == 'user') {
         $articles_id = false;
         $photos_id = false;
         $club_photos_id = false;
     } else {
         $articles_id = Blog::getAllArticlesIdByAuthor($user_id);
         $photos_id = Photo::getAllPhotosIdByAuthor($user_id);
         $club_photos_id = ClubPhoto::getAllClubPhotosIdByAuthor($user_id);
     }
     $comment_blog_query = CommentsBlog::getCommentsQuery($user_id, $type, $articles_id);
     $comment_photo_query = CommentsPhoto::getCommentsQuery($user_id, $type, $photos_id);
     $comment_club_query = CommentsClub::getCommentsQuery($user_id, $type, $club_photos_id);
     $all_comments = $comment_blog_query->union($comment_photo_query, true)->union($comment_club_query, true);
     $sql = (new Query())->from(['ac' => $all_comments])->limit($limit)->orderBy('comment_date_time desc');
     if ($contentId) {
         $sql->andWhere(['<', 'comment_date_time', $date]);
     }
     $all_comments = $sql->all();
     foreach ($all_comments as &$comment) {
         self::DateCommentsInCorrectFormat($comment);
     }
     return $all_comments;
 }
Пример #2
0
 public function actionDeleteCommentPhoto()
 {
     $post = Yii::$app->request->post();
     CommentsPhoto::deleteCommentPhoto($post['id']);
 }
Пример #3
0
 public function actionDeleteComment()
 {
     $post = Yii::$app->request->post();
     $commentId = $post['commentId'];
     if (Yii::$app->user->isGuest) {
         echo json_encode(['status' => 0]);
         return;
     }
     if (CommentsPhoto::isMyComment($commentId)) {
         CommentsPhoto::deleteCommentPhoto($commentId);
     }
     echo json_encode(['status' => '1']);
 }