Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <diosmosis@users.noreply.github.com>2018-09-21 01:53:37 +0300
committerGitHub <noreply@github.com>2018-09-21 01:53:37 +0300
commit2d2abcc9576079a8496ad8bd4a038ba07cf1fb2b (patch)
tree511d4c06b004d8162fb3cd2480252c25caa13a63 /core/Mail.php
parenta7f5d6478cfcff4cb2b9a19b40f2b526da8f1eea (diff)
Send email if no tracked data within N days. (#13363)
* Remember user who created a site. * Send email if no tracked data within N days. * Add test and get to pass. * Fixes after manual tests of emails * Bump version & change column name to creator_login. * Email tweaks. * Rename Site::getCreationUserFor * Modify Site:: access methiod name * Applying PR feedback. * Move email HTML content generation logic to separate class in DI. * tweak translations * Apply PR review feedback. * Couple more tweaks. * Make tracking code check a one time task + and save timetable when removing inactive tasks. * Update save call. * Apply more PR feedback. * small performance tweak and put the site name in quotes * Fixing tests. * Update expected file.
Diffstat (limited to 'core/Mail.php')
-rw-r--r--core/Mail.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/core/Mail.php b/core/Mail.php
index a3771f536d..ab671b4010 100644
--- a/core/Mail.php
+++ b/core/Mail.php
@@ -9,8 +9,10 @@
namespace Piwik;
use Piwik\Container\StaticContainer;
+use Piwik\Email\ContentGenerator;
use Piwik\Plugins\CoreAdminHome\CustomLogo;
use Piwik\Translation\Translator;
+use Piwik\View\HtmlReportEmailHeaderView;
use Zend_Mail;
/**
@@ -52,6 +54,13 @@ class Mail extends Zend_Mail
$this->setFrom($fromEmailAddress, $fromEmailName);
}
+ public function setWrappedHtmlBody(View $body)
+ {
+ $contentGenerator = StaticContainer::get(ContentGenerator::class);
+ $bodyHtml = $contentGenerator->generateHtmlContent($body);
+ $this->setBodyHtml($bodyHtml);
+ }
+
/**
* Sets the sender.
*
@@ -123,7 +132,25 @@ class Mail extends Zend_Mail
public function send($transport = null)
{
+ if (!$this->shouldSendMail()) {
+ return $this;
+ }
+
+ $mail = $this;
+
+ /**
+ * This event is posted right before an email is sent. You can use it to customize the email by, for example, replacing
+ * the subject/body, changing the from address, etc.
+ * TODO: changelog
+ * @param Mail $this The Mail instance that is about to be sent.
+ */
+ Piwik::postEvent('Mail.send', [$mail]);
+
if (defined('PIWIK_TEST_MODE')) { // hack
+ /**
+ * @ignore
+ * @deprecated
+ */
Piwik::postTestEvent("Test.Mail.send", array($this));
} else {
return parent::send($transport);
@@ -183,4 +210,21 @@ class Mail extends Zend_Mail
$string = str_replace($search, $replace, $string);
return $string;
}
+
+ private function shouldSendMail()
+ {
+ $shouldSendMail = true;
+
+ $mail = $this;
+
+ /**
+ * This event is posted before sending an email. You can use it to abort sending a specific email, if you want.
+ * TODO: changelog
+ * @param bool &$shouldSendMail Whether to send this email or not. Set to false to skip sending.
+ * @param Mail $mail The Mail instance that will be sent.
+ */
+ Piwik::postEvent('Mail.shouldSend', [&$shouldSendMail, $mail]);
+
+ return $shouldSendMail;
+ }
}