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/PostAccountsModify.php
<?php


namespace MailChannels;

//For the Whostmgr modify function, we provision the domain name in this post hook
    //because in the pre hook we are not able to properly provision this domain name until the modify function executes and the
    //new main domain name is associated with the account.
//There is a chance that the new main domain has different protection than the old main domain (ex: the old domain was unprotected
    //but the new main domain is protected) since we cannot determine if the old domain was protected or not, and therefore rely on
    //the status of inboundEnabled and isAutomaticDomainProtectionEnabled for the new domain name.
class PostAccountsModify extends PostAccountsCreate {
    public function execute($hookData) {
        if ($this->inboundEnabled()) {
            if (!isset($hookData['data']) || !isset($hookData['data']['domain'])) {
                return array(true, "no domain parameter");
            }
            $newMainDomain = $hookData['data']['domain'];
            if ($this->inboundConfig->isAutomaticDomainProtectionEnabled()) {
                try {
                    list($provisionResult, $provisionMessage) = $this->inboundProvision($newMainDomain);
                } catch (\Exception $e) {
                    $errorMessage = $e->getTraceAsString();
                    return array(false, "error provisioning domain $newMainDomain: $errorMessage");
                }
                if ($provisionResult) {
                    return array(true, "successfully provisioned new main domain $newMainDomain");
                } else {
                    return array(false, "error provisioning new main domain $newMainDomain: $provisionMessage");
                }
            }
            return array(true, "provisioning action not taken; AutomaticDomainProtection not enabled");
        }
        return array(true, "provisioning action not taken; inbound not enabled");
    }

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

    public static function event() {
        return 'Accounts::Modify';
    }

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

}