resourcelinker.php 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026
  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 Display::return_icon('agenda.gif');
  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 Display::return_icon('opendir.gif');
  631. echo "<font color=\"#ffffff\"><b>";
  632. echo $folder."</b></font></td></tr></table>";
  633. }
  634. // showing the documents and subfolders of the folder we are in.
  635. show_documents($folder);
  636. //echo "<hr>";
  637. }
  638. /*
  639. -----------------------------------------------------------
  640. Ad Valvas
  641. -----------------------------------------------------------
  642. */
  643. if ($content == "Ad_Valvas") {
  644. $tbl_announcement = Database :: get_course_table(TABLE_ANNOUNCEMENT);
  645. $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";
  646. $result = Database::query($sql);
  647. while ($myrow = Database::fetch_array($result)) {
  648. echo "<table width=\"100%\"><tr><td>";
  649. echo Display::return_icon('valves.gif');
  650. echo api_convert_and_format_date($myrow["end_date"], DATE_FORMAT_LONG, date_default_timezone_get());
  651. echo "</td></tr><tr><td>";
  652. echo $myrow["title"]."<br />";
  653. showorhide_addresourcelink($content, $myrow["id"]);
  654. echo "</td></tr></table>";
  655. }
  656. }
  657. /*
  658. -----------------------------------------------------------
  659. Forums
  660. -----------------------------------------------------------
  661. */
  662. if ($content == "Forum") {
  663. $TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
  664. $TBL_CATAGORIES = Database::get_course_table(TABLE_FORUM_CATEGORY);
  665. $TBL_FORUMTOPICS = Database::get_course_table(TABLE_FORUM_POST);
  666. $tbl_posts = Database::get_course_table(TABLE_FORUM_POST);
  667. $tbl_posts_text = Database::get_course_table(TOOL_FORUM_POST_TEXT_TABLE);
  668. echo "<table width='100%'>";
  669. // displaying the categories and the forums
  670. if (!$forum and !$thread) {
  671. $sql = "SELECT * FROM ".$TBL_FORUMS." forums, ".$TBL_CATAGORIES." categories WHERE forums.cat_id=categories.cat_id ORDER BY forums.cat_id DESC";
  672. $result = Database::query($sql);
  673. while ($myrow = Database::fetch_array($result)) {
  674. if ($myrow["cat_title"] !== $old_cat_title) {
  675. echo "<tr><td bgcolor='#4171B5' colspan='2'><font color='white'><b>".$myrow["cat_title"]."</b></font></td></tr>";
  676. }
  677. $old_cat_title = $myrow["cat_title"];
  678. echo "<tr><td>";
  679. echo Display::return_icon('forum.gif');
  680. echo "<a href='".api_get_self(
  681. )."?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>";
  682. showorhide_addresourcelink("Forum", $myrow["forum_id"]);
  683. echo "</td></tr>";
  684. }
  685. }
  686. //displaying all the threads of one forum
  687. if ($forum) {
  688. // displaying the category title
  689. $sql = "SELECT * FROM ".$TBL_CATAGORIES." WHERE cat_id=$category";
  690. $result = Database::query($sql);
  691. $myrow = Database::fetch_array($result);
  692. echo "<tr><td bgcolor='#4171B5' colspan='2'><font color='white'><b>".$myrow["cat_title"]."</b></font></td></tr>";
  693. // displaying the forum title
  694. $sql = "SELECT * FROM ".$TBL_FORUMS." forums, ".$TBL_FORUMTOPICS." topics WHERE forums.forum_id=topics.forum_id";
  695. $result = Database::query($sql);
  696. $myrow = Database::fetch_array($result);
  697. echo "<tr><td bgcolor='#cccccc' colspan='2'><b>".$myrow["forum_name"]."</b></td></tr>";
  698. if (!$thread) {
  699. // displaying all the threads of this forum
  700. $sql = "SELECT * FROM ".$TBL_FORUMTOPICS." WHERE forum_id=$forum";
  701. $result = Database::query($sql);
  702. while ($myrow = Database::fetch_array($result)) {
  703. echo "<tr><td><a href='".api_get_self(
  704. )."?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>";
  705. showorhide_addresourcelink("Thread", $myrow["topic_id"]);
  706. echo "</td></tr>";
  707. }
  708. } else {
  709. // displaying all the replies
  710. $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";
  711. $result = Database::query($sql);
  712. while ($myrow = Database::fetch_array($result)) {
  713. echo "<tr><td><b>".$myrow["post_title"]."</b><br>";
  714. echo $myrow["post_text"]."</td>";
  715. echo "<td>";
  716. showorhide_addresourcelink("Post", $myrow["post_id"]);
  717. echo "</td></tr><tr><td colspan='2'><hr noshade></td></tr>";
  718. }
  719. }
  720. }
  721. echo "</table>";
  722. }
  723. /*
  724. -----------------------------------------------------------
  725. Links
  726. -----------------------------------------------------------
  727. */
  728. if ($content == "Link") {
  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. echo "<form name='learnpath_link'><table>";
  736. echo "<tr></td><td align='left'>".get_lang(
  737. 'LinkTarget'
  738. )." :</td><td align='left'><select name='target' onchange='targetfunc()'><option value='_self' ";
  739. if ($target == '_self') {
  740. echo "selected";
  741. }
  742. echo ">".get_lang('SameWindow')."</option><option value='_blank'";
  743. if ($target == '_blank') {
  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. echo "<table width=\"100%\"><tr><td bgcolor=\"#E6E6E6\"><i>".get_lang('NoCategory')."</i></td></tr></table>";
  753. while ($myrow = Database::fetch_array($result)) {
  754. echo Display::return_icon('links.gif');
  755. echo $myrow["title"];
  756. echo "<br>";
  757. showorhide_addresourcelink($content, $myrow["id"]);
  758. echo "<br><br>";
  759. }
  760. }
  761. // showing the categories and the links in it.
  762. $sqlcategories = "SELECT * FROM ".$tbl_categories." ORDER by display_order DESC";
  763. $resultcategories = Database::query($sqlcategories) or die;
  764. while ($myrow = @ Database::fetch_array($resultcategories)) {
  765. $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";
  766. echo "<table width=\"100%\"><tr><td bgcolor=\"#E6E6E6\"><i>".$myrow["category_title"]."</i></td></tr></table>";
  767. $result_links = Database::query($sql_links);
  768. while ($myrow = Database::fetch_array($result_links)) {
  769. echo Display::return_icon('links.gif');
  770. echo $myrow["title"];
  771. echo "<br>";
  772. showorhide_addresourcelink($content, $myrow["id"]);
  773. echo "<br><br>";
  774. }
  775. }
  776. }
  777. /*
  778. -----------------------------------------------------------
  779. Exercise
  780. -----------------------------------------------------------
  781. */
  782. if (($content == "Exercise") or ($content == "HotPotatoes")) {
  783. $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
  784. $result = Database::query("SELECT * FROM ".$TBL_EXERCICES." WHERE active='1' ORDER BY id ASC");
  785. while ($myrow = Database::fetch_array($result)) {
  786. echo Display::return_icon('quiz.gif');
  787. echo $myrow["title"]."<br>";
  788. showorhide_addresourcelink($content, $myrow["id"]);
  789. echo "<br><br>";
  790. }
  791. if ($from_learnpath == 'yes') {
  792. $uploadPath = "/HotPotatoes_files";
  793. $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
  794. $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  795. $sql = "SELECT * FROM ".$TBL_DOCUMENT." WHERE (path LIKE '%htm%' OR path LIKE '%html%') AND path LIKE '".$uploadPath."/%/%' ORDER BY id ASC";
  796. $result = Database::query($sql);
  797. while ($myrow = Database::fetch_array($result)) {
  798. $path = $myrow["path"];
  799. echo Display::return_icon('jqz.gif');
  800. echo GetQuizName($path, $documentPath)."<br>";
  801. showorhide_addresourcelink("HotPotatoes", $myrow["id"]);
  802. echo "<br><br>";
  803. }
  804. }
  805. }
  806. /*
  807. -----------------------------------------------------------
  808. External Links
  809. -----------------------------------------------------------
  810. */
  811. if ($content == "Externallink") {
  812. ?>
  813. <form name="form1" method="post" action="">
  814. <table width="80%" border="0" cellspacing="0" cellpadding="0">
  815. <tr>
  816. <td align="right"><?php echo get_lang('ExternalLink'); ?> : &nbsp;</td>
  817. <td align="left"><input name="external_link" type="text" id="external_link" value="http://"></td>
  818. <?php
  819. if ($learnpath_id != '') {
  820. echo "</tr><tr><td align='right'>".get_lang(
  821. 'LinkTarget'
  822. )." :</td><td align='left'><select name='target'><option value='_self'>".get_lang(
  823. 'SameWindow'
  824. )."</option><option value='_blank'>".get_lang('NewWindow')."</option></select></td>";
  825. }
  826. ?>
  827. </tr>
  828. <tr>
  829. <td><?php if ($is_allowedToEdit) {
  830. echo get_lang('AddToLinks');
  831. } ?></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. echo "<option value='".$row["id"]."'>".$row["category_title"]."</option>";
  844. }
  845. ?>
  846. </select><?php } ?></td>
  847. </tr>
  848. <tr>
  849. <td>&nbsp;</td>
  850. <td><input name="external_link_submit" type="submit" id="external_link_submit"
  851. 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. echo "<a href=".api_get_self(
  871. )."?content=Ass&add=Ass&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no>".get_lang(
  872. 'AddAssignmentPage'
  873. )."</a>";
  874. }
  875. /*
  876. -----------------------------------------------------------
  877. Dropbox
  878. -----------------------------------------------------------
  879. */
  880. if ($content == "Dropbox") {
  881. echo "<a href='".api_get_self(
  882. )."?content=Drop&add=Drop&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'>".get_lang(
  883. 'DropboxAdd'
  884. )."</a>";
  885. }
  886. /*
  887. -----------------------------------------------------------
  888. Introduction text
  889. -----------------------------------------------------------
  890. */
  891. if ($content == "Introduction_text") {
  892. echo "<a href='".api_get_self(
  893. )."?content=Intro&add=Intro&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'>".get_lang(
  894. 'IntroductionTextAdd'
  895. )."</a>";
  896. }
  897. /*
  898. -----------------------------------------------------------
  899. Course description
  900. -----------------------------------------------------------
  901. */
  902. if ($content == "Course_description") {
  903. echo "<a href='".api_get_self(
  904. )."?content=Course_desc&add=Course_desc&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'>".get_lang(
  905. 'CourseDescriptionAdd'
  906. )."</a>";
  907. }
  908. /*
  909. -----------------------------------------------------------
  910. Groups
  911. -----------------------------------------------------------
  912. */
  913. if ($content == "Groups") {
  914. echo "<a href='".api_get_self(
  915. )."?content=Group&add=Group&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'>".get_lang(
  916. '$GroupsAdd'
  917. )."</a>";
  918. }
  919. /*
  920. -----------------------------------------------------------
  921. Users
  922. -----------------------------------------------------------
  923. */
  924. if ($content == "Users") {
  925. echo "<a href='".api_get_self(
  926. )."?content=User&add=User&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no'>".get_lang(
  927. 'UsersAdd'
  928. )."</a>";
  929. }
  930. if ($showresources) {
  931. //echo "<h4>".get_lang('ResourceAdded')."</h4>";
  932. display_resources(1);
  933. }
  934. echo "</td></tr></table>";
  935. Display :: display_footer();