Commit 3cf5dc09 by Julien Jorry

Fix bug on password erratic changed + php cs fixer on files

parent 8b9d66b1
......@@ -208,7 +208,7 @@ class AdherentAdmin extends AbstractAdmin
$password = rtrim(strtr(base64_encode($bytes), '+/', '-_'), '=');
$adherent->getUser()->setPassword($password);
}
$this->userManager->updateUser($adherent->getUser());
$this->userManager->updateCanonicalFields($adherent->getUser());
$adherent->getUser()->createEmailToken();
$account = $em->getRepository(AccountAdherent::class)->findOneBy(['adherent' => $adherent, 'currency' => CurrencyEnum::CURRENCY_EMLC]);
if (null == $account) {
......@@ -257,12 +257,12 @@ class AdherentAdmin extends AbstractAdmin
'advanced_filter' => false,
])
->add('createdAt', 'doctrine_orm_datetime_range', [
'field_type'=> DateTimeRangePickerType::class,
'label' => 'Date de création'
'field_type' => DateTimeRangePickerType::class,
'label' => 'Date de création',
])
->add('updatedAt', 'doctrine_orm_datetime_range', [
'field_type'=> DateTimeRangePickerType::class,
'label' => 'Date de mise à jour'
'field_type' => DateTimeRangePickerType::class,
'label' => 'Date de mise à jour',
])
;
}
......@@ -453,7 +453,7 @@ class AdherentAdmin extends AbstractAdmin
$datagrid->buildPager();
$query = $datagrid->getQuery();
$query->select('DISTINCT '.current($query->getRootAliases()));
$query->select('DISTINCT ' . current($query->getRootAliases()));
$query->setFirstResult($firstResult);
$query->setMaxResults($maxResult);
......
......@@ -433,7 +433,7 @@ class PrestataireAdmin extends AbstractAdmin
}
}
$user->addPossiblegroup($groupePresta);
$this->userManager->updateUser($user);
$this->userManager->updateCanonicalFields($user);
$em->persist($user);
if ($newUser) {
$this->eventDispatcher->dispatch(MLCEvents::REGISTRATION_ADHERENT, new UserEvent($user, $this->getRequest()));
......
......@@ -25,12 +25,10 @@ use App\Enum\MoyenEnum;
use App\Events\MLCEvents;
use App\Form\Type\ImportFormType;
use App\Utils\CustomEntityManager;
use App\Utils\OperationFactory;
use App\Utils\OperationUtils;
use Behat\Transliterator\Transliterator;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use FOS\UserBundle\Event\UserEvent;
use FOS\UserBundle\Model\UserManagerInterface;
use FOS\UserBundle\Util\TokenGeneratorInterface;
......@@ -137,7 +135,7 @@ class ImportController extends CRUDController
// $this->em->getConnection()->rollBack(); // Rollback all previous commit !
$this->addFlash(
'error',
"Il y a eu une erreur lors de l'import : ".$e->getMessage()
"Il y a eu une erreur lors de l'import : " . $e->getMessage()
);
}
......@@ -191,6 +189,7 @@ class ImportController extends CRUDController
return $result;
}
/**
* Open and parse .CSV file.
*
......@@ -838,13 +837,13 @@ class ImportController extends CRUDController
if (!empty($adherent->getId())) {
if (1 == count($cotisationDetailsArray)) {
$cotisationFound = $this->em->getRepository(CotisationAdherent::class)->isCotisationAdherentExist($adherent, intval($cotisationDetails), date("Y"));
$cotisationFound = $this->em->getRepository(CotisationAdherent::class)->isCotisationAdherentExist($adherent, intval($cotisationDetails), date('Y'));
} else {
$cotisationFound = $this->em->getRepository(CotisationAdherent::class)->isCotisationAdherentExist($adherent, intval($cotisationDetailsArray[0]), $cotisationDetailsArray[1]);
}
}
if (!empty($cotisationFound)) {
$this->addWarning($row, $line, 'cotisation', $this->translator->trans("Cotisation déjà trouvée pour l'année ") . (1 == count($cotisationDetailsArray)) ? date("Y") : $cotisationDetailsArray[1]);
$this->addWarning($row, $line, 'cotisation', $this->translator->trans("Cotisation déjà trouvée pour l'année ") . (1 == count($cotisationDetailsArray)) ? date('Y') : $cotisationDetailsArray[1]);
unset($cotisationFound);
} else {
$cotisation = new CotisationAdherent();
......@@ -859,7 +858,7 @@ class ImportController extends CRUDController
$cotisation->setMoyen(MoyenEnum::MOYEN_AUTRE);
if (1 == count($cotisationDetailsArray)) {
$cotisation->setMontant(intval($cotisationDetails));
$cotisation->getCotisationInfos()->setAnnee(date("Y"));
$cotisation->getCotisationInfos()->setAnnee(date('Y'));
$cotisation->getCotisationInfos()->setDebut($now);
$cotisation->getCotisationInfos()->setFin(new DateTime('+ 1 year'));
} else {
......@@ -910,7 +909,6 @@ class ImportController extends CRUDController
++$this->nbsuccess;
$user->setPasswordRequestedAt(new \DateTime());
if (!$this->test) {
$this->userManager->updateUser($user, false);
if ($this->sendemail) {
$this->eventDispatcher->dispatch(MLCEvents::REGISTRATION_ADHERENT, new UserEvent($user, $this->getRequest()));
}
......@@ -1002,15 +1000,15 @@ class ImportController extends CRUDController
continue;
}
$exp = $this->getEntityFromData($exp_type, $exp_id, $exp_name);
if ($exp === null) {
if (null === $exp) {
$this->addError($row, $line, 'exp', $this->translator->trans("L'expediteur est introuvable !"));
++$this->nberrors;
++$line;
continue;
}
$dest = $this->getEntityFromData($dest_type, $dest_id, $dest_name);
if ($dest === null) {
$this->addError($row, $line, 'dest', $this->translator->trans("Le destinataire est introuvable !"));
if (null === $dest) {
$this->addError($row, $line, 'dest', $this->translator->trans('Le destinataire est introuvable !'));
++$this->nberrors;
++$line;
continue;
......@@ -1039,14 +1037,14 @@ class ImportController extends CRUDController
}
$typeFlux = $row['type'];
if (!in_array($typeFlux, FluxEnum::getAvailableTypes())) {
$this->addError($row, $line, 'type', $this->translator->trans("Le type de flux est invalide (types attendus : ".implode(', ', FluxEnum::getAvailableTypes()).") !"));
$this->addError($row, $line, 'type', $this->translator->trans('Le type de flux est invalide (types attendus : ' . implode(', ', FluxEnum::getAvailableTypes()) . ') !'));
++$this->nberrors;
++$line;
continue;
}
$moyen = $row['moyen'];
if (!in_array($moyen, MoyenEnum::getAvailableTypes())) {
$this->addError($row, $line, 'moyen', $this->translator->trans("Le moyen est invalide (moyens attendus : ".implode(', ', MoyenEnum::getAvailableTypes()).") !"));
$this->addError($row, $line, 'moyen', $this->translator->trans('Le moyen est invalide (moyens attendus : ' . implode(', ', MoyenEnum::getAvailableTypes()) . ') !'));
++$this->nberrors;
++$line;
continue;
......@@ -1092,7 +1090,7 @@ class ImportController extends CRUDController
$this->em->flush();
}
} catch (Exception $e) {
$this->addError($row, $line, 'all', $this->translator->trans("L'enregistrement du flux a posé problème ! ".$e->getMessage()));
$this->addError($row, $line, 'all', $this->translator->trans("L'enregistrement du flux a posé problème ! " . $e->getMessage()));
++$this->nberrors;
++$line;
continue;
......@@ -1107,13 +1105,13 @@ class ImportController extends CRUDController
{
$entity = null;
$idNameOrEmailSlug = $this->slugify($idNameOrEmail);
if ($type == 'prestataire') {
if ('prestataire' == $type) {
if (!empty($idNameOrEmail)) {
$entity = $this->em->getRepository(Prestataire::class)->findOneBy(['slug' => $idNameOrEmailSlug]);
} elseif (!empty($idmlc)) {
$entity = $this->em->getRepository(Prestataire::class)->findOneBy(['idmlc' => $idmlc]);
}
} elseif ($type == 'adherent') {
} elseif ('adherent' == $type) {
if (!empty($idNameOrEmail)) {
$userFound = $this->em->getRepository(User::class)->findOneBy(['username' => $idNameOrEmail]);
if (!empty($userFound)) {
......@@ -1122,15 +1120,15 @@ class ImportController extends CRUDController
} elseif (!empty($idmlc)) {
$entity = $this->em->getRepository(Adherent::class)->findOneBy(['idmlc' => $idmlc]);
}
} elseif ($type == 'siege' && $exp_id == 'siege') {
} elseif ('siege' == $type && 'siege' == $exp_id) {
$siege = $this->em->getRepository(Siege::class)->getTheOne();
} elseif ($type == 'groupe') {
} elseif ('groupe' == $type) {
if (!empty($idNameOrEmail)) {
$entity = $this->em->getRepository(Groupe::class)->findOneBy(['slug' => $idNameOrEmailSlug]);
} elseif (!empty($idmlc)) {
$entity = $this->em->getRepository(Groupe::class)->findOneBy(['idmlc' => $idmlc]);
}
} elseif ($type == 'comptoir') {
} elseif ('comptoir' == $type) {
if (!empty($idNameOrEmail)) {
$entity = $this->em->getRepository(Comptoir::class)->findOneBy(['slug' => $idNameOrEmailSlug]);
} elseif (!empty($idmlc)) {
......
......@@ -23,7 +23,6 @@ use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Validator\ValidatorInterface;
class UserPrestataireController extends FluxController
{
......@@ -53,11 +52,11 @@ class UserPrestataireController extends FluxController
$errors = [];
foreach ($caissiers as $caissier) {
$emailConstraint = new Assert\Email();
$emailConstraint->message = "Courriel '".$caissier."' invalide!";
$emailConstraint->message = "Courriel '" . $caissier . "' invalide!";
$errors[] = $this->validator->validate(
$caissier,
$emailConstraint
$emailConstraint
);
}
$errorText = '';
......@@ -128,7 +127,7 @@ class UserPrestataireController extends FluxController
$this->eventDispatcher->dispatch(MLCEvents::REGISTRATION_CAISSIER, new PrestataireEvent($user, $prestataire, $request));
}
$user->addPossiblegroup($groupePresta);
$this->userManager->updateUser($user);
$this->userManager->updateCanonicalFields($user);
$this->em->persist($user);
if ($newUser) {
$this->eventDispatcher->dispatch(MLCEvents::REGISTRATION_ADHERENT, new UserEvent($user, $request));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment