first commit symfony 6

This commit is contained in:
2022-07-21 16:15:47 +02:00
parent d9bfbb6b3c
commit 5c4961748b
282 changed files with 37482 additions and 0 deletions

0
src/Entity/.gitignore vendored Normal file
View File

227
src/Entity/Config.php Normal file
View File

@ -0,0 +1,227 @@
<?php
namespace App\Entity;
use App\Repository\ConfigRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
/**
* Cron
*
* @ORM\Table(name="config")
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity(repositoryClass="App\Repository\ConfigRepository")
*/
class Config
{ /**
* @ORM\Id
* @ORM\Column(type="string")
*/
private $id;
/**
* @ORM\Column(type="string", length=250)
*/
private $title;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $value;
/**
* @ORM\Column(name="defaultvalue", type="text")
*/
private $default;
/**
* @ORM\Column(name="roworder", type="string")
*/
private $order;
/**
* @ORM\Column(type="boolean")
*/
private $visible;
/**
* @ORM\Column(type="boolean")
*/
private $changeable;
/**
* @ORM\Column(type="boolean")
*/
private $required;
/**
* @ORM\Column(type="string")
*/
private $type;
/**
* @ORM\Column(type="string")
*/
private $grouped;
/**
* @ORM\Column(type="string")
*/
private $category;
/**
* @ORM\Column(type="text")
*/
private $help;
//== CODE A NE PAS REGENERER
public function setId(string $id): self
{
$this->id = $id;
return $this;
}
public function getValue(): ?string
{
if($this->value=="") return $this->default;
else return $this->value;
}
//== FIN DU CODE A NE PAS REGENERER
public function getId(): ?string
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function setValue(?string $value): self
{
$this->value = $value;
return $this;
}
public function getDefault(): ?string
{
return $this->default;
}
public function setDefault(string $default): self
{
$this->default = $default;
return $this;
}
public function getOrder(): ?string
{
return $this->order;
}
public function setOrder(string $order): self
{
$this->order = $order;
return $this;
}
public function isVisible(): ?bool
{
return $this->visible;
}
public function setVisible(bool $visible): self
{
$this->visible = $visible;
return $this;
}
public function isChangeable(): ?bool
{
return $this->changeable;
}
public function setChangeable(bool $changeable): self
{
$this->changeable = $changeable;
return $this;
}
public function isRequired(): ?bool
{
return $this->required;
}
public function setRequired(bool $required): self
{
$this->required = $required;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getGrouped(): ?string
{
return $this->grouped;
}
public function setGrouped(string $grouped): self
{
$this->grouped = $grouped;
return $this;
}
public function getCategory(): ?string
{
return $this->category;
}
public function setCategory(string $category): self
{
$this->category = $category;
return $this;
}
public function getHelp(): ?string
{
return $this->help;
}
public function setHelp(string $help): self
{
$this->help = $help;
return $this;
}
}

210
src/Entity/Cron.php Normal file
View File

@ -0,0 +1,210 @@
<?php
namespace App\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Cron
*
* @ORM\Table(name="cron")
* @ORM\Entity(repositoryClass="App\Repository\CronRepository")
*/
class Cron
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="command", type="string", nullable=false)
* @Assert\NotBlank()
*
*/
private $command;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $statut;
/**
* @ORM\Column(type="datetime", nullable=false)
*/
private $submitdate;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $startexecdate;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $endexecdate;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $nextexecdate;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $repeatinterval;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $jsonargument;
// A garder pour forcer l'id en init
public function setId($id)
{
$this->id = $id;
return $this;
}
public function __construct()
{
$this->submitdate = new \DateTime();
}
// A garder pour récupérer le label du statut
public function getStatutLabel()
{
switch($this->statut) {
case -1: return "Désactivé"; break;
case 0: return "KO"; break;
case 1: return "OK"; break;
}
}
public function getId(): ?int
{
return $this->id;
}
public function getCommand(): ?string
{
return $this->command;
}
public function setCommand(string $command): self
{
$this->command = $command;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getStatut(): ?int
{
return $this->statut;
}
public function setStatut($statut): self
{
$this->statut = $statut;
return $this;
}
public function getSubmitdate(): ?\DateTimeInterface
{
return $this->submitdate;
}
public function setSubmitdate(\DateTimeInterface $submitdate): self
{
$this->submitdate = $submitdate;
return $this;
}
public function getStartexecdate(): ?\DateTimeInterface
{
return $this->startexecdate;
}
public function setStartexecdate(?\DateTimeInterface $startexecdate): self
{
$this->startexecdate = $startexecdate;
return $this;
}
public function getEndexecdate(): ?\DateTimeInterface
{
return $this->endexecdate;
}
public function setEndexecdate(?\DateTimeInterface $endexecdate): self
{
$this->endexecdate = $endexecdate;
return $this;
}
public function getNextexecdate(): ?\DateTimeInterface
{
return $this->nextexecdate;
}
public function setNextexecdate(?\DateTimeInterface $nextexecdate): self
{
$this->nextexecdate = $nextexecdate;
return $this;
}
public function getRepeatinterval(): ?int
{
return $this->repeatinterval;
}
public function setRepeatinterval(?int $repeatinterval): self
{
$this->repeatinterval = $repeatinterval;
return $this;
}
public function getJsonargument(): ?string
{
return $this->jsonargument;
}
public function setJsonargument(?string $jsonargument): self
{
$this->jsonargument = $jsonargument;
return $this;
}
}

268
src/Entity/Group.php Normal file
View File

@ -0,0 +1,268 @@
<?php
namespace App\Entity;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity
* @ORM\Table(name="groupe")
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity(repositoryClass="App\Repository\GroupRepository")
*
* @UniqueEntity(fields="label", message="Un group existe déjà avec ce label")
*/
class Group
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", length=250, unique=true)
*/
private $label;
/**
* @var string
*
* @ORM\Column(name="description", type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="string", length=250, nullable=true)
*/
private $email;
/**
* @ORM\Column(type="boolean", options={"default" : false})
*/
private $isopen;
/**
* @ORM\Column(type="boolean", options={"default" : false})
*/
private $isworkgroup;
/**
* @ORM\Column(type="string")
*/
private $apikey;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $ldapfilter;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $attributes;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $idexternal;
/**
* @ORM\ManyToOne(targetEntity="User", inversedBy="ownergroups")
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
*/
private $owner;
/**
* @var ArrayCollection $users
* @var UserGroup
*
* @ORM\OneToMany(targetEntity="UserGroup", mappedBy="group", cascade={"persist"}, orphanRemoval=true)
*/
private $users;
public function __construct()
{
$this->users = new ArrayCollection();
}
//== CODE A NE PAS REGENERER
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
//== FIN DU CODE A NE PAS REGENERER
public function getId(): ?int
{
return $this->id;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function isIsopen(): ?bool
{
return $this->isopen;
}
public function setIsopen(bool $isopen): self
{
$this->isopen = $isopen;
return $this;
}
public function isIsworkgroup(): ?bool
{
return $this->isworkgroup;
}
public function setIsworkgroup(bool $isworkgroup): self
{
$this->isworkgroup = $isworkgroup;
return $this;
}
public function getApikey(): ?string
{
return $this->apikey;
}
public function setApikey(string $apikey): self
{
$this->apikey = $apikey;
return $this;
}
public function getLdapfilter(): ?string
{
return $this->ldapfilter;
}
public function setLdapfilter(?string $ldapfilter): self
{
$this->ldapfilter = $ldapfilter;
return $this;
}
public function getAttributes(): ?string
{
return $this->attributes;
}
public function setAttributes(?string $attributes): self
{
$this->attributes = $attributes;
return $this;
}
public function getIdexternal(): ?string
{
return $this->idexternal;
}
public function setIdexternal(?string $idexternal): self
{
$this->idexternal = $idexternal;
return $this;
}
public function getInvitations(): ?array
{
return $this->invitations;
}
public function setInvitations(?array $invitations): self
{
$this->invitations = $invitations;
return $this;
}
public function getOwner(): ?User
{
return $this->owner;
}
public function setOwner(?User $owner): self
{
$this->owner = $owner;
return $this;
}
/**
* @return Collection<int, UserGroup>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(UserGroup $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->setGroup($this);
}
return $this;
}
public function removeUser(UserGroup $user): self
{
if ($this->users->removeElement($user)) {
// set the owning side to null (unless already changed)
if ($user->getGroup() === $this) {
$user->setGroup(null);
}
}
return $this;
}
}

292
src/Entity/Niveau01.php Normal file
View File

@ -0,0 +1,292 @@
<?php
namespace App\Entity;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use App\Validator as Validator;
/**
* @ORM\Entity
* @ORM\Table(name="niveau01")
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity(repositoryClass="App\Repository\Niveau01Repository")
*
* @UniqueEntity(fields="label", message="Un Niveau de rang 01 existe déjà avec ce label")
*/
class Niveau01
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", length=250, unique=true)
* @Validator\Grouplabel()
* @Validator\Niveau01unique()
*/
private $label;
/**
* @ORM\Column(type="string")
*/
private $apikey;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $ldapfilter;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $attributes;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $idexternal;
/**
* @var ArrayCollection $niveau02s
* @var Registration
*
* @ORM\OneToMany(targetEntity="Niveau02", mappedBy="niveau01", cascade={"persist"}, orphanRemoval=false)
*/
private $niveau02s;
/**
* @var ArrayCollection $registrations
* @var Registration
*
* @ORM\OneToMany(targetEntity="Registration", mappedBy="niveau01", cascade={"persist"}, orphanRemoval=false)
*/
private $registrations;
/**
* @var ArrayCollection $users
* @var User
*
* @ORM\OneToMany(targetEntity="User", mappedBy="niveau01", cascade={"persist"}, orphanRemoval=false)
*/
private $users;
/**
* @var ArrayCollection $modos
* @var User
*
* @ORM\OneToMany(targetEntity="UserModo", mappedBy="niveau01", cascade={"persist"}, orphanRemoval=false)
*/
private $modos;
public function __construct()
{
$this->niveau02s = new ArrayCollection();
$this->registrations = new ArrayCollection();
$this->users = new ArrayCollection();
$this->modos = new ArrayCollection();
}
//== CODE A NE PAS REGENERER
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
//== FIN DU CODE A NE PAS REGENERER
public function getId(): ?int
{
return $this->id;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
public function getApikey(): ?string
{
return $this->apikey;
}
public function setApikey(string $apikey): self
{
$this->apikey = $apikey;
return $this;
}
public function getLdapfilter(): ?string
{
return $this->ldapfilter;
}
public function setLdapfilter(?string $ldapfilter): self
{
$this->ldapfilter = $ldapfilter;
return $this;
}
public function getAttributes(): ?string
{
return $this->attributes;
}
public function setAttributes(?string $attributes): self
{
$this->attributes = $attributes;
return $this;
}
public function getIdexternal(): ?string
{
return $this->idexternal;
}
public function setIdexternal(?string $idexternal): self
{
$this->idexternal = $idexternal;
return $this;
}
/**
* @return Collection<int, Niveau02>
*/
public function getNiveau02s(): Collection
{
return $this->niveau02s;
}
public function addNiveau02(Niveau02 $niveau02): self
{
if (!$this->niveau02s->contains($niveau02)) {
$this->niveau02s[] = $niveau02;
$niveau02->setNiveau01($this);
}
return $this;
}
public function removeNiveau02(Niveau02 $niveau02): self
{
if ($this->niveau02s->removeElement($niveau02)) {
// set the owning side to null (unless already changed)
if ($niveau02->getNiveau01() === $this) {
$niveau02->setNiveau01(null);
}
}
return $this;
}
/**
* @return Collection<int, Registration>
*/
public function getRegistrations(): Collection
{
return $this->registrations;
}
public function addRegistration(Registration $registration): self
{
if (!$this->registrations->contains($registration)) {
$this->registrations[] = $registration;
$registration->setNiveau01($this);
}
return $this;
}
public function removeRegistration(Registration $registration): self
{
if ($this->registrations->removeElement($registration)) {
// set the owning side to null (unless already changed)
if ($registration->getNiveau01() === $this) {
$registration->setNiveau01(null);
}
}
return $this;
}
/**
* @return Collection<int, User>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->setNiveau01($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->removeElement($user)) {
// set the owning side to null (unless already changed)
if ($user->getNiveau01() === $this) {
$user->setNiveau01(null);
}
}
return $this;
}
/**
* @return Collection<int, UserModo>
*/
public function getModos(): Collection
{
return $this->modos;
}
public function addModo(UserModo $modo): self
{
if (!$this->modos->contains($modo)) {
$this->modos[] = $modo;
$modo->setNiveau01($this);
}
return $this;
}
public function removeModo(UserModo $modo): self
{
if ($this->modos->removeElement($modo)) {
// set the owning side to null (unless already changed)
if ($modo->getNiveau01() === $this) {
$modo->setNiveau01(null);
}
}
return $this;
}
}

169
src/Entity/Niveau02.php Normal file
View File

@ -0,0 +1,169 @@
<?php
namespace App\Entity;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use App\Validator as Validator;
/**
* @ORM\Entity
* @ORM\Table(name="niveau02")
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity(repositoryClass="App\Repository\Niveau02Repository")
*
* @UniqueEntity(fields="label", message="Un Niveau de rang 2 existe déjà avec ce label")
*/
class Niveau02
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", length=250, unique=true)
* @Validator\Grouplabel()
* @Validator\Niveau02unique()
*/
private $label;
/**
* @ORM\Column(type="string")
*/
private $apikey;
/**
* @ORM\ManyToOne(targetEntity="Niveau01", inversedBy="niveau02s")
* @ORM\JoinColumn(nullable=false)
*/
private $niveau01;
/**
* @var ArrayCollection $registrations
* @var Registration
*
* @ORM\OneToMany(targetEntity="Registration", mappedBy="niveau02", cascade={"persist"}, orphanRemoval=false)
*/
private $registrations;
/**
* @var ArrayCollection $users
* @var User
*
* @ORM\OneToMany(targetEntity="User", mappedBy="niveau02", cascade={"persist"}, orphanRemoval=false)
*/
private $users;
public function __construct()
{
$this->registrations = new ArrayCollection();
$this->users = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
public function getApikey(): ?string
{
return $this->apikey;
}
public function setApikey(string $apikey): self
{
$this->apikey = $apikey;
return $this;
}
public function getNiveau01(): ?Niveau01
{
return $this->niveau01;
}
public function setNiveau01(?Niveau01 $niveau01): self
{
$this->niveau01 = $niveau01;
return $this;
}
/**
* @return Collection<int, Registration>
*/
public function getRegistrations(): Collection
{
return $this->registrations;
}
public function addRegistration(Registration $registration): self
{
if (!$this->registrations->contains($registration)) {
$this->registrations[] = $registration;
$registration->setNiveau02($this);
}
return $this;
}
public function removeRegistration(Registration $registration): self
{
if ($this->registrations->removeElement($registration)) {
// set the owning side to null (unless already changed)
if ($registration->getNiveau02() === $this) {
$registration->setNiveau02(null);
}
}
return $this;
}
/**
* @return Collection<int, User>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->setNiveau02($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->removeElement($user)) {
// set the owning side to null (unless already changed)
if ($user->getNiveau02() === $this) {
$user->setNiveau02(null);
}
}
return $this;
}
}

416
src/Entity/Registration.php Normal file
View File

@ -0,0 +1,416 @@
<?php
namespace App\Entity;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\LegacyPasswordAuthenticatedUserInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use App\Validator as Validator;
/**
* @ORM\Entity
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity(repositoryClass="App\Repository\RegistrationRepository")
*
* @UniqueEntity(fields="username", message="Un utilisateur existe déjà avec ce login.")
* @UniqueEntity(fields="email", message="Un utilisateur existe déjà avec ce mail.")
*/
class Registration implements UserInterface, LegacyPasswordAuthenticatedUserInterface
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", length=128, unique=true)
* @Validator\Userusername()
*/
private $username;
/**
* @ORM\Column(type="string", length=250, nullable=true)
*/
private $firstname;
/**
* @ORM\Column(type="string", length=250, nullable=true)
*/
private $lastname;
/**
* @ORM\Column(type="string", length=250)
*/
private $password;
/**
* @Validator\Password()
*/
private $passwordplain;
/**
* @ORM\Column(type="string", length=250)
*/
private $salt;
/**
* @ORM\Column(type="string", length=128, unique=true)
*/
private $email;
/**
* @ORM\Column(type="boolean")
*/
protected $isvisible;
/**
* @ORM\Column(type="string", length=250, nullable=true)
*/
private $postaladress;
/**
* @ORM\Column(type="string", length=60, nullable=true)
*/
private $telephonenumber;
/**
* @ORM\Column(type="string", length=250, nullable=true)
*/
private $job;
/**
* @ORM\Column(type="string", length=250, nullable=true)
*/
private $position;
/**
* @ORM\Column(name="motivation", type="text", nullable=true)
*/
private $motivation;
/**
* @ORM\Column(name="note", type="text", nullable=true)
*/
private $note;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $keyexpire;
/**
* @ORM\Column(type="string", length=60, nullable=true)
*/
private $keyvalue;
/**
* @ORM\Column(type="integer", length=60, nullable=false)
*/
private $statut;
/**
* @ORM\ManyToOne(targetEntity="Niveau01", inversedBy="registrations")
* @ORM\JoinColumn(nullable=false)
*/
private $niveau01;
/**
* @ORM\ManyToOne(targetEntity="Niveau02", inversedBy="registrations")
*/
private $niveau02;
//== CODE A NE PAS REGENERER
public function getUserIdentifier(): string
{
return $this->username;
}
public function setPasswordDirect($password)
{
// Permet de setter le password généré lors de l'inscription
$this->password = $password;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword($password): self
{
if($password!=$this->password&&$password!=""){
// Placer le password non encodé dans une variable tempo sur laquel on va appliquer la contraite de form
$this->passwordplain = $password;
// Password encrypté format openldap
$this->salt = uniqid(mt_rand(), true);
$hash = "{SSHA}" . base64_encode(pack("H*", sha1($password . $this->salt)) . $this->salt);
$this->password = $hash;
}
return $this;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return $this->salt;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
$this->passwordplain = null;
}
public function getRoles(): array
{
return $this->roles;
}
public function hasRole(string $role): ?bool
{
return in_array($role,$this->getRoles());
}
public function setRole(string $role): self
{
if(!$this->hasRole($role))
array_push($this->roles,$role);
return $this;
}
public function getDisplayname() {
return $this->firstname." ".$this->lastname;
}
//== FIN DU CODE A NE PAS REGENERER
public function getId(): ?int
{
return $this->id;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(?string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(?string $lastname): self
{
$this->lastname = $lastname;
return $this;
}
public function setSalt(string $salt): self
{
$this->salt = $salt;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function isIsvisible(): ?bool
{
return $this->isvisible;
}
public function setIsvisible(bool $isvisible): self
{
$this->isvisible = $isvisible;
return $this;
}
public function getPostaladress(): ?string
{
return $this->postaladress;
}
public function setPostaladress(?string $postaladress): self
{
$this->postaladress = $postaladress;
return $this;
}
public function getTelephonenumber(): ?string
{
return $this->telephonenumber;
}
public function setTelephonenumber(?string $telephonenumber): self
{
$this->telephonenumber = $telephonenumber;
return $this;
}
public function getJob(): ?string
{
return $this->job;
}
public function setJob(?string $job): self
{
$this->job = $job;
return $this;
}
public function getPosition(): ?string
{
return $this->position;
}
public function setPosition(?string $position): self
{
$this->position = $position;
return $this;
}
public function getMotivation(): ?string
{
return $this->motivation;
}
public function setMotivation(?string $motivation): self
{
$this->motivation = $motivation;
return $this;
}
public function getNote(): ?string
{
return $this->note;
}
public function setNote(?string $note): self
{
$this->note = $note;
return $this;
}
public function getKeyexpire(): ?\DateTimeInterface
{
return $this->keyexpire;
}
public function setKeyexpire(?\DateTimeInterface $keyexpire): self
{
$this->keyexpire = $keyexpire;
return $this;
}
public function getKeyvalue(): ?string
{
return $this->keyvalue;
}
public function setKeyvalue(?string $keyvalue): self
{
$this->keyvalue = $keyvalue;
return $this;
}
public function getStatut(): ?int
{
return $this->statut;
}
public function setStatut(int $statut): self
{
$this->statut = $statut;
return $this;
}
public function getNiveau01(): ?Niveau01
{
return $this->niveau01;
}
public function setNiveau01(?Niveau01 $niveau01): self
{
$this->niveau01 = $niveau01;
return $this;
}
public function getNiveau02(): ?Niveau02
{
return $this->niveau02;
}
public function setNiveau02(?Niveau02 $niveau02): self
{
$this->niveau02 = $niveau02;
return $this;
}
}

626
src/Entity/User.php Normal file
View File

@ -0,0 +1,626 @@
<?php
namespace App\Entity;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\LegacyPasswordAuthenticatedUserInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use App\Validator as Validator;
/**
* @ORM\Entity
* @ORM\Table(name="useraccount")
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
*
* @UniqueEntity(fields="username", message="Un utilisateur existe déjà avec ce login.")
* @UniqueEntity(fields="email", message="Un utilisateur existe déjà avec ce mail.")
*/
class User implements UserInterface, LegacyPasswordAuthenticatedUserInterface
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", length=128, unique=true)
* @Validator\Userusername()
*/
private $username;
/**
* @ORM\Column(type="string")
*/
private $apikey;
/**
* @ORM\Column(type="string", length=250, nullable=true)
*/
private $firstname;
/**
* @ORM\Column(type="string", length=250, nullable=true)
*/
private $lastname;
/**
* @var array
*
* @ORM\Column(type="array", length=255)
*/
private $roles = array();
/**
* @ORM\Column(type="string", length=250)
*/
private $password;
/**
* @Validator\Password()
*/
private $passwordplain;
/**
* @ORM\Column(type="string", length=250)
*/
private $salt;
/**
* @ORM\Column(type="string", length=128, unique=true)
*/
private $email;
/**
* @ORM\Column(type="string", length=250, nullable=true, options={"default" : 0})
*/
private $avatar;
/**
* @ORM\Column(type="boolean")
*/
protected $isvisible;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $postaladress;
/**
* @ORM\Column(type="string", length=60, nullable=true)
*/
private $telephonenumber;
/**
* @ORM\Column(type="string", length=250, nullable=true)
*/
private $job;
/**
* @ORM\Column(type="string", length=250, nullable=true)
*/
private $position;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $motivation;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $note;
/**
* @ORM\Column(type="array", nullable=true)
*/
private $preference;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $keyexpire;
/**
* @ORM\Column(type="string", length=60, nullable=true)
*/
private $keyvalue;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $visitedate;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $visitecpt;
/**
* @ORM\ManyToOne(targetEntity="Niveau01", inversedBy="users")
* @ORM\JoinColumn(nullable=false)
*/
private $niveau01;
/**
* @ORM\ManyToOne(targetEntity="Niveau02", inversedBy="users")
*/
private $niveau02;
/**
* @var ArrayCollection $groups
* @var UserGroup
*
* @ORM\OneToMany(targetEntity="UserGroup", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
*/
private $groups;
/**
* @var ArrayCollection $ownergroups
* @var Group
*
* @ORM\OneToMany(targetEntity="Group", mappedBy="owner", cascade={"persist"}, orphanRemoval=false)
*/
private $ownergroups;
/**
* @var ArrayCollection $groups
* @var UserGroup
*
* @ORM\OneToMany(targetEntity="UserModo", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
*/
private $modos;
public function __construct()
{
$this->groups = new ArrayCollection();
$this->ownergroups = new ArrayCollection();
$this->modos = new ArrayCollection();
}
//== CODE A NE PAS REGENERER
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
public function getUserIdentifier(): string
{
return $this->username;
}
public function setPasswordDirect($password)
{
// Permet de setter le password généré lors de l'inscription
$this->password = $password;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword($password): self
{
if($password!=$this->password&&$password!=""){
// Placer le password non encodé dans une variable tempo sur laquel on va appliquer la contraite de form
$this->passwordplain = $password;
// Password encrypté format openldap
$this->salt = uniqid(mt_rand(), true);
$hash = "{SSHA}" . base64_encode(pack("H*", sha1($password . $this->salt)) . $this->salt);
$this->password = $hash;
}
return $this;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return $this->salt;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
$this->passwordplain = null;
}
public function getRoles(): array
{
return $this->roles;
}
public function hasRole(string $role): ?bool
{
return in_array($role,$this->getRoles());
}
public function setRole(string $role): self
{
if(!$this->hasRole($role))
array_push($this->roles,$role);
return $this;
}
public function getDisplayname() {
return $this->firstname." ".$this->lastname;
}
//== FIN DU CODE A NE PAS REGENERER
public function getId(): ?int
{
return $this->id;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
public function getApikey(): ?string
{
return $this->apikey;
}
public function setApikey(string $apikey): self
{
$this->apikey = $apikey;
return $this;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(?string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(?string $lastname): self
{
$this->lastname = $lastname;
return $this;
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
public function setSalt(string $salt): self
{
$this->salt = $salt;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getAvatar(): ?string
{
return $this->avatar;
}
public function setAvatar(?string $avatar): self
{
$this->avatar = $avatar;
return $this;
}
public function isIsvisible(): ?bool
{
return $this->isvisible;
}
public function setIsvisible(bool $isvisible): self
{
$this->isvisible = $isvisible;
return $this;
}
public function getPostaladress(): ?string
{
return $this->postaladress;
}
public function setPostaladress(?string $postaladress): self
{
$this->postaladress = $postaladress;
return $this;
}
public function getTelephonenumber(): ?string
{
return $this->telephonenumber;
}
public function setTelephonenumber(?string $telephonenumber): self
{
$this->telephonenumber = $telephonenumber;
return $this;
}
public function getJob(): ?string
{
return $this->job;
}
public function setJob(?string $job): self
{
$this->job = $job;
return $this;
}
public function getPosition(): ?string
{
return $this->position;
}
public function setPosition(?string $position): self
{
$this->position = $position;
return $this;
}
public function getMotivation(): ?string
{
return $this->motivation;
}
public function setMotivation(?string $motivation): self
{
$this->motivation = $motivation;
return $this;
}
public function getNote(): ?string
{
return $this->note;
}
public function setNote(?string $note): self
{
$this->note = $note;
return $this;
}
public function getPreference(): ?array
{
return $this->preference;
}
public function setPreference(?array $preference): self
{
$this->preference = $preference;
return $this;
}
public function getKeyexpire(): ?\DateTimeInterface
{
return $this->keyexpire;
}
public function setKeyexpire(?\DateTimeInterface $keyexpire): self
{
$this->keyexpire = $keyexpire;
return $this;
}
public function getKeyvalue(): ?string
{
return $this->keyvalue;
}
public function setKeyvalue(?string $keyvalue): self
{
$this->keyvalue = $keyvalue;
return $this;
}
public function getVisitedate(): ?\DateTimeInterface
{
return $this->visitedate;
}
public function setVisitedate(?\DateTimeInterface $visitedate): self
{
$this->visitedate = $visitedate;
return $this;
}
public function getVisitecpt(): ?int
{
return $this->visitecpt;
}
public function setVisitecpt(?int $visitecpt): self
{
$this->visitecpt = $visitecpt;
return $this;
}
public function getNiveau01(): ?Niveau01
{
return $this->niveau01;
}
public function setNiveau01(?Niveau01 $niveau01): self
{
$this->niveau01 = $niveau01;
return $this;
}
public function getNiveau02(): ?Niveau02
{
return $this->niveau02;
}
public function setNiveau02(?Niveau02 $niveau02): self
{
$this->niveau02 = $niveau02;
return $this;
}
/**
* @return Collection<int, UserGroup>
*/
public function getGroups(): Collection
{
return $this->groups;
}
public function addGroup(UserGroup $group): self
{
if (!$this->groups->contains($group)) {
$this->groups[] = $group;
$group->setUser($this);
}
return $this;
}
public function removeGroup(UserGroup $group): self
{
if ($this->groups->removeElement($group)) {
// set the owning side to null (unless already changed)
if ($group->getUser() === $this) {
$group->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Group>
*/
public function getOwnergroups(): Collection
{
return $this->ownergroups;
}
public function addOwnergroup(Group $ownergroup): self
{
if (!$this->ownergroups->contains($ownergroup)) {
$this->ownergroups[] = $ownergroup;
$ownergroup->setOwner($this);
}
return $this;
}
public function removeOwnergroup(Group $ownergroup): self
{
if ($this->ownergroups->removeElement($ownergroup)) {
// set the owning side to null (unless already changed)
if ($ownergroup->getOwner() === $this) {
$ownergroup->setOwner(null);
}
}
return $this;
}
/**
* @return Collection<int, UserModo>
*/
public function getModos(): Collection
{
return $this->modos;
}
public function addModo(UserModo $modo): self
{
if (!$this->modos->contains($modo)) {
$this->modos[] = $modo;
$modo->setUser($this);
}
return $this;
}
public function removeModo(UserModo $modo): self
{
if ($this->modos->removeElement($modo)) {
// set the owning side to null (unless already changed)
if ($modo->getUser() === $this) {
$modo->setUser(null);
}
}
return $this;
}
}

132
src/Entity/UserGroup.php Normal file
View File

@ -0,0 +1,132 @@
<?php
namespace App\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity
* @ORM\Table(name="usergroupe",uniqueConstraints={@ORM\UniqueConstraint(columns={"user_id", "group_id"})})
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity(repositoryClass="App\Repository\UserGroupRepository")
*
* @UniqueEntity(fields={"user", "group"}, message="Cette liaison existe déjà !")
*/
class UserGroup
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="integer", length=60)
*/
private $rolegroup;
/**
* @ORM\Column(type="string", length=60)
*/
private $apikey;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $visitedate;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $visitecpt;
/**
* @ORM\ManyToOne(targetEntity="User", inversedBy="groups")
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity="Group", inversedBy="users")
*/
private $group;
public function getId(): ?int
{
return $this->id;
}
public function getRolegroup(): ?int
{
return $this->rolegroup;
}
public function setRolegroup(int $rolegroup): self
{
$this->rolegroup = $rolegroup;
return $this;
}
public function getApikey(): ?string
{
return $this->apikey;
}
public function setApikey(string $apikey): self
{
$this->apikey = $apikey;
return $this;
}
public function getVisitedate(): ?\DateTimeInterface
{
return $this->visitedate;
}
public function setVisitedate(?\DateTimeInterface $visitedate): self
{
$this->visitedate = $visitedate;
return $this;
}
public function getVisitecpt(): ?int
{
return $this->visitecpt;
}
public function setVisitecpt(?int $visitecpt): self
{
$this->visitecpt = $visitecpt;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getGroup(): ?Group
{
return $this->group;
}
public function setGroup(?Group $group): self
{
$this->group = $group;
return $this;
}
}

62
src/Entity/UserModo.php Normal file
View File

@ -0,0 +1,62 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity
* @ORM\Table(name="usermodo")
*
* @UniqueEntity(fields={"user", "niveau01"}, message="Cette liaison existe déjà !")
*/
class UserModo
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="User", inversedBy="modos")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
*/
private $user;
/**
* @ORM\ManyToOne(targetEntity="Niveau01", inversedBy="modos")
* @ORM\JoinColumn(name="niveau01_id", referencedColumnName="id", nullable=false)
*/
private $niveau01;
public function getId(): ?int
{
return $this->id;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getNiveau01(): ?Niveau01
{
return $this->niveau01;
}
public function setNiveau01(?Niveau01 $niveau01): self
{
$this->niveau01 = $niveau01;
return $this;
}
}

45
src/Entity/Whitelist.php Normal file
View File

@ -0,0 +1,45 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity
* @ORM\Table(name="whitelist")
* @ORM\HasLifecycleCallbacks()
*
* @UniqueEntity(fields="label", message="Une liste blanche existe déjà avec ce label")
*/
class Whitelist
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", length=250, unique=true)
*/
private $label;
public function getId(): ?int
{
return $this->id;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
}