-
Notifications
You must be signed in to change notification settings - Fork 2
/
script.fillitup.php
executable file
·58 lines (54 loc) · 1.97 KB
/
script.fillitup.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
<?php
/**
* @version 1.x
* @package Fill It Up
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2018 JoomlaWorks Ltd. All rights reserved.
* @license http://www.joomlaworks.net/license
*/
// no direct access
defined('_JEXEC') or die ;
class Com_Jw_FillItUpInstallerScript
{
public function postflight($type, $parent)
{
$db = JFactory::getDBO();
$manifest = $parent->getParent()->manifest;
$src = $parent->getParent()->getPath('source');
$plugins = $manifest->xpath('plugins/plugin');
foreach ($plugins as $plugin)
{
$name = (string)$plugin->attributes()->plugin;
$group = (string)$plugin->attributes()->group;
$path = $src.'/plugins/'.$group.'/'.$name;
$installer = new JInstaller;
$installer->install($path);
$query = "UPDATE #__extensions SET enabled=1 WHERE type='plugin' AND element=".$db->Quote($name)." AND folder=".$db->Quote($group);
$db->setQuery($query);
$db->query();
}
}
public function uninstall($parent)
{
$db = JFactory::getDBO();
$manifest = $parent->getParent()->manifest;
$src = $parent->getParent()->getPath('source');
$plugins = $manifest->xpath('plugins/plugin');
foreach ($plugins as $plugin)
{
$name = (string)$plugin->attributes()->plugin;
$group = (string)$plugin->attributes()->group;
$query = "SELECT `extension_id` FROM #__extensions WHERE `type`='plugin' AND element = ".$db->Quote($name)." AND folder = ".$db->Quote($group);
$db->setQuery($query);
$extensions = $db->loadColumn();
if (count($extensions))
{
foreach ($extensions as $id)
{
$installer = new JInstaller;
$installer->uninstall('plugin', $id);
}
}
}
}
}