course_home.lib.php 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php';
  4. class CourseHome {
  5. /**
  6. * Gets the html content to show in the 3 column view
  7. */
  8. public static function show_tool_3column($cat) {
  9. global $_user;
  10. $charset = api_get_system_encoding();
  11. $TBL_ACCUEIL = Database :: get_course_table(TABLE_TOOL_LIST);
  12. $TABLE_TOOLS = Database :: get_main_table(TABLE_MAIN_COURSE_MODULE);
  13. $numcols = 3;
  14. $table = new HTML_Table('width="100%"');
  15. $all_tools = array();
  16. $course_id = api_get_course_int_id();
  17. switch ($cat) {
  18. case 'Basic' :
  19. $condition_display_tools = ' WHERE t.c_id = '.$course_id.' AND a.link=t.link AND t.position="basic" ';
  20. if ((api_is_coach() || api_is_course_tutor()) && $_SESSION['studentview'] != 'studentview') {
  21. $condition_display_tools = ' WHERE t.c_id = '.$course_id.' AND a.link=t.link AND (t.position="basic" OR a.name = "'.TOOL_TRACKING.'") ';
  22. }
  23. $sql = "SELECT a.*, t.image img, t.row, t.column FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
  24. $condition_display_tools ORDER BY t.row, t.column";
  25. break;
  26. case 'External' :
  27. if (api_is_allowed_to_edit()) {
  28. $sql = "SELECT a.*, t.image img FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
  29. WHERE t.c_id = '.$course_id.' AND ((a.link=t.link AND t.position='external')
  30. OR (a.visibility <= 1 AND (a.image = 'external.gif' OR a.image = 'scormbuilder.gif' OR t.image = 'blog.gif') AND a.image=t.image))
  31. ORDER BY a.id";
  32. } else {
  33. $sql = "SELECT a.*, t.image img FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
  34. WHERE t.c_id = '.$course_id.' AND (a.visibility = 1 AND ((a.link=t.link AND t.position='external')
  35. OR ((a.image = 'external.gif' OR a.image = 'scormbuilder.gif' OR t.image = 'blog.gif') AND a.image=t.image)))
  36. ORDER BY a.id";
  37. }
  38. break;
  39. case 'courseAdmin' :
  40. $sql = "SELECT a.*, t.image img, t.row, t.column FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
  41. WHERE t.c_id = '.$course_id.' AND admin=1 AND a.link=t.link ORDER BY t.row, t.column";
  42. break;
  43. case 'platformAdmin' :
  44. $sql = "SELECT *, image img FROM $TBL_ACCUEIL WHERE t.c_id = '.$course_id.' AND visibility = 2 ORDER BY id";
  45. }
  46. $result = Database::query($sql);
  47. // Grabbing all the tools from $course_tool_table
  48. while ($tool = Database::fetch_array($result)) {
  49. $all_tools[] = $tool;
  50. }
  51. $course_id = api_get_course_int_id();
  52. // Grabbing all the links that have the property on_homepage set to 1
  53. if ($cat == 'External') {
  54. $tbl_link = Database :: get_course_table(TABLE_LINK);
  55. $tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
  56. if (api_is_allowed_to_edit(null, true)) {
  57. $sql_links = "SELECT tl.*, tip.visibility
  58. FROM $tbl_link tl
  59. LEFT JOIN $tbl_item_property tip ON tip.tool='link' AND tip.ref=tl.id
  60. WHERE tl.c_id = $course_id AND
  61. tip.c_id = $course_id AND
  62. tl.on_homepage='1' AND
  63. tip.visibility != 2";
  64. } else {
  65. $sql_links = "SELECT tl.*, tip.visibility
  66. FROM $tbl_link tl
  67. LEFT JOIN $tbl_item_property tip ON tip.tool='link' AND tip.ref=tl.id
  68. WHERE tl.c_id = $course_id AND
  69. tip.c_id = $course_id AND
  70. tl.on_homepage='1' AND
  71. tip.visibility = 1";
  72. }
  73. $result_links = Database::query($sql_links);
  74. while ($links_row = Database::fetch_array($result_links)) {
  75. $properties = array();
  76. $properties['name'] = $links_row['title'];
  77. $properties['link'] = $links_row['url'];
  78. $properties['visibility'] = $links_row['visibility'];
  79. $properties['img'] = 'external.gif';
  80. $properties['adminlink'] = api_get_path(WEB_CODE_PATH).'link/link.php?action=editlink&amp;id='.$links_row['id'];
  81. $all_tools[] = $properties;
  82. }
  83. }
  84. $cell_number = 0;
  85. // Draw line between basic and external, only if there are entries in External
  86. if ($cat == 'External' && count($all_tools)) {
  87. $table->setCellContents(0, 0, '<hr noshade="noshade" size="1"/>');
  88. $table->updateCellAttributes(0, 0, 'colspan="3"');
  89. $cell_number += $numcols;
  90. }
  91. foreach ($all_tools as & $tool) {
  92. if ($tool['image'] == 'scormbuilder.gif') {
  93. // display links to lp only for current session
  94. if (api_get_session_id() != $tool['session_id']) {
  95. continue;
  96. }
  97. // check if the published learnpath is visible for student
  98. $published_lp_id = self::get_published_lp_id_from_link($tool['link']);
  99. if (!api_is_allowed_to_edit(null, true) && !learnpath::is_lp_visible_for_student($published_lp_id,api_get_user_id())) {
  100. continue;
  101. }
  102. }
  103. if (api_get_session_id() != 0 && in_array($tool['name'], array('course_maintenance', 'course_setting'))) {
  104. continue;
  105. }
  106. $cell_content = '';
  107. // The name of the tool
  108. $tool_name = self::translate_tool_name($tool);
  109. $link_annex = '';
  110. // The url of the tool
  111. if ($tool['img'] != 'external.gif') {
  112. $tool['link'] = api_get_path(WEB_CODE_PATH).$tool['link'];
  113. $qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&amp;';
  114. $link_annex = $qm_or_amp.api_get_cidreq();
  115. } else {
  116. // If an external link ends with 'login=', add the actual login...
  117. $pos = strpos($tool['link'], '?login=');
  118. $pos2 = strpos($tool['link'], '&amp;login=');
  119. if ($pos !== false or $pos2 !== false) {
  120. $link_annex = $_user['username'];
  121. }
  122. }
  123. // Setting the actual image url
  124. $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img'];
  125. // VISIBLE
  126. if (($tool['visibility'] || ((api_is_coach() || api_is_course_tutor()) && $tool['name'] == TOOL_TRACKING)) || $cat == 'courseAdmin' || $cat == 'platformAdmin') {
  127. if (strpos($tool['name'], 'visio_') !== false) {
  128. $cell_content .= '<a href="javascript: void(0);" onclick="javascript: window.open(\'' . $tool['link'].$link_annex . '\',\'window_visio'.$_SESSION['_cid'].'\',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>';
  129. } elseif (strpos($tool['name'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) {
  130. $cell_content .= '<a href="javascript: void(0);" onclick="javascript: window.open(\'' .$tool['link'].$link_annex. '\',\'window_chat'.$_SESSION['_cid'].'\',config=\'height=\'+380+\', width=\'+625+\', 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>'; // don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img']
  131. } else {
  132. $cell_content .= '<a href="'.$tool['link'].$link_annex.'" target="'.$tool['target'].'"><img src="'.$tool['img'].'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>'; // don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img']
  133. }
  134. }
  135. // INVISIBLE
  136. else {
  137. if (api_is_allowed_to_edit(null, true)) {
  138. if (strpos($tool['name'], 'visio_') !== false) {
  139. $cell_content .= '<a href="javascript: void(0);" onclick="window.open(\'' . $tool['link'].$link_annex . '\',\'window_visio'.$_SESSION['_cid'].'\',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>';
  140. } elseif (strpos($tool['name'],'chat') !== false && api_get_course_setting('allow_open_chat_window')) {
  141. $cell_content .= '<a href="javascript: void(0);" onclick="javascript: window.open(\'' .$tool['link'].$link_annex. '\',\'window_chat'.$_SESSION['_cid'].'\',config=\'height=\'+380+\', width=\'+625+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="' . $tool['target'] . '" class="invisible"><img src="'.str_replace(".gif", "_na.gif", $tool['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>'; // don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img']
  142. } else {
  143. $cell_content .= '<a href="'.$tool['link'].$link_annex.'" target="'.$tool['target'].'" class="invisible"><img src="'.str_replace(".gif", "_na.gif", $tool['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>';// don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img']
  144. }
  145. } else {
  146. $cell_content .= '<img src="'.str_replace(".gif", "_na.gif", $tool['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'; // don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img']
  147. $cell_content .= '<span class="invisible">'.$tool_name.'</span>';
  148. }
  149. }
  150. $lnk = array();
  151. if (api_is_allowed_to_edit(null, true) && $cat != "courseAdmin" && !strpos($tool['link'], 'learnpath_handler.php?learnpath_id') && !api_is_coach()) {
  152. if ($tool['visibility']) {
  153. $link['name'] = Display::return_icon('remove.gif', get_lang('Deactivate'), array('style' => 'vertical-align: middle;'));
  154. $link['cmd'] = "hide=yes";
  155. $lnk[] = $link;
  156. } else {
  157. $link['name'] = Display::return_icon('add.gif', get_lang('Activate'), array('style' => 'vertical-align: middle;'));
  158. $link['cmd'] = "restore=yes";
  159. $lnk[] = $link;
  160. /*if ($tool['img'] == api_get_path(WEB_IMG_PATH).'external.gif') {
  161. $link['name'] = get_lang('Remove');
  162. $link['cmd'] = 'remove=yes';
  163. if ($tool['visibility'] == 2 && $cat == 'platformAdmin') {
  164. $link['name'] = get_lang('Delete');
  165. $link['cmd'] = 'askDelete=yes';
  166. $lnk[] = $link;
  167. }
  168. }*/
  169. }
  170. //echo "<div class=courseadmin>";
  171. if (is_array($lnk)) {
  172. foreach ($lnk as & $this_lnk) {
  173. if ($tool['adminlink']) {
  174. $cell_content .= '<a href="'.$properties['adminlink'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
  175. } else {
  176. $cell_content .= '<a href="'.api_get_self().'?id='.$tool['id'].'&amp;'.$this_lnk['cmd'].'">'.$this_lnk['name'].'</a>';
  177. }
  178. }
  179. }
  180. // RH: Allow editing of invisible homepage links (modified external_module)
  181. if ($tool['added_tool'] == 1 && api_is_allowed_to_edit() && !$tool['visibility']
  182. && $tool['image'] != 'scormbuilder.gif' && $tool['image'] != 'scormbuilder_na.gif') {
  183. $cell_content .= '<a class="nobold" href="'.api_get_path(WEB_CODE_PATH).'external_module/external_module.php?id='.$tool['id'].'">'.get_lang('Edit').'</a>';
  184. }
  185. }
  186. $table->setCellContents($cell_number / $numcols, ($cell_number) % $numcols, $cell_content);
  187. $table->updateCellAttributes($cell_number / $numcols, ($cell_number) % $numcols, 'width="32%" height="42"');
  188. $cell_number ++;
  189. }
  190. $table->display();
  191. } // end function showtools2($cat)
  192. /**
  193. * Displays the tools of a certain category.
  194. *
  195. * @return void
  196. * @param string $course_tool_category contains the category of tools to display:
  197. * "Public", "PublicButHide", "courseAdmin", "claroAdmin"
  198. */
  199. function show_tool_2column($course_tool_category) {
  200. $charset = api_get_system_encoding();
  201. $web_code_path = api_get_path(WEB_CODE_PATH);
  202. $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
  203. switch ($course_tool_category) {
  204. case TOOL_PUBLIC:
  205. $condition_display_tools = ' WHERE visibility = 1 ';
  206. if ((api_is_coach() || api_is_course_tutor()) && $_SESSION['studentview'] != 'studentview') {
  207. $condition_display_tools = ' WHERE visibility = 1 OR (visibility = 0 AND name = "'.TOOL_TRACKING.'") ';
  208. }
  209. $result = Database::query("SELECT * FROM $course_tool_table $condition_display_tools ORDER BY id");
  210. $col_link ="##003399";
  211. break;
  212. case TOOL_PUBLIC_BUT_HIDDEN:
  213. $result = Database::query("SELECT * FROM $course_tool_table WHERE visibility=0 AND admin=0 ORDER BY id");
  214. $col_link ="##808080";
  215. break;
  216. case TOOL_COURSE_ADMIN:
  217. $result = Database::query("SELECT * FROM $course_tool_table WHERE admin=1 AND visibility != 2 ORDER BY id");
  218. $col_link ="##003399";
  219. break;
  220. case TOOL_PLATFORM_ADMIN:
  221. $result = Database::query("SELECT * FROM $course_tool_table WHERE visibility = 2 ORDER BY id");
  222. $col_link ="##003399";
  223. }
  224. $i = 0;
  225. // Grabbing all the tools from $course_tool_table
  226. while ($temp_row = Database::fetch_array($result)) {
  227. if ($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN && $temp_row['image'] != 'scormbuilder.gif') {
  228. $temp_row['image'] = str_replace('.gif', '_na.gif', $temp_row['image']);
  229. }
  230. $all_tools_list[] = $temp_row;
  231. }
  232. $course_id = api_get_course_int_id();
  233. // Grabbing all the links that have the property on_homepage set to 1
  234. $course_link_table = Database::get_course_table(TABLE_LINK);
  235. $course_item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
  236. switch ($course_tool_category) {
  237. case TOOL_PUBLIC:
  238. $sql_links="SELECT tl.*, tip.visibility
  239. FROM $course_link_table tl
  240. LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
  241. WHERE tl.c_id = $course_id AND
  242. tip.c_id = $course_id AND
  243. tl.on_homepage='1' AND tip.visibility = 1";
  244. break;
  245. case TOOL_PUBLIC_BUT_HIDDEN:
  246. $sql_links="SELECT tl.*, tip.visibility
  247. FROM $course_link_table tl
  248. LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
  249. WHERE tl.c_id = $course_id AND
  250. tip.c_id = $course_id AND
  251. tl.on_homepage='1' AND tip.visibility = 0";
  252. break;
  253. default:
  254. $sql_links = null;
  255. break;
  256. }
  257. if ($sql_links != null) {
  258. $properties = array();
  259. $result_links = Database::query($sql_links);
  260. while ($links_row = Database::fetch_array($result_links)) {
  261. unset($properties);
  262. $properties['name'] = $links_row['title'];
  263. $properties['link'] = $links_row['url'];
  264. $properties['visibility'] = $links_row['visibility'];
  265. $properties['image'] = $course_tool_category == TOOL_PUBLIC_BUT_HIDDEN ? 'external_na.gif' : 'external.gif';
  266. $properties['adminlink'] = api_get_path(WEB_CODE_PATH).'link/link.php?action=editlink&id='.$links_row['id'];
  267. $all_tools_list[] = $properties;
  268. }
  269. }
  270. if (isset($all_tools_list)) {
  271. $lnk = array();
  272. foreach ($all_tools_list as & $tool) {
  273. if ($tool['image'] == 'scormbuilder.gif') {
  274. // display links to lp only for current session
  275. if (api_get_session_id() != $tool['session_id']) {
  276. continue;
  277. }
  278. // check if the published learnpath is visible for student
  279. $published_lp_id = self::get_published_lp_id_from_link($tool['link']);
  280. if (!api_is_allowed_to_edit(null, true) && !learnpath::is_lp_visible_for_student($published_lp_id,api_get_user_id())) {
  281. continue;
  282. }
  283. }
  284. if (api_get_session_id() != 0 && in_array($tool['name'], array('course_maintenance', 'course_setting'))) {
  285. continue;
  286. }
  287. if (!($i % 2)) {
  288. echo "<tr valign=\"top\">";
  289. }
  290. // NOTE : Table contains only the image file name, not full path
  291. if (stripos($tool['link'], 'http://') === false && stripos($tool['link'], 'https://') === false && stripos($tool['link'], 'ftp://') === false) {
  292. $tool['link'] = $web_code_path.$tool['link'];
  293. }
  294. if ($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN) {
  295. $class = 'class="invisible"';
  296. }
  297. $qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&amp;';
  298. $tool['link'] = $tool['link'];
  299. echo '<td width="50%" height="30">';
  300. if (strpos($tool['name'], 'visio_') !== false) {
  301. echo '<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'.$_SESSION['_cid'].'\',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'] . '">';
  302. } elseif (strpos($tool['name'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) {
  303. echo '<a href="javascript: void(0);" onclick="javascript: window.open(\'' . htmlspecialchars($tool['link']).$qm_or_amp.api_get_cidreq() . '\',\'window_chat'.$_SESSION['_cid'].'\',config=\'height=\'+380+\', width=\'+625+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="' . $tool['target'] . '"'.$class.'>';
  304. } else {
  305. echo '<a href="'. htmlspecialchars($tool['link']).(($tool['image'] == 'external.gif' || $tool['image'] == 'external_na.gif') ? '' : $qm_or_amp.api_get_cidreq()).'" target="' , $tool['target'], '" '.$class.'>';
  306. }
  307. $tool_name = self::translate_tool_name($tool);
  308. echo Display::return_icon($tool['image'], $tool_name),'&nbsp;', $tool_name,'</a>';
  309. // This part displays the links to hide or remove a tool.
  310. // These links are only visible by the course manager.
  311. unset($lnk);
  312. if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
  313. if ($tool['visibility'] == '1' || $tool['name'] == TOOL_TRACKING) {
  314. $link['name'] = Display::return_icon('remove.gif', get_lang('Deactivate'));
  315. $link['cmd'] = 'hide=yes';
  316. $lnk[] = $link;
  317. }
  318. if ($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN) {
  319. $link['name'] = Display::return_icon('add.gif', get_lang('Activate'));
  320. $link['cmd'] = 'restore=yes';
  321. $lnk[] = $link;
  322. if ($tool['added_tool'] == 1) {
  323. $link['name'] = Display::return_icon('delete.gif', get_lang('Remove'));
  324. $link['cmd'] = 'remove=yes';
  325. $lnk[] = $link;
  326. }
  327. }
  328. if ($tool['adminlink']) {
  329. echo '<a href="'.$tool['adminlink'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
  330. }
  331. }
  332. if (api_is_platform_admin() && !api_is_coach()) {
  333. if ($tool['visibility'] == 2) {
  334. $link['name'] = Display::return_icon('undelete.gif', get_lang('Activate'));
  335. $link['cmd'] = 'hide=yes';
  336. $lnk[] = $link;
  337. if ($tool['added_tool'] == 1) {
  338. $link['name'] = get_lang('Delete');
  339. $link['cmd'] = 'askDelete=yes';
  340. $lnk[] = $link;
  341. }
  342. }
  343. if ($tool['visibility'] == 0 && $tool['added_tool'] == 0) {
  344. $link['name'] = Display::return_icon('delete.gif', get_lang('Remove'));
  345. $link['cmd'] = 'remove=yes';
  346. $lnk[] = $link;
  347. }
  348. }
  349. if (is_array($lnk)) {
  350. foreach ($lnk as & $this_link) {
  351. if (!$tool['adminlink']) {
  352. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;id='.$tool['id'].'&amp;'.$this_link['cmd'].'">'.$this_link['name'].'</a>';
  353. }
  354. }
  355. }
  356. // Allow editing of invisible homepage links (modified external_module)
  357. if ($tool['added_tool'] == 1 && api_is_allowed_to_edit(null, true) && !$tool['visibility']
  358. && $tool['image'] != 'scormbuilder.gif' && $tool['image'] != 'scormbuilder_na.gif') {
  359. echo '<a class="nobold" href="'.api_get_path(WEB_CODE_PATH).'external_module/external_module.php?'.api_get_cidreq().'&amp;id='.$tool['id'].'">'.get_lang('Edit').'</a>';
  360. }
  361. echo "</td>";
  362. if ($i % 2) {
  363. echo "</tr>";
  364. }
  365. $i++;
  366. }
  367. }
  368. if ($i % 2) {
  369. echo "<td width=\"50%\">&nbsp;</td></tr>";
  370. }
  371. }
  372. /**
  373. * Gets the tools of a certain category. Returns an array expected
  374. * by show_tools_category()
  375. * @param string $course_tool_category contains the category of tools to
  376. * display: "toolauthoring", "toolinteraction", "tooladmin", "tooladminplatform", "toolplugin"
  377. * @return array
  378. */
  379. public static function get_tools_category($course_tool_category) {
  380. global $_user;
  381. $web_code_path = api_get_path(WEB_CODE_PATH);
  382. $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
  383. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  384. $is_platform_admin = api_is_platform_admin();
  385. $all_tools_list = array();
  386. // Condition for the session
  387. $session_id = api_get_session_id();
  388. $course_id = api_get_course_int_id();
  389. $condition_session = api_get_session_condition($session_id, true, true);
  390. $course_id_condition = api_get_course_table_condition();
  391. switch ($course_tool_category) {
  392. case TOOL_STUDENT_VIEW:
  393. $condition_display_tools = ' WHERE visibility = 1 AND (category = "authoring" OR category = "interaction" OR category = "plugin") ';
  394. if ((api_is_coach() || api_is_course_tutor()) && $_SESSION['studentview'] != 'studentview') {
  395. $condition_display_tools = ' WHERE (visibility = 1 AND (category = "authoring" OR category = "interaction" OR category = "plugin") OR (name = "'.TOOL_TRACKING.'") ) ';
  396. }
  397. $sql = "SELECT * FROM $course_tool_table $condition_display_tools AND c_id = $course_id $condition_session ORDER BY id";
  398. $result = Database::query($sql);
  399. $col_link ="##003399";
  400. break;
  401. case TOOL_AUTHORING:
  402. $sql = "SELECT * FROM $course_tool_table WHERE category = 'authoring' AND c_id = $course_id $condition_session ORDER BY id";
  403. $result = Database::query($sql);
  404. $col_link ="##003399";
  405. break;
  406. case TOOL_INTERACTION:
  407. $sql = "SELECT * FROM $course_tool_table WHERE category = 'interaction' AND c_id = $course_id $condition_session ORDER BY id";
  408. $result = Database::query($sql);
  409. $col_link ="##003399";
  410. break;
  411. case TOOL_ADMIN_VISIBLE:
  412. $sql = "SELECT * FROM $course_tool_table WHERE category = 'admin' AND visibility ='1' AND c_id = $course_id $condition_session ORDER BY id";
  413. $result = Database::query($sql);
  414. $col_link ="##003399";
  415. break;
  416. case TOOL_ADMIN_PLATFORM:
  417. $sql = "SELECT * FROM $course_tool_table WHERE category = 'admin' AND c_id = $course_id $condition_session ORDER BY id";
  418. $result = Database::query($sql);
  419. $col_link ="##003399";
  420. break;
  421. case TOOL_COURSE_PLUGIN:
  422. //Other queries recover id, name, link, image, visibility, admin, address, added_tool, target, category and session_id
  423. // but plugins are not present in the tool table, only globally and inside the course_settings table once configured
  424. $sql = "SELECT * FROM $course_tool_table WHERE category = 'plugin' AND c_id = $course_id $condition_session ORDER BY id";
  425. $result = Database::query($sql);
  426. break;
  427. }
  428. //Get the list of hidden tools - this might imply performance slowdowns
  429. // if the course homepage is loaded many times, so the list of hidden
  430. // tools might benefit from a shared memory storage later on
  431. $list = api_get_settings('Tools','list', api_get_current_access_url_id());
  432. $hide_list = array();
  433. $check = false;
  434. foreach ($list as $line) {
  435. if ($line['variable'] == 'course_hide_tools' and $line['selected_value'] == 'true') {
  436. $hide_list[] = $line['subkey'];
  437. $check = true;
  438. }
  439. }
  440. while ($temp_row = Database::fetch_assoc($result)) {
  441. if ($check) {
  442. if (!in_array($temp_row['name'],$hide_list)) {
  443. $all_tools_list[] = $temp_row;
  444. } else {
  445. }
  446. } else {
  447. $all_tools_list[] = $temp_row;
  448. }
  449. }
  450. /*if(api_is_course_coach()) {
  451. $result = Database::query("SELECT * FROM $course_tool_table WHERE name='tracking'");
  452. $all_tools_list[]=Database :: fetch_array($result);
  453. }*/
  454. $i = 0;
  455. // Grabbing all the links that have the property on_homepage set to 1
  456. $course_link_table = Database::get_course_table(TABLE_LINK);
  457. $course_item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
  458. $course_id = api_get_course_int_id();
  459. switch ($course_tool_category) {
  460. case TOOL_AUTHORING:
  461. $sql_links = "SELECT tl.*, tip.visibility
  462. FROM $course_link_table tl
  463. LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
  464. WHERE tl.c_id = $course_id AND
  465. tip.c_id = $course_id AND
  466. tl.on_homepage='1' $condition_session";
  467. break;
  468. case TOOL_INTERACTION:
  469. $sql_links = null;
  470. /*
  471. $sql_links = "SELECT tl.*, tip.visibility
  472. FROM $course_link_table tl
  473. LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
  474. WHERE tl.on_homepage='1' ";
  475. */
  476. break;
  477. case TOOL_STUDENT_VIEW:
  478. $sql_links = "SELECT tl.*, tip.visibility
  479. FROM $course_link_table tl
  480. LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
  481. WHERE tl.c_id = $course_id AND
  482. tip.c_id = $course_id AND
  483. tl.on_homepage ='1' $condition_session";
  484. break;
  485. case TOOL_ADMIN:
  486. $sql_links = "SELECT tl.*, tip.visibility
  487. FROM $course_link_table tl
  488. LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
  489. WHERE tl.c_id = $course_id AND
  490. tip.c_id = $course_id AND
  491. tl.on_homepage='1' $condition_session";
  492. break;
  493. default:
  494. $sql_links = null;
  495. break;
  496. }
  497. // Edited by Kevin Van Den Haute (kevin@develop-it.be) for integrating Smartblogs
  498. if ($sql_links != null) {
  499. $result_links = Database::query($sql_links);
  500. if (Database::num_rows($result_links) > 0) {
  501. while ($links_row = Database::fetch_array($result_links, 'ASSOC')) {
  502. $properties = array();
  503. $properties['name'] = $links_row['title'];
  504. $properties['session_id'] = $links_row['session_id'];
  505. $properties['link'] = $links_row['url'];
  506. $properties['visibility'] = $links_row['visibility'];
  507. $properties['image'] = ($links_row['visibility'] == '0') ? 'file_html.gif' : 'file_html.gif';
  508. $properties['adminlink'] = api_get_path(WEB_CODE_PATH).'link/link.php?action=editlink&id='.$links_row['id'];
  509. $properties['target'] = $links_row['target'];
  510. $tmp_all_tools_list[] = $properties;
  511. }
  512. }
  513. }
  514. if (isset($tmp_all_tools_list)) {
  515. foreach ($tmp_all_tools_list as $tool) {
  516. if ($tool['image'] == 'blog.gif') {
  517. // Init
  518. $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
  519. // Get blog id
  520. $blog_id = substr($tool['link'], strrpos($tool['link'], '=') + 1, strlen($tool['link']));
  521. // Get blog members
  522. if ($is_platform_admin) {
  523. $sql_blogs = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user WHERE blog_id =" . $blog_id;
  524. } else {
  525. $sql_blogs = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user WHERE blog_id =" . $blog_id . " AND user_id = " . api_get_user_id();
  526. }
  527. $result_blogs = Database::query($sql_blogs);
  528. if (Database::num_rows($result_blogs) > 0) {
  529. $all_tools_list[] = $tool;
  530. }
  531. } else {
  532. $all_tools_list[] = $tool;
  533. }
  534. }
  535. }
  536. return $all_tools_list;
  537. }
  538. /**
  539. * Displays the tools of a certain category.
  540. * @param array List of tools as returned by get_tools_category()
  541. * @param int rows
  542. * @return void
  543. */
  544. public static function show_tools_category($all_tools_list, $rows = false) {
  545. global $_user;
  546. $theme = api_get_setting('homepage_view');
  547. if ($theme == 'vertical_activity') {
  548. //ordering by get_lang name
  549. $order_tool_list = array();
  550. if (is_array($all_tools_list) && count($all_tools_list)>0) {
  551. foreach($all_tools_list as $key=>$new_tool) {
  552. $tool_name = self::translate_tool_name($new_tool);
  553. $order_tool_list [$key]= $tool_name;
  554. }
  555. natsort($order_tool_list);
  556. $my_temp_tool_array = array();
  557. foreach($order_tool_list as $key=>$new_tool) {
  558. $my_temp_tool_array[] = $all_tools_list[$key];
  559. }
  560. $all_tools_list = $my_temp_tool_array;
  561. } else {
  562. $all_tools_list = array();
  563. }
  564. }
  565. $web_code_path = api_get_path(WEB_CODE_PATH);
  566. $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
  567. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  568. $is_platform_admin = api_is_platform_admin();
  569. $i = 0;
  570. $items = array();
  571. if (isset($all_tools_list)) {
  572. $lnk = '';
  573. foreach ($all_tools_list as & $tool) {
  574. $item = array();
  575. if ($tool['image'] == 'scormbuilder.gif') {
  576. // display links to lp only for current session
  577. if (api_get_session_id() != $tool['session_id']) {
  578. continue;
  579. }
  580. // check if the published learnpath is visible for student
  581. $published_lp_id = self::get_published_lp_id_from_link($tool['link']);
  582. if (!api_is_allowed_to_edit(null, true) && !learnpath::is_lp_visible_for_student($published_lp_id,api_get_user_id())) {
  583. continue;
  584. }
  585. }
  586. if (api_get_session_id() != 0 && in_array($tool['name'], array('course_maintenance', 'course_setting'))) {
  587. continue;
  588. }
  589. // This part displays the links to hide or remove a tool.
  590. // These links are only visible by the course manager.
  591. unset($lnk);
  592. $item['extra'] = null;
  593. if ($is_allowed_to_edit && !api_is_coach()) {
  594. if ($tool['visibility'] == '1' && $tool['admin'] != '1') {
  595. $link['name'] = Display::return_icon('visible.gif', get_lang('Deactivate'), array('id' => 'linktool_'.$tool['id']));
  596. $link['cmd'] = 'hide=yes';
  597. $lnk[] = $link;
  598. }
  599. if ($tool['visibility'] == '0' && $tool['admin'] != '1') {
  600. $link['name'] = Display::return_icon('invisible.gif', get_lang('Activate'), array('id' => 'linktool_'.$tool['id']));
  601. $link['cmd'] = 'restore=yes';
  602. $lnk[] = $link;
  603. }
  604. if (!empty($tool['adminlink'])) {
  605. $item['extra'] = '<a href="'.$tool['adminlink'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
  606. }
  607. }
  608. // Both checks are necessary as is_platform_admin doesn't take student view into account
  609. if ($is_platform_admin && $is_allowed_to_edit) {
  610. if ($tool['admin'] != '1') {
  611. $link['cmd'] = 'hide=yes';
  612. }
  613. }
  614. $item['visibility'] = null;
  615. if (isset($lnk) && is_array($lnk)) {
  616. foreach ($lnk as $this_link) {
  617. if (empty($tool['adminlink'])) {
  618. $item['visibility'] .= '<a class="make_visible_and_invisible" href="'.api_get_self().'?'.api_get_cidreq().'&amp;id='.$tool['id'].'&amp;'.$this_link['cmd'].'">'.$this_link['name'].'</a>';
  619. }
  620. }
  621. } else {
  622. $item['visibility'] .= '&nbsp;&nbsp;&nbsp;&nbsp;';
  623. }
  624. // NOTE : Table contains only the image file name, not full path
  625. if (stripos($tool['link'], 'http://') === false && stripos($tool['link'], 'https://') === false && stripos($tool['link'], 'ftp://') === false) {
  626. $tool['link'] = $web_code_path.$tool['link'];
  627. }
  628. if ($tool['visibility'] == '0' && $tool['admin'] != '1') {
  629. $class = 'invisible';
  630. $info = pathinfo($tool['image']);
  631. $basename = basename($tool['image'], '.'.$info['extension']); // $file is set to "index"
  632. $tool['image'] = $basename.'_na.'.$info['extension'];
  633. } else {
  634. $class = '';
  635. }
  636. $qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&';
  637. // If it's a link, we don't add the cidReq
  638. if ($tool['image'] == 'file_html.gif' || $tool['image'] == 'file_html_na.gif') {
  639. $tool['link'] = $tool['link'].$qm_or_amp;
  640. } else {
  641. $tool['link'] = $tool['link'].$qm_or_amp.api_get_cidreq();
  642. }
  643. $tool_link_params = array();
  644. //$tool['link'] = htmlspecialchars($tool['link']) ;
  645. if (strpos($tool['name'],'visio_') !== false) {
  646. $tool_link_params = array('id' => 'tooldesc_'.$tool["id"],
  647. 'href' => '"javascript: void(0);"',
  648. 'class' => $class,
  649. 'onclick' => 'javascript: window.open(\'' . $tool['link'] . '\',\'window_visio'.$_SESSION['_cid'].'\',config=\'height=\'+730+\', width=\'+1020+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')',
  650. 'target' => $tool['target']);
  651. } elseif (strpos($tool['name'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) {
  652. $tool_link_params = array('id' => 'tooldesc_'.$tool["id"],
  653. 'class' => $class,
  654. 'href' => 'javascript: void(0);',
  655. 'onclick' => 'javascript: window.open(\'' . $tool['link'] . '\',\'window_chat'.$_SESSION['_cid'].'\',config=\'height=\'+380+\', width=\'+625+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')',
  656. 'target' => $tool['target']);
  657. } else {
  658. if (count(explode('type=classroom',$tool['link'])) == 2 || count(explode('type=conference', $tool['link'])) == 2) {
  659. $tool_link_params = array('id' => 'tooldesc_'.$tool["id"],
  660. 'href' => $tool['link'],
  661. 'class' => $class,
  662. 'target' => '_blank');
  663. } else {
  664. $tool_link_params = array('id' => 'tooldesc_'.$tool["id"],
  665. 'href' => $tool['link'],
  666. 'class' => $class,
  667. 'target' => $tool['target']);
  668. }
  669. }
  670. $tool_name = self::translate_tool_name($tool);
  671. $icon = Display::return_icon($tool['image'], $tool_name, array('class' => 'tool-icon', 'id' => 'toolimage_'.$tool['id']));
  672. // Validacion when belongs to a session
  673. $session_img = api_get_session_image($tool['session_id'], $_user['status']);
  674. $item['url_params'] = $tool_link_params;
  675. $item['icon'] = Display::url($icon, $tool_link_params['href'], $tool_link_params);
  676. $item['tool'] = $tool;
  677. $item['name'] = $tool_name;
  678. $tool_link_params['id'] = 'is'.$tool_link_params['id'];
  679. $item['link'] = Display::url($tool_name.$session_img, $tool_link_params['href'], $tool_link_params);
  680. $items[] = $item;
  681. $i++;
  682. } // end of foreach
  683. }
  684. $i = 0;
  685. if (!empty($items))
  686. foreach($items as $item) {
  687. switch($theme) {
  688. case 'activity_big':
  689. $data = '';
  690. if ($i == 0) {
  691. echo '<table style="width:100%">';
  692. }
  693. $row_per = 33;
  694. $mod = 3;
  695. if (isset($rows) && is_numeric($rows)) {
  696. $row_per = 25;
  697. $mod = $rows;
  698. }
  699. $mod_result = $mod - 1;
  700. if ($i % $mod == 0) {
  701. echo '<tr valign="top">';
  702. }
  703. echo '<td width="'.$row_per.'%">';
  704. $image = (substr($item['tool']['image'], 0, strpos($item['tool']['image'], '.'))).'.png';
  705. $image = Display::tag('center', Display::return_icon($image, $item['name'], array('id'=>'toolimage_'.$item['tool']['id']), 64));
  706. //experimental changes nothing serious
  707. //$my_icon = api_get_path(WEB_CODE_PATH).'img/icons/64/'.$image;
  708. //$image = Display::tag('span', Display::return_icon($image, $item['name'], array('id'=>'toolimage_'.$item['tool']['id'],'style'=>'opacity:0'), 64),array('class'=>'image-wrap','style'=>'background:url('.$my_icon.')'));
  709. $data .= Display::url($image , $item['url_params']['href'], $item['url_params']);
  710. echo Display::div($data, array('class'=>'big_icon')); //box-image reflection
  711. echo Display::tag('center', Display::div($item['visibility'].$item['extra'].$item['link'], array('class'=>'content')));
  712. echo '</td>';
  713. if ($i % $mod == $mod_result) {
  714. echo '</tr>';
  715. }
  716. if ($i == count($items) -1) {
  717. echo '</table>';
  718. }
  719. break;
  720. case 'activity':
  721. if ($i == 0) {
  722. echo '<table class="course_activity_home">';
  723. }
  724. if (!($i % 2)) {
  725. echo '<tr valign="top">';
  726. }
  727. echo '<td width="50%">';
  728. echo $item['extra'];
  729. echo $item['visibility'];
  730. echo $item['icon'];
  731. echo $item['link'];
  732. echo '</td>';
  733. if ($i % 2) {
  734. echo '</tr>';
  735. }
  736. if ($i == count($items) -1) {
  737. echo '</table>';
  738. }
  739. break;
  740. case 'vertical_activity':
  741. if ($i == 0) {
  742. echo '<ul>';
  743. }
  744. echo '<li>';
  745. echo $item['extra'];
  746. echo $item['visibility'];
  747. echo $item['icon'];
  748. echo $item['link'];
  749. echo '</li>';
  750. if ($i == count($items) -1) {
  751. echo '</ul>';
  752. }
  753. break;
  754. }
  755. $i++;
  756. }
  757. }
  758. /**
  759. * Shows the general data for a particular meeting
  760. *
  761. * @param id session id
  762. * @return string session data
  763. */
  764. public static function show_session_data($id_session) {
  765. $session_table = Database::get_main_table(TABLE_MAIN_SESSION);
  766. $user_table = Database::get_main_table(TABLE_MAIN_USER);
  767. $session_category_table = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
  768. if ($id_session != strval(intval($id_session))) {
  769. return '';
  770. } else {
  771. $id_session = intval($id_session);
  772. }
  773. $sql = 'SELECT name, nbr_courses, nbr_users, nbr_classes, DATE_FORMAT(date_start,"%d-%m-%Y") as date_start, DATE_FORMAT(date_end,"%d-%m-%Y") as date_end, lastname, firstname, username, session_admin_id, nb_days_access_before_beginning, nb_days_access_after_end, session_category_id, visibility
  774. FROM '.$session_table.'
  775. LEFT JOIN '.$user_table.'
  776. ON id_coach = user_id
  777. WHERE '.$session_table.'.id='.$id_session;
  778. $rs = Database::query($sql);
  779. $session = Database::store_result($rs);
  780. $session = $session[0];
  781. $sql_category = 'SELECT name FROM '.$session_category_table.' WHERE id = "'.intval($session['session_category_id']).'"';
  782. $rs_category = Database::query($sql_category);
  783. $session_category = '';
  784. if (Database::num_rows($rs_category) > 0) {
  785. $rows_session_category = Database::store_result($rs_category);
  786. $rows_session_category = $rows_session_category[0];
  787. $session_category = $rows_session_category['name'];
  788. }
  789. if ($session['date_start'] == '00-00-0000') {
  790. $msg_date = get_lang('NoTimeLimits');
  791. } else {
  792. $msg_date = get_lang('From').' '.$session['date_start'].' '.get_lang('To').' '.$session['date_end'];
  793. }
  794. $output = '';
  795. if (!empty($session_category)) {
  796. $output .= '<tr><td>'. get_lang('SessionCategory') . ': ' . '<b>' . $session_category .'</b></td></tr>';
  797. }
  798. $output .= '<tr><td style="width:50%">'. get_lang('SessionName') . ': ' . '<b>' . $session['name'] .'</b></td><td>'. get_lang('GeneralCoach') . ': ' . '<b>' . $session['lastname'].' '.$session['firstname'].' ('.$session['username'].')' .'</b></td></tr>';
  799. $output .= '<tr><td>'. get_lang('SessionIdentifier') . ': '. Display::return_icon('star.png', ' ', array('align' => 'absmiddle')) .'</td><td>'. get_lang('Date') . ': ' . '<b>' . $msg_date .'</b></td></tr>';
  800. return $output;
  801. }
  802. /**
  803. * Retrieves the name-field within a tool-record and translates it on necessity.
  804. * @param array $tool The input record.
  805. * @return string Returns the name of the corresponding tool.
  806. */
  807. public static function translate_tool_name(& $tool) {
  808. static $already_translated_icons = array(
  809. 'file_html.gif', 'file_html_na.gif',
  810. 'scormbuilder.gif', 'scormbuilder_na.gif',
  811. 'blog.gif', 'blog_na.gif',
  812. 'external.gif', 'external_na.gif'
  813. );
  814. if (in_array($tool['image'], $already_translated_icons)) {
  815. $tool_name = Security::remove_XSS(stripslashes($tool['name']));
  816. } else {
  817. /*
  818. // The following (slow) code was made in the past for transitional purposes.
  819. // We assume that the new language variables Tool* have been already translated.
  820. $variable = 'Tool'.api_underscore_to_camel_case($tool['name']); // The newly opened language variables.
  821. $variable_old = ucfirst($tool['name']); // The old language variables as a second chance.
  822. if (api_is_translated($variable)) {
  823. $tool_name = get_lang($variable);
  824. } elseif (api_is_translated($variable_old)) {
  825. $tool_name = get_lang($variable_old);
  826. } else {
  827. $tool_name = get_lang($variable);
  828. }
  829. */
  830. $tool_name = get_lang('Tool'.api_underscore_to_camel_case($tool['name']));
  831. }
  832. return $tool_name;
  833. }
  834. /**
  835. * Get published learning path id from link inside course home
  836. * @param string Link to published lp
  837. * @return int Learning path id
  838. */
  839. public static function get_published_lp_id_from_link($published_lp_link) {
  840. $lp_id = 0;
  841. $param_lp_id = strstr($published_lp_link, 'lp_id=');
  842. if (!empty($param_lp_id)) {
  843. $a_param_lp_id = explode('=',$param_lp_id);
  844. if (isset($a_param_lp_id[1])) {
  845. $lp_id = intval($a_param_lp_id[1]);
  846. }
  847. }
  848. return $lp_id;
  849. }
  850. }