|
|
@ -14,7 +14,7 @@ use Chamilo\CoreBundle\Entity\ResourceNode; |
|
|
|
use Chamilo\CoreBundle\Entity\Session; |
|
|
|
use Chamilo\CoreBundle\Entity\Session; |
|
|
|
use Chamilo\CoreBundle\Entity\User; |
|
|
|
use Chamilo\CoreBundle\Entity\User; |
|
|
|
use Chamilo\CoreBundle\Form\Resource\IllustrationType; |
|
|
|
use Chamilo\CoreBundle\Form\Resource\IllustrationType; |
|
|
|
use Chamilo\CourseBundle\Entity\CGroupInfo; |
|
|
|
use Chamilo\CourseBundle\Entity\CGroup; |
|
|
|
use Doctrine\ORM\QueryBuilder; |
|
|
|
use Doctrine\ORM\QueryBuilder; |
|
|
|
use Symfony\Component\Form\FormInterface; |
|
|
|
use Symfony\Component\Form\FormInterface; |
|
|
|
use Symfony\Component\HttpFoundation\File\UploadedFile; |
|
|
|
use Symfony\Component\HttpFoundation\File\UploadedFile; |
|
|
@ -24,7 +24,7 @@ use Symfony\Component\HttpFoundation\File\UploadedFile; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
final class IllustrationRepository extends ResourceRepository implements GridInterface, UploadInterface |
|
|
|
final class IllustrationRepository extends ResourceRepository implements GridInterface, UploadInterface |
|
|
|
{ |
|
|
|
{ |
|
|
|
public function getResources(User $user, ResourceNode $parentNode, Course $course = null, Session $session = null, CGroupInfo $group = null): QueryBuilder |
|
|
|
public function getResources(User $user, ResourceNode $parentNode, Course $course = null, Session $session = null, CGroup $group = null): QueryBuilder |
|
|
|
{ |
|
|
|
{ |
|
|
|
$repo = $this->getRepository(); |
|
|
|
$repo = $this->getRepository(); |
|
|
|
$className = $repo->getClassName(); |
|
|
|
$className = $repo->getClassName(); |
|
|
@ -98,13 +98,12 @@ final class IllustrationRepository extends ResourceRepository implements GridInt |
|
|
|
|
|
|
|
|
|
|
|
if (null === $illustrationNode) { |
|
|
|
if (null === $illustrationNode) { |
|
|
|
$illustration = new Illustration(); |
|
|
|
$illustration = new Illustration(); |
|
|
|
|
|
|
|
$illustration->setParentResourceNode($user->getResourceNode()->getId()); |
|
|
|
$em->persist($illustration); |
|
|
|
$em->persist($illustration); |
|
|
|
$this->createNodeForResource($illustration, $user, $user->getResourceNode()); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$illustration = $this->repository->findOneBy(['resourceNode' => $illustrationNode]); |
|
|
|
$illustration = $this->repository->findOneBy(['resourceNode' => $illustrationNode]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//$this->addResourceToEveryone($illustrationNode); |
|
|
|
|
|
|
|
$file = $this->addFile($illustration, $uploadFile); |
|
|
|
$file = $this->addFile($illustration, $uploadFile); |
|
|
|
$em->flush(); |
|
|
|
$em->flush(); |
|
|
|
|
|
|
|
|
|
|
@ -116,17 +115,18 @@ final class IllustrationRepository extends ResourceRepository implements GridInt |
|
|
|
$nodeRepo = $this->getResourceNodeRepository(); |
|
|
|
$nodeRepo = $this->getResourceNodeRepository(); |
|
|
|
$name = $this->getResourceTypeName(); |
|
|
|
$name = $this->getResourceTypeName(); |
|
|
|
|
|
|
|
|
|
|
|
$qb = $nodeRepo->getEntityManager()->createQueryBuilder() |
|
|
|
$qb = $nodeRepo->createQueryBuilder('n') |
|
|
|
->select('node') |
|
|
|
->select('node') |
|
|
|
->from(ResourceNode::class, 'node') |
|
|
|
->from(ResourceNode::class, 'node') |
|
|
|
->innerJoin('node.resourceType', 'type') |
|
|
|
->innerJoin('node.resourceType', 'type') |
|
|
|
->innerJoin('node.resourceFile', 'file') |
|
|
|
->innerJoin('node.resourceFile', 'file') |
|
|
|
->where('node.parent = :parent') |
|
|
|
->where('node.parent = :parent') |
|
|
|
->andWhere('type.name = :name') |
|
|
|
->andWhere('type.name = :name') |
|
|
|
->setParameters(['parent' => $resourceNode, 'name' => $name]) |
|
|
|
->setParameters(['parent' => $resourceNode->getId(), 'name' => $name]) |
|
|
|
|
|
|
|
->setMaxResults(1) |
|
|
|
; |
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
return $qb->getQuery()->getFirstResult(); |
|
|
|
return $qb->getQuery()->getOneOrNullResult(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function deleteIllustration(AbstractResource $resource) |
|
|
|
public function deleteIllustration(AbstractResource $resource) |
|
|
@ -147,9 +147,9 @@ final class IllustrationRepository extends ResourceRepository implements GridInt |
|
|
|
return $this->getIllustrationUrlFromNode($resource->getResourceNode(), $filter); |
|
|
|
return $this->getIllustrationUrlFromNode($resource->getResourceNode(), $filter); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getIllustrationUrlFromNode(ResourceNode $resourceNode, string $filter = ''): string |
|
|
|
public function getIllustrationUrlFromNode(ResourceNode $node, string $filter = ''): string |
|
|
|
{ |
|
|
|
{ |
|
|
|
$node = $this->getIllustrationNodeFromParent($resourceNode); |
|
|
|
$node = $this->getIllustrationNodeFromParent($node); |
|
|
|
|
|
|
|
|
|
|
|
if (null !== $node) { |
|
|
|
if (null !== $node) { |
|
|
|
$params = [ |
|
|
|
$params = [ |
|
|
|