Release 2.0.34 (#4281)
This commit is contained in:
@@ -232,7 +232,7 @@ class Activity implements EntityWithMetaFields, EntityWithBudget
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addTeam(Team $team)
|
||||
public function addTeam(Team $team): void
|
||||
{
|
||||
if ($this->teams->contains($team)) {
|
||||
return;
|
||||
@@ -242,7 +242,7 @@ class Activity implements EntityWithMetaFields, EntityWithBudget
|
||||
$team->addActivity($this);
|
||||
}
|
||||
|
||||
public function removeTeam(Team $team)
|
||||
public function removeTeam(Team $team): void
|
||||
{
|
||||
if (!$this->teams->contains($team)) {
|
||||
return;
|
||||
|
||||
@@ -15,17 +15,17 @@ interface CommentInterface
|
||||
|
||||
public function getMessage(): ?string;
|
||||
|
||||
public function setMessage(string $message);
|
||||
public function setMessage(string $message): void;
|
||||
|
||||
public function getCreatedBy(): ?User;
|
||||
|
||||
public function setCreatedBy(User $createdBy);
|
||||
public function setCreatedBy(User $createdBy): void;
|
||||
|
||||
public function getCreatedAt(): ?\DateTime;
|
||||
|
||||
public function setCreatedAt(\DateTime $createdAt);
|
||||
public function setCreatedAt(\DateTime $createdAt): void;
|
||||
|
||||
public function isPinned(): bool;
|
||||
|
||||
public function setPinned(bool $pinned);
|
||||
public function setPinned(bool $pinned): void;
|
||||
}
|
||||
|
||||
@@ -440,7 +440,7 @@ class Customer implements EntityWithMetaFields, EntityWithBudget
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addTeam(Team $team)
|
||||
public function addTeam(Team $team): void
|
||||
{
|
||||
if ($this->teams->contains($team)) {
|
||||
return;
|
||||
@@ -450,7 +450,7 @@ class Customer implements EntityWithMetaFields, EntityWithBudget
|
||||
$team->addCustomer($this);
|
||||
}
|
||||
|
||||
public function removeTeam(Team $team)
|
||||
public function removeTeam(Team $team): void
|
||||
{
|
||||
if (!$this->teams->contains($team)) {
|
||||
return;
|
||||
|
||||
@@ -253,7 +253,7 @@ class Project implements EntityWithMetaFields, EntityWithBudget
|
||||
* Make sure begin and end date have the correct timezone.
|
||||
* This will be called once for each item after being loaded from the database.
|
||||
*/
|
||||
protected function localizeDates()
|
||||
protected function localizeDates(): void
|
||||
{
|
||||
if ($this->localized) {
|
||||
return;
|
||||
@@ -392,7 +392,7 @@ class Project implements EntityWithMetaFields, EntityWithBudget
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addTeam(Team $team)
|
||||
public function addTeam(Team $team): void
|
||||
{
|
||||
if ($this->teams->contains($team)) {
|
||||
return;
|
||||
@@ -402,7 +402,7 @@ class Project implements EntityWithMetaFields, EntityWithBudget
|
||||
$team->addProject($this);
|
||||
}
|
||||
|
||||
public function removeTeam(Team $team)
|
||||
public function removeTeam(Team $team): void
|
||||
{
|
||||
if (!$this->teams->contains($team)) {
|
||||
return;
|
||||
|
||||
@@ -371,7 +371,7 @@ class User implements UserInterface, EquatableInterface, ThemeUserInterface, Pas
|
||||
* @param string $name
|
||||
* @param bool|int|string|float|null $value
|
||||
*/
|
||||
public function setPreferenceValue(string $name, $value = null)
|
||||
public function setPreferenceValue(string $name, $value = null): void
|
||||
{
|
||||
$pref = $this->getPreference($name);
|
||||
|
||||
@@ -421,7 +421,7 @@ class User implements UserInterface, EquatableInterface, ThemeUserInterface, Pas
|
||||
return $this->getLocale();
|
||||
}
|
||||
|
||||
public function setLanguage(?string $language)
|
||||
public function setLanguage(?string $language): void
|
||||
{
|
||||
if ($language === null) {
|
||||
$language = User::DEFAULT_LANGUAGE;
|
||||
@@ -449,7 +449,7 @@ class User implements UserInterface, EquatableInterface, ThemeUserInterface, Pas
|
||||
return (string) $this->getPreferenceValue(UserPreference::SKIN, 'default', false);
|
||||
}
|
||||
|
||||
public function setTimezone(?string $timezone)
|
||||
public function setTimezone(?string $timezone): void
|
||||
{
|
||||
if ($timezone === null) {
|
||||
$timezone = date_default_timezone_get();
|
||||
@@ -536,7 +536,9 @@ class User implements UserInterface, EquatableInterface, ThemeUserInterface, Pas
|
||||
}
|
||||
|
||||
$this->memberships->removeElement($member);
|
||||
$member->getTeam()->removeMember($member);
|
||||
if ($member->getTeam() !== null) {
|
||||
$member->getTeam()->removeMember($member);
|
||||
}
|
||||
$member->setUser(null);
|
||||
$member->setTeam(null);
|
||||
}
|
||||
@@ -590,7 +592,7 @@ class User implements UserInterface, EquatableInterface, ThemeUserInterface, Pas
|
||||
public function hasTeamMember(User $user): bool
|
||||
{
|
||||
foreach ($this->memberships as $membership) {
|
||||
if ($membership->getTeam()->hasUser($user)) {
|
||||
if ($membership->getTeam() !== null && $membership->getTeam()->hasUser($user)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -598,6 +600,34 @@ class User implements UserInterface, EquatableInterface, ThemeUserInterface, Pas
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this function to check if the current user can read data from the given user.
|
||||
*/
|
||||
public function canSeeUser(User $user): bool
|
||||
{
|
||||
if ($user->getId() === $this->getId()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->canSeeAllData()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!$user->isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->isSystemAccount() && $user->isSystemAccount()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->isTeamleadOfUser($user)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of all teams, this user is part of
|
||||
*
|
||||
@@ -673,6 +703,17 @@ class User implements UserInterface, EquatableInterface, ThemeUserInterface, Pas
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isTeamleadOfUser(User $user): bool
|
||||
{
|
||||
foreach ($this->memberships as $membership) {
|
||||
if ($membership->isTeamlead() && $membership->getTeam() !== null && $membership->getTeam()->hasUser($user)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function canSeeAllData(): bool
|
||||
{
|
||||
return $this->isSuperAdmin() || true === $this->isAllowedToSeeAllData;
|
||||
@@ -708,7 +749,7 @@ class User implements UserInterface, EquatableInterface, ThemeUserInterface, Pas
|
||||
return $this->hasRole(static::ROLE_ADMIN);
|
||||
}
|
||||
|
||||
public function getDisplayName(): ?string
|
||||
public function getDisplayName(): string
|
||||
{
|
||||
if (!empty($this->getAlias())) {
|
||||
return $this->getAlias();
|
||||
@@ -744,18 +785,16 @@ class User implements UserInterface, EquatableInterface, ThemeUserInterface, Pas
|
||||
return $this->auth === null || $this->auth === self::AUTH_INTERNAL;
|
||||
}
|
||||
|
||||
public function addRole(string $role)
|
||||
public function addRole(string $role): void
|
||||
{
|
||||
$role = strtoupper($role);
|
||||
if ($role === static::DEFAULT_ROLE) {
|
||||
return $this;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!\in_array($role, $this->roles, true)) {
|
||||
$this->roles[] = $role;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function eraseCredentials(): void
|
||||
|
||||
Reference in New Issue
Block a user