HEX
Server: Apache
System: Linux hz.vslconceptsdomains.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: dkfounda (3233)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/local/mailchannels/hooks/PostCpApiUnPark.php
<?php

namespace MailChannels;

class PostCpApiUnPark extends Hook {
    public function execute($hookData) {
        if ($this->inboundEnabled()) {
            if ($this->isSuccessfulCpanelResult($hookData)) {

                if (isset($hookData['data']['args']) && isset($hookData['data']['args']['domain'])) {

                    if ($this->inboundConfig->autoDomainDeProvisioning() && $this->inboundConfig->processParkedAndAddonDomains()) {
                        $domain = $hookData['data']['args']['domain'];
                        try {
                            $deprovisionResult = $this->inboundSmtpService->deProvisionDomain($domain);
                            if ($deprovisionResult) {
                                return array(true, "domain $domain no longer uses MailChannels");
                            } else {
                                return array(true, "no action taken; domain $domain not found");
                            }
                        } catch (\Exception $e) {
                            $errorMessage = $e->getTraceAsString();
                            return array(false, "unexpected error unparking domain $domain: $errorMessage");
                        }
                    }
                    return array(true, "action not taken; action not taken; automatic provisioning and/or parked and/or addon domain processing is not set");
                }
                return array(false, "could not find the domain in the hook data");
            }
            return array(false, "missing hook data or the api function failed");
        }
        return array(true, "action not taken; inbound not enabled");
    }

    public static function category() {
        return 'Cpanel';
    }

    public static function event() {
        return 'Api2::Park::unpark';
    }

    public static function stage() {
        return 'post';
    }
}