Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix double icon in course home see BT#13665
- Loading branch information
Showing
1 changed file
with
58 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -489,56 +489,64 @@ public static function get_tools_category( | |
case TOOL_STUDENT_VIEW: | ||
$conditions = ' WHERE visibility = 1 AND (category = "authoring" OR category = "interaction" OR category = "plugin") '; | ||
if ((api_is_coach() || api_is_course_tutor()) && $_SESSION['studentview'] != 'studentview') { | ||
$conditions = ' WHERE (visibility = 1 AND (category = "authoring" OR category = "interaction" OR category = "plugin") OR (name = "'.TOOL_TRACKING.'") ) '; | ||
$conditions = ' WHERE ( | ||
visibility = 1 AND ( | ||
category = "authoring" OR | ||
category = "interaction" OR | ||
category = "plugin" | ||
) OR (name = "'.TOOL_TRACKING.'") | ||
)'; | ||
} | ||
$sql = "SELECT * | ||
FROM $course_tool_table t | ||
$conditions AND | ||
c_id = $course_id $condition_session | ||
ORDER BY id"; | ||
"; | ||
$result = Database::query($sql); | ||
break; | ||
case TOOL_AUTHORING: | ||
$sql = "SELECT * FROM $course_tool_table t | ||
WHERE category = 'authoring' AND c_id = $course_id $condition_session | ||
ORDER BY id"; | ||
"; | ||
$result = Database::query($sql); | ||
break; | ||
case TOOL_INTERACTION: | ||
$sql = "SELECT * FROM $course_tool_table t | ||
WHERE category = 'interaction' AND c_id = $course_id $condition_session | ||
ORDER BY id"; | ||
"; | ||
$result = Database::query($sql); | ||
break; | ||
case TOOL_ADMIN_VISIBLE: | ||
$sql = "SELECT * FROM $course_tool_table t | ||
WHERE category = 'admin' AND visibility ='1' AND c_id = $course_id $condition_session | ||
ORDER BY id"; | ||
"; | ||
$result = Database::query($sql); | ||
break; | ||
case TOOL_ADMIN_PLATFORM: | ||
$sql = "SELECT * FROM $course_tool_table t | ||
WHERE category = 'admin' AND c_id = $course_id $condition_session | ||
ORDER BY id"; | ||
"; | ||
$result = Database::query($sql); | ||
break; | ||
case TOOL_DRH: | ||
$sql = "SELECT * FROM $course_tool_table t | ||
WHERE name IN ('tracking') AND c_id = $course_id $condition_session | ||
ORDER BY id"; | ||
"; | ||
$result = Database::query($sql); | ||
break; | ||
case TOOL_COURSE_PLUGIN: | ||
//Other queries recover id, name, link, image, visibility, admin, address, added_tool, target, category and session_id | ||
// but plugins are not present in the tool table, only globally and inside the course_settings table once configured | ||
$sql = "SELECT * FROM $course_tool_table t | ||
WHERE category = 'plugin' AND name <> 'courseblock' AND c_id = $course_id $condition_session | ||
ORDER BY id"; | ||
"; | ||
$result = Database::query($sql); | ||
break; | ||
} | ||
|
||
//Get the list of hidden tools - this might imply performance slowdowns | ||
$sql .= " ORDER BY id "; | ||
|
||
// Get the list of hidden tools - this might imply performance slowdowns | ||
// if the course homepage is loaded many times, so the list of hidden | ||
// tools might benefit from a shared memory storage later on | ||
$list = api_get_settings('Tools', 'list', api_get_current_access_url_id()); | ||
|
@@ -556,7 +564,20 @@ public static function get_tools_category( | |
} | ||
|
||
$allowEditionInSession = api_get_configuration_value('allow_edit_tool_visibility_in_session'); | ||
while ($temp_row = Database::fetch_assoc($result)) { | ||
|
||
$tools = []; | ||
while ($row = Database::fetch_assoc($result)) { | ||
$tools[] = $row; | ||
} | ||
|
||
$toolWithSessionValue = []; | ||
foreach ($tools as $row) { | ||
if (!empty($row['session_id'])) { | ||
$toolWithSessionValue[$row['name']] = $row; | ||
} | ||
} | ||
|
||
foreach ($tools as $temp_row) { | ||
$add = false; | ||
if ($check) { | ||
if (!in_array($temp_row['name'], $hide_list)) { | ||
|
@@ -566,17 +587,24 @@ public static function get_tools_category( | |
$add = true; | ||
} | ||
|
||
if (isset($toolWithSessionValue[$temp_row['name']])) { | ||
if (!empty($temp_row['session_id'])) { | ||
continue; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
AngelFQC
Member
|
||
} | ||
//$temp_row = $toolWithSessionValue[$temp_row['name']]; | ||
} | ||
|
||
if ($allowEditionInSession && !empty($sessionId)) { | ||
// Checking if exist row in session | ||
$criteria = [ | ||
'cId' => $course_id, | ||
'name' => $temp_row['name'], | ||
'sessionId' => $sessionId, | ||
]; | ||
/** @var CTool $tool */ | ||
/** @var CTool $toolObj */ | ||
$toolObj = Database::getManager()->getRepository('ChamiloCourseBundle:CTool')->findOneBy($criteria); | ||
if ($toolObj) { | ||
if (api_is_allowed_to_edit() == false && $toolObj->getVisibility() == 0) { | ||
if (api_is_allowed_to_edit() == false && $toolObj->getVisibility() == false) { | ||
continue; | ||
} | ||
} | ||
|
@@ -590,6 +618,7 @@ public static function get_tools_category( | |
$userId | ||
); | ||
$path = $lp->get_preview_image_path(ICON_SIZE_BIG); | ||
|
||
$add = learnpath::is_lp_visible_for_student( | ||
$lp_id, | ||
$userId, | ||
|
@@ -674,7 +703,6 @@ public static function get_tools_category( | |
// Edited by Kevin Van Den Haute (kevin@develop-it.be) for integrating Smartblogs | ||
if ($sql_links != null) { | ||
$result_links = Database::query($sql_links); | ||
|
||
if (Database::num_rows($result_links) > 0) { | ||
while ($links_row = Database::fetch_array($result_links, 'ASSOC')) { | ||
$properties = array(); | ||
|
@@ -717,7 +745,6 @@ public static function get_tools_category( | |
} | ||
} | ||
} | ||
|
||
$all_tools_list = CourseHome::filterPluginTools($all_tools_list, $course_tool_category); | ||
|
||
return $all_tools_list; | ||
|
@@ -737,9 +764,9 @@ private static function filterPluginTools($dataIcons, $courseToolCategory) | |
if ($courseToolCategory == TOOL_STUDENT_VIEW) { | ||
//Fix only coach can see external pages - see #8236 - icpna | ||
if (api_is_coach()) { | ||
foreach ($dataIcons as $indice => $array) { | ||
foreach ($dataIcons as $index => $array) { | ||
if (isset($array['name'])) { | ||
$dataIcons[$indice]['name'] = str_replace($patronKey, '', $array['name']); | ||
$dataIcons[$index]['name'] = str_replace($patronKey, '', $array['name']); | ||
} | ||
} | ||
|
||
|
@@ -748,15 +775,15 @@ private static function filterPluginTools($dataIcons, $courseToolCategory) | |
|
||
$flagOrder = false; | ||
|
||
foreach ($dataIcons as $indice => $array) { | ||
foreach ($dataIcons as $index => $array) { | ||
if (!isset($array['name'])) { | ||
continue; | ||
} | ||
|
||
$pos = strpos($array['name'], $patronKey); | ||
|
||
if ($pos !== false) { | ||
unset($dataIcons[$indice]); | ||
unset($dataIcons[$index]); | ||
$flagOrder = true; | ||
} | ||
} | ||
|
@@ -769,9 +796,9 @@ private static function filterPluginTools($dataIcons, $courseToolCategory) | |
} | ||
|
||
// clean patronKey of name icons | ||
foreach ($dataIcons as $indice => $array) { | ||
foreach ($dataIcons as $index => $array) { | ||
if (isset($array['name'])) { | ||
$dataIcons[$indice]['name'] = str_replace($patronKey, '', $array['name']); | ||
$dataIcons[$index]['name'] = str_replace($patronKey, '', $array['name']); | ||
} | ||
} | ||
|
||
|
@@ -783,7 +810,7 @@ private static function filterPluginTools($dataIcons, $courseToolCategory) | |
* @param array $all_tools_list List of tools as returned by get_tools_category() | ||
* @param bool $rows | ||
* | ||
* @return string | ||
* @return array | ||
*/ | ||
public static function show_tools_category($all_tools_list, $rows = false) | ||
{ | ||
|
@@ -895,9 +922,13 @@ public static function show_tools_category($all_tools_list, $rows = false) | |
/** @var CTool $tool */ | ||
$toolObj = Database::getManager()->getRepository('ChamiloCourseBundle:CTool')->findOneBy($criteria); | ||
if ($toolObj) { | ||
$visibility = $toolObj->getVisibility(); | ||
$visibility = (int) $toolObj->getVisibility(); | ||
switch ($visibility) { | ||
case '0': | ||
$info = pathinfo($tool['image']); | ||
$basename = basename($tool['image'], '.'.$info['extension']); // $file is set to "index" | ||
$tool['image'] = $basename.'_na.'.$info['extension']; | ||
|
||
$link['name'] = Display::return_icon( | ||
'invisible.png', | ||
get_lang('Activate'), | ||
|
@@ -933,7 +964,9 @@ public static function show_tools_category($all_tools_list, $rows = false) | |
} | ||
} | ||
if (!empty($tool['adminlink'])) { | ||
$item['extra'] = '<a href="'.$tool['adminlink'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>'; | ||
$item['extra'] = '<a href="'.$tool['adminlink'].'">'. | ||
Display::return_icon('edit.gif', get_lang('Edit')). | ||
'</a>'; | ||
} | ||
} | ||
|
||
|
@@ -948,7 +981,8 @@ public static function show_tools_category($all_tools_list, $rows = false) | |
if (isset($lnk) && is_array($lnk)) { | ||
foreach ($lnk as $this_link) { | ||
if (empty($tool['adminlink'])) { | ||
$item['visibility'] .= '<a class="make_visible_and_invisible" href="'.api_get_self().'?'.api_get_cidreq().'&id='.$tool['iid'].'&'.$this_link['cmd'].'">'. | ||
$item['visibility'] .= | ||
'<a class="make_visible_and_invisible" href="'.api_get_self().'?'.api_get_cidreq().'&id='.$tool['iid'].'&'.$this_link['cmd'].'">'. | ||
$this_link['name'].'</a>'; | ||
} | ||
} | ||
|
@jmontoyaa Entiendo que este commit fue para evitar mostrar los íconos duplicados, pero hace que no se muestre el ícono del tool en la sesión si yo registré un tool en una sessión.
Por favor revisa si el commit que envié 8706747 no rompe lo que corrige tu commit; mi commit mostraría el ícono del tool de la sesión en lugar del ícono del tool del curso base, en caso dede estar duplicado