kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.6 KiB
72 lines
2.6 KiB
11 years ago
|
#-- copyright
|
||
11 years ago
|
# OpenProject Meeting Plugin
|
||
|
#
|
||
|
# Copyright (C) 2011-2014 the OpenProject Foundation (OPF)
|
||
11 years ago
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License version 3.
|
||
|
#
|
||
11 years ago
|
# 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.
|
||
|
#
|
||
11 years ago
|
# 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.
|
||
|
#
|
||
|
# See doc/COPYRIGHT.md for more details.
|
||
11 years ago
|
#++
|
||
|
|
||
8 years ago
|
require 'icalendar'
|
||
7 years ago
|
require 'icalendar/tzinfo'
|
||
8 years ago
|
|
||
12 years ago
|
class MeetingMailer < UserMailer
|
||
10 years ago
|
def content_for_review(content, content_type, address)
|
||
12 years ago
|
@meeting = content.meeting
|
||
10 years ago
|
@content_type = content_type
|
||
|
|
||
12 years ago
|
open_project_headers 'Project' => @meeting.project.identifier,
|
||
|
'Meeting-Id' => @meeting.id
|
||
|
|
||
12 years ago
|
subject = "[#{@meeting.project.name}] #{I18n.t(:"label_#{content_type}")}: #{@meeting.title}"
|
||
10 years ago
|
mail to: address, subject: subject
|
||
12 years ago
|
end
|
||
7 years ago
|
|
||
8 years ago
|
def icalendar_notification(content, content_type, address)
|
||
|
@meeting = content.meeting
|
||
|
@content_type = content_type
|
||
7 years ago
|
|
||
8 years ago
|
open_project_headers 'Project' => @meeting.project.identifier,
|
||
|
'Meeting-Id' => @meeting.id
|
||
|
headers['Content-Type'] = 'text/calendar; charset=utf-8; method="PUBLISH"; name="meeting.ics"'
|
||
|
headers['Content-Transfer-Encoding'] = '8bit'
|
||
7 years ago
|
|
||
|
subject = "[#{@meeting.project.name}] #{I18n.t(:"label_#{@content_type}")}: #{@meeting.title}"
|
||
|
|
||
8 years ago
|
author = Icalendar::Values::CalAddress.new("mailto:#{@meeting.author.mail}",
|
||
|
cn: @meeting.author.name)
|
||
|
|
||
|
# Create a calendar with an event (standard method)
|
||
|
entry = ::Icalendar::Calendar.new
|
||
7 years ago
|
|
||
|
tzid = @meeting.start_time.zone
|
||
|
tz = TZInfo::Timezone.get tzid
|
||
|
timezone = tz.ical_timezone @meeting.start_time
|
||
|
entry.add_timezone timezone
|
||
|
|
||
8 years ago
|
entry.event do |e|
|
||
7 years ago
|
e.dtstart = Icalendar::Values::DateTime.new @meeting.start_time, 'tzid' => tzid
|
||
|
e.dtend = Icalendar::Values::DateTime.new @meeting.end_time, 'tzid' => tzid
|
||
8 years ago
|
e.url = meeting_url(@meeting)
|
||
|
e.summary = "[#{@meeting.project.name}] #{@meeting.title}"
|
||
|
e.description = subject
|
||
|
e.uid = "#{@meeting.id}@#{@meeting.project.identifier}"
|
||
|
e.organizer = author
|
||
|
end
|
||
|
|
||
|
attachments['meeting.ics'] = entry.to_ical
|
||
|
mail(to: address, subject: subject)
|
||
|
end
|
||
12 years ago
|
end
|