mirror of https://github.com/MISP/MISP
Removed the js title bubble for related events
- Removed javascripts based title bubble showing the event info in related events / attributes and in the search attribute view. - Replaced it with values provided by extra cake queries as the delay for fetching the info field through a js rest request was annoyingly slow - some coding standardspull/63/head
parent
0e18aa099b
commit
019e976783
|
@ -53,7 +53,10 @@ class AttributesController extends AppController {
|
||||||
array(
|
array(
|
||||||
'Event.org =' => $this->Auth->user('org'),
|
'Event.org =' => $this->Auth->user('org'),
|
||||||
'AND' => array(
|
'AND' => array(
|
||||||
array('Attribute.distribution !=' => 'Your organization only'),
|
array('OR' => array(
|
||||||
|
array('Attribute.private !=' => 1),
|
||||||
|
array('Attribute.cluster =' => 1),
|
||||||
|
)),
|
||||||
array('OR' => array(
|
array('OR' => array(
|
||||||
array('Event.private !=' => 1),
|
array('Event.private !=' => 1),
|
||||||
array('Event.cluster =' => 1),
|
array('Event.cluster =' => 1),
|
||||||
|
|
|
@ -181,6 +181,7 @@ class EventsController extends AppController {
|
||||||
|
|
||||||
$relatedAttributes = array();
|
$relatedAttributes = array();
|
||||||
$this->loadModel('Attribute');
|
$this->loadModel('Attribute');
|
||||||
|
$this->loadModel('Event');
|
||||||
if ('db' == Configure::read('CyDefSIG.correlation')) {
|
if ('db' == Configure::read('CyDefSIG.correlation')) {
|
||||||
$this->loadModel('Correlation');
|
$this->loadModel('Correlation');
|
||||||
$fields = array('Correlation.event_id', 'Correlation.attribute_id', 'Correlation.date');
|
$fields = array('Correlation.event_id', 'Correlation.attribute_id', 'Correlation.date');
|
||||||
|
@ -225,19 +226,31 @@ class EventsController extends AppController {
|
||||||
// This is a lot faster (only additional query) than $this->Event->getRelatedEvents()
|
// This is a lot faster (only additional query) than $this->Event->getRelatedEvents()
|
||||||
$relatedEventIds = array();
|
$relatedEventIds = array();
|
||||||
$relatedEventDates = array();
|
$relatedEventDates = array();
|
||||||
|
$relatedEventInfos = array();
|
||||||
$relatedEvents = array();
|
$relatedEvents = array();
|
||||||
foreach ($relatedAttributes as &$relatedAttribute) {
|
foreach ($relatedAttributes as &$relatedAttribute) {
|
||||||
if (null == $relatedAttribute) continue;
|
if (null == $relatedAttribute) continue;
|
||||||
foreach ($relatedAttribute as &$item) {
|
foreach ($relatedAttribute as &$item) {
|
||||||
$relatedEventsIds[] = $item['Attribute']['event_id'];
|
$relatedEventsIds[] = $item['Attribute']['event_id'];
|
||||||
$relatedEventsDates[$item['Attribute']['event_id']] = $item['Attribute']['date'];
|
$relatedEventsDates[$item['Attribute']['event_id']] = $item['Attribute']['date'];
|
||||||
|
$temp = $this->Event->find('first', array(
|
||||||
|
'conditions' => array('Event.id' => $item['Attribute']['event_id']),
|
||||||
|
'fields' => array('info'),
|
||||||
|
'recursive' => 0,
|
||||||
|
));
|
||||||
|
$item['Attribute']['event_info'] = $temp['Event']['info'];
|
||||||
|
$relatedEventInfos[$item['Attribute']['event_id']] = $temp['Event']['info'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($relatedEventsDates)) {
|
if (isset($relatedEventsDates)) {
|
||||||
foreach ($relatedEventsDates as $key => $relatedEventsDate) {
|
foreach ($relatedEventsDates as $key => $relatedEventsDate) {
|
||||||
$relatedEvents[] = array('Event' => array('id' => $key, 'date' => $relatedEventsDate));
|
$relatedEvents[] = array('Event' => array('id' => $key, 'date' => $relatedEventsDate));
|
||||||
}
|
}
|
||||||
|
$i = 0;
|
||||||
|
foreach ($relatedEventInfos as $info) {
|
||||||
|
$relatedEvents[$i]['Event']['info'] = $info;
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
usort($relatedEvents, array($this, 'compareRelatedEvents'));
|
usort($relatedEvents, array($this, 'compareRelatedEvents'));
|
||||||
}
|
}
|
||||||
|
@ -280,7 +293,7 @@ class EventsController extends AppController {
|
||||||
$findParams = array(
|
$findParams = array(
|
||||||
'conditions' => array('OR' => array('Event.id' => $relatedEventsIds)), //array of conditions
|
'conditions' => array('OR' => array('Event.id' => $relatedEventsIds)), //array of conditions
|
||||||
'recursive' => 0, //int
|
'recursive' => 0, //int
|
||||||
'fields' => array('Event.id', 'Event.date', 'Event.uuid'), //array of field names
|
'fields' => array('Event.id', 'Event.date', 'Event.uuid', 'Event.info'), //array of field names
|
||||||
'order' => array('Event.date DESC'), //string or array defining order
|
'order' => array('Event.date DESC'), //string or array defining order
|
||||||
);
|
);
|
||||||
$relatedEvents = $this->Event->find('all', $findParams);
|
$relatedEvents = $this->Event->find('all', $findParams);
|
||||||
|
@ -312,7 +325,6 @@ class EventsController extends AppController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->set('event', $event);
|
$this->set('event', $event);
|
||||||
|
|
||||||
$this->set('relatedEvents', $relatedEvents);
|
$this->set('relatedEvents', $relatedEvents);
|
||||||
|
|
||||||
$this->set('categories', $this->Attribute->validate['category']['rule'][1]);
|
$this->set('categories', $this->Attribute->validate['category']['rule'][1]);
|
||||||
|
@ -1486,7 +1498,6 @@ class EventsController extends AppController {
|
||||||
|
|
||||||
$this->loadModel('Attribute');
|
$this->loadModel('Attribute');
|
||||||
|
|
||||||
|
|
||||||
//restricting to non-private or same org if the user is not a site-admin.
|
//restricting to non-private or same org if the user is not a site-admin.
|
||||||
$conditions['AND'] = array('Attribute.type' => $type);
|
$conditions['AND'] = array('Attribute.type' => $type);
|
||||||
if (!$this->isSiteAdmin()) {
|
if (!$this->isSiteAdmin()) {
|
||||||
|
@ -1499,7 +1510,6 @@ class EventsController extends AppController {
|
||||||
$conditions['OR'] = $temp;
|
$conditions['OR'] = $temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'conditions' => $conditions, //array of conditions
|
'conditions' => $conditions, //array of conditions
|
||||||
'recursive' => 0, //int
|
'recursive' => 0, //int
|
||||||
|
|
|
@ -383,7 +383,6 @@ class Attribute extends AppModel {
|
||||||
$this->data['Attribute']['value1'] = $total;
|
$this->data['Attribute']['value1'] = $total;
|
||||||
$this->data['Attribute']['value2'] = '';
|
$this->data['Attribute']['value2'] = '';
|
||||||
}
|
}
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
// always return true after a beforeSave()
|
// always return true after a beforeSave()
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -15,6 +15,7 @@ class Regexp extends AppModel {
|
||||||
'change' => 'full'
|
'change' => 'full'
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use table
|
* Use table
|
||||||
*
|
*
|
||||||
|
@ -23,6 +24,7 @@ class Regexp extends AppModel {
|
||||||
public $useTable = 'regexp';
|
public $useTable = 'regexp';
|
||||||
|
|
||||||
// this checks whether the regexp would fail and if yes, the entry is blocked from being entered.
|
// this checks whether the regexp would fail and if yes, the entry is blocked from being entered.
|
||||||
|
|
||||||
public function beforeValidate($options = array()) {
|
public function beforeValidate($options = array()) {
|
||||||
$test = preg_replace($this->data['Regexp']['regexp'], 'success', $this->data['Regexp']['regexp']);
|
$test = preg_replace($this->data['Regexp']['regexp'], 'success', $this->data['Regexp']['regexp']);
|
||||||
if ($test == null) return false;
|
if ($test == null) return false;
|
||||||
|
|
|
@ -1,19 +1,3 @@
|
||||||
<script>
|
|
||||||
function getTitle(incInt, id){
|
|
||||||
if (document.getElementById(incInt).title == "Loading event info..."){
|
|
||||||
$.ajax({
|
|
||||||
type: 'GET',
|
|
||||||
url: "/events/"+id+".xml",
|
|
||||||
dataType: 'xml',
|
|
||||||
async:true,
|
|
||||||
success:function(result){
|
|
||||||
var returnData = $(result).find("info").text();
|
|
||||||
document.getElementById(incInt).title=returnData;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<div class="attributes index">
|
<div class="attributes index">
|
||||||
<h2><?php echo __('Attributes');?></h2>
|
<h2><?php echo __('Attributes');?></h2>
|
||||||
<?php
|
<?php
|
||||||
|
@ -41,7 +25,7 @@ foreach ($attributes as $attribute): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="short">
|
<td class="short">
|
||||||
<?php
|
<?php
|
||||||
echo "<div id = \"" . $attribute['Attribute']['id'] . "\" onMouseOver=getTitle(" . $attribute['Attribute']['id'] . "," . $attribute['Event']['id'] . ") title = \"Loading event info...\">";
|
echo "<div id = \"" . $attribute['Attribute']['id'] . "\" title = \"".h($attribute['Event']['info'])."\">";
|
||||||
echo $this->Html->link($attribute['Event']['id'], array('controller' => 'events', 'action' => 'view', $attribute['Event']['id']));
|
echo $this->Html->link($attribute['Event']['id'], array('controller' => 'events', 'action' => 'view', $attribute['Event']['id']));
|
||||||
$currentCount++;
|
$currentCount++;
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,30 +1,3 @@
|
||||||
<script>
|
|
||||||
function getTitle(incInt, incIntb, incIntc){
|
|
||||||
id = incInt;
|
|
||||||
type = null;
|
|
||||||
if (incIntb==0){
|
|
||||||
type = "R";
|
|
||||||
}else{
|
|
||||||
type = "A";
|
|
||||||
}
|
|
||||||
findElementString = type+id;
|
|
||||||
if (type == "A"){
|
|
||||||
findElementString += "X"+incIntc;
|
|
||||||
}
|
|
||||||
if (document.getElementById(findElementString).title == "Loading event info..."){
|
|
||||||
$.ajax({
|
|
||||||
type: 'GET',
|
|
||||||
url: "/events/"+id+".xml",
|
|
||||||
dataType: 'xml',
|
|
||||||
async:false,
|
|
||||||
success:function(result){
|
|
||||||
var returnData = $(result).find("info").text();
|
|
||||||
document.getElementById(findElementString).title=returnData;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<?php
|
<?php
|
||||||
$mayModify = (($isAclModify && $event['Event']['user_id'] == $me['id']) || ($isAclModifyOrg && $event['Event']['org'] == $me['org']));
|
$mayModify = (($isAclModify && $event['Event']['user_id'] == $me['id']) || ($isAclModifyOrg && $event['Event']['org'] == $me['org']));
|
||||||
$mayPublish = ($isAclPublish && $event['Event']['org'] == $me['org']);
|
$mayPublish = ($isAclPublish && $event['Event']['org'] == $me['org']);
|
||||||
|
@ -129,7 +102,6 @@ endif; ?>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<?php
|
<?php
|
||||||
$passAlong = array(0, 0);
|
|
||||||
if (!empty($relatedEvents)):?>
|
if (!empty($relatedEvents)):?>
|
||||||
<div class="related">
|
<div class="related">
|
||||||
<h3>Related Events</h3>
|
<h3>Related Events</h3>
|
||||||
|
@ -138,9 +110,7 @@ if (!empty($relatedEvents)):?>
|
||||||
foreach ($relatedEvents as $relatedEvent): ?>
|
foreach ($relatedEvents as $relatedEvent): ?>
|
||||||
<li><?php
|
<li><?php
|
||||||
$linkText = $relatedEvent['Event']['date'] . ' (' . $relatedEvent['Event']['id'] . ')';
|
$linkText = $relatedEvent['Event']['date'] . ' (' . $relatedEvent['Event']['id'] . ')';
|
||||||
$currentID = $relatedEvent['Event']['id'];
|
echo "<div \" title = \"".$relatedEvent['Event']['info']."\">";
|
||||||
$passAlong[0] = $relatedEvent['Event']['id'];
|
|
||||||
echo "<div id = \"R" . $currentID . "\" onMouseOver=getTitle(" . $passAlong[0] . "," . $passAlong[1] . ") title = \"Loading event info...\">";
|
|
||||||
echo $this->Html->link($linkText, array('controller' => 'events', 'action' => 'view', $relatedEvent['Event']['id']));
|
echo $this->Html->link($linkText, array('controller' => 'events', 'action' => 'view', $relatedEvent['Event']['id']));
|
||||||
?></li>
|
?></li>
|
||||||
<?php
|
<?php
|
||||||
|
@ -178,7 +148,6 @@ if (!empty($event['Attribute'])):?>
|
||||||
<?php
|
<?php
|
||||||
endif;?>
|
endif;?>
|
||||||
</tr><?php
|
</tr><?php
|
||||||
$passAlong = array(0, 1, 0);
|
|
||||||
foreach ($categories as $category):
|
foreach ($categories as $category):
|
||||||
$first = 1;
|
$first = 1;
|
||||||
foreach ($event['Attribute'] as $attribute):
|
foreach ($event['Attribute'] as $attribute):
|
||||||
|
@ -224,12 +193,10 @@ if (!empty($event['Attribute'])):?>
|
||||||
$first = 0;
|
$first = 0;
|
||||||
if (isset($relatedAttributes[$attribute['id']]) && (null != $relatedAttributes[$attribute['id']])) {
|
if (isset($relatedAttributes[$attribute['id']]) && (null != $relatedAttributes[$attribute['id']])) {
|
||||||
foreach ($relatedAttributes[$attribute['id']] as $relatedAttribute) {
|
foreach ($relatedAttributes[$attribute['id']] as $relatedAttribute) {
|
||||||
$passAlong[0] = $relatedAttribute['Attribute']['event_id'];
|
echo "<span title = \"".$relatedAttribute['Attribute']['event_info']."\">";
|
||||||
echo "<span id = \"A" . $passAlong[0] . "X" . $passAlong[2] . "\" onMouseOver=getTitle(" . $passAlong[0] . "," . $passAlong[1] . "," . $passAlong[2] . ") title = \"Loading event info...\">";
|
|
||||||
echo $this->Html->link($relatedAttribute['Attribute']['event_id'], array('controller' => 'events', 'action' => 'view', $relatedAttribute['Attribute']['event_id']));
|
echo $this->Html->link($relatedAttribute['Attribute']['event_id'], array('controller' => 'events', 'action' => 'view', $relatedAttribute['Attribute']['event_id']));
|
||||||
echo "</span>";
|
echo "</span>";
|
||||||
echo ' ';
|
echo ' ';
|
||||||
$passAlong[2]++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue