Admin_EmailController::showEmailLogAction PHP Method

showEmailLogAction() public method

Shows the email logs and returns the Json object for the dynamic params
public showEmailLogAction ( )
    public function showEmailLogAction()
    {
        if (!$this->getUser()->isAllowed("emails")) {
            throw new \Exception("Permission denied, user needs 'emails' permission.");
        }
        $type = $this->getParam('type');
        $emailLog = Tool\Email\Log::getById($this->getParam('id'));
        if ($this->getParam('type') == 'text') {
            $this->disableViewAutoRender();
            echo '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style>body{background-color:#fff;}</style></head><body><pre>' . $emailLog->getTextLog() . '</pre></body></html>';
        } elseif ($this->getParam('type') == 'html') {
            $this->disableViewAutoRender();
            echo $emailLog->getHtmlLog();
        } elseif ($this->getParam('type') == 'params') {
            $this->disableViewAutoRender();
            try {
                $params = \Zend_Json::decode($emailLog->getParams());
            } catch (\Exception $e) {
                Logger::warning("Could not decode JSON param string");
                $params = [];
            }
            foreach ($params as &$entry) {
                $this->enhanceLoggingData($entry);
            }
            $this->_helper->json($params);
        } else {
            die('No Type specified');
        }
    }