PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.6.0
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.6.0
5.13.0 5.12.1 5.12.0 5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / core / Policy / CompliancePolicy.php
matomo / app / core / Policy Last commit date
Exceptions 8 months ago CnilPolicy.php 8 months ago CompliancePolicy.php 8 months ago PolicyManager.php 8 months ago
CompliancePolicy.php
127 lines
1 <?php
2
3 /**
4 * Matomo - free/libre analytics platform
5 *
6 * @link https://matomo.org
7 * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
8 */
9 namespace Piwik\Policy;
10
11 use Piwik\Piwik;
12 use Piwik\Plugin\Manager;
13 use Piwik\Settings\FieldConfig;
14 use Piwik\Settings\Interfaces\ConfigSettingInterface;
15 use Piwik\Settings\Interfaces\MeasurableSettingInterface;
16 use Piwik\Settings\Interfaces\SystemSettingInterface;
17 use Piwik\Settings\Interfaces\Traits\Getters\ConfigGetterTrait;
18 use Piwik\Settings\Interfaces\Traits\Setters\MeasurableSetterTrait;
19 use Piwik\Settings\Interfaces\Traits\Setters\SystemSetterTrait;
20 /**
21 * @implements SystemSettingInterface<bool>
22 * @implements MeasurableSettingInterface<bool>
23 */
24 abstract class CompliancePolicy implements SystemSettingInterface, MeasurableSettingInterface, ConfigSettingInterface
25 {
26 /**
27 * @use SystemSetterTrait<bool>
28 */
29 use SystemSetterTrait;
30 /**
31 * @use MeasurableSetterTrait<bool>
32 */
33 use MeasurableSetterTrait;
34 /**
35 * @use ConfigGetterTrait<bool>
36 */
37 use ConfigGetterTrait;
38 public static abstract function getName() : string;
39 public static abstract function getTitle() : string;
40 protected static abstract function generateDescription() : string;
41 public static function getDescription() : string
42 {
43 $description = static::generateDescription();
44 Piwik::postEvent('CompliancePolicy.updatePolicyDescription', [&$description, static::class]);
45 return $description;
46 }
47 /**
48 * @return array<array<string>> of [['title' => (string) 'TITLE', 'note' => (string) 'NOTE']]
49 */
50 public static abstract function getUnknownSettings() : array;
51 /**
52 * @return array<string, string>
53 */
54 public static function getDetails() : array
55 {
56 return ['id' => static::getName(), 'title' => static::getTitle(), 'description' => static::getDescription()];
57 }
58 protected static function getPluginManagerInstance() : Manager
59 {
60 return Manager::getInstance();
61 }
62 protected static function getSystemDefaultValue()
63 {
64 return \false;
65 }
66 protected static function getSystemName() : string
67 {
68 return preg_replace('/\\s+/', '', static::getName()) . '_policy_enabled';
69 }
70 protected static function getSystemType() : string
71 {
72 return FieldConfig::TYPE_BOOL;
73 }
74 protected static function getMeasurableDefaultValue()
75 {
76 return \false;
77 }
78 protected static function getMeasurableName() : string
79 {
80 return preg_replace('/\\s+/', '', static::getName()) . '_policy_enabled';
81 }
82 protected static function getMeasurableType() : string
83 {
84 return FieldConfig::TYPE_BOOL;
85 }
86 protected static function getConfigSection() : string
87 {
88 return Piwik::getPluginNameOfMatomoClass(static::class);
89 }
90 protected static function getConfigSettingName() : string
91 {
92 return static::getSystemName();
93 }
94 /**
95 * If the policy is active at the instance level,
96 * disabling the policy for a site will also disable it
97 * for the instance.
98 */
99 public static function setActiveStatus(?int $idSite, bool $isActive) : void
100 {
101 if (isset($idSite)) {
102 static::setMeasurableValue($idSite, $isActive);
103 if (static::getSystemValue() && !$isActive) {
104 static::setSystemValue($isActive);
105 }
106 return;
107 }
108 static::setSystemValue($isActive);
109 }
110 /**
111 * If the policy is active at the instance level, then
112 * this function will return true for all sites.
113 */
114 public static function isActive(?int $idSite) : bool
115 {
116 $instanceLevel = static::getSystemValue();
117 if (!$instanceLevel && isset($idSite)) {
118 return static::getMeasurableValue($idSite);
119 }
120 return $instanceLevel;
121 }
122 public static function isConfigControlled()
123 {
124 return !is_null(static::getConfigValue());
125 }
126 }
127