Skip to content

Commit

Permalink
Merge pull request #9 from revers-io/develop
Browse files Browse the repository at this point in the history
Made some changes for the prestashop addons validator
  • Loading branch information
Veterini authored Sep 23, 2019
2 parents 68d7f76 + 761bf65 commit b84681c
Show file tree
Hide file tree
Showing 21 changed files with 240 additions and 142 deletions.
8 changes: 8 additions & 0 deletions controllers/admin/AdminReversIOAjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class AdminReversIOAjaxController extends ReversIOAbstractAdminController
{
public function ajaxProcessImportOrdersToReversIo()
{
if (Tools::getValue('token_bo') !== Tools::getAdminTokenLite('AdminReversIOAjaxController')) {
die();
}

$this->updateValues(
Tools::getValue('orders_status'),
Tools::getValue('orders_date_from'),
Expand Down Expand Up @@ -72,6 +76,10 @@ public function ajaxProcessImportOrdersToReversIo()

public function ajaxProcessImportOrderToReversIo()
{
if (Tools::getValue('token_bo') !== Tools::getAdminTokenLite('AdminReversIOAjaxController')) {
die();
}

/** @var \ReversIO\Services\Orders\OrderImportService $orderImportService */
/** @var \ReversIO\Repository\OrderRepository $orderRepository */
/** @var \ReversIO\Services\APIConnect\ReversIOApi $reversIoApiConnect */
Expand Down
6 changes: 1 addition & 5 deletions controllers/admin/AdminReversIOCategoryMappingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ public function initContent()

public function displayCategoryMappingWarning()
{
$this->informations['revCategoryMap'] =
$this->module->l(
'You should map as many as possible PrestaShop categories for better experience',
self::FILENAME
);
$this->informations['revCategoryMap'] = $this->l('You should map as many as possible PrestaShop categories for better experience', self::FILENAME);
}

public function postProcess()
Expand Down
54 changes: 28 additions & 26 deletions controllers/admin/AdminReversIOSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,7 @@ private function getMainSettingFields()
return [
'title' => $this->l('Main settings'),
'icon' => 'icon-cogs',
'description' => $this->l(
'Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry\'s standard dummy text ever since the
1500s, when an unknown printer took a galley of type and scrambled it to
make a type specimen book. It has survived not only five centuries, but
also the leap into electronic typesetting, remaining essentially unchanged.
It was popularised in the 1960s with the release of Letraset sheets
containing Lorem Ipsum passages, and more recently with desktop publishing
software like Aldus PageMaker including versions of Lorem Ipsum.'
),
'description' => $this->l('Revers.io is the leading solution for Returns Management in Europe. By automating and centralizing the return process, the platform optimizes the after-sales customer experience and allows merchants to save time and money.'),
'fields' => array(
Config::TEST_MODE_SETTING => array(
'title' => $this->l('Revers.io test mode'),
Expand Down Expand Up @@ -145,11 +136,7 @@ private function getOrderSettingsFields()
return [
'title' => $this->l('ORDER SETTINGS'),
'icon' => 'icon-cogs',
'description' => $this->l(
'This settings define the moment when your Customer will be able to proceed to returns.
Until then the Returns section on the Order page won\'t be visible.
Usually, sellers allow returns once the product was shipped.'
),
'description' => $this->l('This setting defines the moment when your Customer will be able to proceed to returns. Until then the Returns section on the Order page won\'t be visible. Tip: Usually, sellers allow returns once the product was shipped.'),
'fields' => array(
Config::ORDERS_STATUS => array(
'title' => $this->l('Only orders with selected statuses will be allowed for returns'),
Expand All @@ -160,7 +147,7 @@ private function getOrderSettingsFields()
'class' => 'col-lg-12'
),
Config::ORDER_DATE_FROM => array(
'title' => $this->l('Synchronise orders with Revers.io between dates'),
'title' => $this->l('Synchronize orders with Revers.io between'),
'type' => 'order_date_from_to',
),
Config::ORDERS_IMPORT_PROGRESS => array(
Expand Down Expand Up @@ -205,13 +192,12 @@ private function getLogsSettingsFields()
'class' => 'fixed-width-lg',
'cast' => 'intval',
'suffix' => 'days',
'desc' => $this->l('Input 0 to not store logs'),
'desc' => $this->l('Input 0 to store indefinitely'),
),
'REVERSIODownload' => array(
'title' => '',
'type' => '',
'desc' =>
//@todo: cia negali buti html tag'u!!!!!!!!!!!! susikurti template
'<a href="'.$this->context->link->getAdminLink(Config::CONTROLLER_EXPORT_LOGS).'">'
.$this->l('Click here to download logs').'</a>',
),
Expand All @@ -236,15 +222,29 @@ public function postProcess()
json_encode(Tools::getValue('orders_status'))
);

Configuration::updateValue(
Config::ORDER_DATE_FROM,
Tools::getValue('orders_date_from')
);
if (!Validate::isDateFormat(Tools::getValue('orders_date_from'))) {
$this->errors[] = $this->l('Date value is incorrect.');
} else {
Configuration::updateValue(
Config::ORDER_DATE_FROM,
Tools::getValue('orders_date_from')
);
}

Configuration::updateValue(
Config::ORDER_DATE_TO,
Tools::getValue('orders_date_to')
);
if (!Validate::isDateFormat(Tools::getValue('orders_date_to'))) {
$this->errors[] = $this->l('Date value is incorrect.');
} else {
Configuration::updateValue(
Config::ORDER_DATE_TO,
Tools::getValue('orders_date_to')
);
}

if (empty($this->errors)) {
$this->confirmations[] = $this->l('Succesfully updated.');
}

$this->init();
}

if (Tools::isSubmit('submitReversIoLogs')) {
Expand All @@ -256,6 +256,7 @@ public function postProcess()
Config::STORE_LOGS,
Tools::getValue('REVERS_IO_STORE_LOGS')
);
$this->confirmations[] = $this->l('Succesfully updated.');
}

$this->processPassword();
Expand Down Expand Up @@ -293,6 +294,7 @@ public function postProcess()
Tools::getValue(Config::TEST_MODE_SETTING)
);
Configuration::updateValue(Config::PUBLIC_KEY, Tools::getValue(Config::PUBLIC_KEY));
$this->confirmations[] = $this->l('The API public key was updated.');
return;
}

Expand Down
4 changes: 4 additions & 0 deletions controllers/front/Ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public function postProcess()
{
parent::postProcess();

if (!$this->isTokenValid()) {
die();
}

/** @var \ReversIO\Services\Orders\OrderImportService $orderImportService */
/** @var \ReversIO\Repository\OrderRepository $orderRepository */
/** @var \ReversIO\Services\APIConnect\ReversIOApi $reversIoApiConnect */
Expand Down
6 changes: 4 additions & 2 deletions reversio.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct()
$this->name = $this->l('reversio');
$this->version = '1.0.0';
$this->tab = 'shipping_logistics';
$this->author = 'Invertus';
$this->author = 'Revers.io';
$this->need_instance = 0;
$this->description = 'Revers.io';
$this->module_key = 'c7843c2c00feb49853bd40ff72820396';
Expand All @@ -54,7 +54,7 @@ public function __construct()
$this->displayName = $this->l('Revers.io');
$this->ps_versions_compliancy = ['min' => '1.7', 'max' => _PS_VERSION_];

$this->confirmUninstall = $this->l('Ar you sure you want to uninstall?');
$this->confirmUninstall = $this->l('Are you sure you want to uninstall?');

if (Module::isInstalled('reversio')) {
$isTestModeEnabled = (bool) Configuration::get(ReversIO\Config\Config::TEST_MODE_SETTING);
Expand Down Expand Up @@ -167,6 +167,7 @@ public function hookActionAdminControllerSetMedia()
'initialOrderImportAjaxUrl' => $this->context->link->getAdminLink(
ReversIO\Config\Config::CONTROLLER_ADMIN_AJAX
),
// 'token_bo' => Tools::getAdminTokenLite('AdminReversIOAjaxController'),
));

$this->context->controller->addJS($this->getPathUri().'views/js/admin/order-import.js');
Expand All @@ -179,6 +180,7 @@ public function hookActionFrontControllerSetMedia()
'reversio',
ReversIO\Config\Config::FO_CONTROLLER
),
'token' => Tools::getToken('token'),
));

$this->context->controller->addJS($this->getPathUri().'views/js/front/order-import-fo.js');
Expand Down
8 changes: 0 additions & 8 deletions src/Services/Product/ProductService.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@ public function getInfoAboutProduct(
$images[0]['id_image']
);

$images = $product->getImages($language);

if (!empty($images)) {
$imageUrl = Context::getContext()->link->getImageLink(
$product->link_rewrite[$language],
$images[0]['id_image']
);
}
}

$productInfoArray = [
Expand Down
Loading

0 comments on commit b84681c

Please sign in to comment.