-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.php
81 lines (74 loc) · 2.38 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
74
75
76
77
78
79
80
81
<?php
/*
* package: Custom Fields - Spotify plugin - FREE Version
* copyright: Copyright (c) 2023. Jeroen Moolenschot | Joomill
* license: GNU General Public License version 3 or later
* link: https://www.joomill-extensions.com
*/
// No direct access.
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Installer\InstallerAdapter;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Log\Log;
class plgFieldsSpotifyInstallerScript
{
/**
* Minimum Joomla version to check
*
* @var string
* @since 4.0.0
*/
private $minimumJoomlaVersion = '4.0';
/**
* Minimum PHP version to check
*
* @var string
* @since 4.0.0
*/
private $minimumPHPVersion = JOOMLA_MINIMUM_PHP;
/**
* Function called before extension installation/update/removal procedure commences
*
* @param string $type The type of change (install, update or discover_install, not uninstall)
* @param InstallerAdapter $parent The class calling this method
* @return boolean True on success
* @throws Exception
* @since 4.0.0
*/
public function preflight($type, $parent): bool
{
if ($type !== 'uninstall')
{
// Check for the minimum PHP version before continuing
if (!empty($this->minimumPHPVersion) && version_compare(PHP_VERSION, $this->minimumPHPVersion, '<'))
{
Log::add(
Text::sprintf('JLIB_INSTALLER_MINIMUM_PHP', $this->minimumPHPVersion),
Log::WARNING,
'jerror'
);
return false;
}
// Check for the minimum Joomla version before continuing
if (!empty($this->minimumJoomlaVersion) && version_compare(JVERSION, $this->minimumJoomlaVersion, '<'))
{
Log::add(
Text::sprintf('JLIB_INSTALLER_MINIMUM_JOOMLA', $this->minimumJoomlaVersion),
Log::WARNING,
'jerror'
);
return false;
}
}
return true;
}
/**
* Set the plugin to enabled on installation
*/
public function install($parent)
{
jimport('joomla.filesystem.file');
Factory::getDBO()->setQuery("UPDATE `#__extensions` SET `enabled` = 1 WHERE `type` = 'plugin' AND`element` = 'spotify'")->execute();
}
}