<?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 Cadoles\CoreBundle\Validator as CadolesCoreAssert;
use Symfony\Component\Validator\Constraints as Assert;




/**
 * @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=128, unique=true)
     * @Assert\Length(
     *      min = "5",
     *      max = "128",
     *      minMessage = "Votre nom doit faire au moins {{ limit }} caractères",
     *      maxMessage = "Votre nom ne peut pas être plus long que {{ limit }} caractères"
     * )
     */
    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;
    
    /**
     * @CadolesCoreAssert\Password()
     */
    private $passwordplain;

    /**
     * @ORM\Column(type="string", length=250)
     */
    private $salt;

    /**
     * @ORM\Column(type="string", length=250, nullable=true)
     */
    private $passwordad;

    /**
     * @ORM\Column(type="string", length=128, 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, nullable=true)
     */
    private $siren;

    /**
     * @ORM\Column(type="string", length=14, nullable=true)
     */
    private $siret;

    /**
     * @ORM\Column(type="string", length=250, nullable=true)
     */
    private $labelniveau01;

    /**
     * @ORM\Column(type="string", length=250, nullable=true)
     */
    private $labelniveau02;


    /**
     * @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\Column(type="integer", nullable=true)
     */
    private $viewcalendar;   

    /**
     * @ORM\Column(type="datetime", nullable=true)
     */
    private $visitedate;

    /**
     * @ORM\Column(type="integer", nullable=true)
     */
    private $visitecpt;

    /**
     * @ORM\Column(type="string", length=150, nullable=true)
     */
    private $niveau01other;

    /**
     * @ORM\Column(name="motivation", type="text", nullable=true)
     */
    private $motivation;

    /**
     * @ORM\Column(name="note", type="text", nullable=true)
     */
    private $note;

    /**
     * @ORM\Column(name="preference", type="array", nullable=true)
     */
    private $preference;

    /**
     * @ORM\ManyToOne(targetEntity="PermModoProfil", inversedBy="users")
     * @ORM\JoinColumn(nullable=true)
     */
    private $permmodoprofil;

    /**
     * @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 $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;

    /**
     * @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")
    */    
    private $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")
    */    
    private $blogwriters;    

    /**
     * @var ArrayCollection $blogarticle
     * @var Blogarticle
     *
     * @ORM\OneToMany(targetEntity="Cadoles\PortalBundle\Entity\Blogarticle", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
     */
    private $blogarticles;    

    /**
     * @var ArrayCollection $blogcomment
     * @var Blogcomment
     *
     * @ORM\OneToMany(targetEntity="Cadoles\PortalBundle\Entity\Blogcomment", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
     */
    private $blogcomments;

    /**
     * @var ArrayCollection $project
     * @var Project
     *
     * @ORM\OneToMany(targetEntity="Cadoles\PortalBundle\Entity\Project", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
     */
    private $projects;    

    /**
    * @ORM\ManyToMany(targetEntity="Cadoles\PortalBundle\Entity\Project", mappedBy="writers")
    */    
    private $projectwriters;    

    /**
     * @var ArrayCollection $projecttask
     * @var Projecttask
     *
     * @ORM\OneToMany(targetEntity="Cadoles\PortalBundle\Entity\Projecttask", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
     */
    private $projecttasks;    

    /**
     * @var ArrayCollection $projecttask
     * @var Projecttask
     *
     * @ORM\OneToMany(targetEntity="Cadoles\PortalBundle\Entity\Projecttask", mappedBy="owner", cascade={"persist"}, orphanRemoval=true)
     */
    private $projectownertasks;    

    /**
     * @var ArrayCollection $projectcomment
     * @var Projectcomment
     *
     * @ORM\OneToMany(targetEntity="Cadoles\PortalBundle\Entity\Projectcomment", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
     */
    private $projectcomments;

    /**
     * @var ArrayCollection $icon
     * @var Icon
     *
     * @ORM\OneToMany(targetEntity="Cadoles\PortalBundle\Entity\Icon", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
     */
    private $icons;    

    /**
     * @var ArrayCollection $message
     * @var Message
     *
     * @ORM\OneToMany(targetEntity="Cadoles\WebsocketBundle\Entity\Message", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
     */
    private $messages;  

    /**
    * @ORM\ManyToMany(targetEntity="Cadoles\WebsocketBundle\Entity\Message", mappedBy="readers")
    */    
    protected $messagereaders;     

    /**
    * @ORM\ManyToMany(targetEntity="Cadoles\WebsocketBundle\Entity\Message", mappedBy="sees")
    */    
    protected $messagesees;  

    /**
    * @ORM\ManyToMany(targetEntity="Cadoles\PortalBundle\Entity\Alert", mappedBy="readers")
    */    
    protected $alertreaders;     


//== 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!=""){
            // Placer le password non encodé dans une variable tempo sur laquel on va appliquer la contraite
            $this->passwordplain = $password;

            // Password encrypté format openldap           
            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;

            // Password encrypté AD
            $newPassword = "\"" . $password . "\"";
            $len = strlen($newPassword);
            $newPassw = "";
            for($i=0;$i<$len;$i++) {
                $newPassw .= "{$newPassword{$i}}\000";
            }   
            $this->passwordad = $newPassw;   
        }
        
        return $this;
    }

    public function setPasswordDirect($password)
    {
        // Permet de setter le password généré lors de l'inscription
        $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();
        $this->icons = 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 labelniveau01
     *
     * @param string $labelniveau01
     *
     * @return User
     */
    public function setLabelniveau01($labelniveau01)
    {
        $this->labelniveau01 = $labelniveau01;

        return $this;
    }

    /**
     * Get labelniveau01
     *
     * @return string
     */
    public function getLabelniveau01()
    {
        return $this->labelniveau01;
    }

    /**
     * Set labelniveau02
     *
     * @param string $labelniveau02
     *
     * @return User
     */
    public function setLabelniveau02($labelniveau02)
    {
        $this->labelniveau02 = $labelniveau02;

        return $this;
    }

    /**
     * Get labelniveau02
     *
     * @return string
     */
    public function getLabelniveau02()
    {
        return $this->labelniveau02;
    }

    /**
     * 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 viewcalendar
     *
     * @param integer $viewcalendar
     *
     * @return User
     */
    public function setViewcalendar($viewcalendar)
    {
        $this->viewcalendar = $viewcalendar;

        return $this;
    }

    /**
     * Get viewcalendar
     *
     * @return integer
     */
    public function getViewcalendar()
    {
        return $this->viewcalendar;
    }    

    /**
     * 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;
    }

    /**
     * Add icon
     *
     * @param \Cadoles\PortalBundle\Entity\Icon $icon
     *
     * @return User
     */
    public function addIcon(\Cadoles\PortalBundle\Entity\Icon $icon)
    {
        $this->icons[] = $icon;

        return $this;
    }

    /**
     * Remove icon
     *
     * @param \Cadoles\PortalBundle\Entity\Icon $icon
     */
    public function removeIcon(\Cadoles\PortalBundle\Entity\Icon $icon)
    {
        $this->icons->removeElement($icon);
    }

    /**
     * Get icons
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getIcons()
    {
        return $this->icons;
    }

    /**
     * Add ownergroup
     *
     * @param \Cadoles\CoreBundle\Entity\Group $ownergroup
     *
     * @return User
     */
    public function addOwnergroup(\Cadoles\CoreBundle\Entity\Group $ownergroup)
    {
        $this->ownergroups[] = $ownergroup;

        return $this;
    }

    /**
     * Remove ownergroup
     *
     * @param \Cadoles\CoreBundle\Entity\Group $ownergroup
     */
    public function removeOwnergroup(\Cadoles\CoreBundle\Entity\Group $ownergroup)
    {
        $this->ownergroups->removeElement($ownergroup);
    }

    /**
     * Get ownergroups
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getOwnergroups()
    {
        return $this->ownergroups;
    }

    /**
     * Add message
     *
     * @param \Cadoles\WebsocketBundle\Entity\Message $message
     *
     * @return User
     */
    public function addMessage(\Cadoles\WebsocketBundle\Entity\Message $message)
    {
        $this->messages[] = $message;

        return $this;
    }

    /**
     * Remove message
     *
     * @param \Cadoles\WebsocketBundle\Entity\Message $message
     */
    public function removeMessage(\Cadoles\WebsocketBundle\Entity\Message $message)
    {
        $this->messages->removeElement($message);
    }

    /**
     * Get messages
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getMessages()
    {
        return $this->messages;
    }

    /**
     * Add messagereader
     *
     * @param \Cadoles\WebsocketBundle\Entity\Message $messagereader
     *
     * @return User
     */
    public function addMessagereader(\Cadoles\WebsocketBundle\Entity\Message $messagereader)
    {
        $this->messagereaders[] = $messagereader;

        return $this;
    }

    /**
     * Remove messagereader
     *
     * @param \Cadoles\WebsocketBundle\Entity\Message $messagereader
     */
    public function removeMessagereader(\Cadoles\WebsocketBundle\Entity\Message $messagereader)
    {
        $this->messagereaders->removeElement($messagereader);
    }

    /**
     * Get messagereaders
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getMessagereaders()
    {
        return $this->messagereaders;
    }

    /**
     * Add messagesee
     *
     * @param \Cadoles\WebsocketBundle\Entity\Message $messagesee
     *
     * @return User
     */
    public function addMessagesee(\Cadoles\WebsocketBundle\Entity\Message $messagesee)
    {
        $this->messagesees[] = $messagesee;

        return $this;
    }

    /**
     * Remove messagesee
     *
     * @param \Cadoles\WebsocketBundle\Entity\Message $messagesee
     */
    public function removeMessagesee(\Cadoles\WebsocketBundle\Entity\Message $messagesee)
    {
        $this->messagesees->removeElement($messagesee);
    }

    /**
     * Get messagesees
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getMessagesees()
    {
        return $this->messagesees;
    }

    /**
     * Add blogcomment
     *
     * @param \Cadoles\PortalBundle\Entity\Blogcomment $blogcomment
     *
     * @return User
     */
    public function addBlogcomment(\Cadoles\PortalBundle\Entity\Blogcomment $blogcomment)
    {
        $this->blogcomments[] = $blogcomment;

        return $this;
    }

    /**
     * Remove blogcomment
     *
     * @param \Cadoles\PortalBundle\Entity\Blogcomment $blogcomment
     */
    public function removeBlogcomment(\Cadoles\PortalBundle\Entity\Blogcomment $blogcomment)
    {
        $this->blogcomments->removeElement($blogcomment);
    }

    /**
     * Get blogcomments
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getBlogcomments()
    {
        return $this->blogcomments;
    }

    /**
     * Add project
     *
     * @param \Cadoles\PortalBundle\Entity\Project $project
     *
     * @return User
     */
    public function addProject(\Cadoles\PortalBundle\Entity\Project $project)
    {
        $this->projects[] = $project;

        return $this;
    }

    /**
     * Remove project
     *
     * @param \Cadoles\PortalBundle\Entity\Project $project
     */
    public function removeProject(\Cadoles\PortalBundle\Entity\Project $project)
    {
        $this->projects->removeElement($project);
    }

    /**
     * Get projects
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getProjects()
    {
        return $this->projects;
    }

    /**
     * Add projectwriter
     *
     * @param \Cadoles\PortalBundle\Entity\Project $projectwriter
     *
     * @return User
     */
    public function addProjectwriter(\Cadoles\PortalBundle\Entity\Project $projectwriter)
    {
        $this->projectwriters[] = $projectwriter;

        return $this;
    }

    /**
     * Remove projectwriter
     *
     * @param \Cadoles\PortalBundle\Entity\Project $projectwriter
     */
    public function removeProjectwriter(\Cadoles\PortalBundle\Entity\Project $projectwriter)
    {
        $this->projectwriters->removeElement($projectwriter);
    }

    /**
     * Get projectwriters
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getProjectwriters()
    {
        return $this->projectwriters;
    }

    /**
     * Add projecttask
     *
     * @param \Cadoles\PortalBundle\Entity\Projecttask $projecttask
     *
     * @return User
     */
    public function addProjecttask(\Cadoles\PortalBundle\Entity\Projecttask $projecttask)
    {
        $this->projecttasks[] = $projecttask;

        return $this;
    }

    /**
     * Remove projecttask
     *
     * @param \Cadoles\PortalBundle\Entity\Projecttask $projecttask
     */
    public function removeProjecttask(\Cadoles\PortalBundle\Entity\Projecttask $projecttask)
    {
        $this->projecttasks->removeElement($projecttask);
    }

    /**
     * Get projecttasks
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getProjecttasks()
    {
        return $this->projecttasks;
    }

    /**
     * Add projectownertask
     *
     * @param \Cadoles\PortalBundle\Entity\Projecttask $projectownertask
     *
     * @return User
     */
    public function addProjectownertask(\Cadoles\PortalBundle\Entity\Projecttask $projectownertask)
    {
        $this->projectownertasks[] = $projectownertask;

        return $this;
    }

    /**
     * Remove projectownertask
     *
     * @param \Cadoles\PortalBundle\Entity\Projecttask $projectownertask
     */
    public function removeProjectownertask(\Cadoles\PortalBundle\Entity\Projecttask $projectownertask)
    {
        $this->projectownertasks->removeElement($projectownertask);
    }

    /**
     * Get projectownertasks
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getProjectownertasks()
    {
        return $this->projectownertasks;
    }

    /**
     * Add projectcomment
     *
     * @param \Cadoles\PortalBundle\Entity\Projectcomment $projectcomment
     *
     * @return User
     */
    public function addProjectcomment(\Cadoles\PortalBundle\Entity\Projectcomment $projectcomment)
    {
        $this->projectcomments[] = $projectcomment;

        return $this;
    }

    /**
     * Remove projectcomment
     *
     * @param \Cadoles\PortalBundle\Entity\Projectcomment $projectcomment
     */
    public function removeProjectcomment(\Cadoles\PortalBundle\Entity\Projectcomment $projectcomment)
    {
        $this->projectcomments->removeElement($projectcomment);
    }

    /**
     * Get projectcomments
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getProjectcomments()
    {
        return $this->projectcomments;
    }

    /**
     * Set visitedate
     *
     * @param \DateTime $visitedate
     *
     * @return User
     */
    public function setVisitedate($visitedate)
    {
        $this->visitedate = $visitedate;

        return $this;
    }

    /**
     * Get visitedate
     *
     * @return \DateTime
     */
    public function getVisitedate()
    {
        return $this->visitedate;
    }

    /**
     * Set visitecpt
     *
     * @param integer $visitecpt
     *
     * @return User
     */
    public function setVisitecpt($visitecpt)
    {
        $this->visitecpt = $visitecpt;

        return $this;
    }

    /**
     * Get visitecpt
     *
     * @return integer
     */
    public function getVisitecpt()
    {
        return $this->visitecpt;
    }

    /**
     * Set niveau01other
     *
     * @param string $niveau01other
     *
     * @return User
     */
    public function setNiveau01other($niveau01other)
    {
        $this->niveau01other = $niveau01other;

        return $this;
    }

    /**
     * Get niveau01other
     *
     * @return string
     */
    public function getNiveau01other()
    {
        return $this->niveau01other;
    }

    /**
     * Add alertreader
     *
     * @param \Cadoles\PortalBundle\Entity\Alert $alertreader
     *
     * @return User
     */
    public function addAlertreader(\Cadoles\PortalBundle\Entity\Alert $alertreader)
    {
        $this->alertreaders[] = $alertreader;

        return $this;
    }

    /**
     * Remove alertreader
     *
     * @param \Cadoles\PortalBundle\Entity\Alert $alertreader
     */
    public function removeAlertreader(\Cadoles\PortalBundle\Entity\Alert $alertreader)
    {
        $this->alertreaders->removeElement($alertreader);
    }

    /**
     * Get alertreaders
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getAlertreaders()
    {
        return $this->alertreaders;
    }

    /**
     * Set motivation
     *
     * @param string $motivation
     *
     * @return User
     */
    public function setMotivation($motivation)
    {
        $this->motivation = $motivation;

        return $this;
    }

    /**
     * Get motivation
     *
     * @return string
     */
    public function getMotivation()
    {
        return $this->motivation;
    }

    /**
     * Set preference
     *
     * @param array $preference
     *
     * @return User
     */
    public function setPreference($preference)
    {
        $this->preference = $preference;

        return $this;
    }

    /**
     * Get preference
     *
     * @return array
     */
    public function getPreference()
    {
        return $this->preference;
    }

    /**
     * Set permmodoprofil
     *
     * @param \Cadoles\CoreBundle\Entity\PermModoProfil $permmodoprofil
     *
     * @return User
     */
    public function setPermmodoprofil(\Cadoles\CoreBundle\Entity\PermModoProfil $permmodoprofil = null)
    {
        $this->permmodoprofil = $permmodoprofil;

        return $this;
    }

    /**
     * Get permmodoprofil
     *
     * @return \Cadoles\CoreBundle\Entity\PermModoProfil
     */
    public function getPermmodoprofil()
    {
        return $this->permmodoprofil;
    }

    /**
     * Set passwordad.
     *
     * @param string|null $passwordad
     *
     * @return User
     */
    public function setPasswordad($passwordad = null)
    {
        $this->passwordad = $passwordad;

        return $this;
    }

    /**
     * Get passwordad.
     *
     * @return string|null
     */
    public function getPasswordad()
    {
        return $this->passwordad;
    }

    /**
     * Set note
     *
     * @param string $note
     *
     * @return User
     */
    public function setNote($note)
    {
        $this->note = $note;

        return $this;
    }

    /**
     * Get note
     *
     * @return string
     */
    public function getNote()
    {
        return $this->note;
    }
}
