1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
workflowtemplateuseroptiontable.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Bizproc\Workflow\Template;
4
5
use Bitrix\Main\Error;
6
use Bitrix\Main\ORM;
7
use Bitrix\Main\ORM\Data\DataManager;
8
use Bitrix\Main\Result;
9
26
class
WorkflowTemplateUserOptionTable
extends
DataManager
27
{
28
public
const
PINNED
= 1;
29
30
public
static
function
getTableName
(): string
31
{
32
return
'b_bp_workflow_template_user_option'
;
33
}
34
35
public
static
function
getMap
():
array
36
{
37
return
[
38
(
new
ORM\Fields\IntegerField
(
'ID'
))
39
->configurePrimary()
40
->configureAutocomplete()
41
,
42
(
new
ORM\Fields\IntegerField
(
'TEMPLATE_ID'
))
43
->configureRequired()
44
,
45
(
new
ORM\Fields\IntegerField
(
'USER_ID'
))
46
->configureRequired()
47
,
48
(
new
ORM\Fields\IntegerField
(
'OPTION_CODE'
))
49
->configureRequired()
50
,
51
new
ORM\Fields\Relations\Reference
(
52
'TEMPLATE'
,
53
Entity
\WorkflowTemplateTable::class,
54
ORM
\
Query
\Join::on(
'this.TEMPLATE_ID'
,
'ref.ID'
)
55
),
56
];
57
}
58
59
public
static
function
isOption
(
int
$option
): bool
60
{
61
return
in_array(
$option
, [self::PINNED],
true
);
62
}
63
64
public
static
function
addOption
(
int
$templateId
,
int
$userId
,
int
$option
):
Result
65
{
66
$addResult =
new
Result
();
67
68
if
(
$templateId
<= 0 ||
$userId
<= 0 || !static::isOption(
$option
))
69
{
70
$addResult->addError(
new
Error
(
'Some parameter is wrong.'
, 1));
71
return
$addResult;
72
}
73
74
$data
= [
75
'TEMPLATE_ID'
=>
$templateId
,
76
'USER_ID'
=>
$userId
,
77
'OPTION_CODE'
=>
$option
,
78
];
79
80
$item =
self::getList
([
81
'select'
=> [
'ID'
],
82
'filter'
=>
$data
,
83
])->fetch();
84
85
if
(!$item)
86
{
87
$tableAddResult =
self::add
(
$data
);
88
if
(!$tableAddResult->isSuccess())
89
{
90
$addResult->addError(
new
Error
(
'Adding to table failed.'
, 2));
91
return
$addResult;
92
}
93
94
return
$addResult;
95
}
96
97
return
$addResult;
98
}
99
100
public
static
function
deleteOption
(
int
$templateId
,
int
$userId
,
int
$option
):
Result
101
{
102
$deleteResult =
new
Result
();
103
104
if
(
$templateId
<= 0 ||
$userId
<= 0 || !static::isOption(
$option
))
105
{
106
$deleteResult->addError(
new
Error
(
'Some parameter is wrong.'
, 1));
107
return
$deleteResult;
108
}
109
110
$item =
self::getList
([
111
'select'
=> [
'ID'
],
112
'filter'
=> [
113
'TEMPLATE_ID'
=>
$templateId
,
114
'USER_ID'
=>
$userId
,
115
'OPTION_CODE'
=>
$option
,
116
],
117
])->fetch();
118
119
if
($item)
120
{
121
$tableDeleteResult =
self::delete
($item);
122
if
(!$tableDeleteResult->isSuccess())
123
{
124
$deleteResult->addError(
new
Error
(
'Deleting from table failed.'
, 2));
125
126
return
$deleteResult;
127
}
128
}
129
130
return
$deleteResult;
131
}
132
}
$userId
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения
check_mail.php:18
Bitrix\Bizproc\Workflow\Template\WorkflowTemplateUserOptionTable
Определения
workflowtemplateuseroptiontable.php:27
Bitrix\Bizproc\Workflow\Template\WorkflowTemplateUserOptionTable\getMap
static getMap()
Определения
workflowtemplateuseroptiontable.php:35
Bitrix\Bizproc\Workflow\Template\WorkflowTemplateUserOptionTable\deleteOption
static deleteOption(int $templateId, int $userId, int $option)
Определения
workflowtemplateuseroptiontable.php:100
Bitrix\Bizproc\Workflow\Template\WorkflowTemplateUserOptionTable\PINNED
const PINNED
Определения
workflowtemplateuseroptiontable.php:28
Bitrix\Bizproc\Workflow\Template\WorkflowTemplateUserOptionTable\addOption
static addOption(int $templateId, int $userId, int $option)
Определения
workflowtemplateuseroptiontable.php:64
Bitrix\Bizproc\Workflow\Template\WorkflowTemplateUserOptionTable\isOption
static isOption(int $option)
Определения
workflowtemplateuseroptiontable.php:59
Bitrix\Bizproc\Workflow\Template\WorkflowTemplateUserOptionTable\getTableName
static getTableName()
Определения
workflowtemplateuseroptiontable.php:30
Bitrix\Main\Error
Определения
error.php:15
Bitrix\Main\ORM\Data\DataManager
Определения
datamanager.php:35
Bitrix\Main\ORM\Data\DataManager\getList
static getList(array $parameters=array())
Определения
datamanager.php:431
Bitrix\Main\ORM\Data\DataManager\delete
static delete($primary)
Определения
datamanager.php:1644
Bitrix\Main\ORM\Data\DataManager\add
static add(array $data)
Определения
datamanager.php:877
Bitrix\Main\ORM\Data\Result
Определения
result.php:16
Bitrix\Main\ORM\Fields\IntegerField
Определения
integerfield.php:20
Bitrix\Main\ORM\Fields\Relations\Reference
Определения
reference.php:26
$templateId
$templateId
Определения
component_props2.php:51
$data
$data['IS_AVAILABLE']
Определения
.description.php:13
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
Bitrix\Main\Entity
Определения
ufield.php:9
Bitrix\Main\ORM\Query
Определения
chain.php:3
Bitrix\Main\ORM
$option
$option
Определения
options.php:1711
bitrix
modules
bizproc
lib
workflow
template
workflowtemplateuseroptiontable.php
Создано системой
1.14.0