diff --git a/public/img/tools/agenda.png b/public/img/tools/agenda.png new file mode 100644 index 0000000000..48e8407c4c Binary files /dev/null and b/public/img/tools/agenda.png differ diff --git a/public/img/tools/agenda_na.png b/public/img/tools/agenda_na.png new file mode 100644 index 0000000000..47361b3573 Binary files /dev/null and b/public/img/tools/agenda_na.png differ diff --git a/public/img/tools/announcement.png b/public/img/tools/announcement.png new file mode 100644 index 0000000000..feba7acdb5 Binary files /dev/null and b/public/img/tools/announcement.png differ diff --git a/public/img/tools/announcement_na.png b/public/img/tools/announcement_na.png new file mode 100644 index 0000000000..7d5c3d5b07 Binary files /dev/null and b/public/img/tools/announcement_na.png differ diff --git a/public/img/tools/attendance.png b/public/img/tools/attendance.png new file mode 100644 index 0000000000..89713e42e4 Binary files /dev/null and b/public/img/tools/attendance.png differ diff --git a/public/img/tools/attendance_na.png b/public/img/tools/attendance_na.png new file mode 100644 index 0000000000..2d15743d8c Binary files /dev/null and b/public/img/tools/attendance_na.png differ diff --git a/public/img/tools/blog.png b/public/img/tools/blog.png new file mode 100644 index 0000000000..5efa9ced7b Binary files /dev/null and b/public/img/tools/blog.png differ diff --git a/public/img/tools/blog_na.png b/public/img/tools/blog_na.png new file mode 100644 index 0000000000..1915837992 Binary files /dev/null and b/public/img/tools/blog_na.png differ diff --git a/public/img/tools/chat.png b/public/img/tools/chat.png new file mode 100644 index 0000000000..96fd9ab0cd Binary files /dev/null and b/public/img/tools/chat.png differ diff --git a/public/img/tools/chat_na.png b/public/img/tools/chat_na.png new file mode 100644 index 0000000000..4c928800ca Binary files /dev/null and b/public/img/tools/chat_na.png differ diff --git a/public/img/tools/courese_description_na.png b/public/img/tools/courese_description_na.png new file mode 100644 index 0000000000..66c3317350 Binary files /dev/null and b/public/img/tools/courese_description_na.png differ diff --git a/public/img/tools/course_description.png b/public/img/tools/course_description.png new file mode 100644 index 0000000000..58c88bc19b Binary files /dev/null and b/public/img/tools/course_description.png differ diff --git a/public/img/tools/course_maintenance.png b/public/img/tools/course_maintenance.png new file mode 100644 index 0000000000..39ce73008c Binary files /dev/null and b/public/img/tools/course_maintenance.png differ diff --git a/public/img/tools/course_maintenance_na.png b/public/img/tools/course_maintenance_na.png new file mode 100644 index 0000000000..97345af60c Binary files /dev/null and b/public/img/tools/course_maintenance_na.png differ diff --git a/public/img/tools/course_progress.png b/public/img/tools/course_progress.png new file mode 100644 index 0000000000..d266b34016 Binary files /dev/null and b/public/img/tools/course_progress.png differ diff --git a/public/img/tools/course_progress_na.png b/public/img/tools/course_progress_na.png new file mode 100644 index 0000000000..b095d3e1ad Binary files /dev/null and b/public/img/tools/course_progress_na.png differ diff --git a/public/img/tools/course_setting.png b/public/img/tools/course_setting.png new file mode 100644 index 0000000000..77b5957ee8 Binary files /dev/null and b/public/img/tools/course_setting.png differ diff --git a/public/img/tools/course_setting_na.png b/public/img/tools/course_setting_na.png new file mode 100644 index 0000000000..6bba0a02fe Binary files /dev/null and b/public/img/tools/course_setting_na.png differ diff --git a/public/img/tools/document.png b/public/img/tools/document.png new file mode 100644 index 0000000000..2a40f0bedf Binary files /dev/null and b/public/img/tools/document.png differ diff --git a/public/img/tools/document_na.png b/public/img/tools/document_na.png new file mode 100644 index 0000000000..04a87dea8e Binary files /dev/null and b/public/img/tools/document_na.png differ diff --git a/public/img/tools/dropbox.png b/public/img/tools/dropbox.png new file mode 100644 index 0000000000..1b94a6c76d Binary files /dev/null and b/public/img/tools/dropbox.png differ diff --git a/public/img/tools/dropbox_na.png b/public/img/tools/dropbox_na.png new file mode 100644 index 0000000000..31e823bb3e Binary files /dev/null and b/public/img/tools/dropbox_na.png differ diff --git a/public/img/tools/forum.png b/public/img/tools/forum.png new file mode 100644 index 0000000000..17d4591a4f Binary files /dev/null and b/public/img/tools/forum.png differ diff --git a/public/img/tools/forum_na.png b/public/img/tools/forum_na.png new file mode 100644 index 0000000000..9524b4c065 Binary files /dev/null and b/public/img/tools/forum_na.png differ diff --git a/public/img/tools/glossary.png b/public/img/tools/glossary.png new file mode 100644 index 0000000000..9ae6531d9a Binary files /dev/null and b/public/img/tools/glossary.png differ diff --git a/public/img/tools/glossary_na.png b/public/img/tools/glossary_na.png new file mode 100644 index 0000000000..18c325580b Binary files /dev/null and b/public/img/tools/glossary_na.png differ diff --git a/public/img/tools/gradebook.png b/public/img/tools/gradebook.png new file mode 100644 index 0000000000..a7049c77f8 Binary files /dev/null and b/public/img/tools/gradebook.png differ diff --git a/public/img/tools/gradebook_na.png b/public/img/tools/gradebook_na.png new file mode 100644 index 0000000000..b32ec23ad7 Binary files /dev/null and b/public/img/tools/gradebook_na.png differ diff --git a/public/img/tools/group.png b/public/img/tools/group.png new file mode 100644 index 0000000000..e7a4d1005a Binary files /dev/null and b/public/img/tools/group.png differ diff --git a/public/img/tools/group_na.png b/public/img/tools/group_na.png new file mode 100644 index 0000000000..47d600e1c0 Binary files /dev/null and b/public/img/tools/group_na.png differ diff --git a/public/img/tools/learnpath.png b/public/img/tools/learnpath.png new file mode 100644 index 0000000000..718baa8c7a Binary files /dev/null and b/public/img/tools/learnpath.png differ diff --git a/public/img/tools/learnpath_na.png b/public/img/tools/learnpath_na.png new file mode 100644 index 0000000000..e3eff6c82d Binary files /dev/null and b/public/img/tools/learnpath_na.png differ diff --git a/public/img/tools/link.png b/public/img/tools/link.png new file mode 100644 index 0000000000..caff224c80 Binary files /dev/null and b/public/img/tools/link.png differ diff --git a/public/img/tools/links_na.png b/public/img/tools/links_na.png new file mode 100644 index 0000000000..3888beea5a Binary files /dev/null and b/public/img/tools/links_na.png differ diff --git a/public/img/tools/member.png b/public/img/tools/member.png new file mode 100644 index 0000000000..2286399175 Binary files /dev/null and b/public/img/tools/member.png differ diff --git a/public/img/tools/member_Na.png b/public/img/tools/member_Na.png new file mode 100644 index 0000000000..5f5b29ff80 Binary files /dev/null and b/public/img/tools/member_Na.png differ diff --git a/public/img/tools/notebook.png b/public/img/tools/notebook.png new file mode 100644 index 0000000000..b5e555b703 Binary files /dev/null and b/public/img/tools/notebook.png differ diff --git a/public/img/tools/notebook_na.png b/public/img/tools/notebook_na.png new file mode 100644 index 0000000000..ce7860946c Binary files /dev/null and b/public/img/tools/notebook_na.png differ diff --git a/public/img/tools/quiz.png b/public/img/tools/quiz.png new file mode 100644 index 0000000000..0f7ca9fd5d Binary files /dev/null and b/public/img/tools/quiz.png differ diff --git a/public/img/tools/quiz_na.png b/public/img/tools/quiz_na.png new file mode 100644 index 0000000000..22fa1826ba Binary files /dev/null and b/public/img/tools/quiz_na.png differ diff --git a/public/img/tools/statistics_na.png b/public/img/tools/statistics_na.png new file mode 100644 index 0000000000..50055541be Binary files /dev/null and b/public/img/tools/statistics_na.png differ diff --git a/public/img/tools/student_publication.png b/public/img/tools/student_publication.png new file mode 100644 index 0000000000..0d0b6b6f6b Binary files /dev/null and b/public/img/tools/student_publication.png differ diff --git a/public/img/tools/student_publication_na.png b/public/img/tools/student_publication_na.png new file mode 100644 index 0000000000..54e0c393eb Binary files /dev/null and b/public/img/tools/student_publication_na.png differ diff --git a/public/img/tools/survey.png b/public/img/tools/survey.png new file mode 100644 index 0000000000..843ea5f7c9 Binary files /dev/null and b/public/img/tools/survey.png differ diff --git a/public/img/tools/survey_na.png b/public/img/tools/survey_na.png new file mode 100644 index 0000000000..af1a4689ec Binary files /dev/null and b/public/img/tools/survey_na.png differ diff --git a/public/img/tools/tracking.png b/public/img/tools/tracking.png new file mode 100644 index 0000000000..575258d990 Binary files /dev/null and b/public/img/tools/tracking.png differ diff --git a/public/img/tools/wiki.png b/public/img/tools/wiki.png new file mode 100644 index 0000000000..bfafbcc6c3 Binary files /dev/null and b/public/img/tools/wiki.png differ diff --git a/public/img/tools/wiki_na.png b/public/img/tools/wiki_na.png new file mode 100644 index 0000000000..90f77f815a Binary files /dev/null and b/public/img/tools/wiki_na.png differ diff --git a/public/main/inc/lib/course_home.lib.php b/public/main/inc/lib/course_home.lib.php index 2e94b31cd0..b3d8e54397 100644 --- a/public/main/inc/lib/course_home.lib.php +++ b/public/main/inc/lib/course_home.lib.php @@ -1,8 +1,10 @@ getRepository('ChamiloCourseBundle:CTool'); + $qb = $repo->createQueryBuilder('tool'); + + $criteria = \Doctrine\Common\Collections\Criteria::create(); + switch ($course_tool_category) { case TOOL_STUDENT_VIEW: - $conditions = ' WHERE visibility = 1 AND - (category = "authoring" OR category = "interaction" OR category = "plugin") AND - t.name <> "notebookteacher" '; - if ((api_is_coach() || api_is_course_tutor() || api_is_platform_admin()) && !$studentView) { + $criteria + ->where(Criteria::expr()->eq('visibility', 1)) + ->andWhere(Criteria::expr()->in('category', ['authoring', 'interaction'])) + ; + + /*if ((api_is_coach() || api_is_course_tutor() || api_is_platform_admin()) && !$studentView) { $conditions = ' WHERE ( visibility = 1 AND ( - category = "authoring" OR - category = "interaction" OR + category = "authoring" OR + category = "interaction" OR category = "plugin" - ) OR (t.name = "'.TOOL_TRACKING.'") + ) OR (t.name = "'.TOOL_TRACKING.'") )'; - } - - // Add order if there are LPs - $sql = "SELECT t.* FROM $course_tool_table t - LEFT JOIN $lpTable l - ON (t.c_id = l.c_id AND link LIKE concat('%/lp_controller.php?action=view&lp_id=', l.id, '&%')) - LEFT JOIN $tblLpCategory lc - ON (t.c_id = lc.c_id AND l.category_id = lc.iid) - $conditions AND - t.c_id = $course_id $condition_session - ORDER BY - CASE WHEN l.category_id IS NULL THEN 0 ELSE 1 END, - CASE WHEN l.display_order IS NULL THEN 0 ELSE 1 END, - lc.position, - l.display_order, - t.id"; - $orderBy = ''; + }*/ break; case TOOL_AUTHORING: - $sql = "SELECT t.* FROM $course_tool_table t - LEFT JOIN $lpTable l - ON (t.c_id = l.c_id AND link LIKE concat('%/lp_controller.php?action=view&lp_id=', l.id, '&%')) - LEFT JOIN $tblLpCategory lc - ON (t.c_id = lc.c_id AND l.category_id = lc.iid) - WHERE - category = 'authoring' AND t.c_id = $course_id $condition_session - ORDER BY - CASE WHEN l.category_id IS NULL THEN 0 ELSE 1 END, - CASE WHEN l.display_order IS NULL THEN 0 ELSE 1 END, - lc.position, - l.display_order, - t.id"; - $orderBy = ''; + $criteria + ->where(Criteria::expr()->in('category', ['authoring'])) + ; break; case TOOL_INTERACTION: - $sql = "SELECT * FROM $course_tool_table t - WHERE category = 'interaction' AND c_id = $course_id $condition_session - "; + $criteria + ->where(Criteria::expr()->in('category', ['interaction'])) + ; 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 - "; + $criteria + ->where(Criteria::expr()->eq('visibility', 1)) + ->andWhere(Criteria::expr()->in('category', ['admin'])) + ; break; case TOOL_ADMIN_PLATFORM: - $sql = "SELECT * FROM $course_tool_table t - WHERE category = 'admin' AND c_id = $course_id $condition_session - "; + $criteria + ->andWhere(Criteria::expr()->in('category', ['admin'])) + ; break; case TOOL_DRH: - $sql = "SELECT * FROM $course_tool_table t - WHERE t.name IN ('tracking') AND c_id = $course_id $condition_session - "; + $criteria + ->andWhere(Criteria::expr()->in('tool.tool.name', ['tracking'])) + ; break; - case TOOL_COURSE_PLUGIN: + /*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 - "; + ";*/ break; } - $sql .= $orderBy; - $result = Database::query($sql); - $tools = []; - while ($row = Database::fetch_assoc($result)) { - $tools[] = $row; - } - - // 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()); - $hide_list = []; - $check = false; - foreach ($list as $line) { - // Admin can see all tools even if the course_hide_tools configuration is set - if ($is_platform_admin) { - continue; - } - if ($line['variable'] == 'course_hide_tools' && $line['selected_value'] == 'true') { - $hide_list[] = $line['subkey']; - $check = true; - } - } - - $allowEditionInSession = api_get_configuration_value('allow_edit_tool_visibility_in_session'); - // 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; - }); + $criteria + ->andWhere(Criteria::expr()->eq('course', api_get_course_entity($courseId))) + ; - foreach ($tools as $temp_row) { - $add = false; - if ($check) { - if (!in_array($temp_row['name'], $hide_list)) { - $add = true; - } - } else { - $add = true; - } + //$condition_session = $condition_add." ( $session_field = $session_id OR $session_field = 0 OR $session_field IS NULL) "; + /*$criteria + ->andWhere(Criteria::expr()->eq('session', $courseId)) + ;*/ - if ($allowEditionInSession && !empty($sessionId)) { - // Checking if exist row in session - $criteria = [ - 'course' => $course_id, - 'name' => $temp_row['name'], - 'sessionId' => $sessionId, - ]; - /** @var CTool $toolObj */ - $toolObj = Database::getManager()->getRepository('ChamiloCourseBundle:CTool')->findOneBy($criteria); - if ($toolObj) { - if (api_is_allowed_to_edit() == false && $toolObj->getVisibility() == false) { - continue; - } - } - } + $qb->addCriteria($criteria); - switch ($temp_row['image']) { - case 'scormbuilder.gif': - $lpId = self::getPublishedLpIdFromLink($temp_row['link']); - $lp = new learnpath( - api_get_course_id(), - $lpId, - $userId - ); - $path = $lp->get_preview_image_path(ICON_SIZE_BIG); - - if (api_is_allowed_to_edit(null, true)) { - $add = true; - } else { - $add = learnpath::is_lp_visible_for_student( - $lpId, - $userId, - $courseInfo, - $sessionId - ); - } - if ($path) { - $temp_row['custom_image'] = $path; - } - break; - case 'lp_category.gif': - $lpCategory = self::getPublishedLpCategoryFromLink( - $temp_row['link'] - ); - $add = learnpath::categoryIsVisibleForStudent( - $lpCategory, - $user - ); - break; - } - - if ($add) { - $all_tools_list[] = $temp_row; - } - } - - // Grabbing all the links that have the property on_homepage set to 1 - $course_link_table = Database::get_course_table(TABLE_LINK); - $course_item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY); - $condition_session = api_get_session_condition( - $sessionId, - true, - true, - 'tip.session_id' - ); - - switch ($course_tool_category) { - case TOOL_AUTHORING: - $sql_links = "SELECT tl.*, tip.visibility - FROM $course_link_table tl - LEFT JOIN $course_item_property_table tip - ON tip.tool='link' AND tip.ref=tl.id - WHERE - tl.c_id = $course_id AND - tip.c_id = $course_id AND - tl.on_homepage='1' $condition_session"; - break; - case TOOL_INTERACTION: - $sql_links = null; - /* - $sql_links = "SELECT tl.*, tip.visibility - FROM $course_link_table tl - LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id - WHERE tl.on_homepage='1' "; - */ - break; - case TOOL_STUDENT_VIEW: - $sql_links = "SELECT tl.*, tip.visibility - FROM $course_link_table tl - LEFT JOIN $course_item_property_table tip - ON tip.tool='link' AND tip.ref=tl.id - WHERE - tl.c_id = $course_id AND - tip.c_id = $course_id AND - tl.on_homepage ='1' $condition_session"; - break; - case TOOL_ADMIN: - $sql_links = "SELECT tl.*, tip.visibility - FROM $course_link_table tl - LEFT JOIN $course_item_property_table tip - ON tip.tool='link' AND tip.ref=tl.id - WHERE - tl.c_id = $course_id AND - tip.c_id = $course_id AND - tl.on_homepage='1' $condition_session"; - break; - default: - $sql_links = null; - break; - } - - // 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 = []; - $properties['name'] = $links_row['title']; - $properties['session_id'] = $links_row['session_id']; - $properties['link'] = $links_row['url']; - $properties['visibility'] = $links_row['visibility']; - $properties['image'] = $links_row['visibility'] == '0' ? 'file_html.png' : 'file_html.png'; - $properties['adminlink'] = api_get_path(WEB_CODE_PATH).'link/link.php?action=editlink&id='.$links_row['id']; - $properties['target'] = $links_row['target']; - $tmp_all_tools_list[] = $properties; - } - } - } - - if (isset($tmp_all_tools_list)) { - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); - foreach ($tmp_all_tools_list as $tool) { - if ($tool['image'] == 'blog.gif') { - // Get blog id - $blog_id = substr($tool['link'], strrpos($tool['link'], '=') + 1, strlen($tool['link'])); - - // Get blog members - if ($is_platform_admin) { - $sql = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user - WHERE blog_id = ".$blog_id; - } else { - $sql = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user - WHERE blog_id = ".$blog_id." AND user_id = ".$userId; - } - $result = Database::query($sql); - if (Database::num_rows($result) > 0) { - $all_tools_list[] = $tool; - } - } else { - $all_tools_list[] = $tool; - } - } - } - - $list = self::filterPluginTools($all_tools_list, $course_tool_category); - - return $list; + return $qb->getQuery()->getResult(); } /** @@ -336,30 +127,13 @@ class CourseHome * * @return array */ - public static function show_tools_category($all_tools_list) + public static function show_tools_category($all_tools_list, ToolChain $toolChain) { - $_user = api_get_user_info(); - $theme = api_get_setting('homepage_view'); - - if ($theme === 'vertical_activity') { - //ordering by get_lang name - $order_tool_list = []; - if (is_array($all_tools_list) && count($all_tools_list) > 0) { - foreach ($all_tools_list as $key => $new_tool) { - $tool_name = self::translate_tool_name($new_tool); - $order_tool_list[$key] = $tool_name; - } - natsort($order_tool_list); - $my_temp_tool_array = []; - foreach ($order_tool_list as $key => $new_tool) { - $my_temp_tool_array[] = $all_tools_list[$key]; - } - $all_tools_list = $my_temp_tool_array; - } else { - $all_tools_list = []; - } + if (empty($all_tools_list)) { + return []; } - $web_code_path = api_get_path(WEB_CODE_PATH); + + $_user = api_get_user_info(); $session_id = api_get_session_id(); $is_platform_admin = api_is_platform_admin(); $allowEditionInSession = api_get_configuration_value('allow_edit_tool_visibility_in_session'); @@ -372,108 +146,52 @@ class CourseHome } } + $items = []; - $app_plugin = new AppPlugin(); - - if (isset($all_tools_list)) { - $lnk = ''; - foreach ($all_tools_list as &$tool) { - $item = []; - $studentview = false; - $tool['original_link'] = $tool['link']; - if ($tool['image'] === 'scormbuilder.gif') { - // Check if the published learnpath is visible for student - $lpId = self::getPublishedLpIdFromLink($tool['link']); - if (api_is_allowed_to_edit(null, true)) { - $studentview = true; + /** @var CTool $tool */ + foreach ($all_tools_list as $tool) { + $item = []; + $studentview = false; + $toolAdmin = false; + $toolModel = $toolChain->getToolFromName($tool->getTool()->getName()); + if ($is_allowed_to_edit) { + if (empty($session_id)) { + if ($tool->getVisibility() == '1' && $toolAdmin != '1') { + $link['name'] = Display::return_icon( + 'visible.png', + get_lang('Deactivate'), + ['id' => 'linktool_'.$tool->getIid()], + ICON_SIZE_SMALL, + false + ); } - if (!api_is_allowed_to_edit(null, true) && - !learnpath::is_lp_visible_for_student( - $lpId, - api_get_user_id(), - api_get_course_info(), - api_get_session_id() - ) - ) { - continue; + if ($tool->getVisibility() == '0' && $toolAdmin != '1') { + $link['name'] = Display::return_icon( + 'invisible.png', + get_lang('Activate'), + ['id' => 'linktool_'.$tool->getIid()], + ICON_SIZE_SMALL, + false + ); } - } - - if ($session_id != 0 && in_array($tool['name'], ['course_setting'])) { - continue; - } - - // This part displays the links to hide or remove a tool. - // These links are only visible by the course manager. - unset($lnk); - - $item['extra'] = null; - $toolAdmin = isset($tool['admin']) ? $tool['admin'] : ''; - - if ($is_allowed_to_edit) { - if (empty($session_id)) { - if (isset($tool['id'])) { - if ($tool['visibility'] == '1' && $toolAdmin != '1') { - $link['name'] = Display::return_icon( - 'visible.png', - get_lang('Deactivate'), - ['id' => 'linktool_'.$tool['iid']], - ICON_SIZE_SMALL, - false - ); - $link['cmd'] = 'hide=yes'; - $lnk[] = $link; - } - if ($tool['visibility'] == '0' && $toolAdmin != '1') { - $link['name'] = Display::return_icon( - 'invisible.png', - get_lang('Activate'), - ['id' => 'linktool_'.$tool['iid']], - ICON_SIZE_SMALL, - false - ); - $link['cmd'] = 'restore=yes'; - $lnk[] = $link; - } - } - } elseif ($allowEditionInSession) { - $criteria = [ - 'course' => api_get_course_int_id(), - 'name' => $tool['name'], - 'sessionId' => $session_id, - ]; - /** @var CTool $tool */ - $toolObj = Database::getManager()->getRepository('ChamiloCourseBundle:CTool')->findOneBy($criteria); - if ($toolObj) { - $visibility = (int) $toolObj->getVisibility(); - switch ($visibility) { - case '0': - $info = pathinfo($tool['image']); - $basename = basename($tool['image'], '.'.$info['extension']); - $tool['image'] = $basename.'_na.'.$info['extension']; - $link['name'] = Display::return_icon( - 'invisible.png', - get_lang('Activate'), - ['id' => 'linktool_'.$tool['iid']], - ICON_SIZE_SMALL, - false - ); - $link['cmd'] = 'restore=yes'; - $lnk[] = $link; - break; - case '1': - $link['name'] = Display::return_icon( - 'visible.png', - get_lang('Deactivate'), - ['id' => 'linktool_'.$tool['iid']], - ICON_SIZE_SMALL, - false - ); - $link['cmd'] = 'hide=yes'; - $lnk[] = $link; - break; - } - } else { + } elseif ($allowEditionInSession) { + $visibility = (int) $tool->getVisibility(); + switch ($visibility) { + case '0': + $info = pathinfo($tool['image']); + $basename = basename($tool['image'], '.'.$info['extension']); + $tool['image'] = $basename.'_na.'.$info['extension']; + $link['name'] = Display::return_icon( + 'invisible.png', + get_lang('Activate'), + ['id' => 'linktool_'.$tool['iid']], + ICON_SIZE_SMALL, + false + ); + $link['cmd'] = 'restore=yes'; + $lnk[] = $link; + break; + case '1': $link['name'] = Display::return_icon( 'visible.png', get_lang('Deactivate'), @@ -483,185 +201,76 @@ class CourseHome ); $link['cmd'] = 'hide=yes'; $lnk[] = $link; - } - } - if (!empty($tool['adminlink'])) { - $item['extra'] = ''. - Display::return_icon('edit.gif', get_lang('Edit')). - ''; - } - } - - // Both checks are necessary as is_platform_admin doesn't take student view into account - if ($is_platform_admin && $is_allowed_to_edit) { - if ($toolAdmin != '1') { - $link['cmd'] = 'hide=yes'; + break; } } + } - $item['visibility'] = ''; - if (isset($lnk) && is_array($lnk)) { - foreach ($lnk as $this_link) { - if (empty($tool['adminlink'])) { - $item['visibility'] .= - ''. - $this_link['name'].''; - } - } - } - - // NOTE : Table contains only the image file name, not full path - if (stripos($tool['link'], 'http://') === false && - stripos($tool['link'], 'https://') === false && - stripos($tool['link'], 'ftp://') === false - ) { - $tool['link'] = $web_code_path.$tool['link']; - } - - $class = ''; - if ($tool['visibility'] == '0' && $toolAdmin != '1') { - $class = 'text-muted'; - $info = pathinfo($tool['image']); - $basename = basename($tool['image'], '.'.$info['extension']); - $tool['image'] = $basename.'_na.'.$info['extension']; - } - - $qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&'; - - // If it's a link, we don't add the cidReq - if ($tool['image'] === 'file_html.png' || $tool['image'] === 'file_html_na.png') { - $tool['link'] = $tool['link']; - } else { - $tool['link'] = $tool['link'].$qm_or_amp.api_get_cidreq(); - } - - $toolIid = isset($tool['iid']) ? $tool['iid'] : null; - - //@todo this visio stuff should be removed - if (strpos($tool['name'], 'visio_') !== false) { - $tool_link_params = [ - 'id' => 'tooldesc_'.$toolIid, - 'href' => '"javascript: void(0);"', - 'class' => $class, - 'onclick' => 'javascript: window.open(\''.$tool['link'].'\',\'window_visio'.api_get_course_id().'\',config=\'height=\'+730+\', width=\'+1020+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')', - 'target' => $tool['target'], - ]; - } elseif (strpos($tool['name'], 'chat') !== false && - api_get_course_setting('allow_open_chat_window') - ) { - $tool_link_params = [ - 'id' => 'tooldesc_'.$toolIid, - 'class' => $class, - 'href' => 'javascript: void(0);', - 'onclick' => 'javascript: window.open(\''.$tool['link'].'\',\'window_chat'.api_get_course_id().'\',config=\'height=\'+600+\', width=\'+825+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')', //Chat Open Windows - 'target' => $tool['target'], - ]; - } else { - $tool_link_params = [ - 'id' => 'tooldesc_'.$toolIid, - 'href' => $tool['link'], - 'class' => $class, - 'target' => $tool['target'], - ]; + // Both checks are necessary as is_platform_admin doesn't take student view into account + if ($is_platform_admin && $is_allowed_to_edit) { + if ($toolAdmin != '1') { + $link['cmd'] = 'hide=yes'; } + } - $tool_name = self::translate_tool_name($tool); - - // Including Courses Plugins - // Creating title and the link - if (isset($tool['category']) && $tool['category'] == 'plugin') { - $plugin_info = $app_plugin->getPluginInfo($tool['name']); - if (isset($plugin_info) && isset($plugin_info['title'])) { - $tool_name = $plugin_info['title']; - } + $item['visibility'] = ''; - if (!file_exists(api_get_path(SYS_CODE_PATH).'img/'.$tool['image']) && - !file_exists(api_get_path(SYS_CODE_PATH).'img/icons/64/'.$tool['image'])) { - $tool['image'] = 'plugins.png'; - } - $tool_link_params['href'] = api_get_path(WEB_PLUGIN_PATH) - .$tool['original_link'].$qm_or_amp.api_get_cidreq(); - } + $class = ''; + if ($tool->getVisibility() == '0' && $toolAdmin != '1') { + $class = 'text-muted'; + $info = pathinfo($tool['image']); + $basename = basename($tool['image'], '.'.$info['extension']); + $tool['image'] = $basename.'_na.'.$info['extension']; + } - // Use in the course home - $icon = Display::return_icon( - $tool['image'], - $tool_name, - ['class' => 'tool-icon', 'id' => 'toolimage_'.$toolIid], - ICON_SIZE_BIG, - false - ); + $toolIid = $tool->getIid(); - // Used in the top bar - $iconMedium = Display::return_icon( - $tool['image'], - $tool_name, - ['class' => 'tool-icon', 'id' => 'toolimage_'.$toolIid], - ICON_SIZE_MEDIUM, - false - ); + $tool_link_params = [ + 'id' => 'tooldesc_'.$toolIid, + 'href' => $toolModel->getLink().'?'.api_get_cidreq(), + 'class' => $class, + ]; - // Used for vertical navigation - $iconSmall = Display::return_icon( - $tool['image'], - $tool_name, - ['class' => 'tool-img', 'id' => 'toolimage_'.$toolIid], - ICON_SIZE_SMALL, - false - ); + $tool_name = $tool->getTool()->getName(); - /*if (!empty($tool['custom_icon'])) { - $image = self::getCustomWebIconPath().$tool['custom_icon']; - $icon = Display::img( - $image, - $tool['description'], - array( - 'class' => 'tool-icon', - 'id' => 'toolimage_'.$tool['id'] - ) - ); - }*/ + $image = 'admin.png'; + // Use in the course home + $icon = Display::return_icon( + $image, + $tool_name, + ['class' => 'tool-icon', 'id' => 'toolimage_'.$toolIid], + ICON_SIZE_BIG, + false + ); - // Validation when belongs to a session + // Validation when belongs to a session + $session_img = ''; + if (!empty($tool->getSession())) { $session_img = api_get_session_image( - $tool['session_id'], + $tool->getSession()->getId(), !empty($_user['status']) ? $_user['status'] : '' ); - if ($studentview) { - $tool_link_params['href'] .= '&isStudentView=true'; - } - $item['url_params'] = $tool_link_params; - $item['icon'] = Display::url($icon, $tool_link_params['href'], $tool_link_params); - $item['only_icon'] = $icon; - $item['only_icon_medium'] = $iconMedium; - $item['only_icon_small'] = $iconSmall; - $item['only_href'] = $tool_link_params['href']; - $item['tool'] = $tool; - $item['name'] = $tool_name; - $tool_link_params['id'] = 'is'.$tool_link_params['id']; - $item['link'] = Display::url( - $tool_name.$session_img, - $tool_link_params['href'], - $tool_link_params - ); - $items[] = $item; } - } - - foreach ($items as &$item) { - $originalImage = self::getToolIcon($item, ICON_SIZE_BIG); - $item['tool']['only_icon_medium'] = self::getToolIcon($item, ICON_SIZE_MEDIUM, false); - $item['tool']['only_icon_small'] = self::getToolIcon($item, ICON_SIZE_SMALL, false); - if ($theme === 'activity_big') { - $item['tool']['image'] = Display::url( - $originalImage, - $item['url_params']['href'], - $item['url_params'] - ); + if ($studentview) { + $tool_link_params['href'] .= '&isStudentView=true'; } + $item['url_params'] = $tool_link_params; + $item['icon'] = Display::url($icon, $tool_link_params['href'], $tool_link_params); + $item['tool'] = $tool; + $item['name'] = $tool_name; + + $item['href'] = $tool_link_params['href']; + $tool_link_params['id'] = 'is'.$tool_link_params['id']; + $item['link'] = Display::url( + $tool_name.$session_img, + $tool_link_params['href'], + $tool_link_params + ); + $items[] = $item; } + return $items; } @@ -721,7 +330,7 @@ class CourseHome * * @return string returns the name of the corresponding tool */ - public static function translate_tool_name(&$tool) + public static function translate_tool_name(CTool $tool) { static $already_translated_icons = [ 'file_html.gif', @@ -736,7 +345,9 @@ class CourseHome 'external_na.gif', ]; - $toolName = Security::remove_XSS(stripslashes(strip_tags($tool['name']))); + $toolName = Security::remove_XSS(stripslashes(strip_tags($tool->getTool()->getName()))); + + return $toolName; if (isset($tool['image']) && in_array($tool['image'], $already_translated_icons)) { return $toolName; @@ -1101,33 +712,25 @@ class CourseHome /** * @return array */ - public static function getCourseAdminBlocks() + public static function getCourseAdminBlocks($toolChain) { $blocks = []; - $my_list = self::get_tools_category(TOOL_AUTHORING); - $blocks[] = [ 'title' => get_lang('Authoring'), 'class' => 'course-tools-author', - 'content' => self::show_tools_category($my_list), + 'content' => self::show_tools_category(self::get_tools_category(TOOL_AUTHORING), $toolChain), ]; - $list1 = self::get_tools_category(TOOL_INTERACTION); - $list2 = self::get_tools_category(TOOL_COURSE_PLUGIN); - $my_list = array_merge($list1, $list2); - $blocks[] = [ 'title' => get_lang('Interaction'), 'class' => 'course-tools-interaction', - 'content' => self::show_tools_category($my_list), + 'content' => self::show_tools_category(self::get_tools_category(TOOL_INTERACTION), $toolChain), ]; - $my_list = self::get_tools_category(TOOL_ADMIN_PLATFORM); - $blocks[] = [ 'title' => get_lang('Administration'), 'class' => 'course-tools-administration', - 'content' => self::show_tools_category($my_list), + 'content' => self::show_tools_category(self::get_tools_category(TOOL_ADMIN_PLATFORM), $toolChain), ]; return $blocks; @@ -1136,13 +739,13 @@ class CourseHome /** * @return array */ - public static function getCoachBlocks() + public static function getCoachBlocks(ToolChain $toolChain) { $blocks = []; $my_list = self::get_tools_category(TOOL_STUDENT_VIEW); $blocks[] = [ - 'content' => self::show_tools_category($my_list), + 'content' => self::show_tools_category($my_list, $toolChain), ]; $sessionsCopy = api_get_setting('allow_session_course_copy_for_teachers'); @@ -1161,7 +764,7 @@ class CourseHome $blocks[] = [ 'title' => get_lang('Administration'), - 'content' => self::show_tools_category($onlyMaintenanceList), + 'content' => self::show_tools_category($onlyMaintenanceList, $toolChain), ]; } @@ -1171,7 +774,7 @@ class CourseHome /** * @return array */ - public static function getStudentBlocks() + public static function getStudentBlocks(ToolChain $toolChain) { $blocks = []; $tools = self::get_tools_category(TOOL_STUDENT_VIEW); @@ -1208,12 +811,12 @@ class CourseHome } if (count($tools) > 0) { - $blocks[] = ['content' => self::show_tools_category($tools)]; + $blocks[] = ['content' => self::show_tools_category($tools, $toolChain)]; } if ($isDrhOfCourse) { $drhTool = self::get_tools_category(TOOL_DRH); - $blocks[] = ['content' => self::show_tools_category($drhTool)]; + $blocks[] = ['content' => self::show_tools_category($drhTool, $toolChain)]; } return $blocks; @@ -1222,16 +825,16 @@ class CourseHome /** * @return array */ - public static function getUserBlocks() + public static function getUserBlocks($toolChain) { $sessionId = api_get_session_id(); // Start of tools for CourseAdmins (teachers/tutors) if ($sessionId === 0 && api_is_course_admin() && api_is_allowed_to_edit(null, true)) { - $blocks = self::getCourseAdminBlocks(); + $blocks = self::getCourseAdminBlocks($toolChain); } elseif (api_is_coach()) { - $blocks = self::getCoachBlocks(); + $blocks = self::getCoachBlocks($toolChain); } else { - $blocks = self::getStudentBlocks(); + $blocks = self::getStudentBlocks($toolChain); } return $blocks; @@ -1293,53 +896,4 @@ class CourseHome return $dataIcons; } - - /** - * Find the tool icon when homepage_view is activity_big. - * - * @param int $iconSize - * @param bool $generateId - * - * @return string - */ - private static function getToolIcon(array $item, $iconSize, $generateId = true) - { - $image = str_replace('.gif', '.png', $item['tool']['image']); - $toolIid = isset($item['tool']['iid']) ? $item['tool']['iid'] : null; - - if (isset($item['tool']['custom_image'])) { - return Display::img( - $item['tool']['custom_image'], - $item['name'], - ['id' => 'toolimage_'.$toolIid] - ); - } - - if (isset($item['tool']['custom_icon']) && !empty($item['tool']['custom_icon'])) { - $customIcon = $item['tool']['custom_icon']; - - if ($item['tool']['visibility'] == '0') { - $customIcon = self::getDisableIcon($item['tool']['custom_icon']); - } - - return Display::img( - self::getCustomWebIconPath().$customIcon, - $item['name'], - ['id' => 'toolimage_'.$toolIid] - ); - } - - $id = ''; - if ($generateId) { - $id = 'toolimage_'.$toolIid; - } - - return Display::return_icon( - $image, - $item['name'], - ['id' => $id], - $iconSize, - false - ); - } } diff --git a/public/main/inc/lib/display.lib.php b/public/main/inc/lib/display.lib.php index e5786288ac..b4c9379b52 100644 --- a/public/main/inc/lib/display.lib.php +++ b/public/main/inc/lib/display.lib.php @@ -1538,6 +1538,7 @@ class Display if (empty($courseInfo)) { return ''; } + return ''; $t_track_e_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS); $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST); @@ -1567,7 +1568,7 @@ class Display c_id = $course_id AND access_user_id = '$user_id' AND access_session_id ='".$sessionId."' - ORDER BY access_date DESC + ORDER BY access_date DESC LIMIT 1 "; $result = Database::query($sql); @@ -1588,12 +1589,12 @@ class Display $hideTools = [TOOL_NOTEBOOK, TOOL_CHAT]; // Get current tools in course - $sql = "SELECT name, link, image - FROM $course_tool_table - WHERE - c_id = $course_id AND + $sql = "SELECT name + FROM $course_tool_table + WHERE + c_id = $course_id AND visibility = '1' AND - name NOT IN ('".implode("','", $hideTools)."') + name NOT IN ('".implode("','", $hideTools)." ') "; $result = Database::query($sql); $tools = Database::store_result($result); @@ -1613,7 +1614,7 @@ class Display $toolName = addslashes($toolName); - $sql = "SELECT * FROM $tool_edit_table + $sql = "SELECT * FROM $tool_edit_table WHERE c_id = $course_id AND $toolCondition @@ -2709,12 +2710,12 @@ class Display $ariaExpanded = $open ? 'true' : 'false'; $html = << -