resourcelinker.php 42 KB

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