Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
handler.php
1<?php
9
14
15Loc::loadMessages(__FILE__);
16
18{
19 const ENTITY_TYPE_GROUPS = 'GROUPS';
20 const ENTITY_TYPE_USERS = 'USERS';
21 const ENTITY_TYPE_EMAILUSERS = 'EMAILUSERS';
22 const ENTITY_TYPE_CRMEMAILUSERS = 'CRMEMAILUSERS';
23 const ENTITY_TYPE_SONETGROUPS = 'SONETGROUPS';
24 const ENTITY_TYPE_PROJECTS = 'PROJECTS';
25
26 public static function isExtranetUser()
27 {
28 return (
29 Loader::includeModule('extranet')
30 && !\CExtranet::isIntranetUser()
31 );
32 }
33
34 public static function getNameTemplate($requestFields = array())
35 {
36 if (!empty($requestFields["nt"]))
37 {
38 preg_match_all("/(#NAME#)|(#LAST_NAME#)|(#SECOND_NAME#)|(#NAME_SHORT#)|(#SECOND_NAME_SHORT#)|\\s|\\,/", urldecode($requestFields["nt"]), $matches);
39 $result = implode("", $matches[0]);
40 }
41 else
42 {
43 $result = \CSite::getNameFormat(false);
44 }
45
46 return $result;
47 }
48
49 public static function OnUISelectorActionProcessAjax(Event $event)
50 {
51 $result = new EventResult(EventResult::UNDEFINED, null, 'socialnetwork');
52
53 $action = $event->getParameter('action');
54
55 $resultParams = false;
56
57 if ($action == \Bitrix\Main\UI\Selector\Actions::GET_DATA)
58 {
59 $resultParams = Entities::getData($event->getParameter('options'));
60 }
61 elseif ($action == \Bitrix\Main\UI\Selector\Actions::SEARCH)
62 {
63 $resultParams = Search::process($event->getParameter('requestFields'));
64 }
65 elseif ($action == \Bitrix\Main\UI\Selector\Actions::GET_DEPARTMENT_DATA)
66 {
67 $resultParams = Entities::getDepartmentData($event->getParameter('requestFields'));
68 }
69
70 if ($resultParams)
71 {
72 $result = new EventResult(
73 EventResult::SUCCESS,
74 array(
75 'result' => $resultParams
76 ),
77 'socialnetwork'
78 );
79 }
80
81 return $result;
82 }
83
84 public static function OnUISelectorEntitiesGetList(Event $event)
85 {
86 $itemsSelected = $event->getParameter('itemsSelected');
87
88 if (
89 empty($itemsSelected)
90 || !is_array($itemsSelected)
91 )
92 {
93 return new EventResult(EventResult::ERROR, null, 'socialnetwork');
94 }
95
96 $entities = Entities::getList(array('itemsSelected' => $itemsSelected));
97
98 return new EventResult(
99 EventResult::SUCCESS,
100 array(
101 'result' => $entities
102 ),
103 'socialnetwork'
104 );
105 }
106
107 public static function OnUISelectorGetProviderByEntityType(Event $event)
108 {
109 $result = new EventResult(EventResult::UNDEFINED, null, 'socialnetwork');
110
111 $entityType = $event->getParameter('entityType');
112
113 $provider = false;
114
115 switch($entityType)
116 {
118 $provider = new \Bitrix\Socialnetwork\Integration\Main\UISelector\Groups;
119 break;
121 $provider = new \Bitrix\Socialnetwork\Integration\Main\UISelector\Users;
122 break;
124 $provider = new \Bitrix\Socialnetwork\Integration\Main\UISelector\EmailUsers;
125 break;
127 $provider = new \Bitrix\Socialnetwork\Integration\Main\UISelector\CrmEmailUsers;
128 break;
130 $provider = new \Bitrix\Socialnetwork\Integration\Main\UISelector\SonetGroups;
131 break;
133 $provider = new \Bitrix\Socialnetwork\Integration\Main\UISelector\Projects;
134 break;
135 default:
136 $provider = false;
137 }
138
139 if ($provider)
140 {
141 $result = new EventResult(
142 EventResult::SUCCESS,
143 array(
144 'result' => $provider
145 ),
146 'socialnetwork'
147 );
148 }
149
150 return $result;
151 }
152}
getParameter($key)
Definition event.php:80
static loadMessages($file)
Definition loc.php:64