From 24e30aff87b7a61ce53d6a5be8d63a7f926777c9 Mon Sep 17 00:00:00 2001 From: Kane York Date: Mon, 13 Jan 2014 15:27:23 -0800 Subject: [PATCH 1/2] Fix group matching SQL query The check there is intended for the :members_mods_and_admins level, which is not automatically checked for normal users. Instead, the :everyone level is the one used, which would always fulfill the "alias_level in :levels" check. This changes the :everyone level to :members_mods_and_admins, which was originally intended. --- app/models/group.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/group.rb b/app/models/group.rb index 848b1a4b832..69b765b9bac 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -125,7 +125,7 @@ class Group < ActiveRecord::Base Group.where("name LIKE :term_like AND (" + " alias_level in (:levels)" + - " OR (alias_level = #{ALIAS_LEVELS[:everyone]} AND id in (" + + " OR (alias_level = #{ALIAS_LEVELS[:members_mods_and_admins]} AND id in (" + "SELECT group_id FROM group_users WHERE user_id= :user_id)" + ")" + ")", term_like: "#{name.downcase}%", levels: levels, user_id: current_user.id) From 0dd317dd74ae42ff26adf5a10d9bd2d9fd48f8d9 Mon Sep 17 00:00:00 2001 From: riking Date: Mon, 13 Jan 2014 16:00:22 -0800 Subject: [PATCH 2/2] Change to case-insensitive matching in group @name matching --- app/models/group.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/group.rb b/app/models/group.rb index 69b765b9bac..15ce948714e 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -123,7 +123,7 @@ class Group < ActiveRecord::Base ALIAS_LEVELS[:members_mods_and_admins]] end - Group.where("name LIKE :term_like AND (" + + Group.where("name ILIKE :term_like AND (" + " alias_level in (:levels)" + " OR (alias_level = #{ALIAS_LEVELS[:members_mods_and_admins]} AND id in (" + "SELECT group_id FROM group_users WHERE user_id= :user_id)" +