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

@ -338,9 +338,9 @@ class CDocument extends AbstractResource implements ResourceInterface
/**
* @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
*/
public function getVisibility()
public function getVisibility(Course $course, Session $session = null)
{
return $this->getCourseSessionResourceLink()->getVisibility();
return $this->getCourseSessionResourceLink($course, $session)->getVisibility();
}
/**
* @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