Updating entities.

1.10.x
Julio Montoya 11 years ago
parent 86b16a2774
commit 7c26a8bb69
  1. 32
      src/Application/Sonata/UserBundle/Entity/Group.php
  2. 1271
      src/Application/Sonata/UserBundle/Entity/User.php
  3. 18
      src/Application/Sonata/UserBundle/Repository/GroupRepository.php
  4. 58
      src/Application/Sonata/UserBundle/Repository/UserRepository.php
  5. 20
      src/ChamiloLMS/CoreBundle/Entity/CGroupInfo.php
  6. 15
      src/ChamiloLMS/CoreBundle/Entity/Course.php
  7. 129
      src/ChamiloLMS/CoreBundle/Entity/CourseRelUser.php

@ -0,0 +1,32 @@
<?php
namespace Application\Sonata\UserBundle\Entity;
use Sonata\UserBundle\Entity\BaseGroup as BaseGroup;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="Application\Sonata\UserBundle\Repository\GroupRepository")
* @ORM\Table(name="fos_group")
*/
class Group extends BaseGroup
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* Get id
*
* @return integer $id
*/
public function getId()
{
return $this->id;
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,18 @@
<?php
namespace Application\Sonata\UserBundle\Repository;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\NoResultException;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Application\Sonata\UserBundle\Entity\User as User;
/**
* Class UserRepository
* @package Entity\Repository
*/
class GroupRepository extends EntityRepository
{
}

@ -1,12 +1,12 @@
<?php
namespace ChamiloLMS\CoreBundle\Entity\Repository;
namespace Application\Sonata\UserBundle\Repository;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\NoResultException;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use ChamiloLMS\UserBundle\Entity\User;
use Application\Sonata\UserBundle\Entity\User as User;
/**
* Class UserRepository
@ -66,27 +66,6 @@ class UserRepository extends EntityRepository
return $user;
}*/
/**
* Refreshes the user for the account interface.
*
* It is up to the implementation if it decides to reload the user data
* from the database, or if it simply merges the passed User into the
* identity map of an entity manager.
*
* @throws UnsupportedUserException if the account is not supported
* @param UserInterface $user
*
* @return UserInterface
*/
/*public function refreshUser(UserInterface $user)
{
//return $user;
$class = get_class($user);
if (!$this->supportsClass($class)) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $class));
}
return $this->loadUserByUsername($user->getUsername());
}*/
/**
* @param string $class
@ -127,4 +106,37 @@ class UserRepository extends EntityRepository
return $query->execute();
}
public function getTeachers()
{
$queryBuilder = $this->createQueryBuilder('u');
// Selecting course info.
$queryBuilder
->select('u')
->where('u.groups.id = :groupId')
->setParameter('groupId', 1);
$query = $queryBuilder->getQuery();
return $query->execute();
/*$studentGroup = $this->findOneBy(array('name' => 'students'));
return $this->getUsers($studentGroup);*/
}
public function getUsers($group)
{
$queryBuilder = $this->createQueryBuilder('u');
// Selecting course info.
$queryBuilder
->select('u')
->where('u.groups = :groupId')
->setParameter('groupId', $group);
$query = $queryBuilder->getQuery();
return $query->execute();
}
}

@ -16,23 +16,23 @@ class CGroupInfo
/**
* @var integer
*
* @ORM\Column(name="c_id", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Column(name="iid", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $cId;
private $iid;
/**
* @var integer
*
* @ORM\Column(name="iid", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(name="c_id", type="integer", precision=0, scale=0, nullable=false, unique=false)
*/
private $iid;
private $cId;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Column(name="id", type="integer", precision=0, scale=0, unique=false)
*/
private $id;
@ -141,12 +141,16 @@ class CGroupInfo
*/
private $sessionId;
/**
* @ORM\OneToMany(targetEntity="CItemProperty", mappedBy="group")
**/
private $items;
/**
* @ORM\OneToMany(targetEntity="CourseRelUser", mappedBy="group")
**/
protected $course;
/**
*
*/

@ -5,6 +5,7 @@ namespace ChamiloLMS\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Course
*
@ -198,7 +199,7 @@ class Course
private $courseTypeId;
/**
* @ORM\OneToMany(targetEntity="CourseRelUser", mappedBy="course")
* @ORM\OneToMany(targetEntity="CourseRelUser", mappedBy="course", cascade={"persist", "remove"})
**/
private $users;
@ -208,10 +209,15 @@ class Course
private $items;
/**
* @ORM\OneToMany(targetEntity="CurriculumCategory", mappedBy="course")
* ORM\OneToMany(targetEntity="CurriculumCategory", mappedBy="course")
**/
//private $curriculumCategories;
public function __toString()
{
return strval($this->getTitle());
}
/*public function __construct()
{
$this->users = new ArrayCollection();
@ -234,6 +240,11 @@ class Course
return $this->users;
}
public function addUser(CourseRelUser $user)
{
$this->users[] = $user;
}
/**
* Set id
*

@ -21,19 +21,12 @@ class CourseRelUser
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="course_code", type="string", length=40, precision=0, scale=0, nullable=false, unique=false)
*/
private $courseCode;
/**
* @var integer
*
* @ORM\Column(name="user_id", type="integer")
*/
private $userId;
//private $userId;
/**
* @var integer
@ -59,14 +52,14 @@ class CourseRelUser
/**
* @var integer
*
* @ORM\Column(name="group_id", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Column(name="group_id", type="integer", precision=0, scale=0, nullable=true, unique=false)
*/
private $groupId;
//private $groupId;
/**
* @var integer
*
* @ORM\Column(name="tutor_id", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Column(name="tutor_id", type="integer", precision=0, scale=0, nullable=true, unique=false)
*/
private $tutorId;
@ -96,24 +89,70 @@ class CourseRelUser
*
* @ORM\Column(name="c_id", type="integer", precision=0, scale=0, nullable=false, unique=false)
*/
protected $cId;
//protected $cId;
/**
* @ORM\ManyToOne(targetEntity="Application\Sonata\UserBundle\Entity\User", inversedBy="courses")
* @ORM\ManyToOne(targetEntity="Application\Sonata\UserBundle\Entity\User", inversedBy="courses", cascade={"persist", "remove"})
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected $user;
/**
* @ORM\ManyToOne(targetEntity="Course", inversedBy="users")
* @ORM\ManyToOne(targetEntity="Course", inversedBy="users", cascade={"persist", "remove"})
* @ORM\JoinColumn(name="c_id", referencedColumnName="id")
*/
protected $course;
public function __construct(Course $course, User $user)
/**
* @ORM\ManyToOne(targetEntity="CGroupInfo", inversedBy="course", cascade={"persist", "remove"})
* @ORM\JoinColumn(name="group_id", referencedColumnName="iid")
*/
protected $group;
public function __toString()
{
$this->course = $course;
$this->user = $user;
return strval($this->getCourse()->getCode());
}
public function __construct()
{
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param int $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @param $group
* @return $this
*/
public function setGroup($group)
{
$this->group = $group;
return $this;
}
/**
* Get group
*
* @return integer
*/
public function getGroup()
{
return $this->group;
}
/**
@ -139,27 +178,42 @@ class CourseRelUser
return $this->cId;
}
public function setCourse($course)
{
$this->course = $course;
return $this;
}
/**
* Set courseCode
* Get Course
*
* @param string $courseCode
* @return CourseRelUser
* @return string
*/
public function setCourseCode($courseCode)
public function getCourse()
{
$this->courseCode = $courseCode;
return $this->course;
}
/**
* @param $user
* @return $this
*/
public function setUser($user)
{
$this->user = $user;
return $this;
}
/**
* Get courseCode
* Get User
*
* @return string
*/
public function getCourseCode()
public function getUser()
{
return $this->courseCode;
return $this->user;
}
/**
@ -368,4 +422,29 @@ class CourseRelUser
{
return $this->legalAgreement;
}
/**
* Get relation_type list
*
* @return array
*/
public static function getRelationTypeList()
{
return array(
'0' => '',
COURSE_RELATION_TYPE_RRHH => 'drh',
);
}
/**
* Get status list
* @return array
*/
public static function getStatusList()
{
return array(
COURSEMANAGER => 'Teacher',
STUDENT => 'Student'
);
}
}

Loading…
Cancel
Save