lp_list.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <?php //$id:$
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2008 Dokeos SPRL
  6. Copyright (c) 2004 Denes Nagy
  7. Copyright (c) 2003 Ghent University (UGent)
  8. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact: Dokeos, rue du Corbeau, 108, B-1000 Brussels, Belgium, info@dokeos.com
  17. ==============================================================================
  18. */
  19. /**
  20. ==============================================================================
  21. * This file was origially the copy of document.php, but many modifications happened since then ;
  22. * the direct file view is not any more needed, if the user uploads a scorm zip file, a directory
  23. * will be automatically created for it, and the files will be uncompressed there for example ;
  24. *
  25. * @package dokeos.learnpath
  26. * @author Yannick Warnier <ywarnier@beeznest.org>
  27. ==============================================================================
  28. */
  29. /**
  30. * Script
  31. */
  32. if(empty($lp_controller_touched) || $lp_controller_touched!=1){
  33. header('location: lp_controller.php?action=list');
  34. }
  35. require_once('back_compat.inc.php');
  36. $courseDir = api_get_course_path().'/scorm';
  37. $baseWordDir = $courseDir;
  38. $display_progress_bar = true;
  39. require_once('learnpathList.class.php');
  40. require_once('learnpath.class.php');
  41. require_once('learnpathItem.class.php');
  42. //$charset = 'UTF-8';
  43. //$charset = 'ISO-8859-1';
  44. /**
  45. * Display initialisation and security checks
  46. */
  47. //extra javascript functions for in html head:
  48. $htmlHeadXtra[] =
  49. "<script language='javascript' type='text/javascript'>
  50. function confirmation(name)
  51. {
  52. if (confirm(\" ".trim(get_lang('AreYouSureToDelete'))." \"+name+\"?\"))
  53. {return true;}
  54. else
  55. {return false;}
  56. }
  57. </script>";
  58. $nameTools = get_lang(ucfirst(TOOL_LEARNPATH));
  59. event_access_tool(TOOL_LEARNPATH);
  60. if (! $is_allowed_in_course) api_not_allowed();
  61. /**
  62. * Display
  63. */
  64. /* Require the search widget and prepare the header with its stuff */
  65. if (api_get_setting('search_enabled') == 'true') {
  66. require api_get_path(LIBRARY_PATH).'search/search_widget.php';
  67. search_widget_prepare(&$htmlHeadXtra);
  68. }
  69. Display::display_header($nameTools,"Path");
  70. //api_display_tool_title($nameTools);
  71. /*
  72. -----------------------------------------------------------
  73. Introduction section
  74. (editable by course admins)
  75. -----------------------------------------------------------
  76. */
  77. $fck_attribute['Width'] = '100%';
  78. $fck_attribute['Height'] = '300';
  79. $fck_attribute['ToolbarSet'] = 'Introduction';
  80. // These settings should stay here.
  81. $fck_attribute['Config']['CreateDocumentWebDir'] = api_get_path('WEB_COURSE_PATH').api_get_course_path().'/document/';
  82. $fck_attribute['Config']['CreateDocumentDir'] = '../../courses/'.api_get_course_path().'/document/';
  83. $fck_attribute['Config']['BaseHref'] = api_get_path('WEB_COURSE_PATH').api_get_course_path().'/';
  84. Display::display_introduction_section(TOOL_LEARNPATH);
  85. $fck_attribute = null; // Clearing this global variable immediatelly after it has been used.
  86. if(api_is_allowed_to_edit())
  87. {
  88. /*--------------------------------------
  89. DIALOG BOX SECTION
  90. --------------------------------------*/
  91. if (!empty($dialog_box))
  92. {
  93. switch ($_GET['dialogtype'])
  94. {
  95. case 'confirmation':
  96. Display::display_confirmation_message($dialog_box);
  97. break;
  98. case 'error':
  99. Display::display_error_message($dialog_box);
  100. break;
  101. case 'warning':
  102. Display::display_warning_message($dialog_box);
  103. break;
  104. default:
  105. Display::display_normal_message($dialog_box);
  106. break;
  107. }
  108. }
  109. if (api_failure::get_last_failure())
  110. {
  111. Display::display_normal_message(api_failure::get_last_failure());
  112. }
  113. //include('content_makers.inc.php');
  114. echo '<div class="actions">';
  115. echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=add_lp">'.
  116. '<img src="../img/wizard.gif" border="0" align="absmiddle" alt="'.get_lang('_add_learnpath').
  117. '">&nbsp;'.get_lang('_add_learnpath').
  118. '</a>' .
  119. str_repeat('&nbsp;',3).
  120. '<a href="../upload/index.php?'.api_get_cidreq().'&curdirpath=/&tool='.TOOL_LEARNPATH.'"><img src="../img/file_zip.gif" border="0" alt="'.get_lang("UploadScorm").'" align="absmiddle">&nbsp;'.get_lang("UploadScorm").'</a>';
  121. if (api_get_setting('service_ppt2lp', 'active') == 'true') {
  122. echo str_repeat('&nbsp;',3).'<a href="../upload/upload_ppt.php?'.api_get_cidreq().'&curdirpath=/&tool='.TOOL_LEARNPATH.'"><img src="../img/powerpoint.gif" border="0" alt="'.get_lang("PowerPointConvert").'" align="absmiddle">&nbsp;'.get_lang("PowerPointConvert").'</a>';
  123. //echo str_repeat('&nbsp;',3).'<a href="../upload/upload_word.php?'.api_get_cidreq().'&curdirpath=/&tool='.TOOL_LEARNPATH.'"><img src="../img/word.gif" border="0" alt="'.get_lang("WordConvert").'" align="absmiddle">&nbsp;'.get_lang("WordConvert").'</a>';
  124. }
  125. echo '</div>';
  126. }
  127. echo '<table width="100%" border="0" cellspacing="2" class="data_table">';
  128. api_is_allowed_to_edit() ? $colspan = 9 : $colspan = 3;
  129. /*
  130. if ($curDirName) // if the $curDirName is empty, we're in the root point and we can't go to a parent dir
  131. {
  132. ?>
  133. <!-- parent dir -->
  134. <a href="<?php echo api_get_self().'?'.api_get_cidreq().'&openDir='.$cmdParentDir.'&subdirs=yes'; ?>">
  135. <img src="../img/parent.gif" border="0" align="absbottom" hspace="5" alt="parent" />
  136. <?php echo get_lang("Up"); ?></a>&nbsp;
  137. <?php
  138. }
  139. */
  140. if (!empty($curDirPath))
  141. {
  142. if(substr($curDirPath,1,1)=='/'){
  143. $tmpcurDirPath=substr($curDirPath,1,strlen($curDirPath));
  144. }else{
  145. $tmpcurDirPath = $curDirPath;
  146. }
  147. ?>
  148. <!-- current dir name -->
  149. <tr>
  150. <td colspan="<?php echo $colspan ?>" align="left" bgcolor="#4171B5">
  151. <img src="../img/opendir.gif" align="absbottom" vspace="2" hspace="3" alt="open_dir" />
  152. <font color="#ffffff"><b><?php echo $tmpcurDirPath ?></b></font>
  153. </td>
  154. </tr>
  155. <?php
  156. }
  157. /* CURRENT DIRECTORY */
  158. echo '<tr>';
  159. echo '<th>'.get_lang('Name').'</th>'."\n" .
  160. '<th>'.get_lang('Progress')."</th>\n";
  161. if (api_is_allowed_to_edit())
  162. {
  163. echo '<th>'.get_lang('CourseSettings')."</th>\n" .
  164. //xport now is inside "Edit"
  165. //'<th>'.get_lang('ExportShort')."</th>\n" .
  166. '<th>'.get_lang('AuthoringOptions')."</th>\n" .
  167. '<th>'.get_lang('Move')."</th>\n";
  168. }
  169. echo "</tr>\n";
  170. /*--------------------------------------
  171. DISPLAY SCORM LIST
  172. --------------------------------------*/
  173. $list = new LearnpathList(api_get_user_id());
  174. $flat_list = $list->get_flat_list();
  175. $is_allowed_to_edit = api_is_allowed_to_edit();
  176. $test_mode = api_get_setting('server_type');
  177. $max = count($flat_list);
  178. //var_dump($flat_list);
  179. if (is_array($flat_list))
  180. {
  181. $counter = 0;
  182. $current = 0;
  183. foreach ($flat_list as $id => $details)
  184. {
  185. if(!$is_allowed_to_edit && $details['lp_visibility'] == 0)
  186. {
  187. // This is a student and this path is invisible, skip
  188. continue;
  189. }
  190. $counter++;
  191. if (($counter % 2)==0) { $oddclass="row_odd"; } else { $oddclass="row_even"; }
  192. $url_start_lp = 'lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$id;
  193. $name = $details['lp_name'];
  194. $image='<img src="../img/kcmdf.gif" border="0" align="absmiddle" alt="' . $name . '">'."\n";
  195. $dsp_line = '<tr align="center" class="'.$oddclass.'">'."\n" .
  196. '<td align="left" valign="top">' .
  197. '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_lp.'">' .
  198. $image . '</a></div><a href="'.$url_start_lp.'">' . $name . '</a>' .
  199. "</td>\n";
  200. //$dsp_desc='<td>'.$details['lp_desc'].'</td>'."\n";
  201. $dsp_desc = '';
  202. $dsp_export = '';
  203. $dsp_edit = '';
  204. $dsp_edit_close = '';
  205. $dsp_delete = '';
  206. $dsp_visible = '';
  207. $dsp_default_view = '';
  208. $dsp_debug = '';
  209. $dsp_order = '';
  210. // Select course theme
  211. if (!empty($platform_theme))
  212. {
  213. $mystyle=$platform_theme;
  214. }
  215. if (!empty($user_theme))
  216. {
  217. $mystyle=$user_theme;
  218. }
  219. if (!empty($mycoursetheme))
  220. {
  221. $mystyle=$mycoursetheme;
  222. }
  223. $lp_theme_css=$mystyle;
  224. if($display_progress_bar)
  225. {
  226. $dsp_progress = '<td>'.learnpath::get_progress_bar('%',learnpath::get_db_progress($id,api_get_user_id()),'').'</td>';
  227. }
  228. else
  229. {
  230. $dsp_progress = '<td style="padding-top:1em;">'.learnpath::get_db_progress($id,api_get_user_id(),'both').'</td>';
  231. }
  232. if($is_allowed_to_edit)
  233. {
  234. $dsp_desc = '<td valign="middle" style="color: grey; padding-top:1em;"><em>'.$details['lp_maker'].'</em> &nbsp;&nbsp; '.$details['lp_proximity'].' &nbsp;&nbsp; '.$details['lp_encoding'].'<a href="lp_controller.php?'.api_get_cidreq().'&action=edit&lp_id='.$id.'">&nbsp;&nbsp;<img src="../img/edit.gif" border="0" title="'.get_lang('_edit_learnpath').'"></a></td>'."\n";
  235. /* export */
  236. //Export is inside "Edit"
  237. //export not available for normal lps yet
  238. /*if($details['lp_type']==1){
  239. $dsp_export = '<td align="center">' .
  240. "<a href='".api_get_self()."?".api_get_cidreq()."&action=export&lp_id=$id'>" .
  241. "<img src=\"../img/cd.gif\" border=\"0\" title=\"".get_lang('Export')."\">" .
  242. "</a>" .
  243. "";
  244. }elseif($details['lp_type']==2){
  245. $dsp_export = '<td align="center">' .
  246. "<a href='".api_get_self()."?".api_get_cidreq()."&action=export&lp_id=$id&export_name=".replace_dangerous_char($name,'strict').".zip'>" .
  247. "<img src=\"../img/cd.gif\" border=\"0\" title=\"".get_lang('Export')."\">" .
  248. "</a>" .
  249. "";
  250. }else{
  251. $dsp_export = '<td align="center">' .
  252. //"<a href='".api_get_self()."?".api_get_cidreq()."&action=export&lp_id=$id'>" .
  253. "<img src=\"../img/cd_gray.gif\" border=\"0\" title=\"".get_lang('Export')."\">" .
  254. //"</a>" .
  255. "";
  256. }*/
  257. /* edit title and description */
  258. $dsp_edit = '<td align="center">';
  259. $dsp_edit_close = '</td>';
  260. /* DELETE COMMAND */
  261. $dsp_delete = "<a href=\"lp_controller.php?".api_get_cidreq()."&action=delete&lp_id=$id\" " .
  262. "onClick=\"return confirmation('".addslashes($name)."');\">" .
  263. "<img src=\"../img/delete.gif\" border=\"0\" title=\"".get_lang('_delete_learnpath')."\" />" .
  264. "</a>";
  265. /* VISIBILITY COMMAND */
  266. if ($details['lp_published'] == "i")
  267. {
  268. $dsp_publish = "<a href=\"".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_publish&new_status=v\">" .
  269. "<img src=\"../img/invisible_LP_list.gif\" border=\"0\" title=\"".get_lang('_publish')."\" />" .
  270. "</a>" .
  271. "";
  272. }
  273. else
  274. {
  275. $dsp_publish = "<a href='".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_publish&new_status=i'>" .
  276. "<img src=\"../img/visible_LP_list.gif\" border=\"0\" title=\"".get_lang('_no_publish')."\" />" .
  277. "</a>".
  278. "";
  279. }
  280. /* VISIBILITY COMMAND */
  281. if ($details['lp_visibility'] == 0)
  282. {
  283. $dsp_visible = "<a href=\"".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_visible&new_status=1\">" .
  284. "<img src=\"../img/invisible.gif\" border=\"0\" title=\"".get_lang('Show')."\" />" .
  285. "</a>" .
  286. "";
  287. }
  288. else
  289. {
  290. $dsp_visible = "<a href='".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_visible&new_status=0'>" .
  291. "<img src=\"../img/visible.gif\" border=\"0\" title=\"".get_lang('Hide')."\" />" .
  292. "</a>".
  293. "";
  294. }
  295. /* Default view mode settings (fullscreen/embedded) */
  296. if($details['lp_view_mode'] == 'fullscreen'){
  297. $dsp_default_view = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_view_mode&lp_id='.$id.'">' .
  298. '<img src="../img/view_fullscreen.gif" border="0" alt="'.get_lang("ViewModeEmbedded").'" title="'.get_lang("ViewModeEmbedded").'"/>' .
  299. '</a>&nbsp;';
  300. }else{
  301. $dsp_default_view = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_view_mode&lp_id='.$id.'">' .
  302. '<img src="../img/view_choose.gif" border="0" alt="'.get_lang("ViewModeFullScreen").'" title="'.get_lang("ViewModeFullScreen").'"/>' .
  303. '</a>&nbsp;';
  304. }
  305. /* Increase SCORM recording */
  306. /*
  307. if($details['lp_force_commit'] == 1){
  308. $dsp_force_commit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_force_commit&lp_id='.$id.'">' .
  309. '<img src="../img/clock.gif" border="0" alt="Normal SCORM recordings" title="'.get_lang("MakeScormRecordingNormal").'"/>' .
  310. '</a>&nbsp;';
  311. }else{
  312. $dsp_force_commit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_force_commit&lp_id='.$id.'">' .
  313. '<img src="../img/clock_gray.gif" border="0" alt="Extra SCORM recordings" title="'.get_lang("MakeScormRecordingExtra").'"/>' .
  314. '</a>&nbsp;';
  315. }
  316. */
  317. if($details['lp_prevent_reinit']==1){
  318. $dsp_reinit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_reinit&lp_id='.$id.'">' .
  319. '<img src="../img/kaboodleloop_gray.gif" border="0" alt="Allow reinit" title="'.get_lang("AllowMultipleAttempts").'"/>' .
  320. '</a>&nbsp;';
  321. }else{
  322. $dsp_reinit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_reinit&lp_id='.$id.'">' .
  323. '<img src="../img/kaboodleloop.gif" border="0" alt="Prevent reinit" title="'.get_lang("PreventMultipleAttempts").'"/>' .
  324. '</a>&nbsp;';
  325. }
  326. if($details['lp_type']==1 || $details['lp_type']==2){
  327. $dsp_build = '<a href="lp_controller.php?'.api_get_cidreq().'&amp;action=build&amp;lp_id='.$id.'"><img src="../img/wizard.gif" border="0" title="'.get_lang("Build").'"></a>&nbsp;';
  328. }else{
  329. $dsp_build = '<img src="../img/wizard_gray.gif" border="0" title="'.get_lang("Build").'">&nbsp;';
  330. }
  331. if($test_mode == 'test' or api_is_platform_admin())
  332. {
  333. if($details['lp_scorm_debug']==1){
  334. $dsp_debug = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_scorm_debug&lp_id='.$id.'">' .
  335. '<img src="../img/bug.gif" border="0" alt="'.get_lang("HideDebug").'" title="'.get_lang("HideDebug").'"/>' .
  336. '</a>&nbsp;';
  337. }else{
  338. $dsp_debug = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_scorm_debug&lp_id='.$id.'">' .
  339. '<img src="../img/bug_gray.gif" border="0" alt="'.get_lang("ShowDebug").'" title="'.get_lang("ShowDebug").'"/>' .
  340. '</a>&nbsp;';
  341. }
  342. }
  343. /* Export */
  344. if($details['lp_type']==1){
  345. $dsp_disk =
  346. "<a href='".api_get_self()."?".api_get_cidreq()."&action=export&lp_id=$id'>" .
  347. "<img src=\"../img/cd.gif\" border=\"0\" title=\"".get_lang('Export')."\">" .
  348. "</a>" .
  349. "";
  350. }elseif($details['lp_type']==2){
  351. $dsp_disk =
  352. "<a href='".api_get_self()."?".api_get_cidreq()."&action=export&lp_id=$id&export_name=".replace_dangerous_char($name,'strict').".zip'>" .
  353. "<img src=\"../img/cd.gif\" border=\"0\" title=\"".get_lang('Export')."\">" .
  354. "</a>" .
  355. "";
  356. }else{
  357. $dsp_disk =
  358. //"<a href='".api_get_self()."?".api_get_cidreq()."&action=export&lp_id=$id'>" .
  359. "<img src=\"../img/cd_gray.gif\" border=\"0\" title=\"".get_lang('Export')."\">" .
  360. //"</a>" .
  361. "";
  362. }
  363. if($details['lp_display_order'] == 1 && $max != 1)
  364. {
  365. $dsp_order .= '<td><a href="lp_controller.php?'.api_get_cidreq().'&action=move_lp_down&lp_id='.$id.'">' .
  366. '<img src="../img/arrow_down_0.gif" border="0" alt="'.get_lang("MoveDown").'" title="'.get_lang("MoveDown").'"/>' .
  367. '</a><img src="../img/blanco.png" border="0" alt="" title="" /></td>';
  368. }
  369. elseif($current == $max-1 && $max != 1) //last element
  370. {
  371. $dsp_order .= '<td><img src="../img/blanco.png" border="0" alt="" title="" /><a href="lp_controller.php?'.api_get_cidreq().'&action=move_lp_up&lp_id='.$id.'">' .
  372. '<img src="../img/arrow_up_0.gif" border="0" alt="'.get_lang("MoveUp").'" title="'.get_lang("MoveUp").'"/>' .
  373. '</a></td>';
  374. }
  375. elseif($max == 1)
  376. {
  377. $dsp_order = '<td></td>';
  378. }
  379. else
  380. {
  381. $dsp_order .= '<td><a href="lp_controller.php?'.api_get_cidreq().'&action=move_lp_down&lp_id='.$id.'">' .
  382. '<img src="../img/arrow_down_0.gif" border="0" alt="'.get_lang("MoveDown").'" title="'.get_lang("MoveDown").'"/>' .
  383. '</a>&nbsp;';
  384. $dsp_order .= '<a href="lp_controller.php?'.api_get_cidreq().'&action=move_lp_up&lp_id='.$id.'">' .
  385. '<img src="../img/arrow_up_0.gif" border="0" alt="'.get_lang("MoveUp").'" title="'.get_lang("MoveUp").'"/>' .
  386. '</a></td>';
  387. }
  388. } // end if($is_allowedToEdit)
  389. //echo $dsp_line.$dsp_desc.$dsp_export.$dsp_edit.$dsp_delete.$dsp_visible;
  390. echo $dsp_line.$dsp_progress.$dsp_desc.$dsp_export.$dsp_edit.$dsp_build.$dsp_visible.$dsp_publish.$dsp_reinit.$dsp_default_view.$dsp_debug.$dsp_delete.$dsp_disk.$dsp_order;
  391. //echo $dsp_line.$dsp_progress.$dsp_desc.$dsp_export.$dsp_edit.$dsp_build.$dsp_visible.$dsp_reinit.$dsp_force_commit.$dsp_delete;
  392. echo "</tr>\n";
  393. $current ++; //counter for number of elements treated
  394. } // end foreach ($flat_list)
  395. //TODO print some user-friendly message if counter is still = 0 to tell nothing can be displayd yet
  396. }// end if ( is_array($flat_list)
  397. echo "</table>";
  398. echo "<br/><br/>";
  399. /*
  400. ==============================================================================
  401. FOOTER
  402. ==============================================================================
  403. */
  404. Display::display_footer();
  405. ?>