mirror of https://github.com/MISP/MISP
chg: [UI] Optimise loading contributors orgs
parent
166ea74093
commit
72d0b873c8
|
@ -1276,6 +1276,7 @@ class EventsController extends AppController
|
|||
$this->set('object_count', $objectCount);
|
||||
// set the data for the contributors / history field
|
||||
$contributors = $this->Event->ShadowAttribute->getEventContributors($event['Event']['id']);
|
||||
$this->set('contributors', $contributors);
|
||||
if ($this->userRole['perm_publish'] && $event['Event']['orgc_id'] == $this->Auth->user('org_id')) {
|
||||
$proposalStatus = false;
|
||||
if (isset($event['ShadowAttribute']) && !empty($event['ShadowAttribute'])) {
|
||||
|
@ -1474,7 +1475,6 @@ class EventsController extends AppController
|
|||
$cortex_modules = $this->Module->getEnabledModules($this->Auth->user(), false, 'Cortex');
|
||||
$this->set('cortex_modules', $cortex_modules);
|
||||
}
|
||||
$this->set('contributors', $contributors);
|
||||
$this->set('typeGroups', array_keys($this->Event->Attribute->typeGroupings));
|
||||
$attributeUri = $this->baseurl . '/events/viewEventAttributes/' . $event['Event']['id'];
|
||||
foreach ($this->params->named as $k => $v) {
|
||||
|
|
|
@ -471,22 +471,29 @@ class ShadowAttribute extends AppModel
|
|||
}
|
||||
}
|
||||
|
||||
public function getEventContributors($id)
|
||||
/**
|
||||
* @param int $eventId
|
||||
* @return array Key is organisation ID, value is an organisation name
|
||||
*/
|
||||
public function getEventContributors($eventId)
|
||||
{
|
||||
$orgs = $this->find('all', array('fields' => array(
|
||||
'DISTINCT(ShadowAttribute.org_id)'),
|
||||
'conditions' => array('event_id' => $id),
|
||||
$orgs = $this->find('all', array(
|
||||
'fields' => array('DISTINCT(ShadowAttribute.org_id)'),
|
||||
'conditions' => array('event_id' => $eventId),
|
||||
'recursive' => -1,
|
||||
'order' => false
|
||||
));
|
||||
$org_ids = array();
|
||||
$this->Organisation = ClassRegistry::init('Organisation');
|
||||
foreach ($orgs as $org) {
|
||||
$org_ids[] = $this->Organisation->find('first', array('recursive' => -1, 'fields' => array('id', 'name'), 'conditions' => array('Organisation.id' => $org['ShadowAttribute']['org_id'])));
|
||||
if (empty($orgs)) {
|
||||
return [];
|
||||
}
|
||||
return $org_ids;
|
||||
}
|
||||
|
||||
$this->Organisation = ClassRegistry::init('Organisation');
|
||||
return $this->Organisation->find('list', array(
|
||||
'recursive' => -1,
|
||||
'fields' => array('id', 'name'),
|
||||
'conditions' => array('Organisation.id' => Hash::extract($orgs, "{n}.ShadowAttribute.org_id")))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an email to members of the organization that owns the event
|
||||
|
|
|
@ -75,11 +75,11 @@
|
|||
}
|
||||
if (!empty($contributors)) {
|
||||
$contributorsContent = '';
|
||||
foreach ($contributors as $k => $entry) {
|
||||
foreach ($contributors as $organisationId => $name) {
|
||||
$contributorsContent .= sprintf(
|
||||
'<a href="%s" style="margin-right:2px;text-decoration: none;">%s</a>',
|
||||
$baseurl . "/logs/event_index/" . $event['Event']['id'] . '/' . h($entry['Organisation']['name']),
|
||||
$this->OrgImg->getOrgImg(array('name' => $entry['Organisation']['name'], 'id' => $entry['Organisation']['id'], 'size' => 24), true, true)
|
||||
'<a href="%s">%s</a>',
|
||||
$baseurl . "/logs/event_index/" . $event['Event']['id'] . '/' . h($name),
|
||||
$this->OrgImg->getOrgImg(array('name' => $name, 'id' => $organisationId, 'size' => 24), true, true)
|
||||
);
|
||||
}
|
||||
$table_data[] = array(
|
||||
|
|
Loading…
Reference in New Issue