mirror of https://github.com/MISP/MISP
chg: [analyst-data:edit] Added support of editable fields
parent
76e61d3e26
commit
224415c3b4
|
@ -80,6 +80,7 @@ class AnalystDataController extends AppController
|
|||
$this->set('id', $id);
|
||||
$conditions = $this->AnalystData->buildConditions($this->Auth->user());
|
||||
$params = [
|
||||
'fields' => $this->AnalystData->getEditableFields(),
|
||||
'conditions' => $conditions,
|
||||
'afterFind' => function(array $analystData): array {
|
||||
$canEdit = $this->ACL->canEditAnalystData($this->Auth->user(), $analystData, $this->modelSelection);
|
||||
|
|
|
@ -36,6 +36,15 @@ class AnalystData extends AppModel
|
|||
'Relationship',
|
||||
];
|
||||
|
||||
protected const BASE_EDITABLE_FIELDS = [
|
||||
'language',
|
||||
'authors',
|
||||
'modified',
|
||||
'distribution',
|
||||
'sharing_group_id',
|
||||
];
|
||||
protected $EDITABLE_FIELDS = [];
|
||||
|
||||
/** @var object|null */
|
||||
protected $Note;
|
||||
/** @var object|null */
|
||||
|
@ -156,6 +165,11 @@ class AnalystData extends AppModel
|
|||
return true;
|
||||
}
|
||||
|
||||
public function getEditableFields(): array
|
||||
{
|
||||
return array_merge(self::BASE_EDITABLE_FIELDS, $this->EDITABLE_FIELDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can modify given analyst data
|
||||
*
|
||||
|
|
|
@ -15,8 +15,11 @@ class Note extends AnalystData
|
|||
public $current_type = 'Note';
|
||||
public $current_type_id = 0;
|
||||
|
||||
public $validate = array(
|
||||
);
|
||||
public const EDITABLE_FIELDS = [
|
||||
'note',
|
||||
];
|
||||
|
||||
public $validate = [];
|
||||
|
||||
public function beforeValidate($options = array())
|
||||
{
|
||||
|
|
|
@ -15,8 +15,12 @@ class Opinion extends AnalystData
|
|||
public $current_type = 'Opinion';
|
||||
public $current_type_id = 1;
|
||||
|
||||
public $validate = array(
|
||||
);
|
||||
public const EDITABLE_FIELDS = [
|
||||
'opinion',
|
||||
'comment',
|
||||
];
|
||||
|
||||
public $validate = [];
|
||||
|
||||
public function beforeValidate($options = array())
|
||||
{
|
||||
|
|
|
@ -15,8 +15,11 @@ class Relationship extends AnalystData
|
|||
public $current_type = 'Relationship';
|
||||
public $current_type_id = 2;
|
||||
|
||||
public $validate = array(
|
||||
);
|
||||
protected $EDITABLE_FIELDS = [
|
||||
'relationship_type',
|
||||
];
|
||||
|
||||
public $validate = [];
|
||||
|
||||
/** @var object|null */
|
||||
protected $Event;
|
||||
|
|
|
@ -89,10 +89,12 @@ if ($modelSelection === 'Note') {
|
|||
'options' => $dropdownData['valid_targets'],
|
||||
'type' => 'dropdown',
|
||||
'stayInLine' => 1,
|
||||
'disabled' => !empty($this->data[$modelSelection]['related_object_type']),
|
||||
],
|
||||
[
|
||||
'field' => 'related_object_uuid',
|
||||
'class' => 'span4',
|
||||
'disabled' => !empty($this->data[$modelSelection]['related_object_uuid']),
|
||||
],
|
||||
sprintf('<div style="max-width: 960px;"><label>%s:</label><div id="related-object-container">%s</div></div>', __('Related Object'), __('- No UUID provided -'))
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue