| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- namespace ThurData\Servers\KerioEmail\App\UI\Client\DomainAlias\Providers;
- 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\Services\Delete\DeleteDomainAlias;
- use ThurData\Servers\KerioEmail\Core\UI\ResponseTemplates\HtmlDataJsonResponse;
- use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\DataProviders\BaseDataProvider;
- /**
- *
- * Created by PhpStorm.
- * User: Tomasz Bielecki ( tomasz.bi@thurdata.com )
- * Date: 02.10.19
- * Time: 14:41
- * Class DeleteDomainAliasProvider
- */
- class DeleteDomainAliasProvider extends BaseDataProvider
- {
- /**
- *
- */
- public function read()
- {
- $this->data['id'] = $this->actionElementId;
- }
- /**
- *
- */
- public function update()
- {
- // TODO: Implement update() method.
- }
- /**
- * @return HtmlDataJsonResponse|void
- */
- public function delete()
- {
- /**
- * hosting id
- */
- $hid = $this->request->get('id');
- /**
- * load product configuration
- */
- $productManager = new ProductManager();
- $productManager->loadByHostingId($hid);
- /**
- * load kerio manager by hosting id
- */
- $service = (new KerioManager())
- ->getApiByHosting($hid)
- ->soap
- ->service()
- ->deleteDomainAlias()
- ->setFormData($this->formData)
- ;
- /**
- * run service
- */
- $result = $service->run();
- /**
- *
- * return success or error response
- */
- if(!$result)
- {
- return (new HtmlDataJsonResponse())->setMessageAndTranslate($service->getError())->setStatusError();
- }
- return (new HtmlDataJsonResponse())->setMessageAndTranslate('domainAliasHasBeenDeleted')->setStatusSuccess();
- }
- public function massDelete()
- {
- /**
- * hosting id
- */
- $hid = $this->request->get('id');
- /**
- * load product configuration
- */
- $productManager = new ProductManager();
- $productManager->loadByHostingId($hid);
- /**
- * load kerio manager by hosting id
- */
- $service = (new KerioManager())
- ->getApiByHosting($hid)
- ->soap
- ->service()
- ->deleteDomainAlias();
- /**
- *
- */
- foreach($this->request->get('massActions') as $id)
- {
- $service->setFormData(['id' => $id]);
- $result = $service->run();
- }
- return (new HtmlDataJsonResponse())
- ->setMessageAndTranslate('massDomainAliasHasBeenDeleted')
- ->setStatusSuccess();
- }
- }
|