resourcelinker.php 43 KB

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