From 93c39159bd0d812ac538e41ecbab4b4388b629c4 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 28 Jan 2010 15:42:34 -0500 Subject: [PATCH] =?UTF-8?q?Student=20publications=20are=20deleted=20when?= =?UTF-8?q?=20an=20user=20is=20unsubscribed=20of=20a=20course=20by=20Andr?= =?UTF-8?q?=C3=A9=20Boivin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/inc/lib/course.lib.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index 4b7d754874..a537922a81 100644 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -253,7 +253,8 @@ class CourseManager { if (count($user_id) == 0) { return; } - + $table_user = Database :: get_main_table(TABLE_MAIN_USER); + $user_ids = implode(',', $user_id); $course_code = Database::escape_string($course_code); @@ -265,16 +266,32 @@ class CourseManager { WHERE user_id IN (".$user_ids.")", __FILE__, __LINE__); Database::query("DELETE FROM ".Database::get_course_table(TABLE_GROUP_TUTOR, $course->db_name)." WHERE user_id IN (".$user_ids.")", __FILE__, __LINE__); - + + // Erase user student publications (works) in the course - by André Boivin + //@todo field student_publication.author should be the user id + + $table_course_user_publication = Database :: get_course_table(TABLE_STUDENT_PUBLICATION, $course->db_name); + $sqlu = "SELECT * FROM $table_user WHERE user_id IN (".$user_ids.")"; + $resu = Database::query($sqlu, __FILE__, __LINE__); + $username = Database::fetch_array($resu,'ASSOC'); + $userfirstname = $username['firstname']; + $userlastname = $username['lastname']; + $publication_name = $userfirstname.' '.$userlastname ; + + $sql = "DELETE FROM $table_course_user_publication WHERE author = '".Database::escape_string($publication_name)."'"; + Database::query($sql, __FILE__, __LINE__); + + // Unsubscribe user from all blogs in the course. Database::query("DELETE FROM ".Database::get_course_table(TABLE_BLOGS_REL_USER, $course->db_name)." WHERE user_id IN (".$user_ids.")", __FILE__, __LINE__); Database::query("DELETE FROM ".Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER, $course->db_name)." WHERE user_id IN (".$user_ids.")", __FILE__, __LINE__); + + // Unsubscribe user from the course. if (!empty($_SESSION['id_session'])) { // We suppose the session is safe! - // Delete in table session_rel_course_rel_user $my_session_id = intval ($_SESSION['id_session']); Database::query("DELETE FROM ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)."