course_home.lib.php 39 KB

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