From 7fe908c50c8dbc5cc05f571dbe11d66141caacd4 Mon Sep 17 00:00:00 2001 From: Marius Cramer <m.cramer@pixcept.de> Date: Thu, 14 Nov 2013 09:01:22 -0500 Subject: [PATCH] Cleaning up code to match coding guidelines --- server/plugins-available/aps_plugin.inc.php | 116 +++++++++++++++++++++++++++++++-------------------------- 1 files changed, 63 insertions(+), 53 deletions(-) diff --git a/server/plugins-available/aps_plugin.inc.php b/server/plugins-available/aps_plugin.inc.php index e529b12..00eb6b7 100644 --- a/server/plugins-available/aps_plugin.inc.php +++ b/server/plugins-available/aps_plugin.inc.php @@ -28,14 +28,14 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -if(defined('ISPC_ROOT_PATH')) include_once(ISPC_ROOT_PATH.'/lib/classes/aps_installer.inc.php'); +if(defined('ISPC_ROOT_PATH')) include_once ISPC_ROOT_PATH.'/lib/classes/aps_installer.inc.php'; //require_once(ISPC_ROOT_PATH.'/lib/classes/class.installer.php'); class aps_plugin { - public $plugin_name = 'aps_plugin'; - public $class_name = 'aps_plugin'; - + public $plugin_name = 'aps_plugin'; + public $class_name = 'aps_plugin'; + //* This function is called during ispconfig installation to determine // if a symlink shall be created for this plugin. function onInstall() { @@ -48,71 +48,81 @@ } } - - /** - * This method gets called when the plugin is loaded - */ - public function onLoad() - { - global $app; - - // Register the available events - $app->plugins->registerEvent('aps_instance_insert', $this->plugin_name, 'install'); - $app->plugins->registerEvent('aps_instance_update', $this->plugin_name, 'install'); - $app->plugins->registerEvent('aps_instance_delete', $this->plugin_name, 'delete'); - } - - /** - * (Re-)install a package - */ - public function install($event_name, $data) - { - global $app, $conf; - + + /** + * This method gets called when the plugin is loaded + */ + + + public function onLoad() + { + global $app; + + // Register the available events + $app->plugins->registerEvent('aps_instance_insert', $this->plugin_name, 'install'); + $app->plugins->registerEvent('aps_instance_update', $this->plugin_name, 'install'); + $app->plugins->registerEvent('aps_instance_delete', $this->plugin_name, 'delete'); + } + + + + /** + * (Re-)install a package + */ + public function install($event_name, $data) + { + global $app, $conf; + //* dont run the installer on a mirror server to prevent // that the pplication gets installed twice. if($conf['mirror_server_id'] > 0) return true; - - $app->log("Starting APS install",LOGLEVEL_DEBUG); - if(!isset($data['new']['id'])) return false; - $instanceid = $data['new']['id']; - + + $app->log("Starting APS install", LOGLEVEL_DEBUG); + if(!isset($data['new']['id'])) return false; + $instanceid = $data['new']['id']; + if($data['new']['instance_status'] == INSTANCE_INSTALL) { $aps = new ApsInstaller($app); - $app->log("Running installHandler",LOGLEVEL_DEBUG); + $app->log("Running installHandler", LOGLEVEL_DEBUG); $aps->installHandler($instanceid, 'install'); } - + if($data['new']['instance_status'] == INSTANCE_REMOVE) { $aps = new ApsInstaller($app); - $app->log("Running installHandler",LOGLEVEL_DEBUG); + $app->log("Running installHandler", LOGLEVEL_DEBUG); $aps->installHandler($instanceid, 'delete'); } - } - - /** - * Update an existing instance (currently unused) - */ - /* + } + + + + /** + * Update an existing instance (currently unused) + */ + /* public function update($event_name, $data) { } */ - - /** - * Uninstall an instance - */ - public function delete($event_name, $data) - { - global $app, $conf; - - if(!isset($data['new']['id'])) return false; - $instanceid = $data['new']['id']; - + + + + /** + * Uninstall an instance + */ + public function delete($event_name, $data) + { + global $app, $conf; + + if(!isset($data['new']['id'])) return false; + $instanceid = $data['new']['id']; + if($data['new']['instance_status'] == INSTANCE_REMOVE) { $aps = new ApsInstaller($app); $aps->installHandler($instanceid, 'install'); - } - } + } + } + } -?> \ No newline at end of file + +?> -- Gitblit v1.9.1