2namespace Bitrix\Report;
4use Bitrix\Report\Internals\SharingTable;
8use CSocNetLogDestination;
10use Bitrix\Main\ErrorCollection;
46 if(!empty($listNewEntity) && is_array($listNewEntity))
48 $newEntityData =
array();
49 foreach($listNewEntity as
$entityId => $entityData)
51 switch($entityData[
'right'])
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);
104 return $this->errorCollection->toArray();
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();
130 'select' =>
array(
'ID',
'ENTITY',
'RIGHTS'),
135 $entitySharing[] =
array(
136 'ENTITY' =>
$data[
'ENTITY'],
137 'RIGHTS' =>
$data[
'RIGHTS'],
140 $cache->endDataCache($entitySharing);
143 return $entitySharing;
156 $users = \CUser::getList(
'id',
'asc',
158 array(
'FIELDS' =>
array(
'ID',
'PERSONAL_PHOTO',
'NAME',
'LAST_NAME'))
160 $user = $users->fetch();
164 $userData[
'name'] = \CUser::formatName(\CSite::getNameFormat(
false), $user,
false,
false);
165 $userData[
'avatar'] = $avatar ? $avatar[
'src'] :
'/bitrix/js/report/css/images/default_avatar.png';
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)
194 case self::CODE_USER:
195 return array(self::TYPE_USER, $id);
196 case self::CODE_GROUP:
197 return array(self::TYPE_GROUP, $id);
198 case self::CODE_SOCNET_GROUP:
199 return array(self::TYPE_SOCNET_GROUP, $id);
200 case self::CODE_DEPARTMENT:
201 return array(self::TYPE_DEPARTMENT, $id);
217 if(
$type == self::TYPE_USER)
227 if(Loader::includeModule(
'socialnetwork'))
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';
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'))
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"))
317 foreach($destination[
'SONETGROUPS'] as
$val)
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";
338 $destination[
'SELECTED'][
$code] =
"groups";
342 $destination[
'SELECTED'][
$code] =
"sonetgroups";
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));
386 'select' =>
array(
'ID'),
390 SharingTable::delete(
$data[
'ID']);
395 $listSharingRow =
array();
397 'filter'=>
array(
'=REPORT_ID' => $this->reportId),
400 $listSharingRow[] =
$data;
402 return $listSharingRow;
407 foreach($listData as
$data)
410 'REPORT_ID' =>
$data[
'REPORT_ID'],
411 'ENTITY' =>
$data[
'ENTITY'],
412 'RIGHTS' =>
$data[
'RIGHTS'],
425 foreach($listData as
$data)
428 'RIGHTS' =>
$data[
'RIGHTS']
441 foreach($listData as
$data)
454 $userPage = \COption::getOptionString(
'socialnetwork',
'user_page',
false,
SITE_ID);
457 $userPage =
SITE_DIR.
'company/personal/';
459 return $userPage.
'user/'.
$userId.
'/';
464 return \CFile::resizeImageGet($imageId,
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static onReportDelete($reportId)
addToManyEntity(array $listData)
changeSharing($listNewEntity)
static getUserData($userId)
static getUserUrl($userId)
static getSocNetDestination($userId, $selected=array())
static getEntityOfSharing($reportId)
const ERROR_SHARING_DELETE
const ERROR_SHARING_UPDATE
static parseEntityValue($entity)
deleteManyEntity(array $listData)
updateManyEntity(array $listData)
static getTypeData($type, $id)
static getImage($imageId)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
while($arParentIBlockProperty=$dbParentIBlockProperty->Fetch()) $errorMessage
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
const BX_RESIZE_IMAGE_EXACT
const SITE_DIR(!defined('LANG'))
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)