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 / project_patch.rb @ 727:e3e958595e07
History | View | Annotate | Download (1.54 KB)
| 1 | 727:e3e958595e07 | luis | # C4DM
|
|---|---|---|---|
| 2 | |||
| 3 | require_dependency 'project'
|
||
| 4 | |||
| 5 | module RedmineTags |
||
| 6 | module Patches |
||
| 7 | module ProjectPatch |
||
| 8 | def self.included(base) |
||
| 9 | base.extend(ClassMethods)
|
||
| 10 | |||
| 11 | base.class_eval do
|
||
| 12 | unloadable |
||
| 13 | acts_as_taggable |
||
| 14 | end
|
||
| 15 | end
|
||
| 16 | |||
| 17 | module ClassMethods |
||
| 18 | # Returns available issue tags
|
||
| 19 | # === Parameters
|
||
| 20 | # * <i>options</i> = (optional) Options hash of
|
||
| 21 | # * project - Project to search in.
|
||
| 22 | # * open_only - Boolean. Whenever search within open issues only.
|
||
| 23 | # * name_like - String. Substring to filter found tags.
|
||
| 24 | def available_tags(options = {}) |
||
| 25 | project = options[:project]
|
||
| 26 | open_only = options[:open_only]
|
||
| 27 | name_like = options[:name_like]
|
||
| 28 | options = {}
|
||
| 29 | visible = ARCondition.new
|
||
| 30 | |||
| 31 | if project
|
||
| 32 | project = project.id if project.is_a? Project |
||
| 33 | visible << ["#{Issue.table_name}.project_id = ?", project]
|
||
| 34 | end
|
||
| 35 | |||
| 36 | if open_only
|
||
| 37 | visible << ["#{Issue.table_name}.status_id IN " +
|
||
| 38 | "( SELECT issue_status.id " +
|
||
| 39 | " FROM #{IssueStatus.table_name} issue_status " +
|
||
| 40 | " WHERE issue_status.is_closed = ? )", false] |
||
| 41 | end
|
||
| 42 | |||
| 43 | if name_like
|
||
| 44 | visible << ["#{ActsAsTaggableOn::Tag.table_name}.name LIKE ?", "%#{name_like.downcase}%"] |
||
| 45 | end
|
||
| 46 | |||
| 47 | options[:conditions] = visible.conditions
|
||
| 48 | self.all_tag_counts(options)
|
||
| 49 | end
|
||
| 50 | end
|
||
| 51 | end
|
||
| 52 | end
|
||
| 53 | end |