* * @ORM\OneToMany(targetEntity="CGroupRelUser", mappedBy="group") */ protected Collection $members; /** * @var CGroupRelTutor[]|Collection * * @ORM\OneToMany(targetEntity="CGroupRelTutor", mappedBy="group") */ protected Collection $tutors; public function __construct() { $this->status = true; $this->members = new ArrayCollection(); $this->tutors = new ArrayCollection(); } public function __toString(): string { return $this->getName(); } /** * Get iid. * * @return int */ public function getIid() { return $this->iid; } /** * Set name. * * @param string $name */ public function setName($name): self { $this->name = $name; return $this; } public function getName(): string { return $this->name; } /** * Set status. * * @param bool $status */ public function setStatus($status): self { $this->status = $status; return $this; } /** * Get status. * * @return bool */ public function getStatus() { return $this->status; } public function setDescription(string $description): self { $this->description = $description; return $this; } public function getDescription(): ?string { return $this->description; } public function setMaxStudent(int $maxStudent): self { $this->maxStudent = $maxStudent; return $this; } public function getMaxStudent(): int { return $this->maxStudent; } public function setDocState(int $docState): self { $this->docState = $docState; return $this; } /** * Get docState. * * @return int */ public function getDocState() { return $this->docState; } /** * Set calendarState. * * @param int $calendarState */ public function setCalendarState($calendarState): self { $this->calendarState = $calendarState; return $this; } /** * Get calendarState. * * @return int */ public function getCalendarState() { return $this->calendarState; } /** * Set workState. * * @param int $workState */ public function setWorkState($workState): self { $this->workState = $workState; return $this; } /** * Get workState. * * @return int */ public function getWorkState() { return $this->workState; } /** * Set announcementsState. * * @param int $announcementsState */ public function setAnnouncementsState($announcementsState): self { $this->announcementsState = $announcementsState; return $this; } /** * Get announcementsState. * * @return int */ public function getAnnouncementsState() { return $this->announcementsState; } /** * Set forumState. * * @param int $forumState */ public function setForumState($forumState): self { $this->forumState = $forumState; return $this; } public function getForumState(): int { return $this->forumState; } /** * Set wikiState. * * @param int $wikiState */ public function setWikiState($wikiState): self { $this->wikiState = $wikiState; return $this; } /** * Get wikiState. * * @return int */ public function getWikiState() { return $this->wikiState; } /** * Set chatState. * * @param int $chatState */ public function setChatState($chatState): self { $this->chatState = $chatState; return $this; } /** * Get chatState. * * @return int */ public function getChatState() { return $this->chatState; } /** * Set selfRegistrationAllowed. * * @param bool $selfRegistrationAllowed */ public function setSelfRegistrationAllowed($selfRegistrationAllowed): self { $this->selfRegistrationAllowed = $selfRegistrationAllowed; return $this; } /** * Get selfRegistrationAllowed. * * @return bool */ public function getSelfRegistrationAllowed() { return $this->selfRegistrationAllowed; } /** * Set selfUnregistrationAllowed. * * @param bool $selfUnregistrationAllowed */ public function setSelfUnregistrationAllowed($selfUnregistrationAllowed): self { $this->selfUnregistrationAllowed = $selfUnregistrationAllowed; return $this; } /** * Get selfUnregistrationAllowed. * * @return bool */ public function getSelfUnregistrationAllowed() { return $this->selfUnregistrationAllowed; } public function getDocumentAccess(): int { return $this->documentAccess; } public function setDocumentAccess(int $documentAccess): self { $this->documentAccess = $documentAccess; return $this; } public function getMembers(): Collection { return $this->members; } /** * @param CGroupRelUser[]|Collection $members */ public function setMembers(Collection $members): self { $this->members = $members; return $this; } public function hasMembers(): bool { return $this->members->count() > 0; } public function hasMember(User $user): bool { $criteria = Criteria::create()->where( Criteria::expr()->eq('user', $user) ); return $this->members->matching($criteria)->count() > 0; } public function hasTutor(User $user): bool { $criteria = Criteria::create()->where( Criteria::expr()->eq('user', $user) ); return $this->tutors->matching($criteria)->count() > 0; } public function getTutors(): Collection { return $this->tutors; } /** * @param CGroupRelTutor[]|Collection $tutors */ public function setTutors(Collection $tutors): self { $this->tutors = $tutors; return $this; } public function hasTutors(): bool { return $this->tutors->count() > 0; } public function userIsTutor(User $user = null): bool { if (null === $user) { return false; } if (0 === $this->tutors->count()) { return false; } $criteria = Criteria::create() ->andWhere( Criteria::expr()->eq('user', $user) ) ; $relation = $this->tutors->matching($criteria); return $relation->count() > 0; } public function getCategory(): CGroupCategory { return $this->category; } public function setCategory(CGroupCategory $category = null): self { $this->category = $category; return $this; } public function getResourceIdentifier(): int { return $this->iid; } public function getResourceName(): string { return $this->getName(); } public function setResourceName(string $name): self { return $this->setName($name); } }