Revision 745:4acfc770e79f

View differences:

vendor/plugins/redmine_tags/lib/redmine_tags/patches/project_patch.rb
48 48
      end
49 49

  
50 50
      module ClassMethods
51

  
52

  
53 51
        def search_by_question(question)
54 52
          if question.length > 1
55 53
            search(RedmineProjectFiltering.calculate_tokens(question), nil, :all_words => true).first.sort_by(&:lft)
......
59 57
        end
60 58

  
61 59

  
62
        # Returns available issue tags
63
        # === Parameters
64
        # * <i>options</i> = (optional) Options hash of
65
        #   * project   - Project to search in.
66
        #   * open_only - Boolean. Whenever search within open issues only.
67
        #   * name_like - String. Substring to filter found tags.
68
        def available_tags(options = {})
69
          project   = options[:project]
70
          open_only = options[:open_only]
71
          name_like = options[:name_like]
72
          options   = {}
60
        # Returns available project tags
61
        #  does not show tags from private projects
62
        def available_tags
63
          options = {}
73 64
          visible   = ARCondition.new
74
          
75
          if project
76
            project = project.id if project.is_a? Project
77
            visible << ["#{Issue.table_name}.project_id = ?", project]
78
          end
79

  
80
          if open_only
81
            visible << ["#{Project.table_name}.status_id IN " +
82
                        "( SELECT issue_status.id " + 
83
                        "    FROM #{IssueStatus.table_name} issue_status " +
84
                        "   WHERE issue_status.is_closed = ? )", false]
85
          end
86

  
87
          if name_like
88
            visible << ["#{ActsAsTaggableOn::Tag.table_name}.name LIKE ?", "%#{name_like.downcase}%"]
89
          end
90

  
65
                  
66
          visible << ["#{Project.table_name}.is_public = \"1\""]
91 67
          options[:conditions] = visible.conditions
92
          self.all_tag_counts(options)
68
          self.all_tag_counts(options)          
93 69
        end
94 70
      end
95 71
    end

Also available in: Unified diff