course_home.lib.php 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use Chamilo\CourseBundle\Entity\CTool;
  4. use Chamilo\CourseBundle\Entity\CLpCategory;
  5. /**
  6. * Class CourseHome
  7. */
  8. class CourseHome
  9. {
  10. /**
  11. * Gets the html content to show in the 3 column view
  12. * @param string $cat
  13. * @param int $userId
  14. * @return string
  15. */
  16. public static function show_tool_3column($cat, $userId = null)
  17. {
  18. $_user = api_get_user_info($userId);
  19. $TBL_ACCUEIL = Database::get_course_table(TABLE_TOOL_LIST);
  20. $TABLE_TOOLS = Database::get_main_table(TABLE_MAIN_COURSE_MODULE);
  21. $numcols = 3;
  22. $table = new HTML_Table('width="100%"');
  23. $all_tools = array();
  24. $course_id = api_get_course_int_id();
  25. switch ($cat) {
  26. case 'Basic':
  27. $condition_display_tools = ' WHERE a.c_id = '.$course_id.' AND a.link=t.link AND t.position="basic" ';
  28. if ((api_is_coach() || api_is_course_tutor()) && $_SESSION['studentview'] != 'studentview') {
  29. $condition_display_tools = ' WHERE a.c_id = '.$course_id.' AND a.link=t.link AND (t.position="basic" OR a.name = "'.TOOL_TRACKING.'") ';
  30. }
  31. $sql = "SELECT a.*, t.image img, t.row, t.column FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
  32. $condition_display_tools ORDER BY t.row, t.column";
  33. break;
  34. case 'External':
  35. if (api_is_allowed_to_edit()) {
  36. $sql = "SELECT a.*, t.image img FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
  37. WHERE a.c_id = $course_id AND ((a.link=t.link AND t.position='external')
  38. OR (a.visibility <= 1 AND (a.image = 'external.gif' OR a.image = 'scormbuilder.gif' OR t.image = 'blog.gif') AND a.image=t.image))
  39. ORDER BY a.id";
  40. } else {
  41. $sql = "SELECT a.*, t.image img FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
  42. WHERE a.c_id = $course_id AND (a.visibility = 1 AND ((a.link=t.link AND t.position='external')
  43. OR ((a.image = 'external.gif' OR a.image = 'scormbuilder.gif' OR t.image = 'blog.gif') AND a.image=t.image)))
  44. ORDER BY a.id";
  45. }
  46. break;
  47. case 'courseAdmin':
  48. $sql = "SELECT a.*, t.image img, t.row, t.column FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
  49. WHERE a.c_id = $course_id AND admin=1 AND a.link=t.link ORDER BY t.row, t.column";
  50. break;
  51. case 'platformAdmin':
  52. $sql = "SELECT *, image img FROM $TBL_ACCUEIL WHERE c_id = $course_id AND visibility = 2 ORDER BY id";
  53. }
  54. $result = Database::query($sql);
  55. // Grabbing all the tools from $course_tool_table
  56. while ($tool = Database::fetch_array($result)) {
  57. $all_tools[] = $tool;
  58. }
  59. $course_id = api_get_course_int_id();
  60. // Grabbing all the links that have the property on_homepage set to 1
  61. if ($cat == 'External') {
  62. $tbl_link = Database::get_course_table(TABLE_LINK);
  63. $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
  64. if (api_is_allowed_to_edit(null, true)) {
  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 != 2";
  72. } else {
  73. $sql_links = "SELECT tl.*, tip.visibility
  74. FROM $tbl_link tl
  75. LEFT JOIN $tbl_item_property tip ON tip.tool='link' AND tip.ref=tl.id
  76. WHERE tl.c_id = $course_id AND
  77. tip.c_id = $course_id AND
  78. tl.on_homepage='1' AND
  79. tip.visibility = 1";
  80. }
  81. $result_links = Database::query($sql_links);
  82. while ($links_row = Database::fetch_array($result_links)) {
  83. $properties = array();
  84. $properties['name'] = $links_row['title'];
  85. $properties['link'] = $links_row['url'];
  86. $properties['visibility'] = $links_row['visibility'];
  87. $properties['img'] = 'external.gif';
  88. $properties['adminlink'] = api_get_path(WEB_CODE_PATH).'link/link.php?action=editlink&amp;id='.$links_row['id'];
  89. $all_tools[] = $properties;
  90. }
  91. }
  92. $cell_number = 0;
  93. // Draw line between basic and external, only if there are entries in External
  94. if ($cat == 'External' && count($all_tools)) {
  95. $table->setCellContents(0, 0, '<hr noshade="noshade" size="1"/>');
  96. $table->updateCellAttributes(0, 0, 'colspan="3"');
  97. $cell_number += $numcols;
  98. }
  99. foreach ($all_tools as & $tool) {
  100. if ($tool['image'] == 'scormbuilder.gif') {
  101. // check if the published learnpath is visible for student
  102. $published_lp_id = self::get_published_lp_id_from_link($tool['link']);
  103. if (!api_is_allowed_to_edit(null, true) &&
  104. !learnpath::is_lp_visible_for_student(
  105. $published_lp_id,
  106. api_get_user_id(),
  107. api_get_course_id(),
  108. api_get_session_id()
  109. )
  110. ) {
  111. continue;
  112. }
  113. }
  114. if (api_get_session_id() != 0 &&
  115. in_array($tool['name'], array('course_maintenance', 'course_setting'))
  116. ) {
  117. continue;
  118. }
  119. $cell_content = '';
  120. // The name of the tool
  121. $tool_name = self::translate_tool_name($tool);
  122. $link_annex = '';
  123. // The url of the tool
  124. if ($tool['img'] != 'external.gif') {
  125. $tool['link'] = api_get_path(WEB_CODE_PATH).$tool['link'];
  126. $qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&amp;';
  127. $link_annex = $qm_or_amp.api_get_cidreq();
  128. } else {
  129. // If an external link ends with 'login=', add the actual login...
  130. $pos = strpos($tool['link'], '?login=');
  131. $pos2 = strpos($tool['link'], '&amp;login=');
  132. if ($pos !== false or $pos2 !== false) {
  133. $link_annex = $_user['username'];
  134. }
  135. }
  136. // Setting the actual image url
  137. $tool['img'] = Display::returnIconPath($tool['img']);
  138. // VISIBLE
  139. if (($tool['visibility'] ||
  140. ((api_is_coach() || api_is_course_tutor()) && $tool['name'] == TOOL_TRACKING)) ||
  141. $cat == 'courseAdmin' || $cat == 'platformAdmin'
  142. ) {
  143. if (strpos($tool['name'], 'visio_') !== false) {
  144. $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>';
  145. } elseif (strpos($tool['name'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) {
  146. $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>';
  147. // don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img']
  148. } else {
  149. $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>';
  150. // don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img']
  151. }
  152. } else {
  153. // INVISIBLE
  154. if (api_is_allowed_to_edit(null, true)) {
  155. if (strpos($tool['name'], 'visio_') !== false) {
  156. $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>';
  157. } elseif (strpos($tool['name'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) {
  158. $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>';
  159. // don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img']
  160. } else {
  161. $cell_content .= '<a href="'.$tool['link'].$link_annex.'" target="'.$tool['target'].'" class="text-muted">
  162. <img src="'.str_replace(".gif", "_na.gif", $tool['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>';
  163. // don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img']
  164. }
  165. } else {
  166. $cell_content .= '<img src="'.str_replace(".gif", "_na.gif", $tool['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">';
  167. // don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img']
  168. $cell_content .= '<span class="text-muted">'.$tool_name.'</span>';
  169. }
  170. }
  171. $lnk = array();
  172. if (api_is_allowed_to_edit(null, true) &&
  173. $cat != "courseAdmin" &&
  174. !strpos($tool['link'], 'learnpath_handler.php?learnpath_id') &&
  175. !api_is_coach()
  176. ) {
  177. if ($tool['visibility']) {
  178. $link['name'] = Display::return_icon('remove.gif', get_lang('Deactivate'), array('style' => 'vertical-align: middle;'));
  179. $link['cmd'] = "hide=yes";
  180. $lnk[] = $link;
  181. } else {
  182. $link['name'] = Display::return_icon('add.gif', get_lang('Activate'), array('style' => 'vertical-align: middle;'));
  183. $link['cmd'] = "restore=yes";
  184. $lnk[] = $link;
  185. }
  186. if (is_array($lnk)) {
  187. foreach ($lnk as & $this_lnk) {
  188. if ($tool['adminlink']) {
  189. $cell_content .= '<a href="'.$properties['adminlink'].'">'.
  190. Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
  191. } else {
  192. $cell_content .= '<a href="'.api_get_self().'?id='.$tool['id'].'&amp;'.$this_lnk['cmd'].'">'.$this_lnk['name'].'</a>';
  193. }
  194. }
  195. }
  196. }
  197. $table->setCellContents($cell_number / $numcols, ($cell_number) % $numcols, $cell_content);
  198. $table->updateCellAttributes($cell_number / $numcols, ($cell_number) % $numcols, 'width="32%" height="42"');
  199. $cell_number++;
  200. }
  201. return $table->toHtml();
  202. }
  203. /**
  204. * Displays the tools of a certain category.
  205. *
  206. * @return void
  207. * @param string $course_tool_category contains the category of tools to display:
  208. * "Public", "PublicButHide", "courseAdmin", "claroAdmin"
  209. */
  210. public static function show_tool_2column($course_tool_category)
  211. {
  212. $html = '';
  213. $web_code_path = api_get_path(WEB_CODE_PATH);
  214. $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
  215. $course_id = api_get_course_int_id();
  216. switch ($course_tool_category) {
  217. case TOOL_PUBLIC:
  218. $condition_display_tools = ' WHERE c_id = '.$course_id.' AND visibility = 1 ';
  219. if ((api_is_coach() || api_is_course_tutor()) && $_SESSION['studentview'] != 'studentview') {
  220. $condition_display_tools = ' WHERE c_id = '.$course_id.' AND (visibility = 1 OR (visibility = 0 AND name = "'.TOOL_TRACKING.'")) ';
  221. }
  222. $result = Database::query("SELECT * FROM $course_tool_table $condition_display_tools ORDER BY id");
  223. $col_link = "##003399";
  224. break;
  225. case TOOL_PUBLIC_BUT_HIDDEN:
  226. $result = Database::query("SELECT * FROM $course_tool_table WHERE c_id = $course_id AND visibility=0 AND admin=0 ORDER BY id");
  227. $col_link = "##808080";
  228. break;
  229. case TOOL_COURSE_ADMIN:
  230. $result = Database::query("SELECT * FROM $course_tool_table WHERE c_id = $course_id AND admin=1 AND visibility != 2 ORDER BY id");
  231. $col_link = "##003399";
  232. break;
  233. case TOOL_PLATFORM_ADMIN:
  234. $result = Database::query("SELECT * FROM $course_tool_table WHERE c_id = $course_id AND visibility = 2 ORDER BY id");
  235. $col_link = "##003399";
  236. }
  237. $i = 0;
  238. // Grabbing all the tools from $course_tool_table
  239. while ($temp_row = Database::fetch_array($result)) {
  240. if ($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN && $temp_row['image'] != 'scormbuilder.gif') {
  241. $temp_row['image'] = str_replace('.gif', '_na.gif', $temp_row['image']);
  242. }
  243. $all_tools_list[] = $temp_row;
  244. }
  245. // Grabbing all the links that have the property on_homepage set to 1
  246. $course_link_table = Database::get_course_table(TABLE_LINK);
  247. $course_item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
  248. switch ($course_tool_category) {
  249. case TOOL_PUBLIC:
  250. $sql_links = "SELECT tl.*, tip.visibility
  251. FROM $course_link_table tl
  252. 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
  253. WHERE tl.on_homepage='1' AND tip.visibility = 1";
  254. break;
  255. case TOOL_PUBLIC_BUT_HIDDEN:
  256. $sql_links = "SELECT tl.*, tip.visibility
  257. FROM $course_link_table tl
  258. 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
  259. WHERE tl.on_homepage='1' AND tip.visibility = 0";
  260. break;
  261. default:
  262. $sql_links = null;
  263. break;
  264. }
  265. if ($sql_links != null) {
  266. $properties = array();
  267. $result_links = Database::query($sql_links);
  268. while ($links_row = Database::fetch_array($result_links)) {
  269. unset($properties);
  270. $properties['name'] = $links_row['title'];
  271. $properties['link'] = $links_row['url'];
  272. $properties['visibility'] = $links_row['visibility'];
  273. $properties['image'] = $course_tool_category == TOOL_PUBLIC_BUT_HIDDEN ? 'external_na.gif' : 'external.gif';
  274. $properties['adminlink'] = api_get_path(WEB_CODE_PATH).'link/link.php?action=editlink&id='.$links_row['id'];
  275. $all_tools_list[] = $properties;
  276. }
  277. }
  278. if (isset($all_tools_list)) {
  279. $lnk = array();
  280. foreach ($all_tools_list as & $tool) {
  281. if ($tool['image'] == 'scormbuilder.gif') {
  282. // check if the published learnpath is visible for student
  283. $published_lp_id = self::get_published_lp_id_from_link($tool['link']);
  284. if (!api_is_allowed_to_edit(null, true) &&
  285. !learnpath::is_lp_visible_for_student(
  286. $published_lp_id,
  287. api_get_user_id(),
  288. api_get_course_id(),
  289. api_get_session_id()
  290. )
  291. ) {
  292. continue;
  293. }
  294. }
  295. if (api_get_session_id() != 0 &&
  296. in_array($tool['name'], array('course_maintenance', 'course_setting'))
  297. ) {
  298. continue;
  299. }
  300. if (!($i % 2)) {
  301. $html .= "<tr valign=\"top\">";
  302. }
  303. // NOTE : Table contains only the image file name, not full path
  304. if (stripos($tool['link'], 'http://') === false &&
  305. stripos($tool['link'], 'https://') === false &&
  306. stripos($tool['link'], 'ftp://') === false
  307. ) {
  308. $tool['link'] = $web_code_path.$tool['link'];
  309. }
  310. $class = '';
  311. if ($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN) {
  312. $class = 'class="text-muted"';
  313. }
  314. $qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&amp;';
  315. $tool['link'] = $tool['link'];
  316. $html .= '<td width="50%" height="30">';
  317. if (strpos($tool['name'], 'visio_') !== false) {
  318. $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'].'">';
  319. } elseif (strpos($tool['name'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) {
  320. $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.'>';
  321. } else {
  322. $html .= '<a href="'.htmlspecialchars($tool['link']).(($tool['image'] == 'external.gif' || $tool['image'] == 'external_na.gif') ? '' : $qm_or_amp.api_get_cidreq()).'" target="'.$tool['target'].'" '.$class.'>';
  323. }
  324. $tool_name = self::translate_tool_name($tool);
  325. $html .= Display::return_icon(
  326. $tool['image'],
  327. $tool_name,
  328. array(),
  329. null,
  330. ICON_SIZE_MEDIUM
  331. ).'&nbsp;'.$tool_name.'</a>';
  332. // This part displays the links to hide or remove a tool.
  333. // These links are only visible by the course manager.
  334. unset($lnk);
  335. if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
  336. if ($tool['visibility'] == '1' || $tool['name'] == TOOL_TRACKING) {
  337. $link['name'] = Display::returnFontAwesomeIcon('minus');
  338. $link['title'] = get_lang('Deactivate');
  339. $link['cmd'] = 'hide=yes';
  340. $lnk[] = $link;
  341. }
  342. if ($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN) {
  343. //$link['name'] = Display::return_icon('add.gif', get_lang('Activate'));
  344. $link['name'] = Display::returnFontAwesomeIcon('plus');
  345. $link['title'] = get_lang('Activate');
  346. $link['cmd'] = 'restore=yes';
  347. $lnk[] = $link;
  348. if ($tool['added_tool'] == 1) {
  349. //$link['name'] = Display::return_icon('delete.gif', get_lang('Remove'));
  350. $link['name'] = Display::returnFontAwesomeIcon('trash');
  351. $link['title'] = get_lang('Remove');
  352. $link['cmd'] = 'remove=yes';
  353. $lnk[] = $link;
  354. }
  355. }
  356. if (isset($tool['adminlink'])) {
  357. $html .= '<a href="'.$tool['adminlink'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
  358. }
  359. }
  360. if (api_is_platform_admin() && !api_is_coach()) {
  361. if ($tool['visibility'] == 2) {
  362. $link['name'] = Display::returnFontAwesomeIcon('undo');
  363. $link['title'] = get_lang('Activate');
  364. $link['cmd'] = 'hide=yes';
  365. $lnk[] = $link;
  366. if ($tool['added_tool'] == 1) {
  367. $link['name'] = get_lang('Delete');
  368. $link['cmd'] = 'askDelete=yes';
  369. $lnk[] = $link;
  370. }
  371. }
  372. if ($tool['visibility'] == 0 && $tool['added_tool'] == 0) {
  373. $link['name'] = Display::returnFontAwesomeIcon('trash');
  374. $link['title'] = get_lang('Remove');
  375. $link['cmd'] = 'remove=yes';
  376. $lnk[] = $link;
  377. }
  378. }
  379. if (is_array($lnk)) {
  380. $html .= '<div class="pull-right">';
  381. $html .= '<div class="btn-options">';
  382. $html .= '<div class="btn-group btn-group-sm" role="group">';
  383. foreach ($lnk as & $this_link) {
  384. if (!isset($tool['adminlink'])) {
  385. $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>';
  386. }
  387. }
  388. $html .= '</div>';
  389. $html .= '</div>';
  390. $html .= '</div>';
  391. }
  392. $html .= "</td>";
  393. if ($i % 2) {
  394. $html .= "</tr>";
  395. }
  396. $i++;
  397. }
  398. }
  399. if ($i % 2) {
  400. $html .= "<td width=\"50%\">&nbsp;</td></tr>";
  401. }
  402. return $html;
  403. }
  404. /**
  405. * Gets the tools of a certain category. Returns an array expected
  406. * by show_tools_category()
  407. * @param string $course_tool_category contains the category of tools to
  408. * display: "toolauthoring", "toolinteraction", "tooladmin", "tooladminplatform", "toolplugin"
  409. * @param int $courseId Optional
  410. * @param int $sessionId Optional
  411. * @return array
  412. */
  413. public static function get_tools_category($course_tool_category, $courseId = 0, $sessionId = 0)
  414. {
  415. $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
  416. $is_platform_admin = api_is_platform_admin();
  417. $all_tools_list = array();
  418. // Condition for the session
  419. $session_id = $sessionId ?: api_get_session_id();
  420. $course_id = $courseId ?: api_get_course_int_id();
  421. $userId = api_get_user_id();
  422. $user = api_get_user_entity($userId);
  423. $condition_session = api_get_session_condition(
  424. $session_id,
  425. true,
  426. true,
  427. 't.session_id'
  428. );
  429. switch ($course_tool_category) {
  430. case TOOL_STUDENT_VIEW:
  431. $conditions = ' WHERE visibility = 1 AND (category = "authoring" OR category = "interaction" OR category = "plugin") ';
  432. if ((api_is_coach() || api_is_course_tutor()) && $_SESSION['studentview'] != 'studentview') {
  433. $conditions = ' WHERE (visibility = 1 AND (category = "authoring" OR category = "interaction" OR category = "plugin") OR (name = "'.TOOL_TRACKING.'") ) ';
  434. }
  435. $sql = "SELECT *
  436. FROM $course_tool_table t
  437. $conditions AND
  438. c_id = $course_id $condition_session
  439. ORDER BY id";
  440. $result = Database::query($sql);
  441. break;
  442. case TOOL_AUTHORING:
  443. $sql = "SELECT * FROM $course_tool_table t
  444. WHERE category = 'authoring' AND c_id = $course_id $condition_session
  445. ORDER BY id";
  446. $result = Database::query($sql);
  447. break;
  448. case TOOL_INTERACTION:
  449. $sql = "SELECT * FROM $course_tool_table t
  450. WHERE category = 'interaction' AND c_id = $course_id $condition_session
  451. ORDER BY id";
  452. $result = Database::query($sql);
  453. break;
  454. case TOOL_ADMIN_VISIBLE:
  455. $sql = "SELECT * FROM $course_tool_table t
  456. WHERE category = 'admin' AND visibility ='1' AND c_id = $course_id $condition_session
  457. ORDER BY id";
  458. $result = Database::query($sql);
  459. break;
  460. case TOOL_ADMIN_PLATFORM:
  461. $sql = "SELECT * FROM $course_tool_table t
  462. WHERE category = 'admin' AND c_id = $course_id $condition_session
  463. ORDER BY id";
  464. $result = Database::query($sql);
  465. break;
  466. case TOOL_DRH:
  467. $sql = "SELECT * FROM $course_tool_table t
  468. WHERE name IN ('tracking') AND c_id = $course_id $condition_session
  469. ORDER BY id";
  470. $result = Database::query($sql);
  471. break;
  472. case TOOL_COURSE_PLUGIN:
  473. //Other queries recover id, name, link, image, visibility, admin, address, added_tool, target, category and session_id
  474. // but plugins are not present in the tool table, only globally and inside the course_settings table once configured
  475. $sql = "SELECT * FROM $course_tool_table t
  476. WHERE category = 'plugin' AND name <> 'courseblock' AND c_id = $course_id $condition_session
  477. ORDER BY id";
  478. $result = Database::query($sql);
  479. break;
  480. }
  481. //Get the list of hidden tools - this might imply performance slowdowns
  482. // if the course homepage is loaded many times, so the list of hidden
  483. // tools might benefit from a shared memory storage later on
  484. $list = api_get_settings('Tools', 'list', api_get_current_access_url_id());
  485. $hide_list = array();
  486. $check = false;
  487. foreach ($list as $line) {
  488. // Admin can see all tools even if the course_hide_tools configuration is set
  489. if ($is_platform_admin) {
  490. continue;
  491. }
  492. if ($line['variable'] == 'course_hide_tools' and $line['selected_value'] == 'true') {
  493. $hide_list[] = $line['subkey'];
  494. $check = true;
  495. }
  496. }
  497. $allowEditionInSession = api_get_configuration_value('allow_edit_tool_visibility_in_session');
  498. while ($temp_row = Database::fetch_assoc($result)) {
  499. $add = false;
  500. if ($check) {
  501. if (!in_array($temp_row['name'], $hide_list)) {
  502. $add = true;
  503. }
  504. } else {
  505. $add = true;
  506. }
  507. if ($allowEditionInSession && !empty($session_id)) {
  508. // Checking if exist row in session
  509. $criteria = [
  510. 'cId' => $course_id,
  511. 'name' => $temp_row['name'],
  512. 'sessionId' => $session_id,
  513. ];
  514. /** @var CTool $tool */
  515. $toolObj = Database::getManager()->getRepository('ChamiloCourseBundle:CTool')->findOneBy($criteria);
  516. if ($toolObj) {
  517. if ($toolObj->getVisibility() == 0) {
  518. continue;
  519. }
  520. }
  521. }
  522. if ($temp_row['image'] == 'scormbuilder.gif') {
  523. $lp_id = self::get_published_lp_id_from_link($temp_row['link']);
  524. $lp = new learnpath(
  525. api_get_course_id(),
  526. $lp_id,
  527. $userId
  528. );
  529. $path = $lp->get_preview_image_path(ICON_SIZE_BIG);
  530. $add = learnpath::is_lp_visible_for_student(
  531. $lp_id,
  532. $userId,
  533. api_get_course_id(),
  534. api_get_session_id()
  535. );
  536. if ($path) {
  537. $temp_row['custom_image'] = $path;
  538. }
  539. }
  540. if ($temp_row['image'] === 'lp_category.gif') {
  541. $lpCategory = self::getPublishedLpCategoryFromLink(
  542. $temp_row['link']
  543. );
  544. $add = learnpath::categoryIsVisibleForStudent(
  545. $lpCategory,
  546. $user
  547. );
  548. }
  549. if ($add) {
  550. $all_tools_list[] = $temp_row;
  551. }
  552. }
  553. // Grabbing all the links that have the property on_homepage set to 1
  554. $course_link_table = Database::get_course_table(TABLE_LINK);
  555. $course_item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
  556. $condition_session = api_get_session_condition($session_id, true, true, 'tip.session_id');
  557. switch ($course_tool_category) {
  558. case TOOL_AUTHORING:
  559. $sql_links = "SELECT tl.*, tip.visibility
  560. FROM $course_link_table tl
  561. LEFT JOIN $course_item_property_table tip
  562. ON tip.tool='link' AND tip.ref=tl.id
  563. WHERE
  564. tl.c_id = $course_id AND
  565. tip.c_id = $course_id AND
  566. tl.on_homepage='1' $condition_session";
  567. break;
  568. case TOOL_INTERACTION:
  569. $sql_links = null;
  570. /*
  571. $sql_links = "SELECT tl.*, tip.visibility
  572. FROM $course_link_table tl
  573. LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tip.ref=tl.id
  574. WHERE tl.on_homepage='1' ";
  575. */
  576. break;
  577. case TOOL_STUDENT_VIEW:
  578. $sql_links = "SELECT tl.*, tip.visibility
  579. FROM $course_link_table tl
  580. LEFT JOIN $course_item_property_table tip
  581. ON tip.tool='link' AND tip.ref=tl.id
  582. WHERE
  583. tl.c_id = $course_id AND
  584. tip.c_id = $course_id AND
  585. tl.on_homepage ='1' $condition_session";
  586. break;
  587. case TOOL_ADMIN:
  588. $sql_links = "SELECT tl.*, tip.visibility
  589. FROM $course_link_table tl
  590. LEFT JOIN $course_item_property_table tip
  591. ON tip.tool='link' AND tip.ref=tl.id
  592. WHERE
  593. tl.c_id = $course_id AND
  594. tip.c_id = $course_id AND
  595. tl.on_homepage='1' $condition_session";
  596. break;
  597. default:
  598. $sql_links = null;
  599. break;
  600. }
  601. // Edited by Kevin Van Den Haute (kevin@develop-it.be) for integrating Smartblogs
  602. if ($sql_links != null) {
  603. $result_links = Database::query($sql_links);
  604. if (Database::num_rows($result_links) > 0) {
  605. while ($links_row = Database::fetch_array($result_links, 'ASSOC')) {
  606. $properties = array();
  607. $properties['name'] = $links_row['title'];
  608. $properties['session_id'] = $links_row['session_id'];
  609. $properties['link'] = $links_row['url'];
  610. $properties['visibility'] = $links_row['visibility'];
  611. $properties['image'] = $links_row['visibility'] == '0' ? 'file_html.png' : 'file_html.png';
  612. $properties['adminlink'] = api_get_path(WEB_CODE_PATH).'link/link.php?action=editlink&id='.$links_row['id'];
  613. $properties['target'] = $links_row['target'];
  614. $tmp_all_tools_list[] = $properties;
  615. }
  616. }
  617. }
  618. if (isset($tmp_all_tools_list)) {
  619. foreach ($tmp_all_tools_list as $tool) {
  620. if ($tool['image'] == 'blog.gif') {
  621. // Init
  622. $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
  623. // Get blog id
  624. $blog_id = substr($tool['link'], strrpos($tool['link'], '=') + 1, strlen($tool['link']));
  625. // Get blog members
  626. if ($is_platform_admin) {
  627. $sql_blogs = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user
  628. WHERE blog_id =".$blog_id;
  629. } else {
  630. $sql_blogs = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user
  631. WHERE blog_id =".$blog_id." AND user_id = ".$userId;
  632. }
  633. $result_blogs = Database::query($sql_blogs);
  634. if (Database::num_rows($result_blogs) > 0) {
  635. $all_tools_list[] = $tool;
  636. }
  637. } else {
  638. $all_tools_list[] = $tool;
  639. }
  640. }
  641. }
  642. return $all_tools_list;
  643. }
  644. /**
  645. * Displays the tools of a certain category.
  646. * @param array $all_tools_list List of tools as returned by get_tools_category()
  647. * @param bool $rows
  648. *
  649. * @return string
  650. */
  651. public static function show_tools_category($all_tools_list, $rows = false)
  652. {
  653. $_user = api_get_user_info();
  654. $theme = api_get_setting('homepage_view');
  655. if ($theme === 'vertical_activity') {
  656. //ordering by get_lang name
  657. $order_tool_list = array();
  658. if (is_array($all_tools_list) && count($all_tools_list) > 0) {
  659. foreach ($all_tools_list as $key => $new_tool) {
  660. $tool_name = self::translate_tool_name($new_tool);
  661. $order_tool_list [$key] = $tool_name;
  662. }
  663. natsort($order_tool_list);
  664. $my_temp_tool_array = array();
  665. foreach ($order_tool_list as $key => $new_tool) {
  666. $my_temp_tool_array[] = $all_tools_list[$key];
  667. }
  668. $all_tools_list = $my_temp_tool_array;
  669. } else {
  670. $all_tools_list = array();
  671. }
  672. }
  673. $web_code_path = api_get_path(WEB_CODE_PATH);
  674. $session_id = api_get_session_id();
  675. $is_platform_admin = api_is_platform_admin();
  676. $allowEditionInSession = api_get_configuration_value('allow_edit_tool_visibility_in_session');
  677. if ($session_id == 0) {
  678. $is_allowed_to_edit = api_is_allowed_to_edit(null, true) && api_is_course_admin();
  679. } else {
  680. $is_allowed_to_edit = api_is_allowed_to_edit(null, true) && !api_is_coach();
  681. if ($allowEditionInSession) {
  682. $is_allowed_to_edit = api_is_allowed_to_edit(null, true) && api_is_coach($session_id, api_get_course_int_id());
  683. }
  684. }
  685. $i = 0;
  686. $items = array();
  687. $app_plugin = new AppPlugin();
  688. if (isset($all_tools_list)) {
  689. $lnk = '';
  690. foreach ($all_tools_list as & $tool) {
  691. $item = array();
  692. $studentview = false;
  693. $tool['original_link'] = $tool['link'];
  694. if ($tool['image'] == 'scormbuilder.gif') {
  695. // check if the published learnpath is visible for student
  696. $published_lp_id = self::get_published_lp_id_from_link($tool['link']);
  697. if (api_is_allowed_to_edit(null, true)) {
  698. $studentview = true;
  699. }
  700. if (!api_is_allowed_to_edit(null, true) &&
  701. !learnpath::is_lp_visible_for_student(
  702. $published_lp_id,
  703. api_get_user_id(),
  704. api_get_course_id(),
  705. api_get_session_id()
  706. )
  707. ) {
  708. continue;
  709. }
  710. }
  711. if ($session_id != 0 && in_array($tool['name'], array('course_setting'))) {
  712. continue;
  713. }
  714. // This part displays the links to hide or remove a tool.
  715. // These links are only visible by the course manager.
  716. unset($lnk);
  717. $item['extra'] = null;
  718. $toolAdmin = isset($tool['admin']) ? $tool['admin'] : '';
  719. if ($is_allowed_to_edit) {
  720. if (empty($session_id)) {
  721. if (isset($tool['id'])) {
  722. if ($tool['visibility'] == '1' && $toolAdmin != '1') {
  723. $link['name'] = Display::return_icon(
  724. 'visible.png',
  725. get_lang('Deactivate'),
  726. array('id' => 'linktool_'.$tool['id']),
  727. ICON_SIZE_SMALL,
  728. false
  729. );
  730. $link['cmd'] = 'hide=yes';
  731. $lnk[] = $link;
  732. }
  733. if ($tool['visibility'] == '0' && $toolAdmin != '1') {
  734. $link['name'] = Display::return_icon(
  735. 'invisible.png',
  736. get_lang('Activate'),
  737. array('id' => 'linktool_'.$tool['id']),
  738. ICON_SIZE_SMALL,
  739. false
  740. );
  741. $link['cmd'] = 'restore=yes';
  742. $lnk[] = $link;
  743. }
  744. }
  745. } elseif ($allowEditionInSession) {
  746. $criteria = [
  747. 'cId' => api_get_course_int_id(),
  748. 'name' => $tool['name'],
  749. 'sessionId' => $session_id
  750. ];
  751. /** @var CTool $tool */
  752. $toolObj = Database::getManager()->getRepository('ChamiloCourseBundle:CTool')->findOneBy($criteria);
  753. if ($toolObj) {
  754. $visibility = $toolObj->getVisibility();
  755. switch ($visibility) {
  756. case '0':
  757. $link['name'] = Display::return_icon(
  758. 'invisible.png',
  759. get_lang('Activate'),
  760. array('id' => 'linktool_'.$tool['iid']),
  761. ICON_SIZE_SMALL,
  762. false
  763. );
  764. $link['cmd'] = 'restore=yes';
  765. $lnk[] = $link;
  766. break;
  767. case '1':
  768. $link['name'] = Display::return_icon(
  769. 'visible.png',
  770. get_lang('Deactivate'),
  771. array('id' => 'linktool_'.$tool['iid']),
  772. ICON_SIZE_SMALL,
  773. false
  774. );
  775. $link['cmd'] = 'hide=yes';
  776. $lnk[] = $link;
  777. break;
  778. }
  779. } else {
  780. $link['name'] = Display::return_icon(
  781. 'visible.png',
  782. get_lang('Deactivate'),
  783. array('id' => 'linktool_'.$tool['iid']),
  784. ICON_SIZE_SMALL,
  785. false
  786. );
  787. $link['cmd'] = 'hide=yes';
  788. $lnk[] = $link;
  789. }
  790. }
  791. if (!empty($tool['adminlink'])) {
  792. $item['extra'] = '<a href="'.$tool['adminlink'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
  793. }
  794. }
  795. // Both checks are necessary as is_platform_admin doesn't take student view into account
  796. if ($is_platform_admin && $is_allowed_to_edit) {
  797. if ($toolAdmin != '1') {
  798. $link['cmd'] = 'hide=yes';
  799. }
  800. }
  801. $item['visibility'] = null;
  802. if (isset($lnk) && is_array($lnk)) {
  803. foreach ($lnk as $this_link) {
  804. if (empty($tool['adminlink'])) {
  805. $item['visibility'] .= '<a class="make_visible_and_invisible" href="'.api_get_self().'?'.api_get_cidreq().'&id='.$tool['iid'].'&'.$this_link['cmd'].'">'.
  806. $this_link['name'].'</a>';
  807. }
  808. }
  809. } else {
  810. $item['visibility'] .= '';
  811. }
  812. // NOTE : Table contains only the image file name, not full path
  813. if (stripos($tool['link'], 'http://') === false &&
  814. stripos($tool['link'], 'https://') === false &&
  815. stripos($tool['link'], 'ftp://') === false
  816. ) {
  817. $tool['link'] = $web_code_path.$tool['link'];
  818. }
  819. if ($tool['visibility'] == '0' && $toolAdmin != '1') {
  820. $class = 'text-muted';
  821. $info = pathinfo($tool['image']);
  822. $basename = basename($tool['image'], '.'.$info['extension']); // $file is set to "index"
  823. $tool['image'] = $basename.'_na.'.$info['extension'];
  824. } else {
  825. $class = '';
  826. }
  827. $qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&';
  828. // If it's a link, we don't add the cidReq
  829. if ($tool['image'] == 'file_html.png' || $tool['image'] == 'file_html_na.png') {
  830. $tool['link'] = $tool['link'].$qm_or_amp;
  831. } else {
  832. $tool['link'] = $tool['link'].$qm_or_amp.api_get_cidreq();
  833. }
  834. $tool_link_params = array();
  835. $toolIid = isset($tool["iid"]) ? $tool["iid"] : null;
  836. //@todo this visio stuff should be removed
  837. if (strpos($tool['name'], 'visio_') !== false) {
  838. $tool_link_params = array(
  839. 'id' => 'tooldesc_'.$toolIid,
  840. 'href' => '"javascript: void(0);"',
  841. 'class' => $class,
  842. '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\')',
  843. 'target' => $tool['target']
  844. );
  845. } elseif (strpos($tool['name'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) {
  846. $tool_link_params = array(
  847. 'id' => 'tooldesc_'.$toolIid,
  848. 'class' => $class,
  849. 'href' => 'javascript: void(0);',
  850. '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
  851. 'target' => $tool['target']
  852. );
  853. } else {
  854. $tool_link_params = array(
  855. 'id' => 'tooldesc_'.$toolIid,
  856. 'href' => $tool['link'],
  857. 'class' => $class,
  858. 'target' => $tool['target']
  859. );
  860. }
  861. $tool_name = self::translate_tool_name($tool);
  862. // Including Courses Plugins
  863. // Creating title and the link
  864. if (isset($tool['category']) && $tool['category'] == 'plugin') {
  865. $plugin_info = $app_plugin->getPluginInfo($tool['name']);
  866. if (isset($plugin_info) && isset($plugin_info['title'])) {
  867. $tool_name = $plugin_info['title'];
  868. }
  869. if (!file_exists(api_get_path(SYS_CODE_PATH).'img/'.$tool['image']) &&
  870. !file_exists(api_get_path(SYS_CODE_PATH).'img/icons/64/'.$tool['image'])) {
  871. $tool['image'] = 'plugins.png';
  872. }
  873. $tool_link_params['href'] = api_get_path(WEB_PLUGIN_PATH).$tool['original_link'].'?'.api_get_cidreq();
  874. }
  875. $icon = Display::return_icon(
  876. $tool['image'],
  877. $tool_name,
  878. array('class' => 'tool-icon', 'id' => 'toolimage_'.$toolIid),
  879. ICON_SIZE_BIG,
  880. false
  881. );
  882. /*if (!empty($tool['custom_icon'])) {
  883. $image = self::getCustomWebIconPath().$tool['custom_icon'];
  884. $icon = Display::img(
  885. $image,
  886. $tool['description'],
  887. array(
  888. 'class' => 'tool-icon',
  889. 'id' => 'toolimage_'.$tool['id']
  890. )
  891. );
  892. }*/
  893. // Validation when belongs to a session
  894. $session_img = api_get_session_image($tool['session_id'], (!empty($_user['status']) ? $_user['status'] : ''));
  895. if ($studentview) {
  896. $tool_link_params['href'] .= '&isStudentView=true';
  897. }
  898. $item['url_params'] = $tool_link_params;
  899. $item['icon'] = Display::url($icon, $tool_link_params['href'], $tool_link_params);
  900. $item['tool'] = $tool;
  901. $item['name'] = $tool_name;
  902. $tool_link_params['id'] = 'is'.$tool_link_params['id'];
  903. $item['link'] = Display::url(
  904. $tool_name.$session_img,
  905. $tool_link_params['href'],
  906. $tool_link_params
  907. );
  908. $items[] = $item;
  909. $i++;
  910. } // end of foreach
  911. }
  912. $i = 0;
  913. $html = '';
  914. if (!empty($items)) {
  915. foreach ($items as $item) {
  916. switch ($theme) {
  917. case 'activity_big':
  918. $data = '';
  919. $html .= '<div class="col-xs-6 col-md-3 course-tool">';
  920. $image = (substr($item['tool']['image'], 0, strpos($item['tool']['image'], '.'))).'.png';
  921. $toolIid = isset($item['tool']['iid']) ? $item['tool']['iid'] : null;
  922. if (isset($item['tool']['custom_image'])) {
  923. $original_image = Display::img(
  924. $item['tool']['custom_image'],
  925. $item['name'],
  926. array('id' => 'toolimage_'.$toolIid)
  927. );
  928. } elseif (isset($item['tool']['custom_icon']) &&
  929. !empty($item['tool']['custom_icon'])
  930. ) {
  931. $customIcon = $item['tool']['custom_icon'];
  932. if ($item['tool']['visibility'] == '0') {
  933. $fileInfo = pathinfo($item['tool']['custom_icon']);
  934. $customIcon = self::getDisableIcon($item['tool']['custom_icon']);
  935. }
  936. $original_image = Display::img(
  937. self::getCustomWebIconPath().$customIcon,
  938. $item['name'],
  939. array('id' => 'toolimage_'.$toolIid)
  940. );
  941. } else {
  942. $original_image = Display::return_icon(
  943. $image,
  944. $item['name'],
  945. array('id' => 'toolimage_'.$toolIid),
  946. ICON_SIZE_BIG,
  947. false
  948. );
  949. }
  950. $data .= Display::url($original_image, $item['url_params']['href'], $item['url_params']);
  951. $html .= Display::div($data, array('class' => 'big_icon')); //box-image reflection
  952. $html .= Display::div('<h4>'.$item['visibility'].$item['extra'].$item['link'].'</h4>', array('class' => 'content'));
  953. $html .= '</div>';
  954. break;
  955. case 'activity':
  956. $html .= '<div class="offset2 col-md-4 course-tool">';
  957. $html .= $item['extra'];
  958. $html .= $item['visibility'];
  959. $html .= $item['icon'];
  960. $html .= $item['link'];
  961. $html .= '</div>';
  962. break;
  963. case 'vertical_activity':
  964. if ($i == 0) {
  965. $html .= '<ul>';
  966. }
  967. $image = (substr($item['tool']['image'], 0, strpos($item['tool']['image'], '.'))).'.png';
  968. $original_image = Display::return_icon(
  969. $image,
  970. $item['name'],
  971. array('id' => 'toolimage_'.$item['tool']['iid']),
  972. ICON_SIZE_SMALL,
  973. false
  974. );
  975. $html .= '<li class="course-tool">';
  976. $html .= $item['extra'];
  977. $html .= $item['visibility'];
  978. $url = Display::url($original_image, $item['url_params']['href'], $item['url_params']);
  979. $html .= $url;
  980. $html .= $item['link'];
  981. $html .= '</li>';
  982. if ($i == count($items) - 1) {
  983. $html .= '</ul>';
  984. }
  985. break;
  986. }
  987. $i++;
  988. }
  989. }
  990. return $html;
  991. }
  992. /**
  993. * Shows the general data for a particular meeting
  994. *
  995. * @param id session id
  996. * @return string session data
  997. */
  998. public static function show_session_data($id_session)
  999. {
  1000. $session_category_table = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
  1001. $sessionInfo = api_get_session_info($id_session);
  1002. if (empty($sessionInfo)) {
  1003. return '';
  1004. }
  1005. $sql = 'SELECT name FROM '.$session_category_table.'
  1006. WHERE id = "'.intval($sessionInfo['session_category_id']).'"';
  1007. $rs_category = Database::query($sql);
  1008. $session_category = '';
  1009. if (Database::num_rows($rs_category) > 0) {
  1010. $rows_session_category = Database::store_result($rs_category);
  1011. $rows_session_category = $rows_session_category[0];
  1012. $session_category = $rows_session_category['name'];
  1013. }
  1014. $coachInfo = api_get_user_info($sessionInfo['id_coach']);
  1015. $output = '';
  1016. if (!empty($session_category)) {
  1017. $output .= '<tr><td>'.get_lang('SessionCategory').': '.'<b>'.$session_category.'</b></td></tr>';
  1018. }
  1019. $dateInfo = SessionManager::parseSessionDates($sessionInfo);
  1020. $msgDate = $dateInfo['access'];
  1021. $output .= '<tr>
  1022. <td style="width:50%">'.get_lang('SessionName').': '.'<b>'.$sessionInfo['name'].'</b></td>
  1023. <td>'.get_lang('GeneralCoach').': '.'<b>'.$coachInfo['complete_name'].'</b></td></tr>';
  1024. $output .= '<tr>
  1025. <td>'.get_lang('SessionIdentifier').': '.
  1026. Display::return_icon('star.png', ' ', array('align' => 'absmiddle')).'
  1027. </td>
  1028. <td>'.get_lang('Date').': '.'<b>'.$msgDate.'</b>
  1029. </td>
  1030. </tr>';
  1031. return $output;
  1032. }
  1033. /**
  1034. * Retrieves the name-field within a tool-record and translates it on necessity.
  1035. * @param array $tool The input record.
  1036. * @return string Returns the name of the corresponding tool.
  1037. */
  1038. public static function translate_tool_name(& $tool)
  1039. {
  1040. static $already_translated_icons = array(
  1041. 'file_html.gif',
  1042. 'file_html_na.gif',
  1043. 'file_html.png',
  1044. 'file_html_na.png',
  1045. 'scormbuilder.gif',
  1046. 'scormbuilder_na.gif',
  1047. 'blog.gif',
  1048. 'blog_na.gif',
  1049. 'external.gif',
  1050. 'external_na.gif'
  1051. );
  1052. $toolName = Security::remove_XSS(stripslashes($tool['name']));
  1053. if (in_array($tool['image'], $already_translated_icons)) {
  1054. return $toolName;
  1055. }
  1056. $toolName = api_underscore_to_camel_case($toolName);
  1057. if (isset($GLOBALS['Tool'.$toolName])) {
  1058. return get_lang('Tool'.$toolName);
  1059. }
  1060. return $toolName;
  1061. }
  1062. /**
  1063. * Get published learning path id from link inside course home
  1064. * @param string Link to published lp
  1065. * @return int Learning path id
  1066. */
  1067. public static function get_published_lp_id_from_link($published_lp_link)
  1068. {
  1069. $lp_id = 0;
  1070. $param_lp_id = strstr($published_lp_link, 'lp_id=');
  1071. if (!empty($param_lp_id)) {
  1072. $a_param_lp_id = explode('=', $param_lp_id);
  1073. if (isset($a_param_lp_id[1])) {
  1074. $lp_id = intval($a_param_lp_id[1]);
  1075. }
  1076. }
  1077. return $lp_id;
  1078. }
  1079. /**
  1080. * Get published learning path category from link inside course home
  1081. * @param string $link
  1082. * @return CLpCategory
  1083. */
  1084. public static function getPublishedLpCategoryFromLink($link)
  1085. {
  1086. $query = parse_url($link, PHP_URL_QUERY);
  1087. parse_str($query, $params);
  1088. $id = isset($params['id']) ? (int) $params['id'] : 0;
  1089. $em = Database::getManager();
  1090. /** @var CLpCategory $category */
  1091. $category = $em->find('ChamiloCourseBundle:CLpCategory', $id);
  1092. return $category;
  1093. }
  1094. /**
  1095. * @param bool $include_admin_tools
  1096. * @return array
  1097. */
  1098. public static function get_navigation_items($include_admin_tools = false)
  1099. {
  1100. $navigation_items = array();
  1101. $course_id = api_get_course_int_id();
  1102. $courseInfo = api_get_course_info();
  1103. $sessionId = api_get_session_id();
  1104. if (!empty($course_id)) {
  1105. $course_tools_table = Database::get_course_table(TABLE_TOOL_LIST);
  1106. /* Link to the Course homepage */
  1107. $navigation_items['home']['image'] = 'home.gif';
  1108. $navigation_items['home']['link'] = $courseInfo['course_public_url'];
  1109. $navigation_items['home']['name'] = get_lang('CourseHomepageLink');
  1110. $sql = "SELECT * FROM $course_tools_table
  1111. WHERE c_id = $course_id AND visibility='1' and admin='0'
  1112. ORDER BY id ASC";
  1113. $sql_result = Database::query($sql);
  1114. while ($row = Database::fetch_array($sql_result)) {
  1115. $navigation_items[$row['id']] = $row;
  1116. if (stripos($row['link'], 'http://') === false && stripos($row['link'], 'https://') === false) {
  1117. $navigation_items[$row['id']]['link'] = api_get_path(WEB_CODE_PATH);
  1118. if ($row['category'] == 'plugin') {
  1119. $plugin = new AppPlugin();
  1120. $pluginInfo = $plugin->getPluginInfo($row['name']);
  1121. $navigation_items[$row['id']]['link'] = api_get_path(WEB_PLUGIN_PATH);
  1122. $navigation_items[$row['id']]['name'] = $pluginInfo['title'];
  1123. } else {
  1124. $navigation_items[$row['id']]['name'] = self::translate_tool_name($row);
  1125. }
  1126. $navigation_items[$row['id']]['link'] .= $row['link'];
  1127. }
  1128. }
  1129. /* Admin (edit rights) only links
  1130. - Course settings (course admin only)
  1131. - Course rights (roles & rights overview) */
  1132. if ($include_admin_tools) {
  1133. $sql = "SELECT name, image FROM $course_tools_table
  1134. WHERE c_id = $course_id AND link='course_info/infocours.php'";
  1135. $sql_result = Database::query($sql);
  1136. $course_setting_info = Database::fetch_array($sql_result);
  1137. $course_setting_visual_name = self::translate_tool_name($course_setting_info);
  1138. if ($sessionId == 0) {
  1139. // course settings item
  1140. $navigation_items['course_settings']['image'] = $course_setting_info['image'];
  1141. $navigation_items['course_settings']['link'] = api_get_path(WEB_CODE_PATH).'course_info/infocours.php';
  1142. $navigation_items['course_settings']['name'] = $course_setting_visual_name;
  1143. }
  1144. }
  1145. }
  1146. foreach ($navigation_items as $key => $navigation_item) {
  1147. if (strstr($navigation_item['link'], '?')) {
  1148. //link already contains a parameter, add course id parameter with &
  1149. $parameter_separator = '&amp;';
  1150. } else {
  1151. //link doesn't contain a parameter yet, add course id parameter with ?
  1152. $parameter_separator = '?';
  1153. }
  1154. //$navigation_items[$key]['link'] .= $parameter_separator.api_get_cidreq();
  1155. $navigation_items[$key]['link'] .= $parameter_separator.'cidReq='.api_get_course_id().'&gidReq=0&id_session='.$sessionId;
  1156. }
  1157. return $navigation_items;
  1158. }
  1159. /**
  1160. * Show a navigation menu
  1161. */
  1162. public static function show_navigation_menu()
  1163. {
  1164. $navigation_items = self::get_navigation_items(true);
  1165. $course_id = api_get_course_id();
  1166. $class = null;
  1167. $idLearn = null;
  1168. $item = null;
  1169. $marginLeft = 160;
  1170. $html = '<div id="toolnav">';
  1171. $html .= '<ul id="toolnavbox">';
  1172. $count = 0;
  1173. foreach ($navigation_items as $key => $navigation_item) {
  1174. //students can't see the course settings option
  1175. $count++;
  1176. if (!api_is_allowed_to_edit() && $key == 'course_settings') {
  1177. continue;
  1178. }
  1179. $html .= '<li>';
  1180. $url_item = parse_url($navigation_item['link']);
  1181. $url_current = parse_url($_SERVER['REQUEST_URI']);
  1182. if (api_get_setting('show_navigation_menu') == 'text') {
  1183. $class = 'text';
  1184. $marginLeft = 170;
  1185. $item = $navigation_item['name'];
  1186. } else if (api_get_setting('show_navigation_menu') == 'icons') {
  1187. $class = 'icons';
  1188. $marginLeft = 25;
  1189. $item = Display::return_icon(substr($navigation_item['image'], 0, -3)."png", $navigation_item['name'], array('class'=>'tool-img'), ICON_SIZE_SMALL);
  1190. } else {
  1191. $class = 'icons-text';
  1192. $item = $navigation_item['name'].Display::return_icon(substr($navigation_item['image'], 0, -3)."png", $navigation_item['name'], array('class'=>'tool-img'), ICON_SIZE_SMALL);
  1193. }
  1194. if (stristr($url_item['path'], $url_current['path'])) {
  1195. if (!isset($_GET['learnpath_id']) || strpos($url_item['query'], 'learnpath_id='.intval($_GET['learnpath_id'])) === 0) {
  1196. $idLearn = ' id="here"';
  1197. }
  1198. }
  1199. if (strpos($navigation_item['link'], 'chat') !== false &&
  1200. api_get_course_setting('allow_open_chat_window', $course_id)
  1201. ) {
  1202. $html .= '<a '.$idLearn.' class="btn btn-default text-left '.$class.' " href="javascript: void(0);" onclick="javascript: window.open(\''.$navigation_item['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\')" target="'.$navigation_item['target'].'"';
  1203. $html .= ' title="'.$navigation_item['name'].'">';
  1204. $html .= $item;
  1205. $html .= '</a>';
  1206. } else {
  1207. $html .= '<a '.$idLearn.' class="btn btn-default text-left '.$class.'" href="'.$navigation_item['link'].'" target="_top" title="'.$navigation_item['name'].'">';
  1208. $html .= $item;
  1209. $html .= '</a>';
  1210. }
  1211. $html .= '</li>';
  1212. }
  1213. $html .= '</ul>';
  1214. $html .= '<script>$(function() {
  1215. $("#toolnavbox a").stop().animate({"margin-left":"-' . $marginLeft.'px"},1000);
  1216. $("#toolnavbox > li").hover(
  1217. function () {
  1218. $("a",$(this)).stop().animate({"margin-left":"-2px"},200);
  1219. $("span",$(this)).css("display","block");
  1220. },
  1221. function () {
  1222. $("a",$(this)).stop().animate({"margin-left":"-' . $marginLeft.'px"},200);
  1223. $("span",$(this)).css("display","initial");
  1224. }
  1225. );
  1226. });</script>';
  1227. $html .= '</div>';
  1228. return $html;
  1229. }
  1230. /**
  1231. * Show a toolbar with shortcuts to the course tool
  1232. * @param int $orientation
  1233. *
  1234. * @return string
  1235. */
  1236. public static function show_navigation_tool_shortcuts($orientation = SHORTCUTS_HORIZONTAL)
  1237. {
  1238. $origin = api_get_origin();
  1239. if ($origin === 'learnpath') {
  1240. return '';
  1241. }
  1242. $navigation_items = self::get_navigation_items(false);
  1243. $html = '';
  1244. if (!empty($navigation_items)) {
  1245. if ($orientation == SHORTCUTS_HORIZONTAL) {
  1246. $style_id = "toolshortcuts_horizontal";
  1247. } else {
  1248. $style_id = "toolshortcuts_vertical";
  1249. }
  1250. $html .= '<div id="'.$style_id.'">';
  1251. foreach ($navigation_items as $key => $navigation_item) {
  1252. if (strpos($navigation_item['link'], 'chat') !== false &&
  1253. api_get_course_setting('allow_open_chat_window')
  1254. ) {
  1255. $html .= '<a class="items-icon" href="javascript: void(0);" onclick="javascript: window.open(\''.$navigation_item['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\')" target="'.$navigation_item['target'].'"';
  1256. } else {
  1257. $html .= '<a class="items-icon" href="'.$navigation_item['link'].'"';
  1258. }
  1259. if (strpos(api_get_self(), $navigation_item['link']) !== false) {
  1260. $html .= ' id="here"';
  1261. }
  1262. $html .= ' target="_top" title="'.$navigation_item['name'].'">';
  1263. if (isset($navigation_item['category']) && $navigation_item['category'] == 'plugin') {
  1264. /*$plugin_info = $app_plugin->getPluginInfo($navigation_item['name']);
  1265. if (isset($plugin_info) && isset($plugin_info['title'])) {
  1266. $tool_name = $plugin_info['title'];
  1267. }*/
  1268. if (!file_exists(api_get_path(SYS_CODE_PATH).'img/'.$navigation_item['image']) &&
  1269. !file_exists(api_get_path(SYS_CODE_PATH).'img/icons/'.ICON_SIZE_MEDIUM.'/'.$navigation_item['image'])
  1270. ) {
  1271. $navigation_item['image'] = 'plugins.png';
  1272. }
  1273. //$tool_link_params['href'] = api_get_path(WEB_PLUGIN_PATH).$navigation_item['link'].'?'.api_get_cidreq();
  1274. }
  1275. $html .= Display::return_icon(
  1276. substr($navigation_item['image'], 0, -3).'png',
  1277. $navigation_item['name'],
  1278. [],
  1279. ICON_SIZE_MEDIUM
  1280. );
  1281. $html .= '</a> ';
  1282. if ($orientation == SHORTCUTS_VERTICAL) {
  1283. $html .= '<br />';
  1284. }
  1285. }
  1286. $html .= '</div>';
  1287. }
  1288. return $html;
  1289. }
  1290. /**
  1291. * List course homepage tools from authoring and interaction sections
  1292. * @param int $courseId The course ID (guessed from context if not provided)
  1293. * @param int $sessionId The session ID (guessed from context if not provided)
  1294. * @return array List of all tools data from the c_tools table
  1295. */
  1296. public static function toolsIconsAction($courseId = null, $sessionId = null)
  1297. {
  1298. if (empty($courseId)) {
  1299. $courseId = api_get_course_int_id();
  1300. } else {
  1301. $courseId = intval($courseId);
  1302. }
  1303. if (empty($sessionId)) {
  1304. $sessionId = api_get_session_id();
  1305. } else {
  1306. $sessionId = intval($sessionId);
  1307. }
  1308. if (empty($courseId)) {
  1309. // We shouldn't get here, but for some reason api_get_course_int_id()
  1310. // doesn't seem to get the course from the context, sometimes
  1311. return array();
  1312. }
  1313. $table = Database::get_course_table(TABLE_TOOL_LIST);
  1314. $sql = "SELECT * FROM $table
  1315. WHERE category in ('authoring','interaction')
  1316. AND c_id = $courseId
  1317. AND session_id = $sessionId
  1318. ORDER BY id";
  1319. $result = Database::query($sql);
  1320. $data = Database::store_result($result, 'ASSOC');
  1321. return $data;
  1322. }
  1323. /**
  1324. * @param int $editIcon
  1325. * @return array
  1326. */
  1327. public static function getTool($editIcon)
  1328. {
  1329. $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
  1330. $editIcon = intval($editIcon);
  1331. $sql = "SELECT * FROM $course_tool_table
  1332. WHERE iid = $editIcon";
  1333. $result = Database::query($sql);
  1334. $tool = Database::fetch_assoc($result, 'ASSOC');
  1335. return $tool;
  1336. }
  1337. /**
  1338. * @return string
  1339. */
  1340. public static function getCustomSysIconPath()
  1341. {
  1342. // Check if directory exists or create it if it doesn't
  1343. $dir = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/upload/course_home_icons/';
  1344. if (!is_dir($dir)) {
  1345. mkdir($dir, api_get_permissions_for_new_directories(), true);
  1346. }
  1347. return $dir;
  1348. }
  1349. /**
  1350. * @return string
  1351. */
  1352. public static function getCustomWebIconPath()
  1353. {
  1354. // Check if directory exists or create it if it doesn't
  1355. $dir = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/upload/course_home_icons/';
  1356. return $dir;
  1357. }
  1358. /**
  1359. * @param string $icon
  1360. * @return string
  1361. */
  1362. public static function getDisableIcon($icon)
  1363. {
  1364. $fileInfo = pathinfo($icon);
  1365. return $fileInfo['filename'].'_na.'.$fileInfo['extension'];
  1366. }
  1367. /**
  1368. * @param int $id
  1369. * @param array $values
  1370. */
  1371. public static function updateTool($id, $values)
  1372. {
  1373. $table = Database::get_course_table(TABLE_TOOL_LIST);
  1374. $params = [
  1375. 'name' => $values['name'],
  1376. 'link' => $values['link'],
  1377. 'target' => $values['target'],
  1378. 'visibility' => $values['visibility'],
  1379. 'description' => $values['description'],
  1380. ];
  1381. if (isset($_FILES['icon']['size']) && $_FILES['icon']['size'] !== 0) {
  1382. $dir = self::getCustomSysIconPath();
  1383. // Resize image if it is larger than 64px
  1384. $temp = new Image($_FILES['icon']['tmp_name']);
  1385. $picture_infos = $temp->get_image_info();
  1386. if ($picture_infos['width'] > 64) {
  1387. $thumbwidth = 64;
  1388. } else {
  1389. $thumbwidth = $picture_infos['width'];
  1390. }
  1391. if ($picture_infos['height'] > 64) {
  1392. $new_height = 64;
  1393. } else {
  1394. $new_height = $picture_infos['height'];
  1395. }
  1396. $temp->resize($thumbwidth, $new_height, 0);
  1397. //copy the image to the course upload folder
  1398. $path = $dir.$_FILES['icon']['name'];
  1399. $result = $temp->send_image($path);
  1400. $temp = new Image($path);
  1401. $r = $temp->convert2bw();
  1402. $ext = pathinfo($path, PATHINFO_EXTENSION);
  1403. $bwPath = substr($path, 0, -(strlen($ext) + 1)).'_na.'.$ext;
  1404. if ($r === false) {
  1405. error_log('Conversion to B&W of '.$path.' failed in '.__FILE__.' at line '.__LINE__);
  1406. } else {
  1407. $temp->send_image($bwPath);
  1408. $iconName = $_FILES['icon']['name'];
  1409. $params['custom_icon'] = $iconName;
  1410. }
  1411. }
  1412. Database::update(
  1413. $table,
  1414. $params,
  1415. [' iid = ?' => [$id]]
  1416. );
  1417. }
  1418. /**
  1419. * @param int $id
  1420. */
  1421. public static function deleteIcon($id)
  1422. {
  1423. $table = Database::get_course_table(TABLE_TOOL_LIST);
  1424. $tool = self::getTool($id);
  1425. if ($tool && !empty($tool['custom_icon'])) {
  1426. $file = self::getCustomSysIconPath().$tool['custom_icon'];
  1427. $fileInfo = pathinfo($file);
  1428. $fileGray = $fileInfo['filename'].'_na.'.$fileInfo['extension'];
  1429. $fileGray = self::getCustomSysIconPath().$fileGray;
  1430. if (file_exists($file) && is_file($file)) {
  1431. if (Security::check_abs_path($file, self::getCustomSysIconPath())) {
  1432. unlink($file);
  1433. }
  1434. }
  1435. if (file_exists($fileGray) && is_file($fileGray)) {
  1436. if (Security::check_abs_path($fileGray, self::getCustomSysIconPath())) {
  1437. unlink($fileGray);
  1438. }
  1439. }
  1440. $params = [
  1441. 'custom_icon' => ''
  1442. ];
  1443. Database::update(
  1444. $table,
  1445. $params,
  1446. [' iid = ?' => [$id]]
  1447. );
  1448. }
  1449. }
  1450. }