|
|
@@ -6,6 +6,7 @@ use ThurData\Servers\KerioEmail\App\Libs\Kerio\Api;
|
|
|
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Client;
|
|
|
use ThurData\Servers\KerioEmail\App\Traits\ExtensionsCheckerTrait;
|
|
|
use ThurData\Servers\KerioEmail\Core\App\Controllers\Instances\AddonController;
|
|
|
+use ThurData\Servers\KerioEmail\api\KerioConnectApi;
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
@@ -27,66 +28,40 @@ class TestConnection extends AddonController
|
|
|
*/
|
|
|
public function execute($params = null)
|
|
|
{
|
|
|
- try{
|
|
|
-
|
|
|
- /**
|
|
|
- *
|
|
|
- */
|
|
|
- $this->checkExtensionOrThrowError();
|
|
|
- /**
|
|
|
- * kerio API manager
|
|
|
- */
|
|
|
- $manager = (new KerioManager());
|
|
|
-
|
|
|
- /**
|
|
|
- * set API params
|
|
|
- */
|
|
|
- if($params['serverusername'] )
|
|
|
- {
|
|
|
- /**
|
|
|
- *
|
|
|
- * override secure param
|
|
|
- */
|
|
|
- $params['serversecure'] = $params['serversecure'] ? 'on' : 'off';
|
|
|
-
|
|
|
- $api = $manager->getApi()->setParams($params);
|
|
|
- }else{
|
|
|
- $api = $manager->getApiByServer($params['serverid']);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * API Connection
|
|
|
- */
|
|
|
- $connection = $api->soap->getConnection();
|
|
|
+ /**
|
|
|
+ * API Connection
|
|
|
+ */
|
|
|
|
|
|
+ $api = new KerioConnectApi('whmcsKerioEmail', 'Thurdata', '1.0');
|
|
|
+ try {
|
|
|
+ $api->login($params['serverhostname'], $params['serverusername'], $params['serverpassword']);
|
|
|
+ $serverInfo = $api->sendRequest('Server.getProductInfo');
|
|
|
+ $api->logout();
|
|
|
+ } catch (KerioApiException $error) {
|
|
|
+ logModuleCall(
|
|
|
+ 'kerioEmail',
|
|
|
+ __FUNCTION__,
|
|
|
+ $api,
|
|
|
+ '',
|
|
|
+ $error->getMessage()
|
|
|
+ );
|
|
|
+ return ['error' => $error->getMessage()];
|
|
|
+ }
|
|
|
+
|
|
|
logModuleCall(
|
|
|
'kerioEmail',
|
|
|
__FUNCTION__,
|
|
|
- $connection,
|
|
|
- 'Debug SOAP Response',
|
|
|
+ $serverInfo,
|
|
|
+ 'Debug Kerio Api',
|
|
|
$api
|
|
|
);
|
|
|
|
|
|
- /**
|
|
|
- * check if connected and return true
|
|
|
- */
|
|
|
- if($connection->isConnected())
|
|
|
- {
|
|
|
- return ['success' => true];
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- *
|
|
|
- * return connection error
|
|
|
- */
|
|
|
- return ['error' => $connection->getConnectionError()];
|
|
|
- }
|
|
|
- catch (\Exception $ex)
|
|
|
+ /**
|
|
|
+ * check if connected and return true
|
|
|
+ */
|
|
|
+ if($serverInfo)
|
|
|
{
|
|
|
- /**
|
|
|
- * return some crit error
|
|
|
- */
|
|
|
- return ['error' => $ex->getMessage()];
|
|
|
+ return ['success' => true];
|
|
|
}
|
|
|
|
|
|
}
|