|
|
@@ -48,7 +48,7 @@ class AccountDataProvider extends BaseDataProvider
|
|
|
try {
|
|
|
$api->login($this->getWhmcsParamByKey('serverhostname'), $this->getWhmcsParamByKey('serverusername'), $this->getWhmcsParamByKey('serverpassword'));
|
|
|
$domainID = $api->getDomainId($maildomain);
|
|
|
- } catch (\Exception $error) {
|
|
|
+ } catch (KerioApiException $error) {
|
|
|
logModuleCall(
|
|
|
'kerioEmail',
|
|
|
__FUNCTION__,
|
|
|
@@ -62,18 +62,20 @@ class AccountDataProvider extends BaseDataProvider
|
|
|
return "Error: Domain $maildomain not found";
|
|
|
}
|
|
|
$active = $this->formData['status'] === 'active' ? TRUE : FALSE;
|
|
|
- try {
|
|
|
- $userID = $api->createUser($domainID, $this->formData['username'], $this->formData['password'], $active)['result'][0]['id'];
|
|
|
- } catch (\Exception $error) {
|
|
|
+ $response = $api->createUser($domainID, $this->formData['username'], $this->formData['password'], $active)['result'][0]['id'];
|
|
|
+
|
|
|
logModuleCall(
|
|
|
'kerioEmail',
|
|
|
__FUNCTION__,
|
|
|
- $error,
|
|
|
- 'Debug Error',
|
|
|
- $error->getMessage()
|
|
|
+ $this->formData,
|
|
|
+ 'Debug Response',
|
|
|
+ $response
|
|
|
);
|
|
|
- return ['error' => $error->getMessage()];
|
|
|
- }
|
|
|
+
|
|
|
+ return (new HtmlDataJsonResponse())->setMessageAndTranslate('emailAccountHasBeenAdded')->setStatusSuccess();
|
|
|
+
|
|
|
+ $userID = $response;
|
|
|
+
|
|
|
$account['fullName'] = $this->formData['display_name'];
|
|
|
if ($this->formData['quota'] > 0) {
|
|
|
$account['diskSizeLimit']['isActive'] = TRUE;
|
|
|
@@ -82,18 +84,8 @@ class AccountDataProvider extends BaseDataProvider
|
|
|
}
|
|
|
$account['diskSizeLimit']['limit']['value'] = intval($this->formData['quota']);
|
|
|
$account['diskSizeLimit']['limit']['units'] = $this->formData['unit'];
|
|
|
- try {
|
|
|
- $result = $api->modifyUser($userID, $account);
|
|
|
- } catch (KerioApiException $error) {
|
|
|
- logModuleCall(
|
|
|
- 'kerioEmail',
|
|
|
- __FUNCTION__,
|
|
|
- $error,
|
|
|
- 'Debug Error',
|
|
|
- $error->getMessage()
|
|
|
- );
|
|
|
- return ['error' => $error->getMessage()];
|
|
|
- }
|
|
|
+
|
|
|
+ $result = $api->modifyUser($userID, $account);
|
|
|
$fields['firstName'] = $this->formData['firstname'];
|
|
|
$fields['surName'] = $this->formData['lastname'];
|
|
|
$fields['commonName'] = $this->formData['display_name'];
|
|
|
@@ -103,18 +95,7 @@ class AccountDataProvider extends BaseDataProvider
|
|
|
$fields['phoneNumberMobile'] = $this->formData['mobile_phone'];
|
|
|
$fields['departmentName'] = $this->formData['department'];
|
|
|
$fields['profession'] = $this->formData['profession'];
|
|
|
- try {
|
|
|
- $result = $api->setAddress($userID, $fields);
|
|
|
- } catch (KerioApiException $error) {
|
|
|
- logModuleCall(
|
|
|
- 'kerioEmail',
|
|
|
- __FUNCTION__,
|
|
|
- $error,
|
|
|
- 'Debug Error',
|
|
|
- $error->getMessage()
|
|
|
- );
|
|
|
- return ['error' => $error->getMessage()];
|
|
|
- }
|
|
|
+ $result = $api->setAddress($userID, $fields);
|
|
|
|
|
|
return (new HtmlDataJsonResponse())->setMessageAndTranslate('emailAccountHasBeenAdded')->setStatusSuccess();
|
|
|
|