1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
usercontentview.php
См. документацию.
1<?php
9
10namespace Bitrix\Socialnetwork;
11
12use Bitrix\Main\Application;
13use Bitrix\Main\ArgumentException;
14use Bitrix\Main\Entity;
15use Bitrix\Main\ModuleManager;
16use Bitrix\Main\NotImplementedException;
17use Bitrix\Main\ObjectPropertyException;
18use Bitrix\Main\ORM\Data\Internal\MergeTrait;
19use Bitrix\Main\SystemException;
20use Bitrix\Main\DB\SqlExpression;
21use Bitrix\Main\UserTable;
22
50class UserContentViewTable extends Entity\DataManager
51{
52 use MergeTrait;
53
54 public static function getTableName(): string
55 {
56 return 'b_sonet_user_content_view';
57 }
58
59 public static function getMap(): array
60 {
61 return [
62 'USER_ID' => [
63 'data_type' => 'integer',
64 'primary' => true,
65 ],
66 'USER' => [
67 'data_type' => 'Bitrix\Main\UserTable',
68 'reference' => ['=this.USER_ID' => 'ref.ID'],
69 ],
70 'RATING_TYPE_ID' => [
71 'data_type' => 'string',
72 'primary' => true,
73 ],
74 'RATING_ENTITY_ID' => [
75 'data_type' => 'integer',
76 'primary' => true,
77 ],
78 'CONTENT_ID' => [
79 'data_type' => 'string',
80 ],
81 'DATE_VIEW' => [
82 'data_type' => 'datetime',
83 ],
84 ];
85 }
86
92 public static function set($params = []): array
93 {
94 static $controllerUser = [];
95
96 $userId = (isset($params['userId']) ? intval($params['userId']) : 0);
97 $typeId = (isset($params['typeId']) ? trim($params['typeId']) : false);
98 $entityId = (isset($params['entityId']) ? intval($params['entityId']) : 0);
99 $save = (isset($params['save']) ? !!$params['save'] : false);
100
101 if (
102 $userId <= 0
103 || empty($typeId)
104 || $entityId < 0
105 )
106 {
107 throw new SystemException("Invalid input data.");
108 }
109
110 $saved = false;
111
112 if (ModuleManager::isModuleInstalled('bitrix24'))
113 {
114 if (!isset($controllerUser[$userId]))
115 {
116 $res = UserTable::getList([
117 'filter' => [
118 '=ID' => $userId,
119 '=EXTERNAL_AUTH_ID' => '__controller',
120 ],
121 'select' => ['ID'],
122 ]);
123 if ($res->fetch())
124 {
125 $controllerUser[$userId] = true;
126 }
127 else
128 {
129 $controllerUser[$userId] = false;
130 }
131 }
132
133 if ($controllerUser[$userId])
134 {
135 return [
136 'success' => true,
137 'savedInDB' => false,
138 ];
139 }
140 }
141
142 if ($save)
143 {
144 $connection = Application::getConnection();
145 $helper = $connection->getSqlHelper();
146
147 $nowDate = new SqlExpression($helper->getCurrentDateTimeFunction());
148
149 $insertFields = [
150 "USER_ID" => $userId,
151 "RATING_TYPE_ID" => $typeId,
152 "RATING_ENTITY_ID" => $entityId,
153 "CONTENT_ID" => $typeId . "-" . $entityId,
154 "DATE_VIEW" => $nowDate,
155 ];
156
157 $updateFields = [
158 'DATE_VIEW' => $nowDate,
159 ];
160
161 static::merge($insertFields, $updateFields);
162 $saved = true;
163 }
164
165 return [
166 'success' => true,
167 'savedInDB' => $saved,
168 ];
169 }
170
171 public static function add(array $data)
172 {
173 throw new NotImplementedException("Use set() method of the class.");
174 }
175
176 public static function update($primary, array $data)
177 {
178 throw new NotImplementedException("Use set() method of the class.");
179 }
180}
$connection
Определения actionsdefinitions.php:38
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static add(array $data)
Определения usercontentview.php:171
static update($primary, array $data)
Определения usercontentview.php:176
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$save
Определения iblock_catalog_edit.php:365
$entityId
Определения payment.php:4
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799