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

Source for file lp_add_item.php

Documentation is available at lp_add_item.php

  1. <?php
  2. /*
  3. ============================================================================== 
  4.     Dokeos - elearning and course management software
  5.  
  6.     Copyright (c) 2004-2008 Dokeos SPRL
  7.     Copyright (c) 2003 Ghent University (UGent)
  8.     Copyright (c) 2001 Universite catholique de Louvain (UCL)
  9.     Copyright (c) Patrick Cool
  10.     Copyright (c) Denes Nagy
  11.     Copyright (c) Yannick Warnier
  12.     
  13.     For a full list of contributors, see "credits.txt".
  14.     The full license can be read in "license.txt".
  15.     
  16.     This program is free software; you can redistribute it and/or
  17.     modify it under the terms of the GNU General Public License
  18.     as published by the Free Software Foundation; either version 2
  19.     of the License, or (at your option) any later version.
  20.     
  21.     See the GNU General Public License for more details.
  22.     
  23.     Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  24.     Mail: info@dokeos.com
  25. ============================================================================== 
  26. */
  27. /**
  28. ============================================================================== 
  29. * This is a learning path creation and player tool in Dokeos - previously
  30. * learnpath_handler.php
  31. *
  32. @author Patrick Cool
  33. @author Denes Nagy
  34. @author Roan Embrechts, refactoring and code cleaning
  35. @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update
  36. @author Julio Montoya  - Improving the list of templates
  37. @package dokeos.learnpath
  38. ============================================================================== 
  39. */
  40.  
  41. /*
  42. ==============================================================================
  43.         INIT SECTION
  44. ==============================================================================
  45. */ 
  46. $this_section=SECTION_COURSES;
  47.  
  48.  
  49. /*
  50. -----------------------------------------------------------
  51.     Libraries
  52. -----------------------------------------------------------
  53. */ 
  54. //the main_api.lib.php, database.lib.php and display.lib.php
  55. //libraries are included by default
  56.  
  57. include('learnpath_functions.inc.php');
  58. //include('../resourcelinker/resourcelinker.inc.php');
  59. include('resourcelinker.inc.php');
  60. //rewrite the language file, sadly overwritten by resourcelinker.inc.php
  61. // name of the language file that needs to be included 
  62. $language_file "learnpath";
  63.  
  64. /*
  65. -----------------------------------------------------------
  66.     Header and action code
  67. -----------------------------------------------------------
  68. */ 
  69. $htmlHeadXtra['
  70. <script type="text/javascript">
  71.             
  72. function FCKeditor_OnComplete( editorInstance )
  73. {    
  74.     document.getElementById(\'frmModel\').innerHTML = "<iframe height=890px width=230px; frameborder=0 src=\''.api_get_path(WEB_LIBRARY_PATH).'fckeditor/editor/fckdialogframe.html \'>";    
  75. }    
  76.     
  77. function InnerDialogLoaded()
  78. {         
  79.     if (document.all)
  80.     {            
  81.         // if is iexplorer    
  82.         var B=new window.frames.content_lp___Frame.FCKToolbarButton(\'Templates\',window.content_lp___Frame.FCKLang.Templates);        
  83.     }
  84.     else
  85.     {        
  86.         var B=new window.frames[0].FCKToolbarButton(\'Templates\',window.frames[0].FCKLang.Templates);    
  87.     }                
  88.     
  89.     return     B.ClickFrame();    
  90. };     
  91.  
  92.         
  93. </script>';
  94.  
  95. $htmlHeadXtra[$_SESSION['oLP']->create_js();
  96. /*
  97. -----------------------------------------------------------
  98.     Constants and variables
  99. -----------------------------------------------------------
  100. */ 
  101. $is_allowed_to_edit api_is_allowed_to_edit();
  102.  
  103. $tbl_lp Database::get_course_table('lp');
  104. $tbl_lp_item Database::get_course_table('lp_item');
  105. $tbl_lp_view Database::get_course_table('lp_view');
  106.  
  107. $isStudentView  = (int) $_REQUEST['isStudentView'];
  108. $learnpath_id   = (int) $_REQUEST['lp_id'];
  109. $submit            $_POST['submit_button'];
  110. /*
  111. $chapter_id     = $_GET['chapter_id'];
  112. $title          = $_POST['title'];
  113. $description   = $_POST['description'];
  114. $Submititem     = $_POST['Submititem'];
  115. $action         = $_REQUEST['action'];
  116. $id             = (int) $_REQUEST['id'];
  117. $type           = $_REQUEST['type'];
  118. $direction      = $_REQUEST['direction'];
  119. $moduleid       = $_REQUEST['moduleid'];
  120. $prereq         = $_REQUEST['prereq'];
  121. $type           = $_REQUEST['type'];
  122. */
  123. /*
  124. ==============================================================================
  125.         MAIN CODE
  126. ==============================================================================
  127. */
  128. // using the resource linker as a tool for adding resources to the learning path
  129. if ($action=="add" and $type=="learnpathitem")
  130. {
  131.      $htmlHeadXtra["<script language='JavaScript' type='text/javascript'> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
  132. }
  133. if ( ($is_allowed_to_editor ($isStudentView) )
  134. {
  135.     error_log('New LP - User not authorized in lp_add_item.php');
  136.     header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  137. }
  138. //from here on, we are admin because of the previous condition, so don't check anymore
  139.  
  140. $sql_query "SELECT * FROM $tbl_lp WHERE id = $learnpath_id"
  141. $result=api_sql_query($sql_query);
  142. $therow=Database::fetch_array($result)
  143.  
  144. //$admin_output = '';
  145. /*
  146. -----------------------------------------------------------
  147.     Course admin section
  148.     - all the functions not available for students - always available in this case (page only shown to admin)
  149. -----------------------------------------------------------
  150. */ 
  151. /*==================================================
  152.             SHOWING THE ADMIN TOOLS
  153.  ==================================================*/
  154.  
  155. $interbreadcrumb[]array ("url"=>"lp_controller.php?action=list""name"=> get_lang("_learning_path"));
  156. $interbreadcrumb[]array ("url"=>api_get_self()."?action=build&lp_id=$learnpath_id""name" => stripslashes("{$therow['name']}"));
  157.  
  158. switch($_GET['type']){
  159.     case 'chapter':
  160.         $interbreadcrumb[]array ("url"=>"#""name" => get_lang("NewChapter"));
  161.     break;
  162.     default:
  163.         $interbreadcrumb[]array ("url"=>"#""name" => get_lang("NewStep"));
  164.     break;
  165. }
  166.  
  167. //Theme calls
  168. $show_learn_path=true;
  169. $lp_theme_css=$_SESSION['oLP']->get_theme();
  170.  
  171. Display::display_header(null,'Path');
  172. //api_display_tool_title($therow['name']);
  173.  
  174. $suredel trim(get_lang('AreYouSureToDelete'));
  175. //$suredelstep = trim(get_lang('AreYouSureToDeleteSteps'));
  176. ?>
  177. <script type='text/javascript'>
  178. /* <![CDATA[ */
  179. function stripslashes(str) {
  180.     str=str.replace(/\\'/g,'\'');
  181.     str=str.replace(/\\"/g,'"');
  182.     str=str.replace(/\\\\/g,'\\');
  183.     str=str.replace(/\\0/g,'\0');
  184.     return str;
  185. }
  186. function confirmation(name)
  187. {
  188.     name=stripslashes(name);    
  189.     if (confirm("<?php echo $suredel?> " + name + " ?"))
  190.     {
  191.         return true;
  192.     }
  193.     else
  194.     {
  195.         return false;
  196.     }    
  197. }
  198. </script>
  199. <?php
  200.  
  201. //echo $admin_output;
  202.  
  203. /*
  204. -----------------------------------------------------------
  205.     DISPLAY SECTION
  206. -----------------------------------------------------------
  207. */
  208. echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
  209.  
  210.     echo '<tr>';
  211.             
  212.         echo '<td class="tree">';
  213.         
  214.             echo '<p style="border-bottom:1px solid #999999; margin:0; padding:2px;">'.get_lang("Build").'&nbsp;&#124;&nbsp;<a href="' .api_get_self()'?cidReq=' $_GET['cidReq''&amp;action=admin_view&amp;lp_id=' $_SESSION['oLP']->lp_id '">'.get_lang("BasicOverview").'</a>&nbsp;&#124;&nbsp;<a href="lp_controller.php?cidReq='.$_GET['cidReq'].'&action=view&lp_id='.$_SESSION['oLP']->lp_id.'">'.get_lang("Display").'</a></p>';
  215.             
  216.             //links for adding a module, chapter or step
  217.             echo '<div class="lp_actions">';                
  218.                 echo '<p class="lp_action">';                
  219.                     echo '<a href="' .api_get_self()'?cidReq=' $_GET['cidReq''&amp;action=add_item&amp;type=chapter&amp;lp_id=' $_SESSION['oLP']->lp_id '" title="'.get_lang("NewChapter").'"><img align="left" alt="'.get_lang("NewChapter").'" src="../img/lp_dokeos_chapter_add.png" title="'.get_lang("NewChapter").'" />'.get_lang("NewChapter").'</a>';                        
  220.                 echo '</p>';
  221.                 echo '<p class="lp_action">';
  222.                 
  223.                     echo '<a href="' .api_get_self()'?cidReq=' $_GET['cidReq''&amp;action=add_item&amp;type=step&amp;lp_id=' $_SESSION['oLP']->lp_id '" title="'.get_lang("NewStep").'"><img align="left" alt="'.get_lang("NewStep").'" src="../img/lp_dokeos_step_add.png" title="'.get_lang("NewStep").'" />'.get_lang("NewStep").'</a>';
  224.                 
  225.                 echo '</p>';
  226.                 
  227.             echo '</div>';
  228.             
  229.             echo '<div class="lp_tree" style="height:250px">';                    
  230.                 //build the tree with the menu items in it
  231.                 echo $_SESSION['oLP']->build_tree();            
  232.             echo '</div>';
  233.             
  234.             // show the template list 
  235.             if ($_GET['type']=='document')
  236.             {
  237.                 echo '<p style="border-bottom:1px solid #999999; margin:0; padding:2px;"></p>'//line                    
  238.                 echo '<br>';            
  239.                 echo '<div id="frmModel" style="display:block; height:890px;width:100px; position:relative;"></div>';
  240.             }
  241.                             
  242.             
  243.         echo '</td>';
  244.         echo '<td class="workspace">';
  245.         
  246.             if(isset($new_item_id&& is_numeric($new_item_id))
  247.             {
  248.                 switch($_GET['type'])
  249.                 {
  250.                     
  251.                     case 'chapter':
  252.                         
  253.                         echo $_SESSION['oLP']->display_manipulate($new_item_id$_GET['type']);
  254.                         
  255.                         echo '<div class="lp_message" style="margin:3px 10px;">';
  256.                         
  257.                             echo get_lang("NewChapterCreated");
  258.                         
  259.                         echo '</div>';
  260.                         
  261.                         break;
  262.                         
  263.                     case TOOL_LINK:
  264.                         
  265.                         echo $_SESSION['oLP']->display_manipulate($new_item_id$_GET['type']);
  266.                         
  267.                         echo '<div class="lp_message" style="margin:3px 10px;">';
  268.                         
  269.                             echo get_lang("NewLinksCreated");
  270.                         
  271.                         echo '</div>';
  272.                         
  273.                         break;
  274.                     
  275.                     case TOOL_STUDENTPUBLICATION:
  276.                         
  277.                         echo $_SESSION['oLP']->display_manipulate($new_item_id$_GET['type']);
  278.                         
  279.                         echo '<div class="lp_message" style="margin:3px 10px;">';
  280.                         
  281.                             echo get_lang("NewStudentPublicationCreated");
  282.                         
  283.                         echo '</div>';
  284.                         
  285.                         break;
  286.                         
  287.                     case 'module':
  288.                         
  289.                         echo $_SESSION['oLP']->display_manipulate($new_item_id$_GET['type']);
  290.                         
  291.                         echo '<div class="lp_message" style="margin:3px 10px;">';
  292.                         
  293.                             echo get_lang("NewModuleCreated");
  294.                         
  295.                         echo '</div>';
  296.                         
  297.                         break;
  298.                         
  299.                     case TOOL_QUIZ:
  300.                     
  301.                         echo $_SESSION['oLP']->display_manipulate($new_item_id$_GET['type']);
  302.                         
  303.                         echo '<div class="lp_message" style="margin:3px 10px;">';
  304.                         
  305.                             echo get_lang("NewExerciseCreated");
  306.                         
  307.                         echo '</div>';
  308.                         
  309.                         break;
  310.                     
  311.                     
  312.                     case TOOL_DOCUMENT:
  313.                         
  314.                         $msg '<div class="lp_message" style="margin-bottom:10px;">';
  315.                         
  316.                             $msg .= get_lang("NewDocumentCreated");
  317.                         
  318.                         $msg .= '</div>';
  319.                         
  320.                         echo $_SESSION['oLP']->display_item($new_item_idtrue$msg);
  321.                         
  322.                         break;
  323.                         
  324.                         
  325.                     case TOOL_FORUM:
  326.                         echo $_SESSION['oLP']->display_manipulate($new_item_id$_GET['type']);
  327.                         
  328.                         echo '<div class="lp_message" style="margin:3px 10px;">';
  329.                         
  330.                             echo get_lang("NewForumCreated");
  331.                         
  332.                         echo '</div>';
  333.                         
  334.                         break;
  335.                     
  336.                     
  337.                     case 'thread':
  338.                         echo $_SESSION['oLP']->display_manipulate($new_item_id$_GET['type']);
  339.                         
  340.                         echo '<div class="lp_message" style="margin:3px 10px;">';
  341.                         
  342.                             echo get_lang("NewThreadCreated");
  343.                         
  344.                         echo '</div>';
  345.                         
  346.                         break;
  347.                     
  348.                 }
  349.             }
  350.             else
  351.             {
  352.                 switch($_GET['type'])
  353.                 {
  354.                     case 'chapter':
  355.                         
  356.                         echo $_SESSION['oLP']->display_item_form($_GET['type']get_lang("EnterDataNewChapter"));
  357.                         
  358.                         break;
  359.                         
  360.                     case 'module':
  361.                     
  362.                         echo $_SESSION['oLP']->display_item_form($_GET['type']get_lang("EnterDataNewModule"));
  363.                         
  364.                         break;
  365.                         
  366.                     case 'document'
  367.                         
  368.                         if(isset($_GET['file']&& is_numeric($_GET['file']))
  369.                         {
  370.                             echo $_SESSION['oLP']->display_document_form('add'0$_GET['file']);
  371.                         }
  372.                         else
  373.                         {
  374.                             echo $_SESSION['oLP']->display_document_form('add'0);
  375.                         }
  376.                         
  377.                         break;
  378.                     
  379.                     case 'hotpotatoes':
  380.                     
  381.                         echo $_SESSION['oLP']->display_hotpotatoes_form('add'0$_GET['file']);
  382.  
  383.                         break;
  384.                     
  385.                     case 'quiz':
  386.                         
  387.                         echo $_SESSION['oLP']->display_quiz_form('add'0$_GET['file']);
  388.                         
  389.                         break;
  390.                         
  391.                     case 'forum':
  392.                         
  393.                         echo $_SESSION['oLP']->display_forum_form('add'0$_GET['forum_id']);
  394.                         
  395.                         break;
  396.                         
  397.                     case 'thread':
  398.                         
  399.                         echo $_SESSION['oLP']->display_thread_form('add'0$_GET['thread_id']);
  400.                         
  401.                         break;
  402.                     
  403.                     case 'link':
  404.                         
  405.                         echo $_SESSION['oLP']->display_link_form('add'0$_GET['file']);
  406.                         
  407.                         break;
  408.                         
  409.                     case 'student_publication':
  410.                         
  411.                         echo $_SESSION['oLP']->display_student_publication_form('add'0$_GET['file']);
  412.                         
  413.                         break;
  414.                         
  415.                     case 'step':
  416.                         
  417.                         echo $_SESSION['oLP']->display_resources();
  418.                         
  419.                         break;
  420.                 }
  421.             }
  422.         
  423.         echo '</td>';
  424.             
  425.     echo '</tr>';
  426.         
  427. echo '</table>';
  428.  
  429. /*
  430. ==============================================================================
  431.         FOOTER 
  432. ==============================================================================
  433. */ 
  434. ?>

Documentation generated on Thu, 12 Jun 2008 14:01:35 -0500 by phpDocumentor 1.4.1