resourcelinker.inc.php 91 KB

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