fix: user model instead of array

pull/9580/head
Luciano Righetti 2024-05-31 10:03:36 +02:00
parent 45b1038a6a
commit 00645b803d
5 changed files with 14 additions and 14 deletions

View File

@ -20,7 +20,6 @@ namespace App\Controller;
use App\Lib\Tools\JsonTool;
use App\Lib\Tools\RedisTool;
use App\Model\Entity\Event;
use Cake\Controller\Controller;
use Cake\Core\Configure;
use Cake\Event\EventInterface;
@ -760,14 +759,14 @@ class AppController extends Controller
/**
* Returns true if user can publish the given event.
*
* @param Event $event
* @param array $event
* @param array|null $user If empty, currently logged user will be used
* @return bool
*/
protected function canPublishEvent(Event $event, $user = null)
protected function canPublishEvent(array $event, $user = null)
{
$user = $user ?: $this->ACL->getUser();
return $this->ACL->canPublishEvent($user, $event->toArray());
return $this->ACL->canPublishEvent($user, $event);
}
/**

View File

@ -3,11 +3,12 @@
namespace App\Lib\Tools;
use App\Model\Entity\Distribution;
use App\Model\Entity\User;
use App\Model\Table\EventsTable;
class DistributionGraphTool
{
/** @var array */
/** @var User */
private $__user;
private $__json = [];
/** @var Event */
@ -23,7 +24,7 @@ class DistributionGraphTool
private $__extended_view = 0;
public function __construct(EventsTable $eventModel, array $servers, array $user, $extended_view = 0)
public function __construct(EventsTable $eventModel, array $servers, User $user, $extended_view = 0)
{
$this->__eventModel = $eventModel;
$this->__serverList = $servers;
@ -95,7 +96,7 @@ class DistributionGraphTool
}
// community
$orgConditions = $this->__organisationModel->createConditions($this->__user);
$orgConditions = $this->__organisationModel->createConditions($this->__user->toArray());
$orgConditions['local'] = true;
$orgConditions['id !='] = $this->__user['Organisation']['id'];
$orgs = $this->__organisationModel->find(

View File

@ -751,11 +751,11 @@ class EventsTable extends AppTable
/**
* Get related attributes for event
* @param array $user
* @param User $user
* @param int|array $eventIds Event IDs
* @return array
*/
public function getRelatedAttributes(array $user, $eventIds)
public function getRelatedAttributes(User $user, $eventIds)
{
// TODO: [3.x-MIGRATION]
// $CorrelationsTable = $this->fetchTable('Correlations');
@ -1652,12 +1652,12 @@ class EventsTable extends AppTable
}
/**
* @param array $user
* @param User $user
* @param array $params
* @param bool $includeOrgc
* @return array
*/
public function fetchSimpleEvents(array $user, array $params, $includeOrgc = false)
public function fetchSimpleEvents(User $user, array $params, $includeOrgc = false)
{
$conditions = $this->createEventConditions($user);
$conditions['AND'][] = $params['conditions'];

View File

@ -63,7 +63,7 @@ class ShadowAttributesTable extends AppTable
$orgIds = $this->find(
'column',
[
'fields' => ['ShadowAttribute.org_id'],
'fields' => ['ShadowAttributes.org_id'],
'conditions' => ['event_id IN' => $eventId],
'unique' => true,
'order' => false

View File

@ -208,11 +208,11 @@ class SightingsTable extends AppTable
/**
* @param array $events
* @param array $user
* @param User $user
* @param bool $csvWithFalsePositive
* @return array
*/
public function eventsStatistic(array $events, array $user, $csvWithFalsePositive = false)
public function eventsStatistic(array $events, User $user, $csvWithFalsePositive = false)
{
if (empty($events)) {
return ['data' => [], 'csv' => []];