| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- namespace ThurData\Servers\KerioEmail\App\Http\Actions;
- use ThurData\Servers\KerioEmail\App\Enums\Response;
- use ThurData\Servers\KerioEmail\App\Helpers\KerioManager;
- use ThurData\Servers\KerioEmail\App\Libs\Product\ProductManager;
- use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Models\Domain;
- use ThurData\Servers\KerioEmail\App\Traits\ExtensionsCheckerTrait;
- use ThurData\Servers\KerioEmail\Core\App\Controllers\Instances\AddonController;
- use ThurData\Servers\KerioEmail\App\Traits\HostingService;
- use \ThurData\Servers\KerioEmail\Core\UI\Traits\WhmcsParams;
- use ThurData\Servers\KerioEmail\Api\KerioConnectApi;
- /**
- *
- * Created by PhpStorm.
- * User: ThurData
- * Date: 09.09.19
- * Time: 15:14
- * Class CreateAccount
- */
- class CreateAccount extends AddonController
- {
- use ExtensionsCheckerTrait;
- use HostingService;
- use WhmcsParams;
-
- /**
- * create domain in kerio
- *
- * @param null $params
- * @return string
- */
- public function execute($params = null)
- {
- try{
- /**
- * check if extensions are installed
- */
- $this->checkExtensionOrThrowError();
- //update domain
- if($params['customfields']['maildomain']){
- $params['domain'] = $params['customfields']['maildomain'];
- $this->hosting()->domain = $params['domain'];
- $this->hosting()->save();
- }
- /**
- * run kerio service
- */
- $result = $this->kerioRunService($params);
- return $result;
- }catch (\Exception $ex)
- {
- /**
- * return some crit error
- */
- return $ex->getMessage();
- }
- }
- /**
- * @param null $params
- * @return mixed|string
- */
- protected function kerioRunService($params = null)
- {
- $api = new KerioConnectApi('whmcsKerioEmail', 'Thurdata', '1.0');
- try {
- $api->login($params['serverhostname'], $params['serverusername'], $params['serverpassword']);
- $result = $api->sendRequest('Domains.get');
- $api->logout();
- } catch (KerioApiException $error) {
- return ['error' => $error->getMessage()];
- }
- logModuleCall(
- 'kerioEmail',
- __FUNCTION__,
- $result,
- 'Debug Features & Attributes',
- $params
- );
- /**
- * return success response
- */
- return Response::SUCCESS;
- }
- }
|