mirror of https://github.com/MISP/MISP
Merge pull request #3770 from devnull-/issues_1643_rebase_2.4
Issues 1643 -- Fix publish_without_email when an event is modified -- rebasepull/3912/head
commit
430ddcd79c
|
@ -3266,7 +3266,7 @@ class Event extends AppModel
|
|||
}
|
||||
}
|
||||
|
||||
public function _edit(&$data, $user, $id, $jobId = null)
|
||||
public function _edit(&$data, $user, $id, $jobId = null, $passAlong = null)
|
||||
{
|
||||
$data = $this->cleanupEventArrayFromXML($data);
|
||||
unset($this->Attribute->validate['event_id']);
|
||||
|
@ -3419,8 +3419,52 @@ class Event extends AppModel
|
|||
}
|
||||
// if published -> do the actual publishing
|
||||
if ((!empty($data['Event']['published']) && 1 == $data['Event']['published'])) {
|
||||
// The edited event is from a remote server ?
|
||||
if ($passAlong) {
|
||||
$this->Server = ClassRegistry::init('Server');
|
||||
$server = $this->Server->find('first', array(
|
||||
'conditions' => array(
|
||||
'Server.id' => $passAlong
|
||||
),
|
||||
'recursive' => -1,
|
||||
'fields' => array(
|
||||
'Server.name',
|
||||
'Server.id',
|
||||
'Server.unpublish_event',
|
||||
'Server.publish_without_email'
|
||||
)
|
||||
));
|
||||
if ($server['Server']['publish_without_email'] == 0) {
|
||||
$st = "enabled";
|
||||
} else {
|
||||
$st = "disabled";
|
||||
}
|
||||
$this->Log->create();
|
||||
$this->Log->save(array(
|
||||
'org' => $user['Organisation']['name'],
|
||||
'model' => 'Event',
|
||||
'model_id' => $saveResult['Event']['id'],
|
||||
'email' => $user['email'],
|
||||
'action' => 'add',
|
||||
'user_id' => $user['id'],
|
||||
'title' => 'Event edited from Server(' . $server['Server']['id'] . ') - "' . $server['Server']['name'] . '" - Notification by mail ' . $st,
|
||||
'change' => ''
|
||||
));
|
||||
} else {
|
||||
$this->Log->create();
|
||||
$this->Log->save(array(
|
||||
'org' => $user['Organisation']['name'],
|
||||
'model' => 'Event',
|
||||
'model_id' => $saveResult['Event']['id'],
|
||||
'email' => $user['email'],
|
||||
'action' => 'add',
|
||||
'user_id' => $user['id'],
|
||||
'title' => 'Event edited (locally)',
|
||||
'change' => ''
|
||||
));
|
||||
}
|
||||
// do the necessary actions to publish the event (email, upload,...)
|
||||
if (true != Configure::read('MISP.disablerestalert')) {
|
||||
if ((true != Configure::read('MISP.disablerestalert')) && (empty($server) || $server['Server']['publish_without_email'] == 0)) {
|
||||
$this->sendAlertEmailRouter($id, $user, $existingEvent['Event']['publish_timestamp']);
|
||||
}
|
||||
$this->publish($existingEvent['Event']['id']);
|
||||
|
|
|
@ -1891,9 +1891,9 @@ class Server extends AppModel
|
|||
{
|
||||
// check if the event already exist (using the uuid)
|
||||
$existingEvent = $eventModel->find('first', array('conditions' => array('Event.uuid' => $event['Event']['uuid'])));
|
||||
$passAlong = $server['Server']['id'];
|
||||
if (!$existingEvent) {
|
||||
// add data for newly imported events
|
||||
$passAlong = $server['Server']['id'];
|
||||
$result = $eventModel->_add($event, true, $user, $server['Server']['org_id'], $passAlong, true, $jobId);
|
||||
if ($result) {
|
||||
$successes[] = $eventId;
|
||||
|
@ -1903,7 +1903,7 @@ class Server extends AppModel
|
|||
} else {
|
||||
$tempUser = $user;
|
||||
$tempUser['Role']['perm_site_admin'] = 0;
|
||||
$result = $eventModel->_edit($event, $tempUser, $existingEvent['Event']['id'], $jobId);
|
||||
$result = $eventModel->_edit($event, $tempUser, $existingEvent['Event']['id'], $jobId, $passAlong);
|
||||
if ($result === true) {
|
||||
$successes[] = $eventId;
|
||||
} elseif (isset($result['error'])) {
|
||||
|
|
Loading…
Reference in New Issue