-
Notifications
You must be signed in to change notification settings - Fork 37
/
installer.script.php
executable file
·83 lines (69 loc) · 2.36 KB
/
installer.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
82
83
<?php
/**
* @package Helix3 Framework
* @author JoomShaper https://www.joomshaper.com
* @copyright Copyright (c) 2010 - 2017 JoomShaper
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
*/
//no direct accees
defined ('_JEXEC') or die ('resticted aceess');
class plgSystemTmp_helix3InstallerScript
{
function postflight($type, $parent)
{
$db = JFactory::getDBO();
$status = new stdClass;
$status->plugins = array();
$src = $parent->getParent()->getPath('source');
$manifest = $parent->getParent()->manifest;
$plugins = $manifest->xpath('plugins/plugin');
foreach ($plugins as $key => $plugin)
{
$name = (string)$plugin->attributes()->plugin;
$group = (string)$plugin->attributes()->group;
$path = $src.'/plugins/'.$group;
if (JFolder::exists($src.'/plugins/'.$group.'/'.$name))
{
$path = $src.'/plugins/'.$group.'/'.$name;
}
$installer = new JInstaller;
$result = $installer->install($path);
if ($result)
{
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$fields = array(
$db->quoteName('enabled') . ' = 1'
);
$conditions = array(
$db->quoteName('type') . ' = ' . $db->quote('plugin'),
$db->quoteName('element') . ' = ' . $db->quote($name),
$db->quoteName('folder') . ' = ' . $db->quote($group)
);
$query->update($db->quoteName('#__extensions'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
}
$template_path = $src.'/template';
if (JFolder::exists( $template_path ))
{
$installer = new JInstaller;
$installer->install($template_path);
}
$conf = JFactory::getConfig();
$conf->set('debug', false);
$parent->getParent()->abort();
}
public function abort($msg = null, $type = null)
{
if ($msg)
{
JError::raiseWarning(100, $msg);
}
foreach ($this->packages as $package)
{
$package['installer']->abort(null, $type);
}
}
}