src/Entity/Registration.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Symfony\Component\Security\Core\User\UserInterface;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use App\Validator as UserAssert;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. /**
  10.  * @ORM\Entity
  11.  * @ORM\Table(name="registration")
  12.  * @ORM\HasLifecycleCallbacks()
  13.  *
  14.  * @UniqueEntity(fields="username", message="Un utilisateur existe déjà avec ce login.")
  15.  * @UniqueEntity(fields="email", message="Un utilisateur existe déjà avec ce mail.")
  16.  */
  17. class Registration implements UserInterface, \Serializable
  18. {
  19.     /**
  20.      * @ORM\Column(type="integer")
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue(strategy="AUTO")
  23.      */
  24.     private $id;
  25.     /**
  26.      * @ORM\Column(type="string", length=128, unique=true)
  27.      * @Assert\Length(
  28.      *      min = "5",
  29.      *      max = "128",
  30.      *      minMessage = "Votre nom doit faire au moins {{ limit }} caractères",
  31.      *      maxMessage = "Votre nom ne peut pas être plus long que {{ limit }} caractères"
  32.      * )
  33.      */
  34.     private $username;
  35.     /**
  36.      * @ORM\Column(type="string", length=250, nullable=true)
  37.      */
  38.     private $firstname;
  39.     /**
  40.      * @ORM\Column(type="string", length=250, nullable=true)
  41.      */
  42.     private $lastname;
  43.     /**
  44.      * @ORM\Column(type="string", length=250)
  45.      */
  46.     private $password;
  47.     
  48.     /**
  49.      * @UserAssert\Password()
  50.      */
  51.     private $passwordplain;
  52.     /**
  53.      * @ORM\Column(type="string", length=250)
  54.      */
  55.     private $salt;
  56.     /**
  57.      * @ORM\Column(type="string", length=250, nullable=true)
  58.      */
  59.     private $passwordad;
  60.     private $ifad;
  61.     /**
  62.      * @ORM\Column(type="string", length=128, unique=true)
  63.      */
  64.     private $email;
  65.     /**
  66.      * @ORM\Column(name="visible", type="boolean")
  67.      */
  68.     protected $visible;
  69.     /**
  70.      * @ORM\Column(type="datetime", nullable=true)
  71.      */
  72.     private $keyexpire;    
  73.     /**
  74.      * @ORM\Column(type="string", length=60, nullable=true)
  75.      */
  76.     private $keyvalue;    
  77.     /**
  78.      * @ORM\ManyToOne(targetEntity="Statut", inversedBy="registrations")
  79.      * @ORM\JoinColumn(nullable=false)
  80.      */
  81.     private $statut;
  82.     /**
  83.      * @ORM\Column(type="string", length=60, nullable=true)
  84.      */
  85.     private $usualname;
  86.     /**
  87.      * @ORM\Column(type="string", length=60, nullable=true)
  88.      */
  89.     private $telephonenumber;
  90.     /**
  91.      * @ORM\Column(type="string", length=250, nullable=true)
  92.      */
  93.     private $postaladress;
  94.     /**
  95.      * @ORM\Column(type="string", length=250, nullable=true)
  96.      */
  97.     private $givensname;
  98.     /**
  99.      * @ORM\Column(type="date", nullable=true)
  100.      */
  101.     private $birthdate;
  102.     /**
  103.      * @ORM\Column(type="string", length=20, nullable=true)
  104.      */
  105.     private $gender;
  106.     /**
  107.      * @ORM\Column(type="string", length=250, nullable=true)
  108.      */
  109.     private $job;
  110.     
  111.     /**
  112.      * @ORM\Column(type="string", length=250, nullable=true)
  113.      */
  114.     private $position;    
  115.     /**
  116.      * @ORM\Column(type="string", length=150, nullable=true)
  117.      */
  118.     private $niveau01other;
  119.        
  120.     /**
  121.      * @ORM\Column(name="motivation", type="text", nullable=true)
  122.      */
  123.     private $motivation;
  124.     /**
  125.      * @ORM\Column(name="note", type="text", nullable=true)
  126.      */
  127.     private $note;
  128.     /**
  129.      * @ORM\Column(name="redirect", type="string", nullable=true)
  130.      */
  131.     private $redirect;
  132.     /**
  133.      * @ORM\Column(type="integer", length=60, nullable=true)
  134.      */
  135.     private $groupid;  
  136.     /**
  137.      * @ORM\ManyToOne(targetEntity="Country", inversedBy="registrations")
  138.      * @ORM\JoinColumn(nullable=true)
  139.      * @ORM\OrderBy({"label" = "ASC"})
  140.      */
  141.     private $birthcountry;
  142.     /**
  143.      * @ORM\ManyToOne(targetEntity="City", inversedBy="registrations")
  144.      * @ORM\JoinColumn(nullable=true)
  145.      */
  146.     private $birthplace;    
  147.     /**
  148.      * @ORM\ManyToOne(targetEntity="Niveau01", inversedBy="registrations")
  149.      * @ORM\JoinColumn(nullable=false)
  150.      */
  151.     private $niveau01;
  152.     /**
  153.      * @ORM\ManyToOne(targetEntity="Niveau02", inversedBy="registrations")
  154.      * @ORM\JoinColumn(nullable=true)
  155.      */
  156.     private $niveau02;    
  157. //== CODE A NE PAS REGENERER
  158.      
  159.     public function getUserName()
  160.     {
  161.         return $this->username;
  162.     }
  163.     public function getSalt()
  164.     {
  165.         return $this->salt;
  166.     }
  167.     public function setIfad($ifad) {
  168.         $this->ifad=$ifad;
  169.     }
  170.     public function setPassword($password)
  171.     {
  172.         if($password!=$this->password&&$password!=""){      
  173.             // Placer le password non encodé dans une variable tempo sur laquel on va appliquer la contraite
  174.             $this->passwordplain $password;
  175.             // Password encrypté format openldap           
  176.             $this->salt uniqid(mt_rand(), true);
  177.             $hash "{SSHA}" base64_encode(pack("H*"sha1($password $this->salt)) . $this->salt);
  178.             $this->password $hash;
  179.             // Password encrypté AD
  180.             if($this->ifad) {
  181.                 $newPassword "\"" $password "\"";
  182.                 $len strlen($newPassword);
  183.                 $newPassw "";
  184.                 for($i=0;$i<$len;$i++) {
  185.                     $newPassw .= "{".$newPassword."{".$i."}}\000";
  186.                 }   
  187.                 $this->passwordad $newPassw;
  188.             }
  189.         }
  190.         
  191.         return $this;
  192.     }
  193.     public function getPassword()
  194.     {
  195.         return $this->password;
  196.     }  
  197.     public function getRoles()
  198.     {
  199.     }
  200.     public function eraseCredentials()
  201.     {
  202.     }
  203.     
  204.     /** @see \Serializable::serialize() */
  205.     public function serialize()
  206.     {
  207.         return serialize(array(
  208.             $this->id,
  209.             $this->username,
  210.             $this->password,
  211.             $this->salt,
  212.         ));
  213.     }
  214.     /** @see \Serializable::unserialize() */
  215.     public function unserialize($serialized)
  216.     {
  217.         list (
  218.             $this->id,
  219.             $this->login,
  220.             $this->password,
  221.             $this->salt
  222.         ) = unserialize($serialized);
  223.     }
  224. //== FIN DU CODE A NE PAS REGENERER  
  225.     /**
  226.      * Get id
  227.      *
  228.      * @return integer
  229.      */
  230.     public function getId()
  231.     {
  232.         return $this->id;
  233.     }
  234.     /**
  235.      * Set username
  236.      *
  237.      * @param string $username
  238.      *
  239.      * @return Registration
  240.      */
  241.     public function setUsername($username)
  242.     {
  243.         $this->username $username;
  244.         return $this;
  245.     }
  246.     /**
  247.      * Set firstname
  248.      *
  249.      * @param string $firstname
  250.      *
  251.      * @return Registration
  252.      */
  253.     public function setFirstname($firstname)
  254.     {
  255.         $this->firstname $firstname;
  256.         return $this;
  257.     }
  258.     /**
  259.      * Get firstname
  260.      *
  261.      * @return string
  262.      */
  263.     public function getFirstname()
  264.     {
  265.         return $this->firstname;
  266.     }
  267.     /**
  268.      * Set lastname
  269.      *
  270.      * @param string $lastname
  271.      *
  272.      * @return Registration
  273.      */
  274.     public function setLastname($lastname)
  275.     {
  276.         $this->lastname $lastname;
  277.         return $this;
  278.     }
  279.     /**
  280.      * Get lastname
  281.      *
  282.      * @return string
  283.      */
  284.     public function getLastname()
  285.     {
  286.         return $this->lastname;
  287.     }
  288.     /**
  289.      * Set salt
  290.      *
  291.      * @param string $salt
  292.      *
  293.      * @return Registration
  294.      */
  295.     public function setSalt($salt)
  296.     {
  297.         $this->salt $salt;
  298.         return $this;
  299.     }
  300.     /**
  301.      * Set email
  302.      *
  303.      * @param string $email
  304.      *
  305.      * @return Registration
  306.      */
  307.     public function setEmail($email)
  308.     {
  309.         $this->email $email;
  310.         return $this;
  311.     }
  312.     /**
  313.      * Get email
  314.      *
  315.      * @return string
  316.      */
  317.     public function getEmail()
  318.     {
  319.         return $this->email;
  320.     }
  321.     /**
  322.      * Set visible
  323.      *
  324.      * @param boolean $visible
  325.      *
  326.      * @return Registration
  327.      */
  328.     public function setVisible($visible)
  329.     {
  330.         $this->visible $visible;
  331.         return $this;
  332.     }
  333.     /**
  334.      * Get visible
  335.      *
  336.      * @return boolean
  337.      */
  338.     public function getVisible()
  339.     {
  340.         return $this->visible;
  341.     }
  342.     /**
  343.      * Set keyexpire
  344.      *
  345.      * @param \DateTime $keyexpire
  346.      *
  347.      * @return Registration
  348.      */
  349.     public function setKeyexpire($keyexpire)
  350.     {
  351.         $this->keyexpire $keyexpire;
  352.         return $this;
  353.     }
  354.     /**
  355.      * Get keyexpire
  356.      *
  357.      * @return \DateTime
  358.      */
  359.     public function getKeyexpire()
  360.     {
  361.         return $this->keyexpire;
  362.     }
  363.     /**
  364.      * Set keyvalue
  365.      *
  366.      * @param string $keyvalue
  367.      *
  368.      * @return Registration
  369.      */
  370.     public function setKeyvalue($keyvalue)
  371.     {
  372.         $this->keyvalue $keyvalue;
  373.         return $this;
  374.     }
  375.     /**
  376.      * Get keyvalue
  377.      *
  378.      * @return string
  379.      */
  380.     public function getKeyvalue()
  381.     {
  382.         return $this->keyvalue;
  383.     }
  384.     /**
  385.      * Set usualname
  386.      *
  387.      * @param string $usualname
  388.      *
  389.      * @return Registration
  390.      */
  391.     public function setUsualname($usualname)
  392.     {
  393.         $this->usualname $usualname;
  394.         return $this;
  395.     }
  396.     /**
  397.      * Get usualname
  398.      *
  399.      * @return string
  400.      */
  401.     public function getUsualname()
  402.     {
  403.         return $this->usualname;
  404.     }
  405.     /**
  406.      * Set telephonenumber
  407.      *
  408.      * @param string $telephonenumber
  409.      *
  410.      * @return Registration
  411.      */
  412.     public function setTelephonenumber($telephonenumber)
  413.     {
  414.         $this->telephonenumber $telephonenumber;
  415.         return $this;
  416.     }
  417.     /**
  418.      * Get telephonenumber
  419.      *
  420.      * @return string
  421.      */
  422.     public function getTelephonenumber()
  423.     {
  424.         return $this->telephonenumber;
  425.     }
  426.     /**
  427.      * Set postaladress
  428.      *
  429.      * @param string $postaladress
  430.      *
  431.      * @return Registration
  432.      */
  433.     public function setPostaladress($postaladress)
  434.     {
  435.         $this->postaladress $postaladress;
  436.         return $this;
  437.     }
  438.     /**
  439.      * Get postaladress
  440.      *
  441.      * @return string
  442.      */
  443.     public function getPostaladress()
  444.     {
  445.         return $this->postaladress;
  446.     }
  447.     /**
  448.      * Set givensname
  449.      *
  450.      * @param string $givensname
  451.      *
  452.      * @return Registration
  453.      */
  454.     public function setGivensname($givensname)
  455.     {
  456.         $this->givensname $givensname;
  457.         return $this;
  458.     }
  459.     /**
  460.      * Get givensname
  461.      *
  462.      * @return string
  463.      */
  464.     public function getGivensname()
  465.     {
  466.         return $this->givensname;
  467.     }
  468.     /**
  469.      * Set birthdate
  470.      *
  471.      * @param \DateTime $birthdate
  472.      *
  473.      * @return Registration
  474.      */
  475.     public function setBirthdate($birthdate)
  476.     {
  477.         $this->birthdate $birthdate;
  478.         return $this;
  479.     }
  480.     /**
  481.      * Get birthdate
  482.      *
  483.      * @return \DateTime
  484.      */
  485.     public function getBirthdate()
  486.     {
  487.         return $this->birthdate;
  488.     }
  489.     /**
  490.      * Set gender
  491.      *
  492.      * @param string $gender
  493.      *
  494.      * @return Registration
  495.      */
  496.     public function setGender($gender)
  497.     {
  498.         $this->gender $gender;
  499.         return $this;
  500.     }
  501.     /**
  502.      * Get gender
  503.      *
  504.      * @return string
  505.      */
  506.     public function getGender()
  507.     {
  508.         return $this->gender;
  509.     }
  510.     /**
  511.      * Set job
  512.      *
  513.      * @param string $job
  514.      *
  515.      * @return Registration
  516.      */
  517.     public function setJob($job)
  518.     {
  519.         $this->job $job;
  520.         return $this;
  521.     }
  522.     /**
  523.      * Get job
  524.      *
  525.      * @return string
  526.      */
  527.     public function getJob()
  528.     {
  529.         return $this->job;
  530.     }
  531.     /**
  532.      * Set position
  533.      *
  534.      * @param string $position
  535.      *
  536.      * @return Registration
  537.      */
  538.     public function setPosition($position)
  539.     {
  540.         $this->position $position;
  541.         return $this;
  542.     }
  543.     /**
  544.      * Get position
  545.      *
  546.      * @return string
  547.      */
  548.     public function getPosition()
  549.     {
  550.         return $this->position;
  551.     }
  552.     /**
  553.      * Set statut
  554.      *
  555.      * @param Statut $statut
  556.      *
  557.      * @return Registration
  558.      */
  559.     public function setStatut(Statut $statut)
  560.     {
  561.         $this->statut $statut;
  562.         return $this;
  563.     }
  564.     /**
  565.      * Get statut
  566.      *
  567.      * @return Statut
  568.      */
  569.     public function getStatut()
  570.     {
  571.         return $this->statut;
  572.     }
  573.     /**
  574.      * Set birthcountry
  575.      *
  576.      * @param Country $birthcountry
  577.      *
  578.      * @return Registration
  579.      */
  580.     public function setBirthcountry(Country $birthcountry null)
  581.     {
  582.         $this->birthcountry $birthcountry;
  583.         return $this;
  584.     }
  585.     /**
  586.      * Get birthcountry
  587.      *
  588.      * @return Country
  589.      */
  590.     public function getBirthcountry()
  591.     {
  592.         return $this->birthcountry;
  593.     }
  594.     /**
  595.      * Set birthplace
  596.      *
  597.      * @param City $birthplace
  598.      *
  599.      * @return Registration
  600.      */
  601.     public function setBirthplace(City $birthplace null)
  602.     {
  603.         $this->birthplace $birthplace;
  604.         return $this;
  605.     }
  606.     /**
  607.      * Get birthplace
  608.      *
  609.      * @return City
  610.      */
  611.     public function getBirthplace()
  612.     {
  613.         return $this->birthplace;
  614.     }
  615.     /**
  616.      * Set niveau01
  617.      *
  618.      * @param Niveau01 $niveau01
  619.      *
  620.      * @return Registration
  621.      */
  622.     public function setNiveau01(Niveau01 $niveau01)
  623.     {
  624.         $this->niveau01 $niveau01;
  625.         return $this;
  626.     }
  627.     /**
  628.      * Get niveau01
  629.      *
  630.      * @return Niveau01
  631.      */
  632.     public function getNiveau01()
  633.     {
  634.         return $this->niveau01;
  635.     }
  636.     /**
  637.      * Set niveau02
  638.      *
  639.      * @param Niveau02 $niveau02
  640.      *
  641.      * @return Registration
  642.      */
  643.     public function setNiveau02(Niveau02 $niveau02 null)
  644.     {
  645.         $this->niveau02 $niveau02;
  646.         return $this;
  647.     }
  648.     /**
  649.      * Get niveau02
  650.      *
  651.      * @return Niveau02
  652.      */
  653.     public function getNiveau02()
  654.     {
  655.         return $this->niveau02;
  656.     }
  657.     /**
  658.      * Set groupid
  659.      *
  660.      * @param integer $groupid
  661.      *
  662.      * @return Registration
  663.      */
  664.     public function setGroupid($groupid)
  665.     {
  666.         $this->groupid $groupid;
  667.         return $this;
  668.     }
  669.     /**
  670.      * Get groupid
  671.      *
  672.      * @return integer
  673.      */
  674.     public function getGroupid()
  675.     {
  676.         return $this->groupid;
  677.     }
  678.     /**
  679.      * Set niveau01other
  680.      *
  681.      * @param string $niveau01other
  682.      *
  683.      * @return Registration
  684.      */
  685.     public function setNiveau01other($niveau01other)
  686.     {
  687.         $this->niveau01other $niveau01other;
  688.         return $this;
  689.     }
  690.     /**
  691.      * Get niveau01other
  692.      *
  693.      * @return string
  694.      */
  695.     public function getNiveau01other()
  696.     {
  697.         return $this->niveau01other;
  698.     }
  699.     /**
  700.      * Set motivation
  701.      *
  702.      * @param string $motivation
  703.      *
  704.      * @return Registration
  705.      */
  706.     public function setMotivation($motivation)
  707.     {
  708.         $this->motivation $motivation;
  709.         return $this;
  710.     }
  711.     /**
  712.      * Get motivation
  713.      *
  714.      * @return string
  715.      */
  716.     public function getMotivation()
  717.     {
  718.         return $this->motivation;
  719.     }
  720.     /**
  721.      * Set passwordad.
  722.      *
  723.      * @param string|null $passwordad
  724.      *
  725.      * @return Registration
  726.      */
  727.     public function setPasswordad($passwordad null)
  728.     {
  729.         $this->passwordad $passwordad;
  730.         return $this;
  731.     }
  732.     /**
  733.      * Get passwordad.
  734.      *
  735.      * @return string|null
  736.      */
  737.     public function getPasswordad()
  738.     {
  739.         return $this->passwordad;
  740.     }
  741.     /**
  742.      * Set note
  743.      *
  744.      * @param string $note
  745.      *
  746.      * @return Registration
  747.      */
  748.     public function setNote($note)
  749.     {
  750.         $this->note $note;
  751.         return $this;
  752.     }
  753.     /**
  754.      * Get note
  755.      *
  756.      * @return string
  757.      */
  758.     public function getNote()
  759.     {
  760.         return $this->note;
  761.     }
  762.     /**
  763.      * Set redirect
  764.      *
  765.      * @param string $redirect
  766.      *
  767.      * @return Registration
  768.      */
  769.     public function setRedirect($redirect)
  770.     {
  771.         $this->redirect $redirect;
  772.         return $this;
  773.     }
  774.     /**
  775.      * Get redirect
  776.      *
  777.      * @return string
  778.      */
  779.     public function getRedirect()
  780.     {
  781.         return $this->redirect;
  782.     }
  783. }