13 private function isCurrentUserAdmin():
bool
15 Loader::includeModule(
'socialnetwork');
17 return \CSocNetUser::isCurrentUserModuleAdmin(SITE_ID,
false);
20 public function addAction(array $fields = []): ?array
23 isset($fields[
'value'])
24 ? (int)$fields[
'value']
30 $this->
addError(
new Error(
Loc::getMessage(
'SONET_CONTROLLER_USER_STRESSLEVEL_ADD_NOSTRESS'),
'SONET_CONTROLLER_USER_STRESSLEVEL_ADD_NOSTRESS'));
35 isset($fields[
'userId'])
36 && $this->isCurrentUserAdmin()
42 !$this->isCurrentUserAdmin()
46 $this->
addError(
new Error(
Loc::getMessage(
'SONET_CONTROLLER_USER_STRESSLEVEL_NO_PERMISSIONS'),
'SONET_CONTROLLER_USER_STRESSLEVEL_NO_PERMISSIONS'));
50 Loader::includeModule(
'socialnetwork');
52 $disclaimerData = $this->getDisclaimer([
55 if (empty($disclaimerData))
57 $this->
addError(
new Error(
Loc::getMessage(
'SONET_CONTROLLER_USER_STRESSLEVEL_NO_SIGNED_DISCLAIMER'),
'SONET_CONTROLLER_USER_STRESSLEVEL_NO_SIGNED_DISCLAIMER'));
61 UserWelltoryTable::add([
64 'STRESS_TYPE' => ($fields[
'type'] ??
''),
65 'STRESS_COMMENT' => ($fields[
'comment'] ??
''),
67 'HASH' => ($fields[
'hash'] ??
'')
83 $this->
addError(
new Error(
Loc::getMessage(
'SONET_CONTROLLER_USER_STRESSLEVEL_GET_NOUSER_ID'),
'SONET_CONTROLLER_USER_STRESSLEVEL_GET_NOUSER_ID'));
97 $data = \Bitrix\Socialnetwork\Item\UserWelltory::getHistoricData([
110 && !empty($parameters[
'PATH_TO_USER_STRESSLEVEL'])
113 $url = \CComponentEngine::makePathFromTemplate($parameters[
"PATH_TO_USER_STRESSLEVEL"], array(
"user_id" =>
$userId));
115 $uri = new \Bitrix\Main\Web\Uri($url);
122 'result' => $uri->getUri()
133 return \Bitrix\Socialnetwork\Item\UserWelltory::getAccess([
141 isset($fields[
'userId'])
142 ? (int)$fields[
'userId']
147 isset($fields[
'value'])
148 && $fields[
'value'] ===
'Y'
153 return \Bitrix\Socialnetwork\Item\UserWelltory::setAccess([
161 $userId = (int)($fields[
'userId'] ?? 0);
165 $this->
addError(
new Error(
Loc::getMessage(
'SONET_CONTROLLER_USER_STRESSLEVEL_GET_NOUSER_ID'),
'SONET_CONTROLLER_USER_STRESSLEVEL_GET_NOUSER_ID'));
170 !$this->isCurrentUserAdmin()
175 $this->
addError(
new Error(
Loc::getMessage(
'SONET_CONTROLLER_USER_STRESSLEVEL_NO_PERMISSIONS'),
'SONET_CONTROLLER_USER_STRESSLEVEL_NO_PERMISSIONS'));
188 $userId = (int)($fields[
'userId'] ?? 0);
191 isset($fields[
'value'])
192 && $fields[
'value'] ===
'Y'
199 $this->
addError(
new Error(
Loc::getMessage(
'SONET_CONTROLLER_USER_STRESSLEVEL_GET_NOUSER_ID'),
'SONET_CONTROLLER_USER_STRESSLEVEL_GET_NOUSER_ID'));
204 !$this->isCurrentUserAdmin()
208 $this->
addError(
new Error(
Loc::getMessage(
'SONET_CONTROLLER_USER_STRESSLEVEL_NO_PERMISSIONS'),
'SONET_CONTROLLER_USER_STRESSLEVEL_NO_PERMISSIONS'));
222 if ($value !==
false)
224 $value = (int)$value;
228 $this->
addError(
new Error(
Loc::getMessage(
'SONET_CONTROLLER_USER_STRESSLEVEL_ADD_NOSTRESS'),
'SONET_CONTROLLER_USER_STRESSLEVEL_ADD_NOSTRESS'));
232 $result = (Loader::includeModule(
'intranet') ? \Bitrix\Intranet\Component\UserProfile\StressLevel::getValueDescription($type, $value) :
'');
235 'description' => $result
239 private function getDisclaimer(array $fields = [])
242 $userId = (int)($fields[
'userId'] ?? 0);
246 $this->
addError(
new Error(
Loc::getMessage(
'SONET_CONTROLLER_USER_STRESSLEVEL_GET_NOUSER_ID'),
'SONET_CONTROLLER_USER_STRESSLEVEL_GET_NOUSER_ID'));
250 $res = \Bitrix\Socialnetwork\UserWelltoryDisclaimerTable::getList([
257 'select' => [
'ID',
'DATE_SIGNED' ],
260 if ($disclaimerFields = $res->fetch())
262 $result = $disclaimerFields;
272 $result = $this->getDisclaimer([
280 if (\
Bitrix\Socialnetwork\UserWelltoryDisclaimerTable::add([
285 $result = $this->getDisclaimer([
297 $res = \Bitrix\Socialnetwork\UserWelltoryDisclaimerTable::getList([
304 'select' => [
'ID',
'DATE_SIGNED' ],
308 if ($disclaimerFields = $res->fetch())
310 $result = $disclaimerFields;
static getConnection($name="")
static getMessage($code, $replace=null, $language=null)