From b9ecde873841353e782cf9825ce5f5484960dc91 Mon Sep 17 00:00:00 2001 From: skodak Date: Tue, 17 Oct 2006 21:06:50 +0000 Subject: [PATCH] Fix forum reset - remove "DELETE .. USING ... " mysqlisms MDL-7053 ; merged from MOODLE_17_STABLE --- mod/forum/lib.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 6d52fdfea7..f7cb62c462 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -4322,44 +4322,42 @@ function forum_check_throttling($forum) { function forum_delete_userdata($data, $showfeedback=true) { global $CFG; - $sql = 'DELETE FROM '.$CFG->prefix.'forum_posts - USING '.$CFG->prefix.'forum_discussions fd, - '.$CFG->prefix.'forum_posts fp, - '.$CFG->prefix.'forum f - WHERE fp.discussion=fd.id and f.course='.$data->courseid.' AND f.id=fd.forum'; + $sql = "DELETE FROM {$CFG->prefix}forum_posts + WHERE discussion IN ( + SELECT fd.id FROM {$CFG->prefix}forum_discussions fd, {$CFG->prefix}forum f + WHERE f.course={$data->courseid} AND f.id=fd.forum "; // closing ) added bellow $strreset = get_string('reset'); if (!empty($data->reset_forum_news)) { - $select = "$sql and f.type = 'news' "; + $select = "$sql AND f.type = 'news' )"; if (execute_sql($select, false) and $showfeedback) { notify($strreset.': '.get_string('namenews','forum'), 'notifysuccess'); } } if (!empty($data->reset_forum_single)) { - $select = "$sql and f.type = 'single' and fp.parent > 0 "; + $select = "$sql AND f.type = 'single' and fp.parent > 0 )"; if (execute_sql($select, false) and $showfeedback) { notify($strreset.': '.get_string('singleforum','forum'), 'notifysuccess'); } } if (!empty($data->reset_forum_eachuser)) { - $select = "$sql and f.type = 'eachuser' "; + $select = "$sql AND f.type = 'eachuser' )"; if (execute_sql($select, false) and $showfeedback) { notify($strreset.': '.get_string('eachuserforum','forum'), 'notifysuccess'); } } if (!empty($data->reset_forum_general)) { - $select = "$sql and f.type = 'general' "; + $select = "$sql AND f.type = 'general' )"; if (execute_sql($select, false) and $showfeedback) { notify($strreset.': '.get_string('generalforum','forum'), 'notifysuccess'); } } if (!empty($data->reset_forum_subscriptions)) { $subscripsql = "DELETE FROM {$CFG->prefix}forum_subscriptions - USING {$CFG->prefix}forum_subscriptions fs, - {$CFG->prefix}forum f - WHERE fs.forum = f.id - AND f.course = {$data->courseid}"; + WHERE forum IN ( + SELECT id FROM {$CFG->prefix}forum + WHERE course = {$data->courseid} )"; if (execute_sql($subscripsql, false) and $showfeedback) { notify($strreset.': '.get_string('resetsubscriptions','forum'), 'notifysuccess'); -- 2.39.5