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