resourcelinker.php 43 KB

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