Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
contentview.php
1
<?php
2
3
namespace
Bitrix\Socialnetwork\Controller
;
4
5
use
Bitrix\Main\Loader
;
6
use
Bitrix\Main\Error
;
7
use
Bitrix\Main\Engine\ActionFilter
;
8
use
Bitrix\Socialnetwork\Item\UserContentView
;
9
10
class
ContentView
extends
Base
11
{
12
public
function
configureActions
(): array
13
{
14
$configureActions = parent::configureActions();
15
$configureActions[
'set'
] = [
16
'+prefilters'
=> [
17
new
ActionFilter\CloseSession(),
18
]
19
];
20
21
return
$configureActions;
22
}
23
24
public
function
setAction
(array $params = []): ?array
25
{
26
global $USER;
27
28
$xmlIdList = (
29
isset($params[
"viewXMLIdList"
])
30
&& is_array($params[
"viewXMLIdList"
])
31
? $params[
"viewXMLIdList"
]
32
: []
33
);
34
35
$context = ($params[
'context'
] ??
''
);
36
37
if
(!Loader::includeModule(
'socialnetwork'
))
38
{
39
$this->
addError
(
new
Error
(
'Cannot include Socialnetwork module'
,
'SONET_CONTROLLER_CONTENTVIEW_NO_SOCIALNETWORK_MODULE'
));
40
return
null
;
41
}
42
43
$signer = new \Bitrix\Main\Engine\ActionFilter\Service\Token($USER->getId());
44
45
foreach
($xmlIdList as $key => $item)
46
{
47
if
(empty($item[
'xmlId'
]))
48
{
49
unset($xmlIdList[$key]);
50
continue
;
51
}
52
53
if
(!empty($item[
'signedKey'
]))
54
{
55
try
56
{
57
if
($signer->unsign($item[
'signedKey'
], $item[
'xmlId'
]) === $item[
'xmlId'
])
58
{
59
$xmlIdList[$key][
'checkAccess'
] =
false
;
60
}
61
else
62
{
63
unset($xmlIdList[$key]);
64
}
65
}
66
catch
(\
Exception
$e)
67
{
68
$xmlIdList[$key][
'checkAccess'
] =
true
;
69
}
70
}
71
else
72
{
73
$xmlIdList[$key][
'checkAccess'
] =
true
;
74
}
75
}
76
77
UserContentView::set([
78
'xmlIdList'
=> $xmlIdList,
79
'context'
=> $context,
80
'userId'
=> $this->getCurrentUser()->getId(),
81
]);
82
83
return
[
84
'SUCCESS'
=>
'Y'
85
];
86
}
87
88
public
function
getListAction
(array $params = []): ?array
89
{
90
$contentId = (
91
isset($params[
'contentId'
])
92
&& is_string($params[
'contentId'
])
93
? trim($params[
'contentId'
])
94
:
''
95
);
96
97
$page = (
98
isset($params[
'page'
])
99
&& (int)$params[
'page'
] > 0
100
? (
int
)$params[
'page'
]
101
: 1
102
);
103
104
$pathToUserProfile = (
105
isset($params[
'pathToUserProfile'
])
106
&& is_string($params[
'pathToUserProfile'
])
107
? trim($params[
'pathToUserProfile'
])
108
:
''
109
);
110
111
if
($contentId ===
''
)
112
{
113
$this->
addError
(
new
Error
(
'Empty Content ID'
,
'SONET_CONTROLLER_CONTENTVIEW_EMPTY_CONTENT_ID'
));
114
return
null
;
115
}
116
117
if
(!Loader::includeModule(
'socialnetwork'
))
118
{
119
$this->
addError
(
new
Error
(
'Cannot include Socialnetwork module'
,
'SONET_CONTROLLER_CONTENTVIEW_NO_SOCIALNETWORK_MODULE'
));
120
return
null
;
121
}
122
123
$userList = UserContentView::getUserList([
124
'contentId'
=> $contentId,
125
'page'
=> $page,
126
'pathToUserProfile'
=> $pathToUserProfile
127
]);
128
129
$result[
'items'
] = $userList[
'items'
];
130
$result[
'itemsCount'
] = count($result[
'items'
]);
131
$result[
'hiddenCount'
] = $userList[
'hiddenCount'
];
132
133
return
$result;
134
}
135
}
136
Bitrix\Im\V2\Error
Definition
Error.php:8
Bitrix\Main\DB\Exception
Definition
exception.php:11
Bitrix\Main\Engine\ActionFilter\Base
Definition
base.php:15
Bitrix\Main\Engine\ActionFilter\Base\addError
addError(Error $error)
Definition
base.php:80
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Socialnetwork\Controller\ContentView
Definition
contentview.php:11
Bitrix\Socialnetwork\Controller\ContentView\getListAction
getListAction(array $params=[])
Definition
contentview.php:88
Bitrix\Socialnetwork\Controller\ContentView\setAction
setAction(array $params=[])
Definition
contentview.php:24
Bitrix\Socialnetwork\Controller\ContentView\configureActions
configureActions()
Definition
contentview.php:12
Bitrix\Socialnetwork\Item\UserContentView
Definition
usercontentview.php:20
Bitrix\Main\Engine\ActionFilter
Definition
authentication.php:4
Bitrix\Socialnetwork\Controller
Definition
base.php:3
modules
socialnetwork
lib
controller
contentview.php
Создано системой
1.10.0