23 !isset($params[
"USER_ID"])
24 || intval($params[
"USER_ID"]) <= 0
31 $siteId = (!empty($params[
"SITE_ID"]) ? $params[
"SITE_ID"] : SITE_ID);
32 $userId = intval($params[
"USER_ID"]);
33 $groupId = (!empty($params[
"GROUP_ID"]) ? $params[
"GROUP_ID"] :
false);
35 $cacheIdKeysList = array(
37 "USE_SOCNET" => (isset($params[
"USE_SOCNET"]) && $params[
"USE_SOCNET"] ==
"Y" ?
"Y" :
false),
38 "GROUP_ID" => $groupId,
39 "GROUP_SITE_ID" => $siteId,
40 "OWNER_ID" => $userId,
44 $cacheId =
'blog_post_blog_'.md5(serialize($cacheIdKeysList));
45 $cacheDir =
'/blog/form/blog/';
47 $cache = new \CPHPCache;
48 if($cache->initCache($cacheTtl, $cacheId, $cacheDir))
50 $result = $cache->getVars();
54 $cache->startDataCache();
60 "GROUP_ID" => $groupId,
61 "GROUP_SITE_ID" => $siteId,
66 isset($params[
"USE_SOCNET"])
67 && $params[
"USE_SOCNET"] ==
"Y"
70 $blogFilter[
"USE_SOCNET"] =
"Y";
73 $res = \CBlog::getList([], $blogFilter);
74 $result = $res->fetch();
82 $ideaBlogGroupIdList = array();
85 $res = \CSite::getList(
"sort",
"desc", Array(
"ACTIVE" =>
"Y"));
86 while ($site = $res->fetch())
88 $val = Config\Option::get(
"idea",
"blog_group_id",
false, $site[
"LID"]);
91 $ideaBlogGroupIdList[] = $val;
96 if (empty($ideaBlogGroupIdList))
98 $result = \CBlog::getByOwnerID($userId);
102 $blogGroupIdList = array();
103 $res = \CBlogGroup::getList(array(), array(),
false,
false, array(
"ID"));
104 while($blogGroup = $res->fetch())
106 if (!in_array($blogGroup[
"ID"], $ideaBlogGroupIdList))
108 $blogGroupIdList[] = $blogGroup[
"ID"];
112 $result = \CBlog::getByOwnerID($userId, $blogGroupIdList);
116 $cache->endDataCache($result);
122 && isset($params[
"CREATE"])
123 && $params[
"CREATE"] ==
"Y"
126 $result = \Bitrix\Socialnetwork\ComponentHelper::createUserBlog(array(
127 "BLOG_GROUP_ID" => $groupId,
128 "USER_ID" => $userId,