resourcelinker.php 37 KB

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