11 private $canRead =
null;
12 private $canEdit =
null;
13 private static $permissions = array();
14 private static $posts = array();
16 private static function getPostData(
$entityId)
18 if (array_key_exists(
$entityId, self::$posts))
21 $cacheId =
'blog_post_socnet_general_' .
$entityId .
'_' . LANGUAGE_ID .
'_voteconnector';
22 $timezoneOffset = \CTimeZone::getOffset();
23 if($timezoneOffset != 0)
25 $cacheId .=
"_" . $timezoneOffset;
29 $cache = new \CPHPCache;
30 if ($cache->initCache($cacheTtl, $cacheId, $cacheDir))
32 $post = $cache->getVars();
36 $cache->startDataCache();
37 $post = \CBlogPost::getList(array(), array(
"ID" =>
$entityId),
false,
false, array(
59 if (!empty($post[
'DETAIL_TEXT']))
61 $post[
'DETAIL_TEXT'] = \Bitrix\Main\Text\Emoji::decode($post[
'DETAIL_TEXT']);
64 $cache->endDataCache($post);
70 private function getPermission($userId)
77 $APPLICATION->getGroupRight(
"blog") >=
"W"
78 || \CSocNetUser::isCurrentUserModuleAdmin()
83 else if (!array_key_exists($this->entityId, self::$permissions))
86 $post = self::getPostData($this->entityId);
87 if ($post && $post[
"ID"] > 0)
89 $p = \CBlogPost::getSocNetPostPerms($this->entityId,
true, $userId, $post[
"AUTHOR_ID"]);
90 if ($p > BLOG_PERMS_MODERATE || ($p >= BLOG_PERMS_WRITE && $post[
"AUTHOR_ID"] == $userId))
105 $post = self::getPostData($this->entityId);
108 $data[
"TITLE"] = $post[
"TITLE"];
109 $data[
"URL"] = str_replace(
110 array(
"#user_id#",
"#post_id#"),
111 array($post[
"BLOG_OWNER_ID"], $post[
"ID"]),
112 \COption::GetOptionString(
"socialnetwork",
"userblogpost_page")
123 if ($this->entityId ===
null)
126 $this->
canRead = $this->getPermission($userId) >= BLOG_PERMS_READ;
128 return $this->canRead;
137 if ($this->entityId ===
null)
140 $this->
canEdit = $this->getPermission($userId) > BLOG_PERMS_MODERATE;
142 return $this->canEdit;
static includeModule($moduleName)
static loadMessages($file)