浏览代码

Fix delete user reporting

jmontoyaa 8 年之前
父节点
当前提交
4fd65a8066
共有 1 个文件被更改,包括 7 次插入4 次删除
  1. 7 4
      main/survey/survey.lib.php

+ 7 - 4
main/survey/survey.lib.php

@@ -1958,11 +1958,13 @@ class SurveyUtil
         $table_survey = Database:: get_course_table(TABLE_SURVEY);
 
         $course_id = api_get_course_int_id();
+        $survey_id = (int) $survey_id;
+        $user_id = Database::escape_string($user_id);
 
         if (!empty($survey_id) && !empty($user_id)) {
             // delete data from survey_answer by user_id and survey_id
             $sql = "DELETE FROM $table_survey_answer
-			        WHERE c_id = $course_id AND survey_id = '".(int)$survey_id."' AND user = '".(int)$user_id."'";
+			        WHERE c_id = $course_id AND survey_id = '".$survey_id."' AND user = '".$user_id."'";
             Database::query($sql);
             // update field answered from survey_invitation by user_id and survey_id
             $sql = "UPDATE $table_survey_invitation SET answered = '0'
@@ -1972,15 +1974,16 @@ class SurveyUtil
                             SELECT code FROM $table_survey
                             WHERE
                                 c_id = $course_id AND
-                                survey_id = '".(int)$survey_id."'
+                                survey_id = '".$survey_id."'
                         ) AND
-			            user = '".(int)$user_id."'";
+			            user = '".$user_id."'";
             $result = Database::query($sql);
         }
 
         if ($result !== false) {
             $message = get_lang('SurveyUserAnswersHaveBeenRemovedSuccessfully').'<br />
-					<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=userreport&survey_id='.intval($survey_id).'">'.get_lang('GoBack').'</a>';
+					<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=userreport&survey_id='.$survey_id.'">'.
+                get_lang('GoBack').'</a>';
             Display::display_confirmation_message($message, false);
         }
     }