HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //home/timetracker.panomity.com/tm.old/Repository/Query/TaskQuery.php
<?php

/*
 * This file is part of the TaskManagementBundle for Kimai 2.
 * All rights reserved by Kevin Papst (www.kevinpapst.de).
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace KimaiPlugin\TaskManagementBundle\Repository\Query;

use App\Entity\Activity;
use App\Entity\Customer;
use App\Entity\Project;
use App\Entity\Tag;
use App\Entity\User;
use App\Form\Model\DateRange;
use App\Repository\Query\BaseQuery;

final class TaskQuery extends BaseQuery
{
    public const TASKS_ORDER_ALLOWED = [
        'title', 'customer', 'project', 'activity', 'description', 'status', 'user', 'begin', 'end', 'team'
    ];

    /**
     * @var Customer[]
     */
    private $customers = [];
    /**
     * @var Project[]
     */
    private $projects = [];
    /**
     * @var Activity[]
     */
    private $activities = [];
    /**
     * @var User[]
     */
    private $users = [];
    /**
     * @var User
     */
    private $user = null;
    /**
     * @var DateRange
     */
    private $dateRange;
    /**
     * @var string[]
     */
    private $status = [];
    // show unassigned tasks only
    private $unassigned = false;
    // include alls tasks for teams of the current user
    private $withTeamTasks = false;
    // include all unassigned
    private $withUnassigned = false;
    /**
     * @var iterable
     */
    private $tags = [];

    public function __construct()
    {
        $this->setDefaults([
            'order' => self::ORDER_ASC,
            'orderBy' => 'end',
            'dateRange' => new DateRange(),
            'status' => [],
        ]);
    }

    public function addUser(User $user): TaskQuery
    {
        $this->users[$user->getId()] = $user;

        return $this;
    }

    public function removeUser(User $user): TaskQuery
    {
        if (isset($this->users[$user->getId()])) {
            unset($this->users[$user->getId()]);
        }

        return $this;
    }

    /**
     * @return User[]
     */
    public function getUsers(): array
    {
        return array_values($this->users);
    }

    public function getUser(): ?User
    {
        return $this->user;
    }

    public function setUser(User $user): TaskQuery
    {
        $this->user = $user;

        return $this;
    }

    public function hasActivities(): bool
    {
        return !empty($this->activities);
    }

    public function getActivities(): array
    {
        return $this->activities;
    }

    public function setActivities(array $activities): TaskQuery
    {
        $this->activities = $activities;

        return $this;
    }

    public function hasCustomers(): bool
    {
        return !empty($this->customers);
    }

    public function getCustomers(): array
    {
        return $this->customers;
    }

    public function setCustomers(array $customers): TaskQuery
    {
        $this->customers = $customers;

        return $this;
    }

    public function hasProjects(): bool
    {
        return !empty($this->projects);
    }

    public function getProjects(): array
    {
        return $this->projects;
    }

    public function setProjects(array $projects): TaskQuery
    {
        $this->projects = $projects;

        return $this;
    }

    public function getBegin(): ?\DateTime
    {
        return $this->dateRange->getBegin();
    }

    public function setBegin(\DateTime $begin): TaskQuery
    {
        $this->dateRange->setBegin($begin);

        return $this;
    }

    public function getEnd(): ?\DateTime
    {
        return $this->dateRange->getEnd();
    }

    public function setEnd(\DateTime $end): TaskQuery
    {
        $this->dateRange->setEnd($end);

        return $this;
    }

    public function getDateRange(): DateRange
    {
        return $this->dateRange;
    }

    public function setDateRange(DateRange $dateRange): TaskQuery
    {
        $this->dateRange = $dateRange;

        return $this;
    }

    public function getStatus(): array
    {
        return $this->status;
    }

    public function addStatus(string $status): TaskQuery
    {
        $this->status[] = $status;

        return $this;
    }

    public function setStatus(array $status): TaskQuery
    {
        $this->status = $status;

        return $this;
    }

    public function isUnassigned(): bool
    {
        return $this->unassigned;
    }

    public function setUnassigned(bool $unassigned): TaskQuery
    {
        $this->unassigned = $unassigned;

        return $this;
    }

    public function isWithTeamTasks(): bool
    {
        return $this->withTeamTasks;
    }

    public function setWithTeamTasks(bool $withTeamTasks): void
    {
        $this->withTeamTasks = $withTeamTasks;
    }

    public function isWithUnassigned(): bool
    {
        return $this->withUnassigned;
    }

    public function setWithUnassigned(bool $withUnassigned): void
    {
        $this->withUnassigned = $withUnassigned;
    }

    public function getTags(bool $allowUnknown = false): iterable
    {
        if (empty($this->tags)) {
            return [];
        }

        $result = [];

        foreach ($this->tags as $tag) {
            if (!$allowUnknown && $tag instanceof Tag && null === $tag->getId()) {
                continue;
            }
            $result[] = $tag;
        }

        return $result;
    }

    public function setTags(iterable $tags): TaskQuery
    {
        $this->tags = $tags;

        return $this;
    }
}