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:
authorPeter Zhang <peter@innocraft.com>2021-11-13 02:49:08 +0300
committerGitHub <noreply@github.com>2021-11-13 02:49:08 +0300
commitbf341b7c0ba46691bf3e475ebaa58391363cd7ec (patch)
tree232d4a0ec7aa3b8c801592872eb2d2523dc66f0e /plugins/Feedback/Feedback.php
parent9c58f4e71db9133b2c83d51cf700e818ec5ff7e4 (diff)
add feedback question, remove other related. (#18262)
* remove feedback links remove feedback links * update screen shot update screen shot * add feedback question add feedback question * update close to icon update close to icon * built vue files * remove in line css remove in line css, change to less file * move translation key to plugin move translation key to plugin * remove feedback popup remove feedback popup * update remove some test and feedback related update remove some test and feedback related * add draft tests add draft tests * update feedback add php and UI tests update feedback add php and UI tests * update test screen shots update test screen shots * Update demo.twig add heart to demo page * add feedback back in extend the modal add feedback back in extend the modal * update coreHome update coreHome * update screen shots update screen shots * Update FeedbackQuestion_spec.js update js tests * update test update test * built vue files * update screenshot and js tests update screenshot and js tests * Update FeedbackQuestion_spec.js test success * update screenshot update screenshot * update tests update tests * fix test error fix test error * Removing the refer us popup * Readding accidentally removed language files * update test * update test * remove refer us * update feedback umd js update feedback umd js * merge Andy branch merge Andy branch and update screen shots * revert language changes revert language changes * revert language changes revert language changes * revert language file revert language file * revert unrelated lang change revert unrelated lang change * revert lang change revert lang change * revert lang change revert lang change * Delete ControllerTest.php remove controller test not in used * Update core/Piwik.php Co-authored-by: Ben Burgess <88810029+bx80@users.noreply.github.com> * Update plugins/Morpheus/javascripts/piwikHelper.js Co-authored-by: Ben Burgess <88810029+bx80@users.noreply.github.com> * update a big that cancel and reopen it again update a bug that cancel and reopen it again * update compare error update compare error * Update plugins/Feedback/FeedbackReminder.php Co-authored-by: Stefan Giehl <stefan@matomo.org> * update feedback show logic update feedback show logic * Update FeedbackQuestion_spec.js update tests * Update Feedback.php remove comments * Update .gitignore * update vue build file update vue build file * built vue files * update vue build file update vue build file * add close button add close button * add close button add close button * update screenshot update screenshot * remove umd remove umd * git add corehome git add corehome * revert all the umd file revert all the umd file * built vue files * built vue files * Update plugins/Feedback/lang/en.json Co-authored-by: Stefan Giehl <stefan@matomo.org> * update per review update per review * built vue files * set auto focus on modal open set auto focus on modal open * built vue files * Update FeedbackQuestion.vue add please write in english * built vue files * remove please write in English remove please write in English * built vue files * update tests and question tests update tests and question tests * set cookie in the test set cookie in the test * Update page-renderer.js add setCookie to tests * update test only load 1 update test only load 1 * built vue files * Update FeedbackQuestion_feedback_popup.png update screen shot * Update piwikHelper.js update button css * update screen shot update screen shot * Update plugins/Feedback/Feedback.php Co-authored-by: Stefan Giehl <stefan@matomo.org> * Update plugins/Feedback/vue/src/FeedbackQuestion/FeedbackQuestion.vue Co-authored-by: Stefan Giehl <stefan@matomo.org> * Update plugins/Feedback/API.php Co-authored-by: Stefan Giehl <stefan@matomo.org> * Update plugins/Feedback/API.php Co-authored-by: Stefan Giehl <stefan@matomo.org> * Update core/Plugin/API.php Co-authored-by: Stefan Giehl <stefan@matomo.org> * update cookie and tests update cookie and tests * built vue files * test setcookie in tests test setcookie in tests * update tests update tests * update tests update tests * Update FeedbackQuestion_spec.js update cookie test * extend setCookie in test extend setCookie in test * update elints format update elints format * built vue files * test set cookie test set cookie * built vue files * Update FeedbackQuestion_spec.js set cookie after goto URL * Update FeedbackQuestion_spec.js int to string * update set cookie update set cookie * update test URL update test URL Co-authored-by: peterhashair <peterhashair@users.noreply.github.com> Co-authored-by: Andrew Davis <andrew.affinity@gmail.com> Co-authored-by: Ben Burgess <88810029+bx80@users.noreply.github.com> Co-authored-by: Stefan Giehl <stefan@matomo.org>
Diffstat (limited to 'plugins/Feedback/Feedback.php')
-rw-r--r--plugins/Feedback/Feedback.php135
1 files changed, 45 insertions, 90 deletions
diff --git a/plugins/Feedback/Feedback.php b/plugins/Feedback/Feedback.php
index 8e6531b7af..55ccc67e4a 100644
--- a/plugins/Feedback/Feedback.php
+++ b/plugins/Feedback/Feedback.php
@@ -9,6 +9,9 @@
namespace Piwik\Plugins\Feedback;
use Piwik\Date;
+use Piwik\Plugins\UsersManager\API as APIUsersManager;
+use Piwik\Plugins\UsersManager\UsersManager;
+use Piwik\Site;
use Piwik\View;
use Piwik\Piwik;
use Piwik\Common;
@@ -39,22 +42,16 @@ class Feedback extends \Piwik\Plugin
{
$stylesheets[] = "plugins/Feedback/stylesheets/feedback.less";
$stylesheets[] = "plugins/Feedback/vue/src/RateFeature/RateFeature.less";
- $stylesheets[] = "plugins/Feedback/angularjs/feedback-popup/feedback-popup.directive.less";
- $stylesheets[] = "plugins/Feedback/angularjs/refer-banner/refer-banner.directive.less";
+ $stylesheets[] = "plugins/Feedback/vue/src/FeedbackQuestion/FeedbackQuestion.less";
}
public function getJsFiles(&$jsFiles)
{
- $jsFiles[] = "plugins/Feedback/angularjs/feedback-popup/feedback-popup.controller.js";
- $jsFiles[] = "plugins/Feedback/angularjs/feedback-popup/feedback-popup.directive.js";
- $jsFiles[] = "plugins/Feedback/angularjs/refer-banner/refer-banner.directive.js";
- $jsFiles[] = "plugins/Feedback/angularjs/refer-banner/refer-banner.controller.js";
}
public function getClientSideTranslationKeys(&$translationKeys)
{
$translationKeys[] = 'Feedback_ThankYou';
- $translationKeys[] = 'Feedback_ThankYouForSpreading';
$translationKeys[] = 'Feedback_RateFeatureTitle';
$translationKeys[] = 'Feedback_RateFeatureThankYouTitle';
$translationKeys[] = 'Feedback_RateFeatureLeaveMessageLike';
@@ -65,97 +62,42 @@ class Feedback extends \Piwik\Plugin
$translationKeys[] = 'Feedback_PleaseLeaveExternalReviewForMatomo';
$translationKeys[] = 'Feedback_RemindMeLater';
$translationKeys[] = 'Feedback_NeverAskMeAgain';
- $translationKeys[] = 'Feedback_ReferMatomo';
- $translationKeys[] = 'Feedback_ReferBannerTitle';
- $translationKeys[] = 'Feedback_ReferBannerLonger';
- $translationKeys[] = 'Feedback_ReferBannerSocialShareText';
- $translationKeys[] = 'Feedback_ReferBannerEmailShareSubject';
- $translationKeys[] = 'Feedback_ReferBannerEmailShareBody';
$translationKeys[] = 'Feedback_WontShowAgain';
$translationKeys[] = 'General_Ok';
$translationKeys[] = 'General_Cancel';
+ $translationKeys[] = 'Feedback_Question0';
+ $translationKeys[] = 'Feedback_Question1';
+ $translationKeys[] = 'Feedback_Question2';
+ $translationKeys[] = 'Feedback_Question3';
+ $translationKeys[] = 'Feedback_Question4';
+ $translationKeys[] = 'Feedback_FeedbackTitle';
+ $translationKeys[] = 'Feedback_FeedbackSubtitle';
+ $translationKeys[] = 'Feedback_ThankYourForFeedback';
+ $translationKeys[] = 'Feedback_Policy';
+ $translationKeys[] = 'Feedback_ThankYourForFeedback';
+ $translationKeys[] = 'Feedback_ThankYou';
+ $translationKeys[] = 'Feedback_MessageBodyValidationError';
}
public function renderViewsAndAddToPage(&$pageHtml)
{
- $feedbackPopopView = $this->renderFeedbackPopup();
- $referBannerView = $this->renderReferBanner();
-
- $views = [$feedbackPopopView, $referBannerView];
- $implodedViews = implode('', $views);
-
- $endOfBody = strpos($pageHtml, '</body>');
- $pageHtml = substr_replace($pageHtml, $implodedViews, $endOfBody, 0);
- }
-
- public function renderFeedbackPopup()
- {
- $popupView = new View('@Feedback/feedbackPopup');
- $popupView->promptForFeedback = (int)$this->getShouldPromptForFeedback();
-
- return $popupView->render();
- }
-
- public function renderReferBanner()
- {
- $referBannerView = new View('@Feedback/referBanner');
- $referBannerView->showReferBanner = (int) $this->showReferBanner();
-
- return $referBannerView->render();
- }
-
- public function showReferBanner()
- {
- if ($this->getShouldPromptForFeedback()) {
- return false;
- }
-
- if (Piwik::isUserIsAnonymous()) {
- return false;
- }
-
+ //only show on superuser
if (!Piwik::hasUserSuperUserAccess()) {
- return false;
- }
-
- if ($this->isDisabledInTestMode()) {
- return false;
+ return $pageHtml;
}
+ $feedbackQuestionBanner = $this->renderFeedbackQuestion();
- $shouldShowReferBanner = true;
-
- /**
- * @internal
- */
- Piwik::postEvent('Feedback.showReferBanner', [&$shouldShowReferBanner]);
-
- if (!$shouldShowReferBanner) {
- return false;
- }
-
- $referReminder = new ReferReminder();
- $nextReminderDate = $referReminder->getUserOption();
-
- if ($nextReminderDate === false) {
- $nextReminder = Date::now()->getStartOfDay()->addDay(135)->toString('Y-m-d');
- $referReminder->setUserOption($nextReminder);
-
- return false;
- }
-
- if ($nextReminderDate === self::NEVER_REMIND_ME_AGAIN) {
- return false;
- }
+ $matches = preg_split('/(<body.*?>)/i', $pageHtml, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
+ $pageHtml = $matches[0] . $matches[1] . $feedbackQuestionBanner . $matches[2];
+ }
- $pluginManager = PluginManager::getInstance();
- if ($pluginManager->hasPremiumFeatures()) {
- return false;
- }
- $now = Date::now()->getTimestamp();
- $nextReminderDate = Date::factory($nextReminderDate);
+ public function renderFeedbackQuestion()
+ {
+ $feedbackQuestionBanner = new View('@Feedback/feedbackQuestionBanner');
+ $feedbackQuestionBanner->showQuestionBanner = (int)$this->getShouldPromptForFeedback();
- return $nextReminderDate->getTimestamp() <= $now;
+ return $feedbackQuestionBanner->render();
}
public function getShouldPromptForFeedback()
@@ -171,22 +113,35 @@ class Feedback extends \Piwik\Plugin
$feedbackReminder = new FeedbackReminder();
$nextReminderDate = $feedbackReminder->getUserOption();
+ $now = Date::now()->getTimestamp();
+ //user answered question
if ($nextReminderDate === self::NEVER_REMIND_ME_AGAIN) {
return false;
}
- if ($nextReminderDate === false) {
- $nextReminder = Date::now()->getStartOfDay()->addDay(90)->toString('Y-m-d');
+ // if is new user or old user field not exist
+ if ($nextReminderDate === false || $nextReminderDate <= 0) {
+
+ // if user is created more than 6 month ago, set reminder to today and show banner
+ $userCreatedDate = Piwik::getCurrentUserCreationData();
+ if (!empty($userCreatedDate) && Date::factory($userCreatedDate)->addMonth(6)->getTimestamp() < $now) {
+ $nextReminder = Date::now()->getStartOfDay()->subDay(1)->toString('Y-m-d');
+ $feedbackReminder->setUserOption($nextReminder);
+ return true;
+ }
+ //new user extend to 6 month, don't show banner
+ $nextReminder = Date::now()->getStartOfDay()->addMonth(6)->toString('Y-m-d');
$feedbackReminder->setUserOption($nextReminder);
-
return false;
}
- $now = Date::now()->getTimestamp();
$nextReminderDate = Date::factory($nextReminderDate);
+ if ($nextReminderDate->getTimestamp() > $now) {
+ return false;
+ }
+ return true;
- return $nextReminderDate->getTimestamp() <= $now;
}
// needs to be protected not private for testing purpose