26 public function getData($params = array())
30 'ITEMS_LAST' => array(),
31 'ITEMS_HIDDEN' => array(),
32 'ADDITIONAL_INFO' => array(
34 'GROUPS_LIST' => array(
38 'DESC_LESS_MODE' =>
'Y',
42 'SORT_SELECTED' => 200
48 $options = (!empty($params[
'options']) ? $params[
'options'] : array());
50 $lastItems = (!empty($params[
'lastItems']) ? $params[
'lastItems'] : array());
51 $selectedItems = (!empty($params[
'selectedItems']) ? $params[
'selectedItems'] : array());
53 $selectedUserList = array();
54 if (!empty($selectedItems[$entityType]))
56 $selectedUserList = array_map(
59 return preg_replace(
'/^U(\d+)$/',
'$1', $code);
61 $selectedItems[$entityType]
65 $allowSearchSelf = (!isset($options[
'allowSearchSelf']) || $options[
'allowSearchSelf'] !==
'N');
68 if (!empty($selectedUserList))
70 $selected = \CSocNetLogDestination::getUsers([
71 'id' => $selectedUserList,
72 'CRM_ENTITY' => ModuleManager::isModuleInstalled(
'crm'),
73 'IGNORE_ACTIVITY' =>
'Y',
74 'ALLOW_BOTS' => (isset($options[
'allowBots']) && $options[
'allowBots'] ===
'Y')
80 $items[$entityType] = \CSocNetLogDestination::getExtranetUser();
81 $result[
'ADDITIONAL_INFO'][
'EXTRANET_USER'] =
'Y';
83 if (!empty($selectedItems[$entityType]))
85 foreach($selectedItems[$entityType] as $code)
87 if (!isset($items[$entityType][$code]))
89 $result[
'ITEMS_HIDDEN'][] = $code;
94 $result[
'ITEMS'] = $items[$entityType];
95 if(!empty($lastItems[$entityType]))
97 $result[
"ITEMS_LAST"] = array_values($lastItems[$entityType]);
99 $result[
"ITEMS_LAST"] = array_values(array_intersect($result[
"ITEMS_LAST"], array_keys($result[
'ITEMS'])));
104 if(!empty($lastItems[$entityType]))
106 $lastUserList = array_map(
109 return preg_replace(
'/^U(\d+)$/',
'$1', $code);
111 $lastItems[$entityType]
115 $result[
'ADDITIONAL_INFO'][
'EXTRANET_USER'] =
'N';
117 $items[$entityType] = [];
118 if (!empty($lastUserList))
120 $items[$entityType] = \CSocNetLogDestination::getUsers([
121 'id' => $lastUserList,
122 'CRM_ENTITY' => ModuleManager::isModuleInstalled(
'crm'),
123 'ONLY_WITH_EMAIL' => (isset($options[
'onlyWithEmail']) && $options[
'onlyWithEmail'] ===
'Y' ?
'Y' :
''),
124 'ALLOW_BOTS' => (isset($options[
'allowBots']) && $options[
'allowBots'] ===
'Y')
125 ], $allowSearchSelf);
128 $items[$entityType] = array_merge($items[$entityType], $selected);
131 isset($options[
'extranetContext'])
135 foreach($items[$entityType] as $key => $value)
137 if (isset($value[
"isExtranet"]))
141 $value[
"isExtranet"] ===
'Y'
145 $value[
"isExtranet"] ===
'N'
150 unset($items[$entityType][$key]);
151 unset($lastItems[$entityType][$key]);
157 if (!empty($selectedItems[$entityType]))
159 foreach($selectedItems[$entityType] as $code)
161 if (!isset($items[$entityType][$code]))
163 $result[
'ITEMS_HIDDEN'][] = $code;
168 foreach($items[$entityType] as $key => $value)
171 !empty($value[
'isEmail'])
172 && $value[
'isEmail'] ===
'Y'
175 unset($items[$entityType][$key]);
176 unset($lastItems[$entityType][$key]);
180 $result[
"ITEMS_LAST"] = array_values($lastItems[$entityType]);
184 isset($options[
"allowAddUser"])
185 && $options[
"allowAddUser"] ===
'Y'
188 isset($options[
"allowSearchEmailUsers"])
189 && $options[
"allowSearchEmailUsers"] ===
'Y'
192 isset($options[
"allowEmailInvitation"])
193 && $options[
"allowEmailInvitation"] ===
'Y'
197 $items[
'LAST'] = $result[
"ITEMS_LAST"];
198 \CSocNetLogDestination::fillEmails($items);
199 $result[
"ITEMS_LAST"] = $items[
'LAST'];
200 unset($items[
'LAST']);
205 empty($items[$entityType])
207 is_array($items[$entityType])
208 && count($items[$entityType]) < 3
211 && ModuleManager::isModuleInstalled(
'intranet')
213 !isset($options[
'extranetContext'])
218 $lastUserList = array();
220 $res = UserTable::getList(array(
222 'LAST_ACTIVITY_DATE' =>
'DESC'
225 '!=UF_DEPARTMENT' =>
false,
227 'CONFIRM_CODE' =>
false
229 'select' => array(
'ID'),
232 while($userFields = $res->fetch())
234 $lastUserList[] = $userFields[
'ID'];
237 $items[$entityType] = array_merge((is_array($items[$entityType]) ? $items[$entityType] : array()), \CSocNetLogDestination::getUsers([
238 'id' => $lastUserList,
239 'ONLY_WITH_EMAIL' => (isset($options[
'onlyWithEmail']) && $options[
'onlyWithEmail'] ===
'Y' ?
'Y' :
''),
240 'ALLOW_BOTS' => (isset($options[
'allowBots']) && $options[
'allowBots'] ===
'Y')
241 ], $allowSearchSelf));
242 foreach($items[$entityType] as $item)
244 $result[
"ITEMS_LAST"][] =
'U'.$item[
'entityId'];
250 isset($options[
"showVacations"])
251 && $options[
"showVacations"] ===
'Y'
254 $result[
'ADDITIONAL_INFO'][
'USERS_VACATION'] = \Bitrix\Socialnetwork\Integration\Intranet\Absence\User::getDayVacationList();
257 $result[
'ITEMS'] = $items[$entityType];
262 public function search($params = array())
266 'ADDITIONAL_INFO' => array()
269 $entityOptions = (!empty($params[
'options']) ? $params[
'options'] : array());
272 !empty($entityOptions[
'allowSearch'])
273 && $entityOptions[
'allowSearch'] ===
'N'
279 $requestFields = (!empty($params[
'requestFields']) ? $params[
'requestFields'] : []);
280 $commonOptions = (!empty($requestFields[
'options']) ? $requestFields[
'options'] : []);
282 $search = $requestFields[
'searchString'];
283 $searchConverted = (!empty($requestFields[
'searchStringConverted']) ? $requestFields[
'searchStringConverted'] :
false);
286 $searchModified =
false;
287 $result[
"ITEMS"] = \CSocNetLogDestination::searchUsers(
290 "NAME_TEMPLATE" => $nameTemplate,
291 "SELF" => (!empty($entityOptions[
'allowSearchSelf']) && $entityOptions[
'allowSearchSelf'] ===
'Y'),
292 "EMPLOYEES_ONLY" => (!empty($entityOptions[
'scope']) && $entityOptions[
'scope'] ===
"I"),
293 "EXTRANET_ONLY" => (!empty($entityOptions[
'scope']) && $entityOptions[
'scope'] ===
"E"),
294 "DEPARTAMENT_ID" => (
295 !empty($commonOptions[
'siteDepartmentId'])
296 && (
int)$commonOptions[
'siteDepartmentId'] > 0
297 ? (
int)$commonOptions[
'siteDepartmentId']
300 "EMAIL_USERS" => (!empty($entityOptions[
'allowSearchByEmail']) && $entityOptions[
'allowSearchByEmail'] ===
'Y'),
301 "CRMEMAIL_USERS" => (!empty($entityOptions[
'allowSearchCrmEmailUsers']) && $entityOptions[
'allowSearchCrmEmailUsers'] ===
'Y'),
302 "NETWORK_SEARCH" =>
false,
303 "ONLY_WITH_EMAIL" => (isset($entityOptions[
'onlyWithEmail']) && $entityOptions[
'onlyWithEmail'] ===
'Y' ?
'Y' :
''),
304 'ALLOW_BOTS' => (isset($entityOptions[
'allowBots']) && $entityOptions[
'allowBots'] ===
'Y'),
305 'SHOW_ALL_EXTRANET_CONTACTS' => (isset($entityOptions[
'showAllExtranetContacts']) && $entityOptions[
'showAllExtranetContacts'] ===
'Y')
310 if (!empty($searchModified))
312 $result[
'SEARCH'] = $searchModified;
316 empty($result[
"ITEMS"])
318 && $search !== $searchConverted
321 $result[
"ITEMS"] = \CSocNetLogDestination::searchUsers(
323 "SEARCH" => $searchConverted,
324 "NAME_TEMPLATE" => $nameTemplate,
325 "SELF" => (!empty($entityOptions[
'allowSearchSelf']) && $entityOptions[
'allowSearchSelf'] ===
'Y'),
326 "EMPLOYEES_ONLY" => (!empty($entityOptions[
'scope']) && $entityOptions[
'scope'] ===
"I"),
327 "EXTRANET_ONLY" => (!empty($entityOptions[
'scope']) && $entityOptions[
'scope'] ===
"E"),
328 "DEPARTAMENT_ID" => (
329 !empty($commonOptions[
'siteDepartmentId'])
330 && (
int)$commonOptions[
'siteDepartmentId'] > 0
331 ? (
int)$commonOptions[
'siteDepartmentId']
334 "EMAIL_USERS" => (!empty($entityOptions[
'allowSearchByEmail']) && $entityOptions[
'allowSearchByEmail'] ===
'Y'),
335 "CRMEMAIL_USERS" => (!empty($entityOptions[
'allowSearchCrmEmailUsers']) && $entityOptions[
'allowSearchCrmEmailUsers'] ===
'Y'),
336 "NETWORK_SEARCH" =>
false,
337 'ALLOW_BOTS' => (isset($entityOptions[
'allowBots']) && $entityOptions[
'allowBots'] ===
'Y'),
338 'SHOW_ALL_EXTRANET_CONTACTS' => (isset($entityOptions[
'showAllExtranetContacts']) && $entityOptions[
'showAllExtranetContacts'] ===
'Y')
343 $result[
'SEARCH'] = $searchConverted;
368 preg_match(
'/^U(\d+)$/i', $itemCode, $matches)
369 && intval($matches[1]) > 0
370 ? intval($matches[1])
376 && \CSocNetUser::canProfileView($USER->getId(), $entityId)
379 $res = UserTable::getList(array(
383 'select' => array(
'NAME',
'SECOND_NAME',
'LAST_NAME',
'LOGIN')
386 if ($userFields = $res->fetch())
388 $result = \CUser::formatName(self::getNameTemplate(), $userFields,
false);