Add user validation to avoid PHP error.

pull/2487/head
jmontoyaa 8 years ago
parent 809bb59d00
commit 950919cd85
  1. 10
      main/lp/lp_view.php

@ -37,6 +37,9 @@ api_protect_course_script();
$lp_id = !empty($_GET['lp_id']) ? intval($_GET['lp_id']) : 0; $lp_id = !empty($_GET['lp_id']) ? intval($_GET['lp_id']) : 0;
$sessionId = api_get_session_id(); $sessionId = api_get_session_id();
$course_code = api_get_course_id();
$course_id = api_get_course_int_id();
$user_id = api_get_user_id();
// Check if the learning path is visible for student - (LP requisites) // Check if the learning path is visible for student - (LP requisites)
if (!api_is_platform_admin()) { if (!api_is_platform_admin()) {
@ -84,10 +87,10 @@ if (!$is_allowed_to_edit) {
$category = $em->getRepository('ChamiloCourseBundle:CLpCategory')->find($categoryId); $category = $em->getRepository('ChamiloCourseBundle:CLpCategory')->find($categoryId);
$block = false; $block = false;
if ($category) { if ($category) {
$user = UserManager::getRepository()->find($user_id);
$users = $category->getUsers(); $users = $category->getUsers();
if (!empty($users) && $users->count() > 0) { if (!empty($users) && $users->count() > 0) {
$user = UserManager::getRepository()->find($user_id); if ($user && !$category->hasUserAdded($user)) {
if (!$category->hasUserAdded($user)) {
$block = true; $block = true;
} }
} }
@ -108,9 +111,6 @@ if (!$is_allowed_to_edit) {
} }
} }
$course_code = api_get_course_id();
$course_id = api_get_course_int_id();
$user_id = api_get_user_id();
$platform_theme = api_get_setting('stylesheets'); // Platform's css. $platform_theme = api_get_setting('stylesheets'); // Platform's css.
$my_style = $platform_theme; $my_style = $platform_theme;

Loading…
Cancel
Save