forked from andresce1979/auth0-joomla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
process.script.php
executable file
·50 lines (46 loc) · 1.88 KB
/
process.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
<?php
/**
* @package Auth0 Extension (joomla 3.x)
* @copyright Copyright (C) - http://www.auth0.com. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0-standalone.html
* @author Germán Lena
* @download URL http://www.auth0.com
*/
defined('_JEXEC') or die('Restricted access');
class com_auth0InstallerScript
{
public function install(JAdapterInstance $adapter)
{
jimport('joomla.installer.installer');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$app = JFactory::getApplication();
$src = dirname(__FILE__);
if (is_dir($src . '/modules/mod_auth0')) {
$installer = new JInstaller;
$result = @$installer->install($src . '/modules/mod_auth0');
if ($result) {
$app->enqueueMessage('Installing module [mod_auth0] was successful.', 'message');
} else {
$app->enqueueMessage('Installing module [mod_auth0] was unsuccessful.', 'error');
}
}
}
public function uninstall(JAdapterInstance $adapter)
{
$db = JFactory::getDBO();
$app = JFactory::getApplication();
jimport('joomla.installer.installer');
$db->setQuery('SELECT `extension_id` FROM #__extensions WHERE `element` = "mod_auth0" AND `type` = "module"');
$id = $db->loadResult();
if ($id) {
$installer = new JInstaller;
$result = @$installer->uninstall('module', $id, 1);
if ($result) {
$app->enqueueMessage('Uninstalling module [mod_auth0] was successful.', 'message');
} else {
$app->enqueueMessage('Uninstalling module [mod_auth0] was unsuccessful. Module may not exist or need manual uninstallation.', 'error');
}
}
}
}