To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / vendor / plugins / redmine_tags / lib / redmine_tags / patches / project_patch.rb @ 1015:52be96e83080

History | View | Annotate | Download (2.22 KB)

1
# C4DM
2

    
3
require_dependency 'project'
4

    
5
module RedmineTags
6
  module Patches
7
    module ProjectPatch
8
      def self.included(base) # :nodoc:
9
        base.extend(ClassMethods)
10
        base.send(:include, InstanceMethods)
11

    
12
        base.class_eval do
13
          unloadable
14

    
15
          attr_accessor :tag_list
16

    
17
          acts_as_taggable
18

    
19
        end
20
      end
21

    
22
      def before_save_with_save_tags()
23
#        debugger
24
        logger.error { "GONNA SAVE TAG LIST" }
25

    
26

    
27
#        params[:tag_list]
28
        
29
        
30
        # logger.error { @project.name }
31

    
32
    #    if params && params[:project] && !params[:project][:tag_list].nil?
33
    #      old_tags = context[:project].tag_list.to_s
34
    #      context[:project].tag_list = params[:project][:tag_list]
35
    #      new_tags = context[:project].tag_list.to_s
36
    #
37
    #      unless (old_tags == new_tags || context[:project].current_journal.blank?)
38
    #        context[:project].current_journal.details << JournalDetail.new(:property => 'attr',
39
    #                                                                     :prop_key => 'tag_list',
40
    #                                                                     :old_value => old_tags,
41
    #                                                                     :value => new_tags)
42
    #      end
43
    #    end
44
      end
45
      
46
      module InstanceMethods
47
        
48
      end
49

    
50
      module ClassMethods
51
        def search_by_question(question)
52
          if question.length > 1
53
            search(RedmineProjectFiltering.calculate_tokens(question), nil, :all_words => true).first.sort_by(&:lft)
54
          else
55
            all(:order => 'lft')
56
          end
57
        end
58

    
59

    
60
        # Returns available project tags
61
        #  does not show tags from private projects
62
        def available_tags( options = {} )
63

    
64
          name_like = options[:name_like]
65
          options = {}
66
          visible   = ARCondition.new
67
                  
68
          visible << ["#{Project.table_name}.is_public = '1'"]
69

    
70
          if name_like
71
            visible << ["#{ActsAsTaggableOn::Tag.table_name}.name LIKE ?", "%#{name_like.downcase}%"]
72
          end
73

    
74
          options[:conditions] = visible.conditions
75

    
76
          self.all_tag_counts(options)          
77
        end
78
      end
79
    end
80
  end
81
end