Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
userwelltory.php
1<?php
9
12
14{
15 public static function getAccess(array $fields = [])
16 {
17 $userId = (
18 isset($fields['userId'])
19 ? intval($fields['userId'])
20 : 0
21 );
22
23 if ($userId <= 0)
24 {
25 return false;
26 }
27
28 $value = \CUserOptions::getOption(
29 'socialnetwork',
30 self::getAccessOptionName(),
31 'N',
32 $userId
33 );
34
35 return ($value == 'Y' ? 'Y' : 'N');
36 }
37
38 public static function setAccess(array $fields = [])
39 {
40
41 $userId = (
42 isset($fields['userId'])
43 ? intval($fields['userId'])
44 : 0
45 );
46
47 $value = (
48 isset($fields['value'])
49 && $fields['value'] == 'Y'
50 ? 'Y'
51 : 'N'
52 );
53
54 return (\CUserOptions::setOption(
55 'socialnetwork',
56 self::getAccessOptionName(),
57 $value,
58 false,
59 $userId
60 )
61 ? $value
62 : false
63 );
64 }
65
66 public static function getHistoricData(array $fields = [])
67 {
68 $result = [];
69
70 $userId = (
71 isset($fields['userId'])
72 ? intval($fields['userId'])
73 : 0
74 );
75
76 $limit = (
77 isset($fields['limit'])
78 ? intval($fields['limit'])
79 : 1
80 );
81
82 $intranetInstalled = Loader::includeModule('intranet');
83
84 $res = UserWelltoryTable::getList([
85 'filter' => [
86 '=USER_ID' => $userId
87 ],
88 'order' => [
89 'DATE_MEASURE' => 'desc'
90 ],
91 'select' => [ 'ID', 'DATE_MEASURE', 'STRESS', 'STRESS_TYPE', 'STRESS_COMMENT', 'HASH' ],
92 'limit' => $limit
93 ]);
94 while ($dataFields = $res->fetch())
95 {
96 $item = [
97 'id' => $dataFields['ID'],
98 'date' => $dataFields['DATE_MEASURE'],
99 'value' => intval($dataFields['STRESS']),
100 'type' => ($dataFields['STRESS_TYPE'] <> '' ? $dataFields['STRESS_TYPE'] : ''),
101 'typeDescription' => ($intranetInstalled ? : ''),
102 'comment' => ($dataFields['STRESS_COMMENT'] <> '' ? $dataFields['STRESS_COMMENT'] : ''),
103 'hash' => ($dataFields['HASH'] <> '' ? $dataFields['HASH'] : '')
104 ];
105 $item['typeDescription'] = ($intranetInstalled ? \Bitrix\Intranet\Component\UserProfile\StressLevel::getTypeDescription($item['type'], $item['value']) : '');
106 $result[] = $item;
107 }
108
109 return $result;
110 }
111
112 private static function getAccessOptionName()
113 {
114 return "welltory_access";
115 }
116}
static setAccess(array $fields=[])
static getHistoricData(array $fields=[])
static getAccess(array $fields=[])