69 public static function set($params = array())
71 $userId = (isset($params[
'userId']) ? intval($params[
'userId']) : 0);
72 $logId = (isset($params[
'logId']) ? intval($params[
'logId']) : 0);
73 $type = (isset($params[
'type']) ? $params[
'type'] :
'');
86 foreach($typeList as $type)
88 $params[
'type'] = $type;
94 if (!in_array($type, self::getTypes()))
100 $helper = $connection->getSqlHelper();
102 $insertFields = array(
103 "USER_ID" => $userId,
105 "TYPE" => $helper->forSql($type),
108 $updateFields = array(
112 isset($params[
'endDate'])
116 $insertFields[
"END_DATE"] = $params[
'endDate'];
117 $updateFields[
"END_DATE"] = $params[
'endDate'];
119 elseif (!empty($params[
'ttl']))
121 $endDate = \Bitrix\Main\Type\DateTime::createFromTimestamp(time() + self::TTL);
122 $insertFields[
"END_DATE"] = $endDate;
123 $updateFields[
"END_DATE"] = $endDate;
127 $updateFields[
"END_DATE"] =
false;
130 $merge = $helper->prepareMerge(
131 static::getTableName(),
132 array(
"USER_ID",
"LOG_ID",
"TYPE"),
139 $connection->query($merge[0]);