- Модуль: disk
- Путь к файлу: ~/bitrix/modules/disk/lib/uf/blogpostconnector.php
- Класс: BitrixDiskUfBlogPostConnector
- Вызов: BlogPostConnector::canRead
public function canRead($userId)
{
if($this->canRead !== null)
{
return $this->canRead;
}
if(!Loader::includeModule('socialnetwork'))
{
return false;
}
$cacheTtl = 2592000;
$cacheId = 'blog_post_socnet_general_' . $this->entityId . '_' . LANGUAGE_ID. '_diskconnector';
$timezoneOffset = CTimeZone::getOffset();
if($timezoneOffset != 0)
{
$cacheId .= "_" . $timezoneOffset;
}
$cacheDir = '/blog/socnet_post/gen/' . intval($this->entityId / 100) . '/' . $this->entityId;
$cache = new CPHPCache;
if($cache->initCache($cacheTtl, $cacheId, $cacheDir))
{
$post = $cache->getVars();
}
else
{
$cache->startDataCache();
$queryPost = CBlogPost::getList(array(), array("ID" => $this->entityId), false, false, array(
"ID",
"BLOG_ID",
"PUBLISH_STATUS",
"TITLE",
"AUTHOR_ID",
"ENABLE_COMMENTS",
"NUM_COMMENTS",
"VIEWS",
"CODE",
"MICRO",
"DETAIL_TEXT",
"DATE_PUBLISH",
"CATEGORY_ID",
"HAS_SOCNET_ALL",
"HAS_TAGS",
"HAS_IMAGES",
"HAS_PROPS",
"HAS_COMMENT_IMAGES"
));
$post = $queryPost->fetch();
if (!empty($post['DETAIL_TEXT']))
{
$post['DETAIL_TEXT'] = BitrixMainTextEmoji::decode($post['DETAIL_TEXT']);
}
$cache->endDataCache($post);
}
if(!$post)
{
$this->canRead = false;
return false;
}
$this->canRead = CBlogPost::getSocNetPostPerms($this->entityId, true, $userId, $post["AUTHOR_ID"]) >= BLOG_PERMS_READ;
if (!$this->canRead)
{
$perms = CBlogPost::getSocNetPerms($this->entityId);
$this->canRead = (
is_array($perms)
&& !empty($perms['UP'])
);
if(
!$this->canRead
&& !empty($perms['SG'])
)
{
$sonetGroupsIdList = array_unique(array_keys($perms['SG']));
if (
!empty($sonetGroupsIdList)
&& Loader::includeModule('socialnetwork')
)
{
$res = WorkgroupTable::getList([
'filter' => [
'@ID' => $sonetGroupsIdList,
'=LANDING' => 'Y',
'=ACTIVE' => 'Y'
],
'limit' => 1
]);
if ($res->fetch())
{
$this->canRead = true;
}
}
}
}
return $this->canRead;
}