2015-08-20 11:03:44 +00:00
|
|
|
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
|
2015-08-20 11:03:44 +00:00
|
|
|
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
|
2015-08-20 11:03:44 +00:00
|
|
|
return html
|
|
|
|
end
|
2015-08-25 10:49:47 +00:00
|
|
|
|
2016-05-23 11:12:16 +00:00
|
|
|
def notify_response_to_client(ticket)
|
|
|
|
network = ONetwork.new("http://" + ticket.registered_site.site_domain, "post") rescue nil
|
|
|
|
network.request("/store/ticket_response_update",{"ticket_id" => ticket.uid}) if !network.nil?
|
|
|
|
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)
|
2021-07-15 11:19:13 +00:00
|
|
|
url = "#{request.protocol}#{request.host_with_port}/#{I18n.locale}/admin/tickets-manage/#{ticket.id.to_s}#response_#{response.id.to_s}"
|
2015-08-25 10:49:47 +00:00
|
|
|
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
|
2015-08-20 11:03:44 +00:00
|
|
|
end
|