diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-09-29 10:37:08 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-09-29 10:37:08 +0000 |
commit | cae547a7ea519aa2519053e366aecba378e787c6 (patch) | |
tree | 8ca01dea0bdd70620afcb7ac4ec77a769d0aa0d9 /lib | |
parent | f2a5304d648f865bb6d46c51b6c46f451d9cf994 (diff) | |
download | redmine-cae547a7ea519aa2519053e366aecba378e787c6.tar.gz redmine-cae547a7ea519aa2519053e366aecba378e787c6.zip |
Redmine acts_as_* plugins moved to vendor/plugins.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@774 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r-- | lib/plugins/acts_as_event/init.rb | 2 | ||||
-rw-r--r-- | lib/plugins/acts_as_event/lib/acts_as_event.rb | 68 | ||||
-rw-r--r-- | lib/plugins/acts_as_searchable/init.rb | 2 | ||||
-rw-r--r-- | lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb | 89 | ||||
-rw-r--r-- | lib/plugins/acts_as_watchable/init.rb | 3 | ||||
-rw-r--r-- | lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb | 53 |
6 files changed, 0 insertions, 217 deletions
diff --git a/lib/plugins/acts_as_event/init.rb b/lib/plugins/acts_as_event/init.rb deleted file mode 100644 index 91051510a..000000000 --- a/lib/plugins/acts_as_event/init.rb +++ /dev/null @@ -1,2 +0,0 @@ -require File.dirname(__FILE__) + '/lib/acts_as_event' -ActiveRecord::Base.send(:include, Redmine::Acts::Event) diff --git a/lib/plugins/acts_as_event/lib/acts_as_event.rb b/lib/plugins/acts_as_event/lib/acts_as_event.rb deleted file mode 100644 index a0d1822ad..000000000 --- a/lib/plugins/acts_as_event/lib/acts_as_event.rb +++ /dev/null @@ -1,68 +0,0 @@ -# redMine - project management software -# Copyright (C) 2006-2007 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -module Redmine - module Acts - module Event - def self.included(base) - base.extend ClassMethods - end - - module ClassMethods - def acts_as_event(options = {}) - return if self.included_modules.include?(Redmine::Acts::Event::InstanceMethods) - options[:datetime] ||= 'created_on' - options[:title] ||= 'title' - options[:description] ||= 'description' - options[:author] ||= 'author' - options[:url] ||= {:controller => 'welcome'} - cattr_accessor :event_options - self.event_options = options - send :include, Redmine::Acts::Event::InstanceMethods - end - end - - module InstanceMethods - def self.included(base) - base.extend ClassMethods - end - - %w(datetime title description author).each do |attr| - src = <<-END_SRC - def event_#{attr} - option = event_options[:#{attr}] - option.is_a?(Proc) ? option.call(self) : send(option) - end - END_SRC - class_eval src, __FILE__, __LINE__ - end - - def event_date - event_datetime.to_date - end - - def event_url(options = {}) - option = event_options[:url] - (option.is_a?(Proc) ? option.call(self) : send(option)).merge(options) - end - - module ClassMethods - end - end - end - end -end diff --git a/lib/plugins/acts_as_searchable/init.rb b/lib/plugins/acts_as_searchable/init.rb deleted file mode 100644 index 063721756..000000000 --- a/lib/plugins/acts_as_searchable/init.rb +++ /dev/null @@ -1,2 +0,0 @@ -require File.dirname(__FILE__) + '/lib/acts_as_searchable' -ActiveRecord::Base.send(:include, Redmine::Acts::Searchable) diff --git a/lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb b/lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb deleted file mode 100644 index ee4d5d6f8..000000000 --- a/lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb +++ /dev/null @@ -1,89 +0,0 @@ -# redMine - project management software -# Copyright (C) 2006-2007 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -module Redmine - module Acts - module Searchable - def self.included(base) - base.extend ClassMethods - end - - module ClassMethods - def acts_as_searchable(options = {}) - return if self.included_modules.include?(Redmine::Acts::Searchable::InstanceMethods) - - cattr_accessor :searchable_options - self.searchable_options = options - - if searchable_options[:columns].nil? - raise 'No searchable column defined.' - elsif !searchable_options[:columns].is_a?(Array) - searchable_options[:columns] = [] << searchable_options[:columns] - end - - if searchable_options[:project_key] - elsif column_names.include?('project_id') - searchable_options[:project_key] = "#{table_name}.project_id" - else - raise 'No project key defined.' - end - - if searchable_options[:date_column] - elsif column_names.include?('created_on') - searchable_options[:date_column] = "#{table_name}.created_on" - else - raise 'No date column defined defined.' - end - - send :include, Redmine::Acts::Searchable::InstanceMethods - end - end - - module InstanceMethods - def self.included(base) - base.extend ClassMethods - end - - module ClassMethods - def search(tokens, all_tokens, project, options={}) - tokens = [] << tokens unless tokens.is_a?(Array) - find_options = {:include => searchable_options[:include]} - find_options[:limit] = options[:limit] if options[:limit] - find_options[:order] = "#{searchable_options[:date_column]} " + (options[:before] ? 'DESC' : 'ASC') - - sql = ([ '(' + searchable_options[:columns].collect {|column| "(LOWER(#{column}) LIKE ?)"}.join(' OR ') + ')' ] * tokens.size).join(all_tokens ? ' AND ' : ' OR ') - if options[:offset] - sql = "(#{sql}) AND (#{searchable_options[:date_column]} " + (options[:before] ? '<' : '>') + "'#{connection.quoted_date(options[:offset])}')" - end - find_options[:conditions] = [sql, * (tokens * searchable_options[:columns].size).sort] - - results = with_scope(:find => {:conditions => ["#{searchable_options[:project_key]} = ?", project.id]}) do - find(:all, find_options) - end - if searchable_options[:with] - searchable_options[:with].each do |model, assoc| - results += model.to_s.camelcase.constantize.search(tokens, all_tokens, project, options).collect {|r| r.send assoc} - end - results.uniq! - end - results - end - end - end - end - end -end diff --git a/lib/plugins/acts_as_watchable/init.rb b/lib/plugins/acts_as_watchable/init.rb deleted file mode 100644 index f39cc7d18..000000000 --- a/lib/plugins/acts_as_watchable/init.rb +++ /dev/null @@ -1,3 +0,0 @@ -# Include hook code here -require File.dirname(__FILE__) + '/lib/acts_as_watchable' -ActiveRecord::Base.send(:include, Redmine::Acts::Watchable) diff --git a/lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb b/lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb deleted file mode 100644 index c789017e5..000000000 --- a/lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb +++ /dev/null @@ -1,53 +0,0 @@ -# ActsAsWatchable -module Redmine - module Acts - module Watchable - def self.included(base) - base.extend ClassMethods - end - - module ClassMethods - def acts_as_watchable(options = {}) - return if self.included_modules.include?(Redmine::Acts::Watchable::InstanceMethods) - send :include, Redmine::Acts::Watchable::InstanceMethods - - class_eval do - has_many :watchers, :as => :watchable, :dependent => :delete_all - end - end - end - - module InstanceMethods - def self.included(base) - base.extend ClassMethods - end - - def add_watcher(user) - self.watchers << Watcher.new(:user => user) - end - - def remove_watcher(user) - return nil unless user && user.is_a?(User) - Watcher.delete_all "watchable_type = '#{self.class}' AND watchable_id = #{self.id} AND user_id = #{user.id}" - end - - def watched_by?(user) - !self.watchers.find(:first, - :conditions => ["#{Watcher.table_name}.user_id = ?", user.id]).nil? - end - - def watcher_recipients - self.watchers.collect { |w| w.user.mail } - end - - module ClassMethods - def watched_by(user) - find(:all, - :include => :watchers, - :conditions => ["#{Watcher.table_name}.user_id = ?", user.id]) - end - end - end - end - end -end
\ No newline at end of file |