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\CoreAdminHome;
use Piwik\API\Request;
use Piwik\Piwik;
use Piwik\ProxyHttp;
use Piwik\Plugins\CoreHome\SystemSummary;
use Piwik\Settings\Storage\Backend\PluginSettingsTable;
/**
*
*/
class CoreAdminHome extends \Piwik\Plugin
{
/**
* @see \Piwik\Plugin::registerEvents
*/
public function registerEvents()
{
return array(
'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
'AssetManager.getJavaScriptFiles' => 'getJsFiles',
'UsersManager.deleteUser' => 'cleanupUser',
'API.DocumentationGenerator.@hideExceptForSuperUser' => 'displayOnlyForSuperUser',
'Template.jsGlobalVariables' => 'addJsGlobalVariables',
'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys',
'System.addSystemSummaryItems' => 'addSystemSummaryItems',
);
}
public function addSystemSummaryItems(&$systemSummary)
{
if (Piwik::isUserHasSomeAdminAccess()) {
$failures = Request::processRequest('CoreAdminHome.getTrackingFailures', [], []);
$numFailures = count($failures);
$icon = 'icon-error';
if ($numFailures === 0) {
$icon = 'icon-ok';
}
$systemSummary[] = new SystemSummary\Item($key = 'trackingfailures', Piwik::translate('CoreAdminHome_NTrackingFailures', $numFailures), $value = null, array('module' => 'CoreAdminHome', 'action' => 'trackingFailures'), $icon, $order = 9);
}
}
public function cleanupUser($userLogin)
{
PluginSettingsTable::removeAllUserSettingsForUser($userLogin);
}
public function getStylesheetFiles(&$stylesheets)
{
$stylesheets[] = "node_modules/jquery-ui-dist/jquery-ui.min.css";
$stylesheets[] = "plugins/Morpheus/stylesheets/base.less";
$stylesheets[] = "plugins/Morpheus/stylesheets/main.less";
$stylesheets[] = "plugins/CoreAdminHome/stylesheets/generalSettings.less";
$stylesheets[] = "plugins/CoreAdminHome/angularjs/trackingfailures/trackingfailures.directive.less";
}
public function getJsFiles(&$jsFiles)
{
$jsFiles[] = "node_modules/jquery/dist/jquery.min.js";
$jsFiles[] = "node_modules/jquery-ui-dist/jquery-ui.min.js";
$jsFiles[] = "node_modules/jquery.browser/dist/jquery.browser.min.js";
$jsFiles[] = "node_modules/sprintf-js/dist/sprintf.min.js";
$jsFiles[] = "plugins/Morpheus/javascripts/piwikHelper.js";
$jsFiles[] = "plugins/Morpheus/javascripts/ajaxHelper.js";
$jsFiles[] = "plugins/CoreHome/javascripts/broadcast.js";
$jsFiles[] = "plugins/CoreAdminHome/javascripts/protocolCheck.js";
}
public function displayOnlyForSuperUser(&$hide)
{
$hide = !Piwik::hasUserSuperUserAccess();
}
public function addJsGlobalVariables(&$out)
{
if (ProxyHttp::isHttps()) {
$isHttps = 'true';
} else {
$isHttps = 'false';
}
$out .= "piwik.hasServerDetectedHttps = $isHttps;\n";
}
public function getClientSideTranslationKeys(&$translationKeys)
{
$translationKeys[] = 'CoreAdminHome_ProtocolNotDetectedCorrectly';
$translationKeys[] = 'CoreAdminHome_ProtocolNotDetectedCorrectlySolution';
$translationKeys[] = 'CoreAdminHome_SettingsSaveSuccess';
$translationKeys[] = 'UserCountryMap_None';
$translationKeys[] = 'Actions_ColumnPageURL';
$translationKeys[] = 'General_Date';
$translationKeys[] = 'General_Measurable';
$translationKeys[] = 'General_Action';
$translationKeys[] = 'General_Delete';
$translationKeys[] = 'General_Id';
$translationKeys[] = 'CoreHome_ClickToSeeFullInformation';
$translationKeys[] = 'CoreAdminHome_LearnMore';
$translationKeys[] = 'CoreAdminHome_ConfirmDeleteAllTrackingFailures';
$translationKeys[] = 'CoreAdminHome_ConfirmDeleteThisTrackingFailure';
$translationKeys[] = 'CoreAdminHome_DeleteAllFailures';
$translationKeys[] = 'CoreAdminHome_NTrackingFailures';
$translationKeys[] = 'CoreAdminHome_Problem';
$translationKeys[] = 'CoreAdminHome_Solution';
$translationKeys[] = 'CoreAdminHome_TrackingFailures';
$translationKeys[] = 'CoreAdminHome_TrackingFailuresIntroduction';
$translationKeys[] = 'CoreAdminHome_TrackingURL';
$translationKeys[] = 'CoreAdminHome_NoKnownFailures';
$translationKeys[] = 'CoreAdminHome_JSTracking_CodeNoteBeforeClosingHead';
$translationKeys[] = 'CoreAdminHome_JSTracking_CodeNoteBeforeClosingHeadEmail';
}
}
|