private function postValidation() { if (Tools::isSubmit('btnSubmit')) { $this->menuTab = Tools::getValue('menuTab'); $email = Tools::getValue('pagseguro_email'); $token = Tools::getValue('pagseguro_token'); $pagseguro_url_redirect = Tools::getValue('pagseguro_url_redirect'); $pagseguro_notification_url = Tools::getValue('pagseguro_notification_url'); $charset = Tools::getValue('pagseguro_charset'); $pagseguro_log = Tools::getValue('pagseguro_log'); /** E-mail validation */ if (!$email) { $this->errors[] = $this->errorMessage('E-MAIL'); } elseif (Tools::strlen($email) > 60) { $this->errors[] = $this->invalidFieldSizeMessage('E-MAIL'); } elseif (!Validate::isEmail($email)) { $this->errors[] = $this->invalidMailMessage('E-MAIL'); } /** Token validation */ if (!$token) { $this->errors[] = $this->errorMessage('TOKEN'); } elseif (Tools::strlen($token) != 32) { $this->errors[] = $this->invalidFieldSizeMessage('TOKEN'); } /** URL redirect validation */ if ($pagseguro_url_redirect && !filter_var($pagseguro_url_redirect, FILTER_VALIDATE_URL)) { $this->errors[] = $this->invalidUrl('URL DE REDIRECIONAMENTO'); } /** Notification url validation */ if ($pagseguro_notification_url && !filter_var($pagseguro_notification_url, FILTER_VALIDATE_URL)) { $this->errors[] = $this->invalidUrl('URL DE NOTIFICAÇÃO'); } /** Charset validation */ if (!array_key_exists($charset, Util::getCharsetOptions())) { $this->errors[] = $this->invalidValue('CHARSET'); } /** Log validation */ if (!array_key_exists($pagseguro_log, Util::getActive())) { $this->errors[] = $this->invalidValue('LOG'); } } }
private function getConfigurationPageHtml() { $this->addToView('email', Tools::safeOutput(Configuration::get('PAGSEGURO_EMAIL'))); $this->addToView('token', Tools::safeOutput(Configuration::get('PAGSEGURO_TOKEN'))); $this->addToView('notificationUrl', $this->getNotificationUrl()); $this->addToView('redirectUrl', $this->getDefaultRedirectionUrl()); $charsetOptions = Util::getCharsetOptions(); $this->addToView('charsetKeys', array_keys($charsetOptions)); $this->addToView('charsetValues', array_values($charsetOptions)); $this->addToView('charsetSelected', Configuration::get('PAGSEGURO_CHARSET')); $checkoutOptions = Util::getTypeCheckout(); $this->addToView('checkoutKeys', array_keys($checkoutOptions)); $this->addToView('checkoutValues', array_values($checkoutOptions)); $this->addToView('checkoutSelected', Configuration::get('PAGSEGURO_CHECKOUT')); $activeOptions = Util::getActive(); $this->addToView('logActiveKeys', array_keys($activeOptions)); $this->addToView('logActiveValues', array_values($activeOptions)); $this->addToView('logActiveSelected', Configuration::get('PAGSEGURO_LOG_ACTIVE')); $this->addToView('logFileLocation', Tools::safeOutput(Configuration::get('PAGSEGURO_LOG_FILELOCATION'))); $this->addToView('recoveryActiveKeys', array_keys($activeOptions)); $this->addToView('recoveryActiveValues', array_values($activeOptions)); $this->addToView('recoveryActiveSelected', Configuration::get('PAGSEGURO_RECOVERY_ACTIVE')); return $this->display(__PS_BASE_URI__ . 'modules/pagseguro', '/views/templates/admin/settings.tpl'); }