1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
finderdest.php
См. документацию.
1<?php
8
9namespace Bitrix\Main;
10
11use Bitrix\Main;
12use Bitrix\Main\Localization\Loc;
13
14Loc::loadMessages(__FILE__);
15
35{
36 /*public static function getTableName()
37 {
38 return 'b_finder_dest';
39 }*/
40
41 /*public static function getMap()
42 {
43 global $USER;
44
45 return array(
46 'USER_ID' => array(
47 'data_type' => 'integer',
48 'primary' => true
49 ),
50 new Entity\ReferenceField(
51 'USER',
52 'Bitrix\Main\UserTable',
53 array('=this.USER_ID' => 'ref.ID')
54 ),
55 'CODE' => array(
56 'data_type' => 'string',
57 'primary' => true
58 ),
59 'CODE_USER_ID' => array(
60 'data_type' => 'integer'
61 ),
62 'CODE_TYPE' => array(
63 'data_type' => 'string'
64 ),
65 new Entity\ReferenceField(
66 'CODE_USER',
67 'Bitrix\Main\UserTable',
68 array('=this.CODE_USER_ID' => 'ref.ID')
69 ),
70 new Entity\ReferenceField(
71 'CODE_USER_CURRENT',
72 'Bitrix\Main\UserTable',
73 array(
74 '=this.CODE_USER_ID' => 'ref.ID',
75 '=this.USER_ID' => new SqlExpression('?i', $USER->GetId())
76 )
77 ),
78 'CONTEXT' => array(
79 'data_type' => 'string',
80 'primary' => true
81 ),
82 'LAST_USE_DATE' => array(
83 'data_type' => 'datetime'
84 )
85 );
86 }*/
87
99 public static function merge(array $data)
100 {
101 global $USER;
102
103 $userId = (
104 isset($data['USER_ID']) && intval($data['USER_ID']) > 0
105 ? intval($data['USER_ID'])
106 : (is_object($GLOBALS['USER']) ? $USER->getId() : 0)
107 );
108
109 if ($userId <= 0 || empty($data['CODE']) || empty($data['CONTEXT']) || !is_string($data['CONTEXT']))
110 {
111 return;
112 }
113
114 if (is_array($data['CODE']))
115 {
116 $dataModified = $data;
117
118 foreach ($data['CODE'] as $code)
119 {
120 $dataModified['CODE'] = $code;
121 FinderDestTable::merge($dataModified);
122 }
123
124 return;
125 }
126
127 if (!is_string($data['CODE']))
128 {
129 return;
130 }
131
132 foreach (Main\UI\EntitySelector\Converter::getCompatEntities() as $entityId => $entity)
133 {
134 if (preg_match('/'.$entity['pattern'].'/i', $data['CODE'], $matches))
135 {
136 $itemId = $matches['itemId'];
137 $prefix = $matches['prefix'];
138
139 if (isset($entity['itemId']) && is_callable($entity['itemId']))
140 {
141 $itemId = $entity['itemId']($prefix, $itemId);
142 }
143
144 parent::merge([
145 'USER_ID' => $userId,
146 'CONTEXT' => mb_strtoupper($data['CONTEXT']),
147 'ENTITY_ID' => $entityId,
148 'ITEM_ID' => $itemId,
149 'PREFIX' => mb_strtoupper($prefix)
150 ]);
151
152 $cache = new \CPHPCache;
153 $cache->cleanDir('/sonet/log_dest_sort/'.intval($userId / 100));
154 $cache->cleanDir(\Bitrix\Main\UI\Selector\Entities::getCacheDir([
155 'userId' => $userId,
156 ]));
157
158 return;
159 }
160 }
161 }
162
171 public static function convertRights($rights, $excludeCodes = [])
172 {
173 $result = [];
174
175 if (is_array($rights))
176 {
177 foreach ($rights as $right)
178 {
179 if (
180 !in_array($right, $excludeCodes)
181 && (
182 preg_match('/^SG(\d+)$/i', $right, $matches)
183 || preg_match('/^U(\d+)$/i', $right, $matches)
184 || preg_match('/^DR(\d+)$/i', $right, $matches)
185 || preg_match('/^CRMCONTACT(\d+)$/i', $right, $matches)
186 || preg_match('/^CRMCOMPANY(\d+)$/i', $right, $matches)
187 || preg_match('/^CRMLEAD(\d+)$/i', $right, $matches)
188 || preg_match('/^CRMDEAL(\d+)$/i', $right, $matches)
189 )
190 )
191 {
192 $result[] = mb_strtoupper($right);
193 }
194 }
195
196 $result = array_unique($result);
197 }
198
199 return $result;
200 }
201
211 public static function onAfterDiskAjaxAction($sharings)
212 {
213 if (is_array($sharings))
214 {
215 $destinationCodes = [];
216 foreach ($sharings as $key => $sharing)
217 {
218 $destinationCodes[] = $sharing->getToEntity();
219 }
220
221 if (!empty($destinationCodes))
222 {
223 $destinationCodes = array_unique($destinationCodes);
225 "CONTEXT" => "DISK_SHARE",
226 "CODE" => \Bitrix\Main\FinderDestTable::convertRights($destinationCodes)
227 ]);
228 }
229 }
230 }
231
237 public static function migrateData()
238 {
239 $res = \CUserOptions::getList(
240 [],
241 [
242 "CATEGORY" => "socialnetwork",
243 "NAME" => "log_destination"
244 ]
245 );
246
247 while ($option = $res->fetch())
248 {
249 if (!empty($option["VALUE"]))
250 {
251 $optionValue = unserialize($option["VALUE"], ['allowed_classes' => false]);
252
253 if (is_array($optionValue))
254 {
255 foreach ($optionValue as $key => $val)
256 {
257 if (in_array(
258 $key,
259 ["users", "sonetgroups", "department", "companies", "contacts", "leads", "deals"]
260 ))
261 {
262 $codes = \CUtil::jsObjectToPhp($val);
263 if (is_array($codes))
264 {
266 [
267 "USER_ID" => $option["USER_ID"],
268 "CONTEXT" => "blog_post",
269 "CODE" => array_keys($codes)
270 ]
271 );
272 }
273 }
274 }
275 }
276 }
277 }
278
279 $res = \CUserOptions::getList(
280 [],
281 [
282 "CATEGORY" => "crm",
283 "NAME" => "log_destination"
284 ]
285 );
286
287 while ($option = $res->fetch())
288 {
289 if (!empty($option["VALUE"]))
290 {
291 $optionValue = unserialize($option["VALUE"], ['allowed_classes' => false]);
292
293 if (is_array($optionValue))
294 {
295 foreach ($optionValue as $key => $val)
296 {
297 $codes = explode(',', $val);
298 if (is_array($codes))
299 {
301 [
302 "USER_ID" => $option["USER_ID"],
303 "CONTEXT" => "crm_post",
304 "CODE" => $codes
305 ]
306 );
307 }
308 }
309 }
310 }
311 }
312 }
313
321 public static function getMailUserId($code)
322 {
323 $userId = [];
324 $result = [];
325
326 if (!is_array($code))
327 {
328 $code = [$code];
329 }
330
331 foreach ($code as $val)
332 {
333 if (preg_match('/^U(\d+)$/', $val, $matches))
334 {
335 $userId[] = $matches[1];
336 }
337 }
338
339 if (!empty($userId))
340 {
342 [
343 'order' => [],
344 'filter' => [
345 "ID" => $userId,
346 "=EXTERNAL_AUTH_ID" => 'email'
347 ],
348 'select' => ["ID"]
349 ]
350 );
351
352 while ($user = $res->fetch())
353 {
354 $result[] = $user["ID"];
355 }
356 }
357
358 return $result;
359 }
360
361}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static onAfterDiskAjaxAction($sharings)
Определения finderdest.php:211
static convertRights($rights, $excludeCodes=[])
Определения finderdest.php:171
static getMailUserId($code)
Определения finderdest.php:321
static migrateData()
Определения finderdest.php:237
static merge(array $data)
Определения finderdest.php:99
static getList(array $parameters=array())
Определения datamanager.php:431
$right
Определения options.php:8
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14
global $USER
Определения csv_new_run.php:40
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
$user
Определения mysql_to_pgsql.php:33
$GLOBALS['____1690880296']
Определения license.php:1
$entityId
Определения payment.php:4
if(empty($signedUserToken)) $key
Определения quickway.php:257
$option
Определения options.php:1711
$val
Определения options.php:1793
$optionValue
Определения options.php:3512
$matches
Определения index.php:22
$rights
Определения options.php:4