]> source.dussan.org Git - redmine.git/commitdiff
Use Query.visible scope.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 4 Dec 2011 23:05:11 +0000 (23:05 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 4 Dec 2011 23:05:11 +0000 (23:05 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8086 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/issues_helper.rb

index d99256f29ff138459fdf5aeb742178da7af09a29..169a0de5ffbec77cdf92263bf2457108afb10a29 100644 (file)
@@ -129,14 +129,11 @@ module IssuesHelper
 
   def sidebar_queries
     unless @sidebar_queries
-      # User can see public queries and his own queries
-      visible = ARCondition.new(["is_public = ? OR user_id = ?", true, (User.current.logged? ? User.current.id : 0)])
-      # Project specific queries and global queries
-      visible << (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id])
-      @sidebar_queries = Query.find(:all,
-                                    :select => 'id, name, is_public',
-                                    :order => "name ASC",
-                                    :conditions => visible.conditions)
+      @sidebar_queries = Query.visible.all(
+        :order => "#{Query.table_name}.name ASC",
+        # Project specific queries and global queries
+        :conditions => (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id])
+      )
     end
     @sidebar_queries
   end