Browse Source

Adding entities as is.

Julio Montoya 10 years ago
parent
commit
33db828b29

+ 1173 - 0
src/Chamilo/CoreBundle/Entity/Course.php

@@ -0,0 +1,1173 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Entity;
+
+use Chamilo\CourseBundle\Entity\CTool;
+use Doctrine\Common\Collections\Criteria;
+use Doctrine\ORM\Mapping as ORM;
+use Doctrine\Common\Collections\ArrayCollection;
+use Gedmo\Mapping\Annotation as Gedmo;
+use Symfony\Component\Validator\Constraints as Assert;
+use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
+use Chamilo\UserBundle\Entity\User;
+// @ORM\EntityListeners({"Chamilo\CoreBundle\Entity\Listener\CourseListener"})
+/**
+ * Class Course
+ *
+ * @ORM\HasLifecycleCallbacks
+ * @ORM\Table(name="course")
+ * @UniqueEntity("code")
+ * @UniqueEntity("visualCode")
+ * @UniqueEntity("directory")
+ * @ORM\Entity(repositoryClass="Chamilo\CoreBundle\Entity\Repository\CourseRepository")
+ * @ORM\EntityListeners({"Chamilo\CoreBundle\Entity\Listener\CourseListener"})
+ */
+class Course
+{
+    const CLOSED = 0;
+    const REGISTERED = 1;
+    const OPEN_PLATFORM = 2;
+    const OPEN_WORLD = 3;
+    const HIDDEN = 4;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer", nullable=false, unique=false)
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="AUTO")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @Assert\NotBlank()
+     *
+     * @ORM\Column(name="title", type="string", length=250, nullable=true, unique=false)
+     */
+    private $title;
+
+    /**
+     * @var string
+     * @Gedmo\Slug(
+     *      fields={"title"},
+     *      updatable = false,
+     *      unique = true
+     * )
+     * @ORM\Column(name="code", type="string", length=40, nullable=false, unique=true)
+     */
+    private $code;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="directory", type="string", length=40, nullable=true, unique=false)
+     */
+    private $directory;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="course_language", type="string", length=20, nullable=true, unique=false)
+     */
+    private $courseLanguage;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="description", type="text", nullable=true, unique=false)
+     */
+    private $description;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="category_code", type="string", length=40, nullable=true, unique=false)
+     */
+    private $categoryCode;
+
+    /**
+     * @var boolean
+     * @Assert\NotBlank()
+     * @ORM\Column(name="visibility", type="integer", nullable=true, unique=false)
+     */
+    private $visibility;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="show_score", type="integer", nullable=true, unique=false)
+     */
+    private $showScore;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="tutor_name", type="string", length=200, nullable=true, unique=false)
+     */
+    private $tutorName;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="visual_code", type="string", length=40, nullable=true, unique=false)
+     */
+    private $visualCode;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="department_name", type="string", length=30, nullable=true, unique=false)
+     */
+    private $departmentName;
+
+    /**
+     * @var string
+     * @Assert\Url()
+     * @ORM\Column(name="department_url", type="string", length=180, nullable=true, unique=false)
+     */
+    private $departmentUrl;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="disk_quota", type="bigint", nullable=true, unique=false)
+     */
+    private $diskQuota;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="last_visit", type="datetime", nullable=true, unique=false)
+     */
+    private $lastVisit;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="last_edit", type="datetime", nullable=true, unique=false)
+     */
+    private $lastEdit;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="creation_date", type="datetime", nullable=true, unique=false)
+     */
+    private $creationDate;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="expiration_date", type="datetime", nullable=true, unique=false)
+     */
+    private $expirationDate;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="target_course_code", type="string", length=40, nullable=true, unique=false)
+     */
+    private $targetCourseCode;
+
+    /**
+     * @var boolean
+     *
+     * @ORM\Column(name="subscribe", type="boolean", nullable=true, unique=false)
+     */
+    private $subscribe;
+
+    /**
+     * @var boolean
+     *
+     * @ORM\Column(name="unsubscribe", type="boolean", nullable=true, unique=false)
+     */
+    private $unsubscribe;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="registration_code", type="string", length=255, nullable=true, unique=false)
+     */
+    private $registrationCode;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="legal", type="text", nullable=true, unique=false)
+     */
+    private $legal;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="activate_legal", type="integer", nullable=true, unique=false)
+     */
+    private $activateLegal;
+
+    /**
+     * @var boolean
+     *
+     * @ORM\Column(name="add_teachers_to_sessions_courses", type="boolean", nullable=true)
+     */
+    private $addTeachersToSessionsCourses;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="course_type_id", type="integer", nullable=true, unique=false)
+     */
+    private $courseTypeId;
+
+    /**
+     * "orphanRemoval" is needed to delete the CourseRelUser relation
+     * in the CourseAdmin class. The setUsers, getUsers, removeUsers and
+     * addUsers methods need to be added.
+     * @ORM\OneToMany(targetEntity="CourseRelUser", mappedBy="course", cascade={"persist"}, orphanRemoval=true)
+     **/
+    protected $users;
+
+    /**
+     * @ORM\OneToMany(targetEntity="AccessUrlRelCourse", mappedBy="course", cascade={"persist"}, orphanRemoval=true)
+     **/
+    protected $urls;
+
+    /**
+     * @ORM\OneToMany(targetEntity="SessionRelCourse", mappedBy="course", cascade={"persist"})
+     **/
+    protected $sessions;
+
+    /**
+     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SessionRelCourseRelUser", mappedBy="course", cascade={"persist"})
+     **/
+    protected $sessionUserSubscriptions;
+
+    /**
+     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CItemProperty", mappedBy="course")
+     **/
+    //protected $items;
+
+    /**
+     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CTool", mappedBy="course", cascade={"persist"})
+     **/
+    protected $tools;
+
+    /**
+     * @ORM\OneToMany(targetEntity="Chamilo\NotebookBundle\Entity\CNotebook", mappedBy="course")
+     **/
+    //protected $notebooks;
+
+    /**
+     * ORM\OneToMany(targetEntity="CurriculumCategory", mappedBy="course")
+     **/
+    //protected $curriculumCategories;
+
+    /**
+     * @var Session
+     **/
+    protected $currentSession;
+
+    /**
+     *
+     */
+    public function __construct()
+    {
+        $this->creationDate = new \DateTime();
+        $this->users = new ArrayCollection();
+    }
+
+    /**
+     * @return string
+     */
+    public function __toString()
+    {
+        return strval($this->getTitle());
+    }
+
+    /**
+     * @return ArrayCollection
+     */
+    public function getSessions()
+    {
+        return $this->sessions;
+    }
+
+    /**
+     * @return ArrayCollection
+     */
+    public function getNotebooks()
+    {
+        return $this->notebooks;
+    }
+
+    /**
+     * @return ArrayCollection
+     */
+    public function getItems()
+    {
+        return $this->items;
+    }
+
+    /**
+     * @return ArrayCollection
+     */
+    public function getTools()
+    {
+        return $this->tools;
+    }
+
+    /**
+     * @param $tools
+     */
+    public function setTools($tools)
+    {
+        foreach ($tools as $tool) {
+            $this->addTools($tool);
+        }
+    }
+
+    /**
+     * @param CTool $tool
+     */
+    public function addTools(CTool $tool)
+    {
+        $tool->setCourse($this);
+        $this->tools[] = $tool;
+    }
+
+    /**
+     * @return ArrayCollection
+     */
+    public function getUrls()
+    {
+        return $this->urls;
+    }
+
+    /**
+     * @param $urls
+     */
+    public function setUrls($urls)
+    {
+        $this->urls = new ArrayCollection();
+
+        foreach ($urls as $url) {
+            $this->addUrls($url);
+        }
+    }
+
+    /**
+     * @param AccessUrlRelCourse $url
+     */
+    public function addUrls(AccessUrlRelCourse $url)
+    {
+        $url->setCourse($this);
+        $this->urls[] = $url;
+    }
+
+    /**
+     * @return ArrayCollection
+     */
+    public function getUsers()
+    {
+        return $this->users;
+    }
+
+    /**
+     * @return ArrayCollection
+     */
+    public function getTeachers()
+    {
+        $criteria = Criteria::create();
+        $criteria->where(Criteria::expr()->eq('status', User::COURSE_MANAGER));
+
+        return $this->users->matching($criteria);
+    }
+
+    /**
+     * @return ArrayCollection
+     */
+    public function getStudents()
+    {
+        $criteria = Criteria::create();
+        $criteria->where(Criteria::expr()->eq('status', User::STUDENT));
+
+        return $this->users->matching($criteria);
+    }
+
+    /**
+     * @param ArrayCollection $users
+     */
+    public function setUsers($users)
+    {
+        $this->users = new ArrayCollection();
+
+        foreach ($users as $user) {
+            $this->addUsers($user);
+        }
+    }
+
+    /**
+     * @param CourseRelUser $courseRelUser
+     */
+    public function addUsers(CourseRelUser $courseRelUser)
+    {
+        $courseRelUser->setCourse($this);
+
+        if (!$this->hasSubscription($courseRelUser)) {
+            $this->users[] = $courseRelUser;
+        }
+    }
+
+    /**
+     * @param CourseRelUser $subscription
+     * @return bool
+     */
+    private function hasSubscription(CourseRelUser $subscription)
+    {
+        if ($this->getUsers()->count()) {
+            $criteria = Criteria::create()->where(
+                Criteria::expr()->eq("user", $subscription->getUser())
+            )->andWhere(
+                Criteria::expr()->eq("status", $subscription->getStatus())
+            )->andWhere(
+                Criteria::expr()->eq("relationType", $subscription->getRelationType())
+            );
+
+            $relation = $this->getUsers()->matching($criteria);
+
+            return $relation->count() > 0;
+        }
+
+        return false;
+    }
+
+    /**
+     * @param User $user
+     * @return bool
+     */
+    public function hasUser(User $user)
+    {
+        $criteria = Criteria::create()->where(
+            Criteria::expr()->eq("user", $user)
+        );
+
+        return $this->getUsers()->matching($criteria)->count() > 0;
+    }
+
+    /**
+     * @param User $user
+     * @return bool
+     */
+    public function hasStudent(User $user)
+    {
+        $criteria = Criteria::create()->where(
+            Criteria::expr()->eq("user", $user)
+        );
+
+        return $this->getStudents()->matching($criteria)->count() > 0;
+    }
+
+    /**
+     * @param User $user
+     * @return bool
+     */
+    public function hasTeacher(User $user)
+    {
+        $criteria = Criteria::create()->where(
+            Criteria::expr()->eq("user", $user)
+        );
+
+        return $this->getTeachers()->matching($criteria)->count() > 0;
+    }
+
+    /**
+     * Remove $user
+     *
+     * @param CourseRelUser $user
+     */
+    public function removeUsers(CourseRelUser $user)
+    {
+        foreach ($this->users as $key => $value) {
+            if ($value->getId() == $user->getId()) {
+                unset($this->users[$key]);
+            }
+        }
+    }
+
+    /**
+     * @param User $user
+     * @param string $relationType
+     * @param string $role
+     * @param string $status
+     */
+    private function addUser(User $user, $relationType, $role, $status)
+    {
+        $courseRelUser = new CourseRelUser();
+        $courseRelUser->setCourse($this);
+        $courseRelUser->setUser($user);
+        $courseRelUser->setRelationType($relationType);
+        $courseRelUser->setRole($role);
+        $courseRelUser->setStatus($status);
+        $this->addUsers($courseRelUser);
+    }
+
+    /**
+     * @param User $user
+     */
+    public function addTeacher(User $user)
+    {
+        $this->addUser($user, 0, "Trainer", User::COURSE_MANAGER);
+    }
+
+    /**
+     * @param User $user
+     */
+    public function addStudent(User $user)
+    {
+        $this->addUser($user, 0, "", User::STUDENT);
+    }
+
+    /**
+     * Set id
+     *
+     * @return integer
+     */
+    public function setId($id)
+    {
+        $this->id = $id;
+    }
+
+    /**
+     * Get id
+     *
+     * @return integer
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * Set code
+     *
+     * @param string $code
+     * @return Course
+     */
+    public function setCode($code)
+    {
+        $this->code = $code;
+        $this->visualCode = $code;
+        $this->directory = $code;
+
+        return $this;
+    }
+
+    /**
+     * Get code
+     *
+     * @return string
+     */
+    public function getCode()
+    {
+        return $this->code;
+    }
+
+    /**
+     * Set directory
+     *
+     * @param string $directory
+     * @return Course
+     */
+    public function setDirectory($directory)
+    {
+        $this->directory = $directory;
+
+        return $this;
+    }
+
+    /**
+     * Get directory
+     *
+     * @return string
+     */
+    public function getDirectory()
+    {
+        return $this->directory;
+    }
+
+
+    /**
+     * Set courseLanguage
+     *
+     * @param string $courseLanguage
+     * @return Course
+     */
+    public function setCourseLanguage($courseLanguage)
+    {
+        $this->courseLanguage = $courseLanguage;
+
+        return $this;
+    }
+
+    /**
+     * Get courseLanguage
+     *
+     * @return string
+     */
+    public function getCourseLanguage()
+    {
+        return $this->courseLanguage;
+    }
+
+    /**
+     * Set title
+     *
+     * @param string $title
+     * @return Course
+     */
+    public function setTitle($title)
+    {
+        $this->title = $title;
+
+        return $this;
+    }
+
+    /**
+     * Get title
+     *
+     * @return string
+     */
+    public function getTitle()
+    {
+        return $this->title;
+    }
+
+    /**
+     * Set description
+     *
+     * @param string $description
+     * @return Course
+     */
+    public function setDescription($description)
+    {
+        $this->description = $description;
+
+        return $this;
+    }
+
+    /**
+     * Get description
+     *
+     * @return string
+     */
+    public function getDescription()
+    {
+        return $this->description;
+    }
+
+    /**
+     * Set categoryCode
+     *
+     * @param string $categoryCode
+     * @return Course
+     */
+    public function setCategoryCode($categoryCode)
+    {
+        $this->categoryCode = $categoryCode;
+
+        return $this;
+    }
+
+    /**
+     * Get categoryCode
+     *
+     * @return string
+     */
+    public function getCategoryCode()
+    {
+        return $this->categoryCode;
+    }
+
+    /**
+     * Set visibility
+     *
+     * @param boolean $visibility
+     * @return Course
+     */
+    public function setVisibility($visibility)
+    {
+        $this->visibility = $visibility;
+
+        return $this;
+    }
+
+    /**
+     * Get visibility
+     *
+     * @return boolean
+     */
+    public function getVisibility()
+    {
+        return $this->visibility;
+    }
+
+    /**
+     * Set showScore
+     *
+     * @param integer $showScore
+     * @return Course
+     */
+    public function setShowScore($showScore)
+    {
+        $this->showScore = $showScore;
+
+        return $this;
+    }
+
+    /**
+     * Get showScore
+     *
+     * @return integer
+     */
+    public function getShowScore()
+    {
+        return $this->showScore;
+    }
+
+    /**
+     * Set tutorName
+     *
+     * @param string $tutorName
+     * @return Course
+     */
+    public function setTutorName($tutorName)
+    {
+        $this->tutorName = $tutorName;
+
+        return $this;
+    }
+
+    /**
+     * Get tutorName
+     *
+     * @return string
+     */
+    public function getTutorName()
+    {
+        return $this->tutorName;
+    }
+
+    /**
+     * Set visualCode
+     *
+     * @param string $visualCode
+     * @return Course
+     */
+    public function setVisualCode($visualCode)
+    {
+        $this->visualCode = $visualCode;
+
+        return $this;
+    }
+
+    /**
+     * Get visualCode
+     *
+     * @return string
+     */
+    public function getVisualCode()
+    {
+        return $this->visualCode;
+    }
+
+    /**
+     * Set departmentName
+     *
+     * @param string $departmentName
+     * @return Course
+     */
+    public function setDepartmentName($departmentName)
+    {
+        $this->departmentName = $departmentName;
+
+        return $this;
+    }
+
+    /**
+     * Get departmentName
+     *
+     * @return string
+     */
+    public function getDepartmentName()
+    {
+        return $this->departmentName;
+    }
+
+    /**
+     * Set departmentUrl
+     *
+     * @param string $departmentUrl
+     * @return Course
+     */
+    public function setDepartmentUrl($departmentUrl)
+    {
+        $this->departmentUrl = $departmentUrl;
+
+        return $this;
+    }
+
+    /**
+     * Get departmentUrl
+     *
+     * @return string
+     */
+    public function getDepartmentUrl()
+    {
+        return $this->departmentUrl;
+    }
+
+    /**
+     * Set diskQuota
+     *
+     * @param integer $diskQuota
+     * @return Course
+     */
+    public function setDiskQuota($diskQuota)
+    {
+        $this->diskQuota = intval($diskQuota);
+
+        return $this;
+    }
+
+    /**
+     * Get diskQuota
+     *
+     * @return integer
+     */
+    public function getDiskQuota()
+    {
+        return $this->diskQuota;
+    }
+
+    /**
+     * Set lastVisit
+     *
+     * @param \DateTime $lastVisit
+     * @return Course
+     */
+    public function setLastVisit($lastVisit)
+    {
+        $this->lastVisit = $lastVisit;
+
+        return $this;
+    }
+
+    /**
+     * Get lastVisit
+     *
+     * @return \DateTime
+     */
+    public function getLastVisit()
+    {
+        return $this->lastVisit;
+    }
+
+    /**
+     * Set lastEdit
+     *
+     * @param \DateTime $lastEdit
+     * @return Course
+     */
+    public function setLastEdit($lastEdit)
+    {
+        $this->lastEdit = $lastEdit;
+
+        return $this;
+    }
+
+    /**
+     * Get lastEdit
+     *
+     * @return \DateTime
+     */
+    public function getLastEdit()
+    {
+        return $this->lastEdit;
+    }
+
+    /**
+     * Set creationDate
+     *
+     * @param \DateTime $creationDate
+     * @return Course
+     */
+    public function setCreationDate($creationDate)
+    {
+        $this->creationDate = $creationDate;
+
+        return $this;
+    }
+
+    /**
+     * Get creationDate
+     *
+     * @return \DateTime
+     */
+    public function getCreationDate()
+    {
+        return $this->creationDate;
+    }
+
+    /**
+     * Set expirationDate
+     *
+     * @param \DateTime $expirationDate
+     * @return Course
+     */
+    public function setExpirationDate($expirationDate)
+    {
+        $this->expirationDate = $expirationDate;
+
+        return $this;
+    }
+
+    /**
+     * Get expirationDate
+     *
+     * @return \DateTime
+     */
+    public function getExpirationDate()
+    {
+        return $this->expirationDate;
+    }
+
+    /**
+     * Set targetCourseCode
+     *
+     * @param string $targetCourseCode
+     * @return Course
+     */
+    public function setTargetCourseCode($targetCourseCode)
+    {
+        $this->targetCourseCode = $targetCourseCode;
+
+        return $this;
+    }
+
+    /**
+     * Get targetCourseCode
+     *
+     * @return string
+     */
+    public function getTargetCourseCode()
+    {
+        return $this->targetCourseCode;
+    }
+
+    /**
+     * Set subscribe
+     *
+     * @param boolean $subscribe
+     * @return Course
+     */
+    public function setSubscribe($subscribe)
+    {
+        $this->subscribe = intval($subscribe);
+
+        return $this;
+    }
+
+    /**
+     * Get subscribe
+     *
+     * @return boolean
+     */
+    public function getSubscribe()
+    {
+        return $this->subscribe;
+    }
+
+    /**
+     * Set unsubscribe
+     *
+     * @param boolean $unsubscribe
+     * @return Course
+     */
+    public function setUnsubscribe($unsubscribe)
+    {
+        $this->unsubscribe = intval($unsubscribe);
+
+        return $this;
+    }
+
+    /**
+     * Get unsubscribe
+     *
+     * @return boolean
+     */
+    public function getUnsubscribe()
+    {
+        return $this->unsubscribe;
+    }
+
+    /**
+     * Set registrationCode
+     *
+     * @param string $registrationCode
+     * @return Course
+     */
+    public function setRegistrationCode($registrationCode)
+    {
+        $this->registrationCode = $registrationCode;
+
+        return $this;
+    }
+
+    /**
+     * Get registrationCode
+     *
+     * @return string
+     */
+    public function getRegistrationCode()
+    {
+        return $this->registrationCode;
+    }
+
+    /**
+     * Set legal
+     *
+     * @param string $legal
+     * @return Course
+     */
+    public function setLegal($legal)
+    {
+        $this->legal = $legal;
+
+        return $this;
+    }
+
+    /**
+     * Get legal
+     *
+     * @return string
+     */
+    public function getLegal()
+    {
+        return $this->legal;
+    }
+
+    /**
+     * Set activateLegal
+     *
+     * @param integer $activateLegal
+     * @return Course
+     */
+    public function setActivateLegal($activateLegal)
+    {
+        $this->activateLegal = $activateLegal;
+
+        return $this;
+    }
+
+    /**
+     * Get activateLegal
+     *
+     * @return integer
+     */
+    public function getActivateLegal()
+    {
+        return $this->activateLegal;
+    }
+
+    /**
+     * Set courseTypeId
+     *
+     * @param integer $courseTypeId
+     * @return Course
+     */
+    public function setCourseTypeId($courseTypeId)
+    {
+        $this->courseTypeId = $courseTypeId;
+
+        return $this;
+    }
+
+    /**
+     * Get courseTypeId
+     *
+     * @return integer
+     */
+    public function getCourseTypeId()
+    {
+        return $this->courseTypeId;
+    }
+
+    /**
+     * @return string
+     */
+    public function getAbsoluteSysCoursePath()
+    {
+        return realpath(__DIR__.'/../../../data/courses/'.$this->getDirectory()).'/';
+    }
+
+    /**
+     * @return bool
+     */
+    public function isActive()
+    {
+        $activeVisibilityList = array(
+            self::REGISTERED,
+            self::OPEN_PLATFORM,
+            self::OPEN_WORLD,
+        );
+
+        return in_array($this->visibility, $activeVisibilityList);
+    }
+
+    /**
+     * Anybody can see this course
+     *
+     * @return bool
+     */
+    public function isPublic()
+    {
+        return $this->visibility == self::OPEN_WORLD;
+    }
+
+    /**
+     * @return array
+     */
+    public static function getStatusList()
+    {
+        return array(
+            self::CLOSED => 'Closed',
+            self::REGISTERED => 'Registered',
+            self::OPEN_PLATFORM => 'Open platform',
+            self::OPEN_WORLD => 'Open world',
+            self::HIDDEN => 'Hidden',
+        );
+    }
+
+    /**
+     * @return Session
+     */
+    public function getCurrentSession()
+    {
+        return $this->currentSession;
+    }
+
+    /**
+     * @param Session $session
+     * @return $this
+     */
+    public function setCurrentSession(Session $session)
+    {
+        // If the session is registered in the course session list.
+        if ($this->getSessions()->contains($session->getId())) {
+            $this->currentSession = $session;
+        }
+        return $this;
+    }
+}

+ 883 - 0
src/Chamilo/CoreBundle/Entity/Session.php

@@ -0,0 +1,883 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Entity;
+
+use Chamilo\UserBundle\Entity\User;
+use Doctrine\Common\Collections\Criteria;
+use Doctrine\ORM\Mapping as ORM;
+use Doctrine\Common\Collections\ArrayCollection;
+use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
+use Gedmo\Mapping\Annotation as Gedmo;
+
+/**
+ * Session
+ * @UniqueEntity("name")
+ * @ORM\Table(
+ *      name="session",
+ *      uniqueConstraints={@ORM\UniqueConstraint(name="name", columns={"name"})},
+ *      indexes={
+ *          @ORM\Index(name="idx_id_coach", columns={"id_coach"}),
+ *          @ORM\Index(name="idx_id_session_admin_id", columns={"session_admin_id"})
+ *      }
+ * )
+ * @ORM\Entity
+ */
+class Session
+{
+    const VISIBLE = 1;
+    const READ_ONLY = 2;
+    const INVISIBLE = 3;
+    const AVAILABLE = 4;
+
+    const STUDENT = 0;
+    const DRH = 1;
+    const COACH = 2;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer", nullable=false, unique=false)
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="AUTO")
+     */
+    private $id;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="name", type="string", length=150, nullable=false, unique=false)
+     */
+    private $name;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="nbr_courses", type="smallint", nullable=true, unique=false)
+     */
+    private $nbrCourses;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="nbr_users", type="integer", nullable=true, unique=false)
+     */
+    private $nbrUsers;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="nbr_classes", type="integer", nullable=true, unique=false)
+     */
+    private $nbrClasses;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="session_admin_id", type="integer", nullable=true, unique=false)
+     */
+    private $sessionAdminId;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="visibility", type="integer", nullable=false, unique=false)
+     */
+    private $visibility;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="promotion_id", type="integer", nullable=true, unique=false)
+     */
+    private $promotionId;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="display_start_date", type="datetime", nullable=false, unique=false)
+     */
+    private $displayStartDate;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="display_end_date", type="datetime", nullable=false, unique=false)
+     */
+    private $displayEndDate;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="access_start_date", type="datetime", nullable=false, unique=false)
+     */
+    private $accessStartDate;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="access_end_date", type="datetime", nullable=false, unique=false)
+     */
+    private $accessEndDate;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="coach_access_start_date", type="datetime", nullable=false, unique=false)
+     */
+    private $coachAccessStartDate;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="coach_access_end_date", type="datetime", nullable=false, unique=false)
+     */
+    private $coachAccessEndDate;
+
+    /**
+     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CItemProperty", mappedBy="session")
+     **/
+    //private $items;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="Chamilo\UserBundle\Entity\User", inversedBy="sessionAsGeneralCoach")
+     * @ORM\JoinColumn(name="id_coach", referencedColumnName="id")
+     **/
+    private $generalCoach;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\SessionCategory", inversedBy="session")
+     * @ORM\JoinColumn(name="session_category_id", referencedColumnName="id")
+     **/
+    private $category;
+
+    /**
+     * @var ArrayCollection
+     * @ORM\OneToMany(targetEntity="SessionRelCourse", mappedBy="session", cascade={"persist"}, orphanRemoval=true)
+     **/
+    protected $courses;
+
+    /**
+     * @var ArrayCollection
+     * @ORM\OneToMany(targetEntity="SessionRelUser", mappedBy="session", cascade={"persist"}, orphanRemoval=true)
+     **/
+    protected $users;
+
+    /**
+     * @var ArrayCollection
+     * @ORM\OneToMany(targetEntity="SessionRelCourseRelUser", mappedBy="session", cascade={"persist"}, orphanRemoval=true)
+     **/
+    protected $userCourseSubscriptions;
+
+    /**
+     * @var Course
+     **/
+    protected $currentCourse;
+
+    /**
+     * Constructor
+     */
+    public function __construct()
+    {
+        $this->items = new ArrayCollection();
+
+        $this->nbrClasses = 0;
+        $this->nbrUsers = 0;
+        $this->nbrUsers = 0;
+
+        $this->displayStartDate = new \DateTime();
+        $this->displayEndDate = new \DateTime();
+        $this->accessStartDate = new \DateTime();
+        $this->accessEndDate = new \DateTime();
+        $this->coachAccessStartDate = new \DateTime();
+        $this->coachAccessEndDate = new \DateTime();
+        $this->visibility = 1;
+
+        $this->courses = new ArrayCollection();
+        $this->users = new ArrayCollection();
+        $this->userCourseSubscriptions = new ArrayCollection();
+    }
+
+    /**
+     * @return string
+     */
+    public function __toString()
+    {
+        return (string) $this->getName();
+    }
+
+    /**
+     * Get id
+     *
+     * @return integer
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * @param int $id
+     */
+    public function setId($id)
+    {
+        $this->id = $id;
+    }
+
+    /**
+     * @return ArrayCollection
+     */
+    public function getUsers()
+    {
+        return $this->users;
+    }
+
+    /**
+     * @param $users
+     */
+    public function setUsers($users)
+    {
+        $this->users = new ArrayCollection();
+
+        foreach ($users as $user) {
+            $this->addUser($user);
+        }
+    }
+
+    /**
+     * @param SessionRelUser $user
+     */
+    public function addUser(SessionRelUser $user)
+    {
+        $user->setSession($this);
+
+        if (!$this->hasUser($user)) {
+            $this->users[] = $user;
+        }
+    }
+
+    /**
+     * @param int $status
+     * @param User $user
+     */
+    public function addUserInSession($status, User $user)
+    {
+        $sessionRelUser = new SessionRelUser();
+        $sessionRelUser->setSession($this);
+        $sessionRelUser->setUser($user);
+        $sessionRelUser->setRelationType($status);
+
+        $this->addUser($sessionRelUser);
+    }
+
+    /**
+     * @param SessionRelUser $subscription
+     * @return bool
+     */
+    public function hasUser(SessionRelUser $subscription)
+    {
+        if ($this->getUsers()->count()) {
+            $criteria = Criteria::create()->where(
+                Criteria::expr()->eq("user", $subscription->getUser())
+            )->andWhere(
+                Criteria::expr()->eq("session", $subscription->getSession())
+            )->andWhere(
+                Criteria::expr()->eq("relationType", $subscription->getRelationType())
+            );
+
+            $relation = $this->getUsers()->matching($criteria);
+
+            return $relation->count() > 0;
+        }
+
+        return false;
+    }
+
+    /**
+     * @return ArrayCollection
+     */
+    public function getCourses()
+    {
+        return $this->courses;
+    }
+
+    /**
+     * @param $courses
+     */
+    public function setCourses($courses)
+    {
+        $this->courses = new ArrayCollection();
+
+        foreach ($courses as $course) {
+            $this->addCourses($course);
+        }
+    }
+
+    /**
+     * @param SessionRelCourse $course
+     */
+    public function addCourses(SessionRelCourse $course)
+    {
+        $course->setSession($this);
+        $this->courses[] = $course;
+    }
+
+    /**
+     * @param Course $course
+     *
+     * @return bool
+     */
+    public function hasCourse(Course $course)
+    {
+        if ($this->getCourses()->count()) {
+            $criteria = Criteria::create()->where(
+                Criteria::expr()->eq("course", $course)
+            );
+            $relation = $this->getCourses()->matching($criteria);
+
+            return $relation->count() > 0;
+        }
+
+        return false;
+    }
+
+
+    /**
+     * Remove $course
+     *
+     * @param SessionRelCourse $course
+     */
+    public function removeCourses($course)
+    {
+        foreach ($this->courses as $key => $value) {
+            if ($value->getId() == $course->getId()) {
+                unset($this->courses[$key]);
+            }
+        }
+    }
+
+    /**
+     * @param User $user
+     * @param Course $course
+     * @param int $status if not set it will check if the user is registered
+     * with any status
+     *
+     * @return bool
+     */
+    public function hasUserInCourse(User $user, Course $course, $status = null)
+    {
+        $relation = $this->getUserInCourse($user, $course, $status);
+
+        return $relation->count() > 0;
+    }
+
+    /**
+     * @param User $user
+     * @param Course $course
+     *
+     * @return bool
+     */
+    public function hasStudentInCourse(User $user, Course $course)
+    {
+        return $this->hasUserInCourse($user, $course, self::STUDENT);
+    }
+
+    /**
+     * @param User $user
+     * @param Course $course
+     *
+     * @return bool
+     */
+    public function hasCoachInCourseWithStatus(User $user, Course $course)
+    {
+        return $this->hasUserInCourse($user, $course, self::COACH);
+    }
+
+    /**
+     * @param User $user
+     * @param Course $course
+     * @param string $status
+     *
+     * @return \Doctrine\Common\Collections\Collection|static
+     */
+    public function getUserInCourse(User $user, Course $course, $status = null)
+    {
+        $criteria = Criteria::create()->where(
+            Criteria::expr()->eq("course", $course)
+        )->andWhere(
+            Criteria::expr()->eq("user", $user)
+        );
+
+        if (!is_null($status))  {
+            $criteria->andWhere(
+                Criteria::expr()->eq("status", $status)
+            );
+        }
+
+        return $this->getUserCourseSubscriptions()->matching($criteria);
+    }
+
+    /**
+     * Set name
+     *
+     * @param string $name
+     * @return Session
+     */
+    public function setName($name)
+    {
+        $this->name = $name;
+
+        return $this;
+    }
+
+    /**
+     * Get name
+     *
+     * @return string
+     */
+    public function getName()
+    {
+        return $this->name;
+    }
+
+    /**
+     * Set nbrCourses
+     *
+     * @param integer $nbrCourses
+     * @return Session
+     */
+    public function setNbrCourses($nbrCourses)
+    {
+        $this->nbrCourses = $nbrCourses;
+
+        return $this;
+    }
+
+    /**
+     * Get nbrCourses
+     *
+     * @return integer
+     */
+    public function getNbrCourses()
+    {
+        return $this->nbrCourses;
+    }
+
+    /**
+     * Set nbrUsers
+     *
+     * @param integer $nbrUsers
+     * @return Session
+     */
+    public function setNbrUsers($nbrUsers)
+    {
+        $this->nbrUsers = $nbrUsers;
+
+        return $this;
+    }
+
+    /**
+     * Get nbrUsers
+     *
+     * @return integer
+     */
+    public function getNbrUsers()
+    {
+        return $this->nbrUsers;
+    }
+
+    /**
+     * Set nbrClasses
+     *
+     * @param integer $nbrClasses
+     * @return Session
+     */
+    public function setNbrClasses($nbrClasses)
+    {
+        $this->nbrClasses = $nbrClasses;
+
+        return $this;
+    }
+
+    /**
+     * Get nbrClasses
+     *
+     * @return integer
+     */
+    public function getNbrClasses()
+    {
+        return $this->nbrClasses;
+    }
+
+    /**
+     * Set sessionAdminId
+     *
+     * @param integer $sessionAdminId
+     * @return Session
+     */
+    public function setSessionAdminId($sessionAdminId)
+    {
+        $this->sessionAdminId = $sessionAdminId;
+
+        return $this;
+    }
+
+    /**
+     * Get sessionAdminId
+     *
+     * @return integer
+     */
+    public function getSessionAdminId()
+    {
+        return $this->sessionAdminId;
+    }
+
+    /**
+     * Set visibility
+     *
+     * @param integer $visibility
+     * @return Session
+     */
+    public function setVisibility($visibility)
+    {
+        $this->visibility = $visibility;
+
+        return $this;
+    }
+
+    /**
+     * Get visibility
+     *
+     * @return integer
+     */
+    public function getVisibility()
+    {
+        return $this->visibility;
+    }
+
+    /**
+     * Set promotionId
+     *
+     * @param integer $promotionId
+     * @return Session
+     */
+    public function setPromotionId($promotionId)
+    {
+        $this->promotionId = $promotionId;
+
+        return $this;
+    }
+
+    /**
+     * Get promotionId
+     *
+     * @return integer
+     */
+    public function getPromotionId()
+    {
+        return $this->promotionId;
+    }
+
+    /**
+     * Set displayStartDate
+     *
+     * @param \DateTime $displayStartDate
+     * @return Session
+     */
+    public function setDisplayStartDate($displayStartDate)
+    {
+        $this->displayStartDate = $displayStartDate;
+
+        return $this;
+    }
+
+    /**
+     * Get displayStartDate
+     *
+     * @return \DateTime
+     */
+    public function getDisplayStartDate()
+    {
+        return $this->displayStartDate;
+    }
+
+    /**
+     * Set displayEndDate
+     *
+     * @param \DateTime $displayEndDate
+     * @return Session
+     */
+    public function setDisplayEndDate($displayEndDate)
+    {
+        $this->displayEndDate = $displayEndDate;
+
+        return $this;
+    }
+
+    /**
+     * Get displayEndDate
+     *
+     * @return \DateTime
+     */
+    public function getDisplayEndDate()
+    {
+        return $this->displayEndDate;
+    }
+
+    /**
+     * Set accessStartDate
+     *
+     * @param \DateTime $accessStartDate
+     * @return Session
+     */
+    public function setAccessStartDate($accessStartDate)
+    {
+        $this->accessStartDate = $accessStartDate;
+
+        return $this;
+    }
+
+    /**
+     * Get accessStartDate
+     *
+     * @return \DateTime
+     */
+    public function getAccessStartDate()
+    {
+        return $this->accessStartDate;
+    }
+
+    /**
+     * Set accessEndDate
+     *
+     * @param \DateTime $accessEndDate
+     * @return Session
+     */
+    public function setAccessEndDate($accessEndDate)
+    {
+        $this->accessEndDate = $accessEndDate;
+
+        return $this;
+    }
+
+    /**
+     * Get accessEndDate
+     *
+     * @return \DateTime
+     */
+    public function getAccessEndDate()
+    {
+        return $this->accessEndDate;
+    }
+
+    /**
+     * Set coachAccessStartDate
+     *
+     * @param \DateTime $coachAccessStartDate
+     * @return Session
+     */
+    public function setCoachAccessStartDate($coachAccessStartDate)
+    {
+        $this->coachAccessStartDate = $coachAccessStartDate;
+
+        return $this;
+    }
+
+    /**
+     * Get coachAccessStartDate
+     *
+     * @return \DateTime
+     */
+    public function getCoachAccessStartDate()
+    {
+        return $this->coachAccessStartDate;
+    }
+
+    /**
+     * Set coachAccessEndDate
+     *
+     * @param \DateTime $coachAccessEndDate
+     * @return Session
+     */
+    public function setCoachAccessEndDate($coachAccessEndDate)
+    {
+        $this->coachAccessEndDate = $coachAccessEndDate;
+
+        return $this;
+    }
+
+    /**
+     * Get coachAccessEndDate
+     *
+     * @return \DateTime
+     */
+    public function getCoachAccessEndDate()
+    {
+        return $this->coachAccessEndDate;
+    }
+
+    /**
+     * Get id
+     *
+     * @return integer
+     */
+    public function getGeneralCoach()
+    {
+        return $this->generalCoach;
+    }
+
+    /**
+     * @param $coach
+     */
+    public function setGeneralCoach($coach)
+    {
+        $this->generalCoach = $coach;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getCategory()
+    {
+        return $this->category;
+    }
+
+    /**
+     * @param $category
+     * @return $this
+     */
+    public function setCategory($category)
+    {
+        $this->category = $category;
+
+        return $this;
+    }
+
+    /**
+     * @return array
+     */
+    public static function getStatusList()
+    {
+        return array(
+            self::VISIBLE => 'status_visible',
+            self::READ_ONLY => 'status_read_only',
+            self::INVISIBLE => 'status_invisible',
+            self::AVAILABLE => 'status_available',
+        );
+    }
+
+    /**
+     * Check if session is visible
+     * @return bool
+     */
+    public function isActive()
+    {
+        $now = new \Datetime('now');
+
+        if ($now > $this->getAccessStartDate()) {
+
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * @param Course $course
+     */
+    public function addCourse(Course $course)
+    {
+        $entity = new SessionRelCourse();
+        $entity->setCourse($course);
+        $this->addCourses($entity);
+    }
+
+    /**
+     * @return ArrayCollection
+     */
+    public function getUserCourseSubscriptions()
+    {
+        return $this->userCourseSubscriptions;
+    }
+
+    /**
+     * @param ArrayCollection $userCourseSubscriptions
+     */
+    public function setUserCourseSubscriptions($userCourseSubscriptions)
+    {
+        $this->userCourseSubscriptions = new ArrayCollection();
+
+        foreach ($userCourseSubscriptions as $item) {
+            $this->addUserCourseSubscription($item);
+        }
+    }
+
+    /**
+     * @param SessionRelCourseRelUser $subscription
+     */
+    public function addUserCourseSubscription(SessionRelCourseRelUser $subscription)
+    {
+        $subscription->setSession($this);
+        if (!$this->hasUserCourseSubscription($subscription)) {
+            $this->userCourseSubscriptions[] = $subscription;
+        }
+    }
+
+    /**
+     * @param int $status
+     * @param User $user
+     * @param Course $course
+     */
+    public function addUserInCourse($status, User $user, Course $course)
+    {
+        $userRelCourseRelSession = new SessionRelCourseRelUser();
+        $userRelCourseRelSession->setCourse($course);
+        $userRelCourseRelSession->setUser($user);
+        $userRelCourseRelSession->setSession($this);
+        $userRelCourseRelSession->setStatus($status);
+        $this->addUserCourseSubscription($userRelCourseRelSession);
+    }
+
+    /**
+     * @param SessionRelCourseRelUser $subscription
+     * @return bool
+     */
+    public function hasUserCourseSubscription(SessionRelCourseRelUser $subscription)
+    {
+        if ($this->getUserCourseSubscriptions()->count()) {
+            $criteria = Criteria::create()->where(
+                Criteria::expr()->eq("user", $subscription->getUser())
+            )->andWhere(
+                Criteria::expr()->eq("course", $subscription->getCourse())
+            )->andWhere(
+                Criteria::expr()->eq("session", $subscription->getSession())
+            );
+            $relation = $this->getUserCourseSubscriptions()->matching($criteria);
+
+            return $relation->count() > 0;
+        }
+
+        return false;
+    }
+
+    /**
+     * @return Course
+     */
+    public function getCurrentCourse()
+    {
+        return $this->currentCourse;
+    }
+
+    /**
+     * @param Course $course
+     * @return $this
+     */
+    public function setCurrentCourse(Course $course)
+    {
+        // If the session is registered in the course session list.
+        if ($this->getCourses()->contains($course->getId())) {
+            $this->currentCourse = $course;
+        }
+        return $this;
+    }
+}

+ 1506 - 0
src/Chamilo/UserBundle/Entity/User.php

@@ -0,0 +1,1506 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\UserBundle\Entity;
+
+use Chamilo\CoreBundle\Entity\UserFieldValues;
+use Sonata\UserBundle\Entity\BaseUser as BaseUser;
+use Doctrine\ORM\Mapping as ORM;
+use Doctrine\Common\Collections\ArrayCollection;
+use Symfony\Component\Security\Core\User\UserInterface;
+use Symfony\Component\Validator\Mapping\ClassMetadata;
+use Symfony\Component\Validator\Constraints as Assert;
+use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
+use Chamilo\CoreBundle\Component\Auth;
+use Doctrine\ORM\Event\LifecycleEventArgs;
+use FOS\MessageBundle\Model\ParticipantInterface;
+use Chamilo\ThemeBundle\Model\UserInterface as ThemeUser;
+//use Vich\UploaderBundle\Mapping\Annotation as Vich;
+use Symfony\Component\HttpFoundation\File\File;
+use Application\Sonata\MediaBundle\Entity\Media;
+use Chamilo\UserBundle\Model\UserInterface as UserInterfaceModel;
+
+use Doctrine\Common\Collections\Collection;
+use Sylius\Component\Attribute\Model\AttributeValueInterface as BaseAttributeValueInterface;
+use Sylius\Component\Variation\Model\OptionInterface as BaseOptionInterface;
+use Sylius\Component\Variation\Model\VariantInterface as BaseVariantInterface;
+
+use Chamilo\CoreBundle\Entity\ExtraFieldValues;
+
+/**
+ * @ORM\HasLifecycleCallbacks
+ * @ORM\Table(name="user")
+ * //Vich\Uploadable
+ * @UniqueEntity("username")
+ * @ORM\Entity(repositoryClass="Chamilo\UserBundle\Repository\UserRepository")
+ * @ORM\AttributeOverrides({
+ *      @ORM\AttributeOverride(name="email",
+ *         column=@ORM\Column(
+ *             name="email",
+ *             type="string",
+ *             length=255,
+ *             unique=false
+ *         )
+ *     ),
+ *     @ORM\AttributeOverride(name="emailCanonical",
+ *         column=@ORM\Column(
+ *             name="emailCanonical",
+ *             type="string",
+ *             length=255,
+ *             unique=false
+ *         )
+ *     )
+ * })
+ *
+ */
+class User extends BaseUser implements ParticipantInterface, ThemeUser
+{
+    const COURSE_MANAGER = 1;
+    const TEACHER = 1;
+    const SESSION_ADMIN = 3;
+    const DRH = 4;
+    const STUDENT = 5;
+    const ANONYMOUS = 6;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="AUTO")
+     */
+    protected $id;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="user_id", type="integer", nullable=true)
+     */
+    protected $userId;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="lastname", type="string", length=60, nullable=true, unique=false)
+     */
+    //protected $lastname;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="firstname", type="string", length=60, nullable=true, unique=false)
+     */
+    //protected $firstname;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="password", type="string", length=50, nullable=false, unique=false)
+     */
+    //protected $password;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="auth_source", type="string", length=50, nullable=true, unique=false)
+     */
+    private $authSource;
+
+    /**
+     * @var boolean
+     *
+     * @ORM\Column(name="status", type="integer", nullable=true)
+     */
+    private $status;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="official_code", type="string", length=40, nullable=true, unique=false)
+     */
+    private $officialCode;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="phone", type="string", length=30, nullable=true, unique=false)
+     */
+    //protected $phone;
+
+    /**
+     * Vich\UploadableField(mapping="user_image", fileNameProperty="picture_uri")
+     *
+     * note This is not a mapped field of entity metadata, just a simple property.
+     *
+     * @var File $imageFile
+     */
+    protected $imageFile;
+
+    /**
+     * @var string
+     * @ORM\Column(name="picture_uri", type="string", length=250, nullable=true, unique=false)
+     */
+    //private $pictureUri;
+
+    /**
+     * @ORM\ManyToOne(targetEntity="Application\Sonata\MediaBundle\Entity\Media", cascade={"all"} )
+     * @ORM\JoinColumn(name="picture_uri", referencedColumnName="id")
+     */
+    protected $pictureUri;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="creator_id", type="integer", nullable=true, unique=false)
+     */
+    private $creatorId;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="competences", type="text", nullable=true, unique=false)
+     */
+    private $competences;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="diplomas", type="text", nullable=true, unique=false)
+     */
+    private $diplomas;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="openarea", type="text", nullable=true, unique=false)
+     */
+    private $openarea;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="teach", type="text", nullable=true, unique=false)
+     */
+    private $teach;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="productions", type="string", length=250, nullable=true, unique=false)
+     */
+    private $productions;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="chatcall_user_id", type="integer", nullable=true, unique=false)
+     */
+    private $chatcallUserId;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="chatcall_date", type="datetime", nullable=true, unique=false)
+     */
+    private $chatcallDate;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="chatcall_text", type="string", length=50, nullable=true, unique=false)
+     */
+    private $chatcallText;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="language", type="string", length=40, nullable=true, unique=false)
+     */
+    private $language;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="registration_date", type="datetime", nullable=false, unique=false)
+     */
+    private $registrationDate;
+
+    /**
+     * @var \DateTime
+     *
+     * @ORM\Column(name="expiration_date", type="datetime", nullable=true, unique=false)
+     */
+    private $expirationDate;
+
+    /**
+     * @var boolean
+     *
+     * @ORM\Column(name="active", type="boolean", nullable=false, unique=false)
+     */
+    private $active;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="openid", type="string", length=255, nullable=true, unique=false)
+     */
+    private $openid;
+
+    /**
+     * @var string
+     *
+     * @ORM\Column(name="theme", type="string", length=255, nullable=true, unique=false)
+     */
+    private $theme;
+
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="hr_dept_id", type="smallint", nullable=true, unique=false)
+     */
+    private $hrDeptId;
+
+    /**
+     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\CourseRelUser", mappedBy="user")
+     **/
+    protected $courses;
+
+    /**
+     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CItemProperty", mappedBy="user")
+     **/
+    //protected $items;
+
+    /**
+     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\UsergroupRelUser", mappedBy="user")
+     **/
+    protected $classes;
+
+    /**
+     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CDropboxPost", mappedBy="user")
+     **/
+    protected $dropBoxReceivedFiles;
+
+    /**
+     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CDropboxFile", mappedBy="userSent")
+     **/
+    protected $dropBoxSentFiles;
+
+    /**
+     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\JuryMembers", mappedBy="user")
+     **/
+    //protected $jurySubscriptions;
+
+    /**
+     * @ORM\ManyToMany(targetEntity="Chamilo\UserBundle\Entity\Group")
+     * @ORM\JoinTable(name="fos_user_user_group",
+     *      joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
+     *      inverseJoinColumns={@ORM\JoinColumn(name="group_id", referencedColumnName="id")}
+     * )
+     */
+    protected $groups;
+
+    /**
+     * @ORM\Column(type="string", length=255)
+     */
+    //protected $salt;
+
+    private $isActive;
+
+    /**
+     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\CurriculumItemRelUser", mappedBy="user")
+     **/
+    protected $curriculumItems;
+
+    /**
+     * @ORM\ManyToMany(targetEntity="Chamilo\CoreBundle\Entity\AccessUrl")
+     * @ORM\JoinTable(
+     *      joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
+     *      inverseJoinColumns={@ORM\JoinColumn(name="access_url_id", referencedColumnName="id")}
+     *      )
+     */
+    protected $portals;
+
+    /**
+     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Session", mappedBy="generalCoach")
+     **/
+    protected $sessionAsGeneralCoach;
+
+    /**
+     * @var ArrayCollection
+     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\UserFieldValues", mappedBy="user", orphanRemoval=true, cascade={"persist"})
+     **/
+    protected $extraFields;
+
+    /**
+     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Resource\ResourceNode", mappedBy="creator")
+     **/
+    protected $resourceNodes;
+
+    /**
+     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SessionRelCourseRelUser", mappedBy="user", cascade={"persist"})
+     **/
+    protected $sessionCourseSubscriptions;
+
+    /**
+     * Constructor
+     */
+    public function __construct()
+    {
+        parent::__construct();
+
+        //$this->salt = sha1(uniqid(null, true));
+        $this->isActive = true;
+        $this->active = 1;
+        $this->registrationDate = new \DateTime();
+
+        $this->courses = new ArrayCollection();
+        $this->items = new ArrayCollection();
+        $this->classes = new ArrayCollection();
+        //$this->roles = new ArrayCollection();
+        $this->curriculumItems = new ArrayCollection();
+        $this->portals = new ArrayCollection();
+        $this->dropBoxSentFiles = new ArrayCollection();
+        $this->dropBoxReceivedFiles = new ArrayCollection();
+        //$this->extraFields = new ArrayCollection();
+        //$this->userId = 0;
+        //$this->createdAt = new \DateTime();
+        //$this->updatedAt = new \DateTime();
+    }
+
+    /**
+     * @return string
+     */
+    public function __toString()
+    {
+        return $this->getUsername();
+    }
+
+    /**
+     * Updates the id with the user_id
+     *  @ORM\PostPersist()
+     */
+    public function postPersist(LifecycleEventArgs $args)
+    {
+        //parent::postPersist();
+        // Updates the user_id field
+        $user = $args->getEntity();
+        $this->setUserId($user->getId());
+        /*$em = $args->getEntityManager();
+        $em->persist($user);
+        $em->flush();*/
+    }
+
+    /**
+     * @param int $userId
+     */
+    public function setId($userId)
+    {
+        $this->id = $userId;
+    }
+
+    /**
+     * @param int $userId
+     */
+    public function setUserId($userId)
+    {
+        if (!empty($userId)) {
+            $this->userId = $userId;
+        }
+    }
+
+    /**
+     * @return int
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * @return string
+     */
+    public function getEncoderName()
+    {
+        return "legacy_encoder";
+    }
+
+    /**
+     * @return ArrayCollection
+     */
+    public function getDropBoxSentFiles()
+    {
+        return $this->dropBoxSentFiles;
+    }
+
+    /**
+     * @return ArrayCollection
+     */
+    public function getDropBoxReceivedFiles()
+    {
+        return $this->dropBoxReceivedFiles;
+    }
+
+    /**
+     * @return ArrayCollection
+     */
+    public function getCourses()
+    {
+        return $this->courses;
+    }
+
+    /**
+     * @return array
+     */
+    public static function getPasswordConstraints()
+    {
+        return
+            array(
+                new Assert\Length(array('min' => 5)),
+                // Alpha numeric + "_" or "-"
+                new Assert\Regex(array(
+                        'pattern' => '/^[a-z\-_0-9]+$/i',
+                        'htmlPattern' => '/^[a-z\-_0-9]+$/i')
+                ),
+                // Min 3 letters - not needed
+                /*new Assert\Regex(array(
+                    'pattern' => '/[a-z]{3}/i',
+                    'htmlPattern' => '/[a-z]{3}/i')
+                ),*/
+                // Min 2 numbers
+                new Assert\Regex(array(
+                        'pattern' => '/[0-9]{2}/',
+                        'htmlPattern' => '/[0-9]{2}/')
+                )
+            )
+            ;
+    }
+
+    /**
+     * @param ClassMetadata $metadata
+     */
+    public static function loadValidatorMetadata(ClassMetadata $metadata)
+    {
+        //$metadata->addPropertyConstraint('firstname', new Assert\NotBlank());
+        //$metadata->addPropertyConstraint('lastname', new Assert\NotBlank());
+        //$metadata->addPropertyConstraint('email', new Assert\Email());
+        /*
+        $metadata->addPropertyConstraint('password',
+            new Assert\Collection(self::getPasswordConstraints())
+        );*/
+
+        /*$metadata->addConstraint(new UniqueEntity(array(
+            'fields'  => 'username',
+            'message' => 'This value is already used.',
+        )));*/
+
+        /*$metadata->addPropertyConstraint(
+            'username',
+            new Assert\Length(array(
+                'min'        => 2,
+                'max'        => 50,
+                'minMessage' => 'This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more.',
+                'maxMessage' => 'This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less.',
+            ))
+        );*/
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function isEqualTo(UserInterface $user)
+    {
+        if (!$user instanceof User) {
+            return false;
+        }
+
+        /*if ($this->password !== $user->getPassword()) {
+            return false;
+        }*/
+
+        /*if ($this->getSalt() !== $user->getSalt()) {
+            return false;
+        }*/
+
+        /*if ($this->username !== $user->getUsername()) {
+            return false;
+        }*/
+
+        return true;
+    }
+
+    /**
+     * @return ArrayCollection
+     */
+    public function getPortals()
+    {
+        return $this->portals;
+    }
+
+    /**
+     * @param $portal
+     */
+    public function setPortal($portal)
+    {
+        $this->portals->add($portal);
+    }
+
+    /**
+     * @return ArrayCollection
+     */
+    public function getCurriculumItems()
+    {
+        return $this->curriculumItems;
+    }
+
+    /**
+     * @param $items
+     */
+    public function setCurriculumItems($items)
+    {
+        $this->curriculumItems = $items;
+    }
+
+    /**
+     * @return bool
+     */
+    public function getIsActive()
+    {
+        return $this->active == 1;
+    }
+
+    /**
+     * @return bool
+     */
+    public function isActive()
+    {
+        return $this->getIsActive();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function isAccountNonExpired()
+    {
+        return true;
+        /*$now = new \DateTime();
+        return $this->getExpirationDate() < $now;*/
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function isAccountNonLocked()
+    {
+        return true;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function isCredentialsNonExpired()
+    {
+        return true;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function isEnabled()
+    {
+        return $this->getActive() == 1;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function eraseCredentials()
+    {
+    }
+
+    /**
+     *
+     * @return ArrayCollection
+     */
+    /*public function getRolesObj()
+    {
+        return $this->roles;
+    }*/
+
+    /**
+     * Set salt
+     *
+     * @param string $salt
+     *
+     * @return User
+     */
+    public function setSalt($salt)
+    {
+        $this->salt = $salt;
+
+        return $this;
+    }
+
+    /**
+     * Get salt
+     *
+     * @return string
+     */
+    public function getSalt()
+    {
+        return $this->salt;
+    }
+
+    /**
+     * @return ArrayCollection
+     */
+    public function getClasses()
+    {
+        return $this->classes;
+    }
+
+    /**
+     *
+     */
+    public function getLps()
+    {
+        //return $this->lps;
+        /*$criteria = Criteria::create()
+            ->where(Criteria::expr()->eq("id", "666"))
+            //->orderBy(array("username" => "ASC"))
+            //->setFirstResult(0)
+            //->setMaxResults(20)
+        ;
+        $lps = $this->lps->matching($criteria);*/
+        /*return $this->lps->filter(
+            function($entry) use ($idsToFilter) {
+                return $entry->getId() == 1;
+        });*/
+    }
+
+    /**
+     * @return string
+     */
+    public function getCompleteName()
+    {
+        return $this->lastname .', '. $this->firstname;
+    }
+
+    /**
+     * Returns the list of classes for the user
+     * @return string
+     */
+    public function getCompleteNameWithClasses()
+    {
+        $classSubscription = $this->getClasses();
+        $classList = array();
+        foreach ($classSubscription as $subscription) {
+            $class = $subscription->getClass();
+            $classList[] = $class->getName();
+        }
+        $classString = !empty($classList) ? ' ['.implode(', ', $classList).']' : null;
+
+        return $this->getCompleteName().$classString;
+    }
+
+    /**
+     * Get userId
+     *
+     * @return integer
+     */
+    public function getUserId()
+    {
+        return $this->userId;
+    }
+
+    /**
+     * 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 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 username
+     *
+     * @param string $username
+     * @return User
+     */
+    public function setUsername($username)
+    {
+        $this->username = $username;
+
+        return $this;
+    }
+
+    /**
+     * Get username
+     *
+     * @return string
+     */
+    public function getUsername()
+    {
+        return $this->username;
+    }
+
+    /**
+     * Set password
+     *
+     * @param string $password
+     * @return User
+     */
+    public function setPassword($password)
+    {
+        $this->password = $password;
+
+        return $this;
+    }
+
+    /**
+     * Get password
+     *
+     * @return string
+     */
+    public function getPassword()
+    {
+        return $this->password;
+    }
+
+    /**
+     * Set authSource
+     *
+     * @param string $authSource
+     * @return User
+     */
+    public function setAuthSource($authSource)
+    {
+        $this->authSource = $authSource;
+
+        return $this;
+    }
+
+    /**
+     * Get authSource
+     *
+     * @return string
+     */
+    public function getAuthSource()
+    {
+        return $this->authSource;
+    }
+
+    /**
+     * 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 status
+     *
+     * @param boolean $status
+     * @return User
+     */
+    public function setStatus($status)
+    {
+        $this->status = $status;
+
+        return $this;
+    }
+
+    /**
+     * Get status
+     *
+     * @return boolean
+     */
+    public function getStatus()
+    {
+        return $this->status;
+    }
+
+    /**
+     * Set officialCode
+     *
+     * @param string $officialCode
+     * @return User
+     */
+    public function setOfficialCode($officialCode)
+    {
+        $this->officialCode = $officialCode;
+
+        return $this;
+    }
+
+    /**
+     * Get officialCode
+     *
+     * @return string
+     */
+    public function getOfficialCode()
+    {
+        return $this->officialCode;
+    }
+
+    /**
+     * Set phone
+     *
+     * @param string $phone
+     * @return User
+     */
+    public function setPhone($phone)
+    {
+        $this->phone = $phone;
+
+        return $this;
+    }
+
+    /**
+     * Get phone
+     *
+     * @return string
+     */
+    public function getPhone()
+    {
+        return $this->phone;
+    }
+
+    /**
+     * Set pictureUri
+     *
+     * @param string $pictureUri
+     * @return User
+     */
+    public function setPictureUri($pictureUri)
+    {
+        $this->pictureUri = $pictureUri;
+
+        return $this;
+    }
+
+    /**
+     * Get pictureUri
+     *
+     * @return Media
+     */
+    public function getPictureUri()
+    {
+        return $this->pictureUri;
+    }
+
+    /**
+     * Set creatorId
+     *
+     * @param integer $creatorId
+     * @return User
+     */
+    public function setCreatorId($creatorId)
+    {
+        $this->creatorId = $creatorId;
+
+        return $this;
+    }
+
+    /**
+     * Get creatorId
+     *
+     * @return integer
+     */
+    public function getCreatorId()
+    {
+        return $this->creatorId;
+    }
+
+    /**
+     * Set competences
+     *
+     * @param string $competences
+     * @return User
+     */
+    public function setCompetences($competences)
+    {
+        $this->competences = $competences;
+
+        return $this;
+    }
+
+    /**
+     * Get competences
+     *
+     * @return string
+     */
+    public function getCompetences()
+    {
+        return $this->competences;
+    }
+
+    /**
+     * Set diplomas
+     *
+     * @param string $diplomas
+     * @return User
+     */
+    public function setDiplomas($diplomas)
+    {
+        $this->diplomas = $diplomas;
+
+        return $this;
+    }
+
+    /**
+     * Get diplomas
+     *
+     * @return string
+     */
+    public function getDiplomas()
+    {
+        return $this->diplomas;
+    }
+
+    /**
+     * Set openarea
+     *
+     * @param string $openarea
+     * @return User
+     */
+    public function setOpenarea($openarea)
+    {
+        $this->openarea = $openarea;
+
+        return $this;
+    }
+
+    /**
+     * Get openarea
+     *
+     * @return string
+     */
+    public function getOpenarea()
+    {
+        return $this->openarea;
+    }
+
+    /**
+     * Set teach
+     *
+     * @param string $teach
+     * @return User
+     */
+    public function setTeach($teach)
+    {
+        $this->teach = $teach;
+
+        return $this;
+    }
+
+    /**
+     * Get teach
+     *
+     * @return string
+     */
+    public function getTeach()
+    {
+        return $this->teach;
+    }
+
+    /**
+     * Set productions
+     *
+     * @param string $productions
+     * @return User
+     */
+    public function setProductions($productions)
+    {
+        $this->productions = $productions;
+
+        return $this;
+    }
+
+    /**
+     * Get productions
+     *
+     * @return string
+     */
+    public function getProductions()
+    {
+        return $this->productions;
+    }
+
+    /**
+     * Set chatcallUserId
+     *
+     * @param integer $chatcallUserId
+     * @return User
+     */
+    public function setChatcallUserId($chatcallUserId)
+    {
+        $this->chatcallUserId = $chatcallUserId;
+
+        return $this;
+    }
+
+    /**
+     * Get chatcallUserId
+     *
+     * @return integer
+     */
+    public function getChatcallUserId()
+    {
+        return $this->chatcallUserId;
+    }
+
+    /**
+     * Set chatcallDate
+     *
+     * @param \DateTime $chatcallDate
+     * @return User
+     */
+    public function setChatcallDate($chatcallDate)
+    {
+        $this->chatcallDate = $chatcallDate;
+
+        return $this;
+    }
+
+    /**
+     * Get chatcallDate
+     *
+     * @return \DateTime
+     */
+    public function getChatcallDate()
+    {
+        return $this->chatcallDate;
+    }
+
+    /**
+     * Set chatcallText
+     *
+     * @param string $chatcallText
+     * @return User
+     */
+    public function setChatcallText($chatcallText)
+    {
+        $this->chatcallText = $chatcallText;
+
+        return $this;
+    }
+
+    /**
+     * Get chatcallText
+     *
+     * @return string
+     */
+    public function getChatcallText()
+    {
+        return $this->chatcallText;
+    }
+
+    /**
+     * Set language
+     *
+     * @param string $language
+     * @return User
+     */
+    public function setLanguage($language)
+    {
+        $this->language = $language;
+
+        return $this;
+    }
+
+    /**
+     * Get language
+     *
+     * @return string
+     */
+    public function getLanguage()
+    {
+        return $this->language;
+    }
+
+    /**
+     * Set registrationDate
+     *
+     * @param \DateTime $registrationDate
+     * @return User
+     */
+    public function setRegistrationDate($registrationDate)
+    {
+        $this->registrationDate = $registrationDate;
+
+        return $this;
+    }
+
+    /**
+     * Get registrationDate
+     *
+     * @return \DateTime
+     */
+    public function getRegistrationDate()
+    {
+        return $this->registrationDate;
+    }
+
+    /**
+     * Set expirationDate
+     *
+     * @param \DateTime $expirationDate
+     * @return User
+     */
+    public function setExpirationDate($expirationDate)
+    {
+        if (!empty($expirationDate)) {
+            $this->expirationDate = $expirationDate;
+        }
+
+        return $this;
+    }
+
+    /**
+     * Get expirationDate
+     *
+     * @return \DateTime
+     */
+    public function getExpirationDate()
+    {
+        return $this->expirationDate;
+    }
+
+    /**
+     * Set active
+     *
+     * @param boolean $active
+     * @return User
+     */
+    public function setActive($active)
+    {
+        $this->active = $active;
+
+        return $this;
+    }
+
+    /**
+     * Get active
+     *
+     * @return boolean
+     */
+    public function getActive()
+    {
+        return $this->active;
+    }
+
+    /**
+     * Set openid
+     *
+     * @param string $openid
+     * @return User
+     */
+    public function setOpenid($openid)
+    {
+        $this->openid = $openid;
+
+        return $this;
+    }
+
+    /**
+     * Get openid
+     *
+     * @return string
+     */
+    public function getOpenid()
+    {
+        return $this->openid;
+    }
+
+    /**
+     * Set theme
+     *
+     * @param string $theme
+     * @return User
+     */
+    public function setTheme($theme)
+    {
+        $this->theme = $theme;
+
+        return $this;
+    }
+
+    /**
+     * Get theme
+     *
+     * @return string
+     */
+    public function getTheme()
+    {
+        return $this->theme;
+    }
+
+    /**
+     * Set hrDeptId
+     *
+     * @param integer $hrDeptId
+     * @return User
+     */
+    public function setHrDeptId($hrDeptId)
+    {
+        $this->hrDeptId = $hrDeptId;
+
+        return $this;
+    }
+
+    /**
+     * Get hrDeptId
+     *
+     * @return integer
+     */
+    public function getHrDeptId()
+    {
+        return $this->hrDeptId;
+    }
+
+    /**
+     * @return Media
+     */
+    public function getAvatar()
+    {
+        return $this->getPictureUri();
+    }
+
+    /**
+     * @return \DateTime
+     */
+    public function getMemberSince()
+    {
+        return $this->registrationDate;
+    }
+
+    /**
+     * @return bool
+     */
+    public function isOnline()
+    {
+        return false;
+    }
+
+    /**
+     * @return int
+     */
+    public function getIdentifier()
+    {
+        return $this->getId();
+    }
+
+    /**
+     * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
+     * of 'UploadedFile' is injected into this setter to trigger the  update. If this
+     * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
+     * must be able to accept an instance of 'File' as the bundle will inject one here
+     * during Doctrine hydration.
+     *
+     * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
+     */
+    public function setImageFile(File $image)
+    {
+        $this->imageFile = $image;
+
+        if ($image) {
+            // It is required that at least one field changes if you are using doctrine
+            // otherwise the event listeners won't be called and the file is lost
+            $this->updatedAt = new \DateTime('now');
+        }
+    }
+
+    /**
+     * @return File
+     */
+    public function getImageFile()
+    {
+        return $this->imageFile;
+    }
+
+    /**
+     * @param string $imageName
+     */
+    public function setImageName($imageName)
+    {
+        $this->imageName = $imageName;
+    }
+
+    /**
+     * @return string
+     */
+    public function getImageName()
+    {
+        return $this->imageName;
+    }
+
+    /**
+     * @return string
+     */
+    public function getSlug()
+    {
+        return $this->getUsername();
+    }
+
+    /**
+     * @param $slug
+     * @return User
+     */
+    public function setSlug($slug)
+    {
+        return $this->setUsername($slug);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getExtraFields()
+    {
+        return $this->extraFields;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function setExtraFields($extraFields)
+    {
+        $this->extraFields = new ArrayCollection();
+        foreach ($extraFields as $extraField) {
+            $this->addExtraFields($extraField);
+        }
+
+        return $this;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    /*public function addExtraFields(ExtraFieldValues $extraFieldValue)
+    {
+        $extraFieldValue->setUser($this);
+        $this->extraFields[] = $extraFieldValue;
+
+        return $this;
+    }*/
+
+    /**
+     * {@inheritdoc}
+     */
+    public function addExtraFields(UserFieldValues $extraFieldValue)
+    {
+        //if (!$this->hasExtraField($attribute)) {
+        $extraFieldValue->setUser($this);
+        $this->extraFields[] = $extraFieldValue;
+        //}
+
+        return $this;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function removeExtraField(ExtraFieldValues $attribute)
+    {
+        //if ($this->hasExtraField($attribute)) {
+            //$this->extraFields->removeElement($attribute);
+            //$attribute->setUser($this);
+        //}
+
+        return $this;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    /*public function hasExtraField($attribute)
+    {
+        if (!$this->extraFields) {
+            return false;
+        }
+        return $this->extraFields->contains($attribute);
+    }*/
+
+    /**
+     * {@inheritdoc}
+     */
+    public function hasExtraFieldByName($attributeName)
+    {
+        foreach ($this->extraFields as $attribute) {
+            if ($attribute->getName() === $attributeName) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getExtraFieldByName($attributeName)
+    {
+        foreach ($this->extraFields as $attribute) {
+            if ($attribute->getName() === $attributeName) {
+                return $attribute;
+            }
+        }
+
+        return null;
+    }
+}