To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / vendor / plugins / redmine_tags / lib / redmine_tags / patches / issue_patch.rb @ 996:c43450d54787
History | View | Annotate | Download (2.28 KB)
| 1 |
# This file is a part of redmine_tags
|
|---|---|
| 2 |
# redMine plugin, that adds tagging support.
|
| 3 |
#
|
| 4 |
# Copyright (c) 2010 Aleksey V Zapparov AKA ixti
|
| 5 |
#
|
| 6 |
# redmine_tags is free software: you can redistribute it and/or modify
|
| 7 |
# it under the terms of the GNU General Public License as published by
|
| 8 |
# the Free Software Foundation, either version 3 of the License, or
|
| 9 |
# (at your option) any later version.
|
| 10 |
#
|
| 11 |
# redmine_tags is distributed in the hope that it will be useful,
|
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
# GNU General Public License for more details.
|
| 15 |
#
|
| 16 |
# You should have received a copy of the GNU General Public License
|
| 17 |
# along with redmine_tags. If not, see <http://www.gnu.org/licenses/>.
|
| 18 |
|
| 19 |
require_dependency 'issue'
|
| 20 |
|
| 21 |
module RedmineTags |
| 22 |
module Patches |
| 23 |
module IssuePatch |
| 24 |
def self.included(base) |
| 25 |
base.extend(ClassMethods)
|
| 26 |
|
| 27 |
base.class_eval do
|
| 28 |
unloadable |
| 29 |
acts_as_taggable |
| 30 |
end
|
| 31 |
end
|
| 32 |
|
| 33 |
module ClassMethods |
| 34 |
# Returns available issue tags
|
| 35 |
# === Parameters
|
| 36 |
# * <i>options</i> = (optional) Options hash of
|
| 37 |
# * project - Project to search in.
|
| 38 |
# * open_only - Boolean. Whenever search within open issues only.
|
| 39 |
# * name_like - String. Substring to filter found tags.
|
| 40 |
def available_tags(options = {}) |
| 41 |
project = options[:project]
|
| 42 |
open_only = options[:open_only]
|
| 43 |
name_like = options[:name_like]
|
| 44 |
options = {}
|
| 45 |
visible = ARCondition.new
|
| 46 |
|
| 47 |
if project
|
| 48 |
project = project.id if project.is_a? Project |
| 49 |
visible << ["#{Issue.table_name}.project_id = ?", project]
|
| 50 |
end
|
| 51 |
|
| 52 |
if open_only
|
| 53 |
visible << ["#{Issue.table_name}.status_id IN " +
|
| 54 |
"( SELECT issue_status.id " +
|
| 55 |
" FROM #{IssueStatus.table_name} issue_status " +
|
| 56 |
" WHERE issue_status.is_closed = ? )", false] |
| 57 |
end
|
| 58 |
|
| 59 |
if name_like
|
| 60 |
visible << ["#{ActsAsTaggableOn::Tag.table_name}.name LIKE ?", "%#{name_like.downcase}%"] |
| 61 |
end
|
| 62 |
|
| 63 |
options[:conditions] = visible.conditions
|
| 64 |
self.all_tag_counts(options)
|
| 65 |
end
|
| 66 |
end
|
| 67 |
end
|
| 68 |
end
|
| 69 |
end
|