82 public static function set($params = array())
84 static $controllerUser = array();
86 $userId = (isset($params[
'userId']) ? intval($params[
'userId']) : 0);
87 $typeId = (isset($params[
'typeId']) ? trim($params[
'typeId']) :
false);
88 $entityId = (isset($params[
'entityId']) ? intval($params[
'entityId']) : 0);
89 $save = (isset($params[
'save']) ? !!$params[
'save'] :
false);
102 if (ModuleManager::isModuleInstalled(
'bitrix24'))
104 if (!isset($controllerUser[$userId]))
106 $res = UserTable::getList(array(
109 '=EXTERNAL_AUTH_ID' =>
'__controller'
111 'select' => array(
'ID')
115 $controllerUser[$userId] =
true;
119 $controllerUser[$userId] =
false;
123 if ($controllerUser[$userId])
134 $connection = \Bitrix\Main\Application::getConnection();
135 $helper = $connection->getSqlHelper();
137 $nowDate =
new SqlExpression($helper->getCurrentDateTimeFunction());
139 $insertFields = array(
140 "USER_ID" => $userId,
141 "RATING_TYPE_ID" => $typeId,
142 "RATING_ENTITY_ID" => $entityId,
143 "CONTENT_ID" => $typeId.
"-".$entityId,
144 "DATE_VIEW" => $nowDate
147 $tableName = static::getTableName();
148 list($prefix, $values) = $helper->prepareInsert($tableName, $insertFields);
150 $connection->queryExecute(
151 "INSERT INTO {$tableName} ({$prefix}) VALUES ({$values})
152 ON DUPLICATE KEY UPDATE DATE_VIEW = {$nowDate}"
160 'savedInDB' => $saved