ninegate/src/ninegate-1.0/src/Cadoles/CoreBundle/Entity/User.php

1260 lines
24 KiB
PHP

<?php
namespace Cadoles\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
use Cadoles\CoreBundle\Validator\Password;
/**
* @ORM\Entity
* @ORM\Table(name="user")
* @ORM\HasLifecycleCallbacks()
*
* @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, \Serializable
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", length=50, unique=true)
*/
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;
/**
* @ORM\Column(type="string", length=250)
*/
private $salt;
/**
* @Password()
*/
private $tempopassword;
/**
* @ORM\Column(type="string", length=60, unique=true)
*/
private $email;
/**
* @ORM\Column(name="visible", type="boolean")
*/
protected $visible;
/**
* @ORM\Column(type="string", length=60, nullable=true, options={"default" : 0})
*/
private $avatar;
/**
* @ORM\Column(type="string", length=60)
*/
private $role;
/**
* @ORM\Column(type="string", length=60)
*/
private $authlevel;
/**
* @ORM\Column(type="string", length=9)
*/
private $siren;
/**
* @ORM\Column(type="string", length=14, nullable=true)
*/
private $siret;
/**
* @ORM\Column(type="string", length=60, nullable=true)
*/
private $usualname;
/**
* @ORM\Column(type="string", length=60, nullable=true)
*/
private $telephonenumber;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $postaladress;
/**
* @ORM\Column(type="string", length=250, nullable=true)
*/
private $givensname;
/**
* @ORM\Column(type="date", nullable=true)
*/
private $birthdate;
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
private $gender;
/**
* @ORM\Column(type="string", length=250, nullable=true)
*/
private $job;
/**
* @ORM\Column(type="string", length=250, nullable=true)
*/
private $position;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $keyexpire;
/**
* @ORM\Column(type="string", length=60, nullable=true)
*/
private $keyvalue;
/**
* @ORM\Column(type="string", length=250, nullable=true)
*/
private $belongingpopulation;
/**
* @ORM\ManyToOne(targetEntity="Country", inversedBy="users")
* @ORM\JoinColumn(nullable=true)
*/
private $birthcountry;
/**
* @ORM\ManyToOne(targetEntity="City", inversedBy="users")
* @ORM\JoinColumn(nullable=true)
*/
private $birthplace;
/**
* @ORM\ManyToOne(targetEntity="Niveau01", inversedBy="users")
* @ORM\JoinColumn(nullable=false)
*/
private $niveau01;
/**
* @ORM\ManyToOne(targetEntity="Niveau02", inversedBy="users")
* @ORM\JoinColumn(nullable=true)
*/
private $niveau02;
/**
* @var ArrayCollection $groups
* @var UserGroup
*
* @ORM\OneToMany(targetEntity="UserGroup", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
*/
private $groups;
/**
* @var ArrayCollection $groups
* @var UserGroup
*
* @ORM\OneToMany(targetEntity="UserModo", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
*/
private $modos;
/**
* @var ArrayCollection $page
* @var Page
*
* @ORM\OneToMany(targetEntity="Cadoles\PortalBundle\Entity\Page", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
*/
private $pages;
/**
* @var ArrayCollection $bookmark
* @var Bookmark
*
* @ORM\OneToMany(targetEntity="Cadoles\PortalBundle\Entity\Bookmark", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
*/
private $bookmarks;
/**
* @var ArrayCollection $calendar
* @var Calendar
*
* @ORM\OneToMany(targetEntity="Cadoles\PortalBundle\Entity\Calendar", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
*/
private $calendars;
/**
* @ORM\ManyToMany(targetEntity="Cadoles\PortalBundle\Entity\Notice", mappedBy="users")
*/
protected $notices;
/**
* @var ArrayCollection $blog
* @var Blog
*
* @ORM\OneToMany(targetEntity="Cadoles\PortalBundle\Entity\Blog", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
*/
private $blogs;
/**
* @ORM\ManyToMany(targetEntity="Cadoles\PortalBundle\Entity\Blog", mappedBy="writers")
*/
protected $blogwriters;
/**
* @var ArrayCollection $blogarticle
* @var Blogarticle
*
* @ORM\OneToMany(targetEntity="Cadoles\PortalBundle\Entity\Blogarticle", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
*/
private $blogarticles;
//== CODE A NE PAS REGENERER
/**
* @ORM\PostLoad
*/
public function PostLoad() {
if($this->getAvatar()=="") {
$this->setAvatar("noavatar.png");
}
}
public function getUserName()
{
return $this->username;
}
public function getSalt()
{
return $this->salt;
}
public function setPassword($password)
{
if($password!=$this->password&&$password!=""){
$this->tempopassword=$password;
mt_srand((double)microtime()*1000000);
$this->salt = pack("CCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand());
$hash = "{SSHA}" . base64_encode(pack("H*", sha1($password . $this->salt)) . $this->salt);
$this->password = $hash;
}
return $this;
}
public function setPasswordDirect($password)
{
$this->password = $password;
return $this;
}
public function getPassword()
{
return $this->password;
}
public function getRoles()
{
return explode(",",$this->role);
}
public function eraseCredentials()
{
}
/** @see \Serializable::serialize() */
public function serialize()
{
return serialize(array(
$this->id,
$this->username,
$this->password,
$this->salt,
));
}
/** @see \Serializable::unserialize() */
public function unserialize($serialized)
{
list (
$this->id,
$this->login,
$this->password,
$this->salt
) = unserialize($serialized);
}
//== FIN DU CODE A NE PAS REGENERER
/**
* Constructor
*/
public function __construct()
{
$this->groups = new \Doctrine\Common\Collections\ArrayCollection();
$this->modos = new \Doctrine\Common\Collections\ArrayCollection();
$this->pages = new \Doctrine\Common\Collections\ArrayCollection();
$this->bookmarks = new \Doctrine\Common\Collections\ArrayCollection();
$this->calendars = new \Doctrine\Common\Collections\ArrayCollection();
$this->notices = new \Doctrine\Common\Collections\ArrayCollection();
$this->blogs = new \Doctrine\Common\Collections\ArrayCollection();
$this->blogwriters = new \Doctrine\Common\Collections\ArrayCollection();
$this->blogarticles = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set username
*
* @param string $username
*
* @return User
*/
public function setUsername($username)
{
$this->username = $username;
return $this;
}
/**
* Set firstname
*
* @param string $firstname
*
* @return User
*/
public function setFirstname($firstname)
{
$this->firstname = $firstname;
return $this;
}
/**
* Get firstname
*
* @return string
*/
public function getFirstname()
{
return $this->firstname;
}
/**
* Set lastname
*
* @param string $lastname
*
* @return User
*/
public function setLastname($lastname)
{
$this->lastname = $lastname;
return $this;
}
/**
* Get lastname
*
* @return string
*/
public function getLastname()
{
return $this->lastname;
}
/**
* Set salt
*
* @param string $salt
*
* @return User
*/
public function setSalt($salt)
{
$this->salt = $salt;
return $this;
}
/**
* Set email
*
* @param string $email
*
* @return User
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Get email
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Set visible
*
* @param boolean $visible
*
* @return User
*/
public function setVisible($visible)
{
$this->visible = $visible;
return $this;
}
/**
* Get visible
*
* @return boolean
*/
public function getVisible()
{
return $this->visible;
}
/**
* Set avatar
*
* @param string $avatar
*
* @return User
*/
public function setAvatar($avatar)
{
$this->avatar = $avatar;
return $this;
}
/**
* Get avatar
*
* @return string
*/
public function getAvatar()
{
return $this->avatar;
}
/**
* Set role
*
* @param string $role
*
* @return User
*/
public function setRole($role)
{
$this->role = $role;
return $this;
}
/**
* Get role
*
* @return string
*/
public function getRole()
{
return $this->role;
}
/**
* Set authlevel
*
* @param string $authlevel
*
* @return User
*/
public function setAuthlevel($authlevel)
{
$this->authlevel = $authlevel;
return $this;
}
/**
* Get authlevel
*
* @return string
*/
public function getAuthlevel()
{
return $this->authlevel;
}
/**
* Set siren
*
* @param string $siren
*
* @return User
*/
public function setSiren($siren)
{
$this->siren = $siren;
return $this;
}
/**
* Get siren
*
* @return string
*/
public function getSiren()
{
return $this->siren;
}
/**
* Set siret
*
* @param string $siret
*
* @return User
*/
public function setSiret($siret)
{
$this->siret = $siret;
return $this;
}
/**
* Get siret
*
* @return string
*/
public function getSiret()
{
return $this->siret;
}
/**
* Set usualname
*
* @param string $usualname
*
* @return User
*/
public function setUsualname($usualname)
{
$this->usualname = $usualname;
return $this;
}
/**
* Get usualname
*
* @return string
*/
public function getUsualname()
{
return $this->usualname;
}
/**
* Set telephonenumber
*
* @param string $telephonenumber
*
* @return User
*/
public function setTelephonenumber($telephonenumber)
{
$this->telephonenumber = $telephonenumber;
return $this;
}
/**
* Get telephonenumber
*
* @return string
*/
public function getTelephonenumber()
{
return $this->telephonenumber;
}
/**
* Set postaladress
*
* @param string $postaladress
*
* @return User
*/
public function setPostaladress($postaladress)
{
$this->postaladress = $postaladress;
return $this;
}
/**
* Get postaladress
*
* @return string
*/
public function getPostaladress()
{
return $this->postaladress;
}
/**
* Set givensname
*
* @param string $givensname
*
* @return User
*/
public function setGivensname($givensname)
{
$this->givensname = $givensname;
return $this;
}
/**
* Get givensname
*
* @return string
*/
public function getGivensname()
{
return $this->givensname;
}
/**
* Set birthdate
*
* @param \DateTime $birthdate
*
* @return User
*/
public function setBirthdate($birthdate)
{
$this->birthdate = $birthdate;
return $this;
}
/**
* Get birthdate
*
* @return \DateTime
*/
public function getBirthdate()
{
return $this->birthdate;
}
/**
* Set gender
*
* @param string $gender
*
* @return User
*/
public function setGender($gender)
{
$this->gender = $gender;
return $this;
}
/**
* Get gender
*
* @return string
*/
public function getGender()
{
return $this->gender;
}
/**
* Set job
*
* @param string $job
*
* @return User
*/
public function setJob($job)
{
$this->job = $job;
return $this;
}
/**
* Get job
*
* @return string
*/
public function getJob()
{
return $this->job;
}
/**
* Set position
*
* @param string $position
*
* @return User
*/
public function setPosition($position)
{
$this->position = $position;
return $this;
}
/**
* Get position
*
* @return string
*/
public function getPosition()
{
return $this->position;
}
/**
* Set keyexpire
*
* @param \DateTime $keyexpire
*
* @return User
*/
public function setKeyexpire($keyexpire)
{
$this->keyexpire = $keyexpire;
return $this;
}
/**
* Get keyexpire
*
* @return \DateTime
*/
public function getKeyexpire()
{
return $this->keyexpire;
}
/**
* Set keyvalue
*
* @param string $keyvalue
*
* @return User
*/
public function setKeyvalue($keyvalue)
{
$this->keyvalue = $keyvalue;
return $this;
}
/**
* Get keyvalue
*
* @return string
*/
public function getKeyvalue()
{
return $this->keyvalue;
}
/**
* Set belongingpopulation
*
* @param string $belongingpopulation
*
* @return User
*/
public function setBelongingpopulation($belongingpopulation)
{
$this->belongingpopulation = $belongingpopulation;
return $this;
}
/**
* Get belongingpopulation
*
* @return string
*/
public function getBelongingpopulation()
{
return $this->belongingpopulation;
}
/**
* Set birthcountry
*
* @param \Cadoles\CoreBundle\Entity\Country $birthcountry
*
* @return User
*/
public function setBirthcountry(\Cadoles\CoreBundle\Entity\Country $birthcountry = null)
{
$this->birthcountry = $birthcountry;
return $this;
}
/**
* Get birthcountry
*
* @return \Cadoles\CoreBundle\Entity\Country
*/
public function getBirthcountry()
{
return $this->birthcountry;
}
/**
* Set birthplace
*
* @param \Cadoles\CoreBundle\Entity\City $birthplace
*
* @return User
*/
public function setBirthplace(\Cadoles\CoreBundle\Entity\City $birthplace = null)
{
$this->birthplace = $birthplace;
return $this;
}
/**
* Get birthplace
*
* @return \Cadoles\CoreBundle\Entity\City
*/
public function getBirthplace()
{
return $this->birthplace;
}
/**
* Set niveau01
*
* @param \Cadoles\CoreBundle\Entity\Niveau01 $niveau01
*
* @return User
*/
public function setNiveau01(\Cadoles\CoreBundle\Entity\Niveau01 $niveau01)
{
$this->niveau01 = $niveau01;
return $this;
}
/**
* Get niveau01
*
* @return \Cadoles\CoreBundle\Entity\Niveau01
*/
public function getNiveau01()
{
return $this->niveau01;
}
/**
* Set niveau02
*
* @param \Cadoles\CoreBundle\Entity\Niveau02 $niveau02
*
* @return User
*/
public function setNiveau02(\Cadoles\CoreBundle\Entity\Niveau02 $niveau02 = null)
{
$this->niveau02 = $niveau02;
return $this;
}
/**
* Get niveau02
*
* @return \Cadoles\CoreBundle\Entity\Niveau02
*/
public function getNiveau02()
{
return $this->niveau02;
}
/**
* Add group
*
* @param \Cadoles\CoreBundle\Entity\UserGroup $group
*
* @return User
*/
public function addGroup(\Cadoles\CoreBundle\Entity\UserGroup $group)
{
$this->groups[] = $group;
return $this;
}
/**
* Remove group
*
* @param \Cadoles\CoreBundle\Entity\UserGroup $group
*/
public function removeGroup(\Cadoles\CoreBundle\Entity\UserGroup $group)
{
$this->groups->removeElement($group);
}
/**
* Get groups
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getGroups()
{
return $this->groups;
}
/**
* Add modo
*
* @param \Cadoles\CoreBundle\Entity\UserModo $modo
*
* @return User
*/
public function addModo(\Cadoles\CoreBundle\Entity\UserModo $modo)
{
$this->modos[] = $modo;
return $this;
}
/**
* Remove modo
*
* @param \Cadoles\CoreBundle\Entity\UserModo $modo
*/
public function removeModo(\Cadoles\CoreBundle\Entity\UserModo $modo)
{
$this->modos->removeElement($modo);
}
/**
* Get modos
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getModos()
{
return $this->modos;
}
/**
* Add page
*
* @param \Cadoles\PortalBundle\Entity\Page $page
*
* @return User
*/
public function addPage(\Cadoles\PortalBundle\Entity\Page $page)
{
$this->pages[] = $page;
return $this;
}
/**
* Remove page
*
* @param \Cadoles\PortalBundle\Entity\Page $page
*/
public function removePage(\Cadoles\PortalBundle\Entity\Page $page)
{
$this->pages->removeElement($page);
}
/**
* Get pages
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getPages()
{
return $this->pages;
}
/**
* Add bookmark
*
* @param \Cadoles\PortalBundle\Entity\Bookmark $bookmark
*
* @return User
*/
public function addBookmark(\Cadoles\PortalBundle\Entity\Bookmark $bookmark)
{
$this->bookmarks[] = $bookmark;
return $this;
}
/**
* Remove bookmark
*
* @param \Cadoles\PortalBundle\Entity\Bookmark $bookmark
*/
public function removeBookmark(\Cadoles\PortalBundle\Entity\Bookmark $bookmark)
{
$this->bookmarks->removeElement($bookmark);
}
/**
* Get bookmarks
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getBookmarks()
{
return $this->bookmarks;
}
/**
* Add calendar
*
* @param \Cadoles\PortalBundle\Entity\Calendar $calendar
*
* @return User
*/
public function addCalendar(\Cadoles\PortalBundle\Entity\Calendar $calendar)
{
$this->calendars[] = $calendar;
return $this;
}
/**
* Remove calendar
*
* @param \Cadoles\PortalBundle\Entity\Calendar $calendar
*/
public function removeCalendar(\Cadoles\PortalBundle\Entity\Calendar $calendar)
{
$this->calendars->removeElement($calendar);
}
/**
* Get calendars
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getCalendars()
{
return $this->calendars;
}
/**
* Add notice
*
* @param \Cadoles\PortalBundle\Entity\Notice $notice
*
* @return User
*/
public function addNotice(\Cadoles\PortalBundle\Entity\Notice $notice)
{
$this->notices[] = $notice;
return $this;
}
/**
* Remove notice
*
* @param \Cadoles\PortalBundle\Entity\Notice $notice
*/
public function removeNotice(\Cadoles\PortalBundle\Entity\Notice $notice)
{
$this->notices->removeElement($notice);
}
/**
* Get notices
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getNotices()
{
return $this->notices;
}
/**
* Add blog
*
* @param \Cadoles\PortalBundle\Entity\Blog $blog
*
* @return User
*/
public function addBlog(\Cadoles\PortalBundle\Entity\Blog $blog)
{
$this->blogs[] = $blog;
return $this;
}
/**
* Remove blog
*
* @param \Cadoles\PortalBundle\Entity\Blog $blog
*/
public function removeBlog(\Cadoles\PortalBundle\Entity\Blog $blog)
{
$this->blogs->removeElement($blog);
}
/**
* Get blogs
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getBlogs()
{
return $this->blogs;
}
/**
* Add blogwriter
*
* @param \Cadoles\PortalBundle\Entity\Blog $blogwriter
*
* @return User
*/
public function addBlogwriter(\Cadoles\PortalBundle\Entity\Blog $blogwriter)
{
$this->blogwriters[] = $blogwriter;
return $this;
}
/**
* Remove blogwriter
*
* @param \Cadoles\PortalBundle\Entity\Blog $blogwriter
*/
public function removeBlogwriter(\Cadoles\PortalBundle\Entity\Blog $blogwriter)
{
$this->blogwriters->removeElement($blogwriter);
}
/**
* Get blogwriters
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getBlogwriters()
{
return $this->blogwriters;
}
/**
* Add blogarticle
*
* @param \Cadoles\PortalBundle\Entity\Blogarticle $blogarticle
*
* @return User
*/
public function addBlogarticle(\Cadoles\PortalBundle\Entity\Blogarticle $blogarticle)
{
$this->blogarticles[] = $blogarticle;
return $this;
}
/**
* Remove blogarticle
*
* @param \Cadoles\PortalBundle\Entity\Blogarticle $blogarticle
*/
public function removeBlogarticle(\Cadoles\PortalBundle\Entity\Blogarticle $blogarticle)
{
$this->blogarticles->removeElement($blogarticle);
}
/**
* Get blogarticles
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getBlogarticles()
{
return $this->blogarticles;
}
}