-
Notifications
You must be signed in to change notification settings - Fork 1
/
pkg_script.php
71 lines (66 loc) · 1.95 KB
/
pkg_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
<?php
/**
* @package Joomla.Package
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
final class pkg_hydroraindropInstallerScript
{
/**
* Called after any type of action
*
* @param string $route Which action is happening (install|uninstall|discover_install|update)
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function postflight($route, JAdapterInstance $adapter)
{
if (in_array($route, array('install', 'update', 'discover_install'))) {
return $this->install($adapter);
} else if ($route == 'uninstall') {
return $this->uninstall($adapter);
}
}
/**
* Called on installation
*
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function install(JAdapterInstance $adapter)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->update('#__extensions');
$query->set($db->qn('enabled') . ' = ' . $db->q(1));
$query->where($db->qn('element') . ' = ' . $db->q('hydroraindrop'));
$query->where($db->qn('folder') . ' = ' . $db->q('system'));
$db->setQuery($query);
$db->execute();
return true;
}
/**
* Called on uninstallation
*
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function uninstall(JAdapterInstance $adapter)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$conditions = array(
$db->quoteName('profile_key') . ' = ' . $db->quote('profile.HydroRaindropToken')
);
$query->delete($db->quoteName('#__user_profiles'));
$query->where($conditions);
$db->setQuery($query);
$db->execute();
return true;
}
}