resourcelinker.php 40 KB

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