tickets/app/helpers/tickets_helper.rb

42 lines
1.6 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/")
2015-10-02 10:33:29 +00:00
temp_html = ActionView::Base.full_sanitizer.sanitize(html)
urls = URI.extract(temp_html,["http","https"])
urls.each do |url|
html = html.sub(url, "<a href='#{url}' target='_blank'>#{url}</a>")
end
2015-09-24 05:46:18 +00:00
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/")
2015-10-02 10:33:29 +00:00
temp_html = ActionView::Base.full_sanitizer.sanitize(html)
urls = URI.extract(temp_html,["http","https"])
urls.each do |url|
html = html.sub(url, "<a href='#{url}' target='_blank'>#{url}</a>")
end
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