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.
This commit is contained in:
Kane York 2014-01-13 15:27:23 -08:00 committed by riking
parent 92cb52e76e
commit 24e30aff87

View file

@ -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)