Ver Fonte

Fix LP view on ecf16fb - refs BT#11021

Angel Fernando Quiroz Campos há 9 anos atrás
pai
commit
acb9489140
1 ficheiros alterados com 17 adições e 10 exclusões
  1. 17 10
      main/newscorm/resourcelinker.inc.php

+ 17 - 10
main/newscorm/resourcelinker.inc.php

@@ -1616,6 +1616,8 @@ function rl_get_resource_link_for_learnpath($course_id, $learnpath_id, $id_in_pa
     $id_in_path = intval($id_in_path);
     $lpViewId = intval($lpViewId);
 
+    $em = Database::getManager();
+
     $sql = "SELECT * FROM $tbl_lp_item
              WHERE
                 c_id = $course_id AND
@@ -1701,22 +1703,27 @@ function rl_get_resource_link_for_learnpath($course_id, $learnpath_id, $id_in_pa
                     '&lp=true';
             break;
         case TOOL_DOCUMENT:
-            $documentInfo = DocumentManager::get_document_data_by_id(
-                $id,
-                $course_code,
-                true,
-                $session_id
-            );
-            $documentPathInfo = pathinfo($documentInfo['absolute_path']);
+            $document = $em
+                ->getRepository('ChamiloCourseBundle:CDocument')
+                ->findOneBy(['cId' => $course_id,  'id' => $id]);
+
+            if (!$document) {
+                break;
+            }
+
+            $documentPathInfo = pathinfo($document->getPath());
             $jplayer_supported_files = ['mp4', 'ogv', 'flv', 'm4v'];
             $extension = isset($documentPathInfo['extension']) ? $documentPathInfo['extension'] : '';
             $showDirectUrl = !in_array($extension, $jplayer_supported_files);
 
             if ($showDirectUrl) {
-                $link = $documentInfo['direct_url'] . '?';
-                $link .= http_build_query(['cidReq' => $course_code, 'id_session' => $session_id]);
+                $link = $main_course_path . 'document' . $document->getPath() . '?' . api_get_cidreq();
             } else {
-                $link = $documentInfo['url'] . '&' . http_build_query(['origin' => 'learnpathitem']);
+                $link = api_get_path(WEB_CODE_PATH) . 'document/showinframes.php?' . http_build_query([
+                    'cidReq' => $course_code,
+                    'id' => $id,
+                    'origin' => 'learnpathitem'
+                ]);
             }
 
             $openmethod = 2;