Browse Source

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

Angel Fernando Quiroz Campos 9 years ago
parent
commit
1aebe33806

+ 2 - 2
main/auth/cas/authcas.php

@@ -88,7 +88,7 @@ function cas_is_authenticated()
 		        // if option is on we update user automatically from ldap server
 		        if (api_get_setting("update_user_info_cas_with_ldap") == "true") {
                     $ldapuser = extldap_authenticate($login, 'nopass', true);
-                    if ($ldap_user !== false) {
+                    if ($ldapuser !== false) {
                         $chamilo_user = extldap_get_chamilo_user($ldapuser);
                         $chamilo_user['user_id'] = $tab_user_info['user_id'];
                         $chamilo_user['status'] = $tab_user_info['status'];
@@ -114,7 +114,7 @@ function cas_is_authenticated()
 	                    // user has already been authenticated by CAS
 	                    // If user not found in LDAP, user not created
 	                    $ldapuser = extldap_authenticate($login, 'nopass', true);
-	                    if ($ldap_user !== false) {
+	                    if ($ldapuser !== false) {
 	                        $chamilo_user = extldap_get_chamilo_user($ldapuser);
                             $chamilo_user['username'] = $login;
                             $chamilo_user['auth_source'] = CAS_AUTH_SOURCE;

+ 5 - 1
main/coursecopy/import_backup.php

@@ -62,6 +62,10 @@ if (Security::check_token('post') && (
     $error = false;
     if (isset($_POST['action']) && $_POST['action'] == 'course_select_form') {
         // Partial backup here we recover the documents posted
+        // This gets $_POST['course']. Beware that when using Suhosin,
+        // the post.max_value_length limit might get in the way of the
+        // restoration of a course with many items. A value of 1,000,000 bytes
+        // might be too short.
         $course = CourseSelectForm::get_posted_course();
 
     } else {
@@ -89,7 +93,7 @@ if (Security::check_token('post') && (
         }
     }
 
-    if (!$error && $course->has_resources()) {
+    if (!$error && is_object($course) && $course->has_resources()) {
         $cr = new CourseRestorer($course);
         $cr->set_file_option($_POST['same_file_name_option']);
         $cr->restore();

BIN
main/exercice/quiz_template.xls


+ 2 - 0
main/exercice/upload_exercise.php

@@ -466,6 +466,8 @@ function lp_upload_quiz_action_handling() {
                                             ) {
                                                 $score = $score_list[$i][3] * -1;
                                             }
+                                        } else {
+                                            $score = $score_list[$i][3] * -1;
                                         }
                                         $score /= $numberRightAnswers;
                                         break;

+ 32 - 80
main/forum/forumfunction.inc.php

@@ -1450,21 +1450,18 @@ function get_forums(
 ) {
     $course_info = api_get_course_info($course_code);
 
-    $table_users = Database :: get_main_table(TABLE_MAIN_USER);
     $table_forums = Database :: get_course_table(TABLE_FORUM);
     $table_threads = Database :: get_course_table(TABLE_FORUM_THREAD);
     $table_posts = Database :: get_course_table(TABLE_FORUM_POST);
     $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
 
-    // GETTING ALL THE FORUMS
-
     // Condition for the session
     if (empty($sessionId)) {
         $session_id = api_get_session_id();
     } else {
         $session_id = $sessionId;
     }
-    
+
     $sessionIdLink = ($session_id === 0) ? '' : 'AND threads.session_id = item_properties.session_id';
 
     $condition_session = api_get_session_condition(
@@ -1505,7 +1502,7 @@ function get_forums(
                 INNER JOIN ".$table_item_property." item_properties
                 ON (
                     threads.thread_id=item_properties.ref AND
-                    threads.c_id = item_properties.c_id 
+                    threads.c_id = item_properties.c_id
                     $sessionIdLink
                 )
                 WHERE
@@ -1515,20 +1512,6 @@ function get_forums(
                     item_properties.c_id = $course_id
                 GROUP BY threads.forum_id";
 
-        // Select the number of posts of the forum (post that are visible and that are in a thread that is visible).
-        $sql3 = "SELECT count(*) AS number_of_posts, posts.forum_id
-                FROM $table_posts posts, $table_threads threads, ".$table_item_property." item_properties
-                WHERE
-                    posts.visible=1 AND
-                    posts.thread_id=threads.thread_id AND
-                    threads.thread_id=item_properties.ref AND
-                    threads.session_id = item_properties.session_id AND
-                    item_properties.visibility=1 AND
-                    item_properties.tool='".TOOL_FORUM_THREAD."' AND
-                    threads.c_id = $course_id AND
-                    posts.c_id = $course_id AND
-                    item_properties.c_id = $course_id
-                GROUP BY threads.forum_id";
 
         // Course Admin
         if (api_is_allowed_to_edit()) {
@@ -1554,7 +1537,7 @@ function get_forums(
                     INNER JOIN ".$table_item_property." item_properties
                     ON (
                         threads.thread_id=item_properties.ref AND
-                        threads.c_id = item_properties.c_id 
+                        threads.c_id = item_properties.c_id
                         $sessionIdLink
                     )
                     WHERE
@@ -1563,19 +1546,6 @@ function get_forums(
                         threads.c_id = $course_id AND
                         item_properties.c_id = $course_id
                     GROUP BY threads.forum_id";
-            // Select the number of posts of the forum.
-            $sql3 = "SELECT count(*) AS number_of_posts, posts.forum_id
-                    FROM $table_posts posts, $table_threads threads, ".$table_item_property." item_properties
-                    WHERE
-                        posts.thread_id=threads.thread_id AND
-                        threads.thread_id=item_properties.ref AND
-                        threads.session_id = item_properties.session_id AND
-                        item_properties.visibility=1 AND
-                        item_properties.tool='".TOOL_FORUM_THREAD."' AND
-                        posts.c_id = $course_id AND
-                        threads.c_id = $course_id AND
-                        item_properties.c_id = $course_id
-                    GROUP BY threads.forum_id";
         }
     } else {
         // GETTING ONE SPECIFIC FORUM
@@ -1605,31 +1575,6 @@ function get_forums(
                     forum_id = ".intval($id)." AND
                     c_id = $course_id
                 GROUP BY forum_id";
-
-        // Select the number of posts of the forum.
-        $sql3 = "SELECT count(*) AS number_of_posts, forum_id
-                FROM $table_posts
-                WHERE
-                    forum_id = ".intval($id)." AND
-                    c_id = $course_id
-                GROUP BY forum_id";
-
-        // Select the last post and the poster (note: this is probably no longer needed).
-        $sql4 = "SELECT
-                    post.post_id,
-                    post.forum_id,
-                    post.poster_id,
-                    post.poster_name,
-                    post.post_date,
-                    users.lastname,
-                    users.firstname
-                FROM $table_posts post, $table_users users
-                WHERE
-                    forum_id = ".intval($id)." AND
-                    post.poster_id=users.user_id AND
-                    post.c_id = $course_id
-                GROUP BY post.forum_id
-                ORDER BY post.post_id ASC";
     }
 
     // Handling all the forum information.
@@ -1653,25 +1598,16 @@ function get_forums(
         }
     }
 
-    // Handling the postcount information.
-    $result3 = Database::query($sql3);
-    while ($row3 = Database::fetch_array($result3)) {
-        if ($id == '') {
-            // This is needed because sql3 takes also the deleted forums into account.
-            if (array_key_exists($row3['forum_id'], $forum_list)) {
-                $forum_list[$row3['forum_id']]['number_of_posts'] = $row3['number_of_posts'];
-            }
-        } else {
-            $forum_list['number_of_posts'] = $row3['number_of_posts'];
-        }
-    }
-
     /* Finding the last post information
     (last_post_id, last_poster_id, last_post_date, last_poster_name, last_poster_lastname, last_poster_firstname)*/
     if ($id == '') {
         if (is_array($forum_list)) {
             foreach ($forum_list as $key => $value) {
-                $last_post_info_of_forum = get_last_post_information($key, api_is_allowed_to_edit(), $course_id);
+                $last_post_info_of_forum = get_last_post_information(
+                    $key,
+                    api_is_allowed_to_edit(),
+                    $course_id
+                );
                 $forum_list[$key]['last_post_id'] = $last_post_info_of_forum['last_post_id'];
                 $forum_list[$key]['last_poster_id'] = $last_post_info_of_forum['last_poster_id'];
                 $forum_list[$key]['last_post_date'] = $last_post_info_of_forum['last_post_date'];
@@ -1683,7 +1619,11 @@ function get_forums(
             $forum_list = array();
         }
     } else {
-        $last_post_info_of_forum = get_last_post_information($id, api_is_allowed_to_edit(), $course_id);
+        $last_post_info_of_forum = get_last_post_information(
+            $id,
+            api_is_allowed_to_edit(),
+            $course_id
+        );
         $forum_list['last_post_id'] = $last_post_info_of_forum['last_post_id'];
         $forum_list['last_poster_id'] = $last_post_info_of_forum['last_poster_id'];
         $forum_list['last_post_date'] = $last_post_info_of_forum['last_post_date'];
@@ -2767,7 +2707,8 @@ function show_add_post_form($current_forum, $forum_setting, $action = '', $id =
                 empty($values['weight_calification'])
             ) {
                 Display::display_error_message(
-                    get_lang('YouMustAssignWeightOfQualification').'&nbsp;<a href="javascript:window.history.go(-1);">'.get_lang('Back').'</a>',
+                    get_lang('YouMustAssignWeightOfQualification').'&nbsp;<a href="javascript:window.history.go(-1);">'.
+                    get_lang('Back').'</a>',
                     false
                 );
 
@@ -3111,10 +3052,11 @@ function store_reply($current_forum, $values)
                 'visible' => $visible,
             ]
         );
-        if ($new_post_id) {
 
+        if ($new_post_id) {
             $sql = "UPDATE $table_posts SET post_id = iid WHERE iid = $new_post_id";
             Database::query($sql);
+
             $values['new_post_id'] = $new_post_id;
             $message = get_lang('ReplyAdded');
 
@@ -3142,12 +3084,19 @@ function store_reply($current_forum, $values)
                 api_get_user_id()
             );
 
+            // Insert post
+            api_item_property_update(
+                $_course,
+                TOOL_FORUM_POST,
+                $new_post_id,
+                'NewPost',
+                api_get_user_id()
+            );
+
             if ($current_forum['approval_direct_post'] == '1' &&
                 !api_is_allowed_to_edit(null, true)
             ) {
-                $message .= '<br />'.get_lang(
-                        'MessageHasToBeApproved'
-                    ).'<br />';
+                $message .= '<br />'.get_lang('MessageHasToBeApproved').'<br />';
             }
 
             // Setting the notification correctly.
@@ -3157,7 +3106,6 @@ function store_reply($current_forum, $values)
             }
 
             send_notification_mails($values['thread_id'], $values);
-
             add_forum_attachment_file('', $new_post_id);
         }
 
@@ -3732,7 +3680,10 @@ function get_post_topics_of_forum($forum_id)
         $number_of_topics = 0; // Due to the nature of the group by this can result in an empty string.
     }
 
-    $return = array('number_of_topics' => $number_of_topics, 'number_of_posts' => $number_of_posts);
+    $return = array(
+        'number_of_topics' => $number_of_topics,
+        'number_of_posts' => $number_of_posts,
+    );
 
     return $return;
 }
@@ -4354,6 +4305,7 @@ function display_forum_search_results($search_term)
     $forum_list = get_forums();
 
     $result = Database::query($sql);
+    $search_results = [];
     while ($row = Database::fetch_array($result, 'ASSOC')) {
         $display_result = false;
         /*

+ 2 - 8
main/forum/index.php

@@ -490,7 +490,7 @@ if (is_array($forumCategories)) {
                         $html .= '<div class="row">';
                         $html .= '<div class="col-md-6">';
                         $html .= '<div class="col-md-3">';
-                        $html .= '<div class="number-post">'.$forum_image.'<p>'.$number_posts.' ' . get_lang('Posts') . '</p>'
+                        $html .= '<div class="number-post">'.$forum_image.'<p>'.$number_threads.' ' . get_lang('ForumThreads') . '</p>'
                             . '</div>';
                         $html .= '</div>';
 
@@ -556,13 +556,7 @@ if (is_array($forumCategories)) {
                         $html .= '<div class="col-md-6">';
                         $html .= '<div class="row">';
                         $html .= '<div class="col-md-2">';
-                        $html .= Display::return_icon(
-                            'post-forum.png',
-                            get_lang('Forum'),
-                            null,
-                            ICON_SIZE_SMALL
-                        );
-                        $html .= ' ' . $number_threads . '<br>'.$newPost.'</div>';
+                        $html .= $newPost.'</div>';
                         $html .= '<div class="col-md-6">';
 
                         // The last post in the forum.

+ 1 - 1
main/forum/reply.php

@@ -17,7 +17,7 @@
  *
  * @package chamilo.forum
  */
-// Including the global initialization file.
+
 require_once '../inc/global.inc.php';
 
 // The section (tabs).

+ 4 - 1
main/forum/viewforum.php

@@ -49,6 +49,7 @@ require 'forumconfig.inc.php';
 require_once 'forumfunction.inc.php';
 
 $userid  = api_get_user_id();
+$sessionId = api_get_session_id();
 
 /* MAIN DISPLAY SECTION */
 
@@ -595,7 +596,9 @@ if (is_array($threads)) {
             $row_post_id = Database::fetch_array($result_post_id);
             $iconsEdit = '';
             if ($origin != 'learnpath') {
-                if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])) {
+                if (api_is_allowed_to_edit(false, true) &&
+                    !(api_is_course_coach() && $current_forum['session_id'] != $sessionId)
+                ) {
                     $iconsEdit .= '<a href="' . $forumUrl . 'editpost.php?' . api_get_cidreq()
                         . '&forum=' . Security::remove_XSS($my_forum) . '&thread='
                         . Security::remove_XSS($row['thread_id']) . '&post=' . $row_post_id['post_id']

+ 9 - 13
main/forum/viewforumcategory.php

@@ -68,6 +68,8 @@ if (!empty($gradebook) && $gradebook == 'view') {
     );
 }
 
+$sessionId = api_get_session_id();
+
 $current_forum_category = get_forum_categories($_GET['forumcategory']);
 $interbreadcrumb[] = array(
     'url' => 'index.php?gradebook=' . $gradebook . '&search='
@@ -152,7 +154,6 @@ if ($action_forums != 'add') {
     $forum_category = get_forum_categories($_GET['forumcategory']);
 
     // Step 2: We find all the forums.
-    $forum_list = array();
     $forum_list = get_forums();
 
     /* RETRIEVING ALL GROUPS AND THOSE OF THE USER */
@@ -172,10 +173,8 @@ if ($action_forums != 'add') {
     $html = '';
     $html .= '<div class="category-forum">';
 
-    $my_session = isset($_SESSION['id_session']) ? $_SESSION['id_session'] : null;
-
     if (
-        (!isset($_SESSION['id_session']) || $_SESSION['id_session'] == 0) &&
+        (!isset($sessionId) || $sessionId == 0) &&
         !empty($forum_category['session_name'])
     ) {
         $session_displayed = ' ('.Security::remove_XSS($forum_category['session_name']).')';
@@ -194,7 +193,7 @@ if ($action_forums != 'add') {
         ICON_SIZE_MEDIUM
     );
 
-    if (api_is_allowed_to_edit(false, true) && !($forum_category['session_id'] == 0 && intval($my_session) != 0)) {
+    if (api_is_allowed_to_edit(false, true) && !($forum_category['session_id'] == 0 && $sessionId != 0)) {
 
         $iconsEdit = '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forumcategory='
             . Security::remove_XSS($_GET['forumcategory']) . '&action=edit&content=forumcategory&id='
@@ -327,7 +326,6 @@ if ($action_forums != 'add') {
 
                 $my_whatsnew_post_info = isset($whatsnew_post_info[$forum['forum_id']]) ? $whatsnew_post_info[$forum['forum_id']] : null;
 
-
                 if ($forum['forum_of_group'] == '0') {
                     $forum_image = Display::return_icon(
                         'forum_group.png',
@@ -360,7 +358,7 @@ if ($action_forums != 'add') {
                     $forum_title_group_addition = '';
                 }
 
-                if ((!isset($_SESSION['id_session']) || $_SESSION['id_session'] == 0) && !empty($forum['session_name'])) {
+                if (!empty($sessionId) && !empty($forum['session_name'])) {
                     $session_displayed = ' ('.$forum['session_name'].')';
                 } else {
                     $session_displayed = '';
@@ -373,7 +371,7 @@ if ($action_forums != 'add') {
                 $html .= '<div class="row">';
                 $html .= '<div class="col-md-6">';
                 $html .= '<div class="col-md-3">';
-                $html .= '<div class="number-post">'.$forum_image .'<p>' . $my_number_posts . ' ' . get_lang('Posts') . '</p></div>';
+                $html .= '<div class="number-post">'.$forum_image .'<p>' . $my_number_threads . ' ' . get_lang('ForumThreads') . '</p></div>';
                 $html .= '</div>';
 
                 $html .= '<div class="col-md-9">';
@@ -416,7 +414,7 @@ if ($action_forums != 'add') {
 
                 // The number of topics and posts.
                 if ($forum['forum_of_group'] !== '0') {
-                    $newPost='';
+                    $newPost = '';
                     if (is_array($my_whatsnew_post_info) && !empty($my_whatsnew_post_info)) {
                         $newPost = ' ' . Display::return_icon('alert.png', get_lang('Forum'), null, ICON_SIZE_SMALL);
                     } else {
@@ -432,8 +430,7 @@ if ($action_forums != 'add') {
 
                 $html .= '<div class="row">';
                 $html .= '<div class="col-md-2">';
-                $html .= Display::return_icon('post-forum.png', null, null, ICON_SIZE_SMALL);
-                $html .= ' ' . $my_number_threads . '<br>' . $newPost . '</div>';
+                $html .= $newPost . '</div>';
 
                 // the last post in the forum
                 if ($forum['last_poster_name'] != '') {
@@ -455,8 +452,7 @@ if ($action_forums != 'add') {
 
                 if (
                     api_is_allowed_to_edit(false, true) &&
-                    !($forum['session_id'] == 0 &&
-                    intval(isset($_SESSION['id_session']) ? $_SESSION['id_session'] : null) != 0)
+                    !($forum['session_id'] == 0 && $sessionId != 0)
                 ) {
                     $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forumcategory='
                         . Security::remove_XSS($_GET['forumcategory'])

+ 3 - 1
main/forum/viewthread.php

@@ -56,6 +56,8 @@ if (!empty($gradebook) && $gradebook == 'view') {
 }
 
 $groupId = api_get_group_id();
+$sessionId = api_get_session_id();
+
 if ($origin == 'group') {
     $group_properties = GroupManager::get_group_properties($groupId);
     $interbreadcrumb[] = array(
@@ -197,7 +199,7 @@ if ($my_message != 'PostDeletedSpecial') {
             if (
                 (
                     api_is_allowed_to_edit(false, true) &&
-                    !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])
+                    !(api_is_course_coach() && $current_forum['session_id'] != $sessionId)
                 ) ||
                 ($current_forum['allow_new_threads'] == 1 && isset($_user['user_id'])) ||
                 ($current_forum['allow_new_threads'] == 1 && !isset($_user['user_id']) && $current_forum['allow_anonymous'] == 1)

+ 1 - 1
main/inc/lib/AnnouncementManager.php

@@ -1329,7 +1329,7 @@ class AnnouncementManager
             $file_name = $file ['name'];
 
             if (!filter_extension($new_file_name)) {
-                $return - 1;
+                $return = -1;
                 Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
             } else {
                 $new_file_name = uniqid('');

+ 5 - 21
main/inc/lib/javascript/pear/qfamsHandler.js

@@ -524,27 +524,11 @@ $(function() {
 
         var checked = !$('#'+ id).is(':checked');
         if (!checked) {
-            $('#' +selectId +' option').each(function() {
-                var val = $(this).val();
-                var text = $(this).text();
-                if (val.substr(0 , 4) == 'USER') {
-                    $('#'+selectId).find('[value="'+val+'"]').remove();
-                    $('#' +selectDestinationId).append(new Option(text, val));
-                }
-            });
+            $('#users-f option').prop('selected', true);
+            QFAMS.moveSelection('users', this.form.elements['users-f[]'], this.form.elements['users-t[]'], this.form.elements['users[]'], 'add', 'none');
+        } else {
+            $('#users-t option').prop('selected', true);
+            QFAMS.moveSelection('users', this.form.elements['users-f[]'], this.form.elements['users-t[]'], this.form.elements['users[]'], 'remove', 'none');
         }
-
-        $('#' + selectDestinationId +' option').each(function() {
-            var val = $(this).val();
-            var text = $(this).text();
-
-            if (val.substr(0 , 4) == 'USER') {
-                if (checked) {
-                    // Add
-                    $('#' +selectId ).append(new Option(text, val));
-                    $('#' + selectDestinationId).find('[value="'+val+'"]').remove();
-                }
-            }
-        });
     });
 });

+ 1 - 1
main/inc/lib/urlmanager.lib.php

@@ -746,7 +746,7 @@ class UrlManager
     * */
     public static function delete_url_rel_user($user_id, $url_id)
     {
-        $table_url_rel_user= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
+        $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
         $result = true;
         if (!empty($user_id) && !empty($url_id)) {
             $sql= "DELETE FROM $table_url_rel_user

+ 28 - 16
main/inc/lib/usermanager.lib.php

@@ -543,6 +543,7 @@ class UserManager
                     cu.user_id = '".$user_id."' AND
                     relation_type<>".COURSE_RELATION_TYPE_RRHH." AND
                     c.id = cu.c_id";
+
         $res = Database::query($sql);
         while ($course = Database::fetch_object($res)) {
             $sql = "DELETE FROM $table_group
@@ -550,11 +551,6 @@ class UserManager
             Database::query($sql);
         }
 
-        // Unsubscribe user from all classes
-        //Classes are not longer supported
-        /* $sql = "DELETE FROM $table_class_user WHERE user_id = '".$user_id."'";
-          Database::query($sql); */
-
         // Unsubscribe user from usergroup_rel_user
         $sql = "DELETE FROM $usergroup_rel_user WHERE user_id = '".$user_id."'";
         Database::query($sql);
@@ -569,25 +565,30 @@ class UserManager
 
         // If the user was added as a id_coach then set the current admin as coach see BT#
         $currentUserId = api_get_user_id();
-        $sql = "UPDATE $table_session SET id_coach = $currentUserId  WHERE id_coach = '".$user_id."'";
+        $sql = "UPDATE $table_session SET id_coach = $currentUserId
+                WHERE id_coach = '".$user_id."'";
         Database::query($sql);
 
-        $sql = "UPDATE $table_session SET id_coach = $currentUserId  WHERE session_admin_id = '".$user_id."'";
+        $sql = "UPDATE $table_session SET id_coach = $currentUserId
+                WHERE session_admin_id = '".$user_id."'";
         Database::query($sql);
 
         // Unsubscribe user from all sessions
-        $sql = "DELETE FROM $table_session_user WHERE user_id = '".$user_id."'";
+        $sql = "DELETE FROM $table_session_user
+                WHERE user_id = '".$user_id."'";
         Database::query($sql);
 
         // Delete user picture
         /* TODO: Logic about api_get_setting('split_users_upload_directory') == 'true'
         a user has 4 different sized photos to be deleted. */
         $user_info = api_get_user_info($user_id);
+
         if (strlen($user_info['picture_uri']) > 0) {
             $path = self::getUserPathById($user_id, 'system');
             $img_path = $path.$user_info['picture_uri'];
-            if (file_exists($img_path))
+            if (file_exists($img_path)) {
                 unlink($img_path);
+            }
         }
 
         // Delete the personal course categories
@@ -611,13 +612,8 @@ class UserManager
         $extraFieldValue = new ExtraFieldValue('user');
         $extraFieldValue->deleteValuesByItem($user_id);
 
-        if (api_get_multiple_access_url()) {
-            $url_id = api_get_current_access_url_id();
-            UrlManager::delete_url_rel_user($user_id, $url_id);
-        } else {
-            //we delete the user from the url_id =1
-            UrlManager::delete_url_rel_user($user_id, 1);
-        }
+        $url_id = api_get_current_access_url_id();
+        UrlManager::delete_url_rel_user($user_id, $url_id);
 
         if (api_get_setting('allow_social_tool') == 'true') {
             $userGroup = new UserGroup();
@@ -640,12 +636,27 @@ class UserManager
         $sql = "DELETE FROM $table_work WHERE user_id = $user_id AND c_id <> 0";
         Database::query($sql);
 
+        $sql = "UPDATE c_item_property SET to_user_id = NULL
+                WHERE to_user_id = '".$user_id."'";
+        Database::query($sql);
+
+        $sql = "UPDATE c_item_property SET insert_user_id = NULL
+                WHERE insert_user_id = '".$user_id."'";
+        Database::query($sql);
+
+        $sql = "UPDATE c_item_property SET lastedit_user_id = NULL
+                WHERE lastedit_user_id = '".$user_id."'";
+        Database::query($sql);
+
         // Delete user from database
         $sql = "DELETE FROM $table_user WHERE id = '".$user_id."'";
         Database::query($sql);
 
+
+
         // Add event to system log
         $user_id_manager = api_get_user_id();
+
         Event::addEvent(
             LOG_USER_DELETE,
             LOG_USER_ID,
@@ -653,6 +664,7 @@ class UserManager
             api_get_utc_datetime(),
             $user_id_manager
         );
+
         Event::addEvent(
             LOG_USER_DELETE,
             LOG_USER_OBJECT,

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

@@ -6008,7 +6008,7 @@ class learnpath
 
         $filename = $title;
 
-        $content = isset($content) ? $content : $_POST['content_lp'];
+        $content = !empty($content) ? $content : $_POST['content_lp'];
 
         $tmp_filename = $filename;