lp_list.php 16 KB

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