dokeos-learnpath
[ class tree: dokeos-learnpath ] [ index: dokeos-learnpath ] [ all elements ]

Source for file lp_controller.php

Documentation is available at lp_controller.php

  1. <?php //$id: $
  2. /**
  3.  * Controller script. Prepares the common background variables to give to the scripts corresponding to
  4.  * the requested action
  5.  * @package dokeos.learnpath
  6.  * @author Yannick Warnier <ywarnier@beeznest.org>
  7.  */
  8. /**
  9.  * Initialisations
  10.  */
  11. $debug 0;
  12. if($debug>0error_log('New LP -+- Entered lp_controller.php -+-',0);
  13. // name of the language file that needs to be included
  14. if (isset($_GET['action']))
  15.     if($_GET['action'== 'export')
  16.     //only needed on export
  17.         $language_file['hotspot';
  18.         $language_file['exercice';
  19.     }
  20. }
  21. $language_file["course_home";
  22. $language_file["scormdocument";
  23. $language_file["scorm";
  24. $language_file["learnpath";
  25. $language_file['resourcelinker';
  26.  
  27. //flag to allow for anonymous user - needs to be set before global.inc.php
  28. $use_anonymous true;
  29.  
  30. //include class definitions before session_start() to ensure availability when touching
  31. //session vars containing learning paths
  32. require_once('learnpath.class.php');
  33. if($debug>0error_log('New LP - Included learnpath',0);
  34. require_once('learnpathItem.class.php');
  35. if($debug>0error_log('New LP - Included learnpathItem',0);
  36. require_once('scorm.class.php');
  37. if($debug>0error_log('New LP - Included scorm',0);
  38. require_once('scormItem.class.php');
  39. if($debug>0error_log('New LP - Included scormItem',0);
  40. require_once('aicc.class.php');
  41. if($debug>0error_log('New LP - Included aicc',0);
  42. require_once('aiccItem.class.php');
  43. if($debug>0error_log('New LP - Included aiccItem',0);
  44.  
  45. require_once('back_compat.inc.php');
  46. if($debug>0error_log('New LP - Included back_compat',0);
  47.  
  48. if ($is_allowed_in_course == false){
  49.     api_not_allowed(true);
  50. }
  51.  
  52. require_once(api_get_path(LIBRARY_PATH"/fckeditor/fckeditor.php");
  53. $lpfound false;
  54.  
  55. $myrefresh 0;
  56. $myrefresh_id 0;
  57. if(!empty($_SESSION['refresh']&& $_SESSION['refresh']==1){
  58.     //check if we should do a refresh of the oLP object (for example after editing the LP)
  59.     //if refresh is set, we regenerate the oLP object from the database (kind of flush)
  60.     api_session_unregister('refresh');
  61.     $myrefresh 1;
  62.     if($debug>0error_log('New LP - Refresh asked',0);
  63. }
  64. if($debug>0error_log('New LP - Passed refresh check',0);
  65.  
  66. if(!empty($_REQUEST['dialog_box'])){
  67.     $dialog_box stripslashes(urldecode($_REQUEST['dialog_box']));
  68. }
  69.  
  70. $lp_controller_touched 1;
  71.  
  72. if(isset($_SESSION['lpobject']))
  73. {
  74.     if($debug>0error_log('New LP - SESSION[lpobject] is defined',0);
  75.     $oLP unserialize($_SESSION['lpobject']);
  76.     if(is_object($oLP)){
  77.         if($debug>0error_log('New LP - oLP is object',0);
  78.         if($myrefresh == OR $oLP->cc != api_get_course_id()){
  79.             if($debug>0error_log('New LP - Course has changed, discard lp object',0);
  80.             if($myrefresh == 1){$myrefresh_id $oLP->get_id();}
  81.             $oLP null;
  82.             api_session_unregister('oLP');
  83.             api_session_unregister('lpobject');
  84.         }else{
  85.             $_SESSION['oLP'$oLP;
  86.             $lp_found true;            
  87.         }
  88.     }
  89. }
  90. if($debug>0error_log('New LP - Passed data remains check',0);
  91.  
  92. if($lp_found == false 
  93.     || ($_SESSION['oLP']->get_id(!= $_REQUEST['lp_id'])
  94.     )
  95. {
  96.     if($debug>0error_log('New LP - oLP is not object, has changed or refresh been asked, getting new',0);        
  97.     //regenerate a new lp object? Not always as some pages don't need the object (like upload?)
  98.     if(!empty($_REQUEST['lp_id']|| !empty($myrefresh_id)){
  99.         if($debug>0error_log('New LP - lp_id is defined',0);
  100.         //select the lp in the database and check which type it is (scorm/dokeos/aicc) to generate the
  101.         //right object
  102.         $lp_table Database::get_course_table('lp');
  103.         if(!empty($_REQUEST['lp_id'])){
  104.             $lp_id learnpath::escape_string($_REQUEST['lp_id']);
  105.         }else{
  106.             $lp_id $myrefresh_id;
  107.         }
  108.         $sel "SELECT * FROM $lp_table WHERE id = $lp_id";
  109.         if($debug>0error_log('New LP - querying '.$sel,0);
  110.         $res api_sql_query($sel);
  111.         if(Database::num_rows($res))
  112.         {
  113.             $row Database::fetch_array($res);
  114.             $type $row['lp_type'];
  115.             if($debug>0error_log('New LP - found row - type '.$type' - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(),0);            
  116.             switch($type){
  117.                 case 1:
  118.             if($debug>0error_log('New LP - found row - type dokeos - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(),0);            
  119.                     $oLP new learnpath(api_get_course_id(),$lp_id,api_get_user_id());
  120.                     if($oLP !== false)$lp_found true}else{eror_log($oLP->error,0);}
  121.                     break;
  122.                 case 2:
  123.             if($debug>0error_log('New LP - found row - type scorm - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(),0);            
  124.                     $oLP new scorm(api_get_course_id(),$lp_id,api_get_user_id());
  125.                     if($oLP !== false)$lp_found true}else{eror_log($oLP->error,0);}
  126.                     break;
  127.                 case 3:
  128.             if($debug>0error_log('New LP - found row - type aicc - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(),0);            
  129.                     $oLP new aicc(api_get_course_id(),$lp_id,api_get_user_id());
  130.                     if($oLP !== false)$lp_found true}else{eror_log($oLP->error,0);}
  131.                     break;                    
  132.                 default:
  133.             if($debug>0error_log('New LP - found row - type other - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(),0);            
  134.                     $oLP new learnpath(api_get_course_id(),$lp_id,api_get_user_id());
  135.                     if($oLP !== false)$lp_found true}else{eror_log($oLP->error,0);}
  136.                     break;
  137.             }
  138.         }
  139.     }else{
  140.         if($debug>0error_log('New LP - Request[lp_id] and refresh_id were empty',0);
  141.     }
  142.     if($lp_found)
  143.     {
  144.         $_SESSION['oLP'$oLP;
  145.     }
  146. }
  147. if($debug>0error_log('New LP - Passed oLP creation check',0);
  148.  
  149.  
  150. /**
  151.  * Actions switching
  152.  */
  153. $_SESSION['oLP']->update_queue array()//reinitialises array used by javascript to update items in the TOC
  154. $_SESSION['oLP']->message ''//should use ->clear_message() method but doesn't work
  155.  
  156. $fck_attribute['Width''100%';
  157. $fck_attribute['Height''950';
  158. $fck_attribute['ToolbarSet''Full';
  159. $fck_attribute['Config']['FullPage'true;
  160.  
  161. if($_GET['isStudentView'== 'true')
  162. {
  163.     if($_REQUEST['action'!= 'list' AND $_REQUEST['action'!= 'view')
  164.     {
  165.         if(!empty($_REQUEST['lp_id']))
  166.         {
  167.             $_REQUEST['action''view';
  168.         }
  169.         else
  170.         {
  171.             $_REQUEST['action''list';
  172.         }
  173.     }
  174. }
  175.  
  176. switch($_REQUEST['action'])
  177. {
  178.     case 'add_item':
  179.         
  180.         if(!api_is_allowed_to_edit()){
  181.             api_not_allowed(true);
  182.         }
  183.         
  184.         if($debug 0error_log('New LP - add item action triggered'0);
  185.         
  186.         if(!$lp_found)
  187.         {    //check if the learnpath ID was defined, otherwise send back to list
  188.             error_log('New LP - No learnpath given for add item'0)
  189.             require('lp_list.php')
  190.         }
  191.         else
  192.         {
  193.             $_SESSION['refresh'1;
  194.             
  195.             if(isset($_POST['submit_button']&& !empty($_POST['title']))
  196.             {    //if a title was sumbitted                 
  197.                 if(isset($_SESSION['post_time']&& $_SESSION['post_time'== $_POST['post_time'])
  198.                 {    //check post_time to ensure ??? (counter-hacking measure?)
  199.                     require('lp_add_item.php');
  200.                 }
  201.                 else
  202.                 {
  203.                     $_SESSION['post_time'$_POST['post_time'];
  204.                     
  205.                     if($_POST['type'== TOOL_DOCUMENT)
  206.                     {
  207.                         if(isset($_POST['path']&& $_GET['edit'!= 'true')
  208.                         {
  209.                             $document_id $_POST['path'];
  210.                         }
  211.                         else
  212.                         {
  213.                             $document_id $_SESSION['oLP']->create_document($_course);
  214.                         }
  215.                                 
  216.                         $new_item_id $_SESSION['oLP']->add_item($_POST['parent']$_POST['previous']$_POST['type']$document_id$_POST['title']$_POST['description']$_POST['prerequisites']);
  217.                     }
  218.                     else
  219.                     {    //for all other item types than documents, load the item using the item type and path rather than its ID
  220.                         $new_item_id $_SESSION['oLP']->add_item($_POST['parent']$_POST['previous']$_POST['type']$_POST['path']$_POST['title']$_POST['description']$_POST['prerequisites']);
  221.                     }
  222.                     //display                     
  223.                     require('lp_add_item.php');
  224.                 }
  225.             }
  226.             else
  227.             {
  228.                 require('lp_add_item.php');
  229.             }
  230.         }
  231.         
  232.         break;
  233.     
  234.     case 'add_lp':
  235.     
  236.         if(!api_is_allowed_to_edit()){
  237.             api_not_allowed(true);
  238.         }
  239.         
  240.         if($debug 0error_log('New LP - add_lp action triggered'0);
  241.         
  242.         $_REQUEST['learnpath_name'trim($_REQUEST['learnpath_name']);
  243.                         
  244.         if(!empty($_REQUEST['learnpath_name']))
  245.         {
  246.             $_SESSION['refresh'1;
  247.             
  248.             if(isset($_SESSION['post_time']&& $_SESSION['post_time'== $_REQUEST['post_time'])
  249.             {
  250.                 require('lp_add.php');
  251.             }
  252.             else
  253.             {
  254.                 $_SESSION['post_time'$_REQUEST['post_time'];
  255.                             
  256.                 //Kevin Van Den Haute: changed $_REQUEST['learnpath_description'] by '' because it's not used
  257.                 //old->$new_lp_id = learnpath::add_lp(api_get_course_id(), $_REQUEST['learnpath_name'], $_REQUEST['learnpath_description'], 'dokeos', 'manual', '');
  258.                 $new_lp_id learnpath::add_lp(api_get_course_id()$_REQUEST['learnpath_name']'''dokeos''manual''');
  259.                 //learnpath::toggle_visibility($new_lp_id,'v');
  260.                 //Kevin Van Den Haute: only go further if learnpath::add_lp has returned an id
  261.                 if(is_numeric($new_lp_id))
  262.                 {
  263.                     //TODO maybe create a first module directly to avoid bugging the user with useless queries
  264.                     $_SESSION['oLP'new learnpath(api_get_course_id(),$new_lp_id,api_get_user_id());
  265.                             
  266.                     //$_SESSION['oLP']->add_item(0,-1,'dokeos_chapter',$_REQUEST['path'],'Default');
  267.                 
  268.                     require('lp_build.php');
  269.                 }
  270.             }
  271.         }
  272.         else
  273.             require('lp_add.php');
  274.         
  275.         break;
  276.         
  277.     case 'admin_view':
  278.     
  279.         if(!api_is_allowed_to_edit()){
  280.             api_not_allowed(true);
  281.         }
  282.         
  283.         if($debug>0error_log('New LP - admin_view action triggered',0);
  284.         
  285.         if(!$lp_found)error_log('New LP - No learnpath given for admin_view'0)require('lp_list.php')}
  286.         else
  287.         {
  288.             $_SESSION['refresh'1;
  289.             
  290.             require('lp_admin_view.php');
  291.         }
  292.         
  293.         break;
  294.     
  295.     case 'build':
  296.     
  297.         if(!api_is_allowed_to_edit()){
  298.             api_not_allowed(true);
  299.         }
  300.     
  301.         if($debug 0error_log('New LP - build action triggered'0);
  302.         
  303.         if(!$lp_found)error_log('New LP - No learnpath given for build'0)require('lp_list.php')}
  304.         else
  305.         {
  306.             $_SESSION['refresh'1;
  307.             
  308.             require('lp_build.php');
  309.         }
  310.         
  311.         break;
  312.         
  313.     case 'delete_item':
  314.     
  315.         if(!api_is_allowed_to_edit()){
  316.             api_not_allowed(true);
  317.         }
  318.         
  319.         if($debug 0error_log('New LP - delete item action triggered'0);
  320.         
  321.         if(!$lp_found)error_log('New LP - No learnpath given for delete item'0)require('lp_list.php')}
  322.         else
  323.         {
  324.             $_SESSION['refresh'1;
  325.             
  326.             if(is_numeric($_GET['id']))
  327.             {
  328.                 $_SESSION['oLP']->delete_item($_GET['id']);
  329.                 
  330.                 $is_success true;
  331.             }
  332.             
  333.             if(isset($_GET['view']&& $_GET['view'== 'build')
  334.             {
  335.                 require('lp_build.php');
  336.             }
  337.             else
  338.             {
  339.                 require('lp_admin_view.php');
  340.             }
  341.         }
  342.         
  343.         break;
  344.         
  345.     case 'edit_item':
  346.     
  347.         if(!api_is_allowed_to_edit()){
  348.             api_not_allowed(true);
  349.         }
  350.         
  351.         if($debug 0error_log('New LP - edit item action triggered'0);
  352.         
  353.         if(!$lp_found)error_log('New LP - No learnpath given for edit item'0)require('lp_list.php')}
  354.         else
  355.         {
  356.             $_SESSION['refresh'1;
  357.             
  358.             if(isset($_POST['submit_button']&& !empty($_POST['title']))
  359.             {
  360.                 $_SESSION['oLP']->edit_item($_GET['id']$_POST['parent']$_POST['previous']$_POST['title']$_POST['description']$_POST['prerequisites']);
  361.                 
  362.                 if(isset($_POST['content_lp']))
  363.                 {
  364.                     $_SESSION['oLP']->edit_document($_course);
  365.                 }
  366.                 
  367.                 $is_success true;
  368.             }
  369.             
  370.             if(isset($_GET['view']&& $_GET['view'== 'build')
  371.             {
  372.                 require('lp_edit_item.php');
  373.             }
  374.             else
  375.             
  376.                 require('lp_admin_view.php');
  377.             }
  378.         }
  379.         
  380.         break;
  381.     
  382.     case 'edit_item_prereq':
  383.     
  384.         if(!api_is_allowed_to_edit()){
  385.             api_not_allowed(true);
  386.         }
  387.         
  388.         if($debug 0error_log('New LP - edit item prereq action triggered'0);
  389.         
  390.         if(!$lp_found)error_log('New LP - No learnpath given for edit item prereq'0)require('lp_list.php')}
  391.         else
  392.         {
  393.             if(isset($_POST['submit_button']))
  394.             {
  395.                 $_SESSION['refresh'1;
  396.                 
  397.                 $_SESSION['oLP']->edit_item_prereq($_GET['id']$_POST['prerequisites']$_POST['min_' $_POST['prerequisites']]$_POST['max_' $_POST['prerequisites']]);
  398.             }
  399.             
  400.             require('lp_edit_item_prereq.php');
  401.         }
  402.         
  403.         break;
  404.         
  405.     case 'move_item':
  406.         
  407.         if(!api_is_allowed_to_edit()){
  408.             api_not_allowed(true);
  409.         }
  410.         
  411.         if($debug 0error_log('New LP - move item action triggered'0);
  412.         
  413.         if(!$lp_found)error_log('New LP - No learnpath given for move item'0)require('lp_list.php')}
  414.         else
  415.         {
  416.             $_SESSION['refresh'1;
  417.             
  418.             if(isset($_POST['submit_button']))
  419.             {
  420.                 $_SESSION['oLP']->edit_item($_GET['id']$_POST['parent']$_POST['previous']$_POST['title']$_POST['description']);
  421.                 
  422.                 $is_success true;
  423.             }
  424.             
  425.             if(isset($_GET['view']&& $_GET['view'== 'build')
  426.             {
  427.                 require('lp_move_item.php');
  428.             }
  429.             else
  430.             {
  431.                 $_SESSION['oLP']->move_item($_GET['id']$_GET['direction']);
  432.                 
  433.                 require('lp_admin_view.php');
  434.             }
  435.         }
  436.         
  437.         break;
  438.         
  439.     case 'view_item':
  440.     
  441.         if(!api_is_allowed_to_edit()){
  442.             api_not_allowed(true);
  443.         }        
  444.         
  445.         if($debug>0error_log('New LP - view_item action triggered'0);
  446.         
  447.         if(!$lp_found)error_log('New LP - No learnpath given for view item'0)require('lp_list.php')}
  448.         else
  449.         {
  450.             $_SESSION['refresh'1;
  451.             
  452.             require('lp_view_item.php');
  453.         }
  454.         
  455.         break;    
  456.         
  457.     case 'upload':
  458.         if(!api_is_allowed_to_edit()){
  459.             api_not_allowed(true);
  460.         }
  461.         if($debug>0error_log('New LP - upload action triggered',0);
  462.         $cwdir getcwd();
  463.         require('lp_upload.php');
  464.         //reinit current working directory as many functions in upload change it
  465.         chdir($cwdir);
  466.         require('lp_list.php');
  467.         break;
  468.     case 'export':
  469.         if(!api_is_allowed_to_edit()){
  470.             api_not_allowed(true);
  471.         }
  472.         if($debug>0error_log('New LP - export action triggered',0);
  473.         if(!$lp_found)error_log('New LP - No learnpath given for export',0)require('lp_list.php')}
  474.         else{
  475.             $_SESSION['oLP']->scorm_export();
  476.             exit();
  477.             //require('lp_list.php'); 
  478.         }
  479.         break;
  480.     case 'delete':
  481.         if(!api_is_allowed_to_edit()){
  482.             api_not_allowed(true);
  483.         }
  484.         if($debug>0error_log('New LP - delete action triggered',0);
  485.         if(!$lp_found)error_log('New LP - No learnpath given for delete',0)require('lp_list.php')}
  486.         else{
  487.             $_SESSION['refresh'1;
  488.             //remove lp from homepage if it is there
  489.             //$_SESSION['oLP']->toggle_visibility((int)$_GET['lp_id'],'i');
  490.             $_SESSION['oLP']->delete(null,(int)$_GET['lp_id'],'remove');
  491.             api_session_unregister('oLP');
  492.             require('lp_list.php');
  493.         }
  494.         break;
  495.     case 'toggle_visible'//change lp visibility (inside lp tool)
  496.         if(!api_is_allowed_to_edit()){
  497.             api_not_allowed(true);
  498.         }
  499.         if($debug>0error_log('New LP - visibility action triggered',0);
  500.         if(!$lp_found)error_log('New LP - No learnpath given for visibility',0)require('lp_list.php')}
  501.         else{
  502.             learnpath::toggle_visibility($_REQUEST['lp_id'],$_REQUEST['new_status']);
  503.             require('lp_list.php');
  504.         }
  505.         break;
  506.     case 'toggle_publish'//change lp published status (visibility on homepage)
  507.         if(!api_is_allowed_to_edit()){
  508.             api_not_allowed(true);
  509.         }
  510.         if($debug>0error_log('New LP - publish action triggered',0);
  511.         if(!$lp_found)error_log('New LP - No learnpath given for publish',0)require('lp_list.php')}
  512.         else{
  513.             learnpath::toggle_publish($_REQUEST['lp_id'],$_REQUEST['new_status']);
  514.             require('lp_list.php');
  515.         }
  516.         break;
  517.     case 'move_lp_up'//change lp published status (visibility on homepage)
  518.         if(!api_is_allowed_to_edit()){
  519.             api_not_allowed(true);
  520.         }
  521.         if($debug>0error_log('New LP - publish action triggered',0);
  522.         if(!$lp_found)
  523.         
  524.             error_log('New LP - No learnpath given for publish',0)
  525.             require('lp_list.php')
  526.         }
  527.         else
  528.         {
  529.             learnpath::move_up($_REQUEST['lp_id']);
  530.             require('lp_list.php');
  531.         }
  532.         break;
  533.     case 'move_lp_down'//change lp published status (visibility on homepage)
  534.         if(!api_is_allowed_to_edit()){
  535.             api_not_allowed(true);
  536.         }
  537.         if($debug>0error_log('New LP - publish action triggered',0);
  538.         if(!$lp_found)
  539.             error_log('New LP - No learnpath given for publish',0)
  540.             require('lp_list.php')
  541.         }
  542.         else
  543.         {
  544.             learnpath::move_down($_REQUEST['lp_id']);
  545.             require('lp_list.php');
  546.         }
  547.         break;
  548.     case 'edit':
  549.         if(!api_is_allowed_to_edit())
  550.         {
  551.             api_not_allowed(true);
  552.         }
  553.         if($debug>0error_log('New LP - edit action triggered',0);
  554.         if(!$lp_found)error_log('New LP - No learnpath given for edit',0)require('lp_list.php')}
  555.         else{
  556.             $_SESSION['refresh'1;
  557.             require('lp_edit.php');
  558.         }
  559.         break;
  560.     case 'update_lp':
  561.         if(!api_is_allowed_to_edit()){
  562.             api_not_allowed(true);
  563.         }
  564.         if($debug>0error_log('New LP - update_lp action triggered',0);
  565.         if(!$lp_found)error_log('New LP - No learnpath given for edit',0)require('lp_list.php')}
  566.         else{
  567.             $_SESSION['refresh'1;
  568.             $_SESSION['oLP']->set_name($_REQUEST['lp_name']);
  569.             $_SESSION['oLP']->set_encoding($_REQUEST['lp_encoding']);
  570.             $_SESSION['oLP']->set_maker($_REQUEST['lp_maker']);
  571.             $_SESSION['oLP']->set_proximity($_REQUEST['lp_proximity']);
  572.             $_SESSION['oLP']->set_theme($_REQUEST['lp_theme']);                
  573.             require('lp_list.php');
  574.         }    
  575.         break;
  576.     case 'add_sub_item'//add an item inside a chapter
  577.         if(!api_is_allowed_to_edit()){
  578.             api_not_allowed(true);
  579.         }
  580.         if($debug>0error_log('New LP - add sub item action triggered',0);
  581.         if(!$lp_found)error_log('New LP - No learnpath given for add sub item',0)require('lp_list.php')}
  582.         else{
  583.             $_SESSION['refresh'1;
  584.             if(!empty($_REQUEST['parent_item_id'])){
  585.                 $_SESSION['from_learnpath']='yes';
  586.                 $_SESSION['origintoolurl''lp_controller.php?action=admin_view&lp_id='.$_REQUEST['lp_id'];
  587.                 require('resourcelinker.php');
  588.                 //$_SESSION['oLP']->add_sub_item($_REQUEST['parent_item_id'],$_REQUEST['previous'],$_REQUEST['type'],$_REQUEST['path'],$_REQUEST['title']);
  589.             }else{
  590.                 require('lp_admin_view.php');
  591.             }
  592.         }
  593.         break;
  594.     case 'deleteitem':
  595.     case 'delete_item':
  596.         if(!api_is_allowed_to_edit()){
  597.             api_not_allowed(true);
  598.         }
  599.         if($debug>0error_log('New LP - delete item action triggered',0);
  600.         if(!$lp_found)error_log('New LP - No learnpath given for delete item',0)require('lp_list.php')}
  601.         else{
  602.             $_SESSION['refresh'1;
  603.             if(!empty($_REQUEST['id'])){
  604.                 $_SESSION['oLP']->delete_item($_REQUEST['id']);
  605.             }
  606.             require('lp_admin_view.php');
  607.         }
  608.         break;
  609.     case 'edititemprereq':
  610.     case 'edit_item_prereq':
  611.         if(!api_is_allowed_to_edit()){
  612.             api_not_allowed(true);
  613.         }
  614.         if($debug>0error_log('New LP - edit item prereq action triggered',0);
  615.         if(!$lp_found)error_log('New LP - No learnpath given for edit item prereq',0)require('lp_list.php')}
  616.         else{
  617.             if(!empty($_REQUEST['id']&& !empty($_REQUEST['submit_item'])){
  618.                 $_SESSION['refresh'1;
  619.                 $_SESSION['oLP']->edit_item_prereq($_REQUEST['id'],$_REQUEST['prereq']);
  620.             }
  621.             require('lp_admin_view.php');
  622.         }
  623.         break;
  624.     case 'restart':
  625.         if($debug>0error_log('New LP - restart action triggered',0);
  626.         if(!$lp_found)error_log('New LP - No learnpath given for restart',0)require('lp_list.php')}
  627.         else{
  628.             $_SESSION['oLP']->restart();
  629.             require('lp_view.php');
  630.         }
  631.         break;
  632.     case 'last':
  633.         if($debug>0error_log('New LP - last action triggered',0);
  634.         if(!$lp_found)error_log('New LP - No learnpath given for last',0)require('lp_list.php')}
  635.         else{
  636.             $_SESSION['oLP']->last();
  637.             require('lp_view.php');
  638.         }
  639.         break;
  640.     case 'first':
  641.         if($debug>0error_log('New LP - first action triggered',0);
  642.         if(!$lp_found)error_log('New LP - No learnpath given for first',0)require('lp_list.php')}
  643.         else{
  644.             $_SESSION['oLP']->first();
  645.             require('lp_view.php');
  646.         }
  647.         break;
  648.     case 'next':
  649.         if($debug>0error_log('New LP - next action triggered',0);
  650.         if(!$lp_found)error_log('New LP - No learnpath given for next',0)require('lp_list.php')}
  651.         else{
  652.             $_SESSION['oLP']->next();
  653.             require('lp_view.php');
  654.         }
  655.         break;
  656.     case 'previous':
  657.         if($debug>0error_log('New LP - previous action triggered',0);
  658.         if(!$lp_found)error_log('New LP - No learnpath given for previous',0)require('lp_list.php')}
  659.         else{
  660.             $_SESSION['oLP']->previous();
  661.             require('lp_view.php');
  662.         }
  663.         break;
  664.     case 'content':
  665.         if($debug>0error_log('New LP - content action triggered',0);
  666.         if($debug>0error_log('New LP - Item id is '.$_GET['item_id'],0);
  667.         if(!$lp_found)error_log('New LP - No learnpath given for content',0)require('lp_list.php')}
  668.         else{
  669.             $_SESSION['oLP']->save_last();
  670.             $_SESSION['oLP']->set_current_item($_GET['item_id'])
  671.             $_SESSION['oLP']->start_current_item();
  672.             require('lp_content.php')
  673.         }
  674.         break;    
  675.     case 'view':
  676.         if($debug 0)
  677.             error_log('New LP - view action triggered'0);
  678.         if(!$lp_found)
  679.         {
  680.             error_log('New LP - No learnpath given for view'0);
  681.             require('lp_list.php');
  682.         }
  683.         else
  684.         {
  685.             if($debug 0){error_log('New LP - Trying to set current item to ' $_REQUEST['item_id']0);}
  686.             $_SESSION['oLP']->set_current_item($_REQUEST['item_id']);
  687.             require('lp_view.php');
  688.         }
  689.         break;        
  690.     case 'save':
  691.         if($debug>0error_log('New LP - save action triggered',0);
  692.         if(!$lp_found)error_log('New LP - No learnpath given for save',0)require('lp_list.php')}
  693.         else{
  694.             $_SESSION['oLP']->save_item();
  695.             require('lp_save.php');
  696.         }
  697.         break;        
  698.     case 'stats':
  699.         if($debug>0error_log('New LP - stats action triggered',0);
  700.         if(!$lp_found)error_log('New LP - No learnpath given for stats',0)require('lp_list.php')}
  701.         else{
  702.             $_SESSION['oLP']->save_current();
  703.             $_SESSION['oLP']->save_last();
  704.             //declare variables to be used in lp_stats.php
  705.             $lp_id $_SESSION['oLP']->get_id();
  706.             $list $_SESSION['oLP']->get_flat_ordered_items_list($lp_id);
  707.             $user_id api_get_user_id();
  708.             $stats_charset $_SESSION['oLP']->encoding;
  709.             require('lp_stats.php');
  710.         }
  711.         break;
  712.     case 'list':
  713.         if($debug>0error_log('New LP - list action triggered',0);
  714.         if($lp_found){
  715.             $_SESSION['refresh'1;
  716.             $_SESSION['oLP']->save_last();
  717.         }
  718.         require('lp_list.php');
  719.         break;
  720.     case 'mode':
  721.         //switch between fullscreen and embedded mode
  722.         if($debug>0error_log('New LP - mode change triggered',0);
  723.         $mode $_REQUEST['mode'];
  724.         if($mode == 'fullscreen'){
  725.             $_SESSION['oLP']->mode 'fullscreen';
  726.         }else{
  727.             $_SESSION['oLP']->mode 'embedded';        
  728.         }
  729.         require('lp_view.php');
  730.         break;
  731.     case 'switch_view_mode':
  732.         if($debug>0error_log('New LP - switch_view_mode action triggered',0);
  733.         if(!$lp_found)error_log('New LP - No learnpath given for switch',0)require('lp_list.php')}
  734.         $_SESSION['refresh'1;
  735.         $_SESSION['oLP']->update_default_view_mode();        
  736.         require('lp_list.php');
  737.         break;
  738.     case 'switch_force_commit':
  739.         if($debug>0error_log('New LP - switch_force_commit action triggered',0);
  740.         if(!$lp_found)error_log('New LP - No learnpath given for switch',0)require('lp_list.php')}
  741.         $_SESSION['refresh'1;
  742.         $_SESSION['oLP']->update_default_scorm_commit();
  743.         require('lp_list.php');
  744.         break;
  745.     case 'switch_reinit':
  746.         if($debug>0error_log('New LP - switch_reinit action triggered',0);
  747.         if(!$lp_found)error_log('New LP - No learnpath given for switch',0)require('lp_list.php')}
  748.         $_SESSION['refresh'1;
  749.         $_SESSION['oLP']->update_reinit();
  750.         require('lp_list.php');
  751.         break;        
  752.     case 'switch_scorm_debug':
  753.         if($debug>0error_log('New LP - switch_scorm_debug action triggered',0);
  754.         if(!$lp_found)error_log('New LP - No learnpath given for switch',0)require('lp_list.php')}
  755.         $_SESSION['refresh'1;
  756.         $_SESSION['oLP']->update_scorm_debug();
  757.         require('lp_list.php');
  758.         break;        
  759.     case 'intro_cmdAdd':
  760.         if($debug>0error_log('New LP - intro_cmdAdd action triggered',0);
  761.         //add introduction section page
  762.         break;
  763.     case 'js_api_refresh':
  764.         if($debug>0error_log('New LP - js_api_refresh action triggered',0);
  765.         if(!$lp_found)error_log('New LP - No learnpath given for js_api_refresh',0)require('lp_message.php')}
  766.         if(isset($_REQUEST['item_id'])){
  767.             $htmlHeadXtra[$_SESSION['oLP']->get_js_info($_REQUEST['item_id']);
  768.         }
  769.         require('lp_message.php');
  770.         break;    
  771.     case 'return_to_course_homepage':
  772.         if(!$lp_found)error_log('New LP - No learnpath given for stats',0)require('lp_list.php')}
  773.         else{
  774.             $_SESSION['oLP']->save_current();
  775.             $_SESSION['oLP']->save_last();
  776.             //declare variables to be used in lp_stats.php
  777.             $lp_id $_SESSION['oLP']->get_id();
  778.             $list $_SESSION['oLP']->get_flat_ordered_items_list($lp_id);
  779.             $user_id api_get_user_id();
  780.             $stats_charset $_SESSION['oLP']->encoding;
  781.             header('location: ../course_home/course_home.php?'.api_get_cidreq());
  782.         }
  783.         break;        
  784.     default:
  785.         if($debug>0error_log('New LP - default action triggered',0);
  786.         //$_SESSION['refresh'] = 1;
  787.         require('lp_list.php');
  788.         break;
  789. }
  790. if(!empty($_SESSION['oLP'])){
  791.     $_SESSION['lpobject'serialize($_SESSION['oLP']);
  792.     if($debug>0error_log('New LP - lpobject is serialized in session',0);
  793. }
  794. ?>

Documentation generated on Thu, 12 Jun 2008 14:02:27 -0500 by phpDocumentor 1.4.1