resourcelinker.php 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146
  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, __FILE__, __LINE__);
  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, __FILE__, __LINE__);
  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, __FILE__, __LINE__);
  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,__FILE__,__LINE__);
  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, __FILE__, __LINE__);
  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, __FILE__, __LINE__);
  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, __FILE__, __LINE__);
  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, __FILE__, __LINE__);
  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,__FILE__,__LINE__);
  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],__FILE__,__LINE__);
  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],__FILE__,__LINE__);
  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],__FILE__,__LINE__);
  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],__FILE__,__LINE__);
  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, __FILE__, __LINE__);
  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,__FILE__,__LINE__);
  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('Gradebook')
  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('Document')."</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('Link')."</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_ucfirst(format_locale_date($dateFormatLong, strtotime($myrow["start_date"])))."&nbsp;";
  695. echo api_ucfirst(strftime($timeNoSecFormat, strtotime($myrow["start_date"])))."<br />";
  696. echo "<b>".$myrow["title"]."</b></td></tr><tr><td>";
  697. echo $myrow["content"]."<br />";
  698. showorhide_addresourcelink($content, $myrow["id"]);
  699. echo "</td></tr></table><br />";
  700. }
  701. } // end if ($_GET["resource"]=="Agenda")
  702. /*
  703. -----------------------------------------------------------
  704. chapter
  705. -----------------------------------------------------------
  706. */
  707. if ($content == "chapter")
  708. {
  709. echo '<table><form name="add_chapter" action="'.'" method="POST">'."\n";
  710. echo ' <tr><td>'.get_lang('Title').'</td><td><input type="text" name="title" value="'.$title.'"></input></td></tr>'."\n";
  711. echo ' <tr><td>'.get_lang('Description').'</td><td><input type="text" name="description" value="'.$description.'"></input></td></tr>'."\n";
  712. echo ' <tr><td></td><td><input type="submit" name="add_chapter" value="'.get_lang('AddIt').'"/></td></tr>'."\n";
  713. echo '</form></table>'."\n";
  714. //echo "<hr>";
  715. }
  716. /*
  717. -----------------------------------------------------------
  718. Documents
  719. -----------------------------------------------------------
  720. */
  721. // We show the documents in the following cases
  722. // 1. the link to add documenets in the resource linker was clicked
  723. // 2. we come to the resource linker for the first time (documents = default). In this case it can only be shown if
  724. // a. one is a teacher (documents can be shown even if the tool is inactive)
  725. // 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)
  726. if ($content == "Document" OR (empty($content) AND (is_allowed_to_edit() OR in_array(TOOL_DOCUMENT,$active_modules))) AND !$_GET['showresources'])
  727. {
  728. // setting variables for file locations
  729. $baseServDir = $_configuration['root_sys'];
  730. $courseDir = $_course['path']."/document";
  731. $baseWorkDir = $baseServDir.$courseDir;
  732. // showing the link to move one folder up (when not in the root folder)
  733. show_folder_up();
  734. // showing the blue bar with the path in it when we are not in the root
  735. if (get_levels($folder))
  736. {
  737. echo "<table width=\"100%\"><tr><td bgcolor=\"#4171B5\">";
  738. echo "<img src=\"../img/opendir.gif\" alt='directory'><font color=\"#ffffff\"><b>";
  739. echo $folder."</b></font></td></tr></table>";
  740. }
  741. // showing the documents and subfolders of the folder we are in.
  742. show_documents($folder);
  743. //echo "<hr>";
  744. }
  745. /*
  746. -----------------------------------------------------------
  747. Ad Valvas
  748. -----------------------------------------------------------
  749. */
  750. if ($content == "Ad_Valvas")
  751. {
  752. include (api_get_path(LIBRARY_PATH)."text.lib.php");
  753. $tbl_announcement = Database :: get_course_table(TABLE_ANNOUNCEMENT);
  754. $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";
  755. //error_log($sql,0);
  756. $result = Database::query($sql,__FILE__,__LINE__);
  757. while ($myrow = Database::fetch_array($result))
  758. {
  759. echo "<table width=\"100%\"><tr><td>";
  760. echo "<img src='../img/valves.gif' alt='advalvas'>";
  761. echo api_ucfirst(format_locale_date($dateFormatLong, strtotime($myrow["end_date"])));
  762. echo "</td></tr><tr><td>";
  763. echo $myrow["title"]."<br />";
  764. showorhide_addresourcelink($content, $myrow["id"]);
  765. echo "</td></tr></table>";
  766. }
  767. }
  768. /*
  769. -----------------------------------------------------------
  770. Forums
  771. -----------------------------------------------------------
  772. */
  773. if ($content == "Forum")
  774. {
  775. $TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
  776. $TBL_CATAGORIES = Database::get_course_table(TABLE_FORUM_CATEGORY);
  777. $TBL_FORUMTOPICS = Database::get_course_table(TABLE_FORUM_THREAD);
  778. $tbl_posts = Database::get_course_table(TABLE_FORUM_POST);
  779. echo "<table width='100%'>";
  780. // displaying the categories and the forums
  781. if (!$forum and !$thread)
  782. {
  783. $sql = "SELECT * FROM ".$TBL_FORUMS." forums, ".$TBL_CATAGORIES." categories WHERE forums.forum_category=categories.cat_id ORDER BY forums.forum_category DESC";
  784. //error_log($sql,0);
  785. $result = Database::query($sql, __FILE__, __LINE__);
  786. while ($myrow = Database::fetch_array($result))
  787. {
  788. if ($myrow["cat_title"] !== $old_cat_title)
  789. {
  790. echo "<tr><td bgcolor='#4171B5' colspan='2'><font color='white'><b>".$myrow["cat_title"]."</b></font></td></tr>";
  791. }
  792. $old_cat_title = $myrow["cat_title"];
  793. 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>";
  794. showorhide_addresourcelink("Forum", $myrow["forum_id"]);
  795. echo "</td></tr>";
  796. }
  797. }
  798. //displaying all the threads of one forum
  799. if ($forum)
  800. {
  801. // displaying the category title
  802. $sql = "SELECT * FROM ".$TBL_CATAGORIES." WHERE cat_id=$category";
  803. $result = Database::query($sql, __FILE__, __LINE__);
  804. $myrow = Database::fetch_array($result);
  805. echo "<tr><td bgcolor='#4171B5' colspan='2'><font color='white'><b>".$myrow["cat_title"]."</b></font></td></tr>";
  806. // displaying the forum title
  807. $sql = "SELECT * FROM ".$TBL_FORUMS." forums, ".$TBL_FORUMTOPICS." topics WHERE forums.forum_id=topics.forum_id";
  808. $result = Database::query($sql, __FILE__, __LINE__);
  809. $myrow = Database::fetch_array($result);
  810. echo "<tr><td bgcolor='#cccccc' colspan='2'><b>".$myrow["forum_name"]."</b></td></tr>";
  811. if (!$thread)
  812. {
  813. // displaying all the threads of this forum
  814. $sql = "SELECT * FROM ".$TBL_FORUMTOPICS." WHERE forum_id=$forum";
  815. $result = Database::query($sql, __FILE__, __LINE__);
  816. while ($myrow = Database::fetch_array($result))
  817. {
  818. 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>";
  819. showorhide_addresourcelink("Thread", $myrow["topic_id"]);
  820. echo "</td></tr>";
  821. }
  822. }
  823. else
  824. {
  825. // displaying all the replies
  826. $sql = "SELECT * FROM ".$tbl_posts." post WHERE post.topic_id=$thread ORDER BY post.post_id ASC";
  827. $result = Database::query($sql, __FILE__, __LINE__);
  828. while ($myrow = Database::fetch_array($result))
  829. {
  830. echo "<tr><td><b>".$myrow["post_title"]."</b><br>";
  831. echo $myrow["post_text"]."</td>";
  832. echo "<td>";
  833. showorhide_addresourcelink("Post", $myrow["post_id"]);
  834. echo "</td></tr><tr><td colspan='2'><hr noshade></td></tr>";
  835. }
  836. }
  837. }
  838. echo "</table>";
  839. }
  840. /*
  841. -----------------------------------------------------------
  842. Links
  843. -----------------------------------------------------------
  844. */
  845. if ($content == "Link")
  846. {
  847. // including the links language file
  848. include ("../lang/$language/link.inc.php");
  849. // including the links functions file
  850. include ("../link/linkfunctions.php");
  851. $tbl_categories = Database::get_course_table(TABLE_LINK_CATEGORY);
  852. if (($learnpath_id != '') and ($content == 'Link'))
  853. {
  854. echo "<form name='learnpath_link'><table>";
  855. echo "<tr></td><td align='left'>".get_lang('LinkTarget')." :</td><td align='left'><select name='target' onchange='targetfunc()'><option value='_self' ";
  856. if ($target == '_self')
  857. {
  858. echo "selected";
  859. }
  860. echo ">".get_lang('SameWindow')."</option><option value='_blank'";
  861. if ($target == '_blank')
  862. {
  863. echo "selected";
  864. }
  865. echo ">".get_lang('NewWindow')."</option></select></td></tr></table></form>";
  866. }
  867. // showing the links that are in the root (having no category)
  868. $sql = "SELECT * FROM ".$link_table.", ".$item_property_table." WHERE (category_id=0 or category_id IS NULL) AND tool = '".TOOL_LINK."' AND id=ref AND visibility='1'";
  869. $result = Database::query($sql, __FILE__, __LINE__);
  870. if (Database::num_rows($result) > 0)
  871. {
  872. echo "<table width=\"100%\"><tr><td bgcolor=\"#E6E6E6\"><i>".get_lang('NoCategory')."</i></td></tr></table>";
  873. while ($myrow = Database::fetch_array($result))
  874. {
  875. echo "<img src='../img/links.gif'>".$myrow["title"];
  876. echo "<br>";
  877. showorhide_addresourcelink($content, $myrow["id"]);
  878. echo "<br><br>";
  879. }
  880. }
  881. // showing the categories and the links in it.
  882. $sqlcategories = "SELECT * FROM ".$tbl_categories." ORDER by display_order DESC";
  883. $resultcategories = Database::query($sqlcategories) or die;
  884. while ($myrow = @ Database::fetch_array($resultcategories))
  885. {
  886. $sql_links = "SELECT * FROM ".$link_table.", ".$item_property_table." WHERE category_id='".$myrow["id"]."' AND tool = '".TOOL_LINK."' AND id=ref AND visibility='1' ORDER BY display_order DESC";
  887. echo "<table width=\"100%\"><tr><td bgcolor=\"#E6E6E6\"><i>".$myrow["category_title"]."</i></td></tr></table>";
  888. $result_links = Database::query($sql_links, __FILE__, __LINE__);
  889. while ($myrow = Database::fetch_array($result_links))
  890. {
  891. echo "<img src='../img/links.gif' />".$myrow["title"];
  892. echo "<br>";
  893. showorhide_addresourcelink($content, $myrow["id"]);
  894. echo "<br><br>";
  895. }
  896. }
  897. }
  898. /*
  899. -----------------------------------------------------------
  900. Exercise
  901. -----------------------------------------------------------
  902. */
  903. if (($content == "Exercise") or ($content == "HotPotatoes"))
  904. {
  905. $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
  906. $result = Database::query("SELECT * FROM ".$TBL_EXERCICES." WHERE active='1' ORDER BY id ASC");
  907. while ($myrow = Database::fetch_array($result))
  908. {
  909. echo "<img src='../img/quiz.gif'>".$myrow["title"]."<br>";
  910. showorhide_addresourcelink($content, $myrow["id"]);
  911. echo "<br><br>";
  912. }
  913. if ($from_learnpath == 'yes')
  914. {
  915. $uploadPath = "/HotPotatoes_files";
  916. $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
  917. $documentPath = api_get_path('SYS_COURSE_PATH').$_course['path'].'/document';
  918. $sql = "SELECT * FROM ".$TBL_DOCUMENT." WHERE (path LIKE '%htm%' OR path LIKE '%html%') AND path LIKE '".$uploadPath."/%/%' ORDER BY `id` ASC";
  919. $result = Database::query($sql, __FILE__, __LINE__);
  920. while ($myrow = Database::fetch_array($result))
  921. {
  922. $path = $myrow["path"];
  923. echo "<img src='../img/jqz.jpg'>".GetQuizName($path, $documentPath)."<br>";
  924. showorhide_addresourcelink("HotPotatoes", $myrow["id"]);
  925. echo "<br><br>";
  926. }
  927. }
  928. }
  929. /*
  930. -----------------------------------------------------------
  931. External Links
  932. -----------------------------------------------------------
  933. */
  934. if ($content == "Externallink")
  935. {
  936. ?>
  937. <form name="form1" method="post" action="">
  938. <table width="80%" border="0" cellspacing="0" cellpadding="0">
  939. <tr>
  940. <td align="right"><?php echo get_lang('ExternalLink'); ?> : &nbsp;</td>
  941. <td align="left"><input name="external_link" type="text" id="external_link" value="http://"></td>
  942. <?php
  943. if ($learnpath_id != '')
  944. {
  945. 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>";
  946. }
  947. ?>
  948. </tr>
  949. <tr>
  950. <td><?php if ($is_allowedToEdit) {echo get_lang('AddToLinks');} ?></td>
  951. <td>
  952. <?php if ($is_allowedToEdit){?>
  953. <select name="add_2_links" id="add_2_links">
  954. <option value="niet toevoegen" selected="selected">-<?php echo get_lang('DontAdd'); ?>-</option>
  955. <option value="0"><?php echo get_lang('MainCategory'); ?></option>
  956. <?php
  957. $tbl_categories = Database::get_course_table(TABLE_LINK_CATEGORY);
  958. $sql = "SELECT * FROM `$tbl_categories` ORDER BY display_order ASC";
  959. echo $sql;
  960. $result = Database::query($sql, __FILE__, __LINE__);
  961. while ($row = Database::fetch_array($result))
  962. {
  963. echo "<option value='".$row["id"]."'>".$row["category_title"]."</option>";
  964. }
  965. ?>
  966. </select><?php } ?></td>
  967. </tr>
  968. <tr>
  969. <td>&nbsp;</td>
  970. <td><input name="external_link_submit" type="submit" id="external_link_submit" value="<?php echo get_lang('AddIt'); ?>"></td>
  971. </tr>
  972. <tr>
  973. <td>&nbsp;</td>
  974. <td>&nbsp;</td>
  975. </tr>
  976. <tr>
  977. <td colspan="2">&nbsp;</td>
  978. </tr>
  979. </table>
  980. </form>
  981. <?php
  982. }
  983. /*
  984. -----------------------------------------------------------
  985. Assignments
  986. -----------------------------------------------------------
  987. */
  988. if ($content == "Assignment")
  989. {
  990. 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>";
  991. }
  992. /*
  993. -----------------------------------------------------------
  994. Dropbox
  995. -----------------------------------------------------------
  996. */
  997. if ($content == "Dropbox")
  998. {
  999. 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>";
  1000. }
  1001. /*
  1002. -----------------------------------------------------------
  1003. Introduction text
  1004. -----------------------------------------------------------
  1005. */
  1006. if ($content == "Introduction_text")
  1007. {
  1008. 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>";
  1009. }
  1010. /*
  1011. -----------------------------------------------------------
  1012. Course description
  1013. -----------------------------------------------------------
  1014. */
  1015. if ($content == "Course_description")
  1016. {
  1017. 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>";
  1018. }
  1019. /*
  1020. -----------------------------------------------------------
  1021. Groups
  1022. -----------------------------------------------------------
  1023. */
  1024. if ($content == "Groups")
  1025. {
  1026. 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>";
  1027. }
  1028. /*
  1029. -----------------------------------------------------------
  1030. Users
  1031. -----------------------------------------------------------
  1032. */
  1033. if ($content == "Users")
  1034. {
  1035. 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>";
  1036. }
  1037. if ($showresources)
  1038. {
  1039. //echo "<h4>".get_lang('ResourceAdded')."</h4>";
  1040. display_resources(1);
  1041. }
  1042. echo "</td></tr></table>";
  1043. /*
  1044. ==============================================================================
  1045. FOOTER
  1046. ==============================================================================
  1047. */
  1048. Display :: display_footer();
  1049. ?>