Merge branch 'develop' into trunk
This commit is contained in:
commit
2b7caabd38
4 changed files with 2002 additions and 39 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,7 +2,6 @@
|
|||
.env
|
||||
*.log
|
||||
uploads/
|
||||
composer.lock
|
||||
vendor/
|
||||
wp-content/passerelle/
|
||||
inco/*
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"vlucas/phpdotenv": "^5.3",
|
||||
"respect/validation": "^2.2",
|
||||
"ext-json": "*",
|
||||
"ldc/ldccrmv2client": "^2.1"
|
||||
"ldc/ldccrmv2client": "^3.0"
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"repositories": [
|
||||
|
|
|
|||
1882
composer.lock
generated
Normal file
1882
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
156
unsubscribe.php
156
unsubscribe.php
|
|
@ -1,27 +1,60 @@
|
|||
<?php
|
||||
require_once 'LDCCRM/ApiV1.php';
|
||||
|
||||
use LDC\LDCCRM\CrmApiV2;
|
||||
use LDC\LDCCRM\Enums\ApiError;
|
||||
use LDC\LDCCRM\Exceptions\ApiErrorException;
|
||||
use LDC\LDCCRM\Exceptions\CrmException;
|
||||
use LDC\LDCCRM\Models\Customer;
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
Dotenv\Dotenv::createImmutable(__DIR__)->load();
|
||||
|
||||
/* CRM */
|
||||
define('CRM_TOKEN', $_ENV['CRM_API_TOKEN']);
|
||||
define('CRM_ENDPOINT', $_ENV['CRM_ENDPOINT']);
|
||||
define('CRM_TOKEN', $_ENV['CRM_TOKEN']);
|
||||
define('CRM_PASSWORD', $_ENV['CRM_PASSWORD']);
|
||||
|
||||
$callOK = false;
|
||||
$modelNotFound = false;
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
if (!isset($_GET['hashcode']) || empty($_GET['hashcode']))
|
||||
die('Missing fields.');
|
||||
if (isset($_GET['hashcode']) and !empty($_GET['hashcode'])) {
|
||||
// * Initialise CRM API
|
||||
new CrmApiV2(CRM_ENDPOINT, CRM_TOKEN, CRM_PASSWORD);
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$hashcode = filter_var($_GET['hashcode'], FILTER_SANITIZE_STRING);
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
$hashcode = filter_var($_GET['hashcode'], FILTER_SANITIZE_STRING);
|
||||
|
||||
$apiCrm = new \LDCCRM\ApiV1(CRM_ENDPOINT, CRM_TOKEN);
|
||||
|
||||
$result = $apiCrm->removeOptInCustomer($hashcode);
|
||||
// Seul customer est géré pas single optin (pas d'envoi de news à ceux-ci)
|
||||
try {
|
||||
// ? Le customer exists ? Il est optin ?
|
||||
if (($customer = Customer::find($hashcode)) and $customer->opt_in) {
|
||||
// * Il met son optin à false
|
||||
$customer->toggleOptin();
|
||||
} else {
|
||||
$modelNotFound = true;
|
||||
}
|
||||
} catch (CrmException | ApiErrorException $e) {
|
||||
if (get_class($e) === ApiErrorException::class and $e->getApiError()->equals(ApiError::modelNotFound())) {
|
||||
$modelNotFound = true;
|
||||
} else {
|
||||
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log,Squiz.PHP.DiscouragedFunctions.Found
|
||||
error_log(sprintf(
|
||||
'ERROR CRM API : %s - %s | hashcode : %s',
|
||||
(get_class($e) === CrmException::class ? $e->getMessage() : $e->getApiError()->label),
|
||||
$e->getMessage(),
|
||||
$hashcode
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
|
|
@ -40,6 +73,7 @@ $result = $apiCrm->removeOptInCustomer($hashcode);
|
|||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Merienda';
|
||||
src: url('https://www.reghalal.com/wp-content/themes/reghalal/theme/fonts/Merienda-Bold.eot');
|
||||
|
|
@ -52,12 +86,18 @@ $result = $apiCrm->removeOptInCustomer($hashcode);
|
|||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
html, body, ::before, ::after, *{
|
||||
|
||||
html,
|
||||
body,
|
||||
::before,
|
||||
::after,
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
body{
|
||||
|
||||
body {
|
||||
background: url('https://www.reghalal.com/wp-content/themes/reghalal/theme/img/prod-slider-background.jpg') center center no-repeat;
|
||||
background-size: cover;
|
||||
background-color: #f5ecde;
|
||||
|
|
@ -65,61 +105,98 @@ $result = $apiCrm->removeOptInCustomer($hashcode);
|
|||
font-size: 30px;
|
||||
font-weight: normal;
|
||||
color: #000000;
|
||||
}
|
||||
.post-title{
|
||||
}
|
||||
|
||||
.post-title {
|
||||
font-family: 'Merienda', Arial, Helvetica, sans-serif;
|
||||
font-size: 1.33em;
|
||||
font-weight: 700;
|
||||
color: #e30613;
|
||||
}
|
||||
a{
|
||||
|
||||
a {
|
||||
color: #000000;
|
||||
transition: color .5s;
|
||||
}
|
||||
a:hover{color: #e30613;}
|
||||
p{
|
||||
|
||||
a:hover {
|
||||
color: #e30613;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 1em 0;
|
||||
font-size: .8em;
|
||||
}
|
||||
span{font-size: .6em;}
|
||||
.wrapper-unsub{
|
||||
|
||||
span {
|
||||
font-size: .6em;
|
||||
}
|
||||
|
||||
.wrapper-unsub {
|
||||
display: grid;
|
||||
grid-template-rows: min-content min-content auto min-content;
|
||||
justify-items: center;
|
||||
min-height: 100vh;
|
||||
padding: 10vw 4vw;
|
||||
}
|
||||
.unsub--logo{
|
||||
|
||||
.unsub--logo {
|
||||
width: 60%;
|
||||
text-align: center;
|
||||
}
|
||||
.unsub--logo img{
|
||||
|
||||
.unsub--logo img {
|
||||
width: 100%;
|
||||
max-width: 300px;
|
||||
}
|
||||
.unsub--title{
|
||||
|
||||
.unsub--title {
|
||||
margin: 4vw 0;
|
||||
text-align: center;
|
||||
}
|
||||
.unsub--footer{width: 100%;}
|
||||
|
||||
.unsub--footer {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@media only screen and (min-width:768px) {
|
||||
.post-title{font-size: 2em;}
|
||||
p{font-size: 1em;}
|
||||
span{font-size: .8em;}
|
||||
.wrapper-unsub{padding: 4vw 10vw;}
|
||||
.post-title {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
.wrapper-unsub {
|
||||
padding: 4vw 10vw;
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (min-width:1024px) {
|
||||
.post-title{font-size: 2.33em;}
|
||||
p{font-size: 1.2em;}
|
||||
span{font-size: 1em;}
|
||||
}
|
||||
@media only screen and (min-width:1440px) {
|
||||
}
|
||||
@media only screen and (min-width:1920px) {
|
||||
.post-title {
|
||||
font-size: 2.33em;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (min-width:1440px) {}
|
||||
|
||||
@media only screen and (min-width:1920px) {}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="wrapper-unsub">
|
||||
<div class="unsub--logo">
|
||||
|
|
@ -129,14 +206,18 @@ $result = $apiCrm->removeOptInCustomer($hashcode);
|
|||
<h1 class="post-title">Désinscription</h1>
|
||||
</div>
|
||||
|
||||
<?php if ($result->status === "OK"){ ?>
|
||||
<?php
|
||||
/**
|
||||
* On ne communique pas sur model not found
|
||||
* pour ne pas créer une page où on peut determiner
|
||||
* qui est inscrit dans la crm
|
||||
*/
|
||||
if ($callOK or $modelNotFound) { ?>
|
||||
<div class="unsub--content">
|
||||
<p>Vous êtes désinscris de la newsletter Réghalal.</p>
|
||||
<p>En espérant vous revoir bientôt !</p>
|
||||
</div>
|
||||
<?php } else {
|
||||
error_log("ERROR CRM API : $result->code - $result->message | hashcode : $hashcode");
|
||||
?>
|
||||
<?php } else { ?>
|
||||
<div class="unsub--content">
|
||||
<p>Une erreur est survenue.</p>
|
||||
<p>Veuillez réessayer ultérieurement.</p>
|
||||
|
|
@ -148,4 +229,5 @@ $result = $apiCrm->removeOptInCustomer($hashcode);
|
|||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue