mirror of
https://github.com/Karaka-Management/oms-Tasks.git
synced 2026-01-28 06:48:40 +00:00
Bug fixes
This commit is contained in:
parent
fc8fbefe7b
commit
33618c0fcc
|
|
@ -22,6 +22,7 @@ use Modules\Tasks\Models\TaskElementMapper;
|
|||
use Modules\Tasks\Models\TaskMapper;
|
||||
use Modules\Tasks\Models\TaskStatus;
|
||||
use Modules\Tasks\Models\TaskType;
|
||||
use Modules\Tasks\Models\TaskPriority;
|
||||
use Modules\Tasks\Models\PermissionState;
|
||||
|
||||
use phpOMS\Message\Http\RequestStatusCode;
|
||||
|
|
@ -319,6 +320,7 @@ class Controller extends ModuleAbstract implements WebInterface
|
|||
$task->setDue(new \DateTime((string) ($request->getData('due') ?? 'now')));
|
||||
$task->setStatus(TaskStatus::OPEN);
|
||||
$task->setType(TaskType::SINGLE);
|
||||
$task->setPriority(TaskPriority::NONE);
|
||||
|
||||
$element = new TaskElement();
|
||||
$element->setForwarded((int) ($request->getData('forward') ?? $request->getHeader()->getAccount()));
|
||||
|
|
@ -409,8 +411,9 @@ class Controller extends ModuleAbstract implements WebInterface
|
|||
$task->setDescription(Markdown::parse((string) ($request->getData('description') ?? $task->getDescriptionRaw())));
|
||||
$task->setDescriptionRaw((string) ($request->getData('description') ?? $task->getDescriptionRaw()));
|
||||
$task->setDue(new \DateTime((string) ($request->getData('due') ?? $task->getDue()->format('Y-m-d H:i:s'))));
|
||||
$task->setStatus((int) $request->getData('status') ?? $task->getSatus());
|
||||
$task->setType((int) $request->getData('type') ?? $task->getType());
|
||||
$task->setStatus((int) ($request->getData('status') ?? $task->getStatus()));
|
||||
$task->setType((int) ($request->getData('type') ?? $task->getType()));
|
||||
$task->setPriority((int) ($request->getData('priority') ?? $task->getPriority()));
|
||||
|
||||
return $task;
|
||||
}
|
||||
|
|
|
|||
169
Models/Task.php
169
Models/Task.php
|
|
@ -68,6 +68,12 @@ class Task implements \JsonSerializable
|
|||
*/
|
||||
protected $description = '';
|
||||
|
||||
/**
|
||||
* Description raw.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $descriptionRaw = '';
|
||||
|
||||
/**
|
||||
|
|
@ -134,8 +140,20 @@ class Task implements \JsonSerializable
|
|||
*/
|
||||
protected $schedule = null;
|
||||
|
||||
/**
|
||||
* Priority
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $priority = TaskPriority::MEDIUM;
|
||||
|
||||
/**
|
||||
* Media files
|
||||
*
|
||||
* @var array
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $media = [];
|
||||
|
||||
protected $acc = [];
|
||||
|
|
@ -154,11 +172,29 @@ class Task implements \JsonSerializable
|
|||
$this->schedule = new Schedule();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set closable
|
||||
*
|
||||
* Setting it to false will only allow other modules to close this task
|
||||
*
|
||||
* @param bool $closable Is closable
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setClosable(bool $closable) /* : void */
|
||||
{
|
||||
$this->isClosable = $closable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is closable
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function isClosable() : bool
|
||||
{
|
||||
return $this->isClosable;
|
||||
|
|
@ -184,21 +220,55 @@ class Task implements \JsonSerializable
|
|||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all media
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getMedia() : array
|
||||
{
|
||||
return $this->media;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add media
|
||||
*
|
||||
* @param mixed $media Media to add
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function addMedia($media) /* : void */
|
||||
{
|
||||
$this->media[] = $media;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user is cc
|
||||
*
|
||||
* @param int $id User id
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function isCc(int $id) : bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if user is forwarded
|
||||
*
|
||||
* @param int $id User id
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function isForwarded(int $id) : bool
|
||||
{
|
||||
foreach ($this->taskElements as $element) {
|
||||
|
|
@ -231,16 +301,22 @@ class Task implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $created
|
||||
* Set start time of task
|
||||
*
|
||||
* @param \DateTime $start Start date of task
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setStart(\DateTime $start)
|
||||
public function setStart(\DateTime $start) /* : void */
|
||||
{
|
||||
$this->start = $start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get created by
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @since 1.0.0
|
||||
|
|
@ -251,17 +327,23 @@ class Task implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed $id
|
||||
* Set created by
|
||||
*
|
||||
* @param mixed $id Created by
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setCreatedBy($id)
|
||||
public function setCreatedBy($id) /* : void */
|
||||
{
|
||||
$this->createdBy = $id;
|
||||
$this->schedule->setCreatedBy($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get description
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
|
|
@ -272,16 +354,22 @@ class Task implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
* Set description
|
||||
*
|
||||
* @param string $description Description
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setDescription(string $description)
|
||||
public function setDescription(string $description) /* : void */
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get description
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
|
|
@ -292,7 +380,11 @@ class Task implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
* Set description
|
||||
*
|
||||
* @param string $description Description
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
@ -302,6 +394,8 @@ class Task implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* Get done date
|
||||
*
|
||||
* @return \DateTime
|
||||
*
|
||||
* @since 1.0.0
|
||||
|
|
@ -312,16 +406,22 @@ class Task implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $done
|
||||
* Set done date
|
||||
*
|
||||
* @param \DateTime $done Done date
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setDone(\DateTime $done)
|
||||
public function setDone(\DateTime $done) /* : void */
|
||||
{
|
||||
$this->done = $done;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get due date
|
||||
*
|
||||
* @return \DateTime
|
||||
*
|
||||
* @since 1.0.0
|
||||
|
|
@ -332,16 +432,22 @@ class Task implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $due
|
||||
* Set due date
|
||||
*
|
||||
* @param \DateTime $due Due date
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setDue(\DateTime $due)
|
||||
public function setDue(\DateTime $due) /* : void */
|
||||
{
|
||||
$this->due = $due;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
|
|
@ -352,6 +458,8 @@ class Task implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* Get status
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
|
|
@ -362,13 +470,17 @@ class Task implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $status
|
||||
* Set status
|
||||
*
|
||||
* @param int $status Task status
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidEnumValue
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setStatus(int $status)
|
||||
public function setStatus(int $status) /* : void */
|
||||
{
|
||||
if (!TaskStatus::isValidValue($status)) {
|
||||
throw new InvalidEnumValue((string) $status);
|
||||
|
|
@ -378,6 +490,8 @@ class Task implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* Get priority
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
|
|
@ -388,15 +502,19 @@ class Task implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $priority
|
||||
* Set priority
|
||||
*
|
||||
* @param int $priority Task priority
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws InvalidEnumValue
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setPriority(int $priority)
|
||||
public function setPriority(int $priority) /* : void */
|
||||
{
|
||||
if (!TaskStatus::isValidValue($priority)) {
|
||||
if (!TaskPriority::isValidValue($priority)) {
|
||||
throw new InvalidEnumValue((string) $priority);
|
||||
}
|
||||
|
||||
|
|
@ -404,6 +522,8 @@ class Task implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* Get title
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
|
|
@ -414,11 +534,15 @@ class Task implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $title
|
||||
* Set title
|
||||
*
|
||||
* @param string $title Title
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setTitle(string $title)
|
||||
public function setTitle(string $title) /* : void */
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
|
@ -507,6 +631,9 @@ class Task implements \JsonSerializable
|
|||
return $this->schedule;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
|
|
@ -524,11 +651,7 @@ class Task implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* Specify data which should be serialized to JSON
|
||||
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
|
||||
* @return mixed data which can be serialized by <b>json_encode</b>,
|
||||
* which is a value of any type other than a resource.
|
||||
* @since 5.4.0
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -134,7 +134,9 @@ class TaskElement implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed $creator
|
||||
* Set created by
|
||||
*
|
||||
* @param mixed $creator Creator
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
|
|
@ -149,17 +151,34 @@ class TaskElement implements \JsonSerializable
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all media
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getMedia() : array
|
||||
{
|
||||
return $this->media;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add media
|
||||
*
|
||||
* @param mixed $media Media to add
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function addMedia($media) /* : void */
|
||||
{
|
||||
$this->media[] = $media;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get description
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
|
|
@ -170,18 +189,22 @@ class TaskElement implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
* Set description
|
||||
*
|
||||
* @param string $description Description
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setDescription(string $description)
|
||||
public function setDescription(string $description) /* : void */
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get description
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
|
|
@ -192,18 +215,22 @@ class TaskElement implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
* Set description
|
||||
*
|
||||
* @param string $description Description
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setDescriptionRaw(string $description)
|
||||
public function setDescriptionRaw(string $description) /* : void */
|
||||
{
|
||||
$this->descriptionRaw = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get due date
|
||||
*
|
||||
* @return \DateTime
|
||||
*
|
||||
* @since 1.0.0
|
||||
|
|
@ -214,18 +241,22 @@ class TaskElement implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $due
|
||||
*
|
||||
* Set due date
|
||||
*
|
||||
* @param \DateTime $due Due date
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setDue(\DateTime $due)
|
||||
public function setDue(\DateTime $due) /* : void */
|
||||
{
|
||||
$this->due = $due;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get forwarded
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @since 1.0.0
|
||||
|
|
@ -236,18 +267,22 @@ class TaskElement implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed $forwarded
|
||||
* Set forwarded
|
||||
*
|
||||
* @param mixed $forwarded Forward to
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setForwarded($forwarded)
|
||||
public function setForwarded($forwarded) /* : void */
|
||||
{
|
||||
$this->forwarded = $forwarded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
|
|
@ -258,6 +293,8 @@ class TaskElement implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* Get status
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
|
|
@ -268,7 +305,9 @@ class TaskElement implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $status
|
||||
* Set Status
|
||||
*
|
||||
* @param int $status Task element status
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
|
|
@ -276,7 +315,7 @@ class TaskElement implements \JsonSerializable
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setStatus(int $status)
|
||||
public function setStatus(int $status) /* : void */
|
||||
{
|
||||
if (!TaskStatus::isValidValue($status)) {
|
||||
throw new InvalidEnumValue((string) $status);
|
||||
|
|
@ -286,6 +325,8 @@ class TaskElement implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* Get task id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
|
|
@ -296,7 +337,9 @@ class TaskElement implements \JsonSerializable
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $task
|
||||
* Set task i
|
||||
*
|
||||
* @param int $task Task id
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
|
|
@ -307,6 +350,9 @@ class TaskElement implements \JsonSerializable
|
|||
$this->task = $task;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
|
|
@ -321,6 +367,9 @@ class TaskElement implements \JsonSerializable
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->toArray();
|
||||
|
|
|
|||
|
|
@ -129,6 +129,15 @@ class TaskMapper extends DataMapperAbstract
|
|||
protected static $primaryField = 'task_id';
|
||||
|
||||
|
||||
/**
|
||||
* Count unread task
|
||||
*
|
||||
* @param int $user User
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function countUnread(int $user) : int
|
||||
{
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user