Fix resources when using a session.

pull/3064/head
Julio Montoya 5 years ago
parent b152026da9
commit c734ad4dc2
  1. 13
      src/CoreBundle/Controller/ResourceController.php
  2. 12
      src/CourseBundle/Entity/CDocument.php

@ -169,10 +169,10 @@ class ResourceController extends AbstractResourceController implements CourseCon
$icon = $resourceNode->getIcon().'  '; $icon = $resourceNode->getIcon().'  ';
if ($resourceNode->hasResourceFile()) { if ($resourceNode->hasResourceFile()) {
$url = $router->generate( /*$url = $router->generate(
'chamilo_core_resource_show', 'chamilo_core_resource_show',
$myParams $myParams
); );*/
if ($resourceNode->isResourceFileAnImage()) { if ($resourceNode->isResourceFileAnImage()) {
$url = $router->generate( $url = $router->generate(
@ -287,7 +287,8 @@ class ResourceController extends AbstractResourceController implements CourseCon
$id = $resource->getResourceNode()->getId(); $id = $resource->getResourceNode()->getId();
$icon = 'fa-eye-slash'; $icon = 'fa-eye-slash';
if ($resource->getCourseSessionResourceLink()->getVisibility() === ResourceLink::VISIBILITY_PUBLISHED) { $link = $resource->getCourseSessionResourceLink($this->getCourse(), $this->getSession());
if ($link->getVisibility() === ResourceLink::VISIBILITY_PUBLISHED) {
$icon = 'fa-eye'; $icon = 'fa-eye';
} }
$routeParams['id'] = $id; $routeParams['id'] = $id;
@ -334,7 +335,7 @@ class ResourceController extends AbstractResourceController implements CourseCon
'chamilo_core_resource_delete', 'chamilo_core_resource_delete',
true, true,
'_self', '_self',
['class' => 'btn btn-danger', 'hidden' => true] ['class' => 'btn btn-danger', 'data_hidden' => true]
); );
$myRowAction->addManipulateRender($setNodeParameters); $myRowAction->addManipulateRender($setNodeParameters);
$grid->addRowAction($myRowAction); $grid->addRowAction($myRowAction);
@ -627,11 +628,11 @@ class ResourceController extends AbstractResourceController implements CourseCon
); );
/** @var ResourceLink $link */ /** @var ResourceLink $link */
$link = $resource->getCourseSessionResourceLink(); $link = $resource->getCourseSessionResourceLink($this->getCourse(), $this->getSession());
$icon = 'fa-eye'; $icon = 'fa-eye';
// Use repository to change settings easily. // Use repository to change settings easily.
if ($link->getVisibility() === ResourceLink::VISIBILITY_PUBLISHED) { if ($link && $link->getVisibility() === ResourceLink::VISIBILITY_PUBLISHED) {
$repository->setVisibilityDraft($resource); $repository->setVisibilityDraft($resource);
$icon = 'fa-eye-slash'; $icon = 'fa-eye-slash';
} else { } else {

@ -338,9 +338,9 @@ class CDocument extends AbstractResource implements ResourceInterface
/** /**
* @return ResourceLink * @return ResourceLink
*/ */
public function getCourseSessionResourceLink() public function getCourseSessionResourceLink(Course $course, Session $session = null)
{ {
return $this->getFirstResourceLinkFromCourseSession($this->getCourse(), $this->getSession()); return $this->getFirstResourceLinkFromCourseSession($course, $session);
} }
/** /**
@ -348,17 +348,17 @@ class CDocument extends AbstractResource implements ResourceInterface
* *
* @return int * @return int
*/ */
public function getVisibility() public function getVisibility(Course $course, Session $session = null)
{ {
return $this->getCourseSessionResourceLink()->getVisibility(); return $this->getCourseSessionResourceLink($course, $session)->getVisibility();
} }
/** /**
* @return bool * @return bool
*/ */
public function isVisible(): bool public function isVisible(Course $course, Session $session = null): bool
{ {
return $this->getCourseSessionResourceLink() === ResourceLink::VISIBILITY_PUBLISHED; return $this->getCourseSessionResourceLink($course, $session) === ResourceLink::VISIBILITY_PUBLISHED;
} }
/** /**

Loading…
Cancel
Save