Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
field.php
1
<?php
8
namespace
Bitrix\Main\UserConsent\Internals
;
9
10
use
Bitrix\Main\Entity
;
11
use
Bitrix\Main\Localization\Loc
;
12
13
Loc::loadMessages
(__FILE__);
14
31
class
FieldTable
extends
Entity\DataManager
32
{
38
public
static
function
getTableName
()
39
{
40
return
'b_consent_field'
;
41
}
42
48
public
static
function
getMap
()
49
{
50
return
array(
51
'ID'
=> array(
52
'data_type'
=>
'integer'
,
53
'primary'
=>
true
,
54
'autocomplete'
=>
true
,
55
),
56
'AGREEMENT_ID'
=> array(
57
'data_type'
=>
'integer'
,
58
'required'
=>
true
,
59
),
60
'CODE'
=> array(
61
'data_type'
=>
'string'
,
62
'required'
=>
true
,
63
),
64
'VALUE'
=> array(
65
'data_type'
=>
'text'
,
66
'required'
=>
true
,
67
)
68
);
69
}
70
77
public
static
function
getConsentFields
($agreementId)
78
{
79
$fields = array();
80
$fieldsDb = static::getList(array(
81
'filter'
=> array(
82
'=AGREEMENT_ID'
=> $agreementId
83
)
84
));
85
while
($field = $fieldsDb->fetch())
86
{
87
$fields[$field[
'CODE'
]] = $field[
'VALUE'
];
88
}
89
90
return
$fields;
91
}
92
100
public
static
function
setConsentFields
($agreementId, array $fields)
101
{
102
// remove old fields
103
$deleteFieldsDb = static::getList(array(
104
'select'
=> array(
'ID'
),
105
'filter'
=> array(
106
'=AGREEMENT_ID'
=> $agreementId
107
)
108
));
109
while
($deleteField = $deleteFieldsDb->fetch())
110
{
111
static::delete($deleteField[
'ID'
]);
112
}
113
114
// add new fields
115
foreach
($fields as $code => $value)
116
{
117
$result = static::add(array(
118
'AGREEMENT_ID'
=> $agreementId,
119
'CODE'
=> $code,
120
'VALUE'
=> $value,
121
));
122
$result->isSuccess();
123
}
124
}
125
}
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Main\UserConsent\Internals\FieldTable
Definition
field.php:32
Bitrix\Main\UserConsent\Internals\FieldTable\getMap
static getMap()
Definition
field.php:48
Bitrix\Main\UserConsent\Internals\FieldTable\getConsentFields
static getConsentFields($agreementId)
Definition
field.php:77
Bitrix\Main\UserConsent\Internals\FieldTable\setConsentFields
static setConsentFields($agreementId, array $fields)
Definition
field.php:100
Bitrix\Main\UserConsent\Internals\FieldTable\getTableName
static getTableName()
Definition
field.php:38
Bitrix\Main\UserConsent\Internals
Definition
agreement.php:8
modules
main
lib
userconsent
internals
field.php
Создано системой
1.10.0