From 04a69bf784486f208aab4a47c7087e633d4b882a Mon Sep 17 00:00:00 2001 From: jmontoya Date: Wed, 3 Jul 2013 19:01:08 +0200 Subject: [PATCH] Fixing SQL queries --- main/forum/forumfunction.inc.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index e4b60fc92d..f418fb4ee3 100644 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -487,9 +487,7 @@ function store_forumcategory($values) $table_categories = Database::get_course_table(TABLE_FORUM_CATEGORY); // Find the max cat_order. The new forum category is added at the end => max cat_order + & - $sql = "SELECT MAX(cat_order) as sort_max FROM ".Database::escape_string( - $table_categories - )." WHERE c_id = $course_id"; + $sql = "SELECT MAX(cat_order) as sort_max FROM $table_categories WHERE c_id = $course_id"; $result = Database::query($sql); $row = Database::fetch_array($result); $new_max = $row['sort_max'] + 1; @@ -1183,7 +1181,7 @@ function move_up_down($content, $direction, $id) // The SQL statement if ($content == 'forumcategory') { - $sql = "SELECT * FROM".$table_categories." forum_categories, ".$table_item_property." item_properties + $sql = "SELECT * FROM ".$table_categories." forum_categories, ".$table_item_property." item_properties WHERE forum_categories.c_id = $course_id AND item_properties.c_id = $course_id AND @@ -1192,7 +1190,7 @@ function move_up_down($content, $direction, $id) ORDER BY forum_categories.cat_order $sort_direction"; } if ($content == 'forum') { - $sql = "SELECT * FROM".$table." WHERE c_id = $course_id AND forum_category='".Database::escape_string( + $sql = "SELECT * FROM ".$table." WHERE c_id = $course_id AND forum_category='".Database::escape_string( $forum_category )."' ORDER BY forum_order $sort_direction"; } @@ -1270,20 +1268,20 @@ function get_forum_categories($id = '') $condition_session .= "AND forum_categories.c_id = $course_id AND item_properties.c_id = $course_id"; if ($id == '') { - $sql = "SELECT * FROM".$table_categories." forum_categories, ".$table_item_property." item_properties + $sql = "SELECT * FROM ".$table_categories." forum_categories, ".$table_item_property." item_properties WHERE forum_categories.cat_id=item_properties.ref AND item_properties.visibility=1 AND item_properties.tool='".TOOL_FORUM_CATEGORY."' $condition_session ORDER BY forum_categories.cat_order ASC"; if (is_allowed_to_edit()) { - $sql = "SELECT * FROM".$table_categories." forum_categories, ".$table_item_property." item_properties + $sql = "SELECT * FROM ".$table_categories." forum_categories, ".$table_item_property." item_properties WHERE forum_categories.cat_id=item_properties.ref AND item_properties.visibility<>2 AND item_properties.tool='".TOOL_FORUM_CATEGORY."' $condition_session ORDER BY forum_categories.cat_order ASC"; } } else { - $sql = "SELECT * FROM".$table_categories." forum_categories, ".$table_item_property." item_properties + $sql = "SELECT * FROM ".$table_categories." forum_categories, ".$table_item_property." item_properties WHERE forum_categories.cat_id=item_properties.ref AND item_properties.tool='".TOOL_FORUM_CATEGORY."' AND forum_categories.cat_id='".Database::escape_string($id)."' $condition_session