Remove CourseModule entity, remove course home views.

Activity big by default.
pull/3016/head
Julio Montoya 6 years ago
parent 5a349fe968
commit 09ec663003
  1. 111
      main/course_home/2column.php
  2. 220
      main/course_home/3column.php
  3. 9
      main/course_home/course_home.php
  4. 1
      main/cron/import_csv.php
  5. 479
      main/inc/lib/course_home.lib.php
  6. 1
      main/inc/lib/database.constants.inc.php

@ -1,111 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* HOME PAGE FOR EACH COURSE.
*
* This page, included in every course's index.php is the home
* page. To make administration simple, the teacher edits his
* course from the home page. Only the login detects that the
* visitor is allowed to activate, deactivate home page links,
* access to the teachers tools (statistics, edit forums...).
*
* @package chamilo.course_home
*/
/* Work with data post askable by admin of course (franglais, clean this) */
$id = isset($_GET['id']) ? intval($_GET['id']) : null;
$course_id = api_get_course_int_id();
if (api_is_allowed_to_edit(null, true)) {
/* Processing request */
/* Modify home page */
/*
* Display message to confirm that a tool must be hidden from the list of available tools (visibility 0,1->2)
*/
if (isset($_GET['remove']) && $_GET['remove']) {
$msgDestroy = get_lang('DelLk').'<br />';
$msgDestroy .= '<a href="'.api_get_self().'">'.get_lang('No').'</a>&nbsp;|&nbsp;';
$msgDestroy .= '<a href="'.api_get_self().'?destroy=yes&amp;id='.$id.'">'.get_lang('Yes').'</a>';
$show_message .= Display :: return_message($msgDestroy, 'confirmation', false);
} elseif (isset($_GET['destroy']) && $_GET['destroy']) {
/*
* Process hiding a tools from available tools.
* visibility=2 are only view by Dokeos Administrator (visibility 0,1->2)
*/
Database::query("UPDATE $tool_table SET visibility='2' WHERE c_id = $course_id AND id='".$id."'");
} elseif (isset($_GET['hide']) && $_GET['hide']) {
/* HIDE */
// visibility 1 -> 0
Database::query("UPDATE $tool_table SET visibility=0 WHERE c_id = $course_id AND id='".$id."'");
$show_message .= Display::return_message(get_lang('ToolIsNowHidden'), 'confirmation');
} elseif (isset($_GET['restore']) && $_GET["restore"]) {
// visibility 0,2 -> 1
/* REACTIVATE */
Database::query("UPDATE $tool_table SET visibility=1 WHERE c_id = $course_id AND id='".$id."'");
$show_message .= Display::return_message(get_lang('ToolIsNowVisible'), 'confirmation');
}
}
// Work with data post askable by admin of course
// Work with data post askable by admin of course
if (api_is_platform_admin()) {
// Show message to confirm that a tool it to be hidden from available tools
// visibility 0,1->2
if (!empty($_GET['askDelete'])) {
$content .= '<div id="toolhide">'.get_lang('DelLk').'<br />&nbsp;&nbsp;&nbsp;
<a href="'.api_get_self().'">'.get_lang('No').'</a>&nbsp;|&nbsp;
<a href="'.api_get_self().'?delete=yes&id='.intval($_GET['id']).'">'.get_lang('Yes').'</a>
</div>';
} elseif (isset($_GET['delete']) && $_GET['delete']) {
/*
* Process hiding a tools from available tools.
*/
//where $id is set?
$id = intval($id);
Database::query("DELETE FROM $tool_table WHERE c_id = $course_id AND id='$id' AND added_tool=1");
}
}
/* TOOLS VISIBLE FOR EVERYBODY */
$content .= '<div class="everybodyview">';
$content .= '<table width="100%">';
$content .= CourseHome::show_tool_2column(TOOL_PUBLIC);
$content .= '</table>';
$content .= '</div>';
/* COURSE ADMIN ONLY VIEW */
// Start of tools for CourseAdmins (teachers/tutors)
if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
$content .= "<div class=\"courseadminview\">";
$content .= "<span class=\"viewcaption\">";
$content .= get_lang('CourseAdminOnly');
$content .= "</span>";
$content .= "<table width=\"100%\">";
$content .= CourseHome::show_tool_2column(TOOL_COURSE_ADMIN);
/* INACTIVE TOOLS - HIDDEN (GREY) LINKS */
$content .= "<tr><td colspan=\"4\"><hr style='color:\"#4171B5\"' noshade=\"noshade\" size=\"1\" /></td></tr>\n".
"<tr>\n".
"<td colspan=\"4\">\n".
"<div style=\"margin-bottom: 10px;\"><font color=\"#808080\">\n".get_lang('InLnk')."</font></div>".
"</td>\n".
"</tr>";
$content .= CourseHome::show_tool_2column(TOOL_PUBLIC_BUT_HIDDEN);
$content .= "</table>";
$content .= "</div> ";
}
/* Tools for platform admin only */
if (api_is_platform_admin() && api_is_allowed_to_edit(null, true) && !api_is_coach()) {
$content .= '<div class="platformadminview">
<span class="viewcaption">'.get_lang('PlatformAdminOnly').'</span>
<table width="100%">
'.CourseHome::show_tool_2column(TOOL_PLATFORM_ADMIN).'
</table>
</div>';
}

@ -1,220 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* HOME PAGE FOR EACH COURSE (BASIC TOOLS FIXED).
*
* This page, included in every course's index.php is the home
* page.To make administration simple, the professor edits his
* course from it's home page. Only the login detects that the
* visitor is allowed to activate, deactivate home page links,
* access to Professor's tools (statistics, edit forums...).
*
* @package chamilo.course_home
*/
$hide = isset($_GET['hide']) && $_GET['hide'] === 'yes' ? 'yes' : null;
$restore = isset($_GET['restore']) && $_GET['restore'] === 'yes' ? 'yes' : null;
$id = isset($_GET['id']) ? intval($_GET['id']) : null;
$TBL_ACCUEIL = Database::get_course_table(TABLE_TOOL_LIST);
$course_id = api_get_course_int_id();
$remove = isset($remove) ? $remove : false;
$destroy = isset($destroy) ? $destroy : false;
$askDelete = isset($askDelete) ? $askDelete : false;
// WORK with data post askable by admin of course
if (api_is_allowed_to_edit(null, true)) {
/* Processing request */
/* MODIFY HOME PAGE */
/*
* Edit visibility of tools
*
* visibility = 1 - everybody
* visibility = 0 - prof and admin
* visibility = 2 - admin
*
* Who can change visibility ?
*
* admin = 0 - prof and admin
* admin = 1 - admin
*
* Show message to confirm that a tools must be hide from aivailable tools
*
* visibility 0,1->2 - $remove
*
* Process hiding a tools from aivailable tools.
*
* visibility=2 are only view by Dokeos
* Administrator visibility 0,1->2 - $destroy
*
* visibility 1 -> 0 - $hide / $restore
*/
/*
* Diplay message to confirm that a tools must be hide from aivailable tools
* (visibility 0,1->2)
*/
if ($remove) {
$sql = "SELECT * FROM $TBL_ACCUEIL WHERE c_id = $course_id AND id=$id";
$result = Database::query($sql);
$tool = Database::fetch_array($result);
$tool_name = @htmlspecialchars(
$tool['name'] != '' ? $tool['name'] : $tool['link'],
ENT_QUOTES,
api_get_system_encoding()
);
if ($tool['img'] != 'external.gif') {
$tool['link'] = api_get_path(WEB_CODE_PATH).$tool['link'];
}
$tool['image'] = Display::returnIconPath($tool['image']);
echo "<br /><br /><br />\n";
echo "<table class=\"message\" width=\"70%\" align=\"center\">\n",
"<tr><td width=\"7%\" align=\"center\">\n",
"<a href=\"".$tool['link']."\">".Display::return_icon($tool['image'], get_lang('Delete')), "</a></td>\n",
"<td width=\"28%\" height=\"45\"><small>\n",
"<a href=\"".$tool['link']."\">".$tool_name."</a></small></td>\n";
echo "<td align=\"center\">\n",
"<font color=\"#ff0000\">",
"&nbsp;&nbsp;&nbsp;",
"<strong>", get_lang('DelLk'), "</strong>",
"<br />&nbsp;&nbsp;&nbsp;\n",
"<a href=\"".api_get_self()."\">", get_lang('No'), "</a>\n",
"&nbsp;|&nbsp;\n",
"<a href=\"".api_get_self()."?destroy=yes&amp;id=$id\">", get_lang('Yes'), "</a>\n",
"</font></td></tr>\n",
"</table>\n";
echo "<br /><br /><br />\n";
} elseif ($destroy) {
// if remove
/*
* Process hiding a tools from aivailable tools.
* visibility=2 are only view by Dokeos Administrator (visibility 0,1->2)
*/
Database::query("UPDATE $TBL_ACCUEIL SET visibility='2' WHERE c_id = $course_id AND id = $id");
} elseif ($hide) {
// visibility 1 -> 0
/* HIDE */
Database::query("UPDATE $TBL_ACCUEIL SET visibility=0 WHERE c_id = $course_id AND id=$id");
$show_message .= Display::return_message(get_lang('ToolIsNowHidden'), 'confirmation');
} elseif ($restore) {
/* REACTIVATE */
// visibility 0,2 -> 1
Database::query("UPDATE $TBL_ACCUEIL SET visibility=1 WHERE c_id = $course_id AND id=$id");
$show_message .= Display::return_message(get_lang('ToolIsNowVisible'), 'confirmation');
} elseif (isset($update) && $update) {
/*
* Editing "apparance" of a tools on the course Home Page.
*/
$result = Database::query("SELECT * FROM $TBL_ACCUEIL WHERE c_id = $course_id AND id=$id");
$tool = Database::fetch_array($result);
$racine = api_get_path(SYS_PATH).'/'.$currentCourseID.'/images/';
$chemin = $racine;
$name = $tool[1];
$image = $tool[3];
$content .= "<tr>\n".
"<td colspan=\"4\">\n".
"<table>\n".
"<tr>\n".
"<td>\n".
"<form method=\"post\" action=\"".api_get_self()."\">\n".
"<input type=\"hidden\" name=\"id\" value=\"$id\">\n".
"Image : ".Display::return_icon($image)."\n".
"</td>\n".
"<td>\n".
"<select name=\"image\">\n".
"<option selected>".$image."</option>\n";
if ($dir = @opendir($chemin)) {
while ($file = readdir($dir)) {
if ($file == '..' || $file == '.') {
unset($file);
}
$content .= "<option>".$file."</option>\n";
}
closedir($dir);
}
$content .= "</select>\n".
"</td>\n".
"</tr>\n".
"<tr>\n".
"<td>".get_lang('NameOfTheLink')." : </td>\n".
"<td><input type=\"text\" name=\"name\" value=\"".$name."\"></td>\n".
"</tr>\n".
"<tr>\n".
"<td>Lien :</td>\n".
"<td><input type=\"text\" name=\"link\" value=\"".$link."\"></td>\n".
"</tr>\n".
"<tr>\n".
"<td colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"".get_lang('Ok')."\"></td>\n".
"</tr>\n".
"</form>\n".
"</table>\n".
"</td>\n".
"</tr>\n";
}
}
// Work with data post askable by admin of course
if (api_is_platform_admin() && api_is_allowed_to_edit(null, true) && !api_is_coach()) {
// Show message to confirm that a tools must be hide from aivailable tools
// visibility 0,1->2
if ($askDelete) {
$content .= "<table align=\"center\"><tr><td colspan=\"4\">
<br /><br /><font color=\"#ff0000\">&nbsp;&nbsp;&nbsp;<strong>".get_lang('DelLk')."</strong>
<br />&nbsp;&nbsp;&nbsp;
<a href=\"".api_get_self()."\">".get_lang('No')."</a>
&nbsp;|&nbsp;
<a href=\"".api_get_self()."?delete=yes&amp;id=$id\">".get_lang('Yes')."</a>
</font>
<br /><br /><br />
</td>
</tr>
</table>\n";
} elseif (isset($delete) && $delete) {
// if remove
/*
* Process hiding a tools from aivailable tools.
* visibility=2 are only viewed by Dokeos Administrator visibility 0,1->2
*/
Database::query("DELETE FROM $TBL_ACCUEIL WHERE c_id = $course_id AND id = $id AND added_tool=1");
}
}
$content .= "<table class=\"item\" align=\"center\" border=\"0\" width=\"95%\">\n";
/* TOOLS FOR EVERYBODY */
$content .= "<tr>\n<td colspan=\"6\">&nbsp;</td>\n</tr>\n";
$content .= "<tr>\n<td colspan=\"6\">";
$content .= CourseHome::show_tool_3column('Basic');
$content .= CourseHome::show_tool_3column('External');
$content .= "</td>\n</tr>\n";
/* PROF ONLY VIEW */
if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
$content .= "<tr><td colspan=\"6\"><hr noshade size=\"1\" /></td></tr>\n".
"<tr><td colspan=\"6\"><font color=\"#F66105\">\n".get_lang('CourseAdminOnly')."</font>
</td></tr>\n";
$content .= "<tr>\n<td colspan=\"6\">";
$content .= CourseHome::show_tool_3column('courseAdmin');
$content .= "</td>\n</tr>\n";
}
/* TOOLS FOR PLATFORM ADMIN ONLY */
if (api_is_platform_admin() && api_is_allowed_to_edit(null, true) && !api_is_coach()) {
$content .= "<tr>"."<td colspan=\"6\">".
"<hr noshade size=\"1\" />".
"</td>"."</tr>\n".
"<tr>\n"."<td colspan=\"6\">\n".
"<font color=\"#F66105\" >".get_lang('PlatformAdminOnly')."</font>\n".
"</td>\n"."</tr>\n";
$content .= "<tr>\n<td colspan=\"6\">";
$content .= CourseHome::show_tool_3column('platformAdmin');
$content .= "</td>\n</tr>\n";
}
$content .= "</table>\n";

@ -355,15 +355,6 @@ switch ($homePageView) {
case 'activity_big':
require 'activity.php';
break;
case '2column':
require '2column.php';
break;
case '3column':
require '3column.php';
break;
case 'vertical_activity':
require 'vertical_activity.php';
break;
}
// Get session-career diagram

@ -3035,7 +3035,6 @@ class ImportCsv
Database::get_main_table(TABLE_MAIN_COURSE_USER),
Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE),
Database::get_main_table(TABLE_MAIN_CATEGORY),
Database::get_main_table(TABLE_MAIN_COURSE_MODULE),
Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER),
Database::get_main_table(TABLE_MAIN_SESSION),
Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY),

@ -9,485 +9,6 @@ use Chamilo\CourseBundle\Entity\CTool;
*/
class CourseHome
{
/**
* Gets the html content to show in the 3 column view.
*
* @param string $cat
* @param int $userId
*
* @return string
*/
public static function show_tool_3column($cat, $userId = null)
{
$_user = api_get_user_info($userId);
$TBL_ACCUEIL = Database::get_course_table(TABLE_TOOL_LIST);
$TABLE_TOOLS = Database::get_main_table(TABLE_MAIN_COURSE_MODULE);
$numcols = 3;
$table = new HTML_Table('width="100%"');
$all_tools = [];
$course_id = api_get_course_int_id();
$studentView = api_is_student_view_active();
switch ($cat) {
case 'Basic':
$condition_display_tools = ' WHERE a.c_id = '.$course_id.' AND a.link=t.link AND t.position="basic" ';
if ((api_is_coach() || api_is_course_tutor() || api_is_platform_admin()) &&
!$studentView
) {
$condition_display_tools = ' WHERE
a.c_id = '.$course_id.' AND
a.link=t.link AND
(t.position="basic" OR a.name = "'.TOOL_TRACKING.'")
';
}
$sql = "SELECT a.*, t.image img, t.row, t.column
FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
$condition_display_tools ORDER BY t.row, t.column";
break;
case 'External':
if (api_is_allowed_to_edit()) {
$sql = "SELECT a.*, t.image img FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
WHERE
a.c_id = $course_id AND
((a.link=t.link AND t.position='external') OR
(a.visibility <= 1 AND
(a.image = 'external.gif' OR a.image = 'scormbuilder.gif' OR t.image = 'blog.gif') AND
a.image=t.image))
ORDER BY a.id";
} else {
$sql = "SELECT a.*, t.image img FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
WHERE
a.c_id = $course_id AND
(a.visibility = 1 AND ((a.link=t.link AND t.position='external') OR
((a.image = 'external.gif' OR a.image = 'scormbuilder.gif' OR t.image = 'blog.gif') AND
a.image=t.image)))
ORDER BY a.id";
}
break;
case 'courseAdmin':
$sql = "SELECT a.*, t.image img, t.row, t.column
FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
WHERE a.c_id = $course_id AND admin=1 AND a.link=t.link
ORDER BY t.row, t.column";
break;
case 'platformAdmin':
$sql = "SELECT *, image img FROM $TBL_ACCUEIL
WHERE c_id = $course_id AND visibility = 2
ORDER BY id";
}
$result = Database::query($sql);
// Grabbing all the tools from $course_tool_table
while ($tool = Database::fetch_array($result)) {
$all_tools[] = $tool;
}
$course_id = api_get_course_int_id();
// Grabbing all the links that have the property on_homepage set to 1
if ($cat == 'External') {
$tbl_link = Database::get_course_table(TABLE_LINK);
$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
if (api_is_allowed_to_edit(null, true)) {
$sql_links = "SELECT tl.*, tip.visibility
FROM $tbl_link tl
LEFT JOIN $tbl_item_property 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' AND
tip.visibility != 2";
} else {
$sql_links = "SELECT tl.*, tip.visibility
FROM $tbl_link tl
LEFT JOIN $tbl_item_property 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' AND
tip.visibility = 1";
}
$result_links = Database::query($sql_links);
while ($links_row = Database::fetch_array($result_links)) {
$properties = [];
$properties['name'] = $links_row['title'];
$properties['link'] = $links_row['url'];
$properties['visibility'] = $links_row['visibility'];
$properties['img'] = 'external.gif';
$properties['adminlink'] = api_get_path(WEB_CODE_PATH).'link/link.php?action=editlink&amp;id='.$links_row['id'];
$all_tools[] = $properties;
}
}
$cell_number = 0;
// Draw line between basic and external, only if there are entries in External
if ($cat == 'External' && count($all_tools)) {
$table->setCellContents(0, 0, '<hr noshade="noshade" size="1"/>');
$table->updateCellAttributes(0, 0, 'colspan="3"');
$cell_number += $numcols;
}
foreach ($all_tools as &$tool) {
if (isset($tool['image']) && $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) &&
!learnpath::is_lp_visible_for_student(
$lpId,
api_get_user_id(),
api_get_course_info(),
api_get_session_id()
)
) {
continue;
}
}
if (api_get_session_id() != 0 &&
in_array($tool['name'], ['course_maintenance', 'course_setting'])
) {
continue;
}
$cell_content = '';
// The name of the tool
$tool_name = self::translate_tool_name($tool);
$link_annex = '';
// The url of the tool
if ($tool['img'] != 'external.gif') {
$tool['link'] = api_get_path(WEB_CODE_PATH).$tool['link'];
$qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&amp;';
$link_annex = $qm_or_amp.api_get_cidreq();
} else {
// If an external link ends with 'login=', add the actual login...
$pos = strpos($tool['link'], '?login=');
$pos2 = strpos($tool['link'], '&amp;login=');
if ($pos !== false or $pos2 !== false) {
$link_annex = $_user['username'];
}
}
// Setting the actual image url
$tool['img'] = Display::returnIconPath($tool['img']);
$target = isset($tool['target']) ? $tool['target'] : '';
// VISIBLE
if (($tool['visibility'] ||
((api_is_coach() || api_is_course_tutor() || api_is_platform_admin()) && $tool['name'] == TOOL_TRACKING)) ||
$cat == 'courseAdmin' || $cat == 'platformAdmin'
) {
if (strpos($tool['name'], 'visio_') !== false) {
$cell_content .= '<a href="javascript: void(0);" onclick="javascript: window.open(\''.$tool['link'].$link_annex.'\',\'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'].'"><img src="'.$tool['img'].'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>';
} elseif (strpos($tool['name'], 'chat') !== false &&
api_get_course_setting('allow_open_chat_window')
) {
// don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img']
$cell_content .= '<a href="javascript: void(0);" onclick="javascript: window.open(\''.$tool['link'].$link_annex.'\',\'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\')" target="'.$tool['target'].'"><img src="'.$tool['img'].'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>';
} else {
// don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img']
$cell_content .= '<a href="'.$tool['link'].$link_annex.'" target="'.$target.'"><img src="'.$tool['img'].'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>';
}
} else {
// INVISIBLE
if (api_is_allowed_to_edit(null, true)) {
if (strpos($tool['name'], 'visio_') !== false) {
$cell_content .= '<a href="javascript: void(0);" onclick="window.open(\''.$tool['link'].$link_annex.'\',\'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'].'"><img src="'.str_replace(".gif", "_na.gif", $tool['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>';
} elseif (strpos($tool['name'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) {
// don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img']
$cell_content .= '<a href="javascript: void(0);" onclick="javascript: window.open(\''.$tool['link'].$link_annex.'\',\'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\')" target="'.$tool['target'].'" class="text-muted"><img src="'.str_replace(".gif", "_na.gif", $tool['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>';
} else {
// don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img']
$cell_content .= '<a href="'.$tool['link'].$link_annex.'" target="'.$tool['target'].'" class="text-muted">
<img src="'.str_replace(".gif", "_na.gif", $tool['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>';
}
} else {
// don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img']
$cell_content .= '<img src="'.str_replace(".gif", "_na.gif", $tool['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">';
$cell_content .= '<span class="text-muted">'.$tool_name.'</span>';
}
}
$lnk = [];
if (api_is_allowed_to_edit(null, true) &&
$cat != "courseAdmin" &&
!strpos($tool['link'], 'learnpath_handler.php?learnpath_id') &&
!api_is_coach()
) {
if ($tool['visibility']) {
$link['name'] = Display::return_icon(
'remove.gif',
get_lang('Deactivate'),
['style' => 'vertical-align: middle;']
);
$link['cmd'] = "hide=yes";
$lnk[] = $link;
} else {
$link['name'] = Display::return_icon(
'add.gif',
get_lang('Activate'),
['style' => 'vertical-align: middle;']
);
$link['cmd'] = "restore=yes";
$lnk[] = $link;
}
if (is_array($lnk)) {
foreach ($lnk as &$this_lnk) {
if (isset($tool['adminlink']) && $tool['adminlink']) {
$cell_content .= '<a href="'.$properties['adminlink'].'">'.
Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
} else {
$cell_content .= '<a href="'.api_get_self().'?id='.$tool['id'].'&amp;'.$this_lnk['cmd'].'">'.$this_lnk['name'].'</a>';
}
}
}
}
$table->setCellContents($cell_number / $numcols, ($cell_number) % $numcols, $cell_content);
$table->updateCellAttributes($cell_number / $numcols, ($cell_number) % $numcols, 'width="32%" height="42"');
$cell_number++;
}
return $table->toHtml();
}
/**
* Displays the tools of a certain category.
*
* @param string $course_tool_category contains the category of tools to display:
* "Public", "PublicButHide", "courseAdmin", "claroAdmin"
*
* @return string
*/
public static function show_tool_2column($course_tool_category)
{
$html = '';
$web_code_path = api_get_path(WEB_CODE_PATH);
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$course_id = api_get_course_int_id();
$studentView = api_is_student_view_active();
switch ($course_tool_category) {
case TOOL_PUBLIC:
$condition_display_tools = ' WHERE c_id = '.$course_id.' AND visibility = 1 ';
if ((api_is_coach() || api_is_course_tutor() || api_is_platform_admin()) &&
!$studentView
) {
$condition_display_tools = ' WHERE
c_id = '.$course_id.' AND
(visibility = 1 OR (visibility = 0 AND name = "'.TOOL_TRACKING.'")) ';
}
$result = Database::query("SELECT * FROM $course_tool_table $condition_display_tools ORDER BY id");
$col_link = "##003399";
break;
case TOOL_PUBLIC_BUT_HIDDEN:
$result = Database::query("SELECT * FROM $course_tool_table WHERE c_id = $course_id AND visibility=0 AND admin=0 ORDER BY id");
$col_link = "##808080";
break;
case TOOL_COURSE_ADMIN:
$result = Database::query("SELECT * FROM $course_tool_table WHERE c_id = $course_id AND admin=1 AND visibility != 2 ORDER BY id");
$col_link = "##003399";
break;
case TOOL_PLATFORM_ADMIN:
$result = Database::query("SELECT * FROM $course_tool_table WHERE c_id = $course_id AND visibility = 2 ORDER BY id");
$col_link = "##003399";
}
$i = 0;
// Grabbing all the tools from $course_tool_table
while ($temp_row = Database::fetch_array($result)) {
if ($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN && $temp_row['image'] != 'scormbuilder.gif') {
$temp_row['image'] = str_replace('.gif', '_na.gif', $temp_row['image']);
}
$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);
switch ($course_tool_category) {
case TOOL_PUBLIC:
$sql_links = "SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip
ON tip.tool='link' AND tl.c_id = tip.c_id AND tl.c_id = $course_id AND tip.ref=tl.id
WHERE tl.on_homepage='1' AND tip.visibility = 1";
break;
case TOOL_PUBLIC_BUT_HIDDEN:
$sql_links = "SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip
ON tip.tool='link' AND tl.c_id = tip.c_id AND tl.c_id = $course_id AND tip.ref=tl.id
WHERE tl.on_homepage='1' AND tip.visibility = 0";
break;
default:
$sql_links = null;
break;
}
if ($sql_links != null) {
$properties = [];
$result_links = Database::query($sql_links);
while ($links_row = Database::fetch_array($result_links)) {
unset($properties);
$properties['name'] = $links_row['title'];
$properties['link'] = $links_row['url'];
$properties['visibility'] = $links_row['visibility'];
$properties['image'] = $course_tool_category == TOOL_PUBLIC_BUT_HIDDEN ? 'external_na.gif' : 'external.gif';
$properties['adminlink'] = api_get_path(WEB_CODE_PATH).'link/link.php?action=editlink&id='.$links_row['id'];
$all_tools_list[] = $properties;
}
}
$lnk = [];
if (isset($all_tools_list)) {
foreach ($all_tools_list as &$tool) {
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) &&
!learnpath::is_lp_visible_for_student(
$lpId,
api_get_user_id(),
api_get_course_info(),
api_get_session_id()
)
) {
continue;
}
}
if (api_get_session_id() != 0 &&
in_array($tool['name'], ['course_maintenance', 'course_setting'])
) {
continue;
}
if (!($i % 2)) {
$html .= "<tr valign=\"top\">";
}
// 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 ($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN) {
$class = 'class="text-muted"';
}
$qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&amp;';
$tool['link'] = $tool['link'];
$html .= '<td width="50%" height="30">';
if (strpos($tool['name'], 'visio_') !== false) {
$html .= '<a '.$class.' href="javascript: void(0);" onclick="javascript: window.open(\''.htmlspecialchars($tool['link']).(($tool['image'] == 'external.gif' || $tool['image'] == 'external_na.gif') ? '' : $qm_or_amp.api_get_cidreq()).'\',\'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')) {
$html .= '<a href="javascript: void(0);" onclick="javascript: window.open(\''.htmlspecialchars($tool['link']).$qm_or_amp.api_get_cidreq().'\',\'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\')" target="'.$tool['target'].'" '.$class.'>';
} else {
$target = isset($tool['target']) ? $tool['target'] : '';
$html .= '<a href="'.
htmlspecialchars($tool['link']).(($tool['image'] == 'external.gif' || $tool['image'] == 'external_na.gif') ? '' : $qm_or_amp.api_get_cidreq()).'" target="'.$target.'" '.$class.'>';
}
$tool_name = self::translate_tool_name($tool);
$html .= Display::return_icon(
$tool['image'],
$tool_name,
[],
null,
ICON_SIZE_MEDIUM
).'&nbsp;'.$tool_name.
'</a>';
// This part displays the links to hide or remove a tool.
// These links are only visible by the course manager.
$lnk = [];
if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
if ($tool['visibility'] == '1' || $tool['name'] == TOOL_TRACKING) {
$link['name'] = Display::returnFontAwesomeIcon('minus');
$link['title'] = get_lang('Deactivate');
$link['cmd'] = 'hide=yes';
$lnk[] = $link;
}
if ($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN) {
//$link['name'] = Display::return_icon('add.gif', get_lang('Activate'));
$link['name'] = Display::returnFontAwesomeIcon('plus');
$link['title'] = get_lang('Activate');
$link['cmd'] = 'restore=yes';
$lnk[] = $link;
if ($tool['added_tool'] == 1) {
//$link['name'] = Display::return_icon('delete.gif', get_lang('Remove'));
$link['name'] = Display::returnFontAwesomeIcon('trash');
$link['title'] = get_lang('Remove');
$link['cmd'] = 'remove=yes';
$lnk[] = $link;
}
}
if (isset($tool['adminlink'])) {
$html .= '<a href="'.$tool['adminlink'].'">'.
Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
}
}
if (api_is_platform_admin() && !api_is_coach()) {
if ($tool['visibility'] == 2) {
$link['name'] = Display::returnFontAwesomeIcon('undo');
$link['title'] = get_lang('Activate');
$link['cmd'] = 'hide=yes';
$lnk[] = $link;
if ($tool['added_tool'] == 1) {
$link['name'] = get_lang('Delete');
$link['cmd'] = 'askDelete=yes';
$lnk[] = $link;
}
}
if ($tool['visibility'] == 0 && $tool['added_tool'] == 0) {
$link['name'] = Display::returnFontAwesomeIcon('trash');
$link['title'] = get_lang('Remove');
$link['cmd'] = 'remove=yes';
$lnk[] = $link;
}
}
if (is_array($lnk)) {
$html .= '<div class="pull-right">';
$html .= '<div class="btn-options">';
$html .= '<div class="btn-group btn-group-sm" role="group">';
foreach ($lnk as &$this_link) {
if (!isset($tool['adminlink'])) {
$html .= '<a class="btn btn-default" title='.$this_link['title'].' href="'.api_get_self().'?'.api_get_cidreq().'&amp;id='.$tool['id'].'&amp;'.$this_link['cmd'].'">'.$this_link['name'].'</a>';
}
}
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
}
$html .= "</td>";
if ($i % 2) {
$html .= "</tr>";
}
$i++;
}
}
if ($i % 2) {
$html .= "<td width=\"50%\">&nbsp;</td></tr>";
}
return $html;
}
/**
* Gets the tools of a certain category. Returns an array expected
* by show_tools_category().

@ -25,7 +25,6 @@ define('TABLE_MAIN_COURSE_USER', 'course_rel_user');
define('TABLE_MAIN_COURSE_CATALOGUE_USER', 'course_rel_user_catalogue');
define('TABLE_MAIN_CLASS_USER', 'class_user');
define('TABLE_MAIN_CATEGORY', 'course_category');
define('TABLE_MAIN_COURSE_MODULE', 'course_module');
define('TABLE_MAIN_SYSTEM_ANNOUNCEMENTS', 'sys_announcement');
define('TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS', 'announcement_rel_group');
define('TABLE_MAIN_LANGUAGE', 'language');

Loading…
Cancel
Save