-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.php
74 lines (64 loc) · 2.08 KB
/
install.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
<?php
/**
* @package LOGman
* @copyright Copyright (C) 2011 - 2016 Timble CVBA. (http://www.timble.net)
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
* @link http://www.joomlatools.com
*/
/**
* LOGman - Komento installer
*
* @author Arunas Mazeika <https://github.com/amazeika>
* @package Joomlatools\Component\LOGman
*/
class plgLogmanKomentoInstallerScript
{
/**
* @var string The current installed LOGman version.
*/
protected $_logman_ver = null;
public function preflight($type, $installer)
{
$return = true;
$errors = array();
if (version_compare($this->getLogmanVersion(), '3.0.0', '<'))
{
$errors[] = JText::_('This plugin requires a newer LOGman version. Please download the latest version from <a href=http://joomlatools.com target=_blank>joomlatools.com</a> and upgrade.');
$return = false;
}
if ($return == false && $errors)
{
$error = implode('<br />', $errors);
$installer->getParent()->abort($error);
}
return $return;
}
/**
* Returns the current version (if any) of LOGman.
*
* @return string|null The LOGman version if present, null otherwise.
*/
public function getLogmanVersion()
{
if (!$this->_logman_ver) {
$this->_logman_ver = $this->_getExtensionVersion('com_logman');
}
return $this->_logman_ver;
}
/**
* Extension version getter.
*
* @param string $element The element name, e.g. com_extman, com_logman, etc.
* @return mixed|null|string The extension version, null if couldn't be determined.
*/
protected function _getExtensionVersion($element)
{
$version = null;
$query = "SELECT manifest_cache FROM #__extensions WHERE element = '{$element}'";
if ($result = JFactory::getDBO()->setQuery($query)->loadResult()) {
$manifest = new JRegistry($result);
$version = $manifest->get('version', null);
}
return $version;
}
}