Răsfoiți Sursa

Avoid double tool icons in course homepage - refs BT#13665 BT#12756

Angel Fernando Quiroz Campos 7 ani în urmă
părinte
comite
6011aed609
1 a modificat fișierele cu 11 adăugiri și 11 ștergeri
  1. 11 11
      main/inc/lib/course_home.lib.php

+ 11 - 11
main/inc/lib/course_home.lib.php

@@ -579,12 +579,18 @@ class CourseHome
         }
 
         $allowEditionInSession = api_get_configuration_value('allow_edit_tool_visibility_in_session');
-        $toolWithSessionValue = [];
-        foreach ($tools as $row) {
-            if (!empty($row['session_id'])) {
-                $toolWithSessionValue[$row['name']] = $row;
+        // If exists same tool (by name) from session in base course then avoid it. Allow them pass in other cases
+        $tools = array_filter($tools, function (array $toolToFilter) use ($sessionId, $tools) {
+            if (!empty($toolToFilter['session_id'])) {
+                foreach ($tools as $originalTool) {
+                    if ($toolToFilter['name'] == $originalTool['name'] && empty($originalTool['session_id'])) {
+                        return false;
+                    }
+                }
             }
-        }
+
+            return true;
+        });
 
         foreach ($tools as $temp_row) {
             $add = false;
@@ -596,12 +602,6 @@ class CourseHome
                 $add = true;
             }
 
-            if (isset($toolWithSessionValue[$temp_row['name']])) {
-                if (!empty($temp_row['session_id'])) {
-                    continue;
-                }
-            }
-
             if ($allowEditionInSession && !empty($sessionId)) {
                 // Checking if exist row in session
                 $criteria = [