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 @ 1081:b56a4c5afa35
History | View | Annotate | Download (1.23 KB)
| 1 | 727:e3e958595e07 | luis | # C4DM
|
|---|---|---|---|
| 2 | |||
| 3 | require_dependency 'project'
|
||
| 4 | |||
| 5 | module RedmineTags |
||
| 6 | module Patches |
||
| 7 | module ProjectPatch |
||
| 8 | 729:291c4d7dc0b6 | luis | def self.included(base) # :nodoc: |
| 9 | 727:e3e958595e07 | luis | base.extend(ClassMethods)
|
| 10 | 730:4a9bb3b8d5cd | luis | base.send(:include, InstanceMethods) |
| 11 | 727:e3e958595e07 | luis | |
| 12 | base.class_eval do
|
||
| 13 | unloadable |
||
| 14 | 730:4a9bb3b8d5cd | luis | |
| 15 | attr_accessor :tag_list
|
||
| 16 | 727:e3e958595e07 | luis | acts_as_taggable |
| 17 | 730:4a9bb3b8d5cd | luis | |
| 18 | 727:e3e958595e07 | luis | end
|
| 19 | end
|
||
| 20 | |||
| 21 | 730:4a9bb3b8d5cd | luis | module InstanceMethods |
| 22 | end
|
||
| 23 | 729:291c4d7dc0b6 | luis | |
| 24 | 727:e3e958595e07 | luis | module ClassMethods |
| 25 | 739:b7ac21913927 | luis | def search_by_question(question) |
| 26 | if question.length > 1 |
||
| 27 | search(RedmineProjectFiltering.calculate_tokens(question), nil, :all_words => true).first.sort_by(&:lft) |
||
| 28 | else
|
||
| 29 | all(:order => 'lft') |
||
| 30 | end
|
||
| 31 | end
|
||
| 32 | |||
| 33 | |||
| 34 | 745:4acfc770e79f | luis | # Returns available project tags
|
| 35 | # does not show tags from private projects
|
||
| 36 | 746:2ced57750157 | luis | def available_tags( options = {} ) |
| 37 | |||
| 38 | name_like = options[:name_like]
|
||
| 39 | 745:4acfc770e79f | luis | options = {}
|
| 40 | 727:e3e958595e07 | luis | visible = ARCondition.new
|
| 41 | 1073:3af6f66496a5 | luis | |
| 42 | 814:03d855015db8 | Chris | visible << ["#{Project.table_name}.is_public = '1'"]
|
| 43 | 746:2ced57750157 | luis | |
| 44 | if name_like
|
||
| 45 | visible << ["#{ActsAsTaggableOn::Tag.table_name}.name LIKE ?", "%#{name_like.downcase}%"] |
||
| 46 | end
|
||
| 47 | |||
| 48 | 727:e3e958595e07 | luis | options[:conditions] = visible.conditions
|
| 49 | 746:2ced57750157 | luis | |
| 50 | 1073:3af6f66496a5 | luis | self.all_tag_counts(options)
|
| 51 | 727:e3e958595e07 | luis | end
|
| 52 | end
|
||
| 53 | end
|
||
| 54 | end
|
||
| 55 | end |