resourcelinker.inc.php 71 KB

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