userIsTutor($currentUser) : false) || !$onlyVisible ) ) { $filterModerated = false; } if ($filterModerated && $onlyVisible && $thread->getForum()->isModerated()) { $userId = null !== $currentUser ? $currentUser->getId() : 0; $conditionModerated = 'AND p.status = 1 OR (p.status = '.CForumPost::STATUS_WAITING_MODERATION." AND p.posterId = {$userId}) OR (p.status = ".CForumPost::STATUS_REJECTED." AND p.poster = {$userId}) OR (p.status IS NULL AND p.posterId = {$userId})"; } $dql = "SELECT p FROM ChamiloCourseBundle:CForumPost p WHERE p.thread = :thread AND p.cId = :course AND {$conditionVisibility} {$conditionModerated} ORDER BY p.iid {$orderDirection}"; return $this ->getEntityManager() ->createQuery($dql) ->setParameters([ 'thread' => $thread, 'course' => $course, ]) ->getResult() ; } public function delete(ResourceInterface $resource): void { /** @var CForumPost $resource */ $attachments = $resource->getAttachments(); if (!empty($attachments)) { foreach ($attachments as $attachment) { $this->getEntityManager()->remove($attachment); } } parent::delete($resource); } }