- Модуль: socialnetwork
- Путь к файлу: ~/bitrix/modules/socialnetwork/lib/integration/main/uiselector/users.php
- Класс: BitrixSocialnetworkIntegrationMainUISelectorUsers
- Вызов: Users::getData
public function getData($params = array())
{
$result = array(
'ITEMS' => array(),
'ITEMS_LAST' => array(),
'ITEMS_HIDDEN' => array(),
'ADDITIONAL_INFO' => array(
'PREFIX' => 'U',
'GROUPS_LIST' => array(
'users' => array(
'TITLE' => Loc::getMessage('MAIN_UI_SELECTOR_TITLE_USERS'),
'TYPE_LIST' => array(Handler::ENTITY_TYPE_USERS, Handler::ENTITY_TYPE_EMAILUSERS, Handler::ENTITY_TYPE_GROUPS),
'DESC_LESS_MODE' => 'Y',
'SORT' => 10
)
),
'SORT_SELECTED' => 200
)
);
$entityType = Handler::ENTITY_TYPE_USERS;
$options = (!empty($params['options']) ? $params['options'] : array());
$lastItems = (!empty($params['lastItems']) ? $params['lastItems'] : array());
$selectedItems = (!empty($params['selectedItems']) ? $params['selectedItems'] : array());
$selectedUserList = array();
if (!empty($selectedItems[$entityType]))
{
$selectedUserList = array_map(
function($code)
{
return preg_replace('/^U(d+)$/', '$1', $code);
},
$selectedItems[$entityType]
);
}
$allowSearchSelf = (!isset($options['allowSearchSelf']) || $options['allowSearchSelf'] !== 'N');
$selected = array();
if (!empty($selectedUserList))
{
$selected = CSocNetLogDestination::getUsers([
'id' => $selectedUserList,
'CRM_ENTITY' => ModuleManager::isModuleInstalled('crm'),
'IGNORE_ACTIVITY' => 'Y',
'ALLOW_BOTS' => (isset($options['allowBots']) && $options['allowBots'] === 'Y')
], $allowSearchSelf);
}
if (Handler::isExtranetUser())
{
$items[$entityType] = CSocNetLogDestination::getExtranetUser();
$result['ADDITIONAL_INFO']['EXTRANET_USER'] = 'Y';
if (!empty($selectedItems[$entityType]))
{
foreach($selectedItems[$entityType] as $code)
{
if (!isset($items[$entityType][$code]))
{
$result['ITEMS_HIDDEN'][] = $code;
}
}
}
$result['ITEMS'] = $items[$entityType];
if(!empty($lastItems[$entityType]))
{
$result["ITEMS_LAST"] = array_values($lastItems[$entityType]);
}
$result["ITEMS_LAST"] = array_values(array_intersect($result["ITEMS_LAST"], array_keys($result['ITEMS'])));
}
else
{
$lastUserList = [];
if(!empty($lastItems[$entityType]))
{
$lastUserList = array_map(
function($code)
{
return preg_replace('/^U(d+)$/', '$1', $code);
},
$lastItems[$entityType]
);
}
$result['ADDITIONAL_INFO']['EXTRANET_USER'] = 'N';
$items[$entityType] = [];
if (!empty($lastUserList))
{
$items[$entityType] = CSocNetLogDestination::getUsers([
'id' => $lastUserList,
'CRM_ENTITY' => ModuleManager::isModuleInstalled('crm'),
'ONLY_WITH_EMAIL' => (isset($options['onlyWithEmail']) && $options['onlyWithEmail'] === 'Y' ? 'Y' : ''),
'ALLOW_BOTS' => (isset($options['allowBots']) && $options['allowBots'] === 'Y')
], $allowSearchSelf);
}
$items[$entityType] = array_merge($items[$entityType], $selected);
if (
isset($options['extranetContext'])
&& in_array($options['extranetContext'], array(Entities::EXTRANET_CONTEXT_INTERNAL, Entities::EXTRANET_CONTEXT_EXTERNAL))
)
{
foreach($items[$entityType] as $key => $value)
{
if (isset($value["isExtranet"]))
{
if (
(
$value["isExtranet"] === 'Y'
&& $options['extranetContext'] == Entities::EXTRANET_CONTEXT_INTERNAL
)
|| (
$value["isExtranet"] === 'N'
&& $options['extranetContext'] == Entities::EXTRANET_CONTEXT_EXTERNAL
)
)
{
unset($items[$entityType][$key]);
unset($lastItems[$entityType][$key]);
}
}
}
}
if (!empty($selectedItems[$entityType]))
{
foreach($selectedItems[$entityType] as $code)
{
if (!isset($items[$entityType][$code]))
{
$result['ITEMS_HIDDEN'][] = $code;
}
}
}
foreach($items[$entityType] as $key => $value)
{
if (
!empty($value['isEmail'])
&& $value['isEmail'] === 'Y'
)
{
unset($items[$entityType][$key]);
unset($lastItems[$entityType][$key]);
}
}
$result["ITEMS_LAST"] = array_values($lastItems[$entityType]);
if (
(
isset($options["allowAddUser"])
&& $options["allowAddUser"] === 'Y'
)
|| (
isset($options["allowSearchEmailUsers"])
&& $options["allowSearchEmailUsers"] === 'Y'
)
|| (
isset($options["allowEmailInvitation"])
&& $options["allowEmailInvitation"] === 'Y'
)
)
{
$items['LAST'] = $result["ITEMS_LAST"];
CSocNetLogDestination::fillEmails($items);
$result["ITEMS_LAST"] = $items['LAST'];
unset($items['LAST']);
}
if (
(
empty($items[$entityType])
|| (
is_array($items[$entityType])
&& count($items[$entityType]) < 3
)
)
&& ModuleManager::isModuleInstalled('intranet')
&& (
!isset($options['extranetContext'])
|| $options['extranetContext'] != Entities::EXTRANET_CONTEXT_EXTERNAL
)
)
{
$lastUserList = array();
$res = UserTable::getList(array(
'order' => array(
'LAST_ACTIVITY_DATE' => 'DESC'
),
'filter' => array(
'!=UF_DEPARTMENT' => false,
'=ACTIVE' => 'Y',
'CONFIRM_CODE' => false
),
'select' => array('ID'),
'limit' => 10
));
while($userFields = $res->fetch())
{
$lastUserList[] = $userFields['ID'];
}
$items[$entityType] = array_merge((is_array($items[$entityType]) ? $items[$entityType] : array()), CSocNetLogDestination::getUsers([
'id' => $lastUserList,
'ONLY_WITH_EMAIL' => (isset($options['onlyWithEmail']) && $options['onlyWithEmail'] === 'Y' ? 'Y' : ''),
'ALLOW_BOTS' => (isset($options['allowBots']) && $options['allowBots'] === 'Y')
], $allowSearchSelf));
foreach($items[$entityType] as $item)
{
$result["ITEMS_LAST"][] = 'U'.$item['entityId'];
}
}
}
if (
isset($options["showVacations"])
&& $options["showVacations"] === 'Y'
)
{
$result['ADDITIONAL_INFO']['USERS_VACATION'] = BitrixSocialnetworkIntegrationIntranetAbsenceUser::getDayVacationList();
}
$result['ITEMS'] = $items[$entityType];
return $result;
}