Mercurial > hg > soundsoftware-site
comparison app/models/.svn/text-base/mailer.rb.svn-base @ 22:40f7cfd4df19
* Update to SVN trunk rev 4173
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Fri, 24 Sep 2010 14:06:04 +0100 |
parents | 1d32c0a0efbf |
children | 94944d00e43c |
comparison
equal
deleted
inserted
replaced
14:1d32c0a0efbf | 22:40f7cfd4df19 |
---|---|
12 # GNU General Public License for more details. | 12 # GNU General Public License for more details. |
13 # | 13 # |
14 # You should have received a copy of the GNU General Public License | 14 # You should have received a copy of the GNU General Public License |
15 # along with this program; if not, write to the Free Software | 15 # along with this program; if not, write to the Free Software |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | |
18 require 'ar_condition' | |
17 | 19 |
18 class Mailer < ActionMailer::Base | 20 class Mailer < ActionMailer::Base |
19 layout 'mailer' | 21 layout 'mailer' |
20 helper :application | 22 helper :application |
21 helper :issues | 23 helper :issues |
304 # Sends reminders to issue assignees | 306 # Sends reminders to issue assignees |
305 # Available options: | 307 # Available options: |
306 # * :days => how many days in the future to remind about (defaults to 7) | 308 # * :days => how many days in the future to remind about (defaults to 7) |
307 # * :tracker => id of tracker for filtering issues (defaults to all trackers) | 309 # * :tracker => id of tracker for filtering issues (defaults to all trackers) |
308 # * :project => id or identifier of project to process (defaults to all projects) | 310 # * :project => id or identifier of project to process (defaults to all projects) |
311 # * :users => array of user ids who should be reminded | |
309 def self.reminders(options={}) | 312 def self.reminders(options={}) |
310 days = options[:days] || 7 | 313 days = options[:days] || 7 |
311 project = options[:project] ? Project.find(options[:project]) : nil | 314 project = options[:project] ? Project.find(options[:project]) : nil |
312 tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil | 315 tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil |
316 user_ids = options[:users] | |
313 | 317 |
314 s = ARCondition.new ["#{IssueStatus.table_name}.is_closed = ? AND #{Issue.table_name}.due_date <= ?", false, days.day.from_now.to_date] | 318 s = ARCondition.new ["#{IssueStatus.table_name}.is_closed = ? AND #{Issue.table_name}.due_date <= ?", false, days.day.from_now.to_date] |
315 s << "#{Issue.table_name}.assigned_to_id IS NOT NULL" | 319 s << "#{Issue.table_name}.assigned_to_id IS NOT NULL" |
320 s << ["#{Issue.table_name}.assigned_to_id IN (?)", user_ids] if user_ids.present? | |
316 s << "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}" | 321 s << "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}" |
317 s << "#{Issue.table_name}.project_id = #{project.id}" if project | 322 s << "#{Issue.table_name}.project_id = #{project.id}" if project |
318 s << "#{Issue.table_name}.tracker_id = #{tracker.id}" if tracker | 323 s << "#{Issue.table_name}.tracker_id = #{tracker.id}" if tracker |
319 | 324 |
320 issues_by_assignee = Issue.find(:all, :include => [:status, :assigned_to, :project, :tracker], | 325 issues_by_assignee = Issue.find(:all, :include => [:status, :assigned_to, :project, :tracker], |