1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
userprops.php
См. документацию.
1
<?php
8
namespace
Bitrix\Sale;
9
10
use Bitrix\Main\Entity;
11
use Bitrix\Main\Localization\Loc;
12
use Bitrix\Main\Error;
13
use Bitrix\Sale\Internals\UserPropsTable;
14
use Bitrix\Sale\Location\LocationTable;
15
16
Loc::loadMessages(__FILE__);
17
18
class
OrderUserProperties
19
{
20
private
$profiles =
array
();
21
private
static
$instance;
22
23
function
__construct
()
24
{
25
26
}
27
31
public
static
function
getInstance
()
32
{
33
34
if
(!isset(self::$instance))
35
{
36
self::$instance =
new
self
();
37
}
38
39
return
self::$instance;
40
}
41
46
public
static
function
getList
(
array
$parameters)
47
{
48
return
UserPropsTable::getList($parameters);
49
}
50
54
public
static
function
loadFromDB
($parameters)
55
{
56
static::getInstance()->profiles = static::getList($parameters)->fetchAll();
57
}
58
64
public
static
function
getFirstId
($personTypeId,
$userId
)
65
{
66
if
(empty(static::getInstance()->profiles))
67
{
68
static::loadFromDB(
array
(
69
'order'
=>
array
(
"DATE_UPDATE"
=>
"DESC"
),
70
'filter'
=>
array
(
71
"PERSON_TYPE_ID"
=> $personTypeId,
72
"USER_ID"
=>
$userId
73
),
74
));
75
}
76
77
if
(!empty(static::getInstance()->profiles) && is_array(static::getInstance()->profiles))
78
{
79
$profile = reset(static::getInstance()->profiles);
80
return
$profile[
'ID'
];
81
}
82
83
return
false
;
84
}
85
92
public
static
function
checkCorrect
($profileId, $personTypeId,
$userId
)
93
{
94
if
(static::getList(
array
(
95
'filter'
=>
array
(
96
"ID"
=> $profileId,
97
"PERSON_TYPE_ID"
=> $personTypeId,
98
"USER_ID"
=>
$userId
99
)))->fetch())
100
{
101
return
true
;
102
}
103
else
104
{
105
return
false
;
106
}
107
}
108
118
public
static
function
loadProfiles
(
$userId
, $personTypeId =
null
, $profileId =
null
)
119
{
120
$result
=
new
Result
();
121
$userId
= (int)
$userId
;
122
123
$resultData =
124
$filter
=
125
$locationIdMap =
126
$locationCodeList =
array
();
127
128
if
(
$userId
<= 0)
129
{
130
return
$result
->addError(
new
Error
(
"EMPTY USER ID"
));
131
}
132
else
133
{
134
$filter
[
'USER_ID'
] =
$userId
;
135
}
136
137
if
((
int
)$personTypeId > 0)
138
$filter
[
'PERSON_TYPE_ID'
] = (int)$personTypeId;
139
140
if
((
int
)$profileId > 0)
141
$filter
[
'USER_PROPS_ID'
] = (int)$profileId;
142
143
$userPropsValueData =
Internals\UserPropsValueTable::getList
(
144
array
(
145
'filter'
=>
$filter
,
146
'select'
=>
array
(
147
'ORDER_PROPS_ID'
,
'USER_PROPS_ID'
,
'VALUE'
,
148
'PROFILE_NAME'
=>
'USER_PROPERTY.NAME'
,
149
'VALUE_ORIG'
=>
'VALUE'
,
150
'USER_ID'
=>
'USER_PROPERTY.USER_ID'
,
151
'PERSON_TYPE_ID'
=>
'USER_PROPERTY.PERSON_TYPE_ID'
,
152
'DATE_UPDATE'
=>
'USER_PROPERTY.DATE_UPDATE'
,
153
'MULTIPLE'
=>
'PROPERTY.MULTIPLE'
,
154
'TYPE'
=>
'PROPERTY.TYPE'
,
155
),
156
'order'
=>
array
(
157
'USER_PROPERTY.DATE_UPDATE'
=>
'DESC'
,
158
'USER_PROPERTY.NAME'
=>
'ASC'
159
)
160
)
161
);
162
163
while
($propValue = $userPropsValueData->fetch())
164
{
165
if
(($propValue[
'MULTIPLE'
] ===
'Y'
|| $propValue[
'TYPE'
] ===
'FILE'
)
166
&&
CheckSerializedData
($propValue[
'VALUE'
])
167
&& ($serialisedValue = @unserialize($propValue[
'VALUE'
], [
'allowed_classes'
=>
false
])) !==
false
)
168
{
169
$propValue[
'VALUE'
] = $serialisedValue;
170
}
171
172
if
(!array_key_exists($propValue[
'PERSON_TYPE_ID'
], $resultData))
173
$resultData[$propValue[
'PERSON_TYPE_ID'
]] =
array
();
174
175
$resultData[$propValue[
'PERSON_TYPE_ID'
]][$propValue[
'USER_PROPS_ID'
]][
'NAME'
] = $propValue[
'PROFILE_NAME'
];
176
177
if
($propValue[
'TYPE'
] ===
'ENUM'
&& $propValue[
'MULTIPLE'
] ===
'Y'
)
178
{
179
$propValue[
'VALUE'
] = explode(
','
, $propValue[
'VALUE'
]);
180
}
181
elseif
($propValue[
'TYPE'
] ===
'FILE'
&& !empty($propValue[
'VALUE'
]))
182
{
183
$fileIds = $propValue[
'VALUE'
];
184
$propValue[
'VALUE'
] =
array
();
185
if
(is_array($fileIds))
186
{
187
foreach
($fileIds as $value)
188
{
189
if
($fileArray = \CFile::GetFileArray($value))
190
{
191
$propValue[
'VALUE'
][] = $fileArray;
192
}
193
}
194
}
195
elseif
($fileArray = \CFile::GetFileArray($fileIds))
196
{
197
$propValue[
'VALUE'
] = $fileArray;
198
}
199
}
200
201
$resultData[$propValue[
'PERSON_TYPE_ID'
]][$propValue[
'USER_PROPS_ID'
]][
'VALUES'
][$propValue[
'ORDER_PROPS_ID'
]] = $propValue[
'VALUE'
];
202
$resultData[$propValue[
'PERSON_TYPE_ID'
]][$propValue[
'USER_PROPS_ID'
]][
'VALUES_ORIG'
][$propValue[
'ORDER_PROPS_ID'
]] = $propValue[
'VALUE_ORIG'
];
203
}
204
205
$result
->setData($resultData);
206
207
return
$result
;
208
}
209
217
public
static
function
getProfileValues
($profileId)
218
{
219
$result
=
array
();
220
if
((
int
)$profileId <= 0)
221
{
222
return
$result
;
223
}
224
225
$userPropsValueData =
Internals\UserPropsTable::getList
(
226
array
(
227
'filter'
=>
array
(
'=ID'
=> (
int
)$profileId),
228
'select'
=>
array
(
'ID'
,
'USER_ID'
,
'PERSON_TYPE_ID'
),
229
'limit'
=> 1
230
)
231
);
232
$profile = $userPropsValueData->fetch();
233
if
(!$profile )
234
{
235
return
$result
;
236
}
237
$resultLoading = static::loadProfiles($profile[
'USER_ID'
], $profile[
'PERSON_TYPE_ID'
], $profile[
'ID'
]);
238
239
if
($resultLoading->isSuccess())
240
{
241
$data
= $resultLoading->getData();
242
$resultValue =
$data
[$profile[
'PERSON_TYPE_ID'
]][$profile[
'ID'
]][
'VALUES'
];
243
$result
= !empty($resultValue) ? $resultValue :
array
();
244
}
245
246
return
$result
;
247
}
248
}
$userId
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения
check_mail.php:18
Bitrix\Main\Error
Определения
error.php:15
Bitrix\Main\ORM\Data\DataManager\getList
static getList(array $parameters=array())
Определения
datamanager.php:431
Bitrix\Sale\OrderUserProperties
Определения
userprops.php:19
Bitrix\Sale\OrderUserProperties\__construct
__construct()
Определения
userprops.php:23
Bitrix\Sale\OrderUserProperties\getProfileValues
static getProfileValues($profileId)
Определения
userprops.php:217
Bitrix\Sale\OrderUserProperties\checkCorrect
static checkCorrect($profileId, $personTypeId, $userId)
Определения
userprops.php:92
Bitrix\Sale\OrderUserProperties\loadProfiles
static loadProfiles($userId, $personTypeId=null, $profileId=null)
Определения
userprops.php:118
Bitrix\Sale\OrderUserProperties\getList
static getList(array $parameters)
Определения
userprops.php:46
Bitrix\Sale\OrderUserProperties\getFirstId
static getFirstId($personTypeId, $userId)
Определения
userprops.php:64
Bitrix\Sale\OrderUserProperties\loadFromDB
static loadFromDB($parameters)
Определения
userprops.php:54
Bitrix\Sale\OrderUserProperties\getInstance
static getInstance()
Определения
userprops.php:31
$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
$result
$result
Определения
get_property_values.php:14
$filter
$filter
Определения
iblock_catalog_list.php:54
CheckSerializedData
CheckSerializedData($str, $max_depth=200)
Определения
tools.php:4949
Bitrix\Sale\Discount\Result
Определения
compatibleformat.php:2
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
bitrix
modules
sale
lib
userprops.php
Создано системой
1.14.0