...Человеческий поиск в разработке...
- Модуль: bizproc
- Путь к файлу: ~/bitrix/modules/bizproc/classes/general/helper.php
- Класс: CBPHelper
- Вызов: CBPHelper::searchUserByName
static function searchUserByName($user) { $user = trim($user); if ($user == '') { return []; } $userId = 0; if ($user."|" == intval($user)."|") { $userId = intval($user); } if ($userId <= 0) { $arMatches = []; if (preg_match('#[(d+)]#i', $user, $arMatches)) { $userId = intval($arMatches[1]); } } $arResult = []; $dbUsers = false; if ($userId > 0) { $arFilter = array("ID_EQUAL_EXACT" => $userId); $dbUsers = CUser::GetList( "LAST_NAME", "asc", $arFilter, [ 'FIELDS' => ['ID'], 'NAV_PARAMS' => false ] ); } else { $userLogin = ""; $arMatches = []; if (preg_match('#((.+?))#i', $user, $arMatches)) { $userLogin = $arMatches[1]; $user = trim(str_replace("(".$userLogin.")", "", $user)); } $userEmail = ""; $arMatches = []; if (preg_match("#<(.+?)>#i", $user, $arMatches)) { if (check_email($arMatches[1])) { $userEmail = $arMatches[1]; $user = trim(Str_Replace("<".$userEmail.">", "", $user)); } } $arUser = []; $arUserTmp = explode(" ", $user); foreach ($arUserTmp as $s) { $s = trim($s); if ($s <> '') { $arUser[] = $s; } } if ($userLogin <> '') { $arUser[] = $userLogin; } $dbUsers = CUser::SearchUserByName($arUser, $userEmail, true); } if ($dbUsers) { while ($arUsers = $dbUsers->GetNext()) { $arResult[] = $arUsers["ID"]; } } return $arResult; }