hide expired projects in team-projects widget (#2432)
This commit is contained in:
@@ -529,6 +529,21 @@ class Project implements EntityWithMetaFields
|
||||
return $this->teams;
|
||||
}
|
||||
|
||||
public function isVisibleAtDate(\DateTime $dateTime): bool
|
||||
{
|
||||
if (!$this->isVisible()) {
|
||||
return false;
|
||||
}
|
||||
if ($this->getCustomer() !== null && !$this->getCustomer()->isVisible()) {
|
||||
return false;
|
||||
}
|
||||
if ($this->getEnd() !== null && $dateTime > $this->getEnd()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
||||
@@ -46,12 +46,13 @@ class UserTeamProjects extends SimpleWidget implements AuthorizedWidget, UserWid
|
||||
/** @var User $user */
|
||||
$user = $options['user'];
|
||||
$projects = [];
|
||||
$now = new \DateTime('now', new \DateTimeZone($user->getTimezone()));
|
||||
|
||||
/** @var Team $team */
|
||||
foreach ($user->getTeams() as $team) {
|
||||
/** @var Project $project */
|
||||
foreach ($team->getProjects() as $project) {
|
||||
if (!$project->isVisible() || !$project->getCustomer()->isVisible()) {
|
||||
if (!$project->isVisibleAtDate($now)) {
|
||||
continue;
|
||||
}
|
||||
$projects[$project->getId()] = $project;
|
||||
|
||||
Reference in New Issue
Block a user