Skip to content

Commit f066632

Browse files
committed
Improve code readability
1 parent f1e7614 commit f066632

File tree

4 files changed

+10
-37
lines changed

4 files changed

+10
-37
lines changed

API.php

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Piwik\Plugins\DisableTracking;
44

55
use Exception;
6-
use Piwik\Container\StaticContainer;
76
use Piwik\Piwik;
87
use Piwik\Plugin\API as BaseAPI;
98

@@ -12,44 +11,18 @@
1211
*/
1312
class API extends BaseAPI
1413
{
15-
private static $instance = null;
16-
17-
/**
18-
* Get Disable Tracking API instance.
19-
*
20-
* @throws \Exception if unable to bind to the container
21-
*
22-
* @return API the class instance
23-
*/
24-
public static function getInstance()
25-
{
26-
try {
27-
$instance = StaticContainer::get('DisableTracking_API');
28-
if (!($instance instanceof API)) {
29-
// Exception is caught below and corrected
30-
throw new Exception('DisableTracking_API must inherit API');
31-
}
32-
self::$instance = $instance;
33-
} catch (Exception $e) {
34-
self::$instance = StaticContainer::get('Piwik\Plugins\DisableTracking\API');
35-
StaticContainer::getContainer()->set('DisableTracking_API', self::$instance);
36-
}
37-
38-
return self::$instance;
39-
}
40-
4114
/**
42-
* Change archive status for websites.
15+
* Change disabled status for websites.
4316
*
4417
* @param string $idSites the list of comma separated websites IDs
45-
* @param $archive 'on' to archive, 'off' to re-enable
18+
* @param $disable 'on' to disable, 'off' to re-enable
4619
*
4720
* @throws Exception if an error occurred
4821
*/
49-
public function changeArchiveState($idSites, $archive)
22+
public function changeDisableState($idSites, $disable)
5023
{
5124
Piwik::checkUserHasAdminAccess($idSites);
5225

53-
DisableTracking::changeArchiveState(explode(',', $idSites), $archive);
26+
DisableTracking::changeDisableState(explode(',', $idSites), $disable);
5427
}
5528
}

Controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function index()
2121
{
2222
Piwik::checkUserHasSuperUserAccess();
2323

24-
if (true === isset($_POST) && true === isset($_POST['saveDisabledSitesState'])) {
24+
if (isset($_POST['saveDisabledSitesState'])) {
2525
DisableTracking::save();
2626
}
2727

DisableTracking.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function registerEvents()
8080
*/
8181
public function newTrackingRequest()
8282
{
83-
if (true === isset($_GET['idsite'])) {
83+
if (isset($_GET['idsite'])) {
8484
$siteId = (int) $_GET['idsite'];
8585
if (Manager::getInstance()->isPluginActivated('ProtectTrackID')) {
8686
$settings = StaticContainer::get('Piwik\Plugins\ProtectTrackID\SystemSettings');
@@ -169,14 +169,14 @@ public static function save()
169169
}
170170

171171
/**
172-
* Change archiving status for the websites.
172+
* Change disabled status for the websites.
173173
*
174174
* @param array $idSites the list of websites
175175
* @param string $disabled 'on' to archive, 'off' to re-enable
176176
*
177177
* @throws \Exception if an error occurred
178178
*/
179-
public static function changeArchiveState($idSites, $disabled)
179+
public static function changeDisableState($idSites, $disabled)
180180
{
181181
Piwik::checkUserHasAdminAccess($idSites);
182182

@@ -208,7 +208,7 @@ public static function changeArchiveState($idSites, $disabled)
208208
*/
209209
private static function disableSiteTracking($id)
210210
{
211-
if (false === self::isSiteTrackingDisabled($id)) {
211+
if (!self::isSiteTrackingDisabled($id)) {
212212
$sql = '
213213
INSERT INTO `' . Common::prefixTable(self::TABLE_DISABLE_TRACKING_MAP) . '`
214214
(siteId, created_at)

Menu.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Menu extends \Piwik\Plugin\Menu
1414
*/
1515
public function configureAdminMenu(MenuAdmin $menu)
1616
{
17-
if (true === Piwik::hasUserSuperUserAccess()) {
17+
if (Piwik::hasUserSuperUserAccess()) {
1818
$menu->addMeasurableItem('Disable Tracking', $this->urlForDefaultAction());
1919
}
2020
}

0 commit comments

Comments
 (0)