tickets/app/helpers/tickets_helper.rb

32 lines
1.2 KiB
Ruby
Raw Normal View History

module TicketsHelper
def smart_links_parser(html,site)
2015-09-24 05:46:18 +00:00
if !site.nil?
html = html.gsub("href=\"/uploads/","href=\"http://#{site.site_domain}/uploads/")
html = html.gsub("src=\"/uploads/","src=\"http://#{site.site_domain}/uploads/")
end
return html
end
def smart_store_link_parser(html)
html = html.gsub("href=\"/uploads/","href=\"http://#{request.host_with_port}/uploads/")
html = html.gsub("src=\"/uploads/","src=\"http://#{request.host_with_port}/uploads/")
return html
end
2015-08-25 10:49:47 +00:00
def send_notification_emails(response, ticket)
response.user_tags.each do |u|
user = User.find(u) rescue nil
if !user.nil?
mp = user.member_profile
send_email(mp.email,ticket,response,user.name) if !mp.email.nil?
2015-08-25 11:20:03 +00:00
sleep(2.seconds)
2015-08-25 10:49:47 +00:00
end
end
end
def send_email(useremail,ticket,response, username)
url = "#{request.protocol}#{request.host_with_port}/#{I18n.locale}/admin/tickets/#{ticket.id.to_s}#response_#{response.id.to_s}"
email = Email.new(:mail_to => useremail, :mail_subject => "Tagged : #{ticket.subject}.", :template => "email/ticket_tag_email.html.erb", :template_data => {"url" => url, "mention" => current_user.name, "name" => username})
email.deliver
end
end