This repository has been archived by the owner on May 5, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.installer.php
60 lines (49 loc) · 1.59 KB
/
script.installer.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
<?php
/**
* @author Branko Wilhelm <branko.wilhelm@gmail.com>
* @link http://www.z-index.net
* @copyright (c) 2014 Branko Wilhelm
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die;
class mod_teamspeak3InstallerScript
{
private $cli = array(
'teamspeak3.php'
);
public function preflight()
{
if (!function_exists('stream_socket_client')) {
JFactory::getApplication()->enqueueMessage(__CLASS__ . ': network functions are not available in this PHP installation', 'error');
return false;
}
return true;
}
public function install(JAdapterInstance $adapter)
{
$lib = $adapter->getParent()->getPath('source') . '/library/';
$installer = new JInstaller;
$installer->install($lib);
$src = $adapter->getParent()->getPath('source');
foreach ($this->cli as $script) {
if (JFile::exists(JPATH_ROOT . '/cli/' . $script)) {
JFile::delete(JPATH_ROOT . '/cli/' . $script);
}
if (JFile::exists($src . '/cli/' . $script)) {
JFile::move($src . '/cli/' . $script, JPATH_ROOT . '/cli/' . $script);
}
}
}
public function update(JAdapterInstance $adapter)
{
$this->install($adapter);
}
public function uninstall(JAdapterInstance $adapter)
{
foreach ($this->cli as $script) {
if (JFile::exists(JPATH_ROOT . '/cli/' . $script)) {
JFile::delete(JPATH_ROOT . '/cli/' . $script);
}
}
}
}