Various changes

- regexp structural changes added to the upgrade script (type)
- Added publish / alert to the background jobs
- fixed a misalignment with the statistics
pull/217/head
iglocska 2014-02-09 22:09:29 +01:00
parent 91d736ceb6
commit 0e1bf5567f
5 changed files with 35 additions and 12 deletions

5
INSTALL/upgrade_2.2.sql Normal file → Executable file
View File

@ -92,6 +92,11 @@ ALTER TABLE `servers`
ADD `self_signed` tinyint(1) NOT NULL,
ADD `cert_file` varchar(255) COLLATE utf8_bin NOT NULL;
ALTER TABLE `regexp`
ADD `type` varchar(100) COLLATE utf8_bin NOT NULL DEFAULT 'ALL';
UPDATE `regexp` SET `type` = 'ALL';
UPDATE `roles` SET `perm_site_admin` = 1 WHERE `id` = 1;
INSERT INTO `threat_levels` (`id`, `name`, `description`, `form_description`)

6
app/Console/Command/EventShell.php Normal file → Executable file
View File

@ -288,10 +288,10 @@ class EventShell extends AppShell
public function publish() {
$id = $this->args[0];
$passAlong = $this->args[1];
$processId = $this->args[2];
$this->Job->id = $processId;
$jobId = $this->args[2];
$this->Job->id = $jobId;
$eventId = $this->args[2];
$result = $this->Event->publish($id, $passAlong, $processId);
$result = $this->Event->publish($id, $passAlong, $jobId);
$this->Job->saveField('progress', '100');
if ($result != true) $this->Job->saveField('message', 'Job done.');
}

View File

@ -979,7 +979,7 @@ class EventsController extends AppController {
// only allow form submit CSRF protection.
if ($this->request->is('post') || $this->request->is('put')) {
// Performs all the actions required to publish an event
$result = $this->Event->publish($id);
$result = $this->Event->publishRouter($id, null, $this->Auth->user('org'));
if (!Configure::read('MISP.background_jobs')) {
if (!is_array($result)) {
// redirect to the view event page
@ -1021,7 +1021,7 @@ class EventsController extends AppController {
$emailResult = $this->Event->sendAlertEmailRouter($id, $this->Auth->user(), $this->_isSiteAdmin());
if (is_bool($emailResult) && $emailResult = true) {
// Performs all the actions required to publish an event
$result = $this->Event->publish($id);
$result = $this->Event->publishRouter($id, null, $this->Auth->user('org'));
if (!is_array($result)) {
// redirect to the view event page

14
app/Model/Event.php Normal file → Executable file
View File

@ -1485,7 +1485,7 @@ class Event extends AppModel {
}
}
public function publishRouter($id, $passAlong = null) {
public function publishRouter($id, $passAlong = null, $org = null) {
if (Configure::read('MISP.background_jobs')) {
$job = ClassRegistry::init('Job');
$job->create();
@ -1495,7 +1495,7 @@ class Event extends AppModel {
'job_input' => 'Event ID: ' . $id,
'status' => 0,
'retries' => 0,
'org' => $this->Auth->user('org'),
'org' => $org,
'message' => 'Publishing.',
);
$job->save($data);
@ -1503,10 +1503,10 @@ class Event extends AppModel {
$process_id = CakeResque::enqueue(
'default',
'EventShell',
array('publish', $id, $passAlong, $process_id)
array('publish', $id, $passAlong, $jobId)
);
$job->saveField('process_id', $process_id);
return true;
return $process_id;
} else {
$result = $this->publish($id, $passAlong);
return $result;
@ -1534,6 +1534,12 @@ class Event extends AppModel {
$this->saveField('published', 0);
}
} else {
if ($processId != null) {
$job = ClassRegistry::init('Job');
$job->id = $processId;
$job->saveField('progress', 100);
$job->saveField('message', 'Event (' . $id . ') published.');
}
return true;
}
return $uploaded;

18
app/View/Users/statistics.ctp Normal file → Executable file
View File

@ -54,9 +54,21 @@
</div>
<br />
<br />
<div style="float:left;margin-top:50px;margin-right:5px;"><button id="goLeft" class="btn"><span class="icon-arrow-left"></span></button></div>
<div id="cal-heatmap" style="float:left;"></div>
<div style="float:left;margin-top:50px;margin-left:5px;"><button id="goRight" class="btn"><span class="icon-arrow-right"></span></button></div>
<div style="margin-top:100px;">
<table>
<tr>
<td style="vertical-align:top;">
<div style="margin-right:5px;margin-top:40px;"><button id="goLeft" class="btn"><span class="icon-arrow-left"></span></button></div>
</td>
<td>
<div id="cal-heatmap"></div>
</td>
<td style="vertical-align:top;">
<div style="margin-left:5px;margin-top:40px;"><button id="goRight" class="btn"><span class="icon-arrow-right"></span></button></div>
</td>
</tr>
</table>
</div>
<script type="text/javascript">
var cal = new CalHeatMap();
cal.init({