1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
usertypesql.php
См. документацию.
1
<?php
2
3
class
CUserTypeSQL
4
{
5
var
$table_alias
=
"BUF"
;
6
var
$entity_id
=
false
;
7
var
$user_fields
=
array
();
8
9
var
$select
=
array
();
10
var
$filter
=
array
();
11
var
$order
=
array
();
12
14
var
$obWhere
=
false
;
15
16
function
SetEntity
(
$entity_id
,
$ID
)
17
{
18
global
$USER_FIELD_MANAGER
;
19
20
$this->user_fields =
$USER_FIELD_MANAGER
->GetUserFields(
$entity_id
);
21
$this->entity_id = mb_strtolower(preg_replace(
"/[^0-9A-Z_]+/"
,
""
,
$entity_id
));
22
$this->
select
=
array
();
23
$this->filter =
array
();
24
$this->order =
array
();
25
26
$this->obWhere =
new
CSQLWhere
;
27
$num = 0;
28
$arFields
=
array
();
29
foreach
($this->user_fields as $FIELD_NAME => $arField)
30
{
31
if
($arField[
"MULTIPLE"
] ==
"Y"
)
32
$num++;
33
$table_alias
= $arField[
"MULTIPLE"
] ==
"N"
? $this->table_alias : $this->table_alias . $num;
34
$arType = $this->user_fields[$FIELD_NAME][
"USER_TYPE"
];
35
36
if
($arField[
"MULTIPLE"
] ==
"N"
)
37
$TABLE_FIELD_NAME =
$table_alias
.
"."
. $FIELD_NAME;
38
elseif
($arType[
"BASE_TYPE"
] ==
"int"
)
39
$TABLE_FIELD_NAME =
$table_alias
.
".VALUE_INT"
;
40
elseif
($arType[
"BASE_TYPE"
] ==
"file"
)
41
$TABLE_FIELD_NAME =
$table_alias
.
".VALUE_INT"
;
42
elseif
($arType[
"BASE_TYPE"
] ==
"enum"
)
43
$TABLE_FIELD_NAME =
$table_alias
.
".VALUE_INT"
;
44
elseif
($arType[
"BASE_TYPE"
] ==
"double"
)
45
$TABLE_FIELD_NAME =
$table_alias
.
".VALUE_DOUBLE"
;
46
elseif
($arType[
"BASE_TYPE"
] ==
"datetime"
)
47
$TABLE_FIELD_NAME =
$table_alias
.
".VALUE_DATE"
;
48
else
49
$TABLE_FIELD_NAME =
$table_alias
.
".VALUE"
;
50
51
$arFields
[$FIELD_NAME] =
array
(
52
"TABLE_ALIAS"
=>
$table_alias
,
53
"FIELD_NAME"
=> $TABLE_FIELD_NAME,
54
"FIELD_TYPE"
=> $arType[
"BASE_TYPE"
],
55
"USER_TYPE_ID"
=> $arType[
"USER_TYPE_ID"
],
56
"MULTIPLE"
=> $arField[
"MULTIPLE"
],
57
"JOIN"
=> $arField[
"MULTIPLE"
] ==
"N"
?
58
"INNER JOIN b_uts_"
. $this->entity_id .
" "
.
$table_alias
.
" ON "
.
$table_alias
.
".VALUE_ID = "
.
$ID
:
59
"INNER JOIN b_utm_"
. $this->entity_id .
" "
.
$table_alias
.
" ON "
.
$table_alias
.
".FIELD_ID = "
. $arField[
"ID"
] .
" AND "
.
$table_alias
.
".VALUE_ID = "
.
$ID
,
60
"LEFT_JOIN"
=> $arField[
"MULTIPLE"
] ==
"N"
?
61
"LEFT JOIN b_uts_"
. $this->entity_id .
" "
.
$table_alias
.
" ON "
.
$table_alias
.
".VALUE_ID = "
.
$ID
:
62
"LEFT JOIN b_utm_"
. $this->entity_id .
" "
.
$table_alias
.
" ON "
.
$table_alias
.
".FIELD_ID = "
. $arField[
"ID"
] .
" AND "
.
$table_alias
.
".VALUE_ID = "
.
$ID
,
63
);
64
65
if
($arType[
"BASE_TYPE"
] ==
"enum"
)
66
{
67
$arFields
[$FIELD_NAME .
"_VALUE"
] =
array
(
68
"TABLE_ALIAS"
=>
$table_alias
.
"EN"
,
69
"FIELD_NAME"
=>
$table_alias
.
"EN.VALUE"
,
70
"FIELD_TYPE"
=>
"string"
,
71
"MULTIPLE"
=> $arField[
"MULTIPLE"
],
72
"JOIN"
=> $arField[
"MULTIPLE"
] ==
"N"
?
73
"INNER JOIN b_uts_"
. $this->entity_id .
" "
.
$table_alias
.
"E ON "
.
$table_alias
.
"E.VALUE_ID = "
.
$ID
.
"
74
INNER JOIN b_user_field_enum "
.
$table_alias
.
"EN ON "
.
$table_alias
.
"EN.ID = "
.
$table_alias
.
"E."
. $FIELD_NAME :
75
"INNER JOIN b_utm_"
. $this->entity_id .
" "
.
$table_alias
.
"E ON "
.
$table_alias
.
"E.FIELD_ID = "
. $arField[
"ID"
] .
" AND "
.
$table_alias
.
"E.VALUE_ID = "
.
$ID
.
"
76
INNER JOIN b_user_field_enum "
.
$table_alias
.
"EN ON "
.
$table_alias
.
"EN.ID = "
.
$table_alias
.
"E.VALUE_INT"
,
77
"LEFT_JOIN"
=> $arField[
"MULTIPLE"
] ==
"N"
?
78
"LEFT JOIN b_uts_"
. $this->entity_id .
" "
.
$table_alias
.
"E ON "
.
$table_alias
.
"E.VALUE_ID = "
.
$ID
.
"
79
LEFT JOIN b_user_field_enum "
.
$table_alias
.
"EN ON "
.
$table_alias
.
"EN.ID = "
.
$table_alias
.
"E."
. $FIELD_NAME :
80
"LEFT JOIN b_utm_"
. $this->entity_id .
" "
.
$table_alias
.
"E ON "
.
$table_alias
.
"E.FIELD_ID = "
. $arField[
"ID"
] .
" AND "
.
$table_alias
.
"E.VALUE_ID = "
.
$ID
.
"
81
LEFT JOIN b_user_field_enum "
.
$table_alias
.
"EN ON "
.
$table_alias
.
"EN.ID = "
.
$table_alias
.
"E.VALUE_INT"
,
82
);
83
}
84
}
85
$this->obWhere->SetFields(
$arFields
);
86
}
87
88
function
SetSelect
($arSelect)
89
{
90
$this->obWhere->bDistinctReqired =
false
;
91
$this->
select
=
array
();
92
if
(is_array($arSelect))
93
{
94
if
(in_array(
"UF_*"
, $arSelect))
95
{
96
foreach
($this->user_fields as $FIELD_NAME => $arField)
97
{
98
$this->
select
[$FIELD_NAME] =
true
;
99
}
100
}
101
else
102
{
103
foreach
($arSelect as $field)
104
{
105
if
(array_key_exists($field, $this->user_fields))
106
{
107
$this->
select
[$field] =
true
;
108
}
109
}
110
}
111
}
112
}
113
114
function
GetDistinct
()
115
{
116
return
$this->obWhere->bDistinctReqired;
117
}
118
119
function
GetSelect
()
120
{
121
$result
=
""
;
122
foreach
($this->
select
as
$key
=> $value)
123
{
124
$simpleFormat =
true
;
125
if
($this->user_fields[
$key
][
"MULTIPLE"
] ==
"N"
)
126
{
127
if
($arType = $this->user_fields[
$key
][
"USER_TYPE"
])
128
{
129
if
(is_callable(
array
($arType[
"CLASS_NAME"
],
"FormatField"
)))
130
{
131
$result
.=
", "
. call_user_func_array(
array
($arType[
"CLASS_NAME"
],
"FormatField"
),
array
($this->user_fields[
$key
], $this->table_alias .
"."
.
$key
)) .
" "
.
$key
;
132
$simpleFormat =
false
;
133
}
134
}
135
}
136
if
($simpleFormat)
137
{
138
$result
.=
", "
. $this->table_alias .
"."
.
$key
;
139
}
140
}
141
return
$result
;
142
}
143
144
function
GetJoin
(
$ID
)
145
{
146
$result
= $this->obWhere->GetJoins();
147
$table =
" b_uts_"
. $this->entity_id .
" "
. $this->table_alias .
" "
;
148
if
((!empty($this->
select
) || !empty($this->order)) && !str_contains(
$result
, $table))
149
$result
.=
"\nLEFT JOIN"
. $table .
"ON "
. $this->table_alias .
".VALUE_ID = "
.
$ID
;
150
return
$result
;
151
}
152
153
function
SetOrder
($arOrder)
154
{
155
if
(is_array($arOrder))
156
{
157
$this->order =
array
();
158
foreach
($arOrder as $field =>
$order
)
159
{
160
if
(array_key_exists($field, $this->user_fields))
161
$this->order[$field] =
$order
!=
"ASC"
?
"DESC"
:
"ASC"
;
162
}
163
}
164
}
165
166
function
GetOrder
($field)
167
{
168
$field = mb_strtoupper($field);
169
if
(isset($this->order[$field]))
170
$result
= $this->table_alias .
"."
. $field;
171
else
172
$result
=
""
;
173
return
$result
;
174
}
175
176
function
SetFilter
(
$arFilter
)
177
{
178
if
(is_array(
$arFilter
))
179
$this->filter =
$arFilter
;
180
}
181
182
function
GetFilter
()
183
{
184
return
$this->obWhere->GetQuery($this->filter);
185
}
186
}
select
return select
Определения
access_edit.php:440
CSQLWhere
Определения
sqlwhere.php:1359
CUserTypeSQL
Определения
usertypesql.php:4
CUserTypeSQL\GetJoin
GetJoin($ID)
Определения
usertypesql.php:144
CUserTypeSQL\GetSelect
GetSelect()
Определения
usertypesql.php:119
CUserTypeSQL\$order
$order
Определения
usertypesql.php:11
CUserTypeSQL\SetOrder
SetOrder($arOrder)
Определения
usertypesql.php:153
CUserTypeSQL\GetDistinct
GetDistinct()
Определения
usertypesql.php:114
CUserTypeSQL\$table_alias
$table_alias
Определения
usertypesql.php:5
CUserTypeSQL\SetEntity
SetEntity($entity_id, $ID)
Определения
usertypesql.php:16
CUserTypeSQL\GetOrder
GetOrder($field)
Определения
usertypesql.php:166
CUserTypeSQL\$select
$select
Определения
usertypesql.php:9
CUserTypeSQL\$user_fields
$user_fields
Определения
usertypesql.php:7
CUserTypeSQL\SetFilter
SetFilter($arFilter)
Определения
usertypesql.php:176
CUserTypeSQL\$filter
$filter
Определения
usertypesql.php:10
CUserTypeSQL\$obWhere
$obWhere
Определения
usertypesql.php:14
CUserTypeSQL\SetSelect
SetSelect($arSelect)
Определения
usertypesql.php:88
CUserTypeSQL\$entity_id
$entity_id
Определения
usertypesql.php:6
CUserTypeSQL\GetFilter
GetFilter()
Определения
usertypesql.php:182
$arFields
$arFields
Определения
dblapprove.php:5
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$USER_FIELD_MANAGER
global $USER_FIELD_MANAGER
Определения
attempt.php:6
$result
$result
Определения
get_property_values.php:14
$ID
if($ajaxMode) $ID
Определения
get_user.php:27
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$key
if(empty($signedUserToken)) $key
Определения
quickway.php:257
$arFilter
$arFilter
Определения
user_search.php:106
bitrix
modules
main
classes
general
usertypesql.php
Создано системой
1.14.0