MDL-43709 Forum: Reset forums not working with multiple forum types

The SQL being generated from the selected forum types on the course reset
form was using AND, resulting in never matching anything if more than one
forum type was selected for resetting (as each forum can only have one
type).  This should use $DB->get_in_or_equal() to generate sensible SQL.
This commit is contained in:
Paul Nicholls 2015-07-13 15:00:16 +12:00
parent 9325cd963f
commit 8ff7531ed7

View file

@ -6811,16 +6811,20 @@ function forum_reset_userdata($data) {
$types = array(); $types = array();
} else if (!empty($data->reset_forum_types)){ } else if (!empty($data->reset_forum_types)){
$removeposts = true; $removeposts = true;
$typesql = "";
$types = array(); $types = array();
$sqltypes = array();
$forum_types_all = forum_get_forum_types_all(); $forum_types_all = forum_get_forum_types_all();
foreach ($data->reset_forum_types as $type) { foreach ($data->reset_forum_types as $type) {
if (!array_key_exists($type, $forum_types_all)) { if (!array_key_exists($type, $forum_types_all)) {
continue; continue;
} }
$typesql .= " AND f.type=?";
$types[] = $forum_types_all[$type]; $types[] = $forum_types_all[$type];
$params[] = $type; $sqltypes[] = $type;
}
if (!empty($sqltypes)) {
list($typesql, $typeparams) = $DB->get_in_or_equal($sqltypes);
$typesql = " AND f.type " . $typesql;
$params = array_merge($params, $typeparams);
} }
$typesstr = get_string('resetforums', 'forum').': '.implode(', ', $types); $typesstr = get_string('resetforums', 'forum').': '.implode(', ', $types);
} }