diff options
author | Stefan Giehl <stefan@matomo.org> | 2021-11-16 00:33:53 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-16 00:33:53 +0300 |
commit | 33132937abf4cbfd7824a4b385c37e6e03fb0ec7 (patch) | |
tree | 480668c4b2a3effd9ffcd3f04743e8c5b143528b /plugins/Feedback | |
parent | 556aada80e48f200a10c8dc4673f32e42494b9fe (diff) |
Determine the first date to show feedback question banner more randomly (#18315)
* Determine the firt date to show feedback question banner more randomly
* fix method name
* use correct date
Diffstat (limited to 'plugins/Feedback')
-rw-r--r-- | plugins/Feedback/Feedback.php | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/plugins/Feedback/Feedback.php b/plugins/Feedback/Feedback.php index bf9dbce534..97cd34fe9c 100644 --- a/plugins/Feedback/Feedback.php +++ b/plugins/Feedback/Feedback.php @@ -123,15 +123,19 @@ class Feedback extends \Piwik\Plugin $nextReminderDate = $feedbackReminder->getUserOption(); $now = Date::now()->getTimestamp(); - //user answered question - if ($nextReminderDate === self::NEVER_REMIND_ME_AGAIN) { - return false; - } - - // if is new user or old user field not exist - if ($nextReminderDate === false) { - //new user extend to 6 month, don't show banner - $nextReminder = Date::now()->getStartOfDay()->addMonth(6)->toString('Y-m-d'); + // If there isn't any reminder date set, or never remind me was selected previously (-1) we determine a new date + if ($nextReminderDate === false || $nextReminderDate <= 0) { + + // if user was created within the last 6 months, we set the date to 6 months after his creation date + $userCreatedDate = Piwik::getCurrentUserCreationDate(); + if (!empty($userCreatedDate) && Date::factory($userCreatedDate)->addMonth(6)->getTimestamp() > $now) { + $nextReminder = Date::factory($userCreatedDate)->addMonth(6)->toString('Y-m-d'); + $feedbackReminder->setUserOption($nextReminder); + return false; + } + + // Otherwise we set the date to somewhen within the next 6 months + $nextReminder = Date::now()->getStartOfDay()->addDay(Common::getRandomInt(1, 6*30))->toString('Y-m-d'); $feedbackReminder->setUserOption($nextReminder); return false; } |