...Человеческий поиск в разработке...
- Модуль: bizproc
- Путь к файлу: ~/bitrix/modules/bizproc/classes/general/helper.php
- Класс: CBPHelper
- Вызов: CBPHelper::extractUsers
static function extractUsers($arUsersDraft, $documentId, $bFirst = false) { $result = []; if (!is_array($arUsersDraft)) { $arUsersDraft = array($arUsersDraft); } $l = mb_strlen("user_"); $documentService = CBPRuntime::GetRuntime(true)->getDocumentService(); foreach ($arUsersDraft as $user) { if (!is_scalar($user)) { continue; } if (mb_substr($user, 0, $l) === "user_") { $user = intval(mb_substr($user, $l)); if (($user > 0) && !in_array($user, $result)) { if ($bFirst) { return $user; } $result[] = $user; } } elseif (CBPActivity::isExpression($user)) { $parsed = CBPActivity::parseExpression($user); if ($parsed && $parsed['object'] === 'Document') { $document = $documentService->GetDocument($documentId); if ($document && $document[$parsed['field']]) { foreach ((array) $document[$parsed['field']] as $docUser) { if (mb_substr($docUser, 0, $l) === "user_") { $user = intval(mb_substr($docUser, $l)); if (($user > 0) && !in_array($user, $result)) { if ($bFirst) { return $user; } $result[] = $user; } } } } } } else { $users = self::extractUsersFromExtendedGroup($user); if ($users === false) { $users = $documentService->GetUsersFromUserGroup($user, $documentId); } foreach ($users as $u) { $u = (int)$u; if (($u > 0) && !in_array($u, $result)) { if ($bFirst) { return $u; } $result[] = $u; } } } } if (!$bFirst) { return $result; } if (count($result) > 0) { return $result[0]; } return null; }