email/controllers/View.php
public function index()
    {
        $oUri     = Factory::service('Uri');
        $oEmailer = Factory::service('Emailer', 'nails/module-email');
        $sRef     = $oUri->segment(3);
        $sGuid    = $oUri->segment(4);
        $sHash    = $oUri->segment(5);

        // --------------------------------------------------------------------------

        //  Fetch the email
        if (is_numeric($sRef)) {
            $oEmail = $oEmailer->getById($sRef);
        } else {
            $oEmail = $oEmailer->getByRef($sRef);
        }

        if (!$oEmail || !$oEmailer->validateHash($oEmail->ref, $sGuid, $sHash)) {
            show404();
        }

        if (Environment::is(Environment::ENV_DEV)) {

            $oAsset = Factory::service('Asset');
            $oAsset->load('debugger.min.css', 'nails/module-email');

            Factory::service('View')
                ->setData([
                    'oEmail' => $oEmail,
                ])
                ->load([
                    'structure/header/blank',
                    'email/view',
                    'structure/footer/blank',
                ]);

        } else {
            $oOutput = Factory::service('Output');
            $oOutput->set_output($oEmail->body->html);
        }
    }
public function index()
    {
        $oUri     = Factory::service('Uri');
        $oEmailer = Factory::service('Emailer', 'nails/module-email');
        $sRef     = $oUri->segment(3);
        $sGuid    = $oUri->segment(4);
        $sHash    = $oUri->segment(5);

        // --------------------------------------------------------------------------

        //  Fetch the email
        if (is_numeric($sRef)) {
            $oEmail = $oEmailer->getById($sRef);
        } else {
            $oEmail = $oEmailer->getByRef($sRef);
        }

        if (!$oEmail || !$oEmailer->validateHash($oEmail->ref, $sGuid, $sHash)) {
            show404();
        }

        if (Environment::is(Environment::ENV_DEV)) {

            $oAsset = Factory::service('Asset');
            $oAsset->load('debugger.min.css', 'nails/module-email');

            Factory::service('View')
                ->setData([
                    'oEmail' => $oEmail,
                ])
                ->load([
                    'structure/header/blank',
                    'email/view',
                    'structure/footer/blank',
                ]);

        } else {
            $oOutput = Factory::service('Output');
            $oOutput->set_output($oEmail->body->html);
        }
    }
public function index ( ) { $ oUri = Factory :: service ( 'Uri' ) ; $ oEmailer = Factory :: service ( 'Emailer' , 'nails/module-email' ) ; $ sRef = $ oUri -> segment ( 3 ) ; $ sGuid = $ oUri -> segment ( 4 ) ; $ sHash = $ oUri -> segment ( 5 ) ; // -------------------------------------------------------------------------- //  Fetch the email if ( is_numeric ( $ sRef ) ) { $ oEmail = $ oEmailer -> getById ( $ sRef ) ; } else { $ oEmail = $ oEmailer -> getByRef ( $ sRef ) ; } if ( ! $ oEmail || ! $ oEmailer -> validateHash ( $ oEmail -> ref , $ sGuid , $ sHash ) ) { show404 ( ) ; } if ( Environment :: is ( Environment :: ENV_DEV ) ) { $ oAsset = Factory :: service ( 'Asset' ) ; $ oAsset -> load ( 'debugger.min.css' , 'nails/module-email' ) ; Factory :: service ( 'View' ) -> setData ( [ 'oEmail' => $ oEmail , ] ) -> load ( [ 'structure/header/blank' , 'email/view' , 'structure/footer/blank' , ] ) ; } else { $ oOutput = Factory :: service ( 'Output' ) ; $ oOutput -> set_output ( $ oEmail -> body -> html ) ; } }
Handle view online requests
Handle view online requests