Update
This commit is contained in:
@@ -188,7 +188,11 @@ class Comment extends BaseObject
|
||||
"SOURCE_ID" => $params["SOURCE_ID"] ?? 0,
|
||||
|
||||
"POST_DATE" => array_key_exists("POST_DATE", $params) ? $params["POST_DATE"] : new \Bitrix\Main\Type\DateTime(),
|
||||
"POST_MESSAGE" => trim($params["POST_MESSAGE"]),
|
||||
"POST_MESSAGE" => (
|
||||
isset($params["POST_MESSAGE"]) && is_string($params["POST_MESSAGE"])
|
||||
? trim($params["POST_MESSAGE"])
|
||||
: ''
|
||||
),
|
||||
"FILES" => $params["FILES"] ?? null,
|
||||
|
||||
"USE_SMILES" => $params["USE_SMILES"],
|
||||
|
||||
@@ -79,8 +79,8 @@ final class TaskEntity extends Entity
|
||||
if (
|
||||
Loader::includeModule("tasks")
|
||||
&& (
|
||||
\CTasksTools::isAdmin($userId)
|
||||
|| \CTasksTools::isPortalB24Admin($userId)
|
||||
\Bitrix\Tasks\Util\User::isAdmin($userId)
|
||||
|| \Bitrix\Tasks\Integration\Bitrix24\User::isAdmin($userId)
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -168,4 +168,4 @@ final class TaskEntity extends Entity
|
||||
$index["PERMISSIONS"] = self::$permissions[$taskId];
|
||||
return sizeof(self::$permissions[$taskId]) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
<?php
|
||||
namespace Bitrix\Forum;
|
||||
|
||||
use Bitrix\Main\Application;
|
||||
use Bitrix\Main\ArgumentException;
|
||||
use Bitrix\Main\DB\SqlQueryException;
|
||||
use Bitrix\Main\Entity;
|
||||
use Bitrix\Main\ObjectPropertyException;
|
||||
use Bitrix\Main\ORM\Fields\Relations\Reference;
|
||||
use Bitrix\Main\ORM\Query\Join;
|
||||
use Bitrix\Main\SystemException;
|
||||
|
||||
|
||||
/**
|
||||
@@ -32,17 +37,42 @@ class ForumStatTable extends Entity\DataManager
|
||||
public static function getMap()
|
||||
{
|
||||
return [
|
||||
new Entity\IntegerField('ID', ['autocomplete' => true]),
|
||||
new Entity\IntegerField('USER_ID', ['primary' => true]),
|
||||
new Entity\IntegerField('ID', ['primary' => true, 'autocomplete' => true]),
|
||||
new Entity\IntegerField('USER_ID'),
|
||||
new Entity\StringField('IP_ADDRESS', ['size' => 128]),
|
||||
new Entity\StringField('PHPSESSID', ['primary' => true, 'size' => 255]),
|
||||
new Entity\StringField('PHPSESSID', ['size' => 255]),
|
||||
new Entity\DatetimeField('LAST_VISIT'),
|
||||
new Entity\StringField('SITE_ID', ['size' => 2]),
|
||||
new Entity\IntegerField('FORUM_ID'),
|
||||
new Entity\IntegerField('TOPIC_ID'),
|
||||
new Entity\EnumField('SHOW_NAME', ['values' => ['Y', 'N'], 'default_value' => 'N']),
|
||||
new Entity\StringField('SHOW_NAME', ['size' => 255]),
|
||||
new Reference('USER', \Bitrix\Main\UserTable::class, Join::on('this.USER_ID', 'ref.ID')),
|
||||
new Reference('FORUM_USER', \Bitrix\Forum\UserTable::class, Join::on('this.USER_ID', 'ref.USER_ID')),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ObjectPropertyException
|
||||
* @throws SystemException
|
||||
* @throws ArgumentException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function upsert(array $fields): void
|
||||
{
|
||||
$existedRecordId = self::query()
|
||||
->where('USER_ID', $fields['USER_ID'])
|
||||
->where('PHPSESSID', $fields['PHPSESSID'])
|
||||
->setSelect(['ID'])
|
||||
->setLimit(1)
|
||||
->fetch()['ID'] ?? null;
|
||||
|
||||
if ($existedRecordId)
|
||||
{
|
||||
self::update($existedRecordId, $fields);
|
||||
}
|
||||
else
|
||||
{
|
||||
self::add($fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ use Bitrix\Main\ORM\EntityError;
|
||||
use Bitrix\Main\ORM\Event;
|
||||
use Bitrix\Main\ORM\Fields\FieldError;
|
||||
use Bitrix\Main\Result;
|
||||
use Bitrix\Main\ORM\Data\AddStrategy;
|
||||
use Bitrix\Main\Type\DateTime;
|
||||
|
||||
|
||||
@@ -57,8 +58,9 @@ Loc::loadMessages(__FILE__);
|
||||
* @method static \Bitrix\Forum\EO_User wakeUpObject($row)
|
||||
* @method static \Bitrix\Forum\EO_User_Collection wakeUpCollection($rows)
|
||||
*/
|
||||
class UserTable extends Main\Entity\DataManager
|
||||
class UserTable extends Main\ORM\Data\DataManager
|
||||
{
|
||||
use AddStrategy\Trait\MergeByDefaultTrait;
|
||||
/**
|
||||
* Returns DB table name for entity
|
||||
*
|
||||
@@ -84,7 +86,8 @@ class UserTable extends Main\Entity\DataManager
|
||||
),
|
||||
'USER_ID' => array(
|
||||
'data_type' => 'integer',
|
||||
'required' => true
|
||||
'required' => true,
|
||||
'unique' => true,
|
||||
),
|
||||
'USER' => array(
|
||||
'data_type' => 'Bitrix\Main\UserTable',
|
||||
@@ -382,7 +385,7 @@ class User implements \ArrayAccess {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setLocation(int $forumId = 0, int $topicId = 0)
|
||||
public function setLocation(int $forumId = 0, int $topicId = 0): void
|
||||
{
|
||||
global $USER;
|
||||
if (!($USER instanceof \CUser && $this->getId() === $USER->GetID()))
|
||||
@@ -390,14 +393,11 @@ class User implements \ArrayAccess {
|
||||
return;
|
||||
}
|
||||
|
||||
$connection = Main\Application::getConnection();
|
||||
$helper = $connection->getSqlHelper();
|
||||
$helper = Main\Application::getConnection()->getSqlHelper();
|
||||
|
||||
$primaryFields = [
|
||||
'USER_ID' => $this->getId(),
|
||||
'PHPSESSID' => $this->getSessId()
|
||||
];
|
||||
$fields = [
|
||||
'USER_ID' => $this->getId(),
|
||||
'PHPSESSID' => $this->getSessId(),
|
||||
'SHOW_NAME' => $this->getName(),
|
||||
'IP_ADDRESS' => Main\Service\GeoIp\Manager::getRealIp(),
|
||||
'LAST_VISIT' => new Main\DB\SqlExpression($helper->getCurrentDateTimeFunction()),
|
||||
@@ -406,21 +406,7 @@ class User implements \ArrayAccess {
|
||||
'TOPIC_ID' => $topicId,
|
||||
];
|
||||
|
||||
if ($this->getId() > 0)
|
||||
{
|
||||
$fields['PHPSESSID'] = $primaryFields['PHPSESSID'];
|
||||
}
|
||||
|
||||
$merge = $helper->prepareMerge(
|
||||
'b_forum_stat',
|
||||
array_keys($primaryFields),
|
||||
$primaryFields + $fields,
|
||||
$fields
|
||||
);
|
||||
if ($merge[0] != '')
|
||||
{
|
||||
$connection->query($merge[0]);
|
||||
}
|
||||
ForumStatTable::upsert($fields);
|
||||
}
|
||||
|
||||
public function isLocked()
|
||||
@@ -515,7 +501,7 @@ class User implements \ArrayAccess {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->data["NUM_POSTS"]++;
|
||||
$this->data["NUM_POSTS"] = empty($this->data["NUM_POSTS"]) ? 1 : $this->data["NUM_POSTS"] + 1;
|
||||
$this->data["POINTS"] = \CForumUser::GetUserPoints($this->getId(), array("INCREMENT" => $this->data["NUM_POSTS"]));
|
||||
$this->data["LAST_POST"] = $message["ID"];
|
||||
$this->save([
|
||||
@@ -785,7 +771,7 @@ class User implements \ArrayAccess {
|
||||
}
|
||||
}
|
||||
|
||||
private function save(array $fields)
|
||||
private function save(array $fields): Main\Result
|
||||
{
|
||||
$result = new Result();
|
||||
|
||||
@@ -796,7 +782,7 @@ class User implements \ArrayAccess {
|
||||
|
||||
if ($this->forumUserId > 0)
|
||||
{
|
||||
$result = User::update($this->forumUserId, $fields);
|
||||
$result = static::update($this->forumUserId, $fields);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -804,9 +790,10 @@ class User implements \ArrayAccess {
|
||||
{
|
||||
$fields['NUM_POSTS'] = 1;
|
||||
}
|
||||
$fields = ['USER_ID' => $this->getId()] + $fields + $this->data;
|
||||
unset($fields['ID']);
|
||||
$result = User::add($fields);
|
||||
$data = ['USER_ID' => $this->getId()] + $fields + $this->data;
|
||||
unset($data['ID']);
|
||||
|
||||
$result = static::add($data);
|
||||
if ($result->isSuccess())
|
||||
{
|
||||
$res = $result->getPrimary();
|
||||
@@ -817,6 +804,7 @@ class User implements \ArrayAccess {
|
||||
$this->forumUserId = $res;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user