mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 14:03:27 +00:00
fix log session in edit
This commit is contained in:
@@ -336,9 +336,10 @@ class EditController extends Controller
|
|||||||
return $this->app->json(['message' => '', 'error' => false]);
|
return $this->app->json(['message' => '', 'error' => false]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sessionLogId = $this->getDataboxLogger($databox)->get_id();
|
||||||
// order the worker to save values in fields
|
// order the worker to save values in fields
|
||||||
$this->dispatch(WorkerEvents::RECORD_EDIT_IN_WORKER,
|
$this->dispatch(WorkerEvents::RECORD_EDIT_IN_WORKER,
|
||||||
new RecordEditInWorkerEvent(RecordEditInWorkerEvent::MDS_TYPE, $request->request->get('mds'), $databox->get_sbas_id())
|
new RecordEditInWorkerEvent(RecordEditInWorkerEvent::MDS_TYPE, $request->request->get('mds'), $databox->get_sbas_id(), $sessionLogId)
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->app->json(['success' => true]);
|
return $this->app->json(['success' => true]);
|
||||||
@@ -362,10 +363,12 @@ class EditController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$databoxId = reset($sbasIds);
|
$databoxId = reset($sbasIds);
|
||||||
|
$databox = $this->findDataboxById($databoxId);
|
||||||
|
$sessionLogId = $this->getDataboxLogger($databox)->get_id();
|
||||||
|
|
||||||
// order the worker to save values in fields
|
// order the worker to save values in fields
|
||||||
$this->dispatch(WorkerEvents::RECORD_EDIT_IN_WORKER,
|
$this->dispatch(WorkerEvents::RECORD_EDIT_IN_WORKER,
|
||||||
new RecordEditInWorkerEvent(RecordEditInWorkerEvent::JSON_TYPE, $request->getContent(), $databoxId)
|
new RecordEditInWorkerEvent(RecordEditInWorkerEvent::JSON_TYPE, $request->getContent(), $databoxId, $sessionLogId)
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->app->json(['success' => true]);
|
return $this->app->json(['success' => true]);
|
||||||
|
@@ -12,13 +12,14 @@ class RecordEditInWorkerEvent extends SfEvent
|
|||||||
private $dataType;
|
private $dataType;
|
||||||
private $data;
|
private $data;
|
||||||
private $databoxId;
|
private $databoxId;
|
||||||
|
private $sessionLogId;
|
||||||
|
|
||||||
|
public function __construct($dataType, $data, $databoxId, $sessionLogId)
|
||||||
public function __construct($dataType, $data, $databoxId)
|
|
||||||
{
|
{
|
||||||
$this->dataType = $dataType;
|
$this->dataType = $dataType;
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
$this->databoxId = $databoxId;
|
$this->databoxId = $databoxId;
|
||||||
|
$this->sessionLogId = $sessionLogId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDataType()
|
public function getDataType()
|
||||||
@@ -34,4 +35,9 @@ class RecordEditInWorkerEvent extends SfEvent
|
|||||||
{
|
{
|
||||||
return $this->databoxId;
|
return $this->databoxId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSessionLogId()
|
||||||
|
{
|
||||||
|
return $this->sessionLogId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -161,7 +161,6 @@ class AlchemyWorkerServiceProvider implements PluginProviderInterface
|
|||||||
$app['alchemy_worker.type_based_worker_resolver']->addFactory(MessagePublisher::EDIT_RECORD_TYPE, new CallableWorkerFactory(function () use ($app) {
|
$app['alchemy_worker.type_based_worker_resolver']->addFactory(MessagePublisher::EDIT_RECORD_TYPE, new CallableWorkerFactory(function () use ($app) {
|
||||||
return (new EditRecordWorker($app['repo.worker-running-job'], $app['dispatcher'], $app['alchemy_worker.message.publisher']))
|
return (new EditRecordWorker($app['repo.worker-running-job'], $app['dispatcher'], $app['alchemy_worker.message.publisher']))
|
||||||
->setApplicationBox($app['phraseanet.appbox'])
|
->setApplicationBox($app['phraseanet.appbox'])
|
||||||
->setDataboxLoggerLocator($app['phraseanet.logger'])
|
|
||||||
;
|
;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@@ -293,7 +293,8 @@ class RecordSubscriber implements EventSubscriberInterface
|
|||||||
'type' => MessagePublisher::EDIT_RECORD_TYPE, // used to specify the final Q to publish message
|
'type' => MessagePublisher::EDIT_RECORD_TYPE, // used to specify the final Q to publish message
|
||||||
'dataType' => $event->getDataType(),
|
'dataType' => $event->getDataType(),
|
||||||
'data' => $event->getData(),
|
'data' => $event->getData(),
|
||||||
'databoxId' => $event->getDataboxId()
|
'databoxId' => $event->getDataboxId(),
|
||||||
|
'sessionLogId' => $event->getSessionLogId()
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@@ -17,7 +17,6 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|||||||
class EditRecordWorker implements WorkerInterface
|
class EditRecordWorker implements WorkerInterface
|
||||||
{
|
{
|
||||||
use ApplicationBoxAware;
|
use ApplicationBoxAware;
|
||||||
use DataboxLoggerAware;
|
|
||||||
|
|
||||||
private $repoWorker;
|
private $repoWorker;
|
||||||
private $dispatcher;
|
private $dispatcher;
|
||||||
@@ -75,6 +74,7 @@ class EditRecordWorker implements WorkerInterface
|
|||||||
$workerRunningJob = new WorkerRunningJob();
|
$workerRunningJob = new WorkerRunningJob();
|
||||||
$workerRunningJob
|
$workerRunningJob
|
||||||
->setDataboxId($payload['databoxId'])
|
->setDataboxId($payload['databoxId'])
|
||||||
|
->setRecordId($payload['record_id'])
|
||||||
->setWork(MessagePublisher::EDIT_RECORD_TYPE)
|
->setWork(MessagePublisher::EDIT_RECORD_TYPE)
|
||||||
->setWorkOn("record")
|
->setWorkOn("record")
|
||||||
->setPublished($date->setTimestamp($payload['published']))
|
->setPublished($date->setTimestamp($payload['published']))
|
||||||
@@ -136,11 +136,11 @@ class EditRecordWorker implements WorkerInterface
|
|||||||
$record->write_metas();
|
$record->write_metas();
|
||||||
|
|
||||||
if ($statbits != '') {
|
if ($statbits != '') {
|
||||||
$this->getDataboxLogger($databox)
|
\Session_Logger::loadById($databox, $payload['sessionLogId'])
|
||||||
->log($record, \Session_Logger::EVENT_STATUS, '', '');
|
->log($record, \Session_Logger::EVENT_STATUS, '', '');
|
||||||
}
|
}
|
||||||
if ($editDirty) {
|
if ($editDirty) {
|
||||||
$this->getDataboxLogger($databox)
|
\Session_Logger::loadById($databox, $payload['sessionLogId'])
|
||||||
->log($record, \Session_Logger::EVENT_EDIT, '', '');
|
->log($record, \Session_Logger::EVENT_EDIT, '', '');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@@ -37,6 +37,7 @@ class MainQueueWorker implements WorkerInterface
|
|||||||
$payloadData = array_map(function($singleMessage) use ($payload) {
|
$payloadData = array_map(function($singleMessage) use ($payload) {
|
||||||
$singleMessage['databoxId'] = $payload['databoxId'];
|
$singleMessage['databoxId'] = $payload['databoxId'];
|
||||||
$singleMessage['dataType'] = $payload['dataType'];
|
$singleMessage['dataType'] = $payload['dataType'];
|
||||||
|
$singleMessage['sessionLogId'] = $payload['sessionLogId'];
|
||||||
|
|
||||||
return $singleMessage;
|
return $singleMessage;
|
||||||
}, $payload['data']);
|
}, $payload['data']);
|
||||||
@@ -45,6 +46,7 @@ class MainQueueWorker implements WorkerInterface
|
|||||||
|
|
||||||
$payloadData = array_map(function($singleMessage) use ($payload, $data) {
|
$payloadData = array_map(function($singleMessage) use ($payload, $data) {
|
||||||
$singleMessage['databoxId'] = $payload['databoxId'];
|
$singleMessage['databoxId'] = $payload['databoxId'];
|
||||||
|
$singleMessage['sessionLogId'] = $payload['sessionLogId'];
|
||||||
$singleMessage['dataType'] = $payload['dataType'];
|
$singleMessage['dataType'] = $payload['dataType'];
|
||||||
$singleMessage['actions'] = $data['actions'];
|
$singleMessage['actions'] = $data['actions'];
|
||||||
unset($singleMessage['sbas_id']);
|
unset($singleMessage['sbas_id']);
|
||||||
|
@@ -170,6 +170,27 @@ class Session_Logger
|
|||||||
return new self($databox, $row['id']);
|
return new self($databox, $row['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function loadById($databox, $logId)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT id, site FROM log
|
||||||
|
WHERE id = :log_id ';
|
||||||
|
|
||||||
|
$params = [
|
||||||
|
':log_id' => $logId
|
||||||
|
];
|
||||||
|
|
||||||
|
$stmt = $databox->get_connection()->prepare($sql);
|
||||||
|
$stmt->execute($params);
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
if (!$row) {
|
||||||
|
throw new Exception_Session_LoggerNotFound('Logger not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return new self($databox, $logId);
|
||||||
|
}
|
||||||
|
|
||||||
public static function updateClientInfos(Application $app, $appId)
|
public static function updateClientInfos(Application $app, $appId)
|
||||||
{
|
{
|
||||||
if (!$app->getAuthenticator()->isAuthenticated()) {
|
if (!$app->getAuthenticator()->isAuthenticated()) {
|
||||||
|
Reference in New Issue
Block a user