From 44221a533e20fcdb54c767b9d151b3395dd42ecf Mon Sep 17 00:00:00 2001 From: Nicolas Ducoulombier Date: Tue, 29 Dec 2015 16:20:22 +0100 Subject: [PATCH 01/12] import with negative score by default -refs BT#8659 --- main/exercice/upload_exercise.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main/exercice/upload_exercise.php b/main/exercice/upload_exercise.php index adbb449892..9733a076c6 100755 --- a/main/exercice/upload_exercise.php +++ b/main/exercice/upload_exercise.php @@ -469,6 +469,8 @@ function lp_upload_quiz_action_handling() { ) { $score = $score_list[$i][3] * -1; } + } else { + $score = $score_list[$i][3] * -1; } $score /= $numberRightAnswers; break; From d2a2878cfbd3db3f0bf569ad5490aafd02d57a61 Mon Sep 17 00:00:00 2001 From: Nicolas Ducoulombier Date: Thu, 31 Dec 2015 11:01:30 +0100 Subject: [PATCH 02/12] Updated excel template to integrate no negative score management, Fill blank or form type of question, matching type of question and category management --- main/exercice/quiz_template.xls | Bin 11776 -> 14336 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/main/exercice/quiz_template.xls b/main/exercice/quiz_template.xls index 6ea839da8a64194d7471e79a02da4f0fc30b4112..967b619c14fbb649ac168b283feb4802c2b0c453 100755 GIT binary patch delta 4243 zcmZvf-)|IE6vxkOOSgd*+5(0CU^>(7beC=EFMbzFe{3ngOQ9G|un$We+Kt=YW_K$z zF-(mbebmegMvO7>#l)DvzVjcLXnY~Qh>0)8#NeAzv7YalnY-OOC9}Ktdq3ygd(S=R z&Sm5Ejn$8a8r#VKYa(iWJXRC2nptS!XD>hd_}S0Tznhzzcni6?!#T*Mm9fj zml{&N3wz+Tj^>wbyEObh?WWeAEy@U#zb*H>hL568>mG4Ws=U3wHUHJqub#Jrn7Yy_7GkH&%Y;(ku3G`AO4nnsb0?CX>w?rDfZ=lTGK|EE@Lx z^vY`1-a&LPUwEU)Q@zVX9g)}HKy+ixE|xO++^zLhJ5F@VzF#u#WlGD&ZLwG|N_pcp zj24Vc&baN_EpWnIOP3axGr6T;jJhcvzL3r>Vzjw*AybSJP1)I{%-RZ1eX6ilEZSL2 zVa_hB@z>SNN_rR3v|U^*WL7bUl>6T9xN|q3&F1gPDzf>d%;KnF3>iire~j_NyOPQm z3ie{jNau?8?82x~u#2ntT+ud$jZ9JO^11A~kvZ6)msF9OKr%zC$2qa;n@ zVEHXj9jXPY({G`0O-?K!FLNCOJ;Y56yH`0xZJRs|&*46ybk*AG5GR01E$;624kuVB z0%1y_V+pNdZTQx$GDa{RPDv(tvt|4PLOzJ>qys|T^lfmmnEcP1%|W5KipA!jnsb{Y z7-yG6p-r%ukF_Zb(KCs2PpEdGdVH!~QHY)?yYrNn(BTgm5gSZC#-!(=llx+1amzsr zJGrArFhn(`Hsz3Dy{v&cq$or+7HkNo2b^)8i3eS%AXZ&M27A&aWWp!AKt`z1{kr1^ zt=8S>JnGa(n&=33*N~<07j0+;K^x%T+qFT_28APSk8nd8313hUT`w9ZnCd5-6rh|F+;K$00ck)*<0NB)gu??aPBJw_I5yCNI-sI)N=Rgg z*9U(%H_(E`fQrUxA#r|qeM~xpqXSJi=vOH;DkxSwDiaJ+2#)(zT+S%!j8HAUFAOoD z;&PU$e!_8t6`xfL#>jlP2m&+4m`*sMfQ_-@K%v?*I{vTyU5y9h?WY`rbD#zA=*rcc7ZjgYBoIZ#SrjPh;}(dyAq;Z4biSu zG(LYd??pOW5tVj5M4Q{DA$KNN)79xVQ5F0NwMB@tt`4?Ip&Y)%%Pvm}7My_yzb;oZ zq~KJQ!ztwu8=|X}O$h})B}9<2*dkq}?6jh$LE-)9O#r*5^DWRztn-3lZRe{dhJDo4 z9dAacZr^4`O$^d%X&~uACwHD)-$v8M51bq%UaW?oUSN zu6b72HOKIXrH~=?*1C@s{i8Qc{F2wRbOc=b~b<8?h=P?gXh@U-A6sKG4AA-gD;rPiFozna#D$Yg^55QaGQe z5V4)pK5g(%uh+v!&;*`?cH6~Woyi9xBIbtv$xITY*#kZJL>|I+1VE>O|Yp`X2i#gFO)v6XHg|ni+g7 z1LF`2pLLWvBh^B|Zze zlwiy)2=8^0+69wL7Q6^Q9d;u0Ko?21oy&GzHMXydKKjN2Qmo$4Li7gZMMs%t$~7*{ zRLRk#y+vo33eY#UmSIYFsEkL!JiRM|^mswo5MyPUh6tV+^lq0Jra6O_VJ~i&@)f4A zc*Ao$%aq|zS&xFN2AvqYR*tEP6LoWpxh}w2!?j!F88sa=&!p=ioHabR3rtoWvhZKc zB9rJ2HdbV^=0<)SRnvt-HD8FTT(QyxR$`IcjuMN|juP{3J7B6I+;-?pjZh9P#96gn zf^UX!+fin!?ojaCrr?`_ZghE_24kZRhE~`I9LAXx*}JI_Wr~JFRVZI&H9Rx9F<7)o zRL%1W>ZIxAi8P|x(d8)a&Ya`0}{+X%L1dfqjd!fgVo;Ze|;-bo$uniRuj;u7 z+$0ehOm9-{jTfz-jdRjkYCP4{!PMdI#IYtz>U;C7{)NC0jbj?PM}E=3br_@y*mY91 zCztB*=IY|=>dMm1(v`*a)s^LSx~u4pqtR*#F-uRez4k1jK1>#aA8&;&%Qvs3y4TmV bW~W-3jH|n?`&u|}{b+4SdEV-rd?^0{k)_Jm From 6b15778515dba8bde92f8fe6e288f501fbe4129c Mon Sep 17 00:00:00 2001 From: IbanGF Date: Tue, 5 Jan 2016 16:27:18 +0100 Subject: [PATCH 03/12] Fix saving new learning path item -ref CT#8018 --- main/newscorm/learnpath.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index d8d16f72e0..6209770c70 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -5982,7 +5982,7 @@ class learnpath $filename = $title; - $content = isset($content) ? $content : $_POST['content_lp']; + $content = !empty($content) ? $content : $_POST['content_lp']; $tmp_filename = $filename; From 3c8ecead9d0074e838416dee83468994ba275fd9 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 27 Jan 2016 10:28:27 +0100 Subject: [PATCH 04/12] Use api_get_session_id() --- main/forum/viewforum.php | 5 ++++- main/forum/viewforumcategory.php | 19 ++++++++----------- main/forum/viewthread.php | 4 +++- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/main/forum/viewforum.php b/main/forum/viewforum.php index b420369345..f117315c00 100755 --- a/main/forum/viewforum.php +++ b/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 .= ''; - $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 = ''; $html .= '
'; - $html .= Display::return_icon('post-forum.png', null, null, ICON_SIZE_SMALL); + $html .= Display::return_icon('post-forum.png', get_lang('Threads'), null, ICON_SIZE_SMALL); $html .= ' ' . $my_number_threads . '
' . $newPost . '
'; // the last post in the forum @@ -455,8 +453,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 .= '
$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').' '.get_lang('Back').'', + get_lang('YouMustAssignWeightOfQualification').' '. + get_lang('Back').'', 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 .= '
'.get_lang( - 'MessageHasToBeApproved' - ).'
'; + $message .= '
'.get_lang('MessageHasToBeApproved').'
'; } // 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; /* diff --git a/main/forum/index.php b/main/forum/index.php index cae84da8ce..3594a60c0b 100755 --- a/main/forum/index.php +++ b/main/forum/index.php @@ -490,7 +490,7 @@ if (is_array($forumCategories)) { $html .= '
'; $html .= '
'; $html .= '
'; - $html .= '
'.$forum_image.'

'.$number_posts.' ' . get_lang('Posts') . '

' + $html .= '
'.$forum_image.'

'.$number_threads.' ' . get_lang('ForumThreads') . '

' . '
'; $html .= '
'; @@ -556,13 +556,7 @@ if (is_array($forumCategories)) { $html .= '
'; $html .= '
'; $html .= '
'; - $html .= Display::return_icon( - 'post-forum.png', - get_lang('Forum'), - null, - ICON_SIZE_SMALL - ); - $html .= ' ' . $number_threads . '
'.$newPost.'
'; + $html .= $newPost.'
'; $html .= '
'; // The last post in the forum. diff --git a/main/forum/reply.php b/main/forum/reply.php index 6399358c53..7ee158d41e 100755 --- a/main/forum/reply.php +++ b/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). diff --git a/main/forum/viewforumcategory.php b/main/forum/viewforumcategory.php index c70b4e93ce..940cef6337 100755 --- a/main/forum/viewforumcategory.php +++ b/main/forum/viewforumcategory.php @@ -371,7 +371,7 @@ if ($action_forums != 'add') { $html .= '
'; $html .= '
'; $html .= '
'; - $html .= '
'.$forum_image .'

' . $my_number_posts . ' ' . get_lang('Posts') . '

'; + $html .= '
'.$forum_image .'

' . $my_number_threads . ' ' . get_lang('ForumThreads') . '

'; $html .= '
'; $html .= '
'; @@ -430,8 +430,7 @@ if ($action_forums != 'add') { $html .= '
'; $html .= '
'; - $html .= Display::return_icon('post-forum.png', get_lang('Threads'), null, ICON_SIZE_SMALL); - $html .= ' ' . $my_number_threads . '
' . $newPost . '
'; + $html .= $newPost . '
'; // the last post in the forum if ($forum['last_poster_name'] != '') { From c4f81fecd5f5fa4815a5ee4e57a73f6b1496dc93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Thu, 28 Jan 2016 18:15:29 -0500 Subject: [PATCH 06/12] Fix Multiselect ADV - Refs #10763 --- main/inc/lib/javascript/pear/qfamsHandler.js | 21 +++----------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/main/inc/lib/javascript/pear/qfamsHandler.js b/main/inc/lib/javascript/pear/qfamsHandler.js index 31d9d11e6e..9cc06e12c1 100755 --- a/main/inc/lib/javascript/pear/qfamsHandler.js +++ b/main/inc/lib/javascript/pear/qfamsHandler.js @@ -524,27 +524,12 @@ $(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'); } $('#' + 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(); - } - } + QFAMS.moveSelection('users', this.form.elements['users-f[]'], this.form.elements['users-t[]'], this.form.elements['users[]'], 'remove', 'none'); }); }); }); From 8ad23cc3bb77459d430597e14a6691873039ecd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Thu, 28 Jan 2016 18:20:49 -0500 Subject: [PATCH 07/12] little fix --- main/inc/lib/javascript/pear/qfamsHandler.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/main/inc/lib/javascript/pear/qfamsHandler.js b/main/inc/lib/javascript/pear/qfamsHandler.js index 9cc06e12c1..4c264dfaef 100755 --- a/main/inc/lib/javascript/pear/qfamsHandler.js +++ b/main/inc/lib/javascript/pear/qfamsHandler.js @@ -526,10 +526,9 @@ $(function() { if (!checked) { $('#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'); - } - - $('#' + selectDestinationId +' option').each(function() { + } 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'); - }); + } }); }); From f37e2596ca5195fe6f7b18eeb0be67d175bbbd1b Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 28 Jan 2016 14:09:12 -0500 Subject: [PATCH 08/12] Avoid fatal error if, for some reason, the course object could not be properly instantiated in partial course import - refs BT#10760 --- main/coursecopy/import_backup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/coursecopy/import_backup.php b/main/coursecopy/import_backup.php index b4c0c968eb..9653d55853 100755 --- a/main/coursecopy/import_backup.php +++ b/main/coursecopy/import_backup.php @@ -89,7 +89,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(); From 9f292516b2cd1da84d69ae6aba48baaa7513bdd5 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 28 Jan 2016 18:11:09 -0500 Subject: [PATCH 09/12] Add comment about Suhosin limits blocking courses import - refs BT#10760 --- main/coursecopy/import_backup.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main/coursecopy/import_backup.php b/main/coursecopy/import_backup.php index 9653d55853..7475770c05 100755 --- a/main/coursecopy/import_backup.php +++ b/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 { From 5cf49b50ade7177b9c8a39aab441ce14b1452d9f Mon Sep 17 00:00:00 2001 From: appchecker Date: Sat, 30 Jan 2016 23:34:42 +0300 Subject: [PATCH 10/12] fix: variable $ldap_user has not been initialized --- main/auth/cas/authcas.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/auth/cas/authcas.php b/main/auth/cas/authcas.php index 673c228baa..27e22c1b50 100755 --- a/main/auth/cas/authcas.php +++ b/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; From 7e07d38ffdc7474ebab8a7e9b1d372cd73695d01 Mon Sep 17 00:00:00 2001 From: appchecker Date: Sun, 31 Jan 2016 18:32:09 +0300 Subject: [PATCH 11/12] fix function return value --- main/inc/lib/AnnouncementManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/inc/lib/AnnouncementManager.php b/main/inc/lib/AnnouncementManager.php index 20f295bc27..d995b1a35a 100755 --- a/main/inc/lib/AnnouncementManager.php +++ b/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(''); From 6db2ef0ee7e0b77885ab369d4e79e9d3c3d4c625 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 1 Feb 2016 14:27:52 +0100 Subject: [PATCH 12/12] Fix sql errors seee #8059 --- main/inc/lib/urlmanager.lib.php | 2 +- main/inc/lib/usermanager.lib.php | 44 ++++++++++++++++++++------------ 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/main/inc/lib/urlmanager.lib.php b/main/inc/lib/urlmanager.lib.php index b6c60afac7..e94a67afc1 100755 --- a/main/inc/lib/urlmanager.lib.php +++ b/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 diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php index 7a9fee64c8..2baa974d65 100755 --- a/main/inc/lib/usermanager.lib.php +++ b/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,