| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace MGModule\DNSManager2\mgLibs\custom\manager;
- use \MGModule\DNSManager2\mgLibs\custom\reverse\ReverseDNS;
- use MGModule\DNSManager2\models\custom\globalsetting\GlobalSettingEnum;
- use \MGModule\DNSManager2\models\custom\reverse\Repository;
- use \MGModule\DNSManager2\models\custom\zone\Zone;
- class ZoneRemover
- {
- /** @var Zone */
- private $zone;
-
- /**
- *
- * @param mixed $zone nazwa zona lub model z bazy
- */
- public function __construct($zone)
- {
- if(!($zone instanceof Zone)) {
- $zone = new Zone($zone);
- }
- $this->zone = $zone;
- }
- private function removePTRs()
- {
- foreach(Repository::factory()->byZone($this->zone)->get() as $reverse)
- {
- $helper = new ReverseDNS($reverse);
- $zone = new Zone();
- $zone->name = $reverse->name;
- $zone->serverid = $reverse->serverid;
- $module = $zone->getModule();
- $helper->remove();
- if($module->zoneExists() && count($module->getRDNSRecord($reverse->ip)) <= 1 && GlobalSettingHelper::getSetting(GlobalSettingEnum::DO_NOT_REMOVE_EMPTY_PTR_ZONES) !== 'on' )
- {
- $module->terminateZone();
- }
- }
- }
-
- /**
- * Usuwanie zona oraz jego rDNS z serwera i bazy
- */
- public function remove() {
- $this->removePTRs();
- $module = $this->zone->getModule();
- if ($module->zoneExists())
- $module->terminateZone();
- $this->zone->delete();
- $clientID = explode("|", $this->zone->clientid)[0];
- // LogHelper::addSuccessLog('Remove Zone', '', $this->zone->name, $clientID);
- EmailNotificationHelper::sendClientNotification(DefaultNotifications::GENERAL_ZONE_REMOVED_NOTIFICATION, $clientID, $this->item->type, $this->item->relid, array(
- 'zone_name' => $this->zone->name,
- ));
- }
-
- /**
- * Jednolinijkowe usuwanie zona
- * @param mixed $zone nazwa zona lub model z bazy
- */
- public static function removeZone($zone) {
- $remover = new self($zone);
- $remover->remove();
- }
- }
|