From 1768c2039b6ff3d68bd3b711621d82dcbf5eab75 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Thu, 8 Sep 2016 11:05:26 -0700 Subject: [PATCH] fix UI links and CSS in searches delivered by email, #72101 --- FS/FS/saved_search.pm | 5 ++--- httemplate/edit/saved_search.html | 22 ++++++++++++++++++++++ httemplate/elements/header-popup.html | 6 ++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/FS/FS/saved_search.pm b/FS/FS/saved_search.pm index 252dc71e5..caaf7fea8 100644 --- a/FS/FS/saved_search.pm +++ b/FS/FS/saved_search.pm @@ -219,11 +219,10 @@ sub render { local $FS::CurrentUser::CurrentUser = $self->access_user; local $FS::Mason::Request::QUERY_STRING = $self->query_string; - local $FS::Mason::Request::FSURL = ''; #? -# local $ENV{SERVER_NAME} = 'localhost'; #? -# local $ENV{SCRIPT_NAME} = '/freeside'. $self->path; + local $FS::Mason::Request::FSURL = $self->access_user->option('rooturl'); my $mason_request = $fs_interp->make_request(comp => '/' . $self->path); + $mason_request->notes('inline_stylesheet', 1); local $@; eval { $mason_request->exec(); }; diff --git a/httemplate/edit/saved_search.html b/httemplate/edit/saved_search.html index 3039aed35..cb6aa45d1 100644 --- a/httemplate/edit/saved_search.html +++ b/httemplate/edit/saved_search.html @@ -61,6 +61,28 @@ <%init> my $curuser = $FS::CurrentUser::CurrentUser; +# remember the user's rooturl() when accessing the UI. this will be the +# base URL for sending email reports to that user so that links work. +my $rooturl_pref = qsearchs('access_user_pref', { + usernum => $curuser->usernum, + prefname => 'rooturl', +}); +my $error; +if ($rooturl_pref) { + if ($rooturl_pref->prefvalue ne rooturl()) { + $rooturl_pref->set('prefvalue', rooturl()); + $error = $rooturl_pref->replace; + } # else don't update it +} else { + $rooturl_pref = FS::access_user_pref->new({ + usernum => $curuser->usernum, + prefname => 'rooturl', + prefvalue => rooturl(), + }); + $error = $rooturl_pref->insert; +} + +warn "error updating rooturl pref: $error" if $error; # prefix to the freeside document root (usually '/freeside/') my $root = URI->new($fsurl)->path; diff --git a/httemplate/elements/header-popup.html b/httemplate/elements/header-popup.html index 839a63676..327673bc6 100644 --- a/httemplate/elements/header-popup.html +++ b/httemplate/elements/header-popup.html @@ -38,7 +38,13 @@ Example: <% $head |n %> > +% if ($m->notes('inline_stylesheet')) { # for email delivery + +% } else { +% } % if ( $title || $title_noescape ) {
<% encode_entities($title) || $title_noescape |n %>
-- 2.11.0