Internal: Validate resource, format code

pull/3466/head
Julio Montoya 4 years ago
parent be5baf7bc3
commit 55f3cd2172
  1. 5
      src/CoreBundle/Controller/ResourceController.php
  2. 1
      src/CoreBundle/Repository/IllustrationRepository.php
  3. 6
      src/CoreBundle/Resources/views/Resource/info_details.html.twig
  4. 4
      src/CoreBundle/Traits/ControllerTrait.php
  5. 2
      src/CoreBundle/Traits/ResourceControllerTrait.php

@ -623,9 +623,9 @@ class ResourceController extends AbstractResourceController implements CourseCon
/** @var AbstractResource $resource */
$resource = $repository->getResourceFromResourceNode($nodeId);
$resourceNode = $resource->getResourceNode();
$this->denyAccessUnlessValidResource($resource);
$resourceNode = $resource->getResourceNode();
$this->setBreadCrumb($request, $resourceNode);
$this->denyAccessUnlessGranted(
@ -701,7 +701,6 @@ class ResourceController extends AbstractResourceController implements CourseCon
/** @var AbstractResource $resource */
$resource = $repository->getResourceFromResourceNode($id);
$this->denyAccessUnlessValidResource($resource);
$resourceNode = $resource->getResourceNode();

@ -155,6 +155,7 @@ final class IllustrationRepository extends ResourceRepository implements GridInt
'tool' => $node->getResourceType()->getTool(),
'type' => $node->getResourceType()->getName(),
];
if (!empty($filter)) {
$params['filter'] = $filter;
}

@ -14,7 +14,9 @@
{% endif %}
<dt class="col-sm-3">{{ 'Created at' | trans }}</dt>
<dd class="col-sm-9">
moment('{{ resource.resourceNode.createdAt | date("Y-m-d H:i:s") }}').fromNow();
<script>
moment('{{ resource.resourceNode.createdAt | date("Y-m-d H:i:s") }}').fromNow();
</script>
{{ resource.resourceNode.createdAt | date_to_time_ago }}
</dd>
@ -22,7 +24,7 @@
<dd class="col-sm-9">{{ resource.resourceNode.updatedAt | date_to_time_ago }}</dd>
<dt class="col-sm-3">{{ 'Author' | trans }}</dt>
{# <dd class="col-sm-9">{{ resource.resourceNode.creator }}</dd>#}
<dd class="col-sm-9">{{ resource.resourceNode.creator }}</dd>
{# Show where the file was added#}
{# {% if resource.resourceNode.resourceLinks %}#}

@ -4,12 +4,11 @@
namespace Chamilo\CoreBundle\Traits;
//use Chamilo\CoreBundle\Block\BreadcrumbBlockService;
use Chamilo\CoreBundle\Component\Utils\Glide;
use Chamilo\CoreBundle\Manager\SettingsManager;
use Chamilo\CoreBundle\Repository\IllustrationRepository;
use Chamilo\CoreBundle\Repository\ResourceFactory;
use Chamilo\CourseBundle\Repository\CAttendanceRepository;
use Chamilo\CourseBundle\Repository\CAnnouncementRepository;
use Chamilo\CourseBundle\Repository\CDocumentRepository;
use Knp\Menu\FactoryInterface as MenuFactoryInterface;
use Sylius\Bundle\SettingsBundle\Form\Factory\SettingsFormFactory;
@ -31,6 +30,7 @@ trait ControllerTrait
$services[] = IllustrationRepository::class;
$services[] = CDocumentRepository::class;
$services[] = CAnnouncementRepository::class;
/*$services[] = CAttendanceRepository::class;
$services[] = CDocumentRepository::class;

@ -36,7 +36,7 @@ trait ResourceControllerTrait
return $this->container->get($name);
}
public function denyAccessUnlessValidResource(AbstractResource $resource)
public function denyAccessUnlessValidResource(AbstractResource $resource = null)
{
if (null === $resource) {
throw new EntityNotFoundException($this->trans('Resource doesn\'t exists.'));

Loading…
Cancel
Save