resourcelinker.php 37 KB

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