mirror of
https://github.com/Karaka-Management/oms-Tasks.git
synced 2026-01-11 15:38:40 +00:00
org -> unit change, some new functionality
This commit is contained in:
parent
801d9a171e
commit
bfe13d806a
|
|
@ -204,7 +204,7 @@ final class BackendController extends Controller implements DashboardElementInte
|
|||
|| $task->isCCAccount($accountId)
|
||||
|| $task->isToAccount($accountId))
|
||||
&& !$this->app->accountManager->get($accountId)->hasPermission(
|
||||
PermissionType::READ, $this->app->orgId, $this->app->appName, self::NAME, PermissionCategory::TASK, $task->getId())
|
||||
PermissionType::READ, $this->app->unitId, $this->app->appName, self::NAME, PermissionCategory::TASK, $task->getId())
|
||||
) {
|
||||
$view->setTemplate('/Web/Backend/Error/403_inline');
|
||||
$response->header->status = RequestStatusCode::R_403;
|
||||
|
|
|
|||
|
|
@ -33,4 +33,8 @@ abstract class AttributeValueType extends Enum
|
|||
public const _FLOAT = 3;
|
||||
|
||||
public const _DATETIME = 4;
|
||||
|
||||
public const _BOOL = 5;
|
||||
|
||||
public const _FLOAT_INT = 6;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Tasks\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Tasks\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\Tasks\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullTaskAttributeTypeL11n extends TaskAttributeTypeL11n
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return ['id' => $this->id];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,135 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Tasks\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Tasks\Models;
|
||||
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Task class.
|
||||
*
|
||||
* @package Modules\Tasks\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class TaskAttributeTypeL11n implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Task ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $type;
|
||||
|
||||
/**
|
||||
* Language.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected string $language = ISO639x1Enum::_EN;
|
||||
|
||||
/**
|
||||
* Title.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $title = '';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param int $type Attribute type
|
||||
* @param string $title Localized title
|
||||
* @param string $language Language
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $type = 0, string $title = '', string $language = ISO639x1Enum::_EN)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->title = $title;
|
||||
$this->language = $language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get language
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getLanguage() : string
|
||||
{
|
||||
return $this->language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set language
|
||||
*
|
||||
* @param string $language Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setLanguage(string $language) : void
|
||||
{
|
||||
$this->language = $language;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'type' => $this->type,
|
||||
'language' => $this->language,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
|||
namespace Modules\Tasks\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
|
||||
/**
|
||||
* Task mapper class.
|
||||
|
|
@ -34,8 +35,8 @@ final class TaskAttributeTypeL11nMapper extends DataMapperFactory
|
|||
*/
|
||||
public const COLUMNS = [
|
||||
'task_attr_type_l11n_id' => ['name' => 'task_attr_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'task_attr_type_l11n_title' => ['name' => 'task_attr_type_l11n_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
|
||||
'task_attr_type_l11n_type' => ['name' => 'task_attr_type_l11n_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'task_attr_type_l11n_title' => ['name' => 'task_attr_type_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
|
||||
'task_attr_type_l11n_type' => ['name' => 'task_attr_type_l11n_type', 'type' => 'int', 'internal' => 'ref'],
|
||||
'task_attr_type_l11n_lang' => ['name' => 'task_attr_type_l11n_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
];
|
||||
|
||||
|
|
@ -54,4 +55,12 @@ final class TaskAttributeTypeL11nMapper extends DataMapperFactory
|
|||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD ='task_attr_type_l11n_id';
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = BaseStringL11n::class;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ final class TaskAttributeTypeMapper extends DataMapperFactory
|
|||
'mapper' => TaskAttributeTypeL11nMapper::class,
|
||||
'table' => 'task_attr_type_l11n',
|
||||
'self' => 'task_attr_type_l11n_type',
|
||||
'column' => 'title',
|
||||
'column' => 'content',
|
||||
'external' => null,
|
||||
],
|
||||
'defaults' => [
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Tasks\Models;
|
||||
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
|
|
@ -37,12 +38,20 @@ class TaskAttributeValue implements \JsonSerializable
|
|||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Datatype of the attribute
|
||||
* Depending attribute type
|
||||
*
|
||||
* @var int
|
||||
* @var null|int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $type = 0;
|
||||
public ?int $dependingAttributeType = null;
|
||||
|
||||
/**
|
||||
* Depending attribute value
|
||||
*
|
||||
* @var null|int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?int $dependingAttributeValue = null;
|
||||
|
||||
/**
|
||||
* Int value
|
||||
|
|
@ -95,24 +104,9 @@ class TaskAttributeValue implements \JsonSerializable
|
|||
/**
|
||||
* Localization
|
||||
*
|
||||
* @var null|TaskAttributeValueL11n
|
||||
* @var null|BaseStringL11n
|
||||
*/
|
||||
private ?TaskAttributeValueL11n $l11n = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param int $type Type
|
||||
* @param mixed $value Value
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $type = 0, mixed $value = '')
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
$this->setValue($value);
|
||||
}
|
||||
private ?BaseStringL11n $l11n = null;
|
||||
|
||||
/**
|
||||
* Get id
|
||||
|
|
@ -129,22 +123,23 @@ class TaskAttributeValue implements \JsonSerializable
|
|||
/**
|
||||
* Set l11n
|
||||
*
|
||||
* @param string|TaskAttributeValueL11n $l11n Tag article l11n
|
||||
* @param string|BaseStringL11n $l11n Tag article l11n
|
||||
* @param string $lang Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setL11n(string | TaskAttributeValueL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
|
||||
public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
|
||||
{
|
||||
if ($l11n instanceof TaskAttributeValueL11n) {
|
||||
if ($l11n instanceof BaseStringL11n) {
|
||||
$this->l11n = $l11n;
|
||||
} elseif (isset($this->l11n) && $this->l11n instanceof TaskAttributeValueL11n) {
|
||||
$this->l11n->title = $l11n;
|
||||
} elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) {
|
||||
$this->l11n->content = $l11n;
|
||||
} else {
|
||||
$this->l11n = new TaskAttributeValueL11n();
|
||||
$this->l11n->title = $l11n;
|
||||
$this->l11n = new BaseStringL11n();
|
||||
$this->l11n->content = $l11n;
|
||||
$this->l11n->ref = $this->id;
|
||||
$this->l11n->setLanguage($lang);
|
||||
}
|
||||
}
|
||||
|
|
@ -158,7 +153,7 @@ class TaskAttributeValue implements \JsonSerializable
|
|||
*/
|
||||
public function getL11n() : ?string
|
||||
{
|
||||
return $this->l11n instanceof TaskAttributeValueL11n ? $this->l11n->title : $this->l11n;
|
||||
return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -170,16 +165,19 @@ class TaskAttributeValue implements \JsonSerializable
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setValue(mixed $value) : void
|
||||
public function setValue(mixed $value, int $datatype) : void
|
||||
{
|
||||
if (\is_string($value)) {
|
||||
$this->valueStr = $value;
|
||||
} elseif (\is_int($value)) {
|
||||
$this->valueInt = $value;
|
||||
} elseif (\is_float($value)) {
|
||||
$this->valueDec = $value;
|
||||
} elseif ($value instanceof \DateTimeInterface) {
|
||||
$this->valueDat = $value;
|
||||
if ($datatype === AttributeValueType::_STRING) {
|
||||
$this->valueStr = (string) $value;
|
||||
} elseif ($datatype === AttributeValueType::_INT
|
||||
|| $datatype === AttributeValueType::_FLOAT_INT
|
||||
|| $datatype === AttributeValueType::_BOOL
|
||||
) {
|
||||
$this->valueInt = (int) $value;
|
||||
} elseif ($datatype === AttributeValueType::_FLOAT) {
|
||||
$this->valueDec = (float) $value;
|
||||
} elseif ($datatype === AttributeValueType::_DATETIME) {
|
||||
$this->valueDat = new \DateTime($value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -212,7 +210,6 @@ class TaskAttributeValue implements \JsonSerializable
|
|||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'type' => $this->type,
|
||||
'valueInt' => $this->valueInt,
|
||||
'valueStr' => $this->valueStr,
|
||||
'valueDec' => $this->valueDec,
|
||||
|
|
|
|||
|
|
@ -1,135 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Tasks\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Tasks\Models;
|
||||
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Item class.
|
||||
*
|
||||
* @package Modules\Tasks\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class TaskAttributeValueL11n implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Item ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $value;
|
||||
|
||||
/**
|
||||
* Language.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected string $language = ISO639x1Enum::_EN;
|
||||
|
||||
/**
|
||||
* Title.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $title = '';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param int $value Attribute value
|
||||
* @param string $title Localized title
|
||||
* @param string $language Language
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $value = 0, string $title = '', string $language = ISO639x1Enum::_EN)
|
||||
{
|
||||
$this->value = $value;
|
||||
$this->title = $title;
|
||||
$this->language = $language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get language
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getLanguage() : string
|
||||
{
|
||||
return $this->language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set language
|
||||
*
|
||||
* @param string $language Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setLanguage(string $language) : void
|
||||
{
|
||||
$this->language = $language;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'value' => $this->value,
|
||||
'language' => $this->language,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -34,8 +34,8 @@ final class TaskAttributeValueL11nMapper extends DataMapperFactory
|
|||
*/
|
||||
public const COLUMNS = [
|
||||
'task_attr_value_l11n_id' => ['name' => 'task_attr_value_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'task_attr_value_l11n_title' => ['name' => 'task_attr_value_l11n_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
|
||||
'task_attr_value_l11n_value' => ['name' => 'task_attr_value_l11n_value', 'type' => 'int', 'internal' => 'value'],
|
||||
'task_attr_value_l11n_title' => ['name' => 'task_attr_value_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
|
||||
'task_attr_value_l11n_value' => ['name' => 'task_attr_value_l11n_value', 'type' => 'int', 'internal' => 'ref'],
|
||||
'task_attr_value_l11n_lang' => ['name' => 'task_attr_value_l11n_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
];
|
||||
|
||||
|
|
@ -54,4 +54,12 @@ final class TaskAttributeValueL11nMapper extends DataMapperFactory
|
|||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD ='task_attr_value_l11n_id';
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = BaseStringL11n::class;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ final class TaskAttributeValueMapper extends DataMapperFactory
|
|||
public const COLUMNS = [
|
||||
'task_attr_value_id' => ['name' => 'task_attr_value_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'task_attr_value_default' => ['name' => 'task_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'],
|
||||
'task_attr_value_valuetype' => ['name' => 'task_attr_value_valuetype', 'type' => 'int', 'internal' => 'type'],
|
||||
'task_attr_value_valueStr' => ['name' => 'task_attr_value_valueStr', 'type' => 'string', 'internal' => 'valueStr'],
|
||||
'task_attr_value_valueInt' => ['name' => 'task_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'],
|
||||
'task_attr_value_valueDec' => ['name' => 'task_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'],
|
||||
|
|
@ -54,6 +53,7 @@ final class TaskAttributeValueMapper extends DataMapperFactory
|
|||
'mapper' => TaskAttributeValueL11nMapper::class,
|
||||
'table' => 'task_attr_value_l11n',
|
||||
'self' => 'task_attr_value_l11n_value',
|
||||
'column' => 'content',
|
||||
'external' => null,
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ final class ControllerTest extends \PHPUnit\Framework\TestCase
|
|||
};
|
||||
|
||||
$this->app->dbPool = $GLOBALS['dbpool'];
|
||||
$this->app->orgId = 1;
|
||||
$this->app->unitId = 1;
|
||||
$this->app->accountManager = new AccountManager($GLOBALS['session']);
|
||||
$this->app->appSettings = new CoreSettings();
|
||||
$this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../Modules/');
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ final class BackendControllerTest extends \PHPUnit\Framework\TestCase
|
|||
};
|
||||
|
||||
$this->app->dbPool = $GLOBALS['dbpool'];
|
||||
$this->app->orgId = 1;
|
||||
$this->app->unitId = 1;
|
||||
$this->app->accountManager = new AccountManager($GLOBALS['session']);
|
||||
$this->app->appSettings = new CoreSettings();
|
||||
$this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../Modules/');
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user