/
script.php
73 lines (62 loc) · 1.42 KB
/
script.php
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
<?php
/**
* @package DD_Google_Analytics
*
* @author HR-IT-Solutions Florian Häusler <info@hr-it-solutions.com>
* @copyright Copyright (C) 2017 - 2019 HR-IT-Solutions GmbH
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
**/
defined('_JEXEC') or die();
/**
* Class PlgSystemDD_Google_AnalyticsInstallerScript
*
* @since Version 1.0.0.0
*/
class PlgSystemDD_Google_AnalyticsInstallerScript
{
protected $name = 'DD Google Analytics';
protected $extensionsToEnable = array(
array( 'name' => 'dd_google_analytics',
'type' => 'plugin',
'group' => 'system')
);
/**
* Enable extensions
*
* @since Version 1.0.0.0
*
* @return void
*/
private function enableExtensions()
{
foreach ($this->extensionsToEnable as $extension)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->update('#__extensions')
->set($db->qn('enabled') . ' = ' . $db->q(1))
->where('type = ' . $db->q($extension['type']))
->where('element = ' . $db->q($extension['name']));
if ($extension['type'] === 'plugin')
{
$query->where('folder = ' . $db->q($extension['group']));
}
$db->setQuery($query);
$db->execute();
}
}
/**
* JInstaller
*
* @param object $parent \JInstallerAdapterPackageParent
*
* @return boolean
*
* @since Version 1.0.0.0
*/
public function install($parent)
{
$this->enableExtensions();
return true;
}
}