Minor - fix php code, replace api_get_item_visibility

pull/3064/head
Julio 5 years ago
parent 9f8e73f58c
commit 846ef02ae4
  1. 5
      public/main/lp/learnpath.class.php
  2. 55
      public/main/lp/lp_controller.php
  3. 1
      public/main/lp/lp_list_search.php
  4. 17
      public/main/lp/lp_view.php
  5. 3
      src/CoreBundle/Repository/ResourceRepository.php

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Resource\ResourceLink;
@ -28,9 +29,7 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
* and SCORM learnpaths. It is used by the scorm class.
*
* @todo decouple class
*
* @package chamilo.learnpath
*
* *
* @author Yannick Warnier <ywarnier@beeznest.org>
* @author Julio Montoya <gugli100@gmail.com> Several improvements and fixes
*/

@ -1410,41 +1410,46 @@ switch ($action) {
require 'lp_view.php';
break;
case 'switch_view_mode':
if (!$lp_found) {
require 'lp_list.php';
}
if (Security::check_token('get')) {
Session::write('refresh', 1);
$_SESSION['oLP']->update_default_view_mode();
if ($lp_found) {
if (Security::check_token('get')) {
Session::write('refresh', 1);
$_SESSION['oLP']->update_default_view_mode();
}
}
require 'lp_list.php';
header('Location: '.$listUrl);
exit;
break;
case 'switch_force_commit':
if (!$lp_found) {
require 'lp_list.php';
if ($lp_found) {
Session::write('refresh', 1);
$_SESSION['oLP']->update_default_scorm_commit();
Display::addFlash(Display::return_message(get_lang('Updated')));
}
Session::write('refresh', 1);
$_SESSION['oLP']->update_default_scorm_commit();
require 'lp_list.php';
header('Location: '.$listUrl);
exit;
break;
case 'switch_attempt_mode':
if (!$lp_found) {
require 'lp_list.php';
if ($lp_found) {
Session::write('refresh', 1);
$_SESSION['oLP']->switch_attempt_mode();
Display::addFlash(Display::return_message(get_lang('Updated')));
}
Session::write('refresh', 1);
$_SESSION['oLP']->switch_attempt_mode();
require 'lp_list.php';
header('Location: '.$listUrl);
exit;
break;
case 'switch_scorm_debug':
if (!$lp_found) {
require 'lp_list.php';
if ($lp_found) {
Session::write('refresh', 1);
$_SESSION['oLP']->update_scorm_debug();
Display::addFlash(Display::return_message(get_lang('Updated')));
}
Session::write('refresh', 1);
$_SESSION['oLP']->update_scorm_debug();
require 'lp_list.php';
break;
case 'intro_cmdAdd':
// Add introduction section page.
header('Location: '.$listUrl);
exit;
break;
case 'return_to_course_homepage':
if (!$lp_found) {

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CourseBundle\Entity\CLpCategory;
@ -9,15 +10,12 @@ use ChamiloSession as Session;
* the direct file view is not needed anymore, if the user uploads a scorm zip file, a directory
* will be automatically created for it, and the files will be uncompressed there for example ;.
*
* @package chamilo.learnpath
*
* @author Yannick Warnier <ywarnier@beeznest.org> - redesign
* @author Denes Nagy, principal author
* @author Isthvan Mandak, several new features
* @author Roan Embrechts, code improvements and refactoring
*/
$use_anonymous = true;
$this_section = SECTION_COURSES;
if ($lp_controller_touched != 1) {
header('Location: lp_controller.php?action=view&item_id='.intval($_REQUEST['item_id']));
@ -38,6 +36,8 @@ $sessionId = api_get_session_id();
$course_code = api_get_course_id();
$course_id = api_get_course_int_id();
$user_id = api_get_user_id();
$courseEntity = api_get_course_entity($course_id);
$sessionEntity = api_get_session_entity($sessionId);
/** @var learnpath $lp */
$lp = Session::read('oLP');
@ -56,16 +56,9 @@ if (!api_is_platform_admin()) {
}
// Checking visibility (eye icon)
$visibility = api_get_item_visibility(
api_get_course_info(),
TOOL_LEARNPATH,
$lp_id,
$action,
api_get_user_id(),
$sessionId
);
$visibility = $lp->getEntity()->isVisible($courseEntity, $sessionEntity);
if ($visibility === 0 &&
if ($visibility === false &&
!api_is_allowed_to_edit(false, true, false, false)
) {
api_not_allowed(true);

@ -413,7 +413,7 @@ class ResourceRepository extends BaseEntityRepository
}
});
if ($exists === false) {
if (false === $exists) {
$resourceLink = new ResourceLink();
$resourceLink
->setResourceNode($resourceNode)
@ -442,7 +442,6 @@ class ResourceRepository extends BaseEntityRepository
return $resourceLink;
}*/
/**
* @return ResourceLink
*/

Loading…
Cancel
Save