new: Sightings enabled by default

pull/1705/head
Iglocska 2016-11-21 17:27:30 +01:00
parent f5a225883c
commit a6734c858a
7 changed files with 16 additions and 12 deletions

View File

@ -567,7 +567,7 @@ class EventsController extends AppController {
$this->redirect(array('controller' => 'events', 'action' => 'view', $events[0]['Event']['id']));
}
if (Configure::read('MISP.showCorrelationsOnIndex')) $events = $this->Event->attachCorrelationCountToEvents($this->Auth->user(), $events);
if (Configure::read('MISP.showSightingsCountOnIndex') && Configure::read('MISP.Plugin.Sightings_enable')) $events = $this->Event->attachSightingsCountToEvents($this->Auth->user(), $events);
if (Configure::read('MISP.showSightingsCountOnIndex') && Configure::read('MISP.Plugin.Sightings_enable') !== false) $events = $this->Event->attachSightingsCountToEvents($this->Auth->user(), $events);
if (Configure::read('MISP.showProposalsCountOnIndex')) $events = $this->Event->attachProposalsCountToEvents($this->Auth->user(), $events);
$this->set('events', $events);
}

View File

@ -6,7 +6,7 @@ class SightingsController extends AppController {
public function beforeFilter() {
parent::beforeFilter();
if (!Configure::read('Plugin.Sightings_enable')) throw new MethodNotAllowedException('This feature is not enabled on this instance.');
if (Configure::read('Plugin.Sightings_enable') === false) throw new MethodNotAllowedException('This feature is not enabled on this instance.');
}
public $paginate = array(

View File

@ -69,6 +69,9 @@ class AppModel extends Model {
$this->SharingGroup->correctSyncedSharingGroups();
$this->SharingGroup->updateRoaming();
break;
case '2.4.55':
$this->updateDatabase('addSightings');
break;
default:
$this->updateDatabase($command);
break;

View File

@ -1308,7 +1308,9 @@ class Event extends AppModel {
if (empty($results)) return array();
// Do some refactoring with the event
$sgsids = $this->SharingGroup->fetchAllAuthorised($user);
if (Configure::read('Plugin.Sightings_enable')) $this->Sighting = ClassRegistry::init('Sighting');
if (Configure::read('Plugin.Sightings_enable') !== false) {
$this->Sighting = ClassRegistry::init('Sighting');
}
foreach ($results as $eventKey => &$event) {
// unset the empty sharing groups that are created due to the way belongsTo is handled
if (isset($event['SharingGroup']['SharingGroupServer'])) {
@ -1377,7 +1379,7 @@ class Event extends AppModel {
}
$event['Attribute'] = array_values($event['Attribute']);
}
if (Configure::read('Plugin.Sightings_enable')) {
if (Configure::read('Plugin.Sightings_enable') !== false) {
$event['Sighting'] = $this->Sighting->attachToEvent($event, $user);
}
// remove proposals to attributes that we cannot see

View File

@ -30,7 +30,7 @@
<?php if (Configure::read('MISP.showCorrelationsOnIndex')):?>
<th title="Correlation Count">#Corr.</th>
<?php endif; ?>
<?php if (Configure::read('MISP.showSightingsCountOnIndex') && Configure::read('Plugin.Sightings_enable')):?>
<?php if (Configure::read('MISP.showSightingsCountOnIndex') && Configure::read('Plugin.Sightings_enable') !== false):?>
<th title="Sigthing Count">#Sightings</th>
<?php endif; ?>
<?php if (Configure::read('MISP.showProposalsOnIndex')):?>
@ -115,7 +115,7 @@
<?php echo !empty($event['Event']['correlation_count']) ? h($event['Event']['correlation_count']) : ''; ?>&nbsp;
</td>
<?php endif; ?>
<?php if (Configure::read('MISP.showSightingsCountOnIndex') && Configure::read('Plugin.Sightings_enable')):?>
<?php if (Configure::read('MISP.showSightingsCountOnIndex') && Configure::read('Plugin.Sightings_enable') !== false):?>
<td class = "bold" style="width:30px;" ondblclick="location.href ='<?php echo $baseurl."/events/view/".$event['Event']['id'];?>'" title="<?php echo (!empty($event['Event']['sightings_count']) ? h($event['Event']['sightings_count']) : '0') . ' sighting(s)';?>">
<?php echo !empty($event['Event']['sightings_count']) ? h($event['Event']['sightings_count']) : ''; ?>&nbsp;
</td>

View File

@ -10,7 +10,7 @@
} else {
$page = 0;
}
if (Configure::read('Plugin.Sightings_enable')) {
if (Configure::read('Plugin.Sightings_enable') !== false) {
$attributeSightings = array();
$attributeOwnSightings = array();
$attributeSightingsPopover = array();
@ -171,7 +171,7 @@
<th>Related Events</th>
<th title="<?php echo $attrDescriptions['signature']['desc'];?>"><?php echo $this->Paginator->sort('to_ids', 'IDS');?></th>
<th title="<?php echo $attrDescriptions['distribution']['desc'];?>"><?php echo $this->Paginator->sort('distribution');?></th>
<?php if (Configure::read('Plugin.Sightings_enable')): ?>
<?php if (Configure::read('Plugin.Sightings_enable') !== false): ?>
<th>Sightings</th>
<?php endif; ?>
<th class="actions">Actions</th>
@ -409,7 +409,7 @@
</td>
<?php
endif;
if (Configure::read('Plugin.Sightings_enable')):
if (Configure::read('Plugin.Sightings_enable') !== false):
?>
<td class="short <?php echo $extra;?>">
<span id="sightingForm_<?php echo h($object['id']);?>">

View File

@ -1,13 +1,12 @@
<?php
$mayModify = (($isAclModify && $event['Event']['user_id'] == $me['id'] && $event['Orgc']['id'] == $me['org_id']) || ($isAclModifyOrg && $event['Orgc']['id'] == $me['org_id']));
$mayPublish = ($isAclPublish && $event['Orgc']['id'] == $me['org_id']);
if (Configure::read('Plugin.Sightings_enable')) {
if (Configure::read('Plugin.Sightings_enable') !== false) {
$sightingPopover = '';
if (isset($event['Sighting']) && !empty($event['Sighting'])) {
$ownSightings = array();
$orgSightings = array();
foreach ($event['Sighting'] as $sighting) {
debug($sighting);
if (isset($sighting['org_id']) && $sighting['org_id'] == $me['org_id']) $ownSightings[] = $sighting;
if (isset($sighting['org_id'])) {
if (isset($orgSightings[$sighting['Organisation']['name']])) {
@ -171,7 +170,7 @@
</dd>
<dt class="<?php echo ($event['Event']['published'] == 0) ? (($isAclPublish && $me['org_id'] == $event['Event']['orgc_id']) ? 'background-red bold' : 'bold') : 'bold'; ?>">Published</dt>
<dd class="<?php echo ($event['Event']['published'] == 0) ? (($isAclPublish && $me['org_id'] == $event['Event']['orgc_id']) ? 'background-red bold' : 'red bold') : 'green bold'; ?>"><?php echo ($event['Event']['published'] == 0) ? 'No' : 'Yes'; ?></dd>
<?php if (Configure::read('Plugin.Sightings_enable')): ?>
<?php if (Configure::read('Plugin.Sightings_enable') !== false): ?>
<dt>Sightings</dt>
<dd style="word-wrap: break-word;">
<span id="eventSightingCount" class="bold sightingsCounter" data-toggle="popover" data-trigger="hover" data-content="<?php echo $sightingPopover; ?>"><?php echo count($event['Sighting']); ?></span>