course_home.lib.php 38 KB

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