12use Bitrix\HumanResources\Compatibility\Utils\DepartmentBackwardAccessCode;
13use Bitrix\HumanResources\Service\Container;
14use Bitrix\Main\DB\SqlExpression;
15use Bitrix\Main\Localization\Loc;
16use Bitrix\Main\ORM\Data\DataManager;
17use Bitrix\Main\ORM\Fields\BooleanField;
18use Bitrix\Main\ORM\Fields\DateField;
19use Bitrix\Main\ORM\Fields\DatetimeField;
20use Bitrix\Main\ORM\Fields\IntegerField;
21use Bitrix\Main\ORM\Fields\StringField;
22use Bitrix\Main\ORM\Fields\ExpressionField;
23use Bitrix\Main\ORM\Fields\Relations\OneToMany;
24use Bitrix\Main\ORM\Fields\Relations\Reference;
25use Bitrix\Main\ORM\Fields\TextField;
26use Bitrix\Main\ORM\Query\Join;
27use Bitrix\Main\Search\MapBuilder;
29Loc::loadMessages(__FILE__);
67 ->configureAutocomplete(),
77 ->configureValues(
'N',
'Y'),
80 ->configureValues(
'N',
'Y'),
86 $helper->getDatetimeToDateFunction(
'%s'),
88 )->configureValueType(DatetimeField::class),
94 $helper->getDatetimeToDateFunction(
'%s'),
96 )->configureValueType(DatetimeField::class),
152 $helper->getConcatFunction(
155 "UPPER(" . $helper->getSubstrFunction(
"%s", 1, 1) .
")",
"'.'"
157 [
'LAST_NAME',
'NAME']
163 . $helper->addSecondsToDateTime(
'(-' . self::getSecondsForLimitOnline() .
')')
164 .
' THEN \'Y\' ELSE \'N\' END',
165 'LAST_ACTIVITY_DATE',
166 [
'values' => [
'N',
'Y']]
167 ))->configureValueType(BooleanField::class),
171 'CASE WHEN %s IN (\''
172 . join(
'\', \
'', static::getExternalUserTypes())
173 .
'\') THEN \
'N\' ELSE \'Y\' END',
175 [
'values' => [
'N',
'Y']]
176 ))->configureValueType(BooleanField::class),
181 %s NOT IN ('" . join(
"', '", static::getExternalUserTypes()) .
"')
184 [
'EXTERNAL_AUTH_ID',
'EXTERNAL_AUTH_ID'],
185 ))->configureValueType(BooleanField::class),
189 UserIndexTable::class,
190 Join::on(
'this.ID',
'ref.USER_ID')
191 ))->configureJoinType(Join::TYPE_INNER),
195 UserCounterTable::class,
196 Join::on(
'this.ID',
'ref.USER_ID')->where(
'ref.CODE',
'tasks_effective')
200 UserPhoneAuthTable::class,
201 Join::on(
'this.ID',
'ref.USER_ID')
203 (
new OneToMany(
'GROUPS', UserGroupTable::class,
'USER'))
204 ->configureJoinType(Join::TYPE_INNER),
209 Join::on(
'this.LANGUAGE_ID',
'ref.LID')->where(
'ref.ACTIVE',
'Y')
213 'NOTIFICATION_LANGUAGE_ID',
214 'CASE WHEN (%s IS NOT NULL AND %s = %s) THEN %s ELSE %s END',
216 'LANGUAGE_ID',
'LANGUAGE_ID',
'ACTIVE_LANGUAGE.LID',
'LANGUAGE_ID',
function () {
220 ))->configureValueType(StringField::class),
226 $seconds = intval(ini_get(
"session.gc_maxlifetime"));
261 'cache' => [
'ttl' => 86400],
264 while ($row =
$result->fetch())
274 static::getEntity()->getConnection()->getSqlHelper()->getCurrentDateTimeFunction()
280 '=UserGroup:GROUP.USER_ID' =>
$userId,
284 '=UserGroup:GROUP.DATE_ACTIVE_FROM' =>
null,
285 '<=UserGroup:GROUP.DATE_ACTIVE_FROM' => $nowTimeExpression,
289 '=UserGroup:GROUP.DATE_ACTIVE_TO' =>
null,
290 '>=UserGroup:GROUP.DATE_ACTIVE_TO' => $nowTimeExpression,
295 while ($row =
$result->fetch())
339 'PERSONAL_PROFESSION',
363 return array_merge(
$fields, [
'UF_DEPARTMENT']);
380 return !empty(array_intersect(
381 static::getIndexedFields(),
394 $record = parent::getList([
395 'select' => static::getIndexedFields(),
396 'filter' => [
'=ID' => $id],
399 if (!is_array($record))
404 $record[
'UF_DEPARTMENT_NAMES'] = [];
407 && isset($record[
'UF_DEPARTMENT'])
408 && is_array($record[
'UF_DEPARTMENT'])
411 $departments = Container::getNodeRepository()->findAllByAccessCodes(
413 static fn($departmentId) => DepartmentBackwardAccessCode::makeById((
int)$departmentId),
414 $record[
'UF_DEPARTMENT'],
418 foreach ($departments as $department)
420 $record[
'UF_DEPARTMENT_NAMES'][] = $department->name;
424 $departmentName = $record[
'UF_DEPARTMENT_NAMES'][0] ??
'';
425 $searchDepartmentContent = implode(
' ', $record[
'UF_DEPARTMENT_NAMES']);
429 'NAME' => (
string)$record[
'NAME'],
430 'SECOND_NAME' => (
string)$record[
'SECOND_NAME'],
431 'LAST_NAME' => (
string)$record[
'LAST_NAME'],
432 'WORK_POSITION' => (
string)$record[
'WORK_POSITION'],
433 'UF_DEPARTMENT_NAME' => (
string)$departmentName,
434 'SEARCH_USER_CONTENT' => self::generateSearchUserContent($record),
435 'SEARCH_ADMIN_CONTENT' => self::generateSearchAdminContent($record),
436 'SEARCH_DEPARTMENT_CONTENT' =>
MapBuilder::create()->addText($searchDepartmentContent)->build(),
444 UserIndexTable::delete($id);
447 private static function generateSearchUserContent(
array $fields)
449 $text = implode(
' ', [
455 $charsToReplace = [
'(',
')',
'[',
']',
'{',
'}',
'<',
'>',
'-',
'#',
'"',
'\''];
457 $clearedText = str_replace($charsToReplace,
' ',
$text);
458 $clearedText = preg_replace(
'/\s\s+/',
' ', $clearedText);
462 ->addText($clearedText)
469 private static function generateSearchAdminContent(
array $fields)
472 isset(
$fields[
'PERSONAL_COUNTRY'])
473 && intval(
$fields[
'PERSONAL_COUNTRY'])
475 'VALUE' => intval(
$fields[
'PERSONAL_COUNTRY']),
481 && intval(
$fields[
'WORK_COUNTRY'])
483 'VALUE' => intval(
$fields[
'WORK_COUNTRY']),
488 isset(
$fields[
'UF_DEPARTMENT_NAMES'])
489 && is_array(
$fields[
'UF_DEPARTMENT_NAMES'])
490 ? implode(
' ',
$fields[
'UF_DEPARTMENT_NAMES'])
500 ->addText(
$fields[
'SECOND_NAME'])
501 ->addText(
$fields[
'LAST_NAME'])
503 ->addText(
$fields[
'WORK_POSITION'])
504 ->addText(
$fields[
'PERSONAL_PROFESSION'])
505 ->addText(
$fields[
'PERSONAL_WWW'])
507 ->addPhone(
$fields[
'PERSONAL_MOBILE'])
508 ->addPhone(
$fields[
'PERSONAL_PHONE'])
509 ->addText(
$fields[
'PERSONAL_CITY'])
510 ->addText(
$fields[
'PERSONAL_STREET'])
511 ->addText(
$fields[
'PERSONAL_STATE'])
512 ->addText(
$fields[
'PERSONAL_ZIP'])
513 ->addText(
$fields[
'PERSONAL_MAILBOX'])
514 ->addText(
$fields[
'WORK_CITY'])
515 ->addText(
$fields[
'WORK_STREET'])
516 ->addText(
$fields[
'WORK_STATE'])
518 ->addText(
$fields[
'WORK_MAILBOX'])
519 ->addPhone(
$fields[
'WORK_PHONE'])
520 ->addText(
$fields[
'WORK_COMPANY'])
521 ->addText($personalCountry)
522 ->addText($workCountry)
523 ->addText($department)
524 ->addText($ufContent)
525 ->addText($tagsContent)
542 public static function delete($primary)
549 $id =
$event->getParameter(
"id");
550 static::indexRecord($id);
556 $primary =
$event->getParameter(
"id");
557 $id = $primary[
"ID"];
558 static::indexRecord($id);
564 $primary =
$event->getParameter(
"id");
565 $id = $primary[
"ID"];
566 static::deleteIndexRecord($id);
574 if (
$entity->hasField(
'UTS_OBJECT'))
577 $leftUtsRef =
$entity->getField(
'UTS_OBJECT');
581 'UTS_OBJECT_INNER', $leftUtsRef->getRefEntity(), $leftUtsRef->getReference()
583 ->configureJoinType(
'inner')
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static getConnection($name="")
static includeModule($moduleName)
static isModuleInstalled($moduleName)
static getList(array $parameters=array())
static postInitialize(Entity $entity)
static getDefaultLanguageId()
static merge(array $data)
static getExternalUserTypes()
static getSecondsForLimitOnline()
static onAfterDelete(ORM\Event $event)
static shouldReindex(array $fields)
static onAfterAdd(ORM\Event $event)
static getIndexedFields()
static onAfterUpdate(ORM\Event $event)
static getActiveUsersCount(Type\Date $lastLoginDate=null)
static deleteIndexRecord($id)
static update($primary, array $data)
static getUserGroupIds($userId)
static getTagsContent($userId)
static getUFContent($userId)
static getCountryValue(array $params=[])
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)