fix query for un-permitted category use

This commit is contained in:
Matt K. Fu 2013-06-26 10:46:50 +08:00
parent 869f3b6815
commit 6a40a9555a
1 changed files with 3 additions and 2 deletions

View File

@ -79,9 +79,10 @@ module OrbitCoreLib
else
auth_object_space = ObjectAuth.where(obj_authable_type: self.to_s,title: title)
end
query1 = auth_object_space.any_in({sub_role_ids: sub_role_ids_ary}).excludes(blocked_user_ids: user.id)
query2 = auth_object_space.any_of({all: true},{privilege_user_ids: user.id},{role_ids: user.role_ids}).excludes(blocked_user_ids: user.id)
query2 = auth_object_space.any_of({all: true},{privilege_user_ids: user.id}).excludes(blocked_user_ids: user.id)
# query2 = auth_object_space.any_of({all: true},{privilege_user_ids: user.id},{role_ids: user.role_ids}).excludes(blocked_user_ids: user.id) #save for backup if something went wrong (0626 Matt)
result = (query1 + query2).uniq
result.collect{|t| t.obj_authable}.delete_if{|val| val==nil}
end