Merge branch 'master' into tax
Conflicts: core/lib/Thelia/Config/Resources/action.xml core/lib/Thelia/Controller/Admin/AddressController.php core/lib/Thelia/Controller/Admin/CustomerController.php core/lib/Thelia/Controller/Admin/ModuleController.php
This commit is contained in:
@@ -25,14 +25,12 @@ namespace Thelia\Controller\Admin;
|
||||
use Thelia\Core\Event\Address\AddressCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\Address\AddressEvent;
|
||||
use Thelia\Core\Event\AdminResources;
|
||||
use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\AddressCreateForm;
|
||||
use Thelia\Form\AddressUpdateForm;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\CustomerQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Class AddressController
|
||||
* @package Thelia\Controller\Admin
|
||||
@@ -79,7 +77,7 @@ class AddressController extends AbstractCrudController
|
||||
$this->dispatch(TheliaEvents::ADDRESS_DEFAULT, $addressEvent);
|
||||
|
||||
$this->adminLogAppend(sprintf("address %d for customer %d removal", $address_id, $address->getCustomerId()));
|
||||
} catch(\Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
\Thelia\Log\Tlog::getInstance()->error(sprintf("error during address removal with message %s", $e->getMessage()));
|
||||
}
|
||||
|
||||
@@ -177,8 +175,6 @@ class AddressController extends AbstractCrudController
|
||||
$formData["is_default"]
|
||||
);
|
||||
|
||||
|
||||
|
||||
return $event;
|
||||
|
||||
}
|
||||
@@ -280,8 +276,8 @@ class AddressController extends AbstractCrudController
|
||||
/**
|
||||
* Put in this method post object delete processing if required.
|
||||
*
|
||||
* @param \Thelia\Core\Event\AddressEvent $deleteEvent the delete event
|
||||
* @return Response a response, or null to continue normal processing
|
||||
* @param \Thelia\Core\Event\AddressEvent $deleteEvent the delete event
|
||||
* @return Response a response, or null to continue normal processing
|
||||
*/
|
||||
protected function performAdditionalDeleteAction($deleteEvent)
|
||||
{
|
||||
@@ -292,8 +288,8 @@ class AddressController extends AbstractCrudController
|
||||
/**
|
||||
* Put in this method post object creation processing if required.
|
||||
*
|
||||
* @param AddressCreateOrUpdateEvent $createEvent the create event
|
||||
* @return Response a response, or null to continue normal processing
|
||||
* @param AddressCreateOrUpdateEvent $createEvent the create event
|
||||
* @return Response a response, or null to continue normal processing
|
||||
*/
|
||||
protected function performAdditionalCreateAction($createEvent)
|
||||
{
|
||||
@@ -304,4 +300,4 @@ class AddressController extends AbstractCrudController
|
||||
{
|
||||
$this->redirectToEditionTemplate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,8 +378,8 @@ class BaseAdminController extends BaseController
|
||||
* Render the given template, and returns the result as a string.
|
||||
*
|
||||
* @param $templateName the complete template name, with extension
|
||||
* @param array $args the template arguments
|
||||
* @param null $templateDir
|
||||
* @param array $args the template arguments
|
||||
* @param null $templateDir
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
|
||||
@@ -244,7 +244,7 @@ class CountryController extends AbstractCrudController
|
||||
try {
|
||||
$this->dispatch(TheliaEvents::COUNTRY_TOGGLE_DEFAULT, $toogleDefaultEvent);
|
||||
|
||||
if($toogleDefaultEvent->hasCountry()) {
|
||||
if ($toogleDefaultEvent->hasCountry()) {
|
||||
return $this->nullResponse();
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Symfony\Component\Form\Form;
|
||||
use Thelia\Core\Event\Address\AddressEvent;
|
||||
use Thelia\Core\Event\AdminResources;
|
||||
use Thelia\Core\Event\Customer\CustomerAddressEvent;
|
||||
use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent;
|
||||
@@ -33,7 +31,6 @@ use Thelia\Core\Event\Customer\CustomerEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\CustomerModification;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\CustomerQuery;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
@@ -58,8 +55,6 @@ class CustomerController extends BaseAdminController
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* update customer action
|
||||
*
|
||||
|
||||
@@ -25,6 +25,11 @@ namespace Thelia\Controller\Admin;
|
||||
|
||||
use Thelia\Core\Event\AdminResources;
|
||||
|
||||
use Thelia\Core\Event\Module\ModuleDeleteEvent;
|
||||
use Thelia\Core\Event\Module\ModuleToggleActivationEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Module\ModuleManagement;
|
||||
|
||||
/**
|
||||
* Class ModuleController
|
||||
* @package Thelia\Controller\Admin
|
||||
@@ -35,7 +40,11 @@ class ModuleController extends BaseAdminController
|
||||
public function indexAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::MODULE_VIEW)) return $response;
|
||||
return $this->render("modules", array("display_module" => 20));
|
||||
|
||||
$modulemanagement = new ModuleManagement();
|
||||
$modulemanagement->updateModules();
|
||||
|
||||
return $this->render("modules");
|
||||
}
|
||||
|
||||
public function updateAction($module_id)
|
||||
@@ -44,4 +53,68 @@ class ModuleController extends BaseAdminController
|
||||
"module_id" => $module_id
|
||||
));
|
||||
}
|
||||
|
||||
public function toggleActivationAction($module_id)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.module.update")) return $response;
|
||||
$message = null;
|
||||
try {
|
||||
$event = new ModuleToggleActivationEvent($module_id);
|
||||
$this->dispatch(TheliaEvents::MODULE_TOGGLE_ACTIVATION, $event);
|
||||
|
||||
if (null === $event->getModule()) {
|
||||
throw new \LogicException(
|
||||
$this->getTranslator()->trans("No %obj was updated.", array('%obj' => 'Module')));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
}
|
||||
|
||||
if ($this->getRequest()->isXmlHttpRequest()) {
|
||||
if ($message) {
|
||||
$response = $this->jsonResponse(json_encode(array(
|
||||
"error" => $message
|
||||
)), 500);
|
||||
} else {
|
||||
$response = $this->nullResponse();
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->redirectToRoute('admin.module');
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth("admin.module.delete")) return $response;
|
||||
|
||||
$message = null;
|
||||
try {
|
||||
|
||||
$module_id = $this->getRequest()->get('module_id');
|
||||
|
||||
$deleteEvent = new ModuleDeleteEvent($module_id);
|
||||
|
||||
$this->dispatch(TheliaEvents::MODULE_DELETE, $deleteEvent);
|
||||
|
||||
if($deleteEvent->hasModule() === false) {
|
||||
throw new \LogicException(
|
||||
$this->getTranslator()->trans("No %obj was updated.", array('%obj' => 'Module')));
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Thelia\Log\Tlog::getInstance()->error(sprintf("error during module removal : %s", $message));
|
||||
$message = $e->getMessage();
|
||||
}
|
||||
|
||||
if($message) {
|
||||
return $this->render("modules", array(
|
||||
"error_message" => $message
|
||||
));
|
||||
} else {
|
||||
$this->redirectToRoute('admin.module');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,7 +212,6 @@ class OrderController extends BaseAdminController
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::ORDER_UPDATE)) return $response;
|
||||
|
||||
|
||||
$html = $this->renderRaw(
|
||||
$fileName,
|
||||
array(
|
||||
@@ -228,7 +227,7 @@ class OrderController extends BaseAdminController
|
||||
|
||||
$this->dispatch(TheliaEvents::GENERATE_PDF, $pdfEvent);
|
||||
|
||||
if($pdfEvent->hasPdf()) {
|
||||
if ($pdfEvent->hasPdf()) {
|
||||
return Response::create($pdfEvent->getPdf(), 200,
|
||||
array(
|
||||
'Content-type' => "application/pdf",
|
||||
|
||||
@@ -141,5 +141,4 @@ class ShippingZoneController extends BaseAdminController
|
||||
return $this->getRequest()->get('shipping_zone_id', 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -200,8 +200,8 @@ class TaxRuleController extends AbstractCrudController
|
||||
/**
|
||||
* Put in this method post object creation processing if required.
|
||||
*
|
||||
* @param TaxRuleEvent $createEvent the create event
|
||||
* @return Response a response, or null to continue normal processing
|
||||
* @param TaxRuleEvent $createEvent the create event
|
||||
* @return Response a response, or null to continue normal processing
|
||||
*/
|
||||
protected function performAdditionalCreateAction($createEvent)
|
||||
{
|
||||
@@ -302,4 +302,4 @@ class TaxRuleController extends AbstractCrudController
|
||||
// At this point, the form has errors, and should be redisplayed.
|
||||
return $this->renderEditionTemplate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class BaseController extends ContainerAware
|
||||
/**
|
||||
* Return an empty response (after an ajax request, for example)
|
||||
*/
|
||||
protected function nullResponse($status = 200)
|
||||
protected function nullResponse($content = null, $status = 200)
|
||||
{
|
||||
return new Response(null, $status);
|
||||
}
|
||||
@@ -66,9 +66,9 @@ class BaseController extends ContainerAware
|
||||
/**
|
||||
* Return a JSON response
|
||||
*/
|
||||
protected function jsonResponse($json_data)
|
||||
protected function jsonResponse($json_data, $status = 200)
|
||||
{
|
||||
return new Response($json_data, 200, array('content-type' => 'application/json'));
|
||||
return new Response($json_data, $status, array('content-type' => 'application/json'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user