118 public static function loadProfiles($userId, $personTypeId =
null, $profileId =
null)
121 $userId = (int)$userId;
126 $locationCodeList = array();
130 return $result->addError(
new Error(
"EMPTY USER ID"));
134 $filter[
'USER_ID'] = $userId;
137 if ((
int)$personTypeId > 0)
138 $filter[
'PERSON_TYPE_ID'] = (int)$personTypeId;
140 if ((
int)$profileId > 0)
141 $filter[
'USER_PROPS_ID'] = (
int)$profileId;
143 $userPropsValueData = Internals\UserPropsValueTable::getList(
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',
157 'USER_PROPERTY.DATE_UPDATE' =>
'DESC',
158 'USER_PROPERTY.NAME' =>
'ASC'
163 while ($propValue = $userPropsValueData->fetch())
165 if (($propValue[
'MULTIPLE'] ===
'Y' || $propValue[
'TYPE'] ===
'FILE')
166 && CheckSerializedData($propValue[
'VALUE'])
167 && ($serialisedValue = @unserialize($propValue[
'VALUE'], [
'allowed_classes' =>
false])) !==
false)
169 $propValue[
'VALUE'] = $serialisedValue;
172 if (!array_key_exists($propValue[
'PERSON_TYPE_ID'], $resultData))
173 $resultData[$propValue[
'PERSON_TYPE_ID']] = array();
175 $resultData[$propValue[
'PERSON_TYPE_ID']][$propValue[
'USER_PROPS_ID']][
'NAME'] = $propValue[
'PROFILE_NAME'];
177 if ($propValue[
'TYPE'] ===
'ENUM' && $propValue[
'MULTIPLE'] ===
'Y')
179 $propValue[
'VALUE'] = explode(
',', $propValue[
'VALUE']);
181 elseif ($propValue[
'TYPE'] ===
'FILE' && !empty($propValue[
'VALUE']))
183 $fileIds = $propValue[
'VALUE'];
184 $propValue[
'VALUE'] = array();
185 if (is_array($fileIds))
187 foreach ($fileIds as $value)
189 if ($fileArray = \CFile::GetFileArray($value))
191 $propValue[
'VALUE'][] = $fileArray;
195 elseif ($fileArray = \CFile::GetFileArray($fileIds))
197 $propValue[
'VALUE'] = $fileArray;
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'];
205 $result->setData($resultData);
220 if ((
int)$profileId <= 0)
225 $userPropsValueData = Internals\UserPropsTable::getList(
227 'filter' => array(
'=ID' => (
int)$profileId),
228 'select' => array(
'ID',
'USER_ID',
'PERSON_TYPE_ID'),
232 $profile = $userPropsValueData->fetch();
237 $resultLoading = static::loadProfiles($profile[
'USER_ID'], $profile[
'PERSON_TYPE_ID'], $profile[
'ID']);
239 if ($resultLoading->isSuccess())
241 $data = $resultLoading->getData();
242 $resultValue = $data[$profile[
'PERSON_TYPE_ID']][$profile[
'ID']][
'VALUES'];
243 $result = !empty($resultValue) ? $resultValue : array();