first commit
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
class stEservice2BackendActions extends stActions
|
||||
{
|
||||
|
||||
public function initializeParameters()
|
||||
{
|
||||
$this->config = stConfig::getInstance('stEservice2Backend');
|
||||
$this->labels = $this->getLabels();
|
||||
}
|
||||
|
||||
public function executeIndex()
|
||||
{
|
||||
if ($this->getRequest()->getMethod() == sfRequest::POST)
|
||||
{
|
||||
$modules = PaymentTypePeer::doSelectByModuleName('stEservice2');
|
||||
|
||||
if (!$modules)
|
||||
{
|
||||
$modules = PaymentTypePeer::doSelectByModuleName('stEservice');
|
||||
}
|
||||
|
||||
/**
|
||||
* @var PaymentType $module
|
||||
*/
|
||||
foreach ($modules as $module)
|
||||
{
|
||||
$module->setModuleName('stEservice2');
|
||||
$module->setIsActive($this->config->get('enabled'));
|
||||
$module->save();
|
||||
}
|
||||
|
||||
if ($this->config->get('enabled'))
|
||||
{
|
||||
$config = stConfig::getInstance('stEserviceBackend');
|
||||
$config->set('enabled', false);
|
||||
$config->save();
|
||||
}
|
||||
|
||||
$this->config->save();
|
||||
|
||||
$this->setFlash('notice', $this->getContext()->getI18n()->__('Twoje zmiany zostały zapisane', null, 'stAdminGeneratorPlugin'));
|
||||
|
||||
return $this->redirect($this->getRequest()->getReferer());
|
||||
}
|
||||
|
||||
if ($this->config->get('enabled')!=1) {
|
||||
$this->setFlash('info', '<a target="_parent" href="https://www.eservice.pl/kontakt?branza=eCommerce?utm_source=&utm_medium=Sote">'.$this->getContext()->getI18n()->__('Zarejestruj się w eService, aby utworzyć konto.').'</a>');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function validateIndex()
|
||||
{
|
||||
$this->initializeParameters();
|
||||
|
||||
if ($this->getRequest()->getMethod() == sfRequest::POST)
|
||||
{
|
||||
$i18n = $this->getContext()->getI18N();
|
||||
$this->config->setFromRequest('config');
|
||||
|
||||
$api = new stEservice2();
|
||||
|
||||
if (!$this->config->get('enabled'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach (['client_id', 'password'] as $field)
|
||||
{
|
||||
if (empty($this->config->get($field)))
|
||||
{
|
||||
$this->getRequest()->setError('config{'.$field.'}', $i18n->__('Proszę uzupełnić pole.'));
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->getRequest()->hasErrors() && !$api->validatePaymentConfiguration())
|
||||
{
|
||||
$this->getRequest()->setError('api', $i18n->__('Wystąpił błąd podczas weryfikacji danych dostępowych. Sprawdź czy podane dane są prawidłowe.'));
|
||||
}
|
||||
}
|
||||
|
||||
return !$this->getRequest()->hasErrors();
|
||||
}
|
||||
|
||||
public function handleErrorIndex()
|
||||
{
|
||||
$this->initializeParameters();
|
||||
|
||||
return sfView::SUCCESS;
|
||||
}
|
||||
|
||||
protected function getLabels()
|
||||
{
|
||||
$i18n = $this->getContext()->getI18N();
|
||||
|
||||
return array(
|
||||
'api' => 'eService',
|
||||
'config{client_id}' => $i18n->__('Identyfikator sprzedawcy'),
|
||||
'config{password}' => $i18n->__('Hasło')
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
class stEservice2BackendComponents extends sfComponents
|
||||
{
|
||||
|
||||
public function executeListMenu()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user