resourcelinker.inc.php 91 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063
  1. <?php // $Id: resourcelinker.inc.php 20468 2009-05-11 08:48:25Z ivantcholakov $
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @author Patrick Cool - original version
  5. * @author Denes Nagy - further improvements for learning path builder
  6. * @author Roan Embrechts - refactoring to improve code organisation
  7. * @package chamilo.resourcelinker
  8. * @todo use the constants for the tools
  9. * @todo use Database API instead of creating table names locally.
  10. * @todo This class is used?
  11. */
  12. use \ChamiloSession as Session;
  13. /**
  14. * INIT SECTION
  15. */
  16. include(api_get_path(SYS_CODE_PATH).'exercice/hotpotatoes.lib.php');
  17. /**
  18. * FUNCTIONS
  19. */
  20. function unset_session_resources()
  21. {
  22. $_SESSION['addedresource'] = '';
  23. $_SESSION['addedresourceid'] = '';
  24. Session::erase('addedresource');
  25. Session::erase('addedresourceid');
  26. }
  27. /**
  28. * Insert description here.
  29. */
  30. function show_folder_up()
  31. {
  32. global $folder;
  33. global $source_id, $action, $learnpath_id, $chapter_id, $originalresource;
  34. $level = FileManager::get_levels($folder);
  35. if ($level == 1) {
  36. echo "<a href='".api_get_self(
  37. )."?content=Document&amp;source_forum=".$_GET['source_forum']."&amp;source_id=$source_id&amp;action=$action&amp;learnpath_id=$learnpath_id&amp;chapter_id=$chapter_id&amp;originalresource=no'><img src='../img/folder_up.gif' border='0' />".get_lang(
  38. 'LevelUp'
  39. )."</a>";
  40. }
  41. if ($level and $level != 0 and $level != 1) {
  42. $folder_up = $folder;
  43. $folder_temp = explode('/', $folder);
  44. $last = count($folder_temp) - 1;
  45. unset($folder_temp[$last]);
  46. $folder_up = implode('/', $folder_temp);
  47. echo "<a href='".api_get_self(
  48. )."?content=Document&amp;source_forum=".$_GET['source_forum']."&amp;folder=$folder_up&amp;source_id=$source_id&amp;action=$action&amp;learnpath_id=$learnpath_id&amp;chapter_id=$chapter_id&amp;originalresource=no'><img src='../img/folder_up.gif' border='0' />".get_lang(
  49. 'LevelUp'
  50. )."</a>";
  51. }
  52. }
  53. /**
  54. * Shows the documents of the document tool
  55. * @param $folder
  56. */
  57. function show_documents($folder)
  58. {
  59. global $_course;
  60. global $source_id, $action, $learnpath_id, $chapter_id, $originalresource;
  61. // documents are a special case: the teacher can add an invisible document (it will be viewable by the user)
  62. // other tools do not have this feature. This only counts
  63. if (api_is_allowed_to_edit()) {
  64. $visibility = "ip.visibility<>'2'";
  65. } else {
  66. $visibility = "ip.visibility='1'";
  67. }
  68. $item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
  69. $document_table = Database::get_course_table(TABLE_DOCUMENT);
  70. $sql = "SELECT * from $document_table docs, $item_property_table ip WHERE docs.id=ip.ref AND ip.tool = '".TOOL_DOCUMENT."' AND $visibility AND ip.to_group_id = 0 AND ip.to_user_id IS NULL ORDER BY docs.path ASC";
  71. $result = Database::query($sql);
  72. while ($row = Database::fetch_array($result)) {
  73. if (!$folder) {
  74. if (FileManager::get_levels($row['path']) - 1 == 1) {
  75. // showing the right icon
  76. if (file_or_folder($row['path'])) {
  77. echo '<img src="../img/file.gif" align="middle" />';
  78. } else {
  79. $image = FileManager::choose_image($row['path']);
  80. echo "<img src=\"../img/$image\" align=\"middle\" />";
  81. }
  82. // folders should be clickable
  83. if (file_or_folder($row['path'])) {
  84. echo "<a href='".api_get_self()."?content=Document";
  85. echo "&amp;folder=".substr(
  86. $row['path'],
  87. 1
  88. )."&amp;source_id=$source_id&amp;source_forum=".$_GET['source_forum']."&amp;action=$action&amp;learnpath_id=$learnpath_id&amp;chapter_id=$chapter_id&amp;originalresource=no'>".substr(
  89. $row['path'],
  90. 1
  91. ).'</a><br />';
  92. } else {
  93. echo substr($row['path'], 1).' ';
  94. echo showorhide_addresourcelink('Document', $row['id']);
  95. echo '<br />';
  96. }
  97. }
  98. } else {
  99. // we calculate the level we are in by using the $folder in the url
  100. // we put +1 because it does not start with an / and in the database it does
  101. $level = FileManager::get_levels($folder) + 1;
  102. // we calculate each level of the database entry
  103. $file_level = FileManager::get_levels($row['path']) - 1;
  104. // if the level of the database entry is equal to the level we ar in, we put it into an array
  105. // as this is a potential good entry
  106. if ($file_level == $level) {
  107. $good_paths[] = $row['path'];
  108. $good_ids[] = $row['id'];
  109. }
  110. //$haystack=$row['path'];
  111. //$conform_folder=strstr($haystack, $folder);
  112. //if (str_replace($folder.'/','',$conform_folder)!==$folder)
  113. // {
  114. // $good_folders[]=$row['path'];
  115. //echo str_replace($folder.'/','',$conform_folder);
  116. // echo '<br />';
  117. // }// if (str_replace($folder.'/','',$conform_folder)!==$folder)
  118. } // else (if (!$folder))
  119. } //while ($row=Database::fetch_array($result))
  120. // this is code for the case that we are in a subfolder
  121. if ($good_paths) {
  122. // we have all the potential good database entries, the good ones are those that start with $folder
  123. foreach ($good_paths as $path) {
  124. if (strstr($path, $folder)) {
  125. $good_key = key($good_paths);
  126. // showing the right icon
  127. if (file_or_folder($path)) {
  128. echo '<img src="../img/file.gif" align="middle" />';
  129. } else {
  130. $image = FileManager::choose_image($path);
  131. echo "<img src=\"../img/$image\" align=\"middle\" />";
  132. }
  133. // folders should be clickable
  134. if (file_or_folder($path)) {
  135. $path = substr($path, 1); // remove the first / in folder_up
  136. $uri = str_replace($folder, $path, $_SERVER['REQUEST_URI']);
  137. $newuri = str_replace('add=', 'addnot=', $uri);
  138. //using the correct name of the folder
  139. $folder_name = str_replace($folder.'/', '', $path);
  140. echo "<a href='$newuri'>".$folder_name.'</a><br />';
  141. } else {
  142. echo str_replace("/$folder/", '', $path).' ';
  143. echo showorhide_addresourcelink('Document', $good_ids[$good_key]);
  144. echo '<br />';
  145. }
  146. }
  147. next($good_paths);
  148. }
  149. }
  150. }
  151. /**
  152. * Checks wether something is a file or a folder
  153. * 0 means file, 1 means folder
  154. * @param $filefolder
  155. * @todo use true and false instead of 1 and 0.
  156. */
  157. function file_or_folder($filefolder)
  158. {
  159. global $_course;
  160. global $baseServDir;
  161. $courseDir = $_course['path'].'/document';
  162. $baseWorkDir = api_get_path(SYS_COURSE_PATH).$courseDir;
  163. return (is_dir($baseWorkDir.$filefolder) ? 1 : 0);
  164. }
  165. /**
  166. * Inserts a resource into the database
  167. *
  168. * @param $source_type
  169. * @param $source_id
  170. */
  171. function store_resources($source_type, $source_id)
  172. {
  173. global $_course;
  174. $resource_table = Database::get_course_table(TABLE_LINKED_RESOURCES);
  175. $addedresource = $_SESSION['addedresource'];
  176. $addedresourceid = $_SESSION['addedresourceid'];
  177. if ($_SESSION['addedresource']) {
  178. foreach ($addedresource as $resource_type) {
  179. $sql = "INSERT INTO $resource_table (source_type, source_id, resource_type, resource_id) VALUES ('$source_type', '$source_id', '$resource_type', '".$addedresourceid[key(
  180. $addedresource
  181. )]."')";
  182. Database::query($sql);
  183. $i = key($addedresource);
  184. next($addedresource);
  185. }
  186. $_SESSION['addedresource'] = '';
  187. $_SESSION['addedresourceid'] = '';
  188. }
  189. }
  190. /**
  191. * Displays the link that opens a new browser window that views the added resource.
  192. *
  193. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  194. * @param $type the type of the tool
  195. * @param $id the id of the resource
  196. * @param $style this is used to style the link (for instance when a resource is hidden => the added resources should also be styled like they are hidden)
  197. * @todo use the constants for the type definitions.
  198. */
  199. function display_addedresource_link($type, $id, $style = '')
  200. {
  201. global $_course;
  202. // styling the link of the added resource
  203. if ($style <> '') {
  204. $styling = ' class="'.$style.'"';
  205. }
  206. $course_id = api_get_course_int_id();
  207. switch ($type) {
  208. case 'Agenda':
  209. $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);
  210. $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE c_id = $course_id AND id=$id");
  211. $myrow = Database::fetch_array($result);
  212. echo '<img src="../img/agenda.gif" align="middle" /> <a href="../calendar/agenda.php"'.$styling.'>'.$myrow['title']."</a><br />\n";
  213. break;
  214. case 'Ad_Valvas':
  215. $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
  216. $result = Database::query("SELECT * FROM $tbl_announcement WHERE c_id = $course_id AND id=$id");
  217. $myrow = Database::fetch_array($result);
  218. echo '<img src="../img/valves.gif" align="middle" /> <a href="../announcements/announcements.php"'.$styling.'>'.$myrow['title']."</a><br />\n";
  219. break;
  220. case 'Link':
  221. Database::get_course_table(TABLE_LINK);
  222. $result = Database::query("SELECT * FROM $TABLETOOLLINK WHERE c_id = $course_id AND id=$id");
  223. $myrow = Database::fetch_array($result);
  224. echo '<img src="../img/links.gif" align="middle" /> <a href="#" onclick="javascript:window.open(\'../link/link_goto.php?link_id='.$myrow['id'].'&amp;link_url='.urlencode(
  225. $myrow['url']
  226. )."','MyWindow','width=500,height=400,top='+((screen.height-400)/2)+',left='+((screen.width-500)/2)+',scrollbars=1,resizable=1,menubar=1'); return false;\"".$styling.'>'.$myrow['title']."</a><br />\n";
  227. break;
  228. case 'Exercise':
  229. $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
  230. $result = Database::query("SELECT * FROM $TBL_EXERCICES WHERE c_id = $course_id AND id=$id");
  231. $myrow = Database::fetch_array($result);
  232. echo '<img src="../img/quiz.gif" align="middle" /> <a href="../exercice/exercise_submit.php?exerciseId='.$myrow['id'].'"'.$styling.'>'.$myrow['title']."</a><br />\n";
  233. break;
  234. case 'Forum':
  235. $TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
  236. $result = Database::query("SELECT * FROM $TBL_FORUMS WHERE c_id = $course_id AND forum_id=$id");
  237. $myrow = Database::fetch_array($result);
  238. echo '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewforum.php?forum='.$myrow['forum_id'].'&amp;md5='.$myrow['md5'].'"'.$styling.'>'.$myrow['forum_name']."</a><br />\n";
  239. break;
  240. case 'Thread': //=topics
  241. //deprecated
  242. $tbl_posts = $_course['dbNameGlu'].'bb_posts';
  243. $tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text';
  244. $TBL_FORUMS = $_course['dbNameGlu'].'bb_forums';
  245. $result = Database::query(
  246. "SELECT * FROM $tbl_posts posts, $TBL_FORUMS forum WHERE forum.forum_id=posts.forum_id and post_id=$id"
  247. );
  248. $myrow = Database::fetch_array($result);
  249. // grabbing the title of the post
  250. $sql_title = "SELECT * FROM $tbl_posts_text WHERE post_id=".$myrow["post_id"];
  251. $result_title = Database::query($sql_title);
  252. $myrow_title = Database::fetch_array($result_title);
  253. echo '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewtopic.php?topic='.$myrow['topic_id'].'&amp;forum='.$myrow['forum_id'].'&amp;md5='.$myrow['md5'].'"'.$styling.'>'.$myrow_title['post_title']."</a><br />\n";
  254. break;
  255. case 'Post':
  256. //deprecated
  257. $tbl_post = Database::get_course_table(TABLE_FORUM_POST);
  258. $tbl_post_text = Database::get_course_table(TOOL_FORUM_POST_TEXT_TABLE);
  259. $sql = "SELECT * FROM $tbl_post p, $tbl_post_text t WHERE p.post_id = t.post_id AND p.post_id = $id";
  260. $result = Database::query($sql);
  261. $post = Database::fetch_object($result);
  262. echo '<img src="../img/forum.gif" align="middle" /> <a href="../phpbb/viewtopic.php?topic='.$post->topic_id.'&amp;forum='.$post->forum_id.'"'.$styling.'>'.$post->post_title."</a><br />\n";
  263. break;
  264. case 'Document':
  265. $dbTable = Database::get_course_table(TABLE_DOCUMENT);
  266. $result = Database::query("SELECT * FROM $dbTable WHERE c_id = $course_id AND id=$id");
  267. $myrow = Database::fetch_array($result);
  268. $pathname = explode('/', $myrow['path']); // making a correct name for the link
  269. $last = count($pathname) - 1; // making a correct name for the link
  270. $filename = $pathname[$last]; // making a correct name for the link
  271. $image = FileManager::choose_image($filename);
  272. $ext = explode('.', $filename);
  273. $ext = strtolower($ext[sizeof($ext) - 1]);
  274. $myrow['path'] = rawurlencode($myrow['path']);
  275. $in_frames = in_array($ext, array('htm', 'html', 'gif', 'jpg', 'jpeg', 'png'));
  276. echo '<img src="../img/'.$image.'" align="middle" /> <a href="../document/'.($in_frames ? 'showinframes.php?file=' : 'download.php?doc_url=').$myrow['path'].'"'.$styling.'>'.$filename."</a><br />\n";
  277. break;
  278. case 'Externallink':
  279. echo '<img src="../img/links.gif" align="middle" /> <a href="'.$id.'"'.$styling.'>'.$id."</a><br />\n";
  280. break;
  281. }
  282. }
  283. /**
  284. * This function is to display the added resources (lessons) in the learning path player and builder
  285. * this function is a modification of display_addedresource_link($type, $id) function
  286. * the two ids are a bit confusing, I admit, but I did not want to change Patrick's work, I was
  287. * building upon it. - Denes
  288. *
  289. * Parameters:
  290. * @param completed - if ="completed" then green presentation with checkbox
  291. * @param id_in_path - if onclick then this lesson will be considered completed, that is the unique index in the items table
  292. * @param id - that is the correspondent id in the mirror tool (like Agenda item 2)
  293. * @param type - that is the correspondent type in the mirror tool (like this is a Link item)
  294. * @param builder - if ="builder" then onclick shows in new window
  295. * @param icon - if ="icon" then the small icon will appear
  296. * if ="wrap" then wrapped settings are used (and no icon is displayed)
  297. * if ="nolink" then only the name is returned with no href and no icon (note:only in this case, the result is not displayed, but returned)
  298. * @todo this function is too long, rewrite
  299. */
  300. function display_addedresource_link_in_learnpath($type, $id, $completed, $id_in_path, $builder, $icon, $level = 0)
  301. {
  302. global $learnpath_id, $tbl_learnpath_item, $items;
  303. global $_course, $curDirPath, $_configuration, $enableDocumentParsing, $_user, $_cid;
  304. $hyperlink_target_parameter = ''; //or e.g. 'target="_blank"'
  305. $length = ((($builder == 'builder') and ($icon == 'nolink')) ? 65 : 32);
  306. if ($builder != 'builder') {
  307. $origin = 'learnpath';
  308. } //origin = learnpath in student view
  309. $linktype = $type;
  310. if (($type == 'Link _self') or ($type == 'Link _blank')) {
  311. $type = 'Link';
  312. }
  313. switch ($type) {
  314. case "Agenda":
  315. $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA, $_course['dbName']);
  316. $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE id=$id");
  317. $myrow = Database::fetch_array($result);
  318. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  319. $result = Database::query($sql);
  320. $row = Database::fetch_array($result);
  321. if ($row['title'] != '') {
  322. $myrow["title"] = $row['title'];
  323. }
  324. $desc = $row['description'];
  325. $agenda_id = $row['item_id'];
  326. echo str_repeat("&nbsp;&gt;", $level);
  327. if (($builder != 'builder') and ($icon != 'wrap')) {
  328. echo "<td>";
  329. }
  330. if ($icon != 'nolink') {
  331. if ($completed == 'completed') {
  332. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  333. } else {
  334. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  335. //echo "&nbsp;";
  336. }
  337. }
  338. if (($builder != 'builder') and ($icon != 'wrap')) {
  339. echo "</td><td>";
  340. }
  341. if ($myrow["title"] == '') {
  342. echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang(
  343. 'StepDeleted2'
  344. )."</span>";
  345. return (true);
  346. }
  347. if ($icon == 'nolink') {
  348. return (shorten($myrow["title"], $length));
  349. }
  350. if ($icon == 'icon') {
  351. echo "<img src='../img/agenda.gif' align=\"absmiddle\" alt='agenda'>";
  352. }
  353. if ($builder != 'builder') {
  354. echo "<a href=\"".api_get_self(
  355. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path\" class='$completed'>".shorten(
  356. $myrow["title"],
  357. ($length - 3 * $level)
  358. )."</a>";
  359. $items[] = api_get_self(
  360. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path";
  361. if ($desc != '') {
  362. if ($icon != 'wrap') {
  363. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten(
  364. $desc,
  365. ($length - 3 * $level)
  366. )."</div></td></tr>";
  367. } else {
  368. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten(
  369. $desc,
  370. ($length - 3 * $level)
  371. )."</div>";
  372. }
  373. }
  374. } else {
  375. echo "<a href=\"../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id\" class='$completed' target='_blank'>".shorten(
  376. $myrow["title"],
  377. ($length - 3 * $level)
  378. )."</a>";
  379. }
  380. break;
  381. case "Ad_Valvas":
  382. $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT, $_course['dbName']);
  383. $result = Database::query("SELECT * FROM $tbl_announcement WHERE id=$id");
  384. $myrow = Database::fetch_array($result);
  385. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  386. $result = Database::query($sql);
  387. $row = Database::fetch_array($result);
  388. if ($row['title'] != '') {
  389. $myrow["content"] = $row['title'];
  390. }
  391. $desc = $row['description'];
  392. $ann_id = $row['item_id'];
  393. echo str_repeat("&nbsp;&gt;", $level);
  394. // the title and the text are in the content field and we only want to display the title
  395. list($title, $text) = split('<br>', $myrow['content']);
  396. if ($title == '') {
  397. $title = $myrow['content'];
  398. }
  399. $title = $myrow['title'];
  400. $text = $myrow['content'];
  401. if (($builder != 'builder') and ($icon != 'wrap')) {
  402. echo "<td>";
  403. }
  404. if ($icon != 'nolink') {
  405. if ($completed == 'completed') {
  406. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  407. } else {
  408. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  409. //echo "&nbsp;";
  410. }
  411. }
  412. if (($builder != 'builder') and ($icon != 'wrap')) {
  413. echo "</td><td>";
  414. }
  415. if ($title == '') {
  416. $type = "Announcement";
  417. echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang(
  418. 'StepDeleted2'
  419. )."</span>";
  420. return (true);
  421. }
  422. if ($icon == 'nolink') {
  423. return (shorten($title, $length));
  424. }
  425. if ($icon == 'icon') {
  426. echo "<img src='../img/valves.gif' align=\"absmiddle\" alt='ad valvas'>";
  427. }
  428. if ($builder != 'builder') {
  429. echo "<a href=\"".api_get_self(
  430. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path\" class='$completed'>".shorten(
  431. $title,
  432. ($length - 3 * $level)
  433. )."</a>";
  434. $items[] = api_get_self(
  435. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path";
  436. if ($desc != '') {
  437. if ($icon != 'wrap') {
  438. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten(
  439. $desc,
  440. ($length - 3 * $level)
  441. )."</div></td></tr>";
  442. } else {
  443. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten(
  444. $desc,
  445. ($length - 3 * $level)
  446. )."</div>";
  447. }
  448. }
  449. } else {
  450. echo "<a href=\"../announcements/announcements.php?origin=$origin&ann_id=$ann_id\" class='$completed' target='_blank'>".shorten(
  451. $title,
  452. ($length - 3 * $level)
  453. )."</a>";
  454. }
  455. break;
  456. case "Link" :
  457. $TABLETOOLLINK = Database::get_course_table(TABLE_LINK, $_course['dbName']);
  458. $result = Database::query("SELECT * FROM $TABLETOOLLINK WHERE id=$id");
  459. $myrow = Database::fetch_array($result);
  460. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  461. $result = Database::query($sql);
  462. $row = Database::fetch_array($result);
  463. if ($row['title'] != '') {
  464. $myrow["title"] = $row['title'];
  465. }
  466. $desc = $row['description'];
  467. echo str_repeat("&nbsp;&gt;", $level);
  468. if (($builder != 'builder') and ($icon != 'wrap')) {
  469. echo "<td>";
  470. }
  471. if ($icon != 'nolink') {
  472. if ($completed == 'completed') {
  473. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  474. } else {
  475. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  476. //echo "&nbsp;";
  477. }
  478. }
  479. if (($builder != 'builder') and ($icon != 'wrap')) {
  480. echo "</td><td>";
  481. }
  482. if ($myrow["title"] == '') {
  483. echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang(
  484. 'StepDeleted2'
  485. )."</span>";
  486. return (true);
  487. }
  488. if ($icon == 'nolink') {
  489. return (shorten($myrow["title"], $length));
  490. }
  491. if ($icon == 'icon') {
  492. if ($linktype == 'Link _self') {
  493. echo "<img src='../img/links.gif' align=\"absmiddle\" alt='links'>";
  494. } else {
  495. echo "<img src='../img/link_blank.gif' align=\"absmiddle\" alt='blank links'>";
  496. }
  497. }
  498. $thelink = $myrow["url"];
  499. if ($builder != 'builder') {
  500. echo "<a href=\"".api_get_self(
  501. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path\" class='$completed'>".shorten(
  502. $myrow["title"],
  503. ($length - 3 * $level)
  504. )."</a>";
  505. $items[] = api_get_self(
  506. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path";
  507. if ($desc != '') {
  508. if ($icon != 'wrap') {
  509. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten(
  510. $desc,
  511. ($length - 3 * $level)
  512. )."</div></td></tr>";
  513. } else {
  514. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten(
  515. $desc,
  516. ($length - 3 * $level)
  517. )."</div>";
  518. }
  519. }
  520. } else {
  521. echo "<a href=\"$thelink\" class='$completed' target='_blank'>".shorten(
  522. $myrow["title"],
  523. ($length - 3 * $level)
  524. )."</a>";
  525. }
  526. break;
  527. case "Exercise":
  528. $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST, $_course['dbName']);
  529. $result = Database::query("SELECT * FROM $TBL_EXERCICES WHERE id=$id");
  530. $myrow = Database::fetch_array($result);
  531. if ($builder == 'builder') {
  532. $origin = 'builder';
  533. }
  534. //this is needed for the exercise_submit.php can delete the session info about tests
  535. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  536. $result = Database::query($sql);
  537. $row = Database::fetch_array($result);
  538. if ($row['title'] != '') {
  539. $myrow["title"] = $row['title'];
  540. }
  541. $desc = $row['description'];
  542. echo str_repeat("&nbsp;&gt;", $level);
  543. if (($builder != 'builder') and ($icon != 'wrap')) {
  544. echo "<td>";
  545. }
  546. if ($icon != 'nolink') {
  547. if ($completed == 'completed') {
  548. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  549. } else {
  550. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  551. //echo "&nbsp;";
  552. }
  553. }
  554. if (($builder != 'builder') and ($icon != 'wrap')) {
  555. echo "</td><td>";
  556. }
  557. if ($myrow["title"] == '') {
  558. echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang(
  559. 'StepDeleted2'
  560. )."</span>";
  561. return (true);
  562. }
  563. if ($icon == 'nolink') {
  564. return (shorten($myrow["title"], $length));
  565. }
  566. if ($icon == 'icon') {
  567. echo "<img src='../img/quiz.gif' align=\"absmiddle\" alt='quizz'>";
  568. }
  569. if ($builder != 'builder') {
  570. echo "<a href=\"".api_get_self(
  571. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path\" class='$completed'>".shorten(
  572. $myrow["title"],
  573. ($length - 3 * $level)
  574. )."</a>";
  575. $items[] = api_get_self(
  576. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path";
  577. if ($desc != '') {
  578. if ($icon != 'wrap') {
  579. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten(
  580. $desc,
  581. ($length - 3 * $level)
  582. )."</div></td></tr>";
  583. } else {
  584. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten(
  585. $desc,
  586. ($length - 3 * $level)
  587. )."</div>";
  588. }
  589. }
  590. } else {
  591. echo "<a href=\"../exercice/exercise_submit.php?origin=$origin&exerciseId=".$myrow["id"]."\" class='$completed' target='_blank'>".shorten(
  592. $myrow["title"],
  593. ($length - 3 * $level)
  594. )."</a>";
  595. }
  596. break;
  597. case "HotPotatoes":
  598. $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT, $_course['dbName']);
  599. $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  600. $result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE id=$id");
  601. $myrow = Database::fetch_array($result);
  602. $path = $myrow["path"];
  603. $name = GetQuizName($path, $documentPath);
  604. if ($builder == 'builder') {
  605. $origin = 'builder';
  606. }
  607. //this is needed for the exercise_submit.php can delete the session info about tests
  608. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  609. $result = Database::query($sql);
  610. $row = Database::fetch_array($result);
  611. if ($row['title'] != '') {
  612. $name = $row['title'];
  613. }
  614. $desc = $row['description'];
  615. echo str_repeat("&nbsp;&gt;", $level);
  616. if (($builder != 'builder') and ($icon != 'wrap')) {
  617. echo "<td>";
  618. }
  619. if ($icon != 'nolink') {
  620. if ($completed == 'completed') {
  621. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  622. } else {
  623. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  624. //echo "&nbsp;";
  625. }
  626. }
  627. if (($builder != 'builder') and ($icon != 'wrap')) {
  628. echo "</td><td>";
  629. }
  630. if ($name == '') {
  631. echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang(
  632. 'StepDeleted2'
  633. )."</span>";
  634. return (true);
  635. }
  636. if ($icon == 'nolink') {
  637. return (shorten($name, $length));
  638. }
  639. if ($icon == 'icon') {
  640. echo "<img src='../img/jqz.gif' align=\"absmiddle\" alt='hot potatoes'>";
  641. }
  642. $cid = $_course['official_code'];
  643. if ($builder != 'builder') {
  644. echo "<a href=\"".api_get_self(
  645. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path\" class='$completed'>".shorten(
  646. $name,
  647. ($length - 3 * $level)
  648. )."</a>";
  649. $items[] = api_get_self(
  650. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path";
  651. if ($desc != '') {
  652. if ($icon != 'wrap') {
  653. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten(
  654. $desc,
  655. ($length - 3 * $level)
  656. )."</div></td></tr>";
  657. } else {
  658. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten(
  659. $desc,
  660. ($length - 3 * $level)
  661. )."</div>";
  662. }
  663. }
  664. } else {
  665. echo "&nbsp;<a href=\"../exercice/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id']."\" class='$completed' target='_blank'>".shorten(
  666. $name,
  667. ($length - 3 * $level)
  668. )."</a>";
  669. }
  670. break;
  671. case "Forum":
  672. $TBL_FORUMS = Database::get_course_table(TABLE_FORUM, $_course['dbName']);
  673. $result = Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id");
  674. $myrow = Database::fetch_array($result);
  675. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  676. $result = Database::query($sql);
  677. $row = Database::fetch_array($result);
  678. if ($row['title'] != '') {
  679. $myrow["forum_name"] = $row['title'];
  680. }
  681. $desc = $row['description'];
  682. echo str_repeat("&nbsp;&gt;", $level);
  683. if (($builder != 'builder') and ($icon != 'wrap')) {
  684. echo "<td>";
  685. }
  686. if ($icon != 'nolink') {
  687. if ($completed == 'completed') {
  688. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  689. } else {
  690. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  691. //echo "&nbsp;";
  692. }
  693. }
  694. if (($builder != 'builder') and ($icon != 'wrap')) {
  695. echo "</td><td>";
  696. }
  697. if ($myrow["forum_name"] == '') {
  698. $type = "Forum";
  699. echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang(
  700. 'StepDeleted2'
  701. )."</span>";
  702. return (true);
  703. }
  704. if ($icon == 'nolink') {
  705. return (shorten($myrow["forum_name"], $length));
  706. }
  707. if ($icon == 'icon') {
  708. echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>";
  709. }
  710. $forumparameters = "forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
  711. if ($builder != 'builder') {
  712. echo "<a href=\"".api_get_self(
  713. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path\" class='$completed'>".shorten(
  714. $myrow["forum_name"],
  715. ($length - 3 * $level)
  716. )."</a>";
  717. $items[] = api_get_self(
  718. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path";
  719. if ($desc != '') {
  720. if ($icon != 'wrap') {
  721. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten(
  722. $desc,
  723. ($length - 3 * $level)
  724. )."</div></td></tr>";
  725. } else {
  726. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten(
  727. $desc,
  728. ($length - 3 * $level)
  729. )."</div>";
  730. }
  731. }
  732. } else {
  733. echo "<a href=\"../phpbb/viewforum.php?$forumparameters\" class='$completed' target='_blank'>".shorten(
  734. $myrow["forum_name"],
  735. ($length - 3 * $level)
  736. )."</a>";
  737. }
  738. break;
  739. case "Thread": //forum post
  740. //deprecated
  741. $tbl_topics = $_course['dbNameGlu'].'bb_topics';
  742. $tbl_posts = $_course['dbNameGlu'].'bb_posts';
  743. $TBL_FORUMS = $_course['dbNameGlu']."bb_forums";
  744. $sql = "SELECT * FROM $tbl_topics where topic_id=$id";
  745. $result = Database::query($sql);
  746. $myrow = Database::fetch_array($result);
  747. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  748. $result = Database::query($sql);
  749. $row = Database::fetch_array($result);
  750. if ($row['title'] != '') {
  751. $myrow["topic_title"] = $row['title'];
  752. }
  753. $desc = $row['description'];
  754. echo str_repeat("&nbsp;&gt;", $level);
  755. if (($builder != 'builder') and ($icon != 'wrap')) {
  756. echo "<td>";
  757. }
  758. if ($icon != 'nolink') {
  759. if ($completed == 'completed') {
  760. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  761. } else {
  762. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  763. //echo "&nbsp;";
  764. }
  765. }
  766. if (($builder != 'builder') and ($icon != 'wrap')) {
  767. echo "</td><td>";
  768. }
  769. if ($myrow["topic_title"] == '') {
  770. $type = "Forum Post";
  771. echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang(
  772. 'StepDeleted2'
  773. )."</span>";
  774. return (true);
  775. }
  776. if ($icon == 'nolink') {
  777. return (shorten($myrow["topic_title"], $length));
  778. }
  779. if ($icon == 'icon') {
  780. echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>";
  781. }
  782. if ($builder != 'builder') {
  783. echo "<a href=\"".api_get_self(
  784. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path\" class='$completed'>".shorten(
  785. $myrow["topic_title"],
  786. ($length - 3 * $level)
  787. )."</a>";
  788. $items[] = api_get_self(
  789. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path";
  790. if ($desc != '') {
  791. if ($icon != 'wrap') {
  792. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten(
  793. $desc,
  794. ($length - 3 * $level)
  795. )."</div></td></tr>";
  796. } else {
  797. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten(
  798. $desc,
  799. ($length - 3 * $level)
  800. )."</div>";
  801. }
  802. }
  803. } else {
  804. echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten(
  805. $myrow["topic_title"],
  806. ($length - 3 * $level)
  807. )."</a>";
  808. }
  809. break;
  810. case "Post":
  811. //deprecated
  812. $tbl_posts = $_course['dbNameGlu'].'bb_posts';
  813. $tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text';
  814. $TBL_FORUMS = $_course['dbNameGlu']."bb_forums";
  815. $result = Database::query("SELECT * FROM $tbl_posts where post_id=$id");
  816. $myrow = Database::fetch_array($result);
  817. // grabbing the title of the post
  818. $sql_titel = "SELECT * FROM $tbl_posts_text WHERE post_id=".$myrow["post_id"];
  819. $result_titel = Database::query($sql_titel);
  820. $myrow_titel = Database::fetch_array($result_titel);
  821. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  822. $result = Database::query($sql);
  823. $row = Database::fetch_array($result);
  824. if ($row['title'] != '') {
  825. $myrow_titel["post_title"] = $row['title'];
  826. }
  827. $desc = $row['description'];
  828. echo str_repeat("&nbsp;&gt;", $level);
  829. $posternom = $myrow['nom'];
  830. $posterprenom = $myrow['prenom'];
  831. $posttime = $myrow['post_time'];
  832. $posttext = $myrow_titel['post_text'];
  833. $posttitle = $myrow_titel['post_title'];
  834. $posttext = str_replace('"', "'", $posttext);
  835. if (($builder != 'builder') and ($icon != 'wrap')) {
  836. echo "<td>";
  837. }
  838. if ($icon != 'nolink') {
  839. if ($completed == 'completed') {
  840. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  841. } else {
  842. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  843. //echo "&nbsp;";
  844. }
  845. }
  846. if (($builder != 'builder') and ($icon != 'wrap')) {
  847. echo "</td><td>";
  848. }
  849. if ($myrow_titel["post_title"] == '') {
  850. $type = "Forum";
  851. echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang(
  852. 'StepDeleted2'
  853. )."</span>";
  854. return (true);
  855. }
  856. if ($icon == 'nolink') {
  857. return (shorten($myrow_titel["post_title"], $length));
  858. }
  859. if ($icon == 'icon') {
  860. echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>";
  861. }
  862. if ($builder != 'builder') {
  863. echo "<a href=\"".api_get_self(
  864. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path\" class='$completed'>".shorten(
  865. $myrow_titel["post_title"],
  866. ($length - 3 * $level)
  867. )."</a>";
  868. $items[] = api_get_self(
  869. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path";
  870. if ($desc != '') {
  871. if ($icon != 'wrap') {
  872. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten(
  873. $desc,
  874. ($length - 3 * $level)
  875. )."</div></td></tr>";
  876. } else {
  877. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten(
  878. $desc,
  879. ($length - 3 * $level)
  880. )."</div>";
  881. }
  882. }
  883. } else {
  884. echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten(
  885. $myrow_titel["post_title"],
  886. ($length - 3 * $level)
  887. )."</a>";
  888. }
  889. break;
  890. case "Document":
  891. $dbTable = Database::get_course_table(TABLE_DOCUMENT, $_course['dbName']);
  892. $result = Database::query("SELECT * FROM $dbTable WHERE id=$id");
  893. $myrow = Database::fetch_array($result);
  894. $pathname = explode("/", $myrow["path"]); // making a correct name for the link
  895. $last = count($pathname) - 1; // making a correct name for the link
  896. $filename = $pathname[$last]; // making a correct name for the link
  897. if (($builder != 'builder') and ($icon != 'wrap')) {
  898. echo "<td>";
  899. }
  900. echo str_repeat("&nbsp;&gt;", $level);
  901. if ($icon != 'nolink') {
  902. if ($completed == 'completed') {
  903. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  904. } else {
  905. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  906. //echo "&nbsp;";
  907. }
  908. }
  909. if (($builder != 'builder') and ($icon != 'wrap')) {
  910. echo "</td><td>";
  911. }
  912. $image = FileManager::choose_image($filename);
  913. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  914. $result = Database::query($sql);
  915. $row = Database::fetch_array($result);
  916. if ($row['title'] != '') {
  917. $filename = $row['title'];
  918. }
  919. $desc = $row['description'];
  920. if (($myrow["path"] == '') and ($filename == '')) {
  921. echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang(
  922. 'StepDeleted2'
  923. )."</span>";
  924. return (true);
  925. }
  926. if ($icon == 'nolink') {
  927. return (shorten($filename, $length));
  928. }
  929. if ($icon == 'icon') {
  930. echo "<img src='../img/$image' align=\"absmiddle\" alt='$image'>";
  931. }
  932. if ($builder != 'builder') {
  933. echo "<a href=\"".api_get_self(
  934. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path\" class='$completed'>".shorten(
  935. $filename,
  936. ($length - 3 * $level)
  937. )."</a>";
  938. if ($desc != '') {
  939. if ($icon != 'wrap') {
  940. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten(
  941. $desc,
  942. ($length - 3 * $level)
  943. )."</div></td></tr>";
  944. } else {
  945. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten(
  946. $desc,
  947. ($length - 3 * $level)
  948. )."</div>";
  949. }
  950. }
  951. $items[] = api_get_self(
  952. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path";
  953. } else {
  954. $enableDocumentParsing = 'yes';
  955. if (!$enableDocumentParsing) { //this is the solution for the non-parsing version in the builder
  956. $file = urlencode($myrow["path"]);
  957. echo "<a href='../document/showinframes.php?file=$file' class='$completed' $hyperlink_target_parameter>".shorten(
  958. $filename,
  959. ($length - 3 * $level)
  960. )."</a>";
  961. } else {
  962. echo "<a href=\"../document/download.php?doc_url=".$myrow["path"]."\" class='$completed' $hyperlink_target_parameter>".shorten(
  963. $filename,
  964. ($length - 3 * $level)
  965. )."</a>";
  966. }
  967. }
  968. break;
  969. case "Assignments":
  970. $name = get_lang('Assignments');
  971. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  972. $result = Database::query($sql);
  973. $row = Database::fetch_array($result);
  974. if ($row['title'] != '') {
  975. $name = $row['title'];
  976. }
  977. $desc = $row['description'];
  978. echo str_repeat("&nbsp;&gt;", $level);
  979. if (($builder != 'builder') and ($icon != 'wrap')) {
  980. echo "<td>";
  981. }
  982. if ($icon != 'nolink') {
  983. if ($completed == 'completed') {
  984. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  985. } else {
  986. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  987. //echo "&nbsp;";
  988. }
  989. }
  990. if (($builder != 'builder') and ($icon != 'wrap')) {
  991. echo "</td><td>";
  992. }
  993. if ($name == '') {
  994. echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang(
  995. 'StepDeleted2'
  996. )."</span>";
  997. return (true);
  998. }
  999. if ($icon == 'nolink') {
  1000. return (shorten($name, $length));
  1001. }
  1002. if ($icon == 'icon') {
  1003. echo "<img src='../img/works.gif' align=\"absmiddle\">";
  1004. }
  1005. if ($builder != 'builder') {
  1006. echo "<a href=\"".api_get_self(
  1007. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path\" class='$completed'>".shorten(
  1008. $name,
  1009. ($length - 3 * $level)
  1010. )."</a>";
  1011. $items[] = api_get_self(
  1012. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path";
  1013. if ($desc != '') {
  1014. if ($icon != 'wrap') {
  1015. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten(
  1016. $desc,
  1017. ($length - 3 * $level)
  1018. )."</div></td></tr>";
  1019. } else {
  1020. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten(
  1021. $desc,
  1022. ($length - 3 * $level)
  1023. )."</div>";
  1024. }
  1025. }
  1026. } else {
  1027. echo "<a href=\"../work/work.php\" class='$completed' target='_blank'>".shorten(
  1028. $name,
  1029. ($length - 3 * $level)
  1030. )."</a>";
  1031. }
  1032. break;
  1033. case "Dropbox":
  1034. $name = get_lang('Dropbox');
  1035. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  1036. $result = Database::query($sql);
  1037. $row = Database::fetch_array($result);
  1038. if ($row['title'] != '') {
  1039. $name = $row['title'];
  1040. }
  1041. $desc = $row['description'];
  1042. echo str_repeat("&nbsp;&gt;", $level);
  1043. if (($builder != 'builder') and ($icon != 'wrap')) {
  1044. echo "<td>";
  1045. }
  1046. if ($icon != 'nolink') {
  1047. if ($completed == 'completed') {
  1048. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  1049. } else {
  1050. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  1051. //echo "&nbsp;";
  1052. }
  1053. }
  1054. if (($builder != 'builder') and ($icon != 'wrap')) {
  1055. echo "</td><td>";
  1056. }
  1057. if ($name == '') {
  1058. echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang(
  1059. 'StepDeleted2'
  1060. )."</span>";
  1061. return (true);
  1062. }
  1063. if ($icon == 'nolink') {
  1064. return (shorten($name, $length));
  1065. }
  1066. if ($icon == 'icon') {
  1067. echo "<img src='../img/dropbox.gif' align=\"absmiddle\">";
  1068. }
  1069. if ($builder != 'builder') {
  1070. echo "<a href=\"".api_get_self(
  1071. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path\" class='$completed'>".shorten(
  1072. $name,
  1073. ($length - 3 * $level)
  1074. )."</a>";
  1075. $items[] = api_get_self(
  1076. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path";
  1077. if ($desc != '') {
  1078. if ($icon != 'wrap') {
  1079. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten(
  1080. $desc,
  1081. ($length - 3 * $level)
  1082. )."</div></td></tr>";
  1083. } else {
  1084. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten(
  1085. $desc,
  1086. ($length - 3 * $level)
  1087. )."</div>";
  1088. }
  1089. }
  1090. } else {
  1091. echo "<a href=\"../dropbox/index.php\" class='$completed' target='_blank'>".shorten(
  1092. $name,
  1093. ($length - 3 * $level)
  1094. )."</a>";
  1095. }
  1096. break;
  1097. case "Introduction_text":
  1098. $name = get_lang('IntroductionText');
  1099. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  1100. $result = Database::query($sql);
  1101. $row = Database::fetch_array($result);
  1102. if ($row['title'] != '') {
  1103. $name = $row['title'];
  1104. }
  1105. $desc = $row['description'];
  1106. echo str_repeat("&nbsp;&gt;", $level);
  1107. if (($builder != 'builder') and ($icon != 'wrap')) {
  1108. echo "<td>";
  1109. }
  1110. if ($icon != 'nolink') {
  1111. if ($completed == 'completed') {
  1112. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  1113. } else {
  1114. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  1115. //echo "&nbsp;";
  1116. }
  1117. }
  1118. if (($builder != 'builder') and ($icon != 'wrap')) {
  1119. echo "</td><td>";
  1120. }
  1121. if ($name == '') {
  1122. echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang(
  1123. 'StepDeleted2'
  1124. )."</span>";
  1125. return (true);
  1126. }
  1127. if ($icon == 'nolink') {
  1128. return (shorten($name, $length));
  1129. }
  1130. if ($icon == 'icon') {
  1131. echo "<img src='../img/introduction.gif' align=\"absmiddle\" alt='introduction'>";
  1132. }
  1133. if ($builder != 'builder') {
  1134. echo "<a href=\"".api_get_self(
  1135. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path\" class='$completed'>".shorten(
  1136. $name,
  1137. ($length - 3 * $level)
  1138. )."</a>";
  1139. $items[] = api_get_self(
  1140. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path";
  1141. if ($desc != '') {
  1142. if ($icon != 'wrap') {
  1143. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten(
  1144. $desc,
  1145. ($length - 3 * $level)
  1146. )."</div></td></tr>";
  1147. } else {
  1148. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten(
  1149. $desc,
  1150. ($length - 3 * $level)
  1151. )."</div>";
  1152. }
  1153. }
  1154. } else {
  1155. $s = api_get_path(WEB_COURSE_PATH)."$_cid/index.php?intro_cmdEdit=1";
  1156. echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name, ($length - 3 * $level))."</a>";
  1157. }
  1158. break;
  1159. case "Course_description":
  1160. $name = get_lang('CourseDescription');
  1161. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  1162. $result = Database::query($sql);
  1163. $row = Database::fetch_array($result);
  1164. if ($row['title'] != '') {
  1165. $name = $row['title'];
  1166. }
  1167. $desc = $row['description'];
  1168. echo str_repeat("&nbsp;&gt;", $level);
  1169. if (($builder != 'builder') and ($icon != 'wrap')) {
  1170. echo "<td>";
  1171. }
  1172. if ($icon != 'nolink') {
  1173. if ($completed == 'completed') {
  1174. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  1175. } else {
  1176. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  1177. //echo "&nbsp;";
  1178. }
  1179. }
  1180. if (($builder != 'builder') and ($icon != 'wrap')) {
  1181. echo "</td><td>";
  1182. }
  1183. if ($name == '') {
  1184. echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang(
  1185. 'StepDeleted2'
  1186. )."</span>";
  1187. return (true);
  1188. }
  1189. if ($icon == 'nolink') {
  1190. return (shorten($name, $length));
  1191. }
  1192. if ($icon == 'icon') {
  1193. echo "<img src='../img/info.gif' align=\"absmiddle\" alt='info'>";
  1194. }
  1195. if ($builder != 'builder') {
  1196. echo "<a href=\"".api_get_self(
  1197. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path\" class='$completed'>".shorten(
  1198. $name,
  1199. ($length - 3 * $level)
  1200. )."</a>";
  1201. $items[] = api_get_self(
  1202. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path";
  1203. if ($desc != '') {
  1204. if ($icon != 'wrap') {
  1205. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten(
  1206. $desc,
  1207. ($length - 3 * $level)
  1208. )."</div></td></tr>";
  1209. } else {
  1210. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten(
  1211. $desc,
  1212. ($length - 3 * $level)
  1213. )."</div>";
  1214. }
  1215. }
  1216. } else {
  1217. $s = api_get_path(WEB_CODE_PATH)."course_description";
  1218. echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name, ($length - 3 * $level))."</a>";
  1219. }
  1220. break;
  1221. case "Groups":
  1222. $name = get_lang('Groups');
  1223. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  1224. $result = Database::query($sql);
  1225. $row = Database::fetch_array($result);
  1226. if ($row['title'] != '') {
  1227. $name = $row['title'];
  1228. }
  1229. $desc = $row['description'];
  1230. echo str_repeat("&nbsp;&gt;", $level);
  1231. if (($builder != 'builder') and ($icon != 'wrap')) {
  1232. echo "<td>";
  1233. }
  1234. if ($icon != 'nolink') {
  1235. if ($completed == 'completed') {
  1236. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  1237. } else {
  1238. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  1239. //echo "&nbsp;";
  1240. }
  1241. }
  1242. if (($builder != 'builder') and ($icon != 'wrap')) {
  1243. echo "</td><td>";
  1244. }
  1245. if ($name == '') {
  1246. echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang(
  1247. 'StepDeleted2'
  1248. )."</span>";
  1249. return (true);
  1250. }
  1251. if ($icon == 'nolink') {
  1252. return (shorten($name, $length));
  1253. }
  1254. if ($icon == 'icon') {
  1255. echo "<img src='../img/group.gif' align=\"absmiddle\" alt='group'>";
  1256. }
  1257. if ($builder != 'builder') {
  1258. echo "<a href=\"".api_get_self(
  1259. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path\" class='$completed'>".shorten(
  1260. $name,
  1261. ($length - 3 * $level)
  1262. )."</a>";
  1263. $items[] = api_get_self(
  1264. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path";
  1265. if ($desc != '') {
  1266. if ($icon != 'wrap') {
  1267. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten(
  1268. $desc,
  1269. ($length - 3 * $level)
  1270. )."</div></td></tr>";
  1271. } else {
  1272. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten(
  1273. $desc,
  1274. ($length - 3 * $level)
  1275. )."</div>";
  1276. }
  1277. }
  1278. } else {
  1279. echo "<a href=\"../group/group.php?origin=$origin\" class='$completed' target='_blank'>".shorten(
  1280. $name,
  1281. ($length - 3 * $level)
  1282. )."</a>";
  1283. }
  1284. break;
  1285. case "Users":
  1286. $name = get_lang('Users');
  1287. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  1288. $result = Database::query($sql);
  1289. $row = Database::fetch_array($result);
  1290. if ($row['title'] != '') {
  1291. $name = $row['title'];
  1292. }
  1293. $desc = $row['description'];
  1294. echo str_repeat("&nbsp;&gt;", $level);
  1295. if (($builder != 'builder') and ($icon != 'wrap')) {
  1296. echo "<td>";
  1297. }
  1298. if ($icon != 'nolink') {
  1299. if ($completed == 'completed') {
  1300. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  1301. } else {
  1302. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  1303. //echo "&nbsp;";
  1304. }
  1305. }
  1306. if (($builder != 'builder') and ($icon != 'wrap')) {
  1307. echo "</td><td>";
  1308. }
  1309. if ($name == '') {
  1310. echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang(
  1311. 'StepDeleted2'
  1312. )."</span>";
  1313. return (true);
  1314. }
  1315. if ($icon == 'nolink') {
  1316. return (shorten($name, $length));
  1317. }
  1318. if ($icon == 'icon') {
  1319. echo "<img src='../img/members.gif' align=\"absmiddle\" alt='members'>";
  1320. }
  1321. if ($builder != 'builder') {
  1322. echo "<a href=\"".api_get_self(
  1323. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path\" class='$completed'>".shorten(
  1324. $name,
  1325. ($length - 3 * $level)
  1326. )."</a>";
  1327. $items[] = api_get_self(
  1328. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path";
  1329. if ($desc != '') {
  1330. if ($icon != 'wrap') {
  1331. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten(
  1332. $desc,
  1333. ($length - 3 * $level)
  1334. )."</div></td></tr>";
  1335. } else {
  1336. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten(
  1337. $desc,
  1338. ($length - 3 * $level)
  1339. )."</div>";
  1340. }
  1341. }
  1342. } else {
  1343. echo "<a href=\"../user/user.php?origin=$origin\" class='$completed' target='_blank'>".shorten(
  1344. $name,
  1345. ($length - 3 * $level)
  1346. )."</a>";
  1347. }
  1348. break;
  1349. }
  1350. //end huge switch-statement
  1351. }
  1352. /**
  1353. * This function is to create and return a link to the added resources (lessons).
  1354. * It returns the same thing as display_addedresource_link_in_learnpath() but doesn't display
  1355. * anything.
  1356. *
  1357. * Parameters:
  1358. * @param type - that is the correspondent type in the mirror tool (like this is a Link item)
  1359. * @param id - that is the correspondent id in the mirror tool (like Agenda item 2)
  1360. * @param id_in_path - the unique index in the items table
  1361. */
  1362. function get_addedresource_link_in_learnpath($type, $id, $id_in_path)
  1363. {
  1364. global $_course, $learnpath_id, $tbl_learnpath_item, $items;
  1365. global $curDirPath, $_configuration, $enableDocumentParsing, $_user, $_cid;
  1366. $hyperlink_target_parameter = ""; //or e.g. target='_blank'
  1367. $builder = 'player';
  1368. $origin = 'learnpath';
  1369. $linktype = $type;
  1370. if (($type == "Link _self") or ($type == "Link _blank")) {
  1371. $type = "Link";
  1372. }
  1373. $link = '';
  1374. switch ($type) {
  1375. case "Agenda":
  1376. $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA, $_course['dbName']);
  1377. ;
  1378. $result = Database::query("SELECT * FROM $TABLEAGENDA WHERE id=$id");
  1379. $myrow = Database::fetch_array($result);
  1380. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  1381. $result = Database::query($sql);
  1382. $row = Database::fetch_array($result);
  1383. if ($row['title'] != '') {
  1384. $myrow["title"] = $row['title'];
  1385. }
  1386. $desc = $row['description'];
  1387. $agenda_id = $row['item_id'];
  1388. if ($builder != 'builder') {
  1389. $link .= api_get_self(
  1390. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path";
  1391. } else {
  1392. $link .= "../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id";
  1393. }
  1394. break;
  1395. case "Ad_Valvas":
  1396. $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
  1397. $result = Database::query("SELECT * FROM $tbl_announcement WHERE id=$id");
  1398. $myrow = Database::fetch_array($result);
  1399. if ($builder != 'builder') {
  1400. $link .= api_get_self(
  1401. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$id#$id_in_path";
  1402. } else {
  1403. $link .= "../announcements/announcements.php?origin=$origin&ann_id=$id";
  1404. }
  1405. break;
  1406. case "Link" :
  1407. $TABLETOOLLINK = Database::get_course_table(TABLE_LINK, $_course['dbName']);
  1408. $result = Database::query("SELECT * FROM $TABLETOOLLINK WHERE id=$id");
  1409. $myrow = Database::fetch_array($result);
  1410. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  1411. $result = Database::query($sql);
  1412. $row = Database::fetch_array($result);
  1413. $thelink = $myrow["url"];
  1414. if ($builder != 'builder') {
  1415. $link .= api_get_self(
  1416. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path";
  1417. } else {
  1418. $link .= $thelink;
  1419. }
  1420. break;
  1421. case "Exercise":
  1422. $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST, $_course['dbName']);
  1423. $result = Database::query("SELECT * FROM $TBL_EXERCICES WHERE id=$id");
  1424. $myrow = Database::fetch_array($result);
  1425. if ($builder == 'builder') {
  1426. $origin = 'builder';
  1427. }
  1428. //this is needed for the exercise_submit.php can delete the session info about tests
  1429. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  1430. $result = Database::query($sql);
  1431. $row = Database::fetch_array($result);
  1432. if ($row['title'] != '') {
  1433. $myrow["title"] = $row['title'];
  1434. }
  1435. if ($builder != 'builder') {
  1436. $link .= api_get_self(
  1437. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path";
  1438. } else {
  1439. $link .= "../exercice/exercise_submit.php?origin=$origin&exerciseId=".$myrow["id"];
  1440. }
  1441. break;
  1442. case "HotPotatoes":
  1443. $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT, $_course['dbName']);
  1444. $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  1445. $result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE id=$id");
  1446. $myrow = Database::fetch_array($result);
  1447. $path = $myrow["path"];
  1448. $name = GetQuizName($path, $documentPath);
  1449. if ($builder == 'builder') {
  1450. $origin = 'builder';
  1451. }
  1452. $cid = $_course['official_code'];
  1453. if ($builder != 'builder') {
  1454. $link .= api_get_self(
  1455. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path";
  1456. } else {
  1457. $link .= "../exercice/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id']."";
  1458. }
  1459. break;
  1460. case "Forum":
  1461. //deprecated
  1462. $TBL_FORUMS = Database::get_course_table(TABLE_FORUM, $_course['dbName']);
  1463. $result = Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id");
  1464. $myrow = Database::fetch_array($result);
  1465. if ($builder == 'builder') {
  1466. $origin = 'builder';
  1467. }
  1468. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  1469. $result = Database::query($sql);
  1470. $row = Database::fetch_array($result);
  1471. if ($row['title'] != '') {
  1472. $myrow["forum_name"] = $row['title'];
  1473. }
  1474. if ($myrow["forum_name"] == '') {
  1475. $type = "Forum";
  1476. }
  1477. $forumparameters = "forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
  1478. if ($builder != 'builder') {
  1479. $link .= api_get_self(
  1480. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path";
  1481. } else {
  1482. $link .= "../phpbb/viewforum.php?$forumparameters";
  1483. }
  1484. break;
  1485. case "Thread": //forum post
  1486. //deprecated
  1487. $tbl_topics = $_course['dbNameGlu'].'bb_topics';
  1488. $tbl_posts = $_course['dbNameGlu'].'bb_posts';
  1489. $TBL_FORUMS = $_course['dbNameGlu']."bb_forums";
  1490. $sql = "SELECT * FROM $tbl_topics where topic_id=$id";
  1491. $result = Database::query($sql);
  1492. $myrow = Database::fetch_array($result);
  1493. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  1494. $result = Database::query($sql);
  1495. $row = Database::fetch_array($result);
  1496. if ($builder != 'builder') {
  1497. $link .= api_get_self(
  1498. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path";
  1499. } else {
  1500. $link .= "../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
  1501. }
  1502. break;
  1503. case "Post":
  1504. /* todo REVIEW THIS SECTION - NOT USING VALID TABLES ANYMORE
  1505. $tbl_posts = $_course['dbNameGlu'].'bb_posts';
  1506. $tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text';
  1507. $TBL_FORUMS = $_course['dbNameGlu']."bb_forums";
  1508. $result= Database::query("SELECT * FROM $tbl_posts where post_id=$id");
  1509. $myrow=Database::fetch_array($result);
  1510. // grabbing the title of the post
  1511. $sql_titel="SELECT * FROM $tbl_posts_text WHERE post_id=".$myrow["post_id"];
  1512. $result_titel=Database::query($sql_titel);
  1513. $myrow_titel=Database::fetch_array($result_titel);
  1514. $sql="select * from $tbl_learnpath_item where id=$id_in_path";
  1515. $result=Database::query($sql); $row=Database::fetch_array($result);
  1516. if ($row['title'] != '') { $myrow_titel["post_title"]=$row['title']; }
  1517. $desc=$row['description'];
  1518. $link .= str_repeat("&nbsp;&gt;",$level);
  1519. $posternom=$myrow['nom']; $posterprenom=$myrow['prenom'];
  1520. $posttime=$myrow['post_time']; $posttext=$myrow_titel['post_text'];
  1521. $posttitle=$myrow_titel['post_title'];
  1522. $posttext = str_replace('"',"'",$posttext);
  1523. if ($builder != 'builder')
  1524. {
  1525. $link .= api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path";
  1526. }
  1527. else
  1528. {
  1529. $link .= "../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
  1530. }
  1531. */
  1532. break;
  1533. case "Document":
  1534. $dbTable = Database::get_course_table(TABLE_DOCUMENT, $_course['dbName']);
  1535. $result = Database::query("SELECT * FROM $dbTable WHERE id=$id", __FILE__, __LINE);
  1536. $myrow = Database::fetch_array($result);
  1537. $pathname = explode("/", $myrow["path"]); // making a correct name for the link
  1538. $last = count($pathname) - 1; // making a correct name for the link
  1539. $filename = $pathname[$last]; // making a correct name for the link
  1540. $sql = "select * from $tbl_learnpath_item where id=$id_in_path";
  1541. $result = Database::query($sql);
  1542. $row = Database::fetch_array($result);
  1543. if ($builder != 'builder') {
  1544. $link .= api_get_self(
  1545. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path";
  1546. } else {
  1547. $enableDocumentParsing = 'yes';
  1548. if (!$enableDocumentParsing) { //this is the solution for the non-parsing version in the builder
  1549. $file = urlencode($myrow["path"]);
  1550. $link .= "../document/showinframes.php?file=$file";
  1551. } else {
  1552. $link .= "../document/download.php?doc_url=".$myrow["path"];
  1553. }
  1554. }
  1555. break;
  1556. case "Assignments":
  1557. if ($builder != 'builder') {
  1558. $link .= api_get_self(
  1559. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path";
  1560. } else {
  1561. $link .= "../work/work.php";
  1562. }
  1563. break;
  1564. case "Dropbox":
  1565. if ($builder != 'builder') {
  1566. $link .= api_get_self(
  1567. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path";
  1568. } else {
  1569. $link .= "../dropbox/index.php";
  1570. }
  1571. break;
  1572. case "Introduction_text":
  1573. if ($builder != 'builder') {
  1574. $link .= api_get_self(
  1575. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path";
  1576. } else {
  1577. $s = api_get_path(WEB_COURSE_PATH)."$_cid/index.php?intro_cmdEdit=1";
  1578. $link .= $s;
  1579. }
  1580. break;
  1581. case "Course_description":
  1582. if ($builder != 'builder') {
  1583. $link .= api_get_self(
  1584. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path";
  1585. } else {
  1586. $s = api_get_path(WEB_CODE_PATH)."course_description";
  1587. $link .= $s;
  1588. }
  1589. break;
  1590. case "Groups":
  1591. if ($builder != 'builder') {
  1592. $link .= api_get_self(
  1593. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path";
  1594. } else {
  1595. $link .= "../group/group.php?origin=$origin";
  1596. }
  1597. break;
  1598. case "Users":
  1599. if ($builder != 'builder') {
  1600. $link .= api_get_self(
  1601. )."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path";
  1602. } else {
  1603. $link .= "../user/user.php?origin=$origin";
  1604. }
  1605. break;
  1606. }
  1607. //end huge switch-statement
  1608. return $link;
  1609. }
  1610. /**
  1611. * This function is to remove an resource item from the array
  1612. */
  1613. function remove_resource($resource_key)
  1614. {
  1615. $addedresource = $_SESSION['addedresource'];
  1616. $addedresourceid = $_SESSION['addedresourceid'];
  1617. unset($addedresource[$resource_key]);
  1618. unset($addedresourceid[$resource_key]);
  1619. $_SESSION['addedresource'] = $addedresource;
  1620. $_SESSION['addedresourceid'] = $addedresourceid;
  1621. }
  1622. /**
  1623. * This function is to show the button "click to add resource" on the tool page
  1624. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  1625. */
  1626. function show_addresource_button($additionalparameters = '')
  1627. {
  1628. global $charset;
  1629. echo '<label for="addresources"><img src="../img/attachment.gif" /></label><input class="link_alike" type="submit" name="addresources" id="addresources" value="'.api_htmlentities(
  1630. get_lang('Attachment'),
  1631. ENT_QUOTES,
  1632. $charset
  1633. ).'" '.$additionalparameters.' />';
  1634. }
  1635. /**
  1636. * this function is to delete ONE specific resource that were added to a specific item
  1637. * Deprecated
  1638. */
  1639. /*
  1640. function delete_one_added_resource($source_type, $source_id, $resource_type, $resource_id)
  1641. {
  1642. //echo "delete_one_added_resource";
  1643. global $_course;
  1644. $TABLERESOURCE = $_course['dbNameGlu']."resource";
  1645. $sql="DELETE FROM $TABLERESOURCE WHERE source_type='$source_type' and source_id='$source_id' and resource_type='$resource_type' and resource_id='$resource_id'";
  1646. Database::query($sql);
  1647. }
  1648. */
  1649. /**
  1650. * this function is to delete the resources that were added to a specific item
  1651. */
  1652. function delete_added_resource($type, $id)
  1653. {
  1654. global $_course;
  1655. $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES, $_course['dbName']);
  1656. $sql = "DELETE FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'";
  1657. Database::query($sql);
  1658. }
  1659. /**
  1660. * this function is te delete all resources of a specific type (only used in announcements -- delete all)
  1661. * Author : Frederik Vermeire <frederik.vermeire@pandora.be>
  1662. */
  1663. function delete_all_resources_type($type)
  1664. {
  1665. global $_course;
  1666. $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES, $_course['dbName']);
  1667. $sql = "DELETE FROM $TABLERESOURCE WHERE source_type='$type'";
  1668. Database::query($sql);
  1669. }
  1670. /**
  1671. * this function checks wether there are added resources or not
  1672. */
  1673. function check_added_resources($type, $id)
  1674. {
  1675. global $_course, $origin;
  1676. $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES, $_course['dbName']);
  1677. $sql = "SELECT * FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'";
  1678. $result = Database::query($sql);
  1679. $number_added = Database::num_rows($result);
  1680. if ($number_added <> 0) {
  1681. return true;
  1682. } else {
  1683. return false;
  1684. }
  1685. }
  1686. /**
  1687. * this function is to load the resources that were added to a specific item
  1688. * into the session variables
  1689. */
  1690. function edit_added_resources($type, $id)
  1691. {
  1692. global $_course;
  1693. $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES, $_course['dbName']);
  1694. $sql = "SELECT * FROM $TABLERESOURCE WHERE source_type='$type' and source_id=$id";
  1695. $result = Database::query($sql);
  1696. while ($row = Database::fetch_array($result)) {
  1697. $addedresource[] = $row["resource_type"];
  1698. $addedresourceid[] = $row["resource_id"];
  1699. }
  1700. $_SESSION['addedresource'] = $addedresource;
  1701. $_SESSION['addedresourceid'] = $addedresourceid;
  1702. }
  1703. /**
  1704. * this function is store the modified resources
  1705. * first we delete all the added resources in the database,
  1706. * then we add all the resources from the session object.
  1707. */
  1708. function update_added_resources($type, $id)
  1709. {
  1710. global $_course;
  1711. $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES, $_course['dbName']);
  1712. // delete all the added resources for this item in the database;
  1713. $sql = "DELETE FROM $TABLERESOURCE WHERE source_type='$type' AND source_id='$id'";
  1714. //echo $sql;
  1715. Database::query($sql);
  1716. // store the resources from the session into the database
  1717. store_resources($type, $id);
  1718. //delete_added_resource_($type, $id);
  1719. unset_session_resources();
  1720. }
  1721. /**
  1722. * this function is to display the resources that were added to a specific item
  1723. */
  1724. function display_added_resources($type, $id, $style = '')
  1725. {
  1726. // the array containing the icons
  1727. $arr_icons = array(
  1728. 'Agenda' => '../img/agenda.gif',
  1729. 'Ad Valvas' => '../img/valves.gif',
  1730. 'Link' => '../img/links.gif',
  1731. 'Exercise' => '../img/quiz.gif'
  1732. );
  1733. global $_course, $origin;
  1734. $TABLERESOURCE = Database::get_course_table(TABLE_LINKED_RESOURCES, $_course['dbName']);
  1735. $sql = "SELECT * FROM $TABLERESOURCE WHERE source_type='$type' and source_id='$id'";
  1736. $result = Database::query($sql);
  1737. while ($row = Database::fetch_array($result)) {
  1738. if ($origin != 'learnpath') {
  1739. display_addedresource_link($row['resource_type'], $row['resource_id'], $style);
  1740. } else {
  1741. display_addedresource_link_in_learnpath(
  1742. $row['resource_type'],
  1743. $row['resource_id'],
  1744. 'agendaitems',
  1745. '',
  1746. 'builder',
  1747. 'icon'
  1748. );
  1749. echo "<br>";
  1750. }
  1751. }
  1752. }
  1753. /**
  1754. * This function is to show the added resources when adding an item
  1755. * $showdeleteimg determine if the delete image should appear or not.
  1756. * deleting an added resource is only possible through the resource linker file itself
  1757. */
  1758. function display_resources($showdeleteimg)
  1759. {
  1760. global $action;
  1761. global $resourceaction;
  1762. global $id;
  1763. global $locationkey;
  1764. global $source_id, $action, $learnpath_id, $chapter_id, $originalresource;
  1765. if ($resourceaction == "removeresource") {
  1766. /* unneccessary because when editing we delete all the added resources from the
  1767. database and add all these from the session
  1768. if ($action=="edit") // we have an edit and thus we delete from the database and from the session
  1769. {
  1770. echo "remove from database";
  1771. echo $_SESSION['source_type']."/";
  1772. echo $id."/";
  1773. $addedresource=$_SESSION['addedresource'];
  1774. $addedresourceid=$_SESSION['addedresourceid'];
  1775. echo $addedresource[$key]."/";
  1776. echo $addedresourceid[$key]."/";
  1777. delete_one_added_resource($_SESSION['source_type'],$id,$addedresource[$key],$addedresourceid[$key]);
  1778. remove_resource($key);
  1779. }
  1780. else // we remove from the session
  1781. {*/
  1782. //echo "remove from session";
  1783. remove_resource($locationkey);
  1784. }
  1785. $addedresource = $_SESSION['addedresource'];
  1786. $addedresourceid = $_SESSION['addedresourceid'];
  1787. if (is_array($addedresource)) {
  1788. echo '<table>';
  1789. foreach ($addedresource as $resource) {
  1790. //echo $resource.":".$addedresourceid[key($addedresource)];
  1791. echo '<tr><td>';
  1792. display_addedresource_link($resource, $addedresourceid[key($addedresource)]);
  1793. echo '</td><td width="30">';
  1794. // if $_SERVER['REQUEST_URI'] contains and ?id=xx we have an edit and the url for deleting a session added resource
  1795. // should also contain this id.
  1796. $test = parse_url($_SERVER['REQUEST_URI']);
  1797. $output = array();
  1798. parse_str($test['query'], $output);
  1799. if ($showdeleteimg == 1) {
  1800. //if (strstr($_SERVER['REQUEST_URI'],"?id="))
  1801. // { echo " <a href='".api_get_self()."?id=".$output['id']."&amp;"; }
  1802. //else
  1803. // { echo " <a href='".api_get_self()."?"; }
  1804. //action=$action&id=$id&
  1805. //echo "action=$action&amp;id=$id&amp;originalresource=no&amp;resourceaction=removeresource&amp;key=".key($addedresource)."'><img src='../img/delete.gif' border='0' alt='resource ".get_lang('Delete')."' /></a><br />";
  1806. echo "<a href=".api_get_self(
  1807. )."?showresources=true&amp;source_forum=".$_GET['source_forum']."&amp;resourceaction=removeresource&amp;locationkey=".key(
  1808. $addedresource
  1809. )."&amp;source_id=$source_id&amp;action=$action&amp;learnpath_id=$learnpath_id&amp;chapter_id=$chapter_id&amp;originalresource=no><img src='../img/delete.gif' border='0' alt='resource ".get_lang(
  1810. 'Delete'
  1811. )."' /></a><br />";
  1812. }
  1813. echo '</td></tr>';
  1814. next($addedresource);
  1815. //$_SESSION['edit']=='';
  1816. }
  1817. echo '</table>';
  1818. } else // it is a string
  1819. {
  1820. echo '';
  1821. }
  1822. } // end of the display_resources function
  1823. /**
  1824. * This function checks wether the link add resource should be displayed next the item in the linker page
  1825. * So we have to check if the specific id of that tool is already in the array of the added resources
  1826. * if it is already in, the link should not be showed since it would make it possible to add
  1827. * the same resource a second time (=duplication of added resources)
  1828. */
  1829. function showorhide_addresourcelink($type, $id)
  1830. {
  1831. global $from_learnpath, $source_id, $action, $learnpath_id, $chapter_id, $originalresource, $folder, $content, $target;
  1832. //global $_SESSION['addresource'];
  1833. //global $_SESSION['addresourceid'];
  1834. $addedresource = $_SESSION['addedresource'];
  1835. $addedresourceid = $_SESSION['addedresourceid'];
  1836. if (is_array($_SESSION['addedresource'])) {
  1837. foreach ($addedresource as $toolcompare) {
  1838. //echo $toolcompare;
  1839. //echo "/".$type."/".$id."****";
  1840. //$key=key($addedresource);
  1841. //echo $addedresourceid[$key];
  1842. //print_r($addedresourceid);
  1843. //echo "<br>";
  1844. if ($toolcompare == $type and $addedresourceid[key($addedresource)] == $id) {
  1845. $show = 0;
  1846. }
  1847. next($addedresource);
  1848. }
  1849. if ($from_learnpath) {
  1850. $lang_add_it_or_resource = get_lang('AddIt');
  1851. } else {
  1852. $lang_add_it_or_resource = get_lang('AddResource');
  1853. }
  1854. if ($show !== 0) {
  1855. if ($type == "Document") {
  1856. echo "<a href=".api_get_self(
  1857. )."?content=".$type."&folder=".$folder."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no>".$lang_add_it_or_resource."</a>";
  1858. } else {
  1859. echo "<a href='".api_get_self(
  1860. )."?content=".$type."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no&target=$target'>".$lang_add_it_or_resource."</a>";
  1861. }
  1862. }
  1863. } else // if it is not an array, it is a string
  1864. {
  1865. if ($_SESSION['addedresource'] !== $type or $_SESSION['addedresourceid'] !== $id) {
  1866. if ($from_learnpath) {
  1867. $lang_add_it_or_resource = get_lang('AddIt');
  1868. } else {
  1869. $lang_add_it_or_resource = get_lang('AddResource');
  1870. }
  1871. echo "<a href='".api_get_self(
  1872. )."?content=".$type."&folder=".$folder."&source_forum=".$_GET['source_forum']."&add=".$id."&source_id=$source_id&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no&target=$target'>".$lang_add_it_or_resource."</a>";
  1873. }
  1874. }
  1875. }
  1876. ?>