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

Challenges.php « Engagement « Tour « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ec09b96093b09b31839f0c5d21565e3d89c7a92b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
/**
 * Matomo - free/libre analytics platform
 *
 * @link https://matomo.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 *
 */
namespace Piwik\Plugins\Tour\Engagement;

use Piwik\Container\StaticContainer;
use Piwik\Piwik;
use Piwik\Plugin;
use Piwik\Plugins\CoreAdminHome\Controller;
use Piwik\Plugins\SitesManager\SitesManager;
use Piwik\Plugins\Tour\Dao\DataFinder;
use Piwik\Plugins\UserCountry\UserCountry;
use Piwik\Plugins\UsersManager\UsersManager;

class Challenges
{
    /**
     * @var DataFinder
     */
    private $finder;

    public function __construct(DataFinder $dataFinder)
    {
        $this->finder = $dataFinder;
    }

    private function isActivePlugin($pluginName)
    {
        return Plugin\Manager::getInstance()->isPluginActivated($pluginName);
    }

    public function getChallenges()
    {
        /** @var Challenge[] $challenges */
        $challenges = array(
           StaticContainer::get(ChallengeTrackingCode::class),
        );

        $challenges[] = StaticContainer::get(ChallengeSetupConsentManager::class);

        if ($this->isActivePlugin('Goals')) {
            $challenges[] = StaticContainer::get(ChallengeCreatedGoal::class);
        }

        $challenges[] = StaticContainer::get(ChallengeCustomLogo::class);

        if ($this->isActivePlugin('UsersManager') && UsersManager::isUsersAdminEnabled()) {
            $challenges[] = StaticContainer::get(ChallengeAddedUser::class);
        }
        if ($this->isActivePlugin('SitesManager') && SitesManager::isSitesAdminEnabled()) {
            $challenges[] = StaticContainer::get(ChallengeAddedWebsite::class);
        }

        $challenges[] = StaticContainer::get(ChallengeFlattenActions::class);
        $challenges[] = StaticContainer::get(ChallengeChangeVisualisation::class);

        if ($this->isActivePlugin('ScheduledReports')) {
            $challenges[] = StaticContainer::get(ChallengeScheduledReport::class);
        }
        if ($this->isActivePlugin('Dashboard')) {
            $challenges[] = StaticContainer::get(ChallengeCustomiseDashboard::class);
        }
        if ($this->isActivePlugin('SegmentEditor')) {
            $challenges[] = StaticContainer::get(ChallengeAddedSegment::class);
        }
        if ($this->isActivePlugin('Annotations')) {
            $challenges[] = StaticContainer::get(ChallengeAddedAnnotation::class);
        }

        if ($this->isActivePlugin('TwoFactorAuth')) {
            $challenges[] = StaticContainer::get(ChallengeSetupTwoFa::class);
        }

        if (Controller::isGeneralSettingsAdminEnabled()) {
            $challenges[] = StaticContainer::get(ChallengeDisableBrowserArchiving::class);
        }

        if (UserCountry::isGeoLocationAdminEnabled()) {
            $challenges[] = StaticContainer::get(ChallengeConfigureGeolocation::class);
        }

        // we're adding this simple challenge only later in the process since there might not be enough data yet in
        // the beginning to actually get much value from it
        $challenges[] = StaticContainer::get(ChallengeSelectDateRange::class);

        if ($this->isActivePlugin('Live')) {
            $challenges[] = StaticContainer::get(ChallengeViewVisitsLog::class);
            $challenges[] = StaticContainer::get(ChallengeViewVisitorProfile::class);
        }

        $challenges[] = StaticContainer::get(ChallengeViewRowEvolution::class);

        if ($this->isActivePlugin('Marketplace')) {
            $challenges[] = StaticContainer::get(ChallengeBrowseMarketplace::class);
        }

        /**
         * Triggered to add new challenges to the "welcome to Matomo tour".
         *
         * **Example**
         *
         *     public function addChallenge(&$challenges)
         *     {
         *         $challenges[] = new MyChallenge();
         *     }
         *
         * @param Challenge[] $challenges An array of challenges
         */
        Piwik::postEvent('Tour.filterChallenges', array(&$challenges));

        return $challenges;
    }


}