Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
crmemailusers.php
1<?
3
6
8{
9 public function getData($params = array())
10 {
11 $result = array(
12 'ITEMS' => array(),
13 'ITEMS_LAST' => array(),
14 'ADDITIONAL_INFO' => array(
15 'GROUPS_LIST' => array(
16 'crmemailusers' => array(
17 'TITLE' => Loc::getMessage('MAIN_UI_SELECTOR_TITLE_CRM_EMAIL_USERS'),
18 'TYPE_LIST' => array(Handler::ENTITY_TYPE_CRMEMAILUSERS),
19 'DESC_LESS_MODE' => 'Y',
20 'SORT' => 15
21 )
22 ),
23 'SORT_SELECTED' => 200
24 )
25 );
26
27 if (
28 !ModuleManager::isModuleInstalled('mail')
29 || !ModuleManager::isModuleInstalled('crm')
30 )
31 {
32 return $result;
33 }
34
35 $options = (!empty($params['options']) ? $params['options'] : array());
36
37 $lastItems = (!empty($params['lastItems']) ? $params['lastItems'] : array());
38
39 $lastUserList = array();
40 if(!empty($lastItems[Handler::ENTITY_TYPE_USERS]))
41 {
42 foreach ($lastItems[Handler::ENTITY_TYPE_USERS] as $value)
43 {
44 $lastUserList[] = str_replace('U', '', $value);
45 }
46 }
47
48 if (!empty($lastUserList))
49 {
50 $usersList = \CSocNetLogDestination::getUsers(array(
51 'id' => $lastUserList,
52 'CRM_ENTITY' => ModuleManager::isModuleInstalled('crm')
53 ));
54
55 foreach($usersList as $key => $user)
56 {
57 if (
58 !empty($user['isCrmEmail'])
59 && $user['isCrmEmail'] == 'Y'
60 )
61 {
62 $result['ITEMS'][$key] = $user;
63 $result["ITEMS_LAST"][] = $key;
64 }
65 }
66 }
67
68 return $result;
69 }
70
71 public function getTabList($params = array())
72 {
73 $result = array();
74 $options = (!empty($params['options']) ? $params['options'] : array());
75
76 if (
77 isset($options['addTab'])
78 && $options['addTab'] == 'Y'
79 && ModuleManager::isModuleInstalled('mail')
80 && ModuleManager::isModuleInstalled('crm')
81 )
82 {
83 $result[] = array(
84 'id' => 'crmemailusers',
85 'name' => Loc::getMessage('MAIN_UI_SELECTOR_TAB_CRM_EMAIL_USERS'),
86 'sort' => 110
87 );
88 }
89
90 return $result;
91 }
92
93 public function search($params = array())
94 {
95 $result = array(
96 'ITEMS' => array(),
97 'ADDITIONAL_INFO' => array()
98 );
99
100 $entityOptions = (!empty($params['options']) ? $params['options'] : array());
101 $requestFields = (!empty($params['requestFields']) ? $params['requestFields'] : array());
102 $commonOptions = (!empty($requestFields['options']) ? $requestFields['options'] : array());
103
104 $search = $requestFields['searchString'];
105
106 if ($entityOptions['allowSearchCrmEmailUsers'] == 'Y')
107 {
108 $crmEntities = \CSocNetLogDestination::searchCrmEntities(array(
109 "SEARCH" => $search,
110 "NAME_TEMPLATE" => \Bitrix\Socialnetwork\Integration\Main\UISelector\Users::getNameTemplate($commonOptions['userNameTemplate'])
111 ));
112 foreach($crmEntities as $crmEntity)
113 {
114 $crmEntity['id'] = 'UE'.$crmEntity['email'];
115 $result["ITEMS"][$crmEntity['id']] = $crmEntity;
116 }
117 }
118
119 return $result;
120 }
121
122 public function getItemName($itemCode = '')
123 {
124 return \Bitrix\Socialnetwork\Integration\Main\UISelector\Users::getUserName($itemCode);
125 }
126}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getNameTemplate($requestNameTemplate='')
Definition users.php:11