|
|
@@ -2,19 +2,8 @@
|
|
|
|
|
|
namespace ThurData\Servers\KerioEmail\App\UI\Client\EmailAccount\Providers;
|
|
|
|
|
|
-
|
|
|
use ThurData\Servers\KerioEmail\App\Enums\Kerio;
|
|
|
-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\Account;
|
|
|
-use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Models\ClassOfService;
|
|
|
-use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Repository;
|
|
|
-use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Repository\ClassOfServices;
|
|
|
-use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Response;
|
|
|
-use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Update\UpdateAccount;
|
|
|
-use ThurData\Servers\KerioEmail\App\Services\ConfigurableOptions\Strategy\Types\ClassOfServicesOptions;
|
|
|
use function ThurData\Servers\KerioEmail\Core\Helper\di;
|
|
|
-use ThurData\Servers\KerioEmail\Core\Models\Whmcs\Hosting;
|
|
|
use ThurData\Servers\KerioEmail\Core\UI\ResponseTemplates\HtmlDataJsonResponse;
|
|
|
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\DataProviders\BaseDataProvider;
|
|
|
use ThurData\Servers\KerioEmail\Api\KerioWhmcs;
|
|
|
@@ -35,17 +24,7 @@ class EditAccountDataProvider extends BaseDataProvider
|
|
|
*/
|
|
|
public function read()
|
|
|
{
|
|
|
- /**
|
|
|
- * hosting id
|
|
|
- */
|
|
|
- $hid = $this->getRequestValue('id');
|
|
|
- /**
|
|
|
- * load hosting
|
|
|
- */
|
|
|
- $hosting = Hosting::where('id', $hid)->first();
|
|
|
- /**
|
|
|
- * load api
|
|
|
- */
|
|
|
+ $domain = $this->getWhmcsParamByKey('domain');
|
|
|
$api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
|
|
|
$fields =array(
|
|
|
'id',
|
|
|
@@ -78,7 +57,7 @@ class EditAccountDataProvider extends BaseDataProvider
|
|
|
return ['error' => $error->getMessage()];
|
|
|
}
|
|
|
try {
|
|
|
- $domainID = $api->getDomainId($this->getWhmcsParamByKey('customfields')['maildomain']);
|
|
|
+ $domainID = $api->getDomainId($domain);
|
|
|
} catch (KerioApiException $error) {
|
|
|
logModuleCall(
|
|
|
'kerioEmail',
|
|
|
@@ -116,7 +95,7 @@ class EditAccountDataProvider extends BaseDataProvider
|
|
|
$api->logout();
|
|
|
$this->data['id'] = $account[0]['id'];
|
|
|
$this->data['username'] = $account[0]['loginName'];
|
|
|
- $this->data['domain'] = $this->getWhmcsParamByKey('customfields')['maildomain'];
|
|
|
+ $this->data['domain'] = $domain;
|
|
|
$this->data['firstname'] = $address['contacts'][0]['firstName'];
|
|
|
$this->data['lastname'] = $address['contacts'][0]['surName'];
|
|
|
$this->data['display_name'] = $address['contacts'][0]['commonName'];
|
|
|
@@ -151,12 +130,6 @@ class EditAccountDataProvider extends BaseDataProvider
|
|
|
*/
|
|
|
public function update()
|
|
|
{
|
|
|
- /**
|
|
|
- * hosting id
|
|
|
- */
|
|
|
- $hid = $this->request->get('id');
|
|
|
-
|
|
|
-
|
|
|
$fieldToProtection = ['firstname', 'lastname', 'display_name', 'office', 'title', 'department', 'profession'];
|
|
|
|
|
|
foreach ($this->formData as $field => &$value)
|
|
|
@@ -164,12 +137,6 @@ class EditAccountDataProvider extends BaseDataProvider
|
|
|
$value = in_array($field, $fieldToProtection) ? htmlentities($value) : $value;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * product manager allow to check product settings
|
|
|
- */
|
|
|
- $productManager = new ProductManager();
|
|
|
- $productManager->loadByHostingId($hid);
|
|
|
-
|
|
|
$account['isEnabled'] = $this->formData['status'] === 'active' ? TRUE : FALSE;
|
|
|
if ($this->formData['quota'] > 0) {
|
|
|
$account['diskSizeLimit']['isActive'] = TRUE;
|
|
|
@@ -234,17 +201,6 @@ class EditAccountDataProvider extends BaseDataProvider
|
|
|
*/
|
|
|
public function updateStatus()
|
|
|
{
|
|
|
- /**
|
|
|
- * hosting id
|
|
|
- */
|
|
|
- $hid = $this->request->get('id');
|
|
|
-
|
|
|
- /**
|
|
|
- * product manager allow to check product settings
|
|
|
- */
|
|
|
- $productManager = new ProductManager();
|
|
|
- $productManager->loadByHostingId($hid);
|
|
|
-
|
|
|
$status['isEnabled'] = $this->formData['status'] === 'active' ? TRUE : FALSE;
|
|
|
$api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
|
|
|
try {
|
|
|
@@ -272,9 +228,7 @@ class EditAccountDataProvider extends BaseDataProvider
|
|
|
return ['error' => $error->getMessage()];
|
|
|
}
|
|
|
$api->logout();
|
|
|
- /**
|
|
|
- * return success
|
|
|
- */
|
|
|
+
|
|
|
return (new HtmlDataJsonResponse())->setMessageAndTranslate('emailAccountStatusHasBeenUpdated')->setStatusSuccess();
|
|
|
|
|
|
}
|
|
|
@@ -284,16 +238,6 @@ class EditAccountDataProvider extends BaseDataProvider
|
|
|
*/
|
|
|
public function changePassword()
|
|
|
{
|
|
|
- /**
|
|
|
- * hosting id
|
|
|
- */
|
|
|
- $hid = $this->request->get('id');
|
|
|
-
|
|
|
- /**
|
|
|
- * product manager allow to check product settings
|
|
|
- */
|
|
|
- $productManager = new ProductManager();
|
|
|
- $productManager->loadByHostingId($hid);
|
|
|
$fields['password'] = $this->formData['password'];
|
|
|
$api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
|
|
|
try {
|
|
|
@@ -330,82 +274,6 @@ class EditAccountDataProvider extends BaseDataProvider
|
|
|
*/
|
|
|
public function readCosParams()
|
|
|
{
|
|
|
- $hid = $this->getRequestValue('id');
|
|
|
- /**
|
|
|
- * product manager allow to check product settings
|
|
|
- */
|
|
|
- $productManager = new ProductManager();
|
|
|
- $productManager->loadByHostingId($hid);
|
|
|
- if($productManager->get('cos_name') === ClassOfServices::CLASS_OF_SERVICE_QUOTA)
|
|
|
- {
|
|
|
- /**
|
|
|
- *
|
|
|
- * get soap create domain service
|
|
|
- */
|
|
|
- $api =(new KerioManager())
|
|
|
- ->getApiByHosting($hid)
|
|
|
- ->soap;
|
|
|
-
|
|
|
- /**
|
|
|
- *
|
|
|
- * get cos from API
|
|
|
- */
|
|
|
- $classOfServices = $api->repository()->cos->all();
|
|
|
-
|
|
|
- /**
|
|
|
- *
|
|
|
- * load configurable options coses
|
|
|
- */
|
|
|
- $supportedCos = $productManager->getSettingCos();
|
|
|
-
|
|
|
- /**
|
|
|
- *
|
|
|
- * add COS to array
|
|
|
- */
|
|
|
- $configoptions = $this->getFilteredCosConfigurableOptions();
|
|
|
- foreach($classOfServices as $cos)
|
|
|
- {
|
|
|
- /**
|
|
|
- *
|
|
|
- *
|
|
|
- * skip COS which is not used in configurable options
|
|
|
- */
|
|
|
- if(!($supportedCos && array_key_exists($cos->getId(), $supportedCos)))
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- *
|
|
|
- * skip if class of services doesnt exists in config option list
|
|
|
- */
|
|
|
- if($configoptions && !array_key_exists('cosQuota_'.$cos->getId(), $configoptions))
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * skip not purchased as CO
|
|
|
- */
|
|
|
- if ($configoptions && $configoptions['cosQuota_'.$cos->getId()] == 0)
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 1. check if config opts are not available
|
|
|
- * 2. skip if quantity === 0
|
|
|
- */
|
|
|
- if(!$configoptions && $supportedCos[$cos->getId()] == 0)
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /* @var $cos ClassOfService*/
|
|
|
- $this->availableValues['cosId'][$cos->getId()] = $cos->getMbMailQuote().' MB';
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -414,18 +282,7 @@ class EditAccountDataProvider extends BaseDataProvider
|
|
|
*/
|
|
|
protected function getFilteredCosConfigurableOptions()
|
|
|
{
|
|
|
- $configoptions = $this->getWhmcsParamByKey('configoptions');
|
|
|
-
|
|
|
- foreach($configoptions as $key => $value)
|
|
|
- {
|
|
|
- if(strpos($key, ClassOfServicesOptions::COS_CONFIG_OPT_PREFIX) === false)
|
|
|
- {
|
|
|
- unset($configoptions[$key]);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
- return $configoptions;
|
|
|
}
|
|
|
|
|
|
}
|