15 global $CACHE_MANAGER;
18 'post_id' => $params[
'POST_ID'],
20 'StatusPage' =>
"done",
25 $postId = (isset($params[
'POST_ID']) && (int)$params[
'POST_ID'] > 0 ? (
int)$params[
'POST_ID'] : 0);
26 $propertyName = (isset($params[
'NAME']) && $params[
'NAME'] <>
'' ? trim($params[
'NAME']) :
'BLOG_POST_IMPRTNT');
27 $propertyValue = (isset($params[
'VALUE']) && $params[
'VALUE'] <>
'' ? trim($params[
'VALUE']) :
'Y');
28 $pathToUser = (isset($params[
'PATH_TO_USER']) && $params[
'PATH_TO_USER'] <>
'' ? $params[
'PATH_TO_USER'] : SITE_DIR.
'company/personal/user/#USER_ID#/');
29 $nameTemplate = (isset($params[
'NAME_TEMPLATE']) && $params[
'NAME_TEMPLATE'] <>
'' ? $params[
'NAME_TEMPLATE'] : \CSite::getNameFormat(
false));
30 $pageNumber = (isset($params[
'PAGE_NUMBER']) && intval($params[
'PAGE_NUMBER']) > 0 ? intval($params[
'PAGE_NUMBER']) : 1);
31 $avatarSize = (isset($params[
'AVATAR_SIZE']) && (int)$params[
'AVATAR_SIZE'] > 0 ? (
int)$params[
'AVATAR_SIZE'] : 21);
35 $this->
addError(
new Error(
Loc::getMessage(
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_IMPORTANT_POST_ID_EMPTY'),
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_IMPORTANT_POST_ID_EMPTY'));
39 $cacheTime = ($pageNumber >= 2 ? 0 : 600);
41 $cache = new \CPHPCache();
42 $cacheId =
'blog_post_param_'.serialize([
53 $cachePath = $CACHE_MANAGER->getCompCachePath(\CComponentEngine::makeComponentPath(
'socialnetwork.blog.blog')).
'/'.$postId;
57 && $cache->initCache($cacheTime, $cacheId, $cachePath)
67 && Loader::includeModule(
'blog')
70 $mailInstalled = ModuleManager::isModuleInstalled(
'mail');
71 $extranetInstalled = ModuleManager::isModuleInstalled(
'extranet');
74 $res = \CBlogUserOptions::getList(
81 'NAME' => $propertyName,
82 'VALUE' => $propertyValue,
86 'iNumPage' => $pageNumber,
87 'bDescPageNumbering' =>
false,
88 'nPageSize' => $pageSize,
90 'SELECT' => [
'USER_ID',
'USER_NAME',
'USER_LAST_NAME',
'USER_SECOND_NAME',
'USER_LOGIN',
'USER_PERSONAL_PHOTO' ]
94 $result[
'items'] = [];
95 if ($res && ($userOptionFields = $res->fetch()))
97 $result[
'StatusPage'] = (
99 $res->NavPageNomer >= $res->NavPageCount
100 || $pageSize > $res->NavRecordCount
105 $result[
'RecordCount'] = $res->NavRecordCount;
106 if ($pageNumber <= $res->NavPageCount)
110 'ID' => $userOptionFields[
'USER_ID'],
113 'FULL_NAME' => \CUser::formatName(
116 'NAME' => $userOptionFields[
'USER_NAME'],
117 'LAST_NAME' => $userOptionFields[
'USER_LAST_NAME'],
118 'SECOND_NAME' => $userOptionFields[
'USER_SECOND_NAME'],
119 'LOGIN' => $userOptionFields[
'USER_LOGIN']
122 'URL' => \CUtil::jsEscape(
123 \CComponentEngine::makePathFromTemplate(
126 'UID' => $userOptionFields[
'USER_ID'],
127 'user_id' => $userOptionFields[
'USER_ID'],
128 'USER_ID' => $userOptionFields[
'USER_ID']
134 if (array_key_exists(
'USER_PERSONAL_PHOTO', $userOptionFields))
136 $fileFields = \CFile::resizeImageGet(
137 $userOptionFields[
'USER_PERSONAL_PHOTO'],
138 [
'width' => $avatarSize,
'height' => $avatarSize ],
139 BX_RESIZE_IMAGE_EXACT,
144 $userFields[
'PHOTO_SRC'] = ($fileFields[
'src'] ??
'');
145 $userFields[
"PHOTO"] = \CFile::showImage(
146 ($fileFields[
'src'] ??
''),
153 $result[
'items'][$userFields[
'ID']] = $userFields;
154 $userIdList[] = $userFields[
'ID'];
155 }
while ($userOptionFields = $res->fetch());
159 && ($mailInstalled || $extranetInstalled)
165 $select[
"FIELDS"] = [
'ID',
'EXTERNAL_AUTH_ID' ];
167 if ($extranetInstalled)
169 $select[
"SELECT"] = [
'UF_DEPARTMENT' ];
172 $res = \CUser::getList(
175 [
'ID' => implode(
"|", $userIdList) ],
178 while($userFields = $res->fetch())
182 && $userFields[
'EXTERNAL_AUTH_ID'] ==
'email'
185 $result[
'items'][$userFields[
'ID']][
'TYPE'] =
'mail';
190 empty($userFields[
'UF_DEPARTMENT'])
191 || intval($userFields[
'UF_DEPARTMENT'][0]) <= 0
195 $result[
'items'][$userFields[
'ID']][
'TYPE'] =
'extranet';
208 global $CACHE_MANAGER;
211 $postId = (isset($params[
'POST_ID']) && intval($params[
'POST_ID']) > 0 ? intval($params[
'POST_ID']) : 0);
215 $this->
addError(
new Error(
Loc::getMessage(
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_IMPORTANT_POST_ID_EMPTY'),
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_IMPORTANT_POST_ID_EMPTY'));
221 || !\CSocNetFeatures::isActiveFeature(SONET_ENTITY_USER, $currentUserId,
'blog')
224 $this->
addError(
new Error(
Loc::getMessage(
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_IMPORTANT_NO_READ_PERMS'),
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_IMPORTANT_NO_READ_PERMS'));
228 if (!Loader::includeModule(
'blog'))
230 $this->
addError(
new Error(
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_IMPORTANT_NO_BLOG_MODULE',
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_IMPORTANT_NO_BLOG_MODULE'));
234 \CBlogUserOptions::setOption($postId,
'BLOG_POST_IMPRTNT',
'Y', $currentUserId);
236 if (defined(
'BX_COMP_MANAGED_CACHE'))
238 $CACHE_MANAGER->clearByTag(
'BLOG_POST_IMPRTNT'.$postId);
239 $CACHE_MANAGER->clearByTag(
'BLOG_POST_IMPRTNT'.$postId.
"_".$currentUserId);
240 $CACHE_MANAGER->clearByTag(
'BLOG_POST_IMPRTNT'.
"_USER_".$currentUserId);
245 'post_id' => $postId,
246 'name' =>
'BLOG_POST_IMPRTNT',
251 $res = getModuleEvents(
'socialnetwork',
'OnAfterCBlogUserOptionsSet');
252 while ($eventFields = $res->fetch())
254 executeModuleEventEx($eventFields, [ $options,
'',
'' ]);