script.installer.php
2.31 KB
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
<?php
/**
* @package OSSystem
* @contact www.joomlashack.com, help@joomlashack.com
* @copyright 2016 Open Source Training, LLC. All rights reserved
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
use Alledia\Installer;
defined('_JEXEC') or die();
require_once 'library/Installer/include.php';
jimport('joomla.filesystem.folder');
/**
* Custom installer script
*/
if (!class_exists('PlgSystemOSSystemInstallerScript')) {
class PlgSystemOSSystemInstallerScript extends Installer\AbstractScript
{
/**
* @param string $type
* @param JInstallerAdapterComponent $parent
*
* @return bool
*/
public function preFlight($type, $parent)
{
if (!parent::preFlight($type, $parent)) {
return false;
}
/* Uninstall the depracated plugin OSCARootCertificates.
* The parent method can't be used because the old plugin
* has a bug that doesn't allow to use the native uninstall method.
*/
$success = false;
// Remove the files
$path = JPATH_SITE . '/plugins/system/oscarootcertificates';
if (JFolder::exists($path)) {
$success = JFolder::delete($path);
}
// Remove the database row
$db = JFactory::getDbo();
$queryWhere = array(
$db->qn('type') . ' = ' . $db->q('plugin'),
$db->qn('element') . ' = ' . $db->q('oscarootcertificates'),
$db->qn('folder') . ' = ' . $db->q('system'),
);
$query = $db->getQuery(true)
->select('COUNT(*)')
->from('#__extensions')
->where($queryWhere);
$db->setQuery($query);
if ((int) $db->loadResult() > 0) {
$query = $db->getQuery(true)
->delete('#__extensions')
->where($queryWhere);
$db->setQuery($query);
$success = $db->execute();
}
// Displays the success message
if ((bool) $success) {
$this->setMessage('OSSystem OSCARootCertificates uninstalled successfully');
}
return true;
}
}
}