Browse Source

Merge branch '1.9.x' of github.com:chamilo/chamilo-lms into 1.9.x

Yannick Warnier 10 years ago
parent
commit
0151b51798

+ 2 - 2
custompages/index-unlogged.php

@@ -102,12 +102,12 @@ $rootWeb = api_get_path('WEB_PATH');
 			<div id="links">
 
                 <?php if (api_get_setting('allow_registration') === 'true') { ?>
-                <a href="<?php echo api_get_path(WEB_PATH); ?>main/auth/inscription.php">
+                <a href="<?php echo api_get_path(WEB_PATH); ?>main/auth/inscription.php?language=<?php echo api_get_interface_language(); ?>">
                     <?php echo custompages_get_lang('langReg')?>
                 </a><br />
                 <?php } ?>
 
-                <a href="<?php echo api_get_path(WEB_PATH); ?>main/auth/lostPassword.php">
+                <a href="<?php echo api_get_path(WEB_PATH); ?>main/auth/lostPassword.php?language=<?php echo api_get_interface_language(); ?>">
                     <?php echo custompages_get_lang('langLostPassword')?>
                 </a>
 			</div>

+ 31 - 37
main/admin/add_many_session_to_category.php

@@ -15,7 +15,7 @@ require_once api_get_path(LIBRARY_PATH).'add_many_session_to_category_functions.
 require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
 
 $xajax = new xajax();
-$xajax -> registerFunction ('search_courses');
+$xajax->registerFunction('search_courses');
 
 // setting the section (for the tabs)
 $this_section = SECTION_PLATFORM_ADMIN;
@@ -36,12 +36,12 @@ $tbl_session_rel_course				= Database::get_main_table(TABLE_MAIN_SESSION_COURSE)
 $tbl_course							= Database::get_main_table(TABLE_MAIN_COURSE);
 
 // setting the name of the tool
-$tool_name= get_lang('SubscribeSessionsToCategory');
-$id_session=intval($_GET['id_session']);
+$tool_name = get_lang('SubscribeSessionsToCategory');
+$id_session = isset($_GET['id_session']) ? intval($_GET['id_session']) : null;
 
 $add_type = 'multiple';
-if(isset($_GET['add_type']) && $_GET['add_type']!=''){
-	$add_type = Security::remove_XSS($_REQUEST['add_type']);
+if (isset($_GET['add_type']) && $_GET['add_type'] != '') {
+    $add_type = Security::remove_XSS($_REQUEST['add_type']);
 }
 
 if (!api_is_platform_admin() && !api_is_session_admin()) {
@@ -90,17 +90,24 @@ $formSent = 0;
 $errorMsg = $firstLetterCourse = $firstLetterSession = '';
 $CourseList = $SessionList = array();
 $courses = $sessions = array();
-$Categoryid = isset($_POST['CategorySessionId']) ? intval($_POST['CategorySessionId']) : null;
+$categoryId = isset($_POST['CategorySessionId']) ? intval($_POST['CategorySessionId']) : null;
 
 if (isset($_POST['formSent']) && $_POST['formSent']) {
     $formSent = $_POST['formSent'];
-    $SessionCategoryList = $_POST['SessionCategoryList'];
+    $sessionCategoryList = $_POST['SessionCategoryList'];
 
-    if ($Categoryid != 0 && count($SessionCategoryList) > 0) {
-        $session_id = join(',', $SessionCategoryList);
-        $sql = "UPDATE $tbl_session SET session_category_id = $Categoryid WHERE id in ($session_id) ";
+
+    if ($categoryId != 0 && count($sessionCategoryList) > 0) {
+        // Removing all
+        $sql = "UPDATE $tbl_session SET session_category_id = '' WHERE session_category_id = $categoryId";
+        Database::query($sql);
+        // Adding new
+        $sessionCategoryList = array_map('intval', $sessionCategoryList);
+        $session_id = join(',', $sessionCategoryList);
+
+        $sql = "UPDATE $tbl_session SET session_category_id = $categoryId WHERE id in ($session_id) ";
         Database::query($sql);
-        header('Location: add_many_session_to_category.php?id_category=' . $Categoryid . '&msg=ok');
+        header('Location: add_many_session_to_category.php?id_category=' . $categoryId . '&msg=ok');
         exit;
     } else {
         header('Location: add_many_session_to_category.php?msg=error');
@@ -109,7 +116,7 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
 }
 
 if (isset($_GET['id_category'])) {
-    $Categoryid = intval($_GET['id_category']);
+    $categoryId = intval($_GET['id_category']);
 }
 
 if (isset($_GET['msg']) && $_GET['msg'] == 'error') {
@@ -121,15 +128,15 @@ if (isset($_GET['msg']) && $_GET['msg'] == 'ok') {
 }
 
 $page = isset($_GET['page']) ? Security::remove_XSS($_GET['page']) : null;
-// display the dokeos header
+
 Display::display_header($tool_name);
 
 $where = '';
 $rows_category_session = array();
 if ((isset($_POST['CategorySessionId']) && $_POST['formSent'] == 0) || isset($_GET['id_category'])) {
 
-    $where = 'WHERE session_category_id !=' . $Categoryid;
-    $sql = 'SELECT id, name  FROM ' . $tbl_session . ' WHERE session_category_id =' . $Categoryid . ' ORDER BY name';
+    $where = 'WHERE session_category_id !=' . $categoryId;
+    $sql = 'SELECT id, name  FROM ' . $tbl_session . ' WHERE session_category_id =' . $categoryId . ' ORDER BY name';
     $result = Database::query($sql);
     $rows_category_session = Database::store_result($result);
 }
@@ -147,7 +154,7 @@ if (api_get_multiple_access_url()) {
     $sql = "SELECT s.id, s.name  FROM $tbl_session s INNER JOIN $table_access_url_rel_session u ON s.id = u.session_id $where AND u.access_url_id = $access_url_id ORDER BY name";
 } else {
     $sql = "SELECT id, name  FROM $tbl_session $where ORDER BY name";
-} 
+}
 $result=Database::query($sql);
 $rows_session = Database::store_result($result);
 ?>
@@ -167,10 +174,10 @@ if(!empty($OkMsg)) {
 	Display::display_confirmation_message($OkMsg); //main API
 }
 
-/* 
- * 
- * The a/b/c Filter is not a priority 
- *  
+/*
+ *
+ * The a/b/c Filter is not a priority
+ *
  * <td width="45%" align="center">
  <?php echo get_lang('FirstLetterCourse'); ?> :
      <select name="firstLetterCourse" onchange = "xajax_search_courses(this.value,'multiple')">
@@ -188,14 +195,14 @@ if(!empty($OkMsg)) {
 <tr>
 	<td align="left"></td>
 	<td align="left"></td>
-	<td  align="center"> 
+	<td  align="center">
 	<b><?php echo get_lang('SessionCategoryName') ?> :</b><br />
 	<select name="CategorySessionId" style="width: 320px;" onchange="javascript:send();" >
 		<option value="0" ></option>
 		<?php
 		if (!empty($rows_session_category)) {
     		foreach($rows_session_category as $category) {
-    			if($category['id'] == $Categoryid)
+    			if($category['id'] == $categoryId)
       				echo '<option value="'.$category['id'].'" selected>'.$category['name'].'</option>';
       			else
       				echo '<option value="'.$category['id'].'">'.$category['name'].'</option>';
@@ -228,19 +235,9 @@ if(!empty($OkMsg)) {
 <?php unset($nosessionCourses); ?>
   </td>
   <td width="10%" valign="middle" align="center">
-  <?php
-  if ($ajax_search) {
-  ?>
-  	<button class="arrowl" type="button" onclick="remove_item(document.getElementById('destination'))"></button>
-  <?php
-  } else {
-  ?>
   	<button class="arrowr" type="button" onclick="moveItem(document.getElementById('origin'), document.getElementById('destination'))" onclick="moveItem(document.getElementById('origin'), document.getElementById('destination'))"></button>
 	<br /><br />
 	<button class="arrowl" type="button" onclick="moveItem(document.getElementById('destination'), document.getElementById('origin'))" onclick="moveItem(document.getElementById('destination'), document.getElementById('origin'))"></button>
-  <?php
-  }
-  ?>
 	<br /><br /><br /><br /><br /><br />
 	<?php
 		echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('SubscribeSessionsToCategory').'</button>';
@@ -258,7 +255,6 @@ if(!empty($OkMsg)) {
 
 </form>
 <script type="text/javascript">
-<!--
 function moveItem(origin , destination) {
 	for(var i = 0 ; i<origin.options.length ; i++) {
 		if(origin.options[i].selected) {
@@ -302,9 +298,7 @@ function valide(){
 
 	document.forms.formulaire.submit();
 }
--->
-
 </script>
 <?php
-/*		FOOTER	*/
-Display::display_footer();
+
+Display::display_footer();

+ 3 - 1
main/admin/course_import.php

@@ -72,6 +72,7 @@ function validate_data($courses)
             }
         }
     }
+
     return $errors;
 }
 
@@ -80,12 +81,13 @@ function getTeacherListInArray($teachers)
     if (!empty($teachers)) {
         return explode('|', $teachers);
     }
+
     return array();
 }
 
 /**
  * Saves imported data.
- * @param array   List of courses
+ * @param array $courses List of courses
  */
 function save_data($courses)
 {

+ 48 - 29
main/admin/session_category_edit.php

@@ -4,27 +4,31 @@
  * Edition script for sessions categories
  * @package chamilo.admin
  */
-/**
- * Code
- */
 
 // name of the language file that needs to be included
 $language_file ='admin';
-$cidReset=true;
+$cidReset = true;
 require_once '../inc/global.inc.php';
 
 // setting the section (for the tabs)
-$this_section=SECTION_PLATFORM_ADMIN;
+$this_section = SECTION_PLATFORM_ADMIN;
 api_protect_admin_script(true);
-$id=intval($_GET['id']);
-$formSent=0;
-$errorMsg='';
+$id = intval($_GET['id']);
+$formSent = 0;
+$errorMsg = '';
 
 // Database Table Definitions
 $tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
 $tool_name = get_lang('EditSessionCategory');
-$interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin'));
-$interbreadcrumb[]=array('url' => "session_category_list.php","name" => get_lang('ListSessionCategory'));
+$interbreadcrumb[] = array(
+    'url' => 'index.php',
+    "name" => get_lang('PlatformAdmin')
+);
+$interbreadcrumb[] = array(
+    'url' => "session_category_list.php",
+    "name" => get_lang('ListSessionCategory')
+);
+
 $sql = "SELECT * FROM $tbl_session_category WHERE id='".$id."' ORDER BY name";
 $result=Database::query($sql);
 if (!$infos=Database::fetch_array($result)) {
@@ -38,24 +42,38 @@ if (!api_is_platform_admin() && $infos['session_admin_id']!=$_user['user_id'] &&
 	api_not_allowed(true);
 }
 
-if ($_POST['formSent']) {
-	$formSent=1;
-	$name= $_POST['name'];
-	$year_start= $_POST['year_start'];
-	$month_start=$_POST['month_start'];
-	$day_start=$_POST['day_start'];
-	$year_end=$_POST['year_end'];
-	$month_end=$_POST['month_end'];
-	$day_end=$_POST['day_end'];
-	$return = SessionManager::edit_category_session($id, $name, $year_start, $month_start, $day_start, $year_end, $month_end, $day_end);
-	if ($return == strval(intval($return))) {
-		header('Location: session_category_list.php?action=show_message&message='.urlencode(get_lang('SessionCategoryUpdate')));
-		exit();
-	}
+if (isset($_POST['formSent']) && $_POST['formSent']) {
+    $formSent = 1;
+    $name = $_POST['name'];
+    $year_start = $_POST['year_start'];
+    $month_start = $_POST['month_start'];
+    $day_start = $_POST['day_start'];
+    $year_end = $_POST['year_end'];
+    $month_end = $_POST['month_end'];
+    $day_end = $_POST['day_end'];
+    $return = SessionManager::edit_category_session(
+        $id,
+        $name,
+        $year_start,
+        $month_start,
+        $day_start,
+        $year_end,
+        $month_end,
+        $day_end
+    );
+    if ($return == strval(intval($return))) {
+        header(
+            'Location: session_category_list.php?action=show_message&message=' . urlencode(
+                get_lang('SessionCategoryUpdate')
+            )
+        );
+        exit();
+    }
 }
-$thisYear=date('Y');
-$thisMonth=date('m');
-$thisDay=date('d');
+
+$thisYear = date('Y');
+$thisMonth = date('m');
+$thisDay = date('d');
 
 // display the header
 Display::display_header($tool_name);
@@ -63,7 +81,7 @@ if (!empty($return)) {
 	Display::display_error_message($return,false);
 }
 ?>
-<form method="post" name="form" action="<?php echo api_get_self(); ?>?page=<?php echo Security::remove_XSS($_GET['page']) ?>&id=<?php echo $id; ?>" style="margin:0px;">
+<form method="post" name="form" action="<?php echo api_get_self(); ?>?id=<?php echo $id; ?>">
 <input type="hidden" name="formSent" value="1">
 <legend><?php echo $tool_name;?> </legend>
 <table border="0" cellpadding="5" cellspacing="0" width="550">
@@ -216,7 +234,8 @@ for($i=$thisYear-5;$i <= ($thisYear+5);$i++)
 <tr>
   <td>&nbsp;</td>
   <td>
-<button class="save" type="submit" value="<?php echo get_lang('ModifyThisSession') ?>"><?php echo get_lang('ModifyThisSession') ?></button>
+<button class="save" type="submit" value="<?php echo get_lang('ModifyThisSession') ?>">
+    <?php echo get_lang('ModifyThisSession') ?></button>
 
   </td>
 </tr>

+ 9 - 3
main/admin/session_edit.php

@@ -37,9 +37,15 @@ $interbreadcrumb[] = array('url' => "resume_session.php?id_session=".$id,"name"
 list($year_start,$month_start,$day_start)   = explode('-', $infos['date_start']);
 list($year_end,$month_end,$day_end)         = explode('-', $infos['date_end']);
 
-$showDescriptionChecked = null;
-if (isset($infos['show_description']) && !empty($infos['show_description'])) {
-    $showDescriptionChecked = 'checked';
+// Default value
+$showDescriptionChecked = 'checked';
+
+if (isset($infos['show_description'])) {
+    if (!empty($infos['show_description'])) {
+        $showDescriptionChecked = 'checked';
+    } else {
+        $showDescriptionChecked = null;
+    }
 }
 
 $end_year_disabled = $end_month_disabled = $end_day_disabled = '';

+ 6 - 6
main/admin/session_import.php

@@ -47,8 +47,8 @@ global $_configuration;
 if (isset($_POST['formSent']) && $_POST['formSent']) {
     if (isset($_FILES['import_file']['tmp_name']) && !empty($_FILES['import_file']['tmp_name'])) {
         $form_sent = $_POST['formSent'];
-        $file_type = $_POST['file_type'];
-        $send_mail = $_POST['sendMail'] ? 1 : 0;
+        $file_type = isset($_POST['file_type']) ? $_POST['file_type'] : null;
+        $send_mail = isset($_POST['sendMail']) && $_POST['sendMail'] ? 1 : 0;
         $isOverwrite = $_POST['overwrite'] ? true: false;
         $deleteUsersNotInList = isset($_POST['delete_users_not_in_list']) ? true : false;
         $sessions = array();
@@ -551,8 +551,8 @@ $form->display();
 <blockquote>
 <pre>
 <strong>SessionName</strong>;Coach;<strong>DateStart</strong>;<strong>DateEnd</strong>;Users;Courses
-<strong>xxx1</strong>;xxx;<strong>xxx;xxx</strong>;username1|username2;course1[coach1][username1,username2,...]|course2[coach1][username1,username2,...]
-<strong>xxx2</strong>;xxx;<strong>xxx;xxx</strong>;username1|username2;course1[coach1][username1,username2,...]|course2[coach1][username1,username2,...]
+<strong>xxx1</strong>;xxx;<strong>yyyy/mm/dd;yyyy/mm/dd</strong>;username1|username2;course1[coach1][username1,username2,...]|course2[coach1][username1,username2,...]
+<strong>xxx2</strong>;xxx;<strong>yyyy/mm/dd;yyyy/mm/dd</strong>;username1|username2;course1[coach1][username1,username2,...]|course2[coach1][username1,username2,...]
 </pre>
 </blockquote>
 
@@ -586,8 +586,8 @@ $form->display();
     &lt;Session&gt;
         <strong>&lt;SessionName&gt;xxx&lt;/SessionName&gt;</strong>
         &lt;Coach&gt;xxx&lt;/Coach&gt;
-        <strong>&lt;DateStart&gt;xxx&lt;/DateStart&gt;</strong>
-        <strong>&lt;DateEnd&gt;xxx&lt;/DateEnd&gt;</strong>
+        <strong>&lt;DateStart&gt;yyyy/mm/dd&lt;/DateStart&gt;</strong>
+        <strong>&lt;DateEnd&gt;yyyy/mm/dd&lt;/DateEnd&gt;</strong>
         &lt;User&gt;xxx&lt;/User&gt;
         &lt;User&gt;xxx&lt;/User&gt;
         &lt;Course&gt;

+ 22 - 6
main/cron/import_csv.php

@@ -78,6 +78,7 @@ class ImportCsv
         $path = api_get_path(SYS_CODE_PATH).'cron/incoming/';
         if (!is_dir($path)) {
             echo "The folder! $path does not exits";
+
             return 0;
         }
 
@@ -128,6 +129,7 @@ class ImportCsv
 
             if (empty($fileToProcess)) {
                 echo 'Error - no files to process.';
+
                 return 0;
             }
 
@@ -581,15 +583,19 @@ class ImportCsv
     {
         $data = Import::csv_to_array($file);
 
-        //$language = $this->defaultLanguage;
-
         if (!empty($data)) {
             $this->logger->addInfo(count($data)." records found.");
 
             foreach ($data as $row) {
                 $row = $this->cleanCourseRow($row);
-                $courseCode = CourseManager::get_course_id_from_original_id($row['extra_'.$this->extraFieldIdNameList['course']], $this->extraFieldIdNameList['course']);
+
+                $courseCode = CourseManager::get_course_id_from_original_id(
+                    $row['extra_' . $this->extraFieldIdNameList['course']],
+                    $this->extraFieldIdNameList['course']
+                );
+
                 $courseInfo = api_get_course_info($courseCode);
+
                 if (empty($courseInfo)) {
                     // Create
                     $params = array();
@@ -603,7 +609,12 @@ class ImportCsv
                     $courseInfo = CourseManager::create_course($params);
 
                     if (!empty($courseInfo)) {
-                        CourseManager::update_course_extra_field_value($courseInfo['code'], 'external_course_id', $row['extra_'.$this->extraFieldIdNameList['course']]);
+                        CourseManager::update_course_extra_field_value(
+                            $courseInfo['code'],
+                            'external_course_id',
+                            $row['extra_'.$this->extraFieldIdNameList['course']]
+                        );
+
                         $this->logger->addInfo("Courses - Course created ".$courseInfo['code']);
                     } else {
                         $this->logger->addError("Courses - Can't create course:".$row['title']);
@@ -617,6 +628,7 @@ class ImportCsv
                     $result = CourseManager::update_attributes($courseInfo['real_id'], $params);
 
                     $addTeacherToSession = isset($courseInfo['add_teachers_to_sessions_courses']) && !empty($courseInfo['add_teachers_to_sessions_courses']) ? true : false;
+
                     if ($addTeacherToSession) {
                         CourseManager::updateTeachers($courseInfo['id'], $row['teachers'], false, true, false);
                     } else {
@@ -844,7 +856,9 @@ if (isset($argv[1]) && $argv[1] = '--dump') {
     $dump = true;
 }
 
-if (isset($_configuration['import_csv_disable_dump']) && $_configuration['import_csv_disable_dump'] == true) {
+if (isset($_configuration['import_csv_disable_dump']) &&
+    $_configuration['import_csv_disable_dump'] == true
+) {
     $import->setDumpValues(false);
 } else {
     $import->setDumpValues($dump);
@@ -859,7 +873,9 @@ if (isset($_configuration['import_csv_test'])) {
 
 $import->run();
 
-if (isset($_configuration['import_csv_fix_permissions']) && $_configuration['import_csv_fix_permissions'] == true) {
+if (isset($_configuration['import_csv_fix_permissions']) &&
+    $_configuration['import_csv_fix_permissions'] == true
+) {
     $command = "sudo find ".api_get_path(SYS_COURSE_PATH)." -type d -exec chmod 777 {} \; ";
     echo "Executing: ".$command.PHP_EOL;
     system($command);

+ 8 - 2
main/inc/ajax/document.ajax.php

@@ -24,7 +24,7 @@ switch($action) {
             exit;
         }
 
-        $ifExists = isset($_POST['if_exists']) ? $_POST['if_exists'] : null;
+        $ifExists = isset($_POST['if_exists']) ? $_POST['if_exists'] : 'overwrite';
 
         if (!empty($_FILES)) {
             require_once api_get_path(LIBRARY_PATH).'fileDisplay.lib.php';
@@ -39,8 +39,14 @@ switch($action) {
                 false,
                 false
             );
+
             $json = array();
-            $json['name'] = Display::url(api_htmlentities($file['name']), api_htmlentities($result['url']), array('target'=>'_blank'));
+            $json['name'] = Display::url(
+                api_htmlentities($result['title']),
+                api_htmlentities($result['url']),
+                array('target'=>'_blank')
+            );
+
             $json['type'] = api_htmlentities($file['type']);
             $json['size'] = format_file_size($file['size']);
             if (!empty($result) && is_array($result)) {

+ 21 - 11
main/inc/lib/document.lib.php

@@ -2635,18 +2635,18 @@ class DocumentManager
                 );
 
                 if ($new_path) {
-                    $docid = DocumentManager::get_document_id($course_info, $new_path);
+                    $documentId = DocumentManager::get_document_id($course_info, $new_path);
 
-                    if (!empty($docid)) {
+                    if (!empty($documentId)) {
                         $table_document = Database::get_course_table(TABLE_DOCUMENT);
                         $params = array();
 
-                        if (!empty($title)) {
-                            $params['title'] = get_document_title($title);
+                        if ($if_exists == 'rename') {
+                            $new_path = basename($new_path);
+                            $params['title'] = get_document_title($new_path);
                         } else {
-                            if ($if_exists == 'rename') {
-                                $new_path = basename($new_path);
-                                $params['title'] = get_document_title($new_path);
+                            if (!empty($title)) {
+                                $params['title'] = get_document_title($title);
                             } else {
                                 $params['title'] = get_document_title($files['file']['name']);
                             }
@@ -2655,7 +2655,16 @@ class DocumentManager
                         if (!empty($comment)) {
                             $params['comment'] = trim($comment);
                         }
-                        Database::update($table_document, $params, array('id = ? AND c_id = ? ' => array($docid, $course_info['real_id'])));
+                        Database::update(
+                            $table_document,
+                            $params,
+                            array(
+                                'id = ? AND c_id = ? ' => array(
+                                    $documentId,
+                                    $course_info['real_id']
+                                )
+                            )
+                        );
                     }
 
                     // Showing message when sending zip files
@@ -2664,10 +2673,11 @@ class DocumentManager
                     }
 
                     if ($index_document) {
-                        self::index_document($docid, $course_info['code'], null, $_POST['language'], $_REQUEST, $if_exists);
+                        self::index_document($documentId, $course_info['code'], null, $_POST['language'], $_REQUEST, $if_exists);
                     }
-                    if (!empty($docid) && is_numeric($docid)) {
-                        $document_data = self::get_document_data_by_id($docid, $course_info['code']);
+
+                    if (!empty($documentId) && is_numeric($documentId)) {
+                        $document_data = self::get_document_data_by_id($documentId, $course_info['code']);
                         return $document_data;
                     }
                 }

+ 27 - 14
main/inc/lib/fileUpload.lib.php

@@ -9,9 +9,6 @@
  *	@package chamilo.library
  *	@todo test and reorganise
  */
-/**
- * Code
- */
 require_once api_get_path(LIBRARY_PATH).'document.lib.php';
 
 /**
@@ -51,13 +48,15 @@ function disable_dangerous_file($filename) {
 
 /**
  * This function generates a unique name for a file on a given location
- * filenames are changed to name_#.ext
+ * file names are changed to name_#.ext
  *
  * @param string $path
  * @param string $name
- * @return new unique name
+ *
+ * @return string new unique name
  */
-function unique_name($path, $name) {
+function unique_name($path, $name)
+{
 	$ext = substr(strrchr($name, '.'), 0);
 	$name_no_ext = substr($name, 0, strlen($name) - strlen(strstr($name, $ext)));
 	$n = 0;
@@ -266,8 +265,9 @@ function handle_uploaded_document(
 			$file_size = $uploaded_file['size'];
 
 			$files_perm = api_get_permissions_for_new_files();
-            $doc_path = '/'.$clean_name;
-            $docId = DocumentManager :: get_document_id($_course, $doc_path, $current_session_id);
+            //$doc_path = '/'.$clean_name;
+            $docId = DocumentManager::get_document_id($_course, $file_path, $current_session_id);
+
             // What to do if the target file exists
 			switch ($what_if_file_exists) {
 				// Overwrite the file if it exists
@@ -339,9 +339,11 @@ function handle_uploaded_document(
 				case 'rename':
                     if ($docId) {
                         $new_name = unique_name($where_to_save, $clean_name);
+                        $document_name = $new_name;
                     } else {
                         $new_name = $clean_name;
                     }
+
 					$store_path = $where_to_save.$new_name;
 					$new_file_path = $upload_path.$new_name;
 
@@ -362,7 +364,7 @@ function handle_uploaded_document(
 						item_property_update_on_folder($_course, $upload_path, $user_id);
 
 						// Display success message to user
-						if ($output){
+						if ($output) {
 							Display::display_confirmation_message(get_lang('UplUploadSucceeded').'<br />'.get_lang('UplFileSavedAs').$new_file_path, false);
 						}
 						return $new_file_path;
@@ -446,8 +448,8 @@ function moveUploadedFile($file, $storePath)
 function enough_size($file_size, $dir, $max_dir_space)
 {
     // If the directory is the archive directory, safely ignore the size limit
-    if (api_get_path(SYS_ARCHIVE_PATH) == $dir) { 
-        return true; 
+    if (api_get_path(SYS_ARCHIVE_PATH) == $dir) {
+        return true;
     }
 
     if ($max_dir_space) {
@@ -613,8 +615,8 @@ function add_ext_on_mime($file_name, $file_type) {
  *
  * @return boolean true if it succeds, false otherwise
  */
-function treat_uploaded_file($uploaded_file, $base_work_dir, $upload_path, $max_filled_space, $uncompress = '') {
-
+function treat_uploaded_file($uploaded_file, $base_work_dir, $upload_path, $max_filled_space, $uncompress = '')
+{
 	$uploaded_file['name'] = stripslashes($uploaded_file['name']);
 
 	if (!enough_size($uploaded_file['size'], $base_work_dir, $max_filled_space)) {
@@ -1216,7 +1218,18 @@ function create_unexisting_directory(
                         $session_id
                     );
 				} else {
-					api_item_property_update($_course, TOOL_DOCUMENT, $document_id, 'FolderCreated', $user_id, $to_group_id, $to_user_id, null, null, $session_id);
+                    api_item_property_update(
+                        $_course,
+                        TOOL_DOCUMENT,
+                        $document_id,
+                        'FolderCreated',
+                        $user_id,
+                        $to_group_id,
+                        $to_user_id,
+                        null,
+                        null,
+                        $session_id
+                    );
 				}
 				return $desired_dir_name.$nb;
 			}

+ 49 - 41
main/mySpace/myStudents.php

@@ -710,12 +710,12 @@ if (empty($_GET['details'])) {
     // csv export headers
     $csv_content[] = array ();
     $csv_content[] = array (
-    	get_lang('Learnpath', ''),
-    	get_lang('Time', ''),
-    	get_lang('AverageScore', ''),
-    	get_lang('LatestScore', ''),
-    	get_lang('Progress', ''),
-    	get_lang('LastConnexion', '')
+    	get_lang('Learnpath'),
+    	get_lang('Time'),
+    	get_lang('AverageScore'),
+    	get_lang('LatestAttemptAverageScore'),
+    	get_lang('Progress'),
+    	get_lang('LastConnexion')
     );
 
     if (empty($session_id)) {
@@ -868,12 +868,13 @@ if (empty($_GET['details'])) {
 			</tr>
 		<?php
 
-		$csv_content[] = array ();
-		$csv_content[] = array (
-			get_lang('Exercices'),
-			get_lang('Score'),
-			get_lang('Attempts')
-		);
+		$csv_content[] = array();
+        $csv_content[] = array(
+            get_lang('Exercices'),
+            get_lang('LearningPath'),
+            get_lang('AvgCourseScore'),
+            get_lang('Attempts')
+        );
 
 		$t_quiz = Database :: get_course_table(TABLE_QUIZ_TEST);
 		$sql_exercices = "SELECT quiz.title, id FROM " . $t_quiz . " AS quiz
@@ -898,11 +899,6 @@ if (empty($_GET['details'])) {
                     $lp_name = '-';
                 }
                 $lp_name = !empty($lp_name) ? $lp_name : get_lang('NoLearnpath');
-				$csv_content[] = array (
-					$exercices['title'],
-					$score_percentage . '%',
-					$count_attempts
-				);
 
                 if ($i % 2) {
                     $css_class = 'row_odd';
@@ -956,6 +952,14 @@ if (empty($_GET['details'])) {
 				$data_exercices[$i][] = $exercices['title'];
 				$data_exercices[$i][] = $score_percentage . '%';
 				$data_exercices[$i][] = $count_attempts;
+
+                $csv_content[] = array (
+                    $exercices['title'],
+                    $lp_name,
+                    $score_percentage,
+                    $count_attempts
+                );
+
 				$i++;
 
 			}
@@ -1020,30 +1024,34 @@ if (empty($_GET['details'])) {
 		$documents				= Tracking::count_student_downloaded_documents($student_id, $course_code, $session_id);
 		$uploaded_documents		= Tracking::count_student_uploaded_documents($student_id, $course_code, $session_id);
 
-		$csv_content[] = array (
-			get_lang('Student_publication'),
-			$nb_assignments
-		);
-		$csv_content[] = array (
-			get_lang('Messages'),
-			$messages
-		);
-		$csv_content[] = array (
-			get_lang('LinksDetails'),
-			$links
-		);
-		$csv_content[] = array (
-			get_lang('DocumentsDetails'),
-			$documents
-		);
-		$csv_content[] = array (
-			get_lang('UploadedDocuments'),
-			$uploaded_documents
-		);
-		$csv_content[] = array (
-			get_lang('ChatLastConnection'),
-			$chat_last_connection
-		);
+        $csv_content[] = array(
+            get_lang('OtherTools')
+        );
+
+        $csv_content[] = array(
+            get_lang('Student_publication'),
+            $nb_assignments
+        );
+        $csv_content[] = array(
+            get_lang('Messages'),
+            $messages
+        );
+        $csv_content[] = array(
+            get_lang('LinksDetails'),
+            $links
+        );
+        $csv_content[] = array(
+            get_lang('DocumentsDetails'),
+            $documents
+        );
+        $csv_content[] = array(
+            get_lang('UploadedDocuments'),
+            $uploaded_documents
+        );
+        $csv_content[] = array(
+            get_lang('ChatLastConnection'),
+            $chat_last_connection
+        );
 ?>
 		<tr>
 			<th colspan="2"><?php echo get_lang('OtherTools'); ?></th>

+ 1 - 1
main/newscorm/learnpath.class.php

@@ -2556,7 +2556,7 @@ class learnpath
                     ' '
                 );
                 $prereq_mod = str_replace($find, $replace, $prereq);
-                $ids = split(' ', $prereq_mod);
+                $ids = explode(' ', $prereq_mod);
                 foreach ($ids as $id) {
                     $id = trim($id);
                     if (isset ($this->refs_list[$id])) {

+ 2 - 1
main/newscorm/learnpathItem.class.php

@@ -1771,6 +1771,7 @@ class learnpathItem
         $query_db = false
     ) {
         $h = get_lang('h');
+        $time = null;
         $course_id = api_get_course_int_id();
         if (!isset($given_time)) {
             if (self::debug > 2) {
@@ -2460,7 +2461,7 @@ class learnpathItem
                                     );
                                 }
 
-                                if (isset($items[$refs_list[$prereqs_string]])) {
+                                if (isset($refs_list[$prereqs_string]) && isset($items[$refs_list[$prereqs_string]])) {
                                     if ($items[$refs_list[$prereqs_string]]->type == 'quiz') {
 
                                         // 1. Checking the status in current items.