fix: Various fixes to the feed system

- allow users to override the IDS flags and keep all attributes pulled from a freetext feed IDS = off
- UI changes
- fix to a bug that caused already deleted attributes to be counted as existing ones
pull/1580/merge
Iglocska 2016-10-07 18:27:13 +02:00
parent a6cb34e4a3
commit 9649c608b4
6 changed files with 46 additions and 25 deletions

View File

@ -87,7 +87,7 @@ class FeedsController extends AppController {
}
}
$this->request->data['Feed']['event_id'] = $this->request->data['Feed']['fixed_event'] ? $this->request->data['Feed']['target_event'] : 0;
$fields = array('id', 'name', 'provider', 'enabled', 'rules', 'url', 'distribution', 'sharing_group_id', 'tag_id', 'fixed_event', 'event_id', 'publish', 'delta_merge');
$fields = array('id', 'name', 'provider', 'enabled', 'rules', 'url', 'distribution', 'sharing_group_id', 'tag_id', 'fixed_event', 'event_id', 'publish', 'delta_merge', 'override_ids');
$feed = array();
foreach ($fields as $field) $feed[$field] = $this->request->data['Feed'][$field];
$result = $this->Feed->save($feed);

View File

@ -439,6 +439,7 @@ class AppModel extends Model {
$sqlArray[] = 'ALTER TABLE feeds ADD delta_merge tinyint(1) NOT NULL DEFAULT 0;';
$sqlArray[] = 'ALTER TABLE feeds ADD event_id int(11) NOT NULL DEFAULT 0;';
$sqlArray[] = 'ALTER TABLE feeds ADD publish tinyint(1) NOT NULL DEFAULT 0;';
$sqlArray[] = 'ALTER TABLE feeds ADD override_ids tinyint(1) NOT NULL DEFAULT 0;';
$sqlArray[] = "ALTER TABLE feeds ADD settings text NOT NULL DEFAULT '';";
break;
case 'fixNonEmptySharingGroupID':

View File

@ -444,7 +444,7 @@ class Feed extends AppModel {
}
}
if ($feed['Feed']['fixed_event'] && $feed['Feed']['delta_merge']) {
$event = $this->Event->find('first', array('conditions' => array('Event.id' => $event['Event']['id']), 'recursive' => -1, 'contain' => array('Attribute')));
$event = $this->Event->find('first', array('conditions' => array('Event.id' => $event['Event']['id']), 'recursive' => -1, 'contain' => array('Attribute' => array('conditions' => array('Attribute.deleted' => 0)))));
$to_delete = array();
foreach ($data as $k => $dataPoint) {
foreach ($event['Attribute'] as $attribute_key => $attribute) {
@ -465,6 +465,7 @@ class Feed extends AppModel {
$data[$key]['event_id'] = $event['Event']['id'];
$data[$key]['distribution'] = $feed['Feed']['distribution'];
$data[$key]['sharing_group_id'] = $feed['Feed']['sharing_group_id'];
$data[$key]['to_ids'] = $feed['Feed']['override_ids'] ? 0 : $data[$key]['to_ids'];
}
if (!$this->Event->Attribute->saveMany($data)) {
return 'Could not save the parsed attributes.';

View File

@ -57,6 +57,16 @@
));
?>
</div>
<div id="OverrideIdsDiv" class="input clear">
<?php
echo $this->Form->input('override_ids', array(
'label' => 'Override IDS Flag',
'title' => 'If checked, the IDS flags will always be set to off when pulling from this feed',
'type' => 'checkbox',
'class' => 'form-control'
));
?>
</div>
<div id="DeltaMergeDiv" class="input clear">
<?php
echo $this->Form->input('delta_merge', array(
@ -140,8 +150,11 @@ function feedFormUpdate() {
$('#TargetDiv').hide();
$('#TargetEventDiv').hide();
$('#PublishDiv').hide();
$('#OverrideIdsDiv').hide();
$('#DeltaMergeDiv').hide();
} else if ($('#FeedSourceFormat').val() == 'freetext') {
$('#TargetDiv').show();
$('#OverrideIdsDiv').show();
$('#PublishDiv').show();
if ($('#FeedTarget').val() == 0) {
$('#TargetEventDiv').hide();

View File

@ -56,6 +56,16 @@
));
?>
</div>
<div id="OverrideIdsDiv" class="input clear">
<?php
echo $this->Form->input('override_ids', array(
'label' => 'Override IDS Flag',
'title' => 'If checked, the IDS flags will always be set to off when pulling from this feed',
'type' => 'checkbox',
'class' => 'form-control'
));
?>
</div>
<div id="DeltaMergeDiv" class="input clear">
<?php
echo $this->Form->input('delta_merge', array(
@ -149,10 +159,12 @@ function feedFormUpdate() {
$('#TargetDiv').hide();
$('#TargetEventDiv').hide();
$('#PublishDiv').hide();
$('#OverrideIdsDiv').hide();
} else if ($('#FeedSourceFormat').val() == 'freetext') {
$('#TargetDiv').show();
$('#OverrideIdsDiv').show();
$('#PublishDiv').show();
if ($('#FeedFixedEvent').val() == 0) {
if ($('#FeedTarget').val() == 0) {
$('#TargetEventDiv').hide();
$('#DeltaMergeDiv').hide();
} else {

View File

@ -26,6 +26,7 @@
<th>Target</th>
<th>Publish</th>
<th>Delta Merge</th>
<th>Override IDS</th>
<th><?php echo $this->Paginator->sort('distribution');?></th>
<th><?php echo $this->Paginator->sort('tag');?></th>
<th><?php echo $this->Paginator->sort('enabled');?></th>
@ -85,28 +86,21 @@ foreach ($feeds as $item):
endif;
?>
</td>
<td>
<?php
if ($item['Feed']['source_format'] == 'freetext'):
?>
<span class="<?php echo ($item['Feed']['publish'] ? 'icon-ok' : 'icon-remove'); ?>"></span>
<?php
else:
echo ' ';
endif;
?>
</td>
<td>
<?php
if ($item['Feed']['source_format'] == 'freetext'):
?>
<span class="<?php echo ($item['Feed']['delta_merge'] ? 'icon-ok' : 'icon-remove'); ?>"></span>
<?php
else:
echo ' ';
endif;
?>
</td>
<?php
if ($item['Feed']['source_format'] == 'freetext'):
?>
<td><span class="<?php echo ($item['Feed']['publish'] ? 'icon-ok' : 'icon-remove'); ?>"></span></td>
<td><span class="<?php echo ($item['Feed']['delta_merge'] ? 'icon-ok' : 'icon-remove'); ?>"></span></td>
<td><span class="<?php echo ($item['Feed']['override_ids'] ? 'icon-ok' : 'icon-remove'); ?>"></span></td>
<?php
else:
?>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<?php
endif;
?>
<td <?php if ($item['Feed']['distribution'] == 0) echo 'class="red"'; ?>>
<?php
echo $item['Feed']['distribution'] == 4 ? '<a href="' . $baseurl . '/sharing_groups/view/' . h($item['SharingGroup']['id']) . '">' . h($item['SharingGroup']['name']) . '</a>' : $distributionLevels[$item['Feed']['distribution']] ;