resourcelinker.inc.php 89 KB

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