resourcelinker.php 37 KB

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