resourcelinker.inc.php 72 KB

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