Filemanager editor: Block access, use translation, hide iid.

pull/3064/head
Julio Montoya 5 years ago
parent 9874563d49
commit 302899470c
  1. 38
      src/CoreBundle/Controller/EditorController.php

@ -72,7 +72,7 @@ class EditorController extends BaseController
* *
* @param int $parentId * @param int $parentId
*/ */
public function customEditorFileManager(Request $request, Grid $grid, $parentId = 0, CDocumentRepository $repository): Response public function customEditorFileManager(Request $request, Grid $grid, $parentId = 0, CDocumentRepository $repository, TranslatorInterface $translator): Response
{ {
$id = $request->get('id'); $id = $request->get('id');
@ -84,6 +84,12 @@ class EditorController extends BaseController
$parent = $repository->getResourceNodeRepository()->find($parentId); $parent = $repository->getResourceNodeRepository()->find($parentId);
} }
$this->denyAccessUnlessGranted(
ResourceNodeVoter::VIEW,
$parent,
$translator->trans('Unauthorised access to resource')
);
$source = new Entity(CDocument::class); $source = new Entity(CDocument::class);
$qb = $repository->getResourcesByCourse($course, $session, null, $parent); $qb = $repository->getResourcesByCourse($course, $session, null, $parent);
@ -95,11 +101,11 @@ class EditorController extends BaseController
$title = $grid->getColumn('title'); $title = $grid->getColumn('title');
$title->setSafe(false); $title->setSafe(false);
//$grid->hideFilters();
$grid->setLimits(20); $grid->setLimits(20);
//$grid->isReadyForRedirect(); $grid->setHiddenColumns(['iid']);
//$grid->setMaxResults(1);
//$grid->setLimits(2); $grid->getColumn('title')->setTitle($translator->trans('Name'));
$grid->getColumn('filetype')->setTitle($translator->trans('Type'));
$courseIdentifier = $course->getCode(); $courseIdentifier = $course->getCode();
@ -141,28 +147,6 @@ class EditorController extends BaseController
} }
); );
// Show resource data
/*$myRowAction = new RowAction(
'use',
'chamilo_core_resource_show',
false,
'_self',
['class' => 'btn btn-secondary']
);
$myRowAction->setRouteParameters($routeParams);
$setNodeParameters = function (RowAction $action, Row $row) use ($routeParams) {
$id = $row->getEntity()->getResourceNode()->getId();
$routeParams['id'] = $id;
$action->setRouteParameters($routeParams);
return $action;
};
$myRowAction->addManipulateRender($setNodeParameters);
$grid->addRowAction($myRowAction);*/
//return $this->render('@ChamiloTheme/Editor/custom.html.twig', $params);
return $grid->getGridResponse( return $grid->getGridResponse(
'@ChamiloTheme/Editor/custom.html.twig', '@ChamiloTheme/Editor/custom.html.twig',
['id' => $id, 'grid' => $grid] ['id' => $id, 'grid' => $grid]

Loading…
Cancel
Save