new: First implementation of the Noticelist system ready

pull/3233/head
iglocska 2018-05-07 10:43:21 +02:00
parent 13e407fd7c
commit 05cf0563e1
7 changed files with 91 additions and 3 deletions

View File

@ -368,6 +368,9 @@ class AttributesController extends AppController {
foreach ($distributionLevels as $key => $value) {
$info['distribution'][$key] = array('key' => $value, 'desc' => $this->Attribute->distributionDescriptions[$key]['formdesc']);
}
$this->loadModel('Noticelist');
$notice_list_triggers = $this->Noticelist->getTriggerData();
$this->set('notice_list_triggers', json_encode($notice_list_triggers, true));
$this->set('info', $info);
$this->set('typeDefinitions', $this->Attribute->typeDefinitions);
$this->set('categoryDefinitions', $this->Attribute->categoryDefinitions);
@ -937,6 +940,9 @@ class AttributesController extends AppController {
$this->set('categoryDefinitions', $categoryDefinitions);
$this->set('compositeTypes', $this->Attribute->getCompositeTypes());
$this->set('action', $this->action);
$this->loadModel('Noticelist');
$notice_list_triggers = $this->Noticelist->getTriggerData();
$this->set('notice_list_triggers', json_encode($notice_list_triggers, true));
$this->render('add');
}

View File

@ -213,6 +213,15 @@ class ACLComponent extends Component {
'delete' => array(),
'index' => array('*'),
),
'noticelists' => array(
'delete' => array(),
'enableNoticelist' => array(),
'getToggleField' => array(),
'index' => array('*'),
'toggleEnable' => array(),
'update' => array(),
'view' => array('*')
),
'objects' => array(
'add' => array('perm_add'),
'addValueField' => array('perm_add'),

View File

@ -955,7 +955,7 @@ class AppModel extends Model {
'email' => 'SYSTEM',
'action' => 'update_database',
'user_id' => 0,
'title' => 'Successfuly executed the SQL query for ' . $command,
'title' => 'Successfuly executed the SQL query for ' . $command,
'change' => 'The executed SQL query was: ' . $sql
));
} catch (Exception $e) {

View File

@ -90,4 +90,37 @@ class Noticelist extends AppModel{
return $this->validationErrors;
}
}
public function getTriggerData($scope = 'attribute') {
$noticelists = $this->find('all', array(
'conditions' => array('enabled' => 1),
'recursive' => -1,
'contain' => 'NoticelistEntry'
));
$noticelist_triggers = array();
$validTriggers = array(
'attribute' => array(
'category',
'type'
)
);
foreach ($noticelists as $noticelist) {
foreach ($noticelist['NoticelistEntry'] as $entry) {
if (in_array('attribute', $entry['data']['scope'])) {
foreach ($entry['data']['field'] as $data_field) {
if (in_array($data_field, $validTriggers[$scope])) {
foreach ($entry['data']['value'] as $value) {
$noticelist_triggers[$data_field][$value][] = array(
'message' => $entry['data']['message'],
'list_id' => $noticelist['Noticelist']['id'],
'list_name' => $noticelist['Noticelist']['name']
);
}
}
}
}
}
}
return $noticelist_triggers;
}
}

View File

@ -81,7 +81,7 @@
?>
</div>
</fieldset>
<p style="color:white;background-color:red;font-weight:bold;display:none;padding:5px;" id="warning-message"><?php echo __('Warning: You are about to share data that is of a classified nature. Make sure that you are authorised to share this.'); ?></p>
<p id="notice_message"><?php echo __('Warning: You are about to share data that is of a classified nature. Make sure that you are authorised to share this.'); ?></p>
<?php if ($ajax): ?>
<div class="overlay_spacing">
<span id="submitButton" class="btn btn-primary" style="margin-bottom:5px;float:left;" title="<?php echo __('Submit'); ?>" role="button" tabindex="0" aria-label="<?php echo __('Submit'); ?>" onClick="submitPopoverForm('<?php echo $action == 'add' ? $event_id : $attribute['Attribute']['id'];?>', '<?php echo $action; ?>')"><?php echo __('Submit'); ?></span>
@ -104,6 +104,7 @@
}
?>
<script type="text/javascript">
var notice_list_triggers = <?php echo $notice_list_triggers; ?>;
var fieldsArray = new Array('AttributeCategory', 'AttributeType', 'AttributeValue', 'AttributeDistribution', 'AttributeComment', 'AttributeToIds', 'AttributeBatchImport', 'AttributeSharingGroupId');
<?php
$formInfoTypes = array('distribution' => 'Distribution', 'category' => 'Category', 'type' => 'Type');
@ -137,6 +138,13 @@ var category_type_mapping = new Array();
var composite_types = <?php echo json_encode($compositeTypes); ?>;
$(document).ready(function() {
<?php
if ($action == 'edit'):
?>
checkNoticeList('attribute');
<?php
endif;
?>
initPopoverContent('Attribute');
$('#AttributeDistribution').change(function() {
if ($('#AttributeDistribution').val() == 4) $('#SGContainer').show();
@ -156,6 +164,10 @@ $(document).ready(function() {
}
});
$("#AttributeCategory, #AttributeType").change(function() {
checkNoticeList('attribute');
});
$("#AttributeCategory, #AttributeType, #AttributeDistribution").change(function() {
var start = $("#AttributeType").val();
initPopoverContent('Attribute');

View File

@ -76,6 +76,7 @@
<li><a href="<?php echo $baseurl;?>/whitelists/index">Signature Whitelist</a></li>
<?php endif;?>
<li><a href="<?php echo $baseurl;?>/warninglists/index">List Warninglists</a></li>
<li><a href="<?php echo $baseurl;?>/noticelists/index">List Noticelists</a></li>
</ul>
</li>
@ -212,4 +213,4 @@
</div>
</div>
</div>
<input type="hidden" class="keyboardShortcutsConfig" value="/shortcuts/global_menu.json" />
<input type="hidden" class="keyboardShortcutsConfig" value="/shortcuts/global_menu.json" />

View File

@ -3329,6 +3329,33 @@ $('.quickToggleCheckbox').toggle(function() {
var url = $(this).data('checkbox-url');
});
function checkNoticeList(type) {
var fields_to_check = {
"attribute": ["category", "type"]
}
var warnings = [];
$('#notice_message').html('<h4>Notices:</h4>');
$('#notice_message').hide();
fields_to_check[type].forEach(function(field_name) {
if (field_name in notice_list_triggers) {
var field_value = $('#' + type.ucfirst() + field_name.ucfirst()).val();
if (field_value in notice_list_triggers[field_name]) {
notice_list_triggers[field_name][field_value].forEach(function(notice) {
$('#notice_message').show();
$('#notice_message').append(
$('<div/>')
.append($('<span/>').text('['))
.append($('<a/>', {href: '/noticelists/view/' + notice['list_id'], class:'bold'}).text(notice['list_name']))
.append($('<span/>').text(']: '))
.append($('<span/>').text(notice['message']['en']))
);
});
}
}
});
}
$(document).ready(function() {
$(".correlation-expand-button").on("click", function() {
$(this).parent().children(".correlation-expanded-area").show();