Skip to content

Commit

Permalink
[Community] fixes organization managers flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Elorfin committed Oct 26, 2023
1 parent 104d34d commit 209420a
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/main/core/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@

/**
* @ORM\Entity(repositoryClass="Claroline\CommunityBundle\Repository\UserRepository")
*
* @ORM\Table(
* name="claro_user",
* indexes={
*
* @ORM\Index(name="code_idx", columns={"administrative_code"}),
* @ORM\Index(name="enabled_idx", columns={"is_enabled"}),
* @ORM\Index(name="is_removed", columns={"is_removed"})
Expand All @@ -53,6 +55,7 @@ class User extends AbstractRoleSubject implements UserInterface, EquatableInterf
* @var string
*
* @ORM\Column(name="first_name", length=50)
*
* @Assert\NotBlank()
*/
private $firstName;
Expand All @@ -61,6 +64,7 @@ class User extends AbstractRoleSubject implements UserInterface, EquatableInterf
* @var string
*
* @ORM\Column(name="last_name", length=50)
*
* @Assert\NotBlank()
*/
private $lastName;
Expand All @@ -69,7 +73,9 @@ class User extends AbstractRoleSubject implements UserInterface, EquatableInterf
* @var string
*
* @ORM\Column(unique=true)
*
* @Assert\NotBlank()
*
* @Assert\Length(min="3")
*/
private $username;
Expand Down Expand Up @@ -99,6 +105,7 @@ class User extends AbstractRoleSubject implements UserInterface, EquatableInterf
* @var string
*
* @Assert\NotBlank(groups={"registration"})
*
* @Assert\Length(min="4", groups={"registration"})
*/
private $plainPassword;
Expand All @@ -114,7 +121,9 @@ class User extends AbstractRoleSubject implements UserInterface, EquatableInterf
* @var string
*
* @ORM\Column(unique=true, name="mail")
*
* @Assert\NotBlank()
*
* @Assert\Email(mode="strict")
*/
private $email;
Expand All @@ -133,6 +142,7 @@ class User extends AbstractRoleSubject implements UserInterface, EquatableInterf
* targetEntity="Claroline\CoreBundle\Entity\Group",
* inversedBy="users"
* )
*
* @ORM\JoinTable(name="claro_user_group")
*/
private $groups;
Expand All @@ -146,6 +156,7 @@ class User extends AbstractRoleSubject implements UserInterface, EquatableInterf
* fetch="EXTRA_LAZY",
* cascade={"merge", "refresh"}
* )
*
* @ORM\JoinTable(name="claro_user_role")
*/
protected $roles;
Expand All @@ -157,6 +168,7 @@ class User extends AbstractRoleSubject implements UserInterface, EquatableInterf
* targetEntity="Claroline\CoreBundle\Entity\Workspace\Workspace",
* cascade={"persist", "remove"}
* )
*
* @ORM\JoinColumn(name="workspace_id", onDelete="SET NULL")
*/
private $personalWorkspace;
Expand All @@ -165,6 +177,7 @@ class User extends AbstractRoleSubject implements UserInterface, EquatableInterf
* @var \DateTime
*
* @ORM\Column(name="creation_date", type="datetime")
*
* @Gedmo\Timestampable(on="create")
*/
private $created;
Expand Down Expand Up @@ -278,6 +291,7 @@ class User extends AbstractRoleSubject implements UserInterface, EquatableInterf
* mappedBy="user",
* cascade={"all"}
* )
*
* @ORM\JoinColumn(name="user_id", nullable=false)
*
* @var ArrayCollection|UserOrganizationReference[]
Expand Down Expand Up @@ -771,11 +785,10 @@ public function addOrganization(Organization $organization, ?bool $managed = fal
$ref = new UserOrganizationReference();
$ref->setOrganization($organization);
$ref->setUser($this);
$ref->setManager($managed);

$this->userOrganizationReferences->add($ref);
}

$ref->setManager($managed);
}

public function removeOrganization(Organization $organization): void
Expand All @@ -791,7 +804,7 @@ public function removeOrganization(Organization $organization): void

if ($found) {
$this->userOrganizationReferences->removeElement($found);
//this is the line doing all the work. I'm not sure the previous one is useful
// this is the line doing all the work. I'm not sure the previous one is useful
$found->getOrganization()->removeUser($this);
}
}
Expand Down Expand Up @@ -849,7 +862,7 @@ public function setRemoved($isRemoved): void
$this->isRemoved = $isRemoved;
}

//alias
// alias
public function remove(): void
{
$this->setRemoved(true);
Expand Down

0 comments on commit 209420a

Please sign in to comment.