mirror of https://github.com/MISP/MISP
chg: migrate sharing_views/view/[id] to factory
parent
559e11acab
commit
8cd5953d39
|
@ -53,13 +53,13 @@ class SharingGroupsController extends AppController
|
|||
$id = $this->SharingGroup->captureSG($this->request->data, $this->Auth->user());
|
||||
if ($id) {
|
||||
if (empty($sg['roaming']) && empty($sg['SharingGroupServer'])) {
|
||||
$this->SharingGroup->SharingGroupServer->create();
|
||||
$this->SharingGroup->SharingGroupServer->save(array(
|
||||
'sharing_group_id' => $this->SharingGroup->id,
|
||||
'server_id' => 0,
|
||||
'all_orgs' => 0
|
||||
));
|
||||
}
|
||||
$this->SharingGroup->SharingGroupServer->create();
|
||||
$this->SharingGroup->SharingGroupServer->save(array(
|
||||
'sharing_group_id' => $this->SharingGroup->id,
|
||||
'server_id' => 0,
|
||||
'all_orgs' => 0
|
||||
));
|
||||
}
|
||||
$sg = $this->SharingGroup->fetchAllAuthorised($this->Auth->user(), 'simplified', false, $id);
|
||||
if (!empty($sg)) {
|
||||
$sg = empty($sg) ? array() : $sg[0];
|
||||
|
@ -90,9 +90,9 @@ class SharingGroupsController extends AppController
|
|||
foreach ($sg['Organisation'] as $org) {
|
||||
$this->SharingGroup->SharingGroupOrg->create();
|
||||
$this->SharingGroup->SharingGroupOrg->save(array(
|
||||
'sharing_group_id' => $this->SharingGroup->id,
|
||||
'org_id' => $org['id'],
|
||||
'extend' => $org['extend']
|
||||
'sharing_group_id' => $this->SharingGroup->id,
|
||||
'org_id' => $org['id'],
|
||||
'extend' => $org['extend']
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -100,9 +100,9 @@ class SharingGroupsController extends AppController
|
|||
foreach ($sg['Server'] as $server) {
|
||||
$this->SharingGroup->SharingGroupServer->create();
|
||||
$this->SharingGroup->SharingGroupServer->save(array(
|
||||
'sharing_group_id' => $this->SharingGroup->id,
|
||||
'server_id' => $server['id'],
|
||||
'all_orgs' => $server['all_orgs']
|
||||
'sharing_group_id' => $this->SharingGroup->id,
|
||||
'server_id' => $server['id'],
|
||||
'all_orgs' => $server['all_orgs']
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ class SharingGroupsController extends AppController
|
|||
} elseif ($this->_isRest()) {
|
||||
return $this->RestResponse->describe('SharingGroup', 'add', false, $this->response->type());
|
||||
}
|
||||
|
||||
|
||||
$orgs = $this->SharingGroup->Organisation->find('all', array(
|
||||
'conditions' => array('local' => 1),
|
||||
'recursive' => -1,
|
||||
|
@ -135,7 +135,7 @@ class SharingGroupsController extends AppController
|
|||
// We just pass true and allow the user to edit, since he/she is just about to create the SG. This is needed to reuse the view for the edit
|
||||
$this->set('user', $this->Auth->user());
|
||||
}
|
||||
|
||||
|
||||
public function edit($id = false)
|
||||
{
|
||||
if (!$this->userRole['perm_sharing_group']) {
|
||||
|
@ -144,7 +144,7 @@ class SharingGroupsController extends AppController
|
|||
if (empty($id)) {
|
||||
throw new NotFoundException('Invalid sharing group.');
|
||||
}
|
||||
|
||||
|
||||
// check if the user is eligible to edit the SG (original creator or extend)
|
||||
$sharingGroup = $this->SharingGroup->find('first', array(
|
||||
'conditions' => Validation::uuid($id) ? ['SharingGroup.uuid' => $id] : ['SharingGroup.id' => $id],
|
||||
|
@ -441,7 +441,7 @@ class SharingGroupsController extends AppController
|
|||
$this->set('mayModify', $this->SharingGroup->checkIfAuthorisedExtend($this->Auth->user(), $sg['SharingGroup']['id']));
|
||||
$this->set('id', $sg['SharingGroup']['id']);
|
||||
$this->set('sg', $sg);
|
||||
$this->set('title_for_layout', __('Sharing Group %s', $sg['SharingGroup']['name']));
|
||||
$this->set('menuData', ['menuList' => 'globalActions', 'menuItem' => 'viewSG']);
|
||||
}
|
||||
|
||||
private function __initialiseSGQuickEdit($id, $request)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
echo isset($data['Organisation']['id']) ? $this->OrgImg->getNameWithImg($data) : __('Unknown');
|
|
@ -1,92 +1,106 @@
|
|||
<div class="roles view">
|
||||
<h2><?= __('Sharing Group %s', h($sg['SharingGroup']['name']));?></h2>
|
||||
<div class="row-fluid"><div class="span8" style="margin:0">
|
||||
<?php
|
||||
$tableData = [
|
||||
['key' => __('ID'), 'value' => $sg['SharingGroup']['id']],
|
||||
['key' => __('UUID'), 'value' => $sg['SharingGroup']['uuid'], 'value_class' => 'quickSelect'],
|
||||
['key' => __('Name'), 'value' => $sg['SharingGroup']['name']],
|
||||
['key' => __('Releasability'), 'value' => $sg['SharingGroup']['releasability']],
|
||||
['key' => __('Description'), 'value' => $sg['SharingGroup']['description']],
|
||||
['key' => __('Selectable'), 'boolean' => $sg['SharingGroup']['active']],
|
||||
|
||||
echo $this->element(
|
||||
'genericElements/SingleViews/single_view',
|
||||
[
|
||||
'key' => __('Created by'),
|
||||
'html' => isset($sg['Organisation']['id']) ? $this->OrgImg->getNameWithImg($sg) : __('Unknown'),
|
||||
],
|
||||
];
|
||||
if ($sg['SharingGroup']['sync_user_id']) {
|
||||
$tableData[] = [
|
||||
'key' => __('Synced by'),
|
||||
'html' => isset($sg['SharingGroup']['sync_org']) ? $this->OrgImg->getNameWithImg($sg['SharingGroup']['sync_org']) : __('Unknown'),
|
||||
];
|
||||
}
|
||||
$eventsLink = $baseurl . '/events/index/searchsharinggroup:' . $sg['SharingGroup']['id'];
|
||||
$tableData[] = [
|
||||
'key' => __('Events'),
|
||||
'html' => '<a href="' . $eventsLink . '">' . __n('%s event', '%s events', $sg['SharingGroup']['event_count'], $sg['SharingGroup']['event_count']) . '</a>',
|
||||
];
|
||||
if (isset($sg['SharingGroup']['org_count'])) {
|
||||
$tableData[] = [
|
||||
'key' => __('Organisations'),
|
||||
'html' => __n('%s organisation', '%s organisations', $sg['SharingGroup']['org_count'], $sg['SharingGroup']['org_count']),
|
||||
];
|
||||
}
|
||||
echo $this->element('genericElements/viewMetaTable', ['table_data' => $tableData]);
|
||||
?>
|
||||
</div></div>
|
||||
<br />
|
||||
<div class="row" style="width:100%;">
|
||||
<?php
|
||||
if (isset($sg['SharingGroupOrg'])):
|
||||
?>
|
||||
<div class="span6">
|
||||
<b><?php echo __('Organisations');?></b>
|
||||
<table class="table table-striped table-hover table-condensed">
|
||||
<tr>
|
||||
<th><?= __('Name') ?></th>
|
||||
<th><?= __('Is local') ?></th>
|
||||
<th><?= __('Can extend') ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($sg['SharingGroupOrg'] as $sgo):
|
||||
?>
|
||||
<tr>
|
||||
<td><?= $this->OrgImg->getNameWithImg($sgo) ?></td>
|
||||
<td><span class="<?= $sgo['Organisation']['local'] ? 'fas fa-check' : 'fas fa-times' ?>"></span></td>
|
||||
<td><span class="<?= $sgo['extend'] ? 'fas fa-check' : 'fas fa-times' ?>"></span></td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
if (!$sg['SharingGroup']['roaming'] && isset($sg['SharingGroupServer'])):
|
||||
?>
|
||||
<div class="span6">
|
||||
<b>Instances</b>
|
||||
<table class="table table-striped table-hover table-condensed">
|
||||
<tr>
|
||||
<th><?= __('Name') ?></th>
|
||||
<th><?= __('URL') ?></th>
|
||||
<th><?= __('All orgs') ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($sg['SharingGroupServer'] as $sgs): ?>
|
||||
<tr>
|
||||
<td><?= h($sgs['Server']['name']) ?></td>
|
||||
<td><?= h($sgs['Server']['url']) ?></td>
|
||||
<td><span class="<?= $sgs['all_orgs'] ? 'fas fa-check' : 'fas fa-times' ?>"></span></td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?= $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'globalActions', 'menuItem' => 'viewSG'));
|
||||
'title' => __('Sharing Group %s', $sg['SharingGroup']['name']),
|
||||
'data' => $sg,
|
||||
'fields' => [
|
||||
[
|
||||
'key' => __('ID'),
|
||||
'path' => 'SharingGroup.id'
|
||||
],
|
||||
[
|
||||
'key' => __('UUID'),
|
||||
'path' => 'SharingGroup.uuid'
|
||||
],
|
||||
[
|
||||
'key' => __('Name'),
|
||||
'path' => 'SharingGroup.name'
|
||||
],
|
||||
[
|
||||
'key' => __('Releasability'),
|
||||
'path' => 'SharingGroup.releasability'
|
||||
],
|
||||
[
|
||||
'key' => __('Description'),
|
||||
'path' => 'SharingGroup.description'
|
||||
],
|
||||
[
|
||||
'key' => __('Selectable'),
|
||||
'path' => 'SharingGroup.active',
|
||||
'type' => 'boolean'
|
||||
],
|
||||
[
|
||||
'key' => __('Created by'),
|
||||
'path' => 'Organisation',
|
||||
'type' => 'org'
|
||||
],
|
||||
[
|
||||
'key' => __('Synced by'),
|
||||
'path' => 'SharingGroup.sync_org',
|
||||
'type' => 'org',
|
||||
'requirement' => isset($sg['SharingGroup']['sync_org'])
|
||||
],
|
||||
[
|
||||
'key' => __('Events'),
|
||||
'raw' => __n('%s event', '%s events', $sg['SharingGroup']['event_count'], $sg['SharingGroup']['event_count']),
|
||||
'url' => sprintf('/events/index/searchsharinggroup:%s', h($sg['SharingGroup']['id']))
|
||||
],
|
||||
[
|
||||
'key' => __('Organisations'),
|
||||
'type' => 'custom',
|
||||
'function' => function ($sharingGroup) {
|
||||
echo sprintf(
|
||||
'<div class="span6">
|
||||
<table class="table table-striped table-hover table-condensed">
|
||||
<tr>
|
||||
<th>%s</th>
|
||||
<th>%s</th>
|
||||
<th>%s</th>
|
||||
</tr>',
|
||||
__('Name'),
|
||||
__('Is local'),
|
||||
__('Can extend')
|
||||
);
|
||||
foreach ($sharingGroup['SharingGroupOrg'] as $sgo) {
|
||||
echo '<tr>';
|
||||
echo sprintf('<td>%s</td>', $this->OrgImg->getNameWithImg($sgo));
|
||||
echo sprintf('<td><span class="%s"></span></td>', $sgo['Organisation']['local'] ? 'fas fa-check' : 'fas fa-times');
|
||||
echo sprintf('<td><span class="%s"></span></td>', $sgo['extend'] ? 'fas fa-check' : 'fas fa-times');
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</table>
|
||||
</div>';
|
||||
}
|
||||
],
|
||||
[
|
||||
'key' => __('Instances'),
|
||||
'type' => 'custom',
|
||||
'function' => function ($sharingGroup) {
|
||||
echo sprintf(
|
||||
'<div class="span6">
|
||||
<table class="table table-striped table-hover table-condensed">
|
||||
<tr>
|
||||
<th>%s</th>
|
||||
<th>%s</th>
|
||||
<th>%s</th>
|
||||
</tr>',
|
||||
__('Name'),
|
||||
__('URL'),
|
||||
__('All orgs')
|
||||
);
|
||||
foreach ($sharingGroup['SharingGroupServer'] as $sgs) {
|
||||
echo '<tr>';
|
||||
echo sprintf('<td>%s</td>', h($sgs['Server']['name']));
|
||||
echo sprintf('<td>%s</td>', h($sgs['Server']['url']));
|
||||
echo sprintf('<td><span class="%s"></span></td>', $sgs['all_orgs'] ? 'fas fa-check' : 'fas fa-times');
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</table>
|
||||
</div>';
|
||||
}
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue