98 $contentId = (!empty($params[
'contentId']) ? $params[
'contentId'] :
false);
99 $pageNum = (!empty($params[
'page']) ? (int)$params[
'page'] : 1);
100 $pathToUserProfile = (!empty($params[
'pathToUserProfile']) ? $params[
'pathToUserProfile'] :
'');
114 'USER_NAME' =>
'USER.NAME',
115 'USER_LAST_NAME' =>
'USER.LAST_NAME',
116 'USER_SECOND_NAME' =>
'USER.SECOND_NAME',
117 'USER_LOGIN' =>
'USER.LOGIN',
118 'USER_PERSONAL_PHOTO' =>
'USER.PERSONAL_PHOTO',
119 'USER_PERSONAL_GENDER' =>
'USER.PERSONAL_GENDER'
122 $extranetInstalled = $mailInstalled =
false;
123 $extranetIdList = [];
125 if (ModuleManager::isModuleInstalled(
'extranet'))
127 $extranetInstalled =
true;
128 $select[
'USER_UF_DEPARTMENT'] =
"USER.UF_DEPARTMENT";
131 if (IsModuleInstalled(
'mail'))
133 $mailInstalled =
true;
134 $select[
'USER_EXTERNAL_AUTH_ID'] =
"USER.EXTERNAL_AUTH_ID";
139 'DATE_VIEW' =>
'DESC'
142 '=CONTENT_ID' => $contentId
147 if (!$extranetInstalled)
149 $queryParams[
'limit'] = $pageSize;
150 $queryParams[
'offset'] = ($pageNum - 1) * $pageSize;
154 $timeZoneOffset = \CTimeZone::getOffset();
156 $res = UserContentViewTable::getList($queryParams);
158 while ($fields = $res->fetch())
162 if ((
int)$fields[
'USER_PERSONAL_PHOTO'] <= 0)
164 switch ($fields[
'USER_PERSONAL_GENDER'])
175 $fields[
'USER_PERSONAL_PHOTO'] = Option::get(
'socialnetwork',
'default_user_picture_' . $suffix,
false, SITE_ID);
179 !empty($fields[
'USER_PERSONAL_PHOTO'])
180 && (
int)$fields[
'USER_PERSONAL_PHOTO'] > 0
183 $file = \CFile::resizeImageGet(
184 $fields[
"USER_PERSONAL_PHOTO"],
185 [
'width' => 58,
'height' => 58 ],
186 BX_RESIZE_IMAGE_EXACT,
191 $photoSrc = $file[
"src"];
195 'NAME' => $fields[
'USER_NAME'],
196 'LAST_NAME' => $fields[
'USER_LAST_NAME'],
197 'SECOND_NAME' => $fields[
'USER_SECOND_NAME'],
198 'LOGIN' => $fields[
'USER_LOGIN'],
204 && $fields[
"USER_EXTERNAL_AUTH_ID"] ===
"email"
212 empty($fields[
"USER_UF_DEPARTMENT"])
213 || (
int)$fields[
"USER_UF_DEPARTMENT"][0] <= 0
217 $userType =
"extranet";
218 $extranetIdList[] = $fields[
"USER_ID"];
222 $fields[
'DATE_VIEW'] instanceof \Bitrix\Main\Type\DateTime
223 ? $fields[
'DATE_VIEW']->toString()
227 $userList[$fields[
'USER_ID']] = [
228 'ID' => $fields[
'USER_ID'],
230 'URL' => \CUtil::jSEscape(\CComponentEngine::makePathFromTemplate($pathToUserProfile, [
231 "UID" => $fields[
"USER_ID"],
232 "user_id" => $fields[
"USER_ID"],
233 "USER_ID" => $fields[
"USER_ID"]
235 'PHOTO_SRC' => $photoSrc,
236 'FULL_NAME' => \CUser::formatName(\CSite::getNameFormat(), $userFields,
true,
true),
237 'DATE_VIEW' => $dateView,
238 'DATE_VIEW_FORMATTED' => (
240 ? \CComponentUtil::getDateTimeFormatted(MakeTimeStamp($dateView),
"FULL", $timeZoneOffset)
246 $userIdToCheckList = [];
248 if (Loader::includeModule(
'extranet'))
250 $userIdToCheckList = (
251 \CExtranet::isIntranetUser(SITE_ID, $USER->getId())
253 : array_keys($userList)
257 if (!empty($userIdToCheckList))
259 $myGroupsUserList = \CExtranet::getMyGroupsUsersSimple(\CExtranet::getExtranetSiteID());
260 foreach ($userIdToCheckList as $userIdToCheck)
263 !in_array($userIdToCheck, $myGroupsUserList)
264 && $userIdToCheck != $USER->getId()
267 unset($userList[$userIdToCheck]);
268 $result[
'hiddenCount']++;
273 if (!$extranetInstalled)
275 $result[
'items'] = $userList;
277 elseif ($pageNum <= ((count($userList) / $pageSize) + 1))
279 $res = new \CDBResult();
280 $res->initFromArray($userList);
281 $res->navStart($pageSize,
false, $pageNum);
283 while($user = $res->fetch())
285 $result[
'items'][] = $user;
290 $result[
'items'] = [];
318 public static function set(array $params = []): void
321 isset($params[
"xmlIdList"])
322 && is_array($params[
"xmlIdList"])
323 ? $params[
"xmlIdList"]
327 $context = ($params[
'context'] ??
'');
330 isset($params[
'userId'])
331 && (int)$params[
'userId'] > 0
332 ? (
int)$params[
'userId'] :
336 if (!empty($xmlIdList))
338 foreach ($xmlIdList as $val)
340 $xmlId = $val[
'xmlId'];
343 || $val[
'save'] !==
'N'
353 $provider = Livefeed\Provider::init([
354 'ENTITY_TYPE' => $entityType,
355 'ENTITY_ID' => $entityId,
359 $hasPermissions =
true;
361 isset($val[
'checkAccess'])
362 && $val[
'checkAccess'] ===
true
365 $provider->setOption(
'checkAccess',
true);
366 $provider->initSourceFields();
368 if (empty($provider->getSourceFields()))
370 $hasPermissions =
false;
376 $provider->setContentView([
394 'context' => $context
399 public static function finalize($params = []): bool
401 $userId = (!empty($params[
'userId']) ? (int)$params[
'userId'] : 0);
402 $context = (!empty($params[
'context']) ? $params[
'context'] :
'');
410 $context !==
'forum.comments/mobile'
411 && ModuleManager::isModuleInstalled(
'tasks')
414 $taskIdList = \Bitrix\Socialnetwork\Integration\Forum\TaskComment::getViewedCommentsTasksList();
415 if (!empty($taskIdList))
417 $event = new \Bitrix\Main\Event(
418 'socialnetwork',
'onContentFinalizeView',
421 'commentsTaskIdList' => $taskIdList