You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
226 lines
4.1 KiB
226 lines
4.1 KiB
<?php
|
|
|
|
/* For licensing terms, see /license.txt */
|
|
|
|
namespace Chamilo\CoreBundle\Entity;
|
|
|
|
use ApiPlatform\Core\Annotation\ApiResource;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Gedmo\Timestampable\Traits\TimestampableEntity;
|
|
|
|
/**
|
|
* @ApiResource(
|
|
* attributes={"security"="is_granted('ROLE_ADMIN')"},
|
|
* normalizationContext={"groups"={"usergroup:read"}}
|
|
* )
|
|
*
|
|
* @ORM\Table(name="usergroup")
|
|
* @ORM\Entity
|
|
*/
|
|
class Usergroup
|
|
{
|
|
use TimestampableEntity;
|
|
|
|
/**
|
|
* @var int
|
|
*
|
|
* @ORM\Column(name="id", type="integer", nullable=false)
|
|
* @ORM\Id
|
|
* @ORM\GeneratedValue
|
|
*/
|
|
protected $id;
|
|
|
|
/**
|
|
* @var string
|
|
*
|
|
* @ORM\Column(name="name", type="string", length=255, nullable=false, unique=false)
|
|
*/
|
|
protected $name;
|
|
|
|
/**
|
|
* @var string
|
|
*
|
|
* @ORM\Column(name="description", type="text", nullable=true)
|
|
*/
|
|
protected $description;
|
|
|
|
/**
|
|
* @var int
|
|
*
|
|
* @ORM\Column(name="group_type", type="integer", nullable=false)
|
|
*/
|
|
protected $groupType;
|
|
|
|
/**
|
|
* @var string
|
|
*
|
|
* @ORM\Column(name="picture", type="string", length=255, nullable=true)
|
|
*/
|
|
protected $picture;
|
|
|
|
/**
|
|
* @var string
|
|
*
|
|
* @ORM\Column(name="url", type="string", length=255, nullable=true)
|
|
*/
|
|
protected $url;
|
|
|
|
/**
|
|
* @var string
|
|
*
|
|
* @ORM\Column(name="visibility", type="string", length=255, nullable=false)
|
|
*/
|
|
protected $visibility;
|
|
|
|
/**
|
|
* @var string
|
|
*
|
|
* @ORM\Column(name="author_id", type="integer", nullable=true)
|
|
*/
|
|
protected $authorId;
|
|
|
|
/**
|
|
* @var int
|
|
*
|
|
* @ORM\Column(name="allow_members_leave_group", type="integer")
|
|
*/
|
|
protected $allowMembersToLeaveGroup;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="UsergroupRelUser", mappedBy="usergroup", cascade={"persist"}, orphanRemoval=true)
|
|
*/
|
|
protected $users;
|
|
|
|
/**
|
|
* Usergroup constructor.
|
|
*/
|
|
public function __construct()
|
|
{
|
|
//$this->users = new ArrayCollection();
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function __toString()
|
|
{
|
|
return (string) $this->getName();
|
|
}
|
|
|
|
/**
|
|
* @return ArrayCollection
|
|
*/
|
|
public function getUsers()
|
|
{
|
|
return $this->users;
|
|
}
|
|
|
|
/**
|
|
* @param $users
|
|
*/
|
|
public function setUsers($users)
|
|
{
|
|
$this->users = new ArrayCollection();
|
|
|
|
foreach ($users as $user) {
|
|
$this->addUsers($user);
|
|
}
|
|
}
|
|
|
|
public function addUsers(UsergroupRelUser $user)
|
|
{
|
|
$user->setUsergroup($this);
|
|
$this->users[] = $user;
|
|
}
|
|
|
|
/**
|
|
* Remove $user.
|
|
*/
|
|
public function removeUsers(UsergroupRelUser $user)
|
|
{
|
|
foreach ($this->users as $key => $value) {
|
|
if ($value->getId() == $user->getId()) {
|
|
unset($this->users[$key]);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get id.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function getId()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
/**
|
|
* Set name.
|
|
*
|
|
* @param string $name
|
|
*
|
|
* @return Usergroup
|
|
*/
|
|
public function setName($name)
|
|
{
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get name.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getName()
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
/**
|
|
* Set description.
|
|
*
|
|
* @param string $description
|
|
*
|
|
* @return Usergroup
|
|
*/
|
|
public function setDescription($description)
|
|
{
|
|
$this->description = $description;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Get description.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getDescription()
|
|
{
|
|
return $this->description;
|
|
}
|
|
|
|
/**
|
|
* @return int
|
|
*/
|
|
public function getGroupType()
|
|
{
|
|
return $this->groupType;
|
|
}
|
|
|
|
/**
|
|
* @param int $groupType
|
|
*
|
|
* @return Usergroup
|
|
*/
|
|
public function setGroupType($groupType)
|
|
{
|
|
$this->groupType = $groupType;
|
|
|
|
return $this;
|
|
}
|
|
}
|
|
|