fix(manager): cs fixer
All checks were successful
Cadoles/nineskeletor/pipeline/pr-master This commit looks good
All checks were successful
Cadoles/nineskeletor/pipeline/pr-master This commit looks good
This commit is contained in:
parent
58518ec70d
commit
681b2f6547
@ -10,12 +10,12 @@ class HomeController extends AbstractController
|
||||
{
|
||||
public function home(Request $request): Response
|
||||
{
|
||||
if ($request->getSession()->get('fgforceconnect')&&!$this->getUser()) {
|
||||
if ($request->getSession()->get('fgforceconnect') && !$this->getUser()) {
|
||||
return $this->redirectToRoute('app_login');
|
||||
}
|
||||
|
||||
if(!$this->getUser()) {
|
||||
dump("here");
|
||||
if (!$this->getUser()) {
|
||||
dump('here');
|
||||
|
||||
return $this->render('Home/home.html.twig', [
|
||||
'useheader' => true,
|
||||
@ -24,22 +24,25 @@ class HomeController extends AbstractController
|
||||
'maxsize' => 1000,
|
||||
]);
|
||||
}
|
||||
if ($this->getUser()->hasRole("ROLE_USER"))
|
||||
if ($this->getUser()->hasRole('ROLE_USER')) {
|
||||
return $this->redirectToRoute('app_user_home');
|
||||
}
|
||||
|
||||
if ($this->getUser()->hasRole("ROLE_MANAGER"))
|
||||
if ($this->getUser()->hasRole('ROLE_MANAGER')) {
|
||||
return $this->redirectToRoute('app_manager_home');
|
||||
|
||||
if ($this->getUser()->hasRole("ROLE_MASTER"))
|
||||
}
|
||||
|
||||
if ($this->getUser()->hasRole('ROLE_MASTER')) {
|
||||
return $this->redirectToRoute('app_master_home');
|
||||
}
|
||||
|
||||
if ($this->getUser()->hasRole("ROLE_MODO"))
|
||||
if ($this->getUser()->hasRole('ROLE_MODO')) {
|
||||
return $this->redirectToRoute('app_modo_home');
|
||||
}
|
||||
|
||||
if ($this->getUser()->hasRole("ROLE_ADMIN"))
|
||||
if ($this->getUser()->hasRole('ROLE_ADMIN')) {
|
||||
return $this->redirectToRoute('app_admin_home');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function homeuser($access): Response
|
||||
@ -77,7 +80,6 @@ class HomeController extends AbstractController
|
||||
return $this->redirectToRoute('app_admin_config');
|
||||
}
|
||||
|
||||
|
||||
public function docrest(): Response
|
||||
{
|
||||
return $this->render('Home/docrest.html.twig', [
|
||||
|
@ -79,7 +79,7 @@ class UserController extends AbstractController
|
||||
break;
|
||||
|
||||
default:
|
||||
$isactive = ($access=="manager"?$em->getRepository($this->entity)->getPreference($this->getUser(), 'userisactive', true):true);
|
||||
$isactive = ('manager' == $access ? $em->getRepository($this->entity)->getPreference($this->getUser(), 'userisactive', true) : true);
|
||||
|
||||
$niveau01 = $this->getUser()->getNiveau01();
|
||||
$niveau02 = $this->getUser()->getNiveau02();
|
||||
@ -300,13 +300,11 @@ class UserController extends AbstractController
|
||||
$action .= "<a href='".$this->generateUrl(str_replace('_admin_', '_modo_', $this->route).'_update', ['id' => $data->getId()])."'><i class='fa fa-file fa-fw fa-2x'></i></a>";
|
||||
break;
|
||||
case 'manager':
|
||||
if($this->getUser()->getNiveau03()&&$this->getUser()->getNiveau03()==$data->getNiveau03()) {
|
||||
if ($this->getUser()->getNiveau03() && $this->getUser()->getNiveau03() == $data->getNiveau03()) {
|
||||
$action .= "<a href='".$this->generateUrl(str_replace('_admin_', '_manager_', $this->route).'_update', ['id' => $data->getId()])."'><i class='fa fa-file fa-fw fa-2x'></i></a>";
|
||||
}
|
||||
elseif(!$this->getUser()->getNiveau03()&&$this->getUser()->getNiveau02()&&$this->getUser()->getNiveau02()==$data->getNiveau02()) {
|
||||
} elseif (!$this->getUser()->getNiveau03() && $this->getUser()->getNiveau02() && $this->getUser()->getNiveau02() == $data->getNiveau02()) {
|
||||
$action .= "<a href='".$this->generateUrl(str_replace('_admin_', '_manager_', $this->route).'_update', ['id' => $data->getId()])."'><i class='fa fa-file fa-fw fa-2x'></i></a>";
|
||||
}
|
||||
elseif(!$this->getUser()->getNiveau02()&&$this->getUser()->getNiveau01()&&$this->getUser()->getNiveau01()==$data->getNiveau01()) {
|
||||
} elseif (!$this->getUser()->getNiveau02() && $this->getUser()->getNiveau01() && $this->getUser()->getNiveau01() == $data->getNiveau01()) {
|
||||
$action .= "<a href='".$this->generateUrl(str_replace('_admin_', '_manager_', $this->route).'_update', ['id' => $data->getId()])."'><i class='fa fa-file fa-fw fa-2x'></i></a>";
|
||||
}
|
||||
break;
|
||||
@ -394,11 +392,11 @@ class UserController extends AbstractController
|
||||
$data->setApikey(Uuid::uuid4());
|
||||
|
||||
// If manager set same niveau to usertosubmit
|
||||
if($access=="manager") {
|
||||
if ('manager' == $access) {
|
||||
$data->setNiveau01($this->getUser()->getNiveau01());
|
||||
$data->setNiveau02($this->getUser()->getNiveau02());
|
||||
$data->setNiveau03($this->getUser()->getNiveau03());
|
||||
$data->setRoles(["ROLE_USER"]);
|
||||
$data->setRoles(['ROLE_USER']);
|
||||
}
|
||||
|
||||
// Création du formulaire
|
||||
@ -711,7 +709,7 @@ class UserController extends AbstractController
|
||||
switch ($access) {
|
||||
case 'admin': return true;
|
||||
break;
|
||||
|
||||
|
||||
case 'modo':
|
||||
$usermodo = $em->getRepository("App\Entity\UserModo")->findOneBy(['user' => $this->getUser(), 'niveau01' => $entity->getNiveau01()]);
|
||||
if (!$usermodo) {
|
||||
@ -722,16 +720,14 @@ class UserController extends AbstractController
|
||||
break;
|
||||
|
||||
case 'manager':
|
||||
if($this->getUser()->getNiveau03()&&$this->getUser()->getNiveau03()==$entity->getNiveau03()) {
|
||||
if ($this->getUser()->getNiveau03() && $this->getUser()->getNiveau03() == $entity->getNiveau03()) {
|
||||
return true;
|
||||
} elseif ($this->getUser()->getNiveau02() && $this->getUser()->getNiveau02() == $entity->getNiveau02()) {
|
||||
return true;
|
||||
} elseif ($this->getUser()->getNiveau01() && $this->getUser()->getNiveau01() == $entity->getNiveau01()) {
|
||||
return true;
|
||||
}
|
||||
elseif($this->getUser()->getNiveau02()&&$this->getUser()->getNiveau02()==$entity->getNiveau02()) {
|
||||
return true;
|
||||
}
|
||||
elseif($this->getUser()->getNiveau01()&&$this->getUser()->getNiveau01()==$entity->getNiveau01()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
throw $this->createAccessDeniedException('Permission denied');
|
||||
break;
|
||||
|
||||
|
@ -2,22 +2,21 @@
|
||||
|
||||
namespace App\DataFixtures;
|
||||
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Doctrine\ORM\Id\AssignedGenerator;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
|
||||
use App\Entity\Niveau01;
|
||||
use App\Entity\Niveau02;
|
||||
use App\Entity\Niveau03;
|
||||
use App\Entity\Niveau04;
|
||||
use App\Entity\User;
|
||||
use App\Entity\UserModo;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\ORM\Id\AssignedGenerator;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
|
||||
class AppFixtures extends Fixture
|
||||
{
|
||||
@ -33,7 +32,7 @@ class AppFixtures extends Fixture
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
// app:Init
|
||||
$this->writeln("app:Init");
|
||||
$this->writeln('app:Init');
|
||||
$application = new Application($this->kernel);
|
||||
$application->setAutoExit(false);
|
||||
$input = new ArrayInput(['command' => 'app:Init']);
|
||||
@ -43,158 +42,161 @@ class AppFixtures extends Fixture
|
||||
|
||||
// app:Synchro
|
||||
$manager->clear();
|
||||
$this->writeln("app:Synchro");
|
||||
$this->writeln('app:Synchro');
|
||||
$input = new ArrayInput(['command' => 'app:Synchro']);
|
||||
$boutput = new BufferedOutput();
|
||||
$application->run($input, $boutput);
|
||||
$application->run($input, $boutput);
|
||||
|
||||
// Assign id
|
||||
$metadata = $manager->getClassMetaData('App\Entity\Niveau01');
|
||||
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
|
||||
$metadata->setIdGenerator(new AssignedGenerator());
|
||||
|
||||
|
||||
$metadata = $manager->getClassMetaData('App\Entity\Niveau02');
|
||||
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
|
||||
$metadata->setIdGenerator(new AssignedGenerator());
|
||||
|
||||
|
||||
$metadata = $manager->getClassMetaData('App\Entity\Niveau03');
|
||||
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
|
||||
$metadata->setIdGenerator(new AssignedGenerator());
|
||||
|
||||
|
||||
$metadata = $manager->getClassMetaData('App\Entity\Niveau04');
|
||||
$metadata->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_NONE);
|
||||
$metadata->setIdGenerator(new AssignedGenerator());
|
||||
|
||||
// Niveau 01
|
||||
$this->writeln("Niveau01");
|
||||
$this->writeln('Niveau01');
|
||||
$csv = file_get_contents($this->kernel->getProjectDir().'/src/DataFixtures/niveau01.csv');
|
||||
$tab = $this->csv_to_array($csv);
|
||||
foreach($tab as $lig) {
|
||||
$niveau01=$manager->getRepository('App\Entity\Niveau01')->find($lig['id']);
|
||||
if(!$niveau01) {
|
||||
$niveau01=new Niveau01();
|
||||
$niveau01->setId($lig["id"]);
|
||||
foreach ($tab as $lig) {
|
||||
$niveau01 = $manager->getRepository('App\Entity\Niveau01')->find($lig['id']);
|
||||
if (!$niveau01) {
|
||||
$niveau01 = new Niveau01();
|
||||
$niveau01->setId($lig['id']);
|
||||
$manager->persist($niveau01);
|
||||
|
||||
}
|
||||
$niveau01->setLabel($lig["label"]);
|
||||
$niveau01->setCode($lig["code"]);
|
||||
$niveau01->setPostaladress($lig["postaladress"]);
|
||||
$niveau01->setTelephonenumber($lig["telephonenumber"]);
|
||||
$niveau01->setEmail($lig["email"]);
|
||||
$niveau01->setApikey($lig["apikey"]);
|
||||
$niveau01->setLabel($lig['label']);
|
||||
$niveau01->setCode($lig['code']);
|
||||
$niveau01->setPostaladress($lig['postaladress']);
|
||||
$niveau01->setTelephonenumber($lig['telephonenumber']);
|
||||
$niveau01->setEmail($lig['email']);
|
||||
$niveau01->setApikey($lig['apikey']);
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
// Niveau 02
|
||||
$this->writeln("Niveau02");
|
||||
$this->writeln('Niveau02');
|
||||
$csv = file_get_contents($this->kernel->getProjectDir().'/src/DataFixtures/niveau02.csv');
|
||||
$tab = $this->csv_to_array($csv);
|
||||
foreach($tab as $lig) {
|
||||
$niveau01=$manager->getRepository('App\Entity\Niveau01')->findOneBy(["code"=>$lig['codenv1']]);
|
||||
if(!$niveau01) continue;
|
||||
|
||||
$niveau02=$manager->getRepository('App\Entity\Niveau02')->find($lig['id']);
|
||||
if(!$niveau02) {
|
||||
$niveau02=new Niveau02();
|
||||
$niveau02->setId($lig["id"]);
|
||||
$manager->persist($niveau02);
|
||||
|
||||
foreach ($tab as $lig) {
|
||||
$niveau01 = $manager->getRepository('App\Entity\Niveau01')->findOneBy(['code' => $lig['codenv1']]);
|
||||
if (!$niveau01) {
|
||||
continue;
|
||||
}
|
||||
$niveau02->setLabel($lig["label"]);
|
||||
$niveau02->setCode($lig["code"]);
|
||||
$niveau02->setPostaladress($lig["postaladress"]);
|
||||
$niveau02->setTelephonenumber($lig["telephonenumber"]);
|
||||
$niveau02->setEmail($lig["email"]);
|
||||
$niveau02->setApikey($lig["apikey"]);
|
||||
|
||||
$niveau02 = $manager->getRepository('App\Entity\Niveau02')->find($lig['id']);
|
||||
if (!$niveau02) {
|
||||
$niveau02 = new Niveau02();
|
||||
$niveau02->setId($lig['id']);
|
||||
$manager->persist($niveau02);
|
||||
}
|
||||
$niveau02->setLabel($lig['label']);
|
||||
$niveau02->setCode($lig['code']);
|
||||
$niveau02->setPostaladress($lig['postaladress']);
|
||||
$niveau02->setTelephonenumber($lig['telephonenumber']);
|
||||
$niveau02->setEmail($lig['email']);
|
||||
$niveau02->setApikey($lig['apikey']);
|
||||
$niveau02->setNiveau01($niveau01);
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
// Niveau 03
|
||||
$this->writeln("Niveau03");
|
||||
$this->writeln('Niveau03');
|
||||
$csv = file_get_contents($this->kernel->getProjectDir().'/src/DataFixtures/niveau03.csv');
|
||||
$tab = $this->csv_to_array($csv);
|
||||
foreach($tab as $lig) {
|
||||
$niveau02=$manager->getRepository('App\Entity\Niveau02')->findOneBy(["code"=>$lig['codenv2']]);
|
||||
if(!$niveau02) continue;
|
||||
|
||||
$niveau03=$manager->getRepository('App\Entity\Niveau03')->find($lig['id']);
|
||||
if(!$niveau03) {
|
||||
$niveau03=new Niveau03();
|
||||
$niveau03->setId($lig["id"]);
|
||||
$manager->persist($niveau03);
|
||||
|
||||
foreach ($tab as $lig) {
|
||||
$niveau02 = $manager->getRepository('App\Entity\Niveau02')->findOneBy(['code' => $lig['codenv2']]);
|
||||
if (!$niveau02) {
|
||||
continue;
|
||||
}
|
||||
$niveau03->setLabel($lig["label"]);
|
||||
$niveau03->setCode($lig["code"]);
|
||||
$niveau03->setPostaladress($lig["postaladress"]);
|
||||
$niveau03->setTelephonenumber($lig["telephonenumber"]);
|
||||
$niveau03->setEmail($lig["email"]);
|
||||
$niveau03->setApikey($lig["apikey"]);
|
||||
|
||||
$niveau03 = $manager->getRepository('App\Entity\Niveau03')->find($lig['id']);
|
||||
if (!$niveau03) {
|
||||
$niveau03 = new Niveau03();
|
||||
$niveau03->setId($lig['id']);
|
||||
$manager->persist($niveau03);
|
||||
}
|
||||
$niveau03->setLabel($lig['label']);
|
||||
$niveau03->setCode($lig['code']);
|
||||
$niveau03->setPostaladress($lig['postaladress']);
|
||||
$niveau03->setTelephonenumber($lig['telephonenumber']);
|
||||
$niveau03->setEmail($lig['email']);
|
||||
$niveau03->setApikey($lig['apikey']);
|
||||
$niveau03->setNiveau02($niveau02);
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
// Niveau 04
|
||||
$this->writeln("Niveau04");
|
||||
$this->writeln('Niveau04');
|
||||
$csv = file_get_contents($this->kernel->getProjectDir().'/src/DataFixtures/niveau04.csv');
|
||||
$tab = $this->csv_to_array($csv);
|
||||
foreach($tab as $lig) {
|
||||
$niveau03=$manager->getRepository('App\Entity\Niveau03')->findOneBy(["code"=>$lig['codenv3']]);
|
||||
if(!$niveau03) continue;
|
||||
foreach ($tab as $lig) {
|
||||
$niveau03 = $manager->getRepository('App\Entity\Niveau03')->findOneBy(['code' => $lig['codenv3']]);
|
||||
if (!$niveau03) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$niveau04=$manager->getRepository('App\Entity\Niveau04')->find($lig['id']);
|
||||
if(!$niveau04) {
|
||||
$niveau04=new Niveau04();
|
||||
$niveau04->setId($lig["id"]);
|
||||
$niveau04 = $manager->getRepository('App\Entity\Niveau04')->find($lig['id']);
|
||||
if (!$niveau04) {
|
||||
$niveau04 = new Niveau04();
|
||||
$niveau04->setId($lig['id']);
|
||||
$manager->persist($niveau04);
|
||||
}
|
||||
$niveau04->setLabel($lig["label"]);
|
||||
$niveau04->setCode($lig["code"]);
|
||||
$niveau04->setPostaladress($lig["postaladress"]);
|
||||
$niveau04->setTelephonenumber($lig["telephonenumber"]);
|
||||
$niveau04->setEmail($lig["email"]);
|
||||
$niveau04->setApikey($lig["apikey"]);
|
||||
$niveau04->setLabel($lig['label']);
|
||||
$niveau04->setCode($lig['code']);
|
||||
$niveau04->setPostaladress($lig['postaladress']);
|
||||
$niveau04->setTelephonenumber($lig['telephonenumber']);
|
||||
$niveau04->setEmail($lig['email']);
|
||||
$niveau04->setApikey($lig['apikey']);
|
||||
$niveau04->setNiveau03($niveau03);
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
||||
// User MODO
|
||||
$this->writeln("User Modo");
|
||||
$userid=-99;
|
||||
$usercpt=0;
|
||||
$niveau01s=$manager->getRepository('App\Entity\Niveau01')->findAll();
|
||||
foreach($niveau01s as $niveau01) {
|
||||
$userid=$userid-1;
|
||||
$usercpt=$usercpt+1;
|
||||
$username="modo".str_pad($usercpt,3,"0", STR_PAD_LEFT);
|
||||
$this->writeln('User Modo');
|
||||
$userid = -99;
|
||||
$usercpt = 0;
|
||||
$niveau01s = $manager->getRepository('App\Entity\Niveau01')->findAll();
|
||||
foreach ($niveau01s as $niveau01) {
|
||||
$userid = $userid - 1;
|
||||
$usercpt = $usercpt + 1;
|
||||
$username = 'modo'.str_pad($usercpt, 3, '0', STR_PAD_LEFT);
|
||||
|
||||
$user=$manager->getRepository('App\Entity\User')->find($userid);
|
||||
if(!$user) {
|
||||
$user=new User();
|
||||
$user = $manager->getRepository('App\Entity\User')->find($userid);
|
||||
if (!$user) {
|
||||
$user = new User();
|
||||
$user->setId($userid);
|
||||
$manager->persist($user);
|
||||
|
||||
$usermodo=new UserModo();
|
||||
$usermodo = new UserModo();
|
||||
$usermodo->setUser($user);
|
||||
$usermodo->setNiveau01($niveau01);
|
||||
$manager->persist($usermodo);
|
||||
}
|
||||
|
||||
|
||||
$user->setUsername($username);
|
||||
$user->setPassword($username);
|
||||
$user->setRoles(["ROLE_MODO"]);
|
||||
$user->setFirstname(str_pad($usercpt,3,"0", STR_PAD_LEFT));
|
||||
$user->setLastname("Modo");
|
||||
$user->setEmail($username."@noreply.fr");
|
||||
$user->setRoles(['ROLE_MODO']);
|
||||
$user->setFirstname(str_pad($usercpt, 3, '0', STR_PAD_LEFT));
|
||||
$user->setLastname('Modo');
|
||||
$user->setEmail($username.'@noreply.fr');
|
||||
$user->setIsvisible(true);
|
||||
$user->setIsactive(true);
|
||||
$user->setAvatar("noavatar.png");
|
||||
$user->setAvatar('noavatar.png');
|
||||
$user->setApikey($username);
|
||||
$user->setNiveau01($niveau01);
|
||||
|
||||
@ -202,31 +204,31 @@ class AppFixtures extends Fixture
|
||||
}
|
||||
|
||||
// User MASTER
|
||||
$this->writeln("User Master");
|
||||
$userid=-199;
|
||||
$usercpt=0;
|
||||
$niveau02s=$manager->getRepository('App\Entity\Niveau02')->findAll();
|
||||
foreach($niveau02s as $niveau02) {
|
||||
$userid=$userid-1;
|
||||
$usercpt=$usercpt+1;
|
||||
$username="master".str_pad($usercpt,3,"0", STR_PAD_LEFT);
|
||||
$this->writeln('User Master');
|
||||
$userid = -199;
|
||||
$usercpt = 0;
|
||||
$niveau02s = $manager->getRepository('App\Entity\Niveau02')->findAll();
|
||||
foreach ($niveau02s as $niveau02) {
|
||||
$userid = $userid - 1;
|
||||
$usercpt = $usercpt + 1;
|
||||
$username = 'master'.str_pad($usercpt, 3, '0', STR_PAD_LEFT);
|
||||
|
||||
$user=$manager->getRepository('App\Entity\User')->find($userid);
|
||||
if(!$user) {
|
||||
$user=new User();
|
||||
$user = $manager->getRepository('App\Entity\User')->find($userid);
|
||||
if (!$user) {
|
||||
$user = new User();
|
||||
$user->setId($userid);
|
||||
$manager->persist($user);
|
||||
}
|
||||
|
||||
|
||||
$user->setUsername($username);
|
||||
$user->setPassword($username);
|
||||
$user->setRoles(["ROLE_MASTER"]);
|
||||
$user->setFirstname(str_pad($usercpt,3,"0", STR_PAD_LEFT));
|
||||
$user->setLastname("Master");
|
||||
$user->setEmail($username."@noreply.fr");
|
||||
$user->setRoles(['ROLE_MASTER']);
|
||||
$user->setFirstname(str_pad($usercpt, 3, '0', STR_PAD_LEFT));
|
||||
$user->setLastname('Master');
|
||||
$user->setEmail($username.'@noreply.fr');
|
||||
$user->setIsvisible(true);
|
||||
$user->setIsactive(true);
|
||||
$user->setAvatar("noavatar.png");
|
||||
$user->setAvatar('noavatar.png');
|
||||
$user->setApikey($username);
|
||||
$user->setNiveau01($niveau02->getNiveau01());
|
||||
$user->setNiveau02($niveau02);
|
||||
@ -235,31 +237,31 @@ class AppFixtures extends Fixture
|
||||
}
|
||||
|
||||
// User MANAGER
|
||||
$this->writeln("User Manager");
|
||||
$userid=-299;
|
||||
$usercpt=0;
|
||||
$niveau03s=$manager->getRepository('App\Entity\Niveau03')->findAll();
|
||||
foreach($niveau03s as $niveau03) {
|
||||
$userid=$userid-1;
|
||||
$usercpt=$usercpt+1;
|
||||
$username="manager".str_pad($usercpt,3,"0", STR_PAD_LEFT);
|
||||
$this->writeln('User Manager');
|
||||
$userid = -299;
|
||||
$usercpt = 0;
|
||||
$niveau03s = $manager->getRepository('App\Entity\Niveau03')->findAll();
|
||||
foreach ($niveau03s as $niveau03) {
|
||||
$userid = $userid - 1;
|
||||
$usercpt = $usercpt + 1;
|
||||
$username = 'manager'.str_pad($usercpt, 3, '0', STR_PAD_LEFT);
|
||||
|
||||
$user=$manager->getRepository('App\Entity\User')->find($userid);
|
||||
if(!$user) {
|
||||
$user=new User();
|
||||
$user = $manager->getRepository('App\Entity\User')->find($userid);
|
||||
if (!$user) {
|
||||
$user = new User();
|
||||
$user->setId($userid);
|
||||
$manager->persist($user);
|
||||
}
|
||||
|
||||
|
||||
$user->setUsername($username);
|
||||
$user->setPassword($username);
|
||||
$user->setRoles(["ROLE_MANAGER"]);
|
||||
$user->setFirstname(str_pad($usercpt,3,"0", STR_PAD_LEFT));
|
||||
$user->setLastname("Manager");
|
||||
$user->setEmail($username."@noreply.fr");
|
||||
$user->setRoles(['ROLE_MANAGER']);
|
||||
$user->setFirstname(str_pad($usercpt, 3, '0', STR_PAD_LEFT));
|
||||
$user->setLastname('Manager');
|
||||
$user->setEmail($username.'@noreply.fr');
|
||||
$user->setIsvisible(true);
|
||||
$user->setIsactive(true);
|
||||
$user->setAvatar("noavatar.png");
|
||||
$user->setAvatar('noavatar.png');
|
||||
$user->setApikey($username);
|
||||
$user->setNiveau01($niveau03->getNiveau02()->getNiveau01());
|
||||
$user->setNiveau02($niveau03->getNiveau02());
|
||||
@ -269,31 +271,31 @@ class AppFixtures extends Fixture
|
||||
}
|
||||
|
||||
// User USER
|
||||
$this->writeln("User User");
|
||||
$userid=-399;
|
||||
$usercpt=0;
|
||||
$niveau03s=$manager->getRepository('App\Entity\Niveau03')->findAll();
|
||||
foreach($niveau03s as $niveau03) {
|
||||
$userid=$userid-1;
|
||||
$usercpt=$usercpt+1;
|
||||
$username="user".str_pad($usercpt,3,"0", STR_PAD_LEFT);
|
||||
$this->writeln('User User');
|
||||
$userid = -399;
|
||||
$usercpt = 0;
|
||||
$niveau03s = $manager->getRepository('App\Entity\Niveau03')->findAll();
|
||||
foreach ($niveau03s as $niveau03) {
|
||||
$userid = $userid - 1;
|
||||
$usercpt = $usercpt + 1;
|
||||
$username = 'user'.str_pad($usercpt, 3, '0', STR_PAD_LEFT);
|
||||
|
||||
$user=$manager->getRepository('App\Entity\User')->find($userid);
|
||||
if(!$user) {
|
||||
$user=new User();
|
||||
$user = $manager->getRepository('App\Entity\User')->find($userid);
|
||||
if (!$user) {
|
||||
$user = new User();
|
||||
$user->setId($userid);
|
||||
$manager->persist($user);
|
||||
}
|
||||
|
||||
|
||||
$user->setUsername($username);
|
||||
$user->setPassword($username);
|
||||
$user->setRoles(["ROLE_USER"]);
|
||||
$user->setFirstname(str_pad($usercpt,3,"0", STR_PAD_LEFT));
|
||||
$user->setLastname("User");
|
||||
$user->setEmail($username."@noreply.fr");
|
||||
$user->setRoles(['ROLE_USER']);
|
||||
$user->setFirstname(str_pad($usercpt, 3, '0', STR_PAD_LEFT));
|
||||
$user->setLastname('User');
|
||||
$user->setEmail($username.'@noreply.fr');
|
||||
$user->setIsvisible(true);
|
||||
$user->setIsactive(true);
|
||||
$user->setAvatar("noavatar.png");
|
||||
$user->setAvatar('noavatar.png');
|
||||
$user->setApikey($username);
|
||||
$user->setNiveau01($niveau03->getNiveau02()->getNiveau01());
|
||||
$user->setNiveau02($niveau03->getNiveau02());
|
||||
@ -304,31 +306,35 @@ class AppFixtures extends Fixture
|
||||
|
||||
// app:Synchro
|
||||
$manager->clear();
|
||||
$this->writeln("app:Synchro");
|
||||
$this->writeln('app:Synchro');
|
||||
$input = new ArrayInput(['command' => 'app:Synchro']);
|
||||
$boutput = new BufferedOutput();
|
||||
$application->run($input, $boutput);
|
||||
$application->run($input, $boutput);
|
||||
}
|
||||
|
||||
private function writeln($string) {
|
||||
$this->output->writeln(' <fg=yellow>></> <info>'.$string.'</info>');
|
||||
private function writeln($string)
|
||||
{
|
||||
$this->output->writeln(' <fg=yellow>></> <info>'.$string.'</info>');
|
||||
}
|
||||
|
||||
private function csv_to_array($csv, $delimiter = ';', $enclosure = '', $escape = '\\', $terminator = "\n")
|
||||
{
|
||||
$r = [];
|
||||
$rows = explode($terminator, trim($csv));
|
||||
|
||||
private function csv_to_array($csv, $delimiter = ';', $enclosure = '', $escape = '\\', $terminator = "\n") {
|
||||
$r = array();
|
||||
$rows = explode($terminator,trim($csv));
|
||||
$names = array_shift($rows);
|
||||
$names = str_getcsv($names, $delimiter, $enclosure, $escape);
|
||||
$nc = count($names);
|
||||
foreach ($rows as $row) {
|
||||
if (trim($row)) {
|
||||
$values = str_getcsv($row, $delimiter, $enclosure, $escape);
|
||||
if (!$values) {
|
||||
$values = array_fill(0, $nc, null);
|
||||
}
|
||||
@$r[] = array_combine($names, $values);
|
||||
}
|
||||
}
|
||||
|
||||
$names = array_shift($rows);
|
||||
$names = str_getcsv($names,$delimiter,$enclosure,$escape);
|
||||
$nc = count($names);
|
||||
foreach ($rows as $row) {
|
||||
if (trim($row)) {
|
||||
$values = str_getcsv($row,$delimiter,$enclosure,$escape);
|
||||
if (!$values) $values = array_fill(0,$nc,null);
|
||||
@$r[] = array_combine($names,$values);
|
||||
}
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ class Niveau02
|
||||
return $this;
|
||||
}
|
||||
// == FIN DU CODE A NE PAS REGENERER
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->niveau03s = new ArrayCollection();
|
||||
|
@ -181,7 +181,7 @@ class UserType extends AbstractType
|
||||
);
|
||||
}
|
||||
|
||||
if(($access!="all"&&$access!="manager")||$options["appUserviewisvisible"]) {
|
||||
if (('all' != $access && 'manager' != $access) || $options['appUserviewisvisible']) {
|
||||
$choices = ['oui' => '1', 'non' => '0'];
|
||||
$builder->add('isvisible',
|
||||
ChoiceType::class, [
|
||||
|
@ -48,7 +48,6 @@ class AppSession
|
||||
$session->set('fgheader', true);
|
||||
$session->set('fgaudit', false);
|
||||
|
||||
|
||||
// Current user
|
||||
$token = $this->token->getToken();
|
||||
if (!$token) {
|
||||
|
Loading…
Reference in New Issue
Block a user