commit | author | age
|
bbc657
|
1 |
<?php |
MC |
2 |
/* |
|
3 |
Copyright (c) 2012, ISPConfig UG |
|
4 |
Contributors: web wack creations, http://www.web-wack.at |
|
5 |
All rights reserved. |
|
6 |
|
|
7 |
Redistribution and use in source and binary forms, with or without modification, |
|
8 |
are permitted provided that the following conditions are met: |
|
9 |
|
|
10 |
* Redistributions of source code must retain the above copyright notice, |
|
11 |
this list of conditions and the following disclaimer. |
|
12 |
* Redistributions in binary form must reproduce the above copyright notice, |
|
13 |
this list of conditions and the following disclaimer in the documentation |
|
14 |
and/or other materials provided with the distribution. |
|
15 |
* Neither the name of ISPConfig nor the names of its contributors |
|
16 |
may be used to endorse or promote products derived from this software without |
|
17 |
specific prior written permission. |
|
18 |
|
|
19 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
|
20 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
21 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
22 |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
|
23 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
24 |
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
25 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
26 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
27 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
28 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
29 |
*/ |
|
30 |
|
b1a6a5
|
31 |
if(defined('ISPC_ROOT_PATH')) include_once ISPC_ROOT_PATH.'/lib/classes/aps_installer.inc.php'; |
bbc657
|
32 |
//require_once(ISPC_ROOT_PATH.'/lib/classes/class.installer.php'); |
MC |
33 |
|
|
34 |
class aps_plugin |
|
35 |
{ |
b1a6a5
|
36 |
public $plugin_name = 'aps_plugin'; |
MC |
37 |
public $class_name = 'aps_plugin'; |
|
38 |
|
bbc657
|
39 |
//* This function is called during ispconfig installation to determine |
MC |
40 |
// if a symlink shall be created for this plugin. |
|
41 |
function onInstall() { |
|
42 |
global $conf; |
|
43 |
|
|
44 |
if($conf['services']['web'] == true) { |
|
45 |
return true; |
|
46 |
} else { |
|
47 |
return false; |
|
48 |
} |
|
49 |
|
|
50 |
} |
b1a6a5
|
51 |
|
MC |
52 |
/** |
|
53 |
* This method gets called when the plugin is loaded |
|
54 |
*/ |
|
55 |
|
|
56 |
|
|
57 |
public function onLoad() |
|
58 |
{ |
|
59 |
global $app; |
|
60 |
|
|
61 |
// Register the available events |
|
62 |
$app->plugins->registerEvent('aps_instance_insert', $this->plugin_name, 'install'); |
|
63 |
$app->plugins->registerEvent('aps_instance_update', $this->plugin_name, 'install'); |
|
64 |
$app->plugins->registerEvent('aps_instance_delete', $this->plugin_name, 'delete'); |
|
65 |
} |
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
/** |
|
70 |
* (Re-)install a package |
|
71 |
*/ |
|
72 |
public function install($event_name, $data) |
|
73 |
{ |
|
74 |
global $app, $conf; |
|
75 |
|
bbc657
|
76 |
//* dont run the installer on a mirror server to prevent |
MC |
77 |
// that the pplication gets installed twice. |
|
78 |
if($conf['mirror_server_id'] > 0) return true; |
b1a6a5
|
79 |
|
MC |
80 |
$app->log("Starting APS install", LOGLEVEL_DEBUG); |
|
81 |
if(!isset($data['new']['id'])) return false; |
|
82 |
$instanceid = $data['new']['id']; |
|
83 |
|
bbc657
|
84 |
if($data['new']['instance_status'] == INSTANCE_INSTALL) { |
MC |
85 |
$aps = new ApsInstaller($app); |
b1a6a5
|
86 |
$app->log("Running installHandler", LOGLEVEL_DEBUG); |
bbc657
|
87 |
$aps->installHandler($instanceid, 'install'); |
MC |
88 |
} |
b1a6a5
|
89 |
|
bbc657
|
90 |
if($data['new']['instance_status'] == INSTANCE_REMOVE) { |
MC |
91 |
$aps = new ApsInstaller($app); |
b1a6a5
|
92 |
$app->log("Running installHandler", LOGLEVEL_DEBUG); |
bbc657
|
93 |
$aps->installHandler($instanceid, 'delete'); |
MC |
94 |
} |
b1a6a5
|
95 |
} |
MC |
96 |
|
|
97 |
|
|
98 |
|
|
99 |
/** |
|
100 |
* Update an existing instance (currently unused) |
|
101 |
*/ |
|
102 |
/* |
bbc657
|
103 |
public function update($event_name, $data) |
MC |
104 |
{ |
|
105 |
} |
|
106 |
*/ |
b1a6a5
|
107 |
|
MC |
108 |
|
|
109 |
|
|
110 |
/** |
|
111 |
* Uninstall an instance |
|
112 |
*/ |
|
113 |
public function delete($event_name, $data) |
|
114 |
{ |
|
115 |
global $app, $conf; |
|
116 |
|
|
117 |
if(!isset($data['new']['id'])) return false; |
|
118 |
$instanceid = $data['new']['id']; |
|
119 |
|
bbc657
|
120 |
if($data['new']['instance_status'] == INSTANCE_REMOVE) { |
MC |
121 |
$aps = new ApsInstaller($app); |
|
122 |
$aps->installHandler($instanceid, 'install'); |
b1a6a5
|
123 |
} |
MC |
124 |
} |
|
125 |
|
bbc657
|
126 |
} |
b1a6a5
|
127 |
|
MC |
128 |
?> |