diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index aff2e8a5b..348c1d7ec 100644 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -512,10 +512,6 @@ Thelia\Controller\Admin\CouponController::updateAction \d+ - - Thelia\Controller\Admin\CouponController::readAction - \d+ - Thelia\Controller\Admin\CouponController::getBackOfficeInputsAjaxAction .* @@ -549,7 +545,7 @@ - + Thelia\Controller\Admin\ConfigurationController::indexAction diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php index 6ecd418e8..695c7c868 100644 --- a/core/lib/Thelia/Controller/Admin/CouponController.php +++ b/core/lib/Thelia/Controller/Admin/CouponController.php @@ -53,58 +53,15 @@ class CouponController extends BaseAdminController */ public function browseAction() { - $this->checkAuth(AdminResources::COUPON, array(), AccessManager::VIEW); - - $args['urlReadCoupon'] = $this->getRoute( - 'admin.coupon.read', - array('couponId' => 0), - Router::ABSOLUTE_URL - ); - - $args['urlEditCoupon'] = $this->getRoute( - 'admin.coupon.update', - array('couponId' => 0), - Router::ABSOLUTE_URL - ); - - $args['urlCreateCoupon'] = $this->getRoute( - 'admin.coupon.create', - array(), - Router::ABSOLUTE_URL - ); + if (null !== $response = $this->checkAuth(AdminResources::COUPON, array(), AccessManager::VIEW)) { + return $response; + } $args['coupon_order'] = $this->getListOrderFromSession('coupon', 'coupon_order', 'code'); return $this->render('coupon-list', $args); } - /** - * Manage Coupons read display - * - * @param int $couponId Coupon Id - * - * @return \Thelia\Core\HttpFoundation\Response - */ - public function readAction($couponId) - { - $this->checkAuth(AdminResources::COUPON, array(), AccessManager::VIEW); - - $coupon = CouponQuery::create()->findPk($couponId); - - if ($coupon === null) { - return $this->pageNotFound(); - } - - $args['couponId'] = $couponId; - $args['urlEditCoupon'] = $this->getRoute( - 'admin.coupon.update', - array('couponId' => $couponId), - Router::ABSOLUTE_URL - ); - - return $this->render('coupon-read', $args); - } - /** * Manage Coupons creation display * @@ -112,9 +69,7 @@ class CouponController extends BaseAdminController */ public function createAction() { - // Check current user authorization - $response = $this->checkAuth(AdminResources::COUPON, array(), AccessManager::CREATE); - if ($response !== null) { + if (null !== $response = $this->checkAuth(AdminResources::COUPON, array(), AccessManager::CREATE)) { return $response; } @@ -165,9 +120,7 @@ class CouponController extends BaseAdminController */ public function updateAction($couponId) { - // Check current user authorization - $response = $this->checkAuth(AdminResources::COUPON, array(), AccessManager::UPDATE); - if ($response !== null) { + if (null !== $response = $this->checkAuth(AdminResources::COUPON, array(), AccessManager::UPDATE)) { return $response; } @@ -342,7 +295,9 @@ class CouponController extends BaseAdminController */ public function getConditionToUpdateInputAjaxAction($couponId, $conditionIndex) { - $this->checkAuth(AdminResources::COUPON, array(), AccessManager::VIEW); + if (null !== $response = $this->checkAuth(AdminResources::COUPON, array(), AccessManager::VIEW)) { + return $response; + } $this->checkXmlHttpRequest(); @@ -396,7 +351,9 @@ class CouponController extends BaseAdminController */ public function saveConditionsAction($couponId) { - $this->checkAuth(AdminResources::COUPON, array(), AccessManager::VIEW); + if (null !== $response = $this->checkAuth(AdminResources::COUPON, array(), AccessManager::UPDATE)) { + return $response; + } $this->checkXmlHttpRequest(); @@ -443,7 +400,9 @@ class CouponController extends BaseAdminController */ public function deleteConditionsAction($couponId, $conditionIndex) { - $this->checkAuth(AdminResources::COUPON, array(), AccessManager::VIEW); + if (null !== $response = $this->checkAuth(AdminResources::COUPON, array(), AccessManager::UPDATE)) { + return $response; + } $this->checkXmlHttpRequest(); @@ -681,7 +640,10 @@ class CouponController extends BaseAdminController */ public function getBackOfficeInputsAjaxAction($couponServiceId) { - $this->checkAuth(AdminResources::COUPON, array(), AccessManager::VIEW); + if (null !== $response = $this->checkAuth(AdminResources::COUPON, array(), AccessManager::VIEW)) { + return $response; + } + $this->checkXmlHttpRequest(); /** @var CouponInterface $coupon */ @@ -706,7 +668,10 @@ class CouponController extends BaseAdminController */ public function getBackOfficeConditionSummariesAjaxAction($couponId) { - $this->checkAuth(AdminResources::COUPON, array(), AccessManager::VIEW); + if (null !== $response = $this->checkAuth(AdminResources::COUPON, array(), AccessManager::VIEW)) { + return $response; + } + $this->checkXmlHttpRequest(); /** @var Coupon $coupon */ diff --git a/templates/backOffice/default/coupon-read.html b/templates/backOffice/default/coupon-read.html deleted file mode 100644 index 3492bd605..000000000 --- a/templates/backOffice/default/coupon-read.html +++ /dev/null @@ -1,173 +0,0 @@ -{extends file="admin-layout.tpl"} - -{block name="check-resource"}admin.coupon{/block} -{block name="check-access"}view{/block} - -{block name="page-title"}{intl l='Coupon'}{/block} - -{block name="main-content"} -
- -
- - {loop type="coupon" name="read_coupon" id={$couponId} backend_context="true"} - - -
-
-
-
- - {if !$IS_ENABLED} -
- - {intl l='This coupon is disabled, you can enable at the bottom of this form.'} -
- {/if} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{intl l='Title'}{$TITLE}
- {if $IS_ENABLED} - - {intl l="Is enabled"} - - {else} - - {intl l="Is disabled"} - - {/if} -
- {$SUMMARY} -
{intl l='Amount'}{$AMOUNT}
{intl l='Expiration date'}{$EXPIRATION_DATE} ({$DAY_LEFT_BEFORE_EXPIRATION} {intl l="days left"})
{intl l='Usage left'} - {if $USAGE_LEFT == -1} - - {intl l="Unlimited"} - - {elseif $USAGE_LEFT} - - {$USAGE_LEFT} - - {else} - - 0 - - {/if} -
- {if $IS_CUMULATIVE} - - {intl l="May be cumulative"} - - {else} - - {intl l="Can't be cumulative"} - - {/if} -
- {if $IS_REMOVING_POSTAGE} - - {intl l="Will remove postage"} - - {else} - - {intl l="Won't remove postage"} - - {/if} -
- {if $IS_AVAILABLE_ON_SPECIAL_OFFERS} - - {intl l="Will be available on special offers"} - - {else} - - {intl l="Won't be available on special offers"} - - {/if} -
{intl l='Application field'} -
    - {foreach from=$APPLICATION_CONDITIONS item=condition name=conditionsForeach} - {if !$smarty.foreach.conditionsForeach.first} -
  • {intl l='And'}
  • - {/if} -
  • {$condition nofilter}
  • - {/foreach} -
-
{$SHORT_DESCRIPTION}
{$DESCRIPTION}
- - {intl l='Edit'} - -
-
-
-
-
- {/loop} -
-
- -{include file='includes/confirmation-modal.html' id="enable" message="{intl l='Do you really want to enable this element ?'}"} - -{/block} - -{block name="javascript-initialization"} - {javascripts file='assets/js/main.js'} - - {/javascripts} - -{/block} - -{block name="javascript-last-call"} - {module_include location='coupon-read-js'} -{/block}