A server plugin allows Clientexec to automatically provision and manage services.
We have created a sample server module that should be used as a starting point: https://github.com/clientexec/sample-server
Naming Convention
The name of the plugin directory MUST be all lower case, and alphanumeric, such as sample.
The name of the plugin file, and the plugin class MUST start with Plugin, followed by the name of the directory with ONLY the first letter capitalized, such as PluginSample
Features
Each server plugin can define certain features to be available or not.
- packageName - If Clientexec should show the "Package Name On Server" option.
- testConnection - If this plugin supports testing the server credentials (coded in the testConnection function).
- showNameservers - If this plugin should have name servers associated with it.
- directlink - If this plugin has a direct login link from the client side.
public $features = [ 'packageName' => true, 'testConnection' => true, 'showNameservers' => false, 'directlink' => true ];
Configuration
Each server plugin must have a getVariables() function which will define options for each server and package. The function must return an array of values.
public function getVariables() { $variables = [ 'Name' => [ 'type' => 'hidden', 'description' => 'Used by CE to show plugin', 'value' => 'Sample' ], 'Description' => [ 'type' => 'hidden', 'description' => 'Description viewable by admin in server settings', 'value' => 'Sample Server Plugin' ], 'Text Field' => [ 'type' => 'text', 'description' => 'Text Field Description', 'value' => 'Default Value', ], 'Encrypted Text Field' => [ 'type' => 'text', 'description' => 'Encrypted Text Field Description', 'value' => '', 'encryptable' => true ], 'Password Text Field' => [ 'type' => 'password', 'description' => 'Encrypted Password Field Description', 'value' => '', 'encryptable' => true ], 'Text Area' => [ 'type' => 'textarea', 'description' => 'Text Area Description', 'value' => 'Default Value', ], 'Yes / No' => [ 'type' => 'yesno', 'description' => 'Yes / No Description', 'value' => '1', ], 'Actions' => [ 'type' => 'hidden', 'description' => 'Current actions that are active for this plugin per server', 'value'=>'Create,Delete,Suspend,UnSuspend' ], 'Registered Actions For Customer' => [ 'type' => 'hidden', 'description' => 'Current actions that are active for this plugin per server for customers', 'value' => 'authenticateClient' ], 'package_addons' => [ 'type' => 'hidden', 'description' => 'Supported signup addons variables', 'value' => ['DISKSPACE', 'BANDWIDTH', 'SSL'] ], 'package_vars' => [ 'type' => 'hidden', 'description' => 'Whether package settings are set', 'value' => '1', ], 'package_vars_values' => [ 'type' => 'hidden', 'description' => lang('Package Settings'), 'value' => [ 'Text Field' => [ 'type' => 'text', 'label' => 'Text Field Label', 'description' => 'Text Field Description', 'value' => 'Default Value', ], 'Drop Down' => [ 'type' => 'dropdown', 'multiple' => false, 'getValues' => 'getDropDownValues', 'label' => 'Drop Down Label', 'description' => 'Drop Down Description', 'vaue' => '', ] ] ] ]; return $variables; }
Error Handling
Throwing a CE_Exception will display the error message to the client/admin.
Functions
The following is a list of minimal functions for a server plugin. Additional functions may be created, and assigned to the "Actions" (for admin) or "Registered Actions For Customer" (for client side) array. Only actions should be prepended with "do" in the actual server class (i.e. function doCreate()).