resourcelinker.inc.php 72 KB

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