46 if(!empty($listNewEntity) && is_array($listNewEntity))
48 $newEntityData = array();
49 foreach($listNewEntity as $entityId => $entityData)
51 switch($entityData[
'right'])
55 $newEntityData[$entityId][
'ENTITY'] = $entityId;
56 $newEntityData[$entityId][
'RIGHTS'] = $entityData[
'right'];
62 $overwriteSharing = $deleteSharing = $addSharing = array();
63 foreach($listSharingRow as $sharingRow)
65 if(array_key_exists($sharingRow[
'ENTITY'], $newEntityData))
67 if($newEntityData[$sharingRow[
'ENTITY']][
'RIGHTS'] != $sharingRow[
'RIGHTS'])
69 $overwriteSharing[$sharingRow[
'ENTITY']] = $newEntityData[$sharingRow[
'ENTITY']];
70 $overwriteSharing[$sharingRow[
'ENTITY']][
'ID'] = $sharingRow[
'ID'];
72 elseif($newEntityData[$sharingRow[
'ENTITY']][
'RIGHTS'] == $sharingRow[
'RIGHTS'])
74 unset($newEntityData[$sharingRow[
'ENTITY']]);
79 $deleteSharing[$sharingRow[
'ENTITY']] = $sharingRow;
82 $addSharing = array_diff_key($newEntityData, $overwriteSharing);
95 $cache =
new CPHPCache;
96 $cache->cleanDir(
'/report/sharing/'.$this->reportId);
116 $entitySharing = array();
118 $cacheTime = defined(
'BX_COMP_MANAGED_CACHE') ? 3153600 : 3600*4;
119 $cacheId =
'report-sharing-'.$reportId;
120 $cacheDir =
'/report/sharing/'.$reportId;
121 $cache =
new CPHPCache;
122 if($cache->initCache($cacheTime, $cacheId, $cacheDir))
124 $entitySharing = $cache->getVars();
128 $cache->startDataCache();
129 $result = SharingTable::getList(array(
130 'select' => array(
'ID',
'ENTITY',
'RIGHTS'),
131 'filter' => array(
'=REPORT_ID' =>
$reportId),
133 while($data = $result->fetch())
135 $entitySharing[] = array(
136 'ENTITY' => $data[
'ENTITY'],
137 'RIGHTS' => $data[
'RIGHTS'],
140 $cache->endDataCache($entitySharing);
143 return $entitySharing;
182 '%(' . self::CODE_USER .
'|' . self::CODE_SOCNET_GROUP .
'|' .
183 self::CODE_DEPARTMENT .
'){1,2}([0-9]+)%u',
187 list(, $code, $id) = $m;
188 if($code ===
null || $id ===
null)
195 return array(self::TYPE_USER, $id);
197 return array(self::TYPE_GROUP, $id);
199 return array(self::TYPE_SOCNET_GROUP, $id);
201 return array(self::TYPE_DEPARTMENT, $id);
217 if($type == self::TYPE_USER)
221 elseif($type == self::TYPE_GROUP)
225 elseif($type == self::TYPE_SOCNET_GROUP)
227 if(Loader::includeModule(
'socialnetwork'))
229 $query = \CSocNetGroup::getList(array(), array(
'ID' => $id),
230 false,
false, array(
'IMAGE_ID',
'NAME'));
231 while($group = $query->fetch())
233 $typeData[
'name'] = $group[
'NAME'];
235 $typeData[
'avatar'] = $avatar?$avatar[
'src']:
'/bitrix/js/report/css/images/default_groupe.png';
239 elseif($type == self::TYPE_DEPARTMENT)
241 if(Loader::includeModule(
'socialnetwork'))
243 $structure = \CSocNetLogDestination::getStucture();
244 if(!empty($structure[
'department'][
'DR' . $id]))
246 $typeData[
'name'] = $structure[
'department'][
'DR' . $id][
'name'];
247 $typeData[
'avatar'] =
'/bitrix/js/report/css/images/default_groupe.png';
264 if(!Loader::includeModule(
'socialnetwork'))
269 global $CACHE_MANAGER;
271 if (!is_array($selected))
276 if (method_exists(
'CSocNetLogDestination',
'getDestinationSort'))
278 $destination = array(
282 $lastDestination = CSocNetLogDestination::getDestinationSort(array(
283 "DEST_CONTEXT" =>
"REPORT_SHARE"
286 CSocNetLogDestination::fillLastDestination($lastDestination, $destination[
'LAST']);
290 $destination = array(
292 'SONETGROUPS' => CSocNetLogDestination::getLastSocnetGroup(),
293 'DEPARTMENT' => CSocNetLogDestination::getLastDepartment(),
294 'USERS' => CSocNetLogDestination::getLastUser()
299 $cacheTtl = defined(
"BX_COMP_MANAGED_CACHE") ? 3153600 : 3600*4;
300 $cacheId =
'dest_group_'.$userId;
301 $cacheDir =
'/report/dest/'.$userId;
303 $cache =
new CPHPCache;
304 if($cache->initCache($cacheTtl, $cacheId, $cacheDir))
306 $destination[
'SONETGROUPS'] = $cache->getVars();
310 $cache->startDataCache();
311 $destination[
'SONETGROUPS'] = CSocNetLogDestination::getSocnetGroup(
312 array(
'GROUP_CLOSED' =>
'N',
'features' => array(
"files", array(
"view"))));
313 if(defined(
"BX_COMP_MANAGED_CACHE"))
315 $CACHE_MANAGER->startTagCache($cacheDir);
316 $CACHE_MANAGER->registerTag(
"sonet_feature_all_G_files");
317 foreach($destination[
'SONETGROUPS'] as $val)
319 $CACHE_MANAGER->registerTag(
"sonet_features_G_".$val[
"entityId"]);
320 $CACHE_MANAGER->registerTag(
"sonet_group_".$val[
"entityId"]);
322 $CACHE_MANAGER->registerTag(
"sonet_user2group_U".$userId);
323 $CACHE_MANAGER->endTagCache();
325 $cache->endDataCache($destination[
'SONETGROUPS']);
329 $destination[
'SELECTED'] = array();
330 foreach ($selected as $ind => $code)
332 if (mb_substr($code, 0, 2) ==
'DR')
334 $destination[
'SELECTED'][$code] =
"department";
336 elseif (mb_substr($code, 0, 2) ==
'UA')
338 $destination[
'SELECTED'][$code] =
"groups";
340 elseif (mb_substr($code, 0, 2) ==
'SG')
342 $destination[
'SELECTED'][$code] =
"sonetgroups";
344 elseif (mb_substr($code, 0, 1) ==
'U')
346 $destination[
'SELECTED'][$code] =
"users";
347 $destUser[] = str_replace(
'U',
'', $code);
352 $structure = CSocNetLogDestination::getStucture();
353 $destination[
'DEPARTMENT'] = $structure[
'department'];
354 $destination[
'DEPARTMENT_RELATION'] = $structure[
'department_relation'];
355 $destination[
'DEPARTMENT_RELATION_HEAD'] = $structure[
'department_relation_head'];
357 if (Loader::includeModule(
'extranet') && !CExtranet::isIntranetUser())
359 $destination[
'EXTRANET_USER'] =
'Y';
360 $destination[
'USERS'] = CSocNetLogDestination::getExtranetUser();
364 if(is_array($destination[
'LAST'][
'USERS']))
366 foreach ($destination[
'LAST'][
'USERS'] as $value)
367 $destUser[] = str_replace(
'U',
'', $value);
370 $destination[
'EXTRANET_USER'] =
'N';
371 $destination[
'USERS'] = CSocNetLogDestination::getUsers(array(
'id' => $destUser));