-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 61bb553
Showing
38 changed files
with
4,162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
/*************************************************************************************/ | ||
/* This file is part of the Thelia package. */ | ||
/* */ | ||
/* Copyright (c) OpenStudio */ | ||
/* email : [email protected] */ | ||
/* web : http://www.thelia.net */ | ||
/* */ | ||
/* For the full copyright and license information, please view the LICENSE.txt */ | ||
/* file that was distributed with this source code. */ | ||
/*************************************************************************************/ | ||
|
||
namespace PaniersAbandonnes\Command; | ||
|
||
use PaniersAbandonnes\Events\PaniersAbandonnesEvent; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\HttpFoundation\RequestStack; | ||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; | ||
use Thelia\Command\ContainerAwareCommand; | ||
use Thelia\Core\Event\DefaultActionEvent; | ||
use Thelia\Core\HttpFoundation\Request; | ||
use Thelia\Core\HttpFoundation\Session\Session; | ||
|
||
class ExaminerPaniers extends ContainerAwareCommand | ||
{ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName("examiner-paniers-abandonnes") | ||
->setDescription("Examine les paniers abandonnes en evoie les mails de rappel si nécessaire.") | ||
; | ||
} | ||
|
||
protected function init() | ||
{ | ||
$container = $this->getContainer(); | ||
|
||
$request = new Request(); | ||
$request->setSession(new Session(new MockArraySessionStorage())); | ||
|
||
/** @var RequestStack $requestStack */ | ||
$requestStack = $container->get('request_stack'); | ||
$requestStack->push($request); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$this->init(); | ||
|
||
try { | ||
$this->getDispatcher()->dispatch(PaniersAbandonnesEvent::EXAMINER_PANIERS_EVENT, new DefaultActionEvent()); | ||
|
||
} catch (\Exception $ex) { | ||
$output->writeln( | ||
"<error>".$ex->getMessage()."</error>" | ||
); | ||
$output->writeln( | ||
"<error>".$ex->getTraceAsString()."</error>" | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
|
||
<config xmlns="http://thelia.net/schema/dic/config" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd"> | ||
|
||
<forms> | ||
<form name="paniersabandonnes.configuration.form" class="PaniersAbandonnes\Form\ConfigurationForm" /> | ||
</forms> | ||
|
||
<loops> | ||
<loop name="panierabandonne.cartinfo" class="PaniersAbandonnes\Loop\CartInfo" /> | ||
<loop name="panierabandonne.cartitem" class="PaniersAbandonnes\Loop\Cart" /> | ||
</loops> | ||
|
||
<commands> | ||
<command class="PaniersAbandonnes\Command\ExaminerPaniers" /> | ||
</commands> | ||
|
||
<services> | ||
<service id="paniersabandonnes.listener" class="PaniersAbandonnes\EventListeners\ListenerManager"> | ||
<argument type="service" id="thelia.securityContext"/> | ||
<argument type="service" id="request_stack"/> | ||
<argument type="service" id="mailer"/> | ||
<tag name="kernel.event_subscriber"/> | ||
</service> | ||
</services> | ||
|
||
<hooks> | ||
<hook id="paniersabandonnes.hook.module_configuration" class="PaniersAbandonnes\Hook\HookManager"> | ||
<tag name="hook.event_listener" event="module.configuration" type="back" method="onModuleConfigure" /> | ||
</hook> | ||
</hooks> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module xmlns="http://thelia.net/schema/dic/module" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://thelia.net/schema/dic/module http://thelia.net/schema/dic/module/module-2_2.xsd"> | ||
<fullnamespace>PaniersAbandonnes\PaniersAbandonnes</fullnamespace> | ||
<descriptive locale="en_US"> | ||
<title>Abandonned carts management</title> | ||
</descriptive> | ||
<descriptive locale="fr_FR"> | ||
<title>Génération des paniers abandonnés</title> | ||
</descriptive> | ||
<languages> | ||
<language>en_US</language> | ||
<language>fr_FR</language> | ||
</languages> | ||
<version>0.9.0</version> | ||
<authors> | ||
<author> | ||
<name>Franck Allimant</name> | ||
<company>CQFDev</company> | ||
<email>[email protected]</email> | ||
<website>www.cqfdev.fr</website> | ||
</author> | ||
</authors> | ||
<type>classic</type> | ||
<thelia>2.3.0</thelia> | ||
<stability>prod</stability> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
|
||
<routes xmlns="http://symfony.com/schema/routing" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> | ||
|
||
|
||
<route id="paniersabandonnes.admin.configure" path="/admin/module/PaniersAbandonnes/configure" methods="post"> | ||
<default key="_controller">PaniersAbandonnes\Controller\ConfigurationController::configure</default> | ||
</route> | ||
|
||
<route id="paniersabandonnes.cart" path="/back-to-cart/{token}" methods="get"> | ||
<default key="_controller">PaniersAbandonnes\Controller\BackToCart::loadCart</default> | ||
</route> | ||
|
||
<route id="paniersabandonnes.cron" path="/PaniersAbandonnes/cron"> | ||
<default key="_controller">PaniersAbandonnes\Controller\ExaminerPaniers::examiner</default> | ||
</route> | ||
</routes> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<database defaultIdMethod="native" name="thelia" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="../../../core/vendor/propel/propel/resources/xsd/database.xsd" > | ||
|
||
<table name="panier_abandonne" namespace="PaniersAbandonnes\Model"> | ||
<column name="id" type="INTEGER" primaryKey="true" required="true" autoIncrement="true" /> | ||
<column name="cart_id" required="true" type="INTEGER" /> | ||
<column name="email_client" size="255" type="VARCHAR" /> | ||
<column name="locale" size="5" type="VARCHAR" /> | ||
<column name="etat_rappel" size="1" type="INTEGER" defaultValue="0" /> | ||
<column name="login_token" size="255" type="VARCHAR" /> | ||
<column name="last_update" type="TIMESTAMP"/> | ||
|
||
<foreign-key foreignTable="cart" name="fk_panier_abandonne_cart_id" onDelete="CASCADE" onUpdate="RESTRICT"> | ||
<reference foreign="id" local="cart_id" /> | ||
</foreign-key> | ||
</table> | ||
|
||
<external-schema filename="local/config/schema.xml" referenceOnly="true" /> | ||
</database> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Sqlfile -> Database map | ||
thelia.sql=thelia |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
# This is a fix for InnoDB in MySQL >= 4.1.x | ||
# It "suspends judgement" for fkey relationships until are tables are set. | ||
SET FOREIGN_KEY_CHECKS = 0; | ||
|
||
-- --------------------------------------------------------------------- | ||
-- panier_abandonne | ||
-- --------------------------------------------------------------------- | ||
|
||
DROP TABLE IF EXISTS `panier_abandonne`; | ||
|
||
CREATE TABLE `panier_abandonne` | ||
( | ||
`id` INTEGER NOT NULL AUTO_INCREMENT, | ||
`cart_id` INTEGER NOT NULL, | ||
`email_client` VARCHAR(255), | ||
`locale` VARCHAR(5), | ||
`etat_rappel` INTEGER(1) DEFAULT 0, | ||
`login_token` VARCHAR(255), | ||
`last_update` DATETIME, | ||
PRIMARY KEY (`id`), | ||
INDEX `FI_panier_abandonne_cart_id` (`cart_id`), | ||
CONSTRAINT `fk_panier_abandonne_cart_id` | ||
FOREIGN KEY (`cart_id`) | ||
REFERENCES `cart` (`id`) | ||
ON UPDATE RESTRICT | ||
ON DELETE CASCADE | ||
) ENGINE=InnoDB; | ||
|
||
# This restores the fkey checks, after having unset them earlier | ||
SET FOREIGN_KEY_CHECKS = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
/*************************************************************************************/ | ||
/* Copyright (c) Franck Allimant, CQFDev */ | ||
/* email : [email protected] */ | ||
/* web : http://www.cqfdev.fr */ | ||
/* */ | ||
/* For the full copyright and license information, please view the LICENSE */ | ||
/* file that was distributed with this source code. */ | ||
/*************************************************************************************/ | ||
|
||
/** | ||
* Created by Franck Allimant, CQFDev <[email protected]> | ||
* Date: 14/05/2017 11:31 | ||
*/ | ||
|
||
namespace PaniersAbandonnes\Controller; | ||
|
||
use PaniersAbandonnes\Model\PanierAbandonneQuery; | ||
use Thelia\Controller\Front\BaseFrontController; | ||
use Thelia\Core\Event\Customer\CustomerLoginEvent; | ||
use Thelia\Core\Event\TheliaEvents; | ||
use Thelia\Model\CustomerQuery; | ||
use Thelia\Tools\URL; | ||
|
||
class BackToCart extends BaseFrontController | ||
{ | ||
public function loadCart($token) | ||
{ | ||
if (null !== $pa = PanierAbandonneQuery::create()->findOneByLoginToken($token)) { | ||
// Un client ? Le connecter. | ||
if (null !== $customer = CustomerQuery::create()->findOneByEmail($pa->getEmailClient())) { | ||
$this->dispatch(TheliaEvents::CUSTOMER_LOGIN, new CustomerLoginEvent($customer)); | ||
} | ||
|
||
// Restaurer le cart | ||
$this->getSession()->setSessionCart($pa->getCart()); | ||
|
||
// Afficher la page cart. | ||
return $this->generateRedirect(URL::getInstance()->absoluteUrl('/cart')); | ||
} | ||
|
||
return $this->generateRedirect(URL::getInstance()->getBaseUrl()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
/*************************************************************************************/ | ||
/* */ | ||
/* Thelia 2 PortLocalAvecFranco payment module */ | ||
/* */ | ||
/* Copyright (c) CQFDev */ | ||
/* email : [email protected] */ | ||
/* web : http://www.cqfdev.fr */ | ||
/* */ | ||
/*************************************************************************************/ | ||
|
||
namespace PaniersAbandonnes\Controller; | ||
|
||
use PaniersAbandonnes\PaniersAbandonnes; | ||
use Thelia\Controller\Admin\BaseAdminController; | ||
use Thelia\Core\Security\AccessManager; | ||
use Thelia\Core\Security\Resource\AdminResources; | ||
use Thelia\Form\Exception\FormValidationException; | ||
use Thelia\Tools\URL; | ||
|
||
class ConfigurationController extends BaseAdminController | ||
{ | ||
public function configure() | ||
{ | ||
if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'PaniersAbandonnes', AccessManager::UPDATE)) { | ||
return $response; | ||
} | ||
|
||
$configurationForm = $this->createForm('paniersabandonnes.configuration.form'); | ||
|
||
try { | ||
$form = $this->validateForm($configurationForm, "POST"); | ||
|
||
// Get the form field values | ||
$data = $form->getData(); | ||
|
||
foreach ($data as $name => $value) { | ||
if (is_array($value)) { | ||
$value = implode(';', $value); | ||
} | ||
|
||
PaniersAbandonnes::setConfigValue($name, $value); | ||
} | ||
|
||
$this->adminLogAppend( | ||
"paniersabandonnes.configuration.message", | ||
AccessManager::UPDATE, | ||
sprintf("PaniersAbandonnes configuration updated") | ||
); | ||
|
||
if ($this->getRequest()->get('save_mode') == 'stay') { | ||
// If we have to stay on the same page, redisplay the configuration page/ | ||
$url = '/admin/module/PaniersAbandonnes'; | ||
} else { | ||
// If we have to close the page, go back to the module back-office page. | ||
$url = '/admin/modules'; | ||
} | ||
|
||
return $this->generateRedirect(URL::getInstance()->absoluteUrl($url)); | ||
} catch (FormValidationException $ex) { | ||
$error_msg = $this->createStandardFormValidationErrorMessage($ex); | ||
} catch (\Exception $ex) { | ||
$error_msg = $ex->getMessage(); | ||
} | ||
|
||
$this->setupFormErrorContext( | ||
$this->getTranslator()->trans("PaniersAbandonnes configuration", [], PaniersAbandonnes::DOMAIN_NAME), | ||
$error_msg, | ||
$configurationForm, | ||
$ex | ||
); | ||
|
||
return $this->generateRedirect(URL::getInstance()->absoluteUrl('/admin/module/PaniersAbandonnes')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/*************************************************************************************/ | ||
/* Copyright (c) Franck Allimant, CQFDev */ | ||
/* email : [email protected] */ | ||
/* web : http://www.cqfdev.fr */ | ||
/* */ | ||
/* For the full copyright and license information, please view the LICENSE */ | ||
/* file that was distributed with this source code. */ | ||
/*************************************************************************************/ | ||
|
||
/** | ||
* Created by Franck Allimant, CQFDev <[email protected]> | ||
* Date: 14/05/2017 11:31 | ||
*/ | ||
namespace PaniersAbandonnes\Controller; | ||
|
||
use PaniersAbandonnes\Events\PaniersAbandonnesEvent; | ||
use Thelia\Controller\Front\BaseFrontController; | ||
use Thelia\Core\Event\DefaultActionEvent; | ||
use Thelia\Core\HttpFoundation\Response; | ||
use Thelia\Log\Tlog; | ||
|
||
class ExaminerPaniers extends BaseFrontController | ||
{ | ||
public function examiner() | ||
{ | ||
try { | ||
$this->getDispatcher()->dispatch( | ||
PaniersAbandonnesEvent::EXAMINER_PANIERS_EVENT, | ||
new DefaultActionEvent() | ||
); | ||
|
||
} catch (\Exception $ex) { | ||
Tlog::getInstance()->error("Echec de l'examen des paniers abandonnés :" . $ex->getMessage()); | ||
Tlog::getInstance()->error($ex); | ||
|
||
throw $ex; | ||
} | ||
|
||
return new Response("Examen des paniers abandonnés terminé."); | ||
} | ||
} |
Oops, something went wrong.