jmontoyaa 8 年 前
コミット
f909086d01
4 ファイル変更87 行追加96 行削除
  1. 36 43
      main/lp/lp_add_item.php
  2. 13 8
      main/lp/lp_admin_view.php
  3. 29 33
      main/lp/lp_controller.php
  4. 9 12
      main/lp/lp_list.php

+ 36 - 43
main/lp/lp_add_item.php

@@ -17,58 +17,51 @@ $this_section = SECTION_COURSES;
 
 api_protect_course_script();
 
-include 'learnpath_functions.inc.php';
-include 'resourcelinker.inc.php';
+require_once 'learnpath_functions.inc.php';
+require_once 'resourcelinker.inc.php';
+
 /** @var learnpath $learnPath */
 $learnPath = $_SESSION['oLP'];
 
 $htmlHeadXtra[] = '<script>'.
+$learnPath->get_js_dropdown_array()."
+function load_cbo(id) {
+    if (!id) {
+        return false;
+    }
 
-$learnPath->get_js_dropdown_array() .
-"
-    function load_cbo(id) {
-        if (!id) {
-            return false;
-        }
-
-        var cbo = document.getElementById('previous');
-
-        for(var i = cbo.length - 1; i > 0; i--) {
-            cbo.options[i] = null;
-        }
-
-        var k=0;
+    var cbo = document.getElementById('previous');
+    for(var i = cbo.length - 1; i > 0; i--) {
+        cbo.options[i] = null;
+    }
 
-        for(var i = 1; i <= child_name[id].length; i++){
-            var option = new Option(child_name[id][i - 1], child_value[id][i - 1]);
-            option.style.paddingLeft = '40px';
+    var k=0;
+    for(var i = 1; i <= child_name[id].length; i++){
+        var option = new Option(child_name[id][i - 1], child_value[id][i - 1]);
+        option.style.paddingLeft = '40px';
+        cbo.options[i] = option;
+        k = i;
+    }
 
-            cbo.options[i] = option;
-            k = i;
-        }
+    cbo.options[k].selected = true;
+    $('#previous').selectpicker('refresh');
+}
 
-        cbo.options[k].selected = true;
-        $('#previous').selectpicker('refresh');
-    }
-" .
-'
 $(function() {
-    if ($(\'#previous\')) {
-        if(\'parent is\'+$(\'#idParent\').val()) {
-            load_cbo($(\'#idParent\').val());
+    if ($('#previous')) {
+        if('parent is'+$('#idParent').val()) {
+            load_cbo($('#idParent').val());
         }
     }
-    $(\'.lp_resource_element\').click(function() {
-        window.location.href = $(\'a\', this).attr(\'href\');
+    $('.lp_resource_element').click(function() {
+        window.location.href = $('a', this).attr('href');
     });
+    
+     CKEDITOR.on('instanceReady', function (e) {
+        showTemplates('content_lp');
+    });    
 });
-
-$(document).on("ready", function() {
-    CKEDITOR.on("instanceReady", function (e) {
-        showTemplates("content_lp");
-    });
-});
-</script>';
+</script>";
 
 /* Constants and variables */
 
@@ -83,7 +76,7 @@ $action = isset($_GET['action']) ? $_GET['action'] : null;
 if ($action == 'add' && $type == 'learnpathitem') {
      $htmlHeadXtra[] = "<script type='text/javascript'> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
 }
-if ((!$is_allowed_to_edit)) {
+if (!$is_allowed_to_edit) {
     error_log('New LP - User not authorized in lp_add_item.php');
     header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
     exit;
@@ -183,14 +176,14 @@ $(document).ready(function() {
         if ($("#doc_form").is(".col-md-8")) {
             $("#doc_form").removeClass("col-md-8");
             $("#doc_form").addClass("col-md-11");
-            
+
             $("#lp_sidebar").removeClass("col-md-4");
             $("#lp_sidebar").addClass("hide");
-            
+
         } else {
             $("#doc_form").removeClass("col-md-11");
             $("#doc_form").addClass("col-md-8");
-            
+
             $("#lp_sidebar").removeClass("hide");
             $("#lp_sidebar").addClass("col-md-4");
         }

+ 13 - 8
main/lp/lp_admin_view.php

@@ -11,10 +11,6 @@
  * @package chamilo.learnpath
 */
 
-/**
- * INIT SECTION
- */
-
 $this_section = SECTION_COURSES;
 
 api_protect_course_script();
@@ -28,7 +24,7 @@ include 'resourcelinker.inc.php';
 
 $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
 
-$tbl_lp      = Database::get_course_table(TABLE_LP_MAIN);
+$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
 $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
 
 $isStudentView = isset($_REQUEST['isStudentView']) ? (int)$_REQUEST['isStudentView'] : null;
@@ -141,7 +137,18 @@ if (isset($_POST['save_audio'])) {
             }
 
             // Upload the file in the documents tool.
-            $file_path = handle_uploaded_document($_course, $_FILES[$key], api_get_path(SYS_COURSE_PATH).$_course['path'].'/document','/audio', api_get_user_id(), '', '', '', '', false);
+            $file_path = handle_uploaded_document(
+                $_course,
+                $_FILES[$key],
+                api_get_path(SYS_COURSE_PATH).$_course['path'].'/document',
+                '/audio',
+                api_get_user_id(),
+                '',
+                '',
+                '',
+                '',
+                false
+            );
 
             // Getting the filename only.
             $file_components = explode('/', $file_path);
@@ -161,12 +168,10 @@ if (isset($_POST['save_audio'])) {
 }
 
 Display::display_header(null, 'Path');
-
 $suredel = trim(get_lang('AreYouSureToDeleteJS'));
 
 ?>
 <script>
-
 var newOrderData= "";
 //source code found in http://www.swartzfager.org/blog/dspNestedList.cfm
 

+ 29 - 33
main/lp/lp_controller.php

@@ -32,8 +32,8 @@ $glossaryExtraTools = api_get_setting('show_glossary_in_extra_tools');
 $showGlossary = in_array($glossaryExtraTools, array('true', 'lp', 'exercise_and_lp'));
 
 if ($showGlossary) {
-    if (api_get_setting('show_glossary_in_documents') == 'ismanual' ||
-        api_get_setting('show_glossary_in_documents') == 'isautomatic'
+    if (api_get_setting('show_glossary_in_documents') === 'ismanual' ||
+        api_get_setting('show_glossary_in_documents') === 'isautomatic'
     ) {
         $htmlHeadXtra[] = '<script>
     <!--
@@ -52,30 +52,12 @@ function setFocus(){
 $(window).load(function () {
     setFocus();
 });
-</script>
-<style>
-form .label {
-    padding: 1px 3px 2px;
-    font-size: 100%;
-    font-weight: normal;
-    color: #ffffff;
-    text-transform: none;
-    background: none;
-    border-radius: unset;
-    color: #404040;
-    float: left;
-    line-height: 18px;
-    padding-top: 6px;
-    text-align: right;
-    width: 150px;
-    text-shadow:none;
-}
-</style>';
+</script>';
 $ajax_url = api_get_path(WEB_AJAX_PATH).'lp.ajax.php';
 $htmlHeadXtra[] = '
 <script>
     /*
-    Script to manipuplate Learning Path items with Drag and drop
+    Script to manipulate Learning Path items with Drag and drop
      */
     var newOrderData = "";
     var lptree_debug = "";  // for debug
@@ -169,7 +151,6 @@ $htmlHeadXtra[] = '
                     }
                 );
             },
-
             receive: function(event, ui) {
                 var id = $(ui.item).attr("data_id");
                 var type = $(ui.item).attr("data_type");
@@ -214,15 +195,12 @@ $htmlHeadXtra[] = '
         });
         processReceive = false;
     });
-</script>
-';
+</script>';
 
 $session_id = api_get_session_id();
-
 api_protect_course_script(true);
 
 $lpfound = false;
-
 $myrefresh = 0;
 $myrefresh_id = 0;
 
@@ -298,22 +276,38 @@ if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $
                         if ($debug > 0) error_log('New LP - found row - type dokeos - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
 
                         $oLP = new learnpath(api_get_course_id(), $lp_id, api_get_user_id());
-                        if ($oLP !== false) { $lp_found = true; } else { error_log($oLP->error, 0); }
+                        if ($oLP !== false) {
+                            $lp_found = true;
+                        } else {
+                            error_log($oLP->error, 0);
+                        }
                         break;
                     case 2:
                         if ($debug > 0) error_log('New LP - found row - type scorm - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
                         $oLP = new scorm(api_get_course_id(), $lp_id, api_get_user_id());
-                        if ($oLP !== false) { $lp_found = true; } else { error_log($oLP->error, 0); }
+                        if ($oLP !== false) {
+                            $lp_found = true;
+                        } else {
+                            error_log($oLP->error, 0);
+                        }
                         break;
                     case 3:
                         if ($debug > 0) error_log('New LP - found row - type aicc - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
                         $oLP = new aicc(api_get_course_id(), $lp_id, api_get_user_id());
-                        if ($oLP !== false) { $lp_found = true; } else { error_log($oLP->error, 0); }
+                        if ($oLP !== false) {
+                            $lp_found = true;
+                        } else {
+                            error_log($oLP->error, 0);
+                        }
                         break;
                     default:
                         if ($debug > 0) error_log('New LP - found row - type other - Calling constructor with '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id(), 0);
                         $oLP = new learnpath(api_get_course_id(), $lp_id, api_get_user_id());
-                        if ($oLP !== false) { $lp_found = true; } else { error_log($oLP->error, 0); }
+                        if ($oLP !== false) {
+                            $lp_found = true;
+                        } else {
+                            error_log($oLP->error, 0);
+                        }
                         break;
                 }
             }
@@ -337,7 +331,7 @@ if (isset($_SESSION['oLP'])) {
 }
 
 if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') {
-    if ($_REQUEST['action'] != 'list' AND $_REQUEST['action'] != 'view') {
+    if ($_REQUEST['action'] != 'list' && $_REQUEST['action'] != 'view') {
         if (!empty($_REQUEST['lp_id'])) {
             $_REQUEST['action'] = 'view';
         } else {
@@ -368,7 +362,6 @@ $redirectTo = null;
 
 switch ($action) {
     case 'add_item':
-
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);
         }
@@ -684,6 +677,8 @@ switch ($action) {
                 }
                 $is_success = true;
 
+                Display::addFlash(Display::return_message(get_lang('Updated')));
+
                 $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
                 header('Location: '.$url);
                 exit;
@@ -1453,4 +1448,5 @@ if (!empty($_SESSION['oLP'])) {
 
 if (!empty($redirectTo)) {
     header("Location: $redirectTo");
+    exit;
 }

+ 9 - 12
main/lp/lp_list.php

@@ -27,25 +27,24 @@ $baseWordDir = $courseDir;
  * Display initialisation and security checks
  */
 // Extra javascript functions for in html head:
-$htmlHeadXtra[] =
-    "<script>
+$htmlHeadXtra[] = "<script>
 function confirmation(name) {
-    if (confirm(\" ".trim(get_lang('AreYouSureToDeleteJS'))." \"+name+\"?\"))
-        {return true;}
-    else
-        {return false;}
+    if (confirm(\" ".trim(get_lang('AreYouSureToDeleteJS'))." \"+name+\"?\")) {
+        return true;
+    } else {
+        return false;
+    }
 }
 </script>";
 $nameTools = get_lang('LearningPaths');
 Event::event_access_tool(TOOL_LEARNPATH);
-
 api_protect_course_script();
 
 /**
  * Display
  */
 /* Require the search widget and prepare the header with its stuff. */
-if (api_get_setting('search_enabled') == 'true') {
+if (api_get_setting('search_enabled') === 'true') {
     require api_get_path(LIBRARY_PATH).'search/search_widget.php';
     search_widget_prepare($htmlHeadXtra);
 }
@@ -101,7 +100,7 @@ if ($is_allowed_to_edit) {
         '../upload/index.php?'.api_get_cidreq().'&curdirpath=/&tool='.TOOL_LEARNPATH
     );
 
-    if (api_get_setting('service_ppt2lp', 'active') == 'true') {
+    if (api_get_setting('service_ppt2lp', 'active') === 'true') {
         $actions .= Display::url(
             Display::return_icon('import_powerpoint.png', get_lang('PowerPointConvert'), '', ICON_SIZE_MEDIUM),
             '../upload/upload_ppt.php?'.api_get_cidreq().'&curdirpath=/&tool='.TOOL_LEARNPATH
@@ -112,7 +111,6 @@ if ($is_allowed_to_edit) {
 $token = Security::get_token();
 
 /* DISPLAY SCORM LIST */
-
 $categoriesTempList = learnpath::getCategories(api_get_course_int_id());
 $categoryTest = new CLpCategory();
 $categoryTest->setId(0);
@@ -120,7 +118,7 @@ $categoryTest->setName(get_lang('WithOutCategory'));
 $categoryTest->setPosition(0);
 
 $categories = array(
-    $categoryTest,
+    $categoryTest
 );
 
 if (!empty($categoriesTempList)) {
@@ -142,7 +140,6 @@ foreach ($categories as $item) {
 
     if (!$is_allowed_to_edit) {
         $users = $item->getUsers();
-
         if (!empty($users) && $users->count() > 0) {
             if (!$item->hasUserAdded($user)) {
                 continue;