| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- namespace ModulesGarden\Servers\KerioEmail\App\Http\Actions;
- use ModulesGarden\Servers\KerioEmail\App\Enums\Response;
- use ModulesGarden\Servers\KerioEmail\App\Helpers\KerioManager;
- use ModulesGarden\Servers\KerioEmail\App\Libs\Product\ProductManager;
- use ModulesGarden\Servers\KerioEmail\App\Traits\ExtensionsCheckerTrait;
- use ModulesGarden\Servers\KerioEmail\Core\App\Controllers\Instances\AddonController;
- use ModulesGarden\Servers\KerioEmail\App\Models\ProductConfiguration;
- /**
- *
- * Created by PhpStorm.
- * User: Tomasz Bielecki ( tomasz.bi@modulesgarden.com )
- * Date: 09.09.19
- * Time: 15:15
- * Class ChangePackage
- */
- class ChangePackage extends AddonController
- {
- use ExtensionsCheckerTrait;
- /**
- * @param null $params
- * @return string|void
- */
- public function execute($params = null)
- {
- try{
- /**
- * check if extensions are installed
- */
- $this->checkExtensionOrThrowError();
- /**
- * run kerio service
- */
- $result = $this->kerioRunService($params);
- return $result;
- }catch (\Exception $ex)
- {
- /**
- * return some crit error
- */
- return $ex->getMessage();
- }
- }
- /**
- * @param null $params
- * @return string
- */
- protected function kerioRunService($params = null)
- {
- $productManager = new ProductManager();
- $productManager->loadById($params['pid']);
- $service = (new KerioManager())
- ->getApiByServer($params['serverid'])
- ->soap
- ->service()
- ->changePackages($productManager->get('cos_name'))
- ->setProductManager($productManager)
- ->setFormData($params)
- ;
- $result = $service->run();
- // $configuration = ProductConfiguration::where('product_id', $params['pid'])->get();
- // foreach($configuration as $cModel)
- // {
- // $config[$cModel->setting] = $cModel->value;
- // }
- //
- // $new_account_size = $config['acc_size'];
- //
- // //todo mailboxes from API
- //
- // $repository = (new KerioManager())
- // ->getApiByServer($params['serverid'])
- // ->soap
- // ->repository();
- //
- // $mailboxesApi = $repository->accounts->getByDomainName($params['domain']);
- //
- // if ($config['coss_name'] == "customMGkerio")
- // {
- // $attr = $config;
- // foreach ($attr as $key => &$item)
- // {
- // if (preg_match('/kerio.+/', $key))
- // {
- // $item = $item == "on" ? "TRUE" : "FALSE";
- // }
- // else
- // {
- // unset($attr[$key]);
- // }
- // }
- //
- // $attr['kerioMailQuota'] = $new_account_size * 1048576;
- // }elseif ($config['coss_name'] == 'cosQuota')
- // {
- // //todo
- // }else{
- //
- // }
- //
- // foreach($mailboxesApi as $key => $value)
- // {
- // //todo
- // }
- return Response::SUCCESS;
- }
- }
|