resourcelinker.php 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2005 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Patrick Cool (patrick.cool@ugent.be)
  9. Copyright (c) Denes Nagy
  10. For a full list of contributors, see "credits.txt".
  11. The full license can be read in "license.txt".
  12. This program is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU General Public License
  14. as published by the Free Software Foundation; either version 2
  15. of the License, or (at your option) any later version.
  16. See the GNU General Public License for more details.
  17. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  18. ==============================================================================
  19. */
  20. /**
  21. ==============================================================================
  22. * @author Patrick Cool, original code
  23. * @author Denes Nagy - many bugfixes and improvements, adjusted for learning path
  24. * @author Roan Embrechts - refactoring, code cleaning
  25. * @package dokeos.resourcelinker
  26. * @todo reorganise code,
  27. * use Database API instead of creating table names locally.
  28. ==============================================================================
  29. */
  30. /*
  31. ==============================================================================
  32. INIT SECTION
  33. ==============================================================================
  34. */
  35. // name of the language file that needs to be included
  36. $language_file = 'resourcelinker';
  37. require_once('back_compat.inc.php');
  38. $this_section=SECTION_COURSES;
  39. api_protect_course_script();
  40. /*
  41. -----------------------------------------------------------
  42. Libraries
  43. -----------------------------------------------------------
  44. */
  45. include ('resourcelinker.inc.php');
  46. /*
  47. -----------------------------------------------------------
  48. Constants and variables
  49. -----------------------------------------------------------
  50. */
  51. $link_table = Database :: get_course_table(TABLE_LINK);
  52. $item_property_table = Database :: get_course_table(TABLE_ITEM_PROPERTY);
  53. //$tbl_learnpath_main = Database :: get_course_table(TABLE_LEARNPATH_MAIN);
  54. //$tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER);
  55. //$tbl_learnpath_item = Database :: get_course_table(TABLE_LEARNPATH_ITEM);
  56. $tbl_lp = Database::get_course_table('lp');
  57. $tbl_lp_item = Database::get_course_table('lp_item');
  58. $action = $_REQUEST['action'];
  59. $add = $_REQUEST['add'];
  60. $chapter_id = $_REQUEST['parent_item_id'];
  61. $content = $_REQUEST['content'];
  62. // Note by Patrick Cool: this has been solved belowd. This piece of code hacking produced too much errors.
  63. /*
  64. if(empty($content)){
  65. //adds a default to the item-type selection
  66. $content = 'Document';
  67. }
  68. */
  69. $folder = $_REQUEST['folder'];
  70. $id = $_REQUEST['id'];
  71. $learnpath_id = $_REQUEST['lp_id'];
  72. $originalresource = $_REQUEST['originalresource'];
  73. $show_resources = $_REQUEST['show_resources'];
  74. $source_forum = $_REQUEST['source_forum'];
  75. $source_id = $_REQUEST['source_id'];
  76. $target = $_REQUEST['target'];
  77. $external_link = $_REQUEST['external_link'];
  78. $from_learnpath = $_SESSION['from_learnpath'];
  79. // this variable controls wether the link to add a chapter in a module or
  80. // another chapter is shown. This allows to create multi-level learnpaths,
  81. // but export features are not ready for this, yet, so use at your own risks
  82. // default : false -> do not display link
  83. // This setting should be moved to the platform configuration page in time...
  84. $multi_level_learnpath = true;
  85. /*
  86. ==============================================================================
  87. MAIN CODE
  88. ==============================================================================
  89. */
  90. if ($from_learnpath == 'yes')
  91. {
  92. //start from clear every time in LearnPath Builder
  93. $_SESSION['addedresource'] = null;
  94. $_SESSION['addedresourceid'] = null;
  95. $_SESSION['addedresourceassigned'] = null;
  96. unset ($_SESSION['addedresource']);
  97. unset ($_SESSION['addedresourceid']);
  98. unset ($_SESSION['addedresourceassigned']);
  99. }
  100. // Process a new chapter?
  101. if (!empty ($_POST['add_chapter']) && !empty ($_POST['title']))
  102. {
  103. $title = $_POST['title'];
  104. $description = '';
  105. /*if (!empty ($_POST['description']))
  106. {
  107. $description = $_POST['description'];
  108. }*/
  109. // get max display_order so far in this parent chapter
  110. $sql = "SELECT MAX(display_order) as maxi FROM $tbl_lp_item " .
  111. "WHERE lp_id = $learnpath_id ".
  112. " AND parent_item_id = $chapter_id";
  113. $res = api_sql_query($sql, __FILE__, __LINE__);
  114. $row = mysql_fetch_array($res);
  115. $lastorder_item = $row['maxi'];
  116. if(empty($lastorder_item)){
  117. $lastorder_item = 0;
  118. $previous = 0;
  119. }else{
  120. $sql = "SELECT id FROM $tbl_lp_item " .
  121. "WHERE lp_id = $learnpath_id AND parent_item_id=$chapter_id AND display_order = $lastorder_item";
  122. $result = api_sql_query($sql, __FILE__, __LINE__);
  123. $row = Database::fetch_array($result);
  124. $previous = $row['id'];
  125. }
  126. $order = $lastorder_item+1;
  127. $sql = "INSERT INTO $tbl_lp_item "."(lp_id,item_type,title,parent_item_id,previous_item_id, next_item_id, display_order) " .
  128. "VALUES "."($learnpath_id,'dokeos_chapter','$title', $chapter_id, $previous, 0, $order )";
  129. //error_log('New LP - Inserting new resource: '.$sql,0);
  130. $res = api_sql_query($sql, __FILE__, __LINE__);
  131. $my_id = Database::get_last_insert_id($res);
  132. if($previous>0){
  133. $sql = "UPDATE $tbl_lp_item SET next_item_id = $my_id WHERE id=$previous";
  134. $res = api_sql_query($sql,__FILE__,__LINE__);
  135. }
  136. if ($res !== false)
  137. {
  138. $title = '';
  139. $description = '';
  140. }
  141. $resource_added = true;
  142. }
  143. // This if when a external link is submitted
  144. if (!empty ($_POST['external_link_submit']))
  145. {
  146. if ($external_link == "" || $external_link == "http://")
  147. $InvalidURL = 1;
  148. else
  149. {
  150. $add = true;
  151. if ($add_2_links != "niet toevoegen")
  152. {
  153. // add external link to the links table.
  154. $pos = strpos($external_link, 'ttp:');
  155. if ($pos == '')
  156. {
  157. $external_link = 'http://'.$external_link;
  158. }
  159. $sql = "INSERT INTO $link_table (url, title, category_id) VALUES ('$external_link','$external_link','$add_2_links')";
  160. $result = api_sql_query($sql, __FILE__, __LINE__);
  161. $addedresource[] = "Link";
  162. $addedresourceid[] = mysql_insert_id();
  163. $_SESSION['addedresource'] = $addedresource;
  164. $_SESSION['addedresourceid'] = $addedresourceid;
  165. }
  166. else
  167. {
  168. // do not add external link to the links table
  169. $addedresource[] = "Externallink";
  170. $addedresourceid[] = $external_link;
  171. $_SESSION['addedresource'] = $addedresource;
  172. $_SESSION['addedresourceid'] = $addedresourceid;
  173. }
  174. }
  175. }
  176. // loading the session variables into local array
  177. $addedresource = $_SESSION['addedresource'];
  178. $addedresourceid = $_SESSION['addedresourceid'];
  179. // This is when a resource was added to the session
  180. if ($add)
  181. {
  182. // adding the new variable to the local array
  183. if (empty ($_POST['external_link_submit']))
  184. {
  185. //that case is already arranged, see upwards
  186. $addedresource[] = $content;
  187. $addedresourceid[] = $add;
  188. }
  189. $addedresourceassigned[] = 0;
  190. // loading the local array into the session variable
  191. $_SESSION['addedresource'] = $addedresource;
  192. $_SESSION['addedresourceid'] = $addedresourceid;
  193. //---------------------------------------
  194. //we assign to chapters immediately !
  195. //---------------------------------------
  196. $resource_added = false;
  197. if ($from_learnpath == 'yes')
  198. {
  199. $i = 0;
  200. //calculating the last order of the items of this chapter
  201. $sql = "SELECT MAX(display_order) as maxi FROM $tbl_lp_item " .
  202. "WHERE lp_id = $learnpath_id AND parent_item_id=$chapter_id";
  203. $result = api_sql_query($sql, __FILE__, __LINE__);
  204. $row = Database::fetch_array($result);
  205. $lastorder_item = $row['maxi'];
  206. if(empty($lastorder_item)){
  207. $lastorder_item = 0;
  208. $previous = 0;
  209. }else{
  210. $sql = "SELECT id FROM $tbl_lp_item " .
  211. "WHERE lp_id = $learnpath_id AND parent_item_id=$chapter_id AND display_order = $lastorder_item";
  212. //error_log('New LP - resourcelinker.php - '.$sql,0);
  213. $result = api_sql_query($sql, __FILE__, __LINE__);
  214. $row = Database::fetch_array($result);
  215. $previous = $row['id'];
  216. }
  217. $lastorder = $lastorder_item+1;
  218. foreach ($addedresource as $addedresource_item)
  219. {
  220. // in the case we added a chapter, add this into the chapters list with the correct parent_id
  221. if ($addedresource_item == "Chap")
  222. {
  223. $sql = "INSERT INTO $tbl_lp_item " .
  224. "(lp_id,item_type,title,parent_item_id,previous_item_id,next_item_id,display_order) " .
  225. "VALUES (".$learnpath_id.",'dokeos_chapter','".$learnpath_chapter_name."',".$chapter_id.",$previous,0,".$lastorder.")";
  226. //error_log('New LP - Inserting new resource: '.$sql,0);
  227. $res = api_sql_query($sql, __FILE__, __LINE__);
  228. $my_id = Database::get_last_insert_id($res);
  229. if($previous>0){
  230. $sql = "UPDATE $tbl_lp_item SET next_item_id = $my_id WHERE id=$previous";
  231. $res = api_sql_query($sql,__FILE__,__LINE__);
  232. }
  233. }
  234. if (!$addedresourceassigned[$i])
  235. {
  236. //not to assign it twice
  237. switch($addedresource_item){
  238. case 'Assignment':
  239. case 'Ass':
  240. //set tool type
  241. $addedresource_item = "Assignments";
  242. $title = get_lang('Assignments');
  243. break;
  244. case 'Drop':
  245. //$addedresource_item = "Dropbox";
  246. $addedresource_item = TOOL_DROPBOX;
  247. $title = get_lang('dropbox');
  248. break;
  249. case 'Intro':
  250. $addedresource_item = "Introduction_text";
  251. //$addedresource_item = TOOL_INTRO;
  252. $title = get_lang('IntroductionText');
  253. break;
  254. case 'Course_desc':
  255. //$addedresource_item = "Course_description";
  256. $addedresource_item = TOOL_COURSE_DESCRIPTION;
  257. $title = get_lang('CourseDescription');
  258. break;
  259. case 'Group':
  260. //$addedresource_item = "Groups";
  261. $addedresource_item = TOOL_GROUP;
  262. $title = get_lang('Groups');
  263. break;
  264. case 'User':
  265. //$addedresource_item = "Users";
  266. $addedresource_item = TOOL_USER;
  267. $title = get_lang('Users');
  268. break;
  269. case 'Link':
  270. /*
  271. if ($target == '')
  272. {
  273. $target = '_self';
  274. }
  275. */
  276. //$addedresource_item .= ' '.$target;
  277. //error_log('New LP - resourcelinker.php - In Link addition: '.$external_link);
  278. $addedresource_item = TOOL_LINK;
  279. $title = $external_link;
  280. break;
  281. case 'Document':
  282. $addedresource_item = TOOL_DOCUMENT;
  283. //get title from tool-type table
  284. $tooltable = Database::get_course_table(TABLE_DOCUMENT);
  285. $result = api_sql_query("SELECT * FROM $tooltable WHERE id=".$addedresourceid[$i],__FILE__,__LINE__);
  286. $myrow=mysql_fetch_array($result);
  287. $title = $myrow['title'];
  288. break;
  289. case 'Exercise':
  290. $addedresource_item = TOOL_QUIZ;
  291. //get title from tool-type table
  292. $tooltable = Database::get_course_table(TABLE_QUIZ_TEST);
  293. $result = api_sql_query("SELECT * FROM $tooltable WHERE id=".$addedresourceid[$i],__FILE__,__LINE__);
  294. $myrow=mysql_fetch_array($result);
  295. $title = $myrow['title'];
  296. break;
  297. case 'Forum':
  298. $addedresource_item = TOOL_FORUM;
  299. //TODO
  300. break;
  301. case 'Agenda':
  302. $addedresource_item = TOOL_CALENDAR_EVENT;
  303. //get title from tool-type table
  304. $tooltable = Database::get_course_table(TABLE_AGENDA);
  305. $result = api_sql_query("SELECT * FROM $tooltable WHERE id=".$addedresourceid[$i],__FILE__,__LINE__);
  306. $myrow=mysql_fetch_array($result);
  307. $title = $myrow['title'];
  308. break;
  309. case 'Ad_Valvas':
  310. $addedresource_item = TOOL_ANNOUNCEMENT;
  311. //get title from tool-type table
  312. $tooltable = Database::get_course_table(TABLE_ANNOUNCEMENT);
  313. $result = api_sql_query("SELECT * FROM $tooltable WHERE id=".$addedresourceid[$i],__FILE__,__LINE__);
  314. $myrow=mysql_fetch_array($result);
  315. $title = $myrow['title'];
  316. break;
  317. }
  318. $sql = "INSERT INTO $tbl_lp_item (lp_id, title, parent_item_id, item_type, ref, previous_item_id, next_item_id, display_order) " .
  319. "VALUES ($learnpath_id, '$title','$chapter_id', '$addedresource_item','$addedresourceid[$i]',$previous,0,'".$lastorder."')";
  320. //error_log('New LP - Inserting new resource: '.$sql,0);
  321. $result = api_sql_query($sql, __FILE__, __LINE__);
  322. $my_id = Database::get_last_insert_id($result);
  323. if($previous>0){
  324. $sql = "UPDATE $tbl_lp_item SET next_item_id = $my_id WHERE id = $previous";
  325. //error_log($sql,0);
  326. $res = api_sql_query($sql,__FILE__,__LINE__);
  327. }
  328. $addedresourceassigned[$i] = 1;
  329. $resource_added = true;
  330. }
  331. $i ++;
  332. $lastorder ++;
  333. }
  334. //$_SESSION['addedresource']=null;
  335. //$_SESSION['addedresourceid']=null;
  336. // cleaning up the session once again
  337. $_SESSION['addedresource'] = null;
  338. $_SESSION['addedresourceid'] = null;
  339. $_SESSION['addedresourceassigned'] = null;
  340. unset ($_SESSION['addedresource']);
  341. unset ($_SESSION['addedresourceid']);
  342. unset ($_SESSION['addedresourceassigned']);
  343. }
  344. }
  345. /*
  346. ==============================================================================
  347. BREADCRUMBS
  348. This part is to allow going back to the tool where you came from
  349. in a previous version I used the table tool_list, but since the forum can access the
  350. resource_linker from two different pages (newtopic.php and editpost.php) and this is different
  351. from the link field in tool_list, I decide to hardcode this stuff here.
  352. By doing this, you can easily control which pages can access the toollinker and which not.
  353. ==============================================================================
  354. */
  355. if ($_GET["source_id"])
  356. {
  357. switch ($_GET["source_id"])
  358. {
  359. case "1" : // coming from Agenda
  360. if ($action == "edit")
  361. {
  362. $url = "../calendar/agenda.php?action=edit&id=49&originalresource=$originalresource";
  363. }
  364. elseif ($action == "add")
  365. {
  366. $url = "../calendar/agenda.php?action=add&originalresource=$originalresource";
  367. }
  368. else
  369. {
  370. $url = "../calendar/agenda.php?action=add";
  371. }
  372. $originaltoolname = get_lang("Agenda");
  373. $breadcrumbelement = array ("url" => $url, "name" => $originaltoolname);
  374. session_unregister('from_learnpath');
  375. unset ($from_learnpath);
  376. break;
  377. case "2" : // coming from forum: new topic
  378. $url = "../phpbb/newtopic.php?forum=$source_forum&md5=$md5";
  379. $originaltoolname = get_lang("ForumAddNewTopic");
  380. $breadcrumbelement = array ("url" => $url, "name" => $originaltoolname);
  381. session_unregister('from_learnpath');
  382. unset ($from_learnpath);
  383. break;
  384. case "3" : // coming from forum: edit topic
  385. $url = "../phpbb/editpost.php?post_id=$post_id&topic=$topic&forum=$forum&md5=$md5&originalresource=no";
  386. $originaltoolname = get_lang("ForumEditTopic");
  387. $breadcrumbelement = array ("url" => $url, "name" => $originaltoolname);
  388. session_unregister('from_learnpath');
  389. unset ($from_learnpath);
  390. break;
  391. case "4" : // coming from exercises: edit topic
  392. $url = "../exercice/admin.php?modifyAnswers=$modifyAnswers";
  393. $originaltoolname = get_lang("ExerciseAnswers");
  394. $breadcrumbelement = array ("url" => $url, "name" => $originaltoolname);
  395. session_unregister('from_learnpath');
  396. unset ($from_learnpath);
  397. break;
  398. case "5" : // coming from learning path
  399. $from_learnpath = 'yes';
  400. api_session_register('from_learnpath');
  401. break;
  402. case "6" : // coming from forum: reply
  403. $url = "../phpbb/reply.php?topic=$topic&forum=$forum&parentid=$parentid";
  404. $url = $_SESSION['origintoolurl'];
  405. $originaltoolname = get_lang("ForumReply");
  406. $breadcrumbelement = array ("url" => $url, "name" => $originaltoolname);
  407. session_unregister('from_learnpath');
  408. unset ($from_learnpath);
  409. break;
  410. /*************************************** add Frederik.Vermeire@pandora.be *************************************/
  411. case "7" : // coming from Ad_Valvas
  412. if ($action == "edit")
  413. {
  414. $url = "../announcements/announcements.php?action=edit&id=49&originalresource=$originalresource";
  415. }
  416. elseif ($action == "add")
  417. {
  418. $url = "../announcements/announcements.php?action=add&originalresource=$originalresource";
  419. }
  420. else
  421. {
  422. $url = "../announcements/announcements.php?action=add";
  423. }
  424. $originaltoolname = get_lang("AdValvas");
  425. $breadcrumbelement = array ("url" => $url, "name" => $originaltoolname);
  426. session_unregister('from_learnpath');
  427. unset ($from_learnpath);
  428. break;
  429. /*************************************** end add Frederik.Vermeire@pandora.be *********************************/
  430. }
  431. // We do not come from the learning path. We store the name of the tool & url in a session.
  432. if ($from_learnpath != 'yes')
  433. {
  434. if (!$_SESSION["origintoolurl"] OR $_SESSION["origintoolurl"]<>$interbreadcrumb["url"])
  435. {
  436. $_SESSION["origintoolurl"] = $breadcrumbelement["url"];
  437. $_SESSION["origintoolname"] = $breadcrumbelement["name"];
  438. $interbreadcrumb = "";
  439. }
  440. }
  441. }
  442. // This part of the code is the actual breadcrumb mechanism. If we do not come from the learning path we use
  443. // the information from the session. Else we use the information of the learningpath itself.
  444. if ($from_learnpath != 'yes')
  445. {
  446. $nameTools = get_lang('Attachment');
  447. $interbreadcrumb[] = array ("url" => $_SESSION["origintoolurl"], "name" => $_SESSION["origintoolname"]);
  448. }
  449. else
  450. {
  451. $learnpath_select_query = " SELECT * FROM $tbl_lp
  452. WHERE id=$learnpath_id";
  453. $sql_result = api_sql_query($learnpath_select_query);
  454. $therow = mysql_fetch_array($sql_result);
  455. $learnpath_chapter_query = " SELECT * FROM $tbl_lp_item
  456. WHERE (lp_id = '$learnpath_id' and id = '$chapter_id')";
  457. $sql_result = api_sql_query($learnpath_chapter_query);
  458. $therow2 = mysql_fetch_array($sql_result);
  459. $from_learnpath = 'yes';
  460. session_register('from_learnpath');
  461. $interbreadcrumb[] = array ("url" => "../newscorm/lp_controller.php?action=list", "name" => get_lang('LearningPath'));
  462. $interbreadcrumb[] = array ("url" => "../newscorm/lp_controller.php?action=admin_view&lp_id=$learnpath_id", "name" => stripslashes("{$therow['name']}"));
  463. $interbreadcrumb[] = array ("url" => $_SERVER['PHP_SELF']."?action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&originalresource=no", "name" => "{$therow2['title']}");
  464. }
  465. $htmlHeadXtra[] = '<script type="text/javascript">
  466. /* <![CDATA[ */
  467. function targetfunc(input)
  468. {
  469. window.location=window.location+"&amp;target="+document.learnpath_link.target.value;
  470. }
  471. /* ]]> */
  472. </script>';
  473. Display :: display_header($nameTools);
  474. echo "<h3>".$nameTools;
  475. if ($from_learnpath == 'yes')
  476. {
  477. echo get_lang("AddResource")." - {$therow2['title']}";
  478. }
  479. echo "</h3>";
  480. // we retrieve the tools that are active.
  481. // We use this to check which resources a student may add (only the modules that are active)
  482. // see http://www.dokeos.com/forum/viewtopic.php?t=4858
  483. $active_modules=array();
  484. $tool_table = Database::get_course_table(TABLE_TOOL_LIST);
  485. $sql_select_active="SELECT * FROM $tool_table WHERE visibility='1'";
  486. $result_select_active=api_sql_query($sql_select_active);
  487. while ($row=mysql_fetch_array($result_select_active))
  488. {
  489. $active_modules[]=$row['name'];
  490. }
  491. ?>
  492. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  493. <tr>
  494. <td width="300" valign="top" style='padding-right:15px;'>
  495. <table width="300" border="0" cellspacing="0" cellpadding="0" style='border-right:1px solid grey;'>
  496. <?php if ($from_learnpath != 'yes') { ?>
  497. <tr>
  498. <td width="26%"><b><?php echo get_lang('CourseResources'); ?></b></td>
  499. </tr>
  500. <?php
  501. if (is_allowed_to_edit() OR in_array(TOOL_DOCUMENT,$active_modules))
  502. {
  503. ?>
  504. <tr>
  505. <td><?php echo "<a href=\"".$_SERVER['PHP_SELF']."?content=Document&action=$action&id=$id&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Document')."</a>"; ?></td>
  506. </tr>
  507. <?php
  508. }
  509. if (is_allowed_to_edit() OR in_array(TOOL_CALENDAR_EVENT,$active_modules))
  510. {
  511. ?>
  512. <tr>
  513. <td><?php echo "<a href=\"".$_SERVER['PHP_SELF']."?content=Agenda&action=$action&id=$id&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Agenda')."</a>"; ?></td>
  514. </tr>
  515. <?php
  516. }
  517. if (is_allowed_to_edit() OR in_array(TOOL_ANNOUNCEMENT,$active_modules))
  518. {
  519. ?>
  520. <tr>
  521. <td><?php echo "<a href=\"".$_SERVER['PHP_SELF']."?content=Ad_Valvas&action=$action&id=$id&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('AdValvas')."</a>"; ?></td>
  522. </tr>
  523. <?php
  524. }
  525. if (is_allowed_to_edit() OR in_array(TOOL_BB_FORUM,$active_modules))
  526. {
  527. ?>
  528. <tr>
  529. <td><?php echo "<a href=\"".$_SERVER['PHP_SELF']."?content=Forum&action=$action&id=$id&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Forum')."</a>"; ?></td>
  530. </tr>
  531. <?php
  532. }
  533. if (is_allowed_to_edit() OR in_array(TOOL_LINK,$active_modules))
  534. {
  535. ?>
  536. <tr>
  537. <td><?php echo "<a href=\"".$_SERVER['PHP_SELF']."?content=Link&action=$action&id=$id&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Link')."</a>"; ?></td>
  538. </tr>
  539. <?php
  540. }
  541. if (is_allowed_to_edit() OR in_array(TOOL_QUIZ,$active_modules))
  542. {
  543. ?>
  544. <tr>
  545. <td><?php echo "<a href=\"".$_SERVER['PHP_SELF']."?content=Exercise&action=$action&id=$id&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Exercise')."</a>"; ?></td>
  546. </tr>
  547. <?php
  548. }
  549. }
  550. else
  551. {
  552. ?>
  553. <!--tr>
  554. <td width="26%"><b><?php echo get_lang('ExportableCourseResources'); ?></b></td>
  555. </tr-->
  556. <?php if ($multi_level_learnpath === true ) { ?>
  557. <tr>
  558. <td><?php echo "<a href=\"".$_SERVER['PHP_SELF']."?content=chapter&action=$action&id=$id&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Chapter')."</a>"; ?></td>
  559. </tr>
  560. <?php } ?>
  561. <tr>
  562. <td><?php echo "<a href=\"".$_SERVER['PHP_SELF']."?content=Document&action=$action&id=$id&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Document')."</a>"; ?></td>
  563. </tr>
  564. <tr>
  565. <td><?php echo "<a href=\"".$_SERVER['PHP_SELF']."?content=Exercise&action=$action&id=$id&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Exercise')."</a>"; ?></td>
  566. </tr>
  567. <tr>
  568. <td><?php echo "<a href=\"".$_SERVER['PHP_SELF']."?content=Link&action=$action&id=$id&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Link')."</a>"; ?></td>
  569. </tr>
  570. <tr>
  571. <td><?php echo "<a href=\"".$_SERVER['PHP_SELF']."?content=Forum&action=$action&id=$id&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Forum')."</a>"; ?></td>
  572. </tr>
  573. <tr>
  574. <td><?php echo "<a href=\"".$_SERVER['PHP_SELF']."?content=Agenda&action=$action&id=$id&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Agenda')."</a>"; ?></td>
  575. </tr>
  576. <tr>
  577. <td><?php echo "<a href=\"".$_SERVER['PHP_SELF']."?content=Ad_Valvas&action=$action&id=$id&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('AdValvas')."</a>"; ?></td>
  578. </tr>
  579. <!--tr>
  580. <td><?php echo "<a href=\"".$_SERVER['PHP_SELF']."?content=Course_description&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('CourseDescription')."</a>"; ?></td>
  581. </tr-->
  582. <!--tr>
  583. <td><?php echo "<a href=\"".$_SERVER['PHP_SELF']."?content=Introduction_text&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('IntroductionText')."</a>"; ?></td>
  584. </tr-->
  585. <!--tr>
  586. <td>&nbsp;</td>
  587. </tr-->
  588. <!--tr>
  589. <td width="26%"><b><?php echo get_lang('DokeosRelatedCourseMaterial'); ?></b></td>
  590. </tr-->
  591. <tr>
  592. <td><?php echo "<a href=\"".$_SERVER['PHP_SELF']."?content=Dropbox&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Dropbox')."</a>"; ?></td>
  593. </tr>
  594. <tr>
  595. <td><?php echo "<a href=\"".$_SERVER['PHP_SELF']."?content=Assignment&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Assignments')."</a>"; ?></td>
  596. </tr>
  597. <tr>
  598. <td><?php echo "<a href=\"".$_SERVER['PHP_SELF']."?content=Groups&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Groups')."</a>"; ?></td>
  599. </tr>
  600. <tr>
  601. <td><?php echo "<a href=\"".$_SERVER['PHP_SELF']."?content=Users&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('Users')."</a>"; ?></td>
  602. </tr>
  603. <?php
  604. }
  605. ?>
  606. <!--tr>
  607. <td>&nbsp;</td>
  608. </tr-->
  609. <!--tr>
  610. <td><b><?php echo get_lang("ExternalResources"); ?></b></td>
  611. </tr-->
  612. <tr>
  613. <td><?php echo "<a href=\"".$_SERVER['PHP_SELF']."?content=Externallink&action=$action&id=$id&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('ExternalLink')."</a>"; ?></td>
  614. </tr>
  615. <?php
  616. if ($from_learnpath != 'yes')
  617. {
  618. echo "<tr><td>&nbsp;</td></tr>";
  619. echo "<tr><td><b>".get_lang('ResourcesAdded')." (";
  620. echo count($addedresource);
  621. echo ")</b></td></tr>";
  622. echo "<tr><td nowrap><a href=\"".$_SERVER['PHP_SELF']."?showresources=true&action=$action&id=$id&lp_id=$learnpath_id&parent_item_id=$chapter_id&source_forum=$source_forum&originalresource=no\">".get_lang('ShowDelete')."</a>";
  623. echo "</td></tr>";
  624. }
  625. ?>
  626. <tr>
  627. <td>&nbsp;</td>
  628. </tr>
  629. <!--<tr>
  630. <td><b><?php echo get_lang('BackTo'); ?></b></td>
  631. </tr>//-->
  632. <tr>
  633. <td>
  634. <?php
  635. if ($from_learnpath != 'yes')
  636. {
  637. echo "<form method=\"post\" action=\"{$_SESSION['origintoolurl']}\" style=\"margin: 0px;\"><input type=\"submit\" value=\"".get_lang('Ok')."\"></form>";
  638. }
  639. else
  640. {
  641. echo "<form method=\"get\" action=\"lp_controller.php\" style=\"margin: 0px;\"><input type=\"hidden\" name=\"lp_id\" value=\"".htmlentities($learnpath_id)."\"><input type=\"hidden\" name=\"action\" value=\"admin_view\"><input type=\"submit\" value=\"".get_lang('Ok')."\"></form>";
  642. }
  643. ?>
  644. </td>
  645. </tr>
  646. <tr>
  647. <td>&nbsp;</td>
  648. </tr>
  649. </table>
  650. </td>
  651. <td valign="top">
  652. <?php
  653. if ($resource_added)
  654. {
  655. Display :: display_normal_message(get_lang("ResourceAdded"));
  656. }
  657. if ($InvalidURL)
  658. {
  659. Display :: display_normal_message(get_lang("GiveURL"));
  660. }
  661. if ($from_learnpath != 'yes')
  662. {
  663. echo count($addedresource)." ".strtolower(get_lang('ResourcesAdded'))."<br/>";
  664. }
  665. //echo "<hr>";
  666. // Agenda items -->
  667. if ($content == "Agenda")
  668. {
  669. include (api_get_path(LIBRARY_PATH)."text.lib.php");
  670. $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);
  671. $TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
  672. $sql="SELECT agenda.*, toolitemproperties.*
  673. FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
  674. WHERE `agenda`.`id` = `toolitemproperties`.`ref`
  675. AND `toolitemproperties`.`tool`='".TOOL_CALENDAR_EVENT."'
  676. AND `toolitemproperties`.`to_group_id`='0'
  677. AND `toolitemproperties`.`visibility`='1'";
  678. $result = api_sql_query($sql);
  679. while ($myrow = mysql_fetch_array($result))
  680. {
  681. echo "<table width=\"100%\"><tr><td bgcolor=\"#E6E6E6\">";
  682. echo "<img src='../img/agenda.gif' alt='agenda'>";
  683. echo ucfirst(format_locale_date($dateFormatLong, strtotime($myrow["start_date"])))."&nbsp;";
  684. echo ucfirst(strftime($timeNoSecFormat, strtotime($myrow["start_date"])))."<br>";
  685. echo "<b>".$myrow["title"]."</b></td></tr><tr><td>";
  686. echo $myrow["content"]."<br />";
  687. showorhide_addresourcelink($content, $myrow["id"]);
  688. echo "</td></tr></table><br />";
  689. }
  690. } // end if ($_GET["resource"]=="Agenda")
  691. /*
  692. -----------------------------------------------------------
  693. chapter
  694. -----------------------------------------------------------
  695. */
  696. if ($content == "chapter")
  697. {
  698. echo '<table><form name="add_chapter" action="'.'" method="POST">'."\n";
  699. echo ' <tr><td>'.get_lang('Title').'</td><td><input type="text" name="title" value="'.$title.'"></input></td></tr>'."\n";
  700. echo ' <tr><td>'.get_lang('Description').'</td><td><input type="text" name="description" value="'.$description.'"></input></td></tr>'."\n";
  701. echo ' <tr><td></td><td><input type="submit" name="add_chapter" value="'.get_lang('AddIt').'"/></td></tr>'."\n";
  702. echo '</form></table>'."\n";
  703. //echo "<hr>";
  704. }
  705. /*
  706. -----------------------------------------------------------
  707. Documents
  708. -----------------------------------------------------------
  709. */
  710. // We show the documents in the following cases
  711. // 1. the link to add documenets in the resource linker was clicked
  712. // 2. we come to the resource linker for the first time (documents = default). In this case it can only be shown if
  713. // a. one is a teacher (documents can be shown even if the tool is inactive)
  714. // b. one is a student AND the documents tool is active. Student cannot add documents if the documents tool is inactive (teacher can do this)
  715. if ($content == "Document" OR (empty($content) AND (is_allowed_to_edit() OR in_array(TOOL_DOCUMENT,$active_modules))) AND !$_GET['showresources'])
  716. {
  717. // setting variables for file locations
  718. $baseServDir = $_configuration['root_sys'];
  719. $courseDir = $_course['path']."/document";
  720. $baseWorkDir = $baseServDir.$courseDir;
  721. // showing the link to move one folder up (when not in the root folder)
  722. show_folder_up();
  723. // showing the blue bar with the path in it when we are not in the root
  724. if (get_levels($folder))
  725. {
  726. echo "<table width=\"100%\"><tr><td bgcolor=\"#4171B5\">";
  727. echo "<img src=\"../img/opendir.gif\" alt='directory'><font color=\"#ffffff\"><b>";
  728. echo $folder."</b></font></td></tr></table>";
  729. }
  730. // showing the documents and subfolders of the folder we are in.
  731. show_documents($folder);
  732. //echo "<hr>";
  733. }
  734. /*
  735. -----------------------------------------------------------
  736. Ad Valvas
  737. -----------------------------------------------------------
  738. */
  739. if ($content == "Ad_Valvas")
  740. {
  741. include (api_get_path(LIBRARY_PATH)."text.lib.php");
  742. $tbl_announcement = Database :: get_course_table(TABLE_ANNOUNCEMENT);
  743. $sql = "SELECT * FROM ".$tbl_announcement." a, ".$item_property_table." i WHERE i.tool = '".TOOL_ANNOUNCEMENT."' AND a.id=i.ref AND i.visibility='1' AND i.to_group_id = 0 AND i.to_user_id IS NULL ORDER BY a.display_order ASC";
  744. //error_log($sql,0);
  745. $result = api_sql_query($sql,__FILE__,__LINE__);
  746. while ($myrow = mysql_fetch_array($result))
  747. {
  748. echo "<table width=\"100%\"><tr><td>";
  749. echo "<img src='../img/valves.gif' alt='advalvas'>";
  750. echo ucfirst(format_locale_date($dateFormatLong, strtotime($myrow["end_date"])));
  751. echo "</td></tr><tr><td>";
  752. echo $myrow["title"]."<br />";
  753. showorhide_addresourcelink($content, $myrow["id"]);
  754. echo "</td></tr></table>";
  755. }
  756. }
  757. /*
  758. -----------------------------------------------------------
  759. Forums
  760. -----------------------------------------------------------
  761. */
  762. if ($content == "Forum")
  763. {
  764. $TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
  765. $TBL_CATAGORIES = Database::get_course_table(TABLE_FORUM_CATEGORY);
  766. $TBL_FORUMTOPICS = Database::get_course_table(TABLE_FORUM_THREAD);
  767. $tbl_posts = Database::get_course_table(TABLE_FORUM_POST);
  768. echo "<table width='100%'>";
  769. // displaying the categories and the forums
  770. if (!$forum and !$thread)
  771. {
  772. $sql = "SELECT * FROM ".$TBL_FORUMS." forums, ".$TBL_CATAGORIES." categories WHERE forums.forum_category=categories.cat_id ORDER BY forums.forum_category DESC";
  773. //error_log($sql,0);
  774. $result = api_sql_query($sql, __FILE__, __LINE__);
  775. while ($myrow = mysql_fetch_array($result))
  776. {
  777. if ($myrow["cat_title"] !== $old_cat_title)
  778. {
  779. echo "<tr><td bgcolor='#4171B5' colspan='2'><font color='white'><b>".$myrow["cat_title"]."</b></font></td></tr>";
  780. }
  781. $old_cat_title = $myrow["cat_title"];
  782. echo "<tr><td><img src='../img/forum.gif'><a href='".$_SERVER['PHP_SELF']."?content=Forum&category=".$myrow["cat_id"]."&forum=".$myrow["forum_id"]."&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&originalresource=no'>".$myrow["forum_name"]."</td><td>";
  783. showorhide_addresourcelink("Forum", $myrow["forum_id"]);
  784. echo "</td></tr>";
  785. }
  786. }
  787. //displaying all the threads of one forum
  788. if ($forum)
  789. {
  790. // displaying the category title
  791. $sql = "SELECT * FROM ".$TBL_CATAGORIES." WHERE cat_id=$category";
  792. $result = api_sql_query($sql, __FILE__, __LINE__);
  793. $myrow = mysql_fetch_array($result);
  794. echo "<tr><td bgcolor='#4171B5' colspan='2'><font color='white'><b>".$myrow["cat_title"]."</b></font></td></tr>";
  795. // displaying the forum title
  796. $sql = "SELECT * FROM ".$TBL_FORUMS." forums, ".$TBL_FORUMTOPICS." topics WHERE forums.forum_id=topics.forum_id";
  797. $result = api_sql_query($sql, __FILE__, __LINE__);
  798. $myrow = mysql_fetch_array($result);
  799. echo "<tr><td bgcolor='#cccccc' colspan='2'><b>".$myrow["forum_name"]."</b></td></tr>";
  800. if (!$thread)
  801. {
  802. // displaying all the threads of this forum
  803. $sql = "SELECT * FROM ".$TBL_FORUMTOPICS." WHERE forum_id=$forum";
  804. $result = api_sql_query($sql, __FILE__, __LINE__);
  805. while ($myrow = mysql_fetch_array($result))
  806. {
  807. echo "<tr><td><a href='".$_SERVER['PHP_SELF']."?content=Forum&category=$category&forum=1&thread=".$myrow["topic_id"]."&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&originalresource=no'>".$myrow["topic_title"]."</a> (".$myrow["prenom"]." ".$myrow["nom"].")</td><td>";
  808. showorhide_addresourcelink("Thread", $myrow["topic_id"]);
  809. echo "</td></tr>";
  810. }
  811. }
  812. else
  813. {
  814. // displaying all the replies
  815. $sql = "SELECT * FROM ".$tbl_posts." post WHERE post.topic_id=$thread ORDER BY post.post_id ASC";
  816. $result = api_sql_query($sql, __FILE__, __LINE__);
  817. while ($myrow = mysql_fetch_array($result))
  818. {
  819. echo "<tr><td><b>".$myrow["post_title"]."</b><br>";
  820. echo $myrow["post_text"]."</td>";
  821. echo "<td>";
  822. showorhide_addresourcelink("Post", $myrow["post_id"]);
  823. echo "</td></tr><tr><td colspan='2'><hr noshade></td></tr>";
  824. }
  825. }
  826. }
  827. echo "</table>";
  828. }
  829. /*
  830. -----------------------------------------------------------
  831. Links
  832. -----------------------------------------------------------
  833. */
  834. if ($content == "Link")
  835. {
  836. // including the links language file
  837. include ("../lang/$language/link.inc.php");
  838. // including the links functions file
  839. include ("../link/linkfunctions.php");
  840. $tbl_categories = Database::get_course_table(TABLE_LINK_CATEGORY);
  841. if (($learnpath_id != '') and ($content == 'Link'))
  842. {
  843. echo "<form name='learnpath_link'><table>";
  844. echo "<tr></td><td align='left'>".get_lang('LinkTarget')." :</td><td align='left'><select name='target' onchange='targetfunc()'><option value='_self' ";
  845. if ($target == '_self')
  846. {
  847. echo "selected";
  848. }
  849. echo ">".get_lang('SameWindow')."</option><option value='_blank'";
  850. if ($target == '_blank')
  851. {
  852. echo "selected";
  853. }
  854. echo ">".get_lang('NewWindow')."</option></select></td></tr></table></form>";
  855. }
  856. // showing the links that are in the root (having no category)
  857. $sql = "SELECT * FROM ".$link_table.", ".$item_property_table." WHERE (category_id=0 or category_id IS NULL) AND tool = '".TOOL_LINK."' AND id=ref AND visibility='1'";
  858. $result = api_sql_query($sql, __FILE__, __LINE__);
  859. if (mysql_num_rows($result) > 0)
  860. {
  861. echo "<table width=\"100%\"><tr><td bgcolor=\"#E6E6E6\"><i>".get_lang('NoCategory')."</i></td></tr></table>";
  862. while ($myrow = mysql_fetch_array($result))
  863. {
  864. echo "<img src='../img/links.gif'>".$myrow["title"];
  865. echo "<br>";
  866. showorhide_addresourcelink($content, $myrow["id"]);
  867. echo "<br><br>";
  868. }
  869. }
  870. // showing the categories and the links in it.
  871. $sqlcategories = "SELECT * FROM ".$tbl_categories." ORDER by display_order DESC";
  872. $resultcategories = api_sql_query($sqlcategories) or die;
  873. while ($myrow = @ mysql_fetch_array($resultcategories))
  874. {
  875. $sql_links = "SELECT * FROM ".$link_table.", ".$item_property_table." WHERE category_id='".$myrow["id"]."' AND tool = '".TOOL_LINK."' AND id=ref AND visibility='1' ORDER BY display_order DESC";
  876. echo "<table width=\"100%\"><tr><td bgcolor=\"#E6E6E6\"><i>".$myrow["category_title"]."</i></td></tr></table>";
  877. $result_links = api_sql_query($sql_links, __FILE__, __LINE__);
  878. while ($myrow = mysql_fetch_array($result_links))
  879. {
  880. echo "<img src='../img/links.gif' />".$myrow["title"];
  881. echo "<br>";
  882. showorhide_addresourcelink($content, $myrow["id"]);
  883. echo "<br><br>";
  884. }
  885. }
  886. }
  887. /*
  888. -----------------------------------------------------------
  889. Exercise
  890. -----------------------------------------------------------
  891. */
  892. if (($content == "Exercise") or ($content == "HotPotatoes"))
  893. {
  894. $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
  895. $result = api_sql_query("SELECT * FROM ".$TBL_EXERCICES." WHERE active='1' ORDER BY id ASC");
  896. while ($myrow = mysql_fetch_array($result))
  897. {
  898. echo "<img src='../img/quiz.gif'>".$myrow["title"]."<br>";
  899. showorhide_addresourcelink($content, $myrow["id"]);
  900. echo "<br><br>";
  901. }
  902. if ($from_learnpath == 'yes')
  903. {
  904. $uploadPath = "/HotPotatoes_files";
  905. $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
  906. $documentPath = api_get_path('SYS_COURSE_PATH').$_course['path'].'/document';
  907. $sql = "SELECT * FROM ".$TBL_DOCUMENT." WHERE (path LIKE '%htm%' OR path LIKE '%html%') AND path LIKE '".$uploadPath."/%/%' ORDER BY `id` ASC";
  908. $result = api_sql_query($sql, __FILE__, __LINE__);
  909. while ($myrow = mysql_fetch_array($result))
  910. {
  911. $path = $myrow["path"];
  912. echo "<img src='../img/jqz.jpg'>".GetQuizName($path, $documentPath)."<br>";
  913. showorhide_addresourcelink("HotPotatoes", $myrow["id"]);
  914. echo "<br><br>";
  915. }
  916. }
  917. }
  918. /*
  919. -----------------------------------------------------------
  920. External Links
  921. -----------------------------------------------------------
  922. */
  923. if ($content == "Externallink")
  924. {
  925. ?>
  926. <form name="form1" method="post" action="">
  927. <table width="80%" border="0" cellspacing="0" cellpadding="0">
  928. <tr>
  929. <td align="right"><?php echo get_lang('ExternalLink'); ?> : &nbsp;</td>
  930. <td align="left"><input name="external_link" type="text" id="external_link" value="http://"></td>
  931. <?php
  932. if ($learnpath_id != '')
  933. {
  934. echo "</tr><tr><td align='right'>".get_lang('LinkTarget')." :</td><td align='left'><select name='target'><option value='_self'>".get_lang('SameWindow')."</option><option value='_blank'>".get_lang('NewWindow')."</option></select></td>";
  935. }
  936. ?>
  937. </tr>
  938. <tr>
  939. <td><?php if ($is_allowedToEdit) {echo get_lang('AddToLinks');} ?></td>
  940. <td>
  941. <?php if ($is_allowedToEdit){?>
  942. <select name="add_2_links" id="add_2_links">
  943. <option value="niet toevoegen" selected="selected">-<?php echo get_lang('DontAdd'); ?>-</option>
  944. <option value="0"><?php echo get_lang('MainCategory'); ?></option>
  945. <?php
  946. $tbl_categories = Database::get_course_table(TABLE_LINK_CATEGORY);
  947. $sql = "SELECT * FROM `$tbl_categories` ORDER BY display_order ASC";
  948. echo $sql;
  949. $result = api_sql_query($sql, __FILE__, __LINE__);
  950. while ($row = mysql_fetch_array($result))
  951. {
  952. echo "<option value='".$row["id"]."'>".$row["category_title"]."</option>";
  953. }
  954. ?>
  955. </select><?php } ?></td>
  956. </tr>
  957. <tr>
  958. <td>&nbsp;</td>
  959. <td><input name="external_link_submit" type="submit" id="external_link_submit" value="<?php echo get_lang('AddIt'); ?>"></td>
  960. </tr>
  961. <tr>
  962. <td>&nbsp;</td>
  963. <td>&nbsp;</td>
  964. </tr>
  965. <tr>
  966. <td colspan="2">&nbsp;</td>
  967. </tr>
  968. </table>
  969. </form>
  970. <?php
  971. }
  972. /*
  973. -----------------------------------------------------------
  974. Assignments
  975. -----------------------------------------------------------
  976. */
  977. if ($content == "Assignment")
  978. {
  979. echo "<a href=".$_SERVER['PHP_SELF']."?content=Ass&add=Ass&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&originalresource=no>".get_lang('AddAssignmentPage')."</a>";
  980. }
  981. /*
  982. -----------------------------------------------------------
  983. Dropbox
  984. -----------------------------------------------------------
  985. */
  986. if ($content == "Dropbox")
  987. {
  988. echo "<a href='".$_SERVER['PHP_SELF']."?content=Drop&add=Drop&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&originalresource=no'>".get_lang('DropboxAdd')."</a>";
  989. }
  990. /*
  991. -----------------------------------------------------------
  992. Introduction text
  993. -----------------------------------------------------------
  994. */
  995. if ($content == "Introduction_text")
  996. {
  997. echo "<a href='".$_SERVER['PHP_SELF']."?content=Intro&add=Intro&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&originalresource=no'>".get_lang('IntroductionTextAdd')."</a>";
  998. }
  999. /*
  1000. -----------------------------------------------------------
  1001. Course description
  1002. -----------------------------------------------------------
  1003. */
  1004. if ($content == "Course_description")
  1005. {
  1006. echo "<a href='".$_SERVER['PHP_SELF']."?content=Course_desc&add=Course_desc&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&originalresource=no'>".get_lang('CourseDescriptionAdd')."</a>";
  1007. }
  1008. /*
  1009. -----------------------------------------------------------
  1010. Groups
  1011. -----------------------------------------------------------
  1012. */
  1013. if ($content == "Groups")
  1014. {
  1015. echo "<a href='".$_SERVER['PHP_SELF']."?content=Group&add=Group&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&originalresource=no'>".get_lang('GroupsAdd')."</a>";
  1016. }
  1017. /*
  1018. -----------------------------------------------------------
  1019. Users
  1020. -----------------------------------------------------------
  1021. */
  1022. if ($content == "Users")
  1023. {
  1024. echo "<a href='".$_SERVER['PHP_SELF']."?content=User&add=User&action=$action&lp_id=$learnpath_id&parent_item_id=$chapter_id&originalresource=no'>".get_lang('UsersAdd')."</a>";
  1025. }
  1026. if ($showresources)
  1027. {
  1028. //echo "<h4>".get_lang('ResourceAdded')."</h4>";
  1029. display_resources(1);
  1030. }
  1031. echo "</td></tr></table>";
  1032. /*
  1033. ==============================================================================
  1034. FOOTER
  1035. ==============================================================================
  1036. */
  1037. Display :: display_footer();
  1038. ?>