| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?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\BackupJob\Buttons;
- use MGProvision\Proxmox\v2\models\BackupSchedule;
- use ModulesGarden\ProxmoxAddon\App\Services\ApiService;
- use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
- use ModulesGarden\ProxmoxAddon\App\Enum\Cloud\ConfigurableOption;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\ClientArea;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\ResponseTemplates\DataJsonResponse;
- use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Buttons\ButtonSwitchAjax;
- class MailtoSwitchButton extends ButtonSwitchAjax implements ClientArea
- {
- use ProductService;
- use ApiService;
- protected $switchColumn = 'mailto';
- protected $id = 'mailtoSwitchButton';
- protected $name = 'mailtoSwitchButton';
- protected $refreshActionIds = 'backupJobDataTable';
- public function returnAjaxData()
- {
- try
- {
- $data = json_decode(base64_decode($this->getRequestValue('actionElementId')), true);
- $storage = $this->configuration()->getBackupStorage() ? $this->configuration()->getBackupStorage() : "local";
- $routing = 1;
- $maxFiles = $this->configuration()->getBackupMaxFiles();
- if($this->isWhmcsConfigOption(ConfigurableOption::BACKUPS_FILES) && $this->getWhmcsConfigOption(ConfigurableOption::BACKUPS_FILES)!="-1"){
- $maxFiles = $this->getWhmcsConfigOption(ConfigurableOption::BACKUPS_FILES);
- }else if($this->getWhmcsConfigOption(ConfigurableOption::BACKUPS_FILES)=="-1"){
- $maxFiles = null;
- }
- $backupSchedule = new BackupSchedule();
- $backupSchedule->setApi($this->api());
- $vmid = \ModulesGarden\ProxmoxAddon\Core\Helper\sl('Vm')->getVmModel()->vmid;
- $backupSchedule->setAttributes([
- "id" => $data['backupScheduleId'],
- "vmid" => $vmid,
- "storage" => $storage,
- "remove" => $routing,
- "maxfiles" => $maxFiles,
- "starttime" => $data['starttime'],
- "dow" => $data['dow'],
- "mode" => $data['mode'],
- "compress" => $data['compress'],
- "mailto" => $this->getRequestValue("value") == "on" ? $this->getWhmcsParamByKey('clientsdetails')['email'] : null,
- ]);
- $backupSchedule->update();
- }
- catch (\Exception $exc)
- {
- return (new DataJsonResponse())->setStatusError()->setMessage($exc->getMessage())->setCallBackFunction($this->callBackFunction)->addRefreshTargetId($this->refreshActionIds);
- }
- return (new DataJsonResponse())->setMessageAndTranslate('changesSaved')
- ->setCallBackFunction('pmOnBackupJobChanged');
- }
- /**
- *
- */
- protected function afterInitContent()
- {
- //Why?
- }
- }
|