| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- /* * ********************************************************************
- * ProxmoxVPS Product developed. (27.03.19)
- * *
- *
- * CREATED BY MODULESGARDEN -> http://modulesgarden.com
- * CONTACT -> contact@modulesgarden.com
- *
- *
- * This software is furnished under a license and may be used and copied
- * only in accordance with the terms of such license and with the
- * inclusion of the above copyright notice. This software or any other
- * copies thereof may not be provided or otherwise made available to any
- * other person. No title to and ownership of the software is hereby
- * transferred.
- *
- *
- * ******************************************************************** */
- namespace ModulesGarden\Servers\ProxmoxCloudVps\App\UI\FirewallOption\Providers;
- use ModulesGarden\ProxmoxAddon\App\Services\ApiService;
- use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\ClientArea;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\ResponseTemplates\HtmlDataJsonResponse;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\DataProviders\BaseDataProvider;
- class FirewallOptionProvider extends BaseDataProvider implements ClientArea
- {
- use ApiService;
- use ProductService;
- public function read()
- {
- $vm = \ModulesGarden\ProxmoxAddon\Core\Helper\sl('Vm')->getVm();
- $this->data = $vm->firewallOptions()->read()->getAttributes();
- $this->data["enable"] = str_replace(["1", "0"], ["on", "off"], $this->data["enable"]);
- $this->data["dhcp"] = str_replace(["1", "0"], ["on", "off"], $this->data["dhcp"]);
- $this->data["ndp"] = str_replace(["1", "0"], ["on", "off"], $this->data["ndp"]);
- $this->data["radv"] = str_replace(["1", "0"], ["on", "off"], $this->data["radv"]);
- $this->data["macfilter"] = str_replace(["1", "0"], ["on", "off"], $this->data["macfilter"]);
- $this->data["ipfilter"] = str_replace(["1", "0"], ["on", "off"], $this->data["ipfilter"]);
- }
- public function update()
- {
- $vm = \ModulesGarden\ProxmoxAddon\Core\Helper\sl('Vm')->getVm();
- $attributes = $this->formData;
- $attributes["enable"] = str_replace(["on", "off"], ["1", "0"], $attributes["enable"]);
- if(!$this->acl()->hasFirewallOption("enable")){
- unset($attributes["enable"] );
- }
- $attributes["dhcp"] = str_replace(["on", "off"], ["1", "0"], $attributes["dhcp"]);
- if(!$this->acl()->hasFirewallOption("dhcp")){
- unset($attributes["dhcp"] );
- }
- $attributes["ndp"] = str_replace(["on", "off"], ["1", "0"], $attributes["ndp"]);
- if(!$this->acl()->hasFirewallOption("ndp")){
- unset($attributes["ndp"] );
- }
- $attributes["radv"] = str_replace(["on", "off"], ["1", "0"], $attributes["radv"]);
- if(!$this->acl()->hasFirewallOption("radv")){
- unset($attributes["radv"] );
- }
- $attributes["macfilter"] = str_replace(["on", "off"], ["1", "0"], $attributes["macfilter"]);
- if(!$this->acl()->hasFirewallOption("macfilter")){
- unset($attributes["macfilter"] );
- }
- $attributes["ipfilter"] = str_replace(["on", "off"], ["1", "0"], $attributes["ipfilter"]);
- if(!$this->acl()->hasFirewallOption("ipfilter")){
- unset($attributes["ipfilter"] );
- }
- $vm->firewallOptions()->setAttributes($attributes)->update();
- return (new HtmlDataJsonResponse())
- ->setStatusSuccess()
- ->setMessageAndTranslate('The firewall options has been updated successfully')
- ->setRefreshTargetIds(["firewallOption"]);
- }
- }
|