resourcelinker.inc.php 89 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063
  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 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Patrick Cool (patrick.cool@ugent.be)
  9. Copyright (c) Denes Nagy
  10. For a full list of contributors, see "credits.txt".
  11. The full license can be read in "license.txt".
  12. This program is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU General Public License
  14. as published by the Free Software Foundation; either version 2
  15. of the License, or (at your option) any later version.
  16. See the GNU General Public License for more details.
  17. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  18. ==============================================================================
  19. */
  20. /**
  21. ==============================================================================
  22. * @author Patrick Cool - original version
  23. * @author Denes Nagy - further improvements for learning path builder
  24. * @author Roan Embrechts - refactoring to improve code organisation
  25. * @package dokeos.resourcelinker
  26. * @todo use the constants for the tools
  27. * @todo use Database API instead of creating table names locally.
  28. ==============================================================================
  29. */
  30. /*
  31. ==============================================================================
  32. INIT SECTION
  33. ==============================================================================
  34. */
  35. #$langFile = "resourcelinker";
  36. require_once('back_compat.inc.php');
  37. include(api_get_path(SYS_CODE_PATH).'lang/english/resourcelinker.inc.php');
  38. if(!empty($_course['language'])){
  39. include(api_get_path(SYS_CODE_PATH).'lang/'.$_course['language'].'/resourcelinker.inc.php');
  40. }
  41. include('../exercice/hotpotatoes.lib.php');
  42. /*
  43. ==============================================================================
  44. FUNCTIONS
  45. ==============================================================================
  46. */
  47. function unset_session_resources()
  48. {
  49. $_SESSION['addedresource']='';
  50. $_SESSION['addedresourceid']='';
  51. api_session_unregister(addedresource);
  52. api_session_unregister(addedresourceid);
  53. }
  54. /**
  55. * Insert description here.
  56. */
  57. function show_folder_up()
  58. {
  59. global $folder;
  60. global $source_id, $action, $learnpath_id, $chapter_id, $originalresource;
  61. $level = get_levels($folder);
  62. if ($level == 1)
  63. {
  64. echo "<a href='".$_SERVER['PHP_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/parent.gif' border='0' />".get_lang('LevelUp')."</a>";
  65. }
  66. if ($level and $level != 0 and $level != 1)
  67. {
  68. $folder_up=$folder;
  69. $folder_temp=explode('/',$folder);
  70. $last=count($folder_temp)-1;
  71. unset($folder_temp[$last]);
  72. $folder_up=implode('/',$folder_temp);
  73. echo "<a href='".$_SERVER['PHP_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/parent.gif' border='0' />".get_lang('LevelUp')."</a>";
  74. }
  75. }
  76. /**
  77. * Shows the documents of the document tool
  78. * @param $folder
  79. */
  80. function show_documents($folder)
  81. {
  82. global $_course;
  83. global $source_id, $action, $learnpath_id, $chapter_id, $originalresource;
  84. // documents are a special case: the teacher can add an invisible document (it will be viewable by the user)
  85. // other tools do not have this feature. This only counts
  86. if (is_allowed_to_edit())
  87. {
  88. $visibility="visibility<>'2'";
  89. }
  90. else
  91. {
  92. $visibility="visibility='1'";
  93. }
  94. $item_property_table = Database::get_course_table(ITEM_PROPERTY_TABLE);
  95. $document_table = Database::get_course_table(DOCUMENT_TABLE);
  96. $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";
  97. $result=api_sql_query($sql,__FILE__,__LINE__);
  98. while ($row=mysql_fetch_array($result))
  99. {
  100. if (!$folder)
  101. {
  102. if (get_levels($row['path'])-1==1)
  103. {
  104. // showing the right icon
  105. if (file_or_folder($row['path']))
  106. {
  107. echo '<img src="../img/file.gif" align="middle" />';
  108. }
  109. else
  110. {
  111. $image = choose_image($row['path']);
  112. echo "<img src=\"../img/$image\" align=\"middle\" />";
  113. }
  114. // folders should be clickable
  115. if (file_or_folder($row['path']))
  116. {
  117. echo "<a href='".$_SERVER['PHP_SELF']."?content=Document";
  118. 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 />';
  119. }
  120. else
  121. {
  122. echo substr($row['path'],1).' ';
  123. echo showorhide_addresourcelink('Document',$row['id']);
  124. echo '<br />';
  125. }
  126. }
  127. }
  128. else
  129. {
  130. // we calculate the level we are in by using the $folder in the url
  131. // we put +1 because it does not start with an / and in the database it does
  132. $level=get_levels($folder)+1;
  133. // we calculate each level of the database entry
  134. $file_level=get_levels($row['path'])-1;
  135. // if the level of the database entry is equal to the level we ar in, we put it into an array
  136. // as this is a potential good entry
  137. if ($file_level==$level)
  138. {
  139. $good_paths[]=$row['path'];
  140. $good_ids[]=$row['id'];
  141. }
  142. //$haystack=$row['path'];
  143. //$conform_folder=strstr($haystack, $folder);
  144. //if (str_replace($folder.'/','',$conform_folder)!==$folder)
  145. // {
  146. // $good_folders[]=$row['path'];
  147. //echo str_replace($folder.'/','',$conform_folder);
  148. // echo '<br />';
  149. // }// if (str_replace($folder.'/','',$conform_folder)!==$folder)
  150. } // else (if (!$folder))
  151. } //while ($row=mysql_fetch_array($result))
  152. // this is code for the case that we are in a subfolder
  153. if ($good_paths)
  154. {
  155. // we have all the potential good database entries, the good ones are those that start with $folder
  156. foreach ($good_paths as $path)
  157. {
  158. if (strstr($path,$folder))
  159. {
  160. $good_key=key($good_paths);
  161. // showing the right icon
  162. if (file_or_folder($path))
  163. {
  164. echo '<img src="../img/file.gif" align="middle" />';
  165. }
  166. else
  167. {
  168. $image = choose_image($path);
  169. echo "<img src=\"../img/$image\" align=\"middle\" />";
  170. }
  171. // folders should be clickable
  172. if (file_or_folder($path))
  173. {
  174. $path=substr($path,1); // remove the first / in folder_up
  175. $uri=str_replace($folder,$path,$_SERVER['REQUEST_URI']);
  176. $newuri=str_replace('add=','addnot=',$uri);
  177. //using the correct name of the folder
  178. $folder_name=str_replace($folder.'/','',$path);
  179. echo "<a href='$newuri'>".$folder_name.'</a><br />';
  180. }
  181. else
  182. {
  183. echo str_replace("/$folder/", '',$path).' ';
  184. echo showorhide_addresourcelink('Document',$good_ids[$good_key]);
  185. echo '<br />';
  186. }
  187. }
  188. next($good_paths);
  189. }
  190. }
  191. }
  192. /**
  193. * Checks wether something is a file or a folder
  194. * 0 means file, 1 means folder
  195. * @param $filefolder
  196. * @todo: use true and false instead of 1 and 0.
  197. */
  198. function file_or_folder($filefolder)
  199. {
  200. global $_course;
  201. global $baseServDir;
  202. $courseDir = $_course['path'].'/document';
  203. $baseWorkDir = api_get_path(SYS_COURSE_PATH).$courseDir;
  204. return (is_dir($baseWorkDir.$filefolder) ? 1 : 0);
  205. }
  206. /**
  207. * Inserts a resource into the database
  208. *
  209. * @param $source_type
  210. * @param $source_id
  211. */
  212. function store_resources($source_type, $source_id)
  213. {
  214. global $_course;
  215. $resource_table = Database::get_course_table(LINKED_RESOURCES_TABLE);
  216. $addedresource = $_SESSION['addedresource'];
  217. $addedresourceid = $_SESSION['addedresourceid'];
  218. if ($_SESSION['addedresource'])
  219. {
  220. foreach ($addedresource as $resource_type)
  221. {
  222. $sql="INSERT INTO $resource_table (source_type, source_id, resource_type, resource_id) VALUES ('$source_type', '$source_id', '$resource_type', '".$addedresourceid[key($addedresource)]."')";
  223. api_sql_query($sql,__FILE__,__LINE__);
  224. $i=key($addedresource);
  225. next($addedresource);
  226. }
  227. $_SESSION['addedresource']='';
  228. $_SESSION['addedresourceid']='';
  229. }
  230. }
  231. /**
  232. * DEPRECATED - use rl_get_resource_link() instead - DEPRECATED
  233. * Displays the link that opens a new browser window that views the added resource.
  234. *
  235. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  236. * @param $type the type of the tool
  237. * @param $id the id of the resource
  238. * @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)
  239. * @todo use the constants for the type definitions.
  240. */
  241. function display_addedresource_link($type, $id, $style='')
  242. {
  243. global $_course;
  244. // styling the link of the added resource
  245. if ($style <> '')
  246. {
  247. $styling = ' class="'.$style.'"';
  248. }
  249. switch ($type)
  250. {
  251. case 'Agenda':
  252. $TABLEAGENDA = $_course['dbNameGlu'].'calendar_event';
  253. $result = api_sql_query("SELECT * FROM `$TABLEAGENDA` WHERE id=$id",__FILE__,__LINE__);
  254. $myrow = mysql_fetch_array($result);
  255. echo '<img src="../img/agenda.gif" align="middle" /> <a href="../calendar/agenda.php"'.$styling.'>'.$myrow['title']."</a><br />\n";
  256. break;
  257. case 'Ad_Valvas':
  258. $tbl_announcement = $_course['dbNameGlu'].'announcement';
  259. $result = api_sql_query("SELECT * FROM `$tbl_announcement` WHERE id=$id",__FILE__,__LINE__);
  260. $myrow = mysql_fetch_array($result);
  261. echo '<img src="../img/valves.gif" align="middle" /> <a href="../announcements/announcements.php"'.$styling.'>'.$myrow['title']."</a><br />\n";
  262. break;
  263. case 'Link':
  264. $TABLETOOLLINK = $_course['dbNameGlu'].'link';
  265. $result = api_sql_query("SELECT * FROM `$TABLETOOLLINK` WHERE id=$id",__FILE__,__LINE__);
  266. $myrow = mysql_fetch_array($result);
  267. 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";
  268. break;
  269. case 'Exercise':
  270. $TBL_EXERCICES = $_course['dbNameGlu'].'quiz';
  271. $result = api_sql_query("SELECT * FROM `$TBL_EXERCICES` WHERE id=$id",__FILE__,__LINE__);
  272. $myrow = mysql_fetch_array($result);
  273. echo '<img src="../img/quiz.gif" align="middle" /> <a href="../exercice/exercice_submit.php?exerciseId='.$myrow['id'].'"'.$styling.'>'.$myrow['title']."</a><br />\n";
  274. break;
  275. case 'Forum':
  276. $TBL_FORUMS = $_course['dbNameGlu'].'bb_forums';
  277. $result = api_sql_query("SELECT * FROM `$TBL_FORUMS` WHERE forum_id=$id",__FILE__,__LINE__);
  278. $myrow = mysql_fetch_array($result);
  279. 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";
  280. break;
  281. case 'Thread': //=topics
  282. $tbl_posts = $_course['dbNameGlu'].'bb_posts';
  283. $tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text';
  284. $TBL_FORUMS = $_course['dbNameGlu'].'bb_forums';
  285. $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__);
  286. $myrow = mysql_fetch_array($result);
  287. // grabbing the title of the post
  288. $sql_title = "SELECT * FROM `$tbl_posts_text` WHERE post_id=".$myrow["post_id"];
  289. $result_title = api_sql_query($sql_title,__FILE__,__LINE__);
  290. $myrow_title = mysql_fetch_array($result_title);
  291. 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";
  292. break;
  293. case 'Post':
  294. $tbl_post = Database::get_course_table(FORUM_POST_TABLE);
  295. $tbl_post_text = Database::get_course_table(FORUM_POST_TEXT_TABLE);
  296. $sql = "SELECT * FROM $tbl_post p, $tbl_post_text t WHERE p.post_id = t.post_id AND p.post_id = $id";
  297. $result = api_sql_query($sql,__FILE__,__LINE__);
  298. $post = mysql_fetch_object($result);
  299. 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";
  300. break;
  301. case 'Document':
  302. $dbTable = $_course['dbNameGlu'].'document';
  303. $result = api_sql_query("SELECT * FROM `$dbTable` WHERE id=$id",__FILE__,__LINE__);
  304. $myrow = mysql_fetch_array($result);
  305. $pathname = explode('/',$myrow['path']); // making a correct name for the link
  306. $last = count($pathname) - 1; // making a correct name for the link
  307. $filename = $pathname[$last]; // making a correct name for the link
  308. $image = choose_image($filename);
  309. $ext = explode('.',$filename);
  310. $ext = strtolower($ext[sizeof($ext)-1]);
  311. $myrow['path'] = rawurlencode($myrow['path']);
  312. $in_frames = in_array($ext, array('htm','html','gif','jpg','jpeg','png'));
  313. 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";
  314. break;
  315. case 'Externallink':
  316. echo '<img src="../img/links.gif" align="middle" /> <a href="'.$id.'"'.$styling.'>'.$id."</a><br />\n";
  317. break;
  318. }
  319. }
  320. /**
  321. * This function is to display the added resources (lessons) in the learning path player and builder
  322. * this function is a modification of display_addedresource_link($type, $id) function
  323. * the two ids are a bit confusing, I admit, but I did not want to change Patrick's work, I was
  324. * building upon it. - Denes
  325. *
  326. * Parameters:
  327. * @param completed - if ="completed" then green presentation with checkbox
  328. * @param id_in_path - if onclick then this lesson will be considered completed, that is the unique index in the items table
  329. * @param id - that is the correspondent id in the mirror tool (like Agenda item 2)
  330. * @param type - that is the correspondent type in the mirror tool (like this is a Link item)
  331. * @param builder - if ="builder" then onclick shows in new window
  332. * @param icon - if ="icon" then the small icon will appear
  333. * if ="wrap" then wrapped settings are used (and no icon is displayed)
  334. * 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)
  335. * @todo this function is too long, rewrite
  336. */
  337. function display_addedresource_link_in_learnpath($type, $id, $completed, $id_in_path, $builder, $icon, $level = 0)
  338. {
  339. global $_course, $learnpath_id, $tbl_learnpath_item, $items;
  340. global $_course, $curDirPath, $rootWeb, $enableDocumentParsing, $_course, $_uid, $_cid, $rootSys;
  341. $tbl_lp_item = Database::get_course_table('lp_item');
  342. $hyperlink_target_parameter = ''; //or e.g. 'target="_blank"'
  343. $length = ((($builder == 'builder') and ($icon == 'nolink')) ? 65 : 32);
  344. if ($builder != 'builder') $origin = 'learnpath'; //origin = learnpath in student view
  345. $linktype = $type;
  346. if (($type == 'Link _self') or ($type == 'Link _blank')) $type = 'Link';
  347. //YW switched litteral tool names to use of constants declared in main_api.lib.php
  348. switch ($type)
  349. {
  350. case TOOL_CALENDAR_EVENT:
  351. case "Agenda":
  352. $TABLEAGENDA = $_course['dbNameGlu']."calendar_event";
  353. $result = api_sql_query("SELECT * FROM `$TABLEAGENDA` WHERE id=$id",__FILE__,__LINE__);
  354. $myrow=mysql_fetch_array($result);
  355. $sql="select * from $tbl_lp_item where id=$id_in_path";
  356. $result=api_sql_query($sql,__FILE__,__LINE__); $row=mysql_fetch_array($result);
  357. if ($row['title'] != '') { $myrow["title"]=$row['title']; }
  358. $desc=$row['description'];
  359. $agenda_id=$row['item_id'];
  360. echo str_repeat("&nbsp;&gt;",$level);
  361. if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
  362. if ($icon != 'nolink')
  363. {
  364. if ($completed=='completed') {
  365. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  366. } else {
  367. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  368. //echo "&nbsp;";
  369. }
  370. }
  371. if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
  372. if ($myrow["title"]=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
  373. if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); }
  374. if ($icon == 'icon') { echo "<img src='../img/agenda.gif' align=\"absmiddle\" alt='agenda'>"; }
  375. if ($builder != 'builder')
  376. {
  377. echo "<a href=\"".$_SERVER['PHP_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>";
  378. $items[]=$_SERVER['PHP_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";
  379. if ($desc != '')
  380. {
  381. if ($icon != 'wrap')
  382. {
  383. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
  384. }
  385. else
  386. {
  387. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
  388. }
  389. }
  390. }
  391. else
  392. {
  393. echo "<a href=\"../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>";
  394. }
  395. break;
  396. case TOOL_ANNOUNCEMENT:
  397. case "Ad_Valvas":
  398. $tbl_announcement = $_course['dbNameGlu']."announcement";
  399. $result = api_sql_query("SELECT * FROM `$tbl_announcement` WHERE id=$id",__FILE__,__LINE__);
  400. $myrow=mysql_fetch_array($result);
  401. $sql="select * from $tbl_lp_item where id=$id_in_path";
  402. $result=api_sql_query($sql,__FILE__,__LINE__); $row=mysql_fetch_array($result);
  403. if ($row['title'] != '') { $myrow["content"]=$row['title']; }
  404. $desc=$row['description'];
  405. $ann_id=$row['item_id'];
  406. echo str_repeat("&nbsp;&gt;",$level);
  407. // the title and the text are in the content field and we only want to display the title
  408. list($title, $text)=split('<br>',$myrow['content']);
  409. if ($title=='') { $title=$myrow['content']; }
  410. $title=$myrow['title'];
  411. $text=$myrow['content'];
  412. if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
  413. if ($icon != 'nolink')
  414. {
  415. if ($completed=='completed') {
  416. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  417. } else {
  418. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  419. //echo "&nbsp;";
  420. }
  421. }
  422. if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
  423. if ($title=='') {
  424. $type="Announcement";
  425. echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
  426. return(true);
  427. }
  428. if ($icon == 'nolink') { return(shorten($title,$length)); }
  429. if ($icon == 'icon') { echo "<img src='../img/valves.gif' align=\"absmiddle\" alt='ad valvas'>"; }
  430. if ($builder != 'builder')
  431. {
  432. echo "<a href=\"".$_SERVER['PHP_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>";
  433. $items[]=$_SERVER['PHP_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";
  434. if ($desc != '')
  435. {
  436. if ($icon != 'wrap')
  437. {
  438. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
  439. }
  440. else
  441. {
  442. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
  443. }
  444. }
  445. }
  446. else
  447. {
  448. echo "<a href=\"../announcements/announcements.php?origin=$origin&ann_id=$ann_id\" class='$completed' target='_blank'>".shorten($title,($length-3*$level))."</a>";
  449. }
  450. break;
  451. case TOOL_LINK:
  452. case "Link" :
  453. $TABLETOOLLINK = $_course['dbNameGlu']."link";
  454. $result= api_sql_query("SELECT * FROM `$TABLETOOLLINK` WHERE id=$id",__FILE__,__LINE__);
  455. $myrow=mysql_fetch_array($result);
  456. $sql="select * from $tbl_lp_item where id=$id_in_path";
  457. $result=api_sql_query($sql,__FILE__,__LINE__); $row=mysql_fetch_array($result);
  458. if ($row['title'] != '') { $myrow["title"]=$row['title']; }
  459. $desc=$row['description'];
  460. echo str_repeat("&nbsp;&gt;",$level);
  461. if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
  462. if ($icon != 'nolink')
  463. {
  464. if ($completed=='completed') {
  465. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  466. } else {
  467. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  468. //echo "&nbsp;";
  469. }
  470. }
  471. if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
  472. if ($myrow["title"]=='')
  473. {
  474. echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
  475. return(true);
  476. }
  477. if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); }
  478. if ($icon == 'icon')
  479. {
  480. if ($linktype=='Link _self') { echo "<img src='../img/links.gif' align=\"absmiddle\" alt='links'>"; }
  481. else { echo "<img src='../img/link_blank.gif' align=\"absmiddle\" alt='blank links'>"; }
  482. }
  483. $thelink=$myrow["url"];
  484. if ($builder != 'builder')
  485. {
  486. echo "<a href=\"".$_SERVER['PHP_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>";
  487. $items[]=$_SERVER['PHP_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";
  488. if ($desc != '')
  489. {
  490. if ($icon != 'wrap')
  491. {
  492. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
  493. }
  494. else
  495. {
  496. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
  497. }
  498. }
  499. }
  500. else
  501. {
  502. echo "<a href=\"$thelink\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>";
  503. }
  504. break;
  505. case TOOL_QUIZ:
  506. case "Exercise":
  507. $TBL_EXERCICES = $_course['dbNameGlu'].'quiz';
  508. $result= api_sql_query("SELECT * FROM `$TBL_EXERCICES` WHERE id=$id",__FILE__,__LINE__);
  509. $myrow=mysql_fetch_array($result);
  510. if ($builder=='builder') { $origin='builder'; }
  511. //this is needed for the exercise_submit.php can delete the session info about tests
  512. $sql="select * from $tbl_lp_item where id=$id_in_path";
  513. $result=api_sql_query($sql,__FILE__,__LINE__);
  514. $row=mysql_fetch_array($result);
  515. if ($row['title'] != '') { $myrow["title"]=$row['title']; }
  516. $desc=$row['description'];
  517. echo str_repeat("&nbsp;&gt;",$level);
  518. if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
  519. if ($icon != 'nolink')
  520. {
  521. if ($completed=='completed') {
  522. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  523. } else {
  524. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  525. //echo "&nbsp;";
  526. }
  527. }
  528. if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
  529. if ($myrow["title"]=='') {
  530. echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
  531. return(true);
  532. }
  533. if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); }
  534. if ($icon == 'icon') { echo "<img src='../img/quiz.gif' align=\"absmiddle\" alt='quizz'>"; }
  535. if ($builder != 'builder')
  536. {
  537. echo "<a href=\"".$_SERVER['PHP_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>";
  538. $items[]=$_SERVER['PHP_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";
  539. if ($desc != '')
  540. {
  541. if ($icon != 'wrap')
  542. {
  543. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
  544. }
  545. else
  546. {
  547. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
  548. }
  549. }
  550. }
  551. else
  552. {
  553. echo "<a href=\"../exercice/exercice_submit.php?origin=$origin&exerciseId=".$myrow["id"]."\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>";
  554. }
  555. break;
  556. case 'hotpotatoes':
  557. case "HotPotatoes":
  558. $TBL_DOCUMENT = $_course['dbNameGlu'].'document';
  559. $documentPath=api_get_path('SYS_COURSE_PATH').$_course['path'].'/document';
  560. $result = api_sql_query("SELECT * FROM `".$TBL_DOCUMENT."` WHERE id=$id");
  561. $myrow= mysql_fetch_array($result);
  562. $path=$myrow["path"];
  563. $name=GetQuizName($path,$documentPath);
  564. if ($builder=='builder') { $origin='builder'; }
  565. //this is needed for the exercise_submit.php can delete the session info about tests
  566. $sql="select * from $tbl_lp_item where id=$id_in_path";
  567. $result=api_sql_query($sql,__FILE__,__LINE__); $row=mysql_fetch_array($result);
  568. if ($row['title'] != '') { $name=$row['title']; }
  569. $desc=$row['description'];
  570. echo str_repeat("&nbsp;&gt;",$level);
  571. if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
  572. if ($icon != 'nolink')
  573. {
  574. if ($completed=='completed') {
  575. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  576. } else {
  577. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  578. //echo "&nbsp;";
  579. }
  580. }
  581. if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
  582. if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }
  583. if ($icon == 'nolink') { return(shorten($name,$length)); }
  584. if ($icon == 'icon') { echo "<img src='../img/jqz.jpg' align=\"absmiddle\" alt='hot potatoes'>"; }
  585. $cid = $_course['official_code'];
  586. if ($builder != 'builder')
  587. {
  588. echo "<a href=\"".$_SERVER['PHP_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>";
  589. $items[]=$_SERVER['PHP_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";
  590. if ($desc != '')
  591. {
  592. if ($icon != 'wrap')
  593. {
  594. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
  595. }
  596. else
  597. {
  598. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
  599. }
  600. }
  601. }
  602. else
  603. {
  604. echo "&nbsp;<a href=\"../exercice/showinframes.php?file=$path&cid=$cid&uid=$_uid\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
  605. }
  606. break;
  607. case TOOL_FORUM:
  608. case "Forum":
  609. $TBL_FORUMS = $_course['dbNameGlu']."bb_forums";
  610. $result= api_sql_query("SELECT * FROM `$TBL_FORUMS` WHERE forum_id=$id",__FILE__,__LINE__);
  611. $myrow=mysql_fetch_array($result);
  612. $sql="select * from $tbl_lp_item where id=$id_in_path";
  613. $result=api_sql_query($sql,__FILE__,__LINE__); $row=mysql_fetch_array($result);
  614. if ($row['title'] != '') { $myrow["forum_name"]=$row['title']; }
  615. $desc=$row['description'];
  616. echo str_repeat("&nbsp;&gt;",$level);
  617. if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
  618. if ($icon != 'nolink')
  619. {
  620. if ($completed=='completed') {
  621. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
  622. } else {
  623. echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
  624. //echo "&nbsp;";
  625. }
  626. }
  627. if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
  628. if ($myrow["forum_name"]=='') { $type="Forum"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('step_deleted2')."</span>"; return(true); }
  629. if ($icon == 'nolink') { return(shorten($myrow["forum_name"],$length)); }
  630. if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; }
  631. $forumparameters="forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
  632. if ($builder != 'builder')
  633. {
  634. echo "<a href=\"".$_SERVER['PHP_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>";
  635. $items[]=$_SERVER['PHP_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";
  636. if ($desc != '')
  637. {
  638. if ($icon != 'wrap')
  639. {
  640. echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
  641. }
  642. else
  643. {
  644. echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
  645. }
  646. }
  647. }
  648. else
  649. {
  650. echo "<a href=\"../phpbb/viewforum.php?$forumparameters\" class='$completed' target='_blank'>".shorten($myrow["forum_name"],($length-3*$level))."</a>";
  651. }
  652. break;
  653. case TOOL_THREAD:
  654. case "Thread": //forum post
  655. $tbl_topics = $_course['dbNameGlu'].'bb_topics';
  656. $tbl_posts = $_course['dbNameGlu'].'bb_posts';
  657. $TBL_FORUMS = $_course['dbNameGlu']."bb_forums";
  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=\"".$_SERVER['PHP_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[]=$_SERVER['PHP_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=\"".$_SERVER['PHP_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[]=$_SERVER['PHP_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=\"".$_SERVER['PHP_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[]=$_SERVER['PHP_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=\"".$_SERVER['PHP_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[]=$_SERVER['PHP_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=\"".$_SERVER['PHP_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[]=$_SERVER['PHP_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=\"".$_SERVER['PHP_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[]=$_SERVER['PHP_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=\"".$_SERVER['PHP_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[]=$_SERVER['PHP_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=\"".$_SERVER['PHP_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[]=$_SERVER['PHP_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=\"".$_SERVER['PHP_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[]=$_SERVER['PHP_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, $rootWeb, $enableDocumentParsing, $_uid, $_cid, $rootSys;
  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 .= $_SERVER['PHP_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_announcement_table();
  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 .= $_SERVER['PHP_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 .= $_SERVER['PHP_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 .= $_SERVER['PHP_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 .= $_SERVER['PHP_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=$_uid";
  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 .= $_SERVER['PHP_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 .= $_SERVER['PHP_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 .= "../phpbb/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 .= $_SERVER['PHP_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 .= $_SERVER['PHP_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 .= $_SERVER['PHP_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 .= $_SERVER['PHP_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 .= $_SERVER['PHP_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 .= $_SERVER['PHP_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 .= $_SERVER['PHP_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 .= $_SERVER['PHP_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=".$_SERVER['PHP_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=".$_SERVER['PHP_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='".$_SERVER['PHP_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='".$_SERVER['PHP_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_from_code($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(AGENDA_TABLE,$_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(ANNOUNCEMENT_TABLE,$_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(LINK_TABLE,$_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(QUIZ_TEST_TABLE,$_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(TOOL_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. if(!empty($_SESSION['dokeos_version']) AND $_SESSION['dokeos_version']>=1.8){
  1563. //$tbl_forum = Database::get_course_table(TOOL_FORUM_TABLE,$_course['database']);
  1564. //$tbl_thread = Database::get_course_table(TOOL_FORUM_THREAD_TABLE,$_course['database']);
  1565. $tbl_post = Database::get_course_table(TOOL_FORUM_POST_TABLE,$_course['database']);
  1566. // grabbing the title of the post
  1567. $sql_title = "SELECT * FROM $tbl_post WHERE post_id=".$id;
  1568. $result_title = api_sql_query($sql_title,__FILE__,__LINE__);
  1569. $myrow_title = Database::fetch_array($result_title);
  1570. $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";
  1571. }else{//older dokeos versions
  1572. $tbl_posts = $_course['dbNameGlu'].'bb_posts';
  1573. $tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text';
  1574. $TBL_FORUMS = $_course['dbNameGlu'].'bb_forums';
  1575. $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__);
  1576. $myrow = Database::fetch_array($result);
  1577. // grabbing the title of the post
  1578. $sql_title = "SELECT * FROM `$tbl_posts_text` WHERE post_id=".$myrow["post_id"];
  1579. $result_title = api_sql_query($sql_title,__FILE__,__LINE__);
  1580. $myrow_title = Database::fetch_array($result_title);
  1581. $output = '<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.' '.$target.'>'.$myrow_title['post_title']."</a><br />\n";
  1582. }
  1583. break;
  1584. case TOOL_POST:
  1585. $tbl_post = Database::get_course_table(TOOL_FORUM_POST_TABLE,$_course['database']);
  1586. //$tbl_post_text = Database::get_course_table(FORUM_POST_TEXT_TABLE);
  1587. $sql = "SELECT * FROM $tbl_post p WHERE p.post_id = $id";
  1588. $result = api_sql_query($sql,__FILE__,__LINE__);
  1589. $post = Database::fetch_array($result);
  1590. $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";
  1591. break;
  1592. case TOOL_DOCUMENT:
  1593. $tbl_doc = Database::get_course_table(DOCUMENT_TABLE,$_course['database']);
  1594. $result = api_sql_query("SELECT * FROM $tbl_doc WHERE id=$id",__FILE__,__LINE__);
  1595. $myrow = Database::fetch_array($result);
  1596. $pathname = explode('/',$myrow['path']); // making a correct name for the link
  1597. $last = count($pathname) - 1; // making a correct name for the link
  1598. $filename = $pathname[$last]; // making a correct name for the link
  1599. $image = choose_image($filename);
  1600. $ext = explode('.',$filename);
  1601. $ext = strtolower($ext[sizeof($ext)-1]);
  1602. $myrow['path'] = rawurlencode($myrow['path']);
  1603. $in_frames = in_array($ext, array('htm','html','gif','jpg','jpeg','png'));
  1604. $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";
  1605. break;
  1606. /*
  1607. case 'Externallink':
  1608. $output = '<img src="../img/links.gif" align="middle" /> <a href="'.$id.'"'.$styling.' '.$target.'>'.$id."</a><br />\n";
  1609. break;
  1610. */
  1611. }
  1612. return $output;
  1613. }
  1614. /**
  1615. * Returns an HTML-formatted link to a resource, to incorporate directly into
  1616. * the new learning path tool.
  1617. *
  1618. * The function is a big switch on tool type.
  1619. * In each case, we query the corresponding table for information and build the link
  1620. * with that information.
  1621. * @author Yannick Warnier <ywarnier@beeznest.org> - rebranding based on previous work (display_addedresource_link_in_learnpath())
  1622. * @param string Course code
  1623. * @param integer The learning path ID (in lp table)
  1624. * @param integer The database ID for that item in the lp_item table
  1625. * @param
  1626. * @param string Type (as one of the TOOL_ constants declared in main_api.lib.php)
  1627. * @param integer ID of the database item to get (from that tool's table)
  1628. * @param id - that is the correspondent id in the mirror tool (like Agenda item 2)
  1629. * @param id_in_path - the unique index in the items table
  1630. */
  1631. function rl_get_resource_link_for_learnpath($course_code, $learnpath_id, $id_in_path)
  1632. {
  1633. //error_log('In rl_get_resource_link_for_learnpath()',0);
  1634. global $my_version; //added global variable just for cross compatibility. I hate it.
  1635. if($my_version=='1.8'){
  1636. $_course = Database::get_course_info($course_code);
  1637. }else{
  1638. $_course = Database::get_course_info_from_code($course_code);
  1639. }
  1640. $tbl_lp_item = Database::get_course_table('lp_item');
  1641. $sql_item = "SELECT * FROM $tbl_lp_item " .
  1642. "WHERE lp_id = $learnpath_id AND id = $id_in_path";
  1643. $res_item = api_sql_query($sql_item,__FILE__,__LINE__);
  1644. if(Database::num_rows($res_item<1)) return -1; //exit
  1645. $row_item = Database::fetch_array($res_item);
  1646. $type = strtolower($row_item['item_type']);
  1647. $id = $row_item['path'];
  1648. $origin='learnpath';
  1649. $main_dir_path = api_get_path(WEB_CODE_PATH);
  1650. $main_course_path = api_get_path(WEB_COURSE_PATH).$_course['directory'].'/';
  1651. $link = '';
  1652. switch ($type)
  1653. {
  1654. case 'dokeos_chapter':
  1655. $link .= $main_dir_path.'newscorm/blank.php';
  1656. case TOOL_CALENDAR_EVENT:
  1657. $link .= $main_dir_path.'calendar/agenda.php?origin='.$origin.'&agenda_id='.$id;
  1658. break;
  1659. case TOOL_ANNOUNCEMENT:
  1660. $link .= $main_dir_path.'announcements/announcements.php?origin='.$origin.'&ann_id='.$id;
  1661. break;
  1662. case TOOL_LINK:
  1663. $TABLETOOLLINK = Database::get_course_table(LINK_TABLE,$_course['database']);
  1664. $result= api_sql_query("SELECT * FROM $TABLETOOLLINK WHERE id=$id",__FILE__,__LINE__);
  1665. $myrow=Database::fetch_array($result);
  1666. $thelink=$myrow["url"];
  1667. $link .= $thelink;
  1668. break;
  1669. case TOOL_QUIZ:
  1670. $TBL_EXERCICES = Database::get_course_table(QUIZ_TEST_TABLE,$_course['database']);
  1671. $sql = "SELECT * FROM $TBL_EXERCICES WHERE id=$id";
  1672. $result= api_sql_query($sql,__FILE__,__LINE__);
  1673. $myrow=Database::fetch_array($result);
  1674. if ($row_item['title'] != '') { $myrow["title"]=$row_item['title']; }
  1675. $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;
  1676. break;
  1677. case "hotpotatoes": //lowercase because of strtolower above
  1678. $TBL_DOCUMENT = Database::get_course_table(DOCUMENT_TABLE);
  1679. $result = api_sql_query("SELECT * FROM ".$TBL_DOCUMENT." WHERE id=$id",__FILE__,__LINE__);
  1680. $myrow= Database::fetch_array($result);
  1681. $path=$myrow["path"];
  1682. $link .= $main_dir_path.'exercice/showinframes.php?file='.$path.'' .
  1683. '&origin='.$origin.'&cid='.$course_code.'&uid='.api_get_user_id().'' .
  1684. '&learnpath_id='.$learnpath_id.'&learnpath_item_id='.$id_in_path;
  1685. break;
  1686. case TOOL_FORUM:
  1687. $link .= $main_dir_path.'phpbb/viewforum.php?forum='.$id.'&lp=true';
  1688. break;
  1689. case TOOL_THREAD: //forum post
  1690. $tbl_topics = Database::get_course_table(TOOL_FORUM_THREAD,$_course['database']);
  1691. $sql="SELECT * FROM $tbl_topics where thread_id=$id";
  1692. $result= api_sql_query($sql,__FILE__,__LINE__);
  1693. $myrow=Database::fetch_array($result);
  1694. $link .= $main_dir_path.'phpbb/viewtopic.php?topic='.$id.'' .
  1695. '&forum='.$myrow['forum_id'].'&lp=true';
  1696. break;
  1697. case TOOL_POST:
  1698. $tbl_post = Database::get_course_table(TOOL_FORUM_POST_TABLE,$_course['database']);
  1699. $result= api_sql_query("SELECT * FROM $tbl_post where post_id=$id",__FILE__,__LINE__);
  1700. $myrow=Database::fetch_array($result);
  1701. $title=$myrow['post_title'];
  1702. $desc=$row_item['description'];
  1703. $posternom=$myrow['poster_name'];
  1704. $posttime=$myrow['post_date'];
  1705. $posttext=$myrow['post_text'];
  1706. $posttitle=$title;
  1707. $posttext = str_replace('"',"'",$posttext);
  1708. $link .= $main_dir_path.'phpbb/viewpost.php?post='.$id.'' .
  1709. '&topic='.$myrow['topic_id'].'&forum='.$myrow['forum_id'].'' .
  1710. '&lp=true';
  1711. break;
  1712. case TOOL_DOCUMENT:
  1713. $tbl_doc = Database::get_course_table(DOCUMENT_TABLE,$_course['database']);
  1714. $sql = "SELECT * FROM $tbl_doc WHERE id=$id";
  1715. $result=api_sql_query($sql,__FILE__,__LINE__);
  1716. $myrow=Database::fetch_array($result);
  1717. $docurl=$myrow['path'];
  1718. $link .= $main_course_path.'document'.$docurl;
  1719. $openmethod=2;
  1720. $officedoc=false;
  1721. api_session_register('openmethod');
  1722. api_session_register('officedoc');
  1723. break;
  1724. case "assignments":
  1725. $link .= $main_dir_path.'work/work.php?origin='.$origin;
  1726. break;
  1727. case TOOL_DROPBOX:
  1728. $link .= $main_dir_path.'dropbox/index.php?origin=learnpath';
  1729. break;
  1730. case "introduction_text": //DEPRECATED
  1731. $link .= '';
  1732. break;
  1733. case TOOL_COURSE_DESCRIPTION:
  1734. $link .= $main_dir_path.'course_description?origin='.$learnpath;
  1735. break;
  1736. case TOOL_GROUP:
  1737. $link .= $main_dir_path.'group/group.php?origin='.$origin;
  1738. break;
  1739. case TOOL_USER:
  1740. $link .= $main_dir_path.'user/user.php?origin='.$origin;
  1741. break;
  1742. }//end switch
  1743. return $link;
  1744. }
  1745. /**
  1746. * Gets the name of a resource (generally used in learnpath when no name is provided)
  1747. *
  1748. * @author Yannick Warnier <ywarnier@beeznest.org>, Dokeos - rebranding
  1749. * @param string Course code
  1750. * @param string The tool type (using constants declared in main_api.lib.php)
  1751. * @param integer The resource ID
  1752. */
  1753. function rl_get_resource_name($course_code, $learnpath_id, $id_in_path)
  1754. {
  1755. global $my_version;
  1756. if($my_version == '1.8'){
  1757. $_course = Database::get_course_info($course_code);
  1758. }else{
  1759. $_course = Database::get_course_info_from_code($course_code);
  1760. }
  1761. $tbl_lp_item = Database::get_course_table('lp_item');
  1762. $sql_item = "SELECT * FROM $tbl_lp_item " .
  1763. "WHERE lp_id = $learnpath_id AND id = $id_in_path";
  1764. $res_item = api_sql_query($sql_item,__FILE__,__LINE__);
  1765. if(Database::num_rows($res_item<1)) return ''; //exit
  1766. $row_item = Database::fetch_array($res_item);
  1767. $type = strtolower($row_item['item_type']);
  1768. $id = $row_item['ref'];
  1769. $output = '';
  1770. switch ($type)
  1771. {
  1772. case TOOL_CALENDAR_EVENT:
  1773. $TABLEAGENDA = Database::get_course_table(AGENDA_TABLE,$_course['database']);
  1774. $result = api_sql_query("SELECT * FROM $TABLEAGENDA WHERE id=$id",__FILE__,__LINE__);
  1775. $myrow = Database::fetch_array($result);
  1776. $output = $myrow['title'];
  1777. break;
  1778. case TOOL_ANNOUNCEMENT:
  1779. $tbl_announcement = Database::get_course_table(ANNOUNCEMENT_TABLE,$_course['database']);
  1780. $result = api_sql_query("SELECT * FROM $tbl_announcement WHERE id=$id",__FILE__,__LINE__);
  1781. $myrow = Database::fetch_array($result);
  1782. $output = $myrow['title'];
  1783. break;
  1784. case TOOL_LINK:
  1785. //doesn't take $target into account
  1786. $TABLETOOLLINK = Database::get_course_table(LINK_TABLE,$_course['database']);
  1787. $result = api_sql_query("SELECT * FROM $TABLETOOLLINK WHERE id=$id",__FILE__,__LINE__);
  1788. $myrow = Database::fetch_array($result);
  1789. $output = $myrow['title'];
  1790. break;
  1791. case TOOL_QUIZ:
  1792. $TBL_EXERCICES = Database::get_course_table(QUIZ_TEST_TABLE,$_course['database']);
  1793. $result = api_sql_query("SELECT * FROM $TBL_EXERCICES WHERE id=$id",__FILE__,__LINE__);
  1794. $myrow = Database::fetch_array($result);
  1795. $output = $myrow['title'];
  1796. break;
  1797. case TOOL_FORUM:
  1798. $TBL_FORUMS = Database::get_course_table(TOOL_FORUM,$_course['database']);
  1799. $result = api_sql_query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id",__FILE__,__LINE__);
  1800. $myrow = Database::fetch_array($result);
  1801. $output = $myrow['forum_name'];
  1802. break;
  1803. case TOOL_THREAD: //=topics
  1804. if(!empty($_SESSION['dokeos_version']) AND $_SESSION['dokeos_version']>=1.8){
  1805. //$tbl_forum = Database::get_course_table(TOOL_FORUM_TABLE,$_course['database']);
  1806. //$tbl_thread = Database::get_course_table(TOOL_FORUM_THREAD_TABLE,$_course['database']);
  1807. $tbl_post = Database::get_course_table(TOOL_FORUM_POST_TABLE,$_course['database']);
  1808. // grabbing the title of the post
  1809. $sql_title = "SELECT * FROM $tbl_post WHERE post_id=".$id;
  1810. $result_title = api_sql_query($sql_title,__FILE__,__LINE__);
  1811. $myrow_title = Database::fetch_array($result_title);
  1812. $output = $myrow_title['post_title'];
  1813. }else{//older dokeos versions
  1814. $tbl_posts = $_course['dbNameGlu'].'bb_posts';
  1815. $tbl_posts_text = $_course['dbNameGlu'].'bb_posts_text';
  1816. $TBL_FORUMS = $_course['dbNameGlu'].'bb_forums';
  1817. $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__);
  1818. $myrow = Database::fetch_array($result);
  1819. // grabbing the title of the post
  1820. $sql_title = "SELECT * FROM `$tbl_posts_text` WHERE post_id=".$myrow["post_id"];
  1821. $result_title = api_sql_query($sql_title,__FILE__,__LINE__);
  1822. $myrow_title = Database::fetch_array($result_title);
  1823. $output = $myrow_title['post_title'];
  1824. }
  1825. break;
  1826. case TOOL_POST:
  1827. $tbl_post = Database::get_course_table(TOOL_FORUM_POST_TABLE,$_course['database']);
  1828. //$tbl_post_text = Database::get_course_table(FORUM_POST_TEXT_TABLE);
  1829. $sql = "SELECT * FROM $tbl_post p WHERE p.post_id = $id";
  1830. $result = api_sql_query($sql,__FILE__,__LINE__);
  1831. $post = Database::fetch_array($result);
  1832. $output = $post['post_title'];
  1833. break;
  1834. case TOOL_DOCUMENT:
  1835. case 'hotpotatoes':
  1836. $tbl_doc = Database::get_course_table(DOCUMENT_TABLE,$_course['database']);
  1837. $result = api_sql_query("SELECT * FROM $tbl_doc WHERE id=$id",__FILE__,__LINE__);
  1838. $myrow = Database::fetch_array($result);
  1839. $pathname = explode('/',$myrow['path']); // making a correct name for the link
  1840. $last = count($pathname) - 1; // making a correct name for the link
  1841. $filename = $pathname[$last]; // making a correct name for the link
  1842. $image = choose_image($filename);
  1843. $ext = explode('.',$filename);
  1844. $ext = strtolower($ext[sizeof($ext)-1]);
  1845. $myrow['path'] = rawurlencode($myrow['path']);
  1846. $in_frames = in_array($ext, array('htm','html','gif','jpg','jpeg','png'));
  1847. $output = $filename;
  1848. break;
  1849. /*
  1850. case 'externallink':
  1851. $output = '<img src="../img/links.gif" align="middle" /> <a href="'.$id.'"'.$styling.' '.$target.'>'.$id."</a><br />\n";
  1852. break;
  1853. */
  1854. }
  1855. return stripslashes($output);
  1856. }
  1857. ?>