From c649b13798c598468ff20823a136748451a98bb5 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 22 Jan 2013 14:32:39 +0100 Subject: [PATCH] Removing survey invitation data see #5847 --- main/inc/lib/usermanager.lib.php | 11 +++++++---- main/survey/survey.lib.php | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php index 3656370444..56145b3a09 100644 --- a/main/inc/lib/usermanager.lib.php +++ b/main/inc/lib/usermanager.lib.php @@ -270,7 +270,7 @@ class UserManager $table_user = Database :: get_main_table(TABLE_MAIN_USER); $usergroup_rel_user = Database :: get_main_table(TABLE_USERGROUP_REL_USER); $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER); - $table_class_user = Database :: get_main_table(TABLE_MAIN_CLASS_USER); + //$table_class_user = Database :: get_main_table(TABLE_MAIN_CLASS_USER); $table_course = Database :: get_main_table(TABLE_MAIN_COURSE); $table_admin = Database :: get_main_table(TABLE_MAIN_ADMIN); $table_session_user = Database :: get_main_table(TABLE_MAIN_SESSION_USER); @@ -339,10 +339,9 @@ class UserManager $sql = 'DELETE FROM '.$gradebook_results_table.' WHERE user_id = '.$user_id; Database::query($sql); - $user = Database::fetch_array($res); $t_ufv = Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES); $sqlv = "DELETE FROM $t_ufv WHERE user_id = $user_id"; - $resv = Database::query($sqlv); + Database::query($sqlv); require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php'; if (api_get_multiple_access_url()) { @@ -367,9 +366,13 @@ class UserManager //Delete user from friend lists SocialManager::remove_user_rel_user($user_id, true); } + + //Removing survey invitation + survey_manager::delete_all_survey_invitations_by_user($user_id); + // Delete students works $sqlw = "DELETE FROM $table_work WHERE user_id = $user_id"; - $resw = Database::query($sqlw); + Database::query($sqlw); unset($sqlw); // Add event to system log $user_id_manager = api_get_user_id(); diff --git a/main/survey/survey.lib.php b/main/survey/survey.lib.php index e5bd8bcdb2..661c81df51 100644 --- a/main/survey/survey.lib.php +++ b/main/survey/survey.lib.php @@ -1,6 +1,8 @@ , Ghent University: cleanup, refactoring and rewriting large parts (if not all) of the code * @author Julio Montoya Armas , Chamilo: Personality Test modification and rewriting large parts of the code @@ -21,12 +23,20 @@ $htmlHeadXtra[] = ''; -/** - * Survey manager class - * @package chamilo.survey - */ + class survey_manager { + public static function delete_all_survey_invitations_by_user($user_id) { + $user_id = intval($user_id); + + if (empty($user_id)) { + return false; + } + $table_survey_invitation = Database :: get_course_table(TABLE_SURVEY_INVITATION); + $sql = "DELETE FROM $table_survey_invitation WHERE user = '$user_id'"; + Database::query($sql); + } + public static function get_surveys($course_code, $session_id = 0) { $table_survey = Database :: get_course_table(TABLE_SURVEY); $course_info = api_get_course_info($course_code);