1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
important.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Socialnetwork\Controller\Livefeed\BlogPost
;
4
5
use
Bitrix\Main\Loader
;
6
use
Bitrix\Main\Error
;
7
use
Bitrix\Main\Localization\Loc
;
8
use
Bitrix\Main\ModuleManager
;
9
use
Bitrix\Socialnetwork\Controller\Base
;
10
11
class
Important
extends
Base
12
{
13
public
function
getUsersAction
(
array
$params
= [])
14
{
15
global
$CACHE_MANAGER
;
16
17
$result
= [
18
'post_id'
=>
$params
[
'POST_ID'
],
19
'items'
=> [],
20
'StatusPage'
=>
"done"
,
21
'RecordCount'
=> 0
22
];
23
24
$pageSize
= 10;
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);
32
33
if
($postId <= 0)
34
{
35
$this->
addError
(
new
Error
(Loc::getMessage(
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_IMPORTANT_POST_ID_EMPTY'
),
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_IMPORTANT_POST_ID_EMPTY'
));
36
return
null
;
37
}
38
39
$cacheTime = ($pageNumber >= 2 ? 0 : 600);
40
41
$cache = new \CPHPCache();
42
$cacheId =
'blog_post_param_'
.serialize([
43
$pageSize
,
44
$postId,
45
$propertyName,
46
$pageNumber,
47
$propertyValue
,
48
$nameTemplate,
49
$pathToUser,
50
$avatarSize
51
]);
52
53
$cachePath =
$CACHE_MANAGER
->getCompCachePath(\
CComponentEngine::makeComponentPath
(
'socialnetwork.blog.blog'
)).
'/'
.$postId;
54
55
$result
= (
56
$cacheTime > 0
57
&& $cache->initCache($cacheTime, $cacheId, $cachePath)
58
? $cache->getVars()
59
: []
60
);
61
62
if
(
63
(
64
!is_array(
$result
)
65
|| empty(
$result
)
66
)
67
&& Loader::includeModule(
'blog'
)
68
)
69
{
70
$mailInstalled = ModuleManager::isModuleInstalled(
'mail'
);
71
$extranetInstalled = ModuleManager::isModuleInstalled(
'extranet'
);
72
$userIdList = [];
73
74
$res
= \CBlogUserOptions::getList(
75
[
76
'RANK'
=>
'DESC'
,
77
'OWNER_ID'
=> $this->getCurrentUser()->getId()
78
],
79
[
80
'POST_ID'
=> $postId,
81
'NAME'
=> $propertyName,
82
'VALUE'
=>
$propertyValue
,
83
'USER_ACTIVE'
=>
'Y'
84
],
85
[
86
'iNumPage'
=> $pageNumber,
87
'bDescPageNumbering'
=>
false
,
88
'nPageSize'
=>
$pageSize
,
89
'bShowAll'
=>
false
,
90
'SELECT'
=> [
'USER_ID'
,
'USER_NAME'
,
'USER_LAST_NAME'
,
'USER_SECOND_NAME'
,
'USER_LOGIN'
,
'USER_PERSONAL_PHOTO'
]
91
]
92
);
93
94
$result
[
'items'
] = [];
95
if
(
$res
&& ($userOptionFields =
$res
->fetch()))
96
{
97
$result
[
'StatusPage'
] = (
98
(
99
$res
->NavPageNomer >=
$res
->NavPageCount
100
||
$pageSize
>
$res
->NavRecordCount
101
)
102
?
'done'
103
:
'continue'
104
);
105
$result
[
'RecordCount'
] =
$res
->NavRecordCount;
106
if
($pageNumber <= $res->NavPageCount)
107
{
108
do
{
109
$userFields = [
110
'ID'
=> $userOptionFields[
'USER_ID'
],
111
'PHOTO'
=>
''
,
112
'PHOTO_SRC'
=>
''
,
113
'FULL_NAME'
=> \CUser::formatName(
114
$nameTemplate,
115
[
116
'NAME'
=> $userOptionFields[
'USER_NAME'
],
117
'LAST_NAME'
=> $userOptionFields[
'USER_LAST_NAME'
],
118
'SECOND_NAME'
=> $userOptionFields[
'USER_SECOND_NAME'
],
119
'LOGIN'
=> $userOptionFields[
'USER_LOGIN'
]
120
]
121
),
122
'URL'
=> \CUtil::jsEscape(
123
\
CComponentEngine::makePathFromTemplate
(
124
$pathToUser,
125
[
126
'UID'
=> $userOptionFields[
'USER_ID'
],
127
'user_id'
=> $userOptionFields[
'USER_ID'
],
128
'USER_ID'
=> $userOptionFields[
'USER_ID'
]
129
]
130
)
131
),
132
'TYPE'
=>
''
133
];
134
if
(array_key_exists(
'USER_PERSONAL_PHOTO'
, $userOptionFields))
135
{
136
$fileFields = \CFile::resizeImageGet(
137
$userOptionFields[
'USER_PERSONAL_PHOTO'
],
138
[
'width'
=> $avatarSize,
'height'
=> $avatarSize ],
139
BX_RESIZE_IMAGE_EXACT
,
140
false
,
141
false
,
142
true
143
);
144
$userFields[
'PHOTO_SRC'
] = ($fileFields[
'src'
] ??
''
);
145
$userFields[
"PHOTO"
] = \CFile::showImage(
146
($fileFields[
'src'
] ??
''
),
147
21,
148
21,
149
'border=0'
150
);
151
}
152
153
$result
[
'items'
][$userFields[
'ID'
]] = $userFields;
154
$userIdList[] = $userFields[
'ID'
];
155
}
while
($userOptionFields =
$res
->fetch());
156
157
if
(
158
!empty($userIdList)
159
&& ($mailInstalled || $extranetInstalled)
160
)
161
{
162
$select
= [];
163
if
($mailInstalled)
164
{
165
$select
[
"FIELDS"
] = [
'ID'
,
'EXTERNAL_AUTH_ID'
];
166
}
167
if
($extranetInstalled)
168
{
169
$select
[
"SELECT"
] = [
'UF_DEPARTMENT'
];
170
}
171
172
$res
= \CUser::getList(
173
"ID"
,
174
"ASC"
,
175
[
'ID'
=> implode(
"|"
, $userIdList) ],
176
$select
177
);
178
while
($userFields =
$res
->fetch())
179
{
180
if
(
181
$mailInstalled
182
&& $userFields[
'EXTERNAL_AUTH_ID'
] ==
'email'
183
)
184
{
185
$result
[
'items'
][$userFields[
'ID'
]][
'TYPE'
] =
'mail'
;
186
}
187
elseif
(
188
$extranetInstalled
189
&& (
190
empty($userFields[
'UF_DEPARTMENT'
])
191
|| intval($userFields[
'UF_DEPARTMENT'
][0]) <= 0
192
)
193
)
194
{
195
$result
[
'items'
][$userFields[
'ID'
]][
'TYPE'
] =
'extranet'
;
196
}
197
}
198
}
199
}
200
}
201
}
202
203
return
$result
;
204
}
205
206
public
function
voteAction
(
array
$params
= [])
207
{
208
global
$CACHE_MANAGER
;
209
210
$currentUserId = $this->getCurrentUser()->getId();
211
$postId = (isset(
$params
[
'POST_ID'
]) && intval(
$params
[
'POST_ID'
]) > 0 ? intval(
$params
[
'POST_ID'
]) : 0);
212
213
if
($postId <= 0)
214
{
215
$this->
addError
(
new
Error
(Loc::getMessage(
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_IMPORTANT_POST_ID_EMPTY'
),
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_IMPORTANT_POST_ID_EMPTY'
));
216
return
null
;
217
}
218
219
if
(
220
!$currentUserId
221
|| !\CSocNetFeatures::isActiveFeature(
SONET_ENTITY_USER
, $currentUserId,
'blog'
)
222
)
223
{
224
$this->
addError
(
new
Error
(Loc::getMessage(
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_IMPORTANT_NO_READ_PERMS'
),
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_IMPORTANT_NO_READ_PERMS'
));
225
return
null
;
226
}
227
228
if
(!Loader::includeModule(
'blog'
))
229
{
230
$this->
addError
(
new
Error
(
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_IMPORTANT_NO_BLOG_MODULE'
,
'SONET_CONTROLLER_LIVEFEED_BLOGPOST_IMPORTANT_NO_BLOG_MODULE'
));
231
return
null
;
232
}
233
234
\CBlogUserOptions::setOption($postId,
'BLOG_POST_IMPRTNT'
,
'Y'
, $currentUserId);
235
236
if
(defined(
'BX_COMP_MANAGED_CACHE'
))
237
{
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);
241
}
242
243
$options
= [
244
[
245
'post_id'
=> $postId,
246
'name'
=>
'BLOG_POST_IMPRTNT'
,
247
'value'
=>
'Y'
248
]
249
];
250
251
$res
= getModuleEvents(
'socialnetwork'
,
'OnAfterCBlogUserOptionsSet'
);
252
while
($eventFields =
$res
->fetch())
253
{
254
executeModuleEventEx($eventFields, [
$options
,
''
,
''
]);
255
}
256
257
return
[
258
'success'
=>
'Y'
259
];
260
}
261
}
262
Bitrix\Main\Engine\ActionFilter\Base
Определения
base.php:15
Bitrix\Main\Engine\ActionFilter\Base\addError
addError(Error $error)
Определения
base.php:80
Bitrix\Main\Error
Определения
error.php:15
Bitrix\Main\Loader
Определения
loader.php:13
Bitrix\Main\Localization\Loc
Определения
loc.php:12
Bitrix\Main\ModuleManager
Определения
modulemanager.php:6
Bitrix\Socialnetwork\Controller\Livefeed\BlogPost\Important
Определения
important.php:12
Bitrix\Socialnetwork\Controller\Livefeed\BlogPost\Important\getUsersAction
getUsersAction(array $params=[])
Определения
important.php:13
Bitrix\Socialnetwork\Controller\Livefeed\BlogPost\Important\voteAction
voteAction(array $params=[])
Определения
important.php:206
CComponentEngine\makeComponentPath
static makeComponentPath($componentName)
Определения
component_engine.php:81
CComponentEngine\makePathFromTemplate
static makePathFromTemplate($template, $arParams=array())
Определения
component_engine.php:355
$CACHE_MANAGER
global $CACHE_MANAGER
Определения
clear_component_cache.php:7
$options
$options
Определения
commerceml2.php:49
$propertyValue
</td ></tr ></table ></td ></tr ><?endif?><? $propertyIndex=0;foreach( $arGlobalProperties as $propertyCode=> $propertyValue
Определения
file_new.php:729
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$res
$res
Определения
filter_act.php:7
$result
$result
Определения
get_property_values.php:14
$select
$select
Определения
iblock_catalog_list.php:194
$pageSize
$pageSize
Определения
csv_new_run.php:34
BX_RESIZE_IMAGE_EXACT
const BX_RESIZE_IMAGE_EXACT
Определения
constants.php:12
SITE_DIR
const SITE_DIR(!defined('LANG'))
Определения
include.php:72
Bitrix\Socialnetwork\Controller\Livefeed\BlogPost
Определения
important.php:3
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$params
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения
template.php:799
SONET_ENTITY_USER
const SONET_ENTITY_USER
Определения
include.php:118
bitrix
modules
socialnetwork
lib
controller
livefeed
blogpost
important.php
Создано системой
1.14.0