diff --git a/app/Controller/ServersController.php b/app/Controller/ServersController.php index f53977c0c..b3fa2a53b 100644 --- a/app/Controller/ServersController.php +++ b/app/Controller/ServersController.php @@ -308,7 +308,8 @@ class ServersController extends AppController 'json' => '[]', 'push_rules' => '[]', 'pull_rules' => '[]', - 'self_signed' => 0 + 'self_signed' => 0, + 'remove_missing_tags' => 0 ); foreach ($defaults as $default => $dvalue) { if (!isset($this->request->data['Server'][$default])) { @@ -492,7 +493,7 @@ class ServersController extends AppController } if (!$fail) { // say what fields are to be updated - $fieldList = array('id', 'url', 'push', 'pull', 'push_sightings', 'push_galaxy_clusters', 'pull_galaxy_clusters', 'caching_enabled', 'unpublish_event', 'publish_without_email', 'remote_org_id', 'name' ,'self_signed', 'cert_file', 'client_cert_file', 'push_rules', 'pull_rules', 'internal', 'skip_proxy'); + $fieldList = array('id', 'url', 'push', 'pull', 'push_sightings', 'push_galaxy_clusters', 'pull_galaxy_clusters', 'caching_enabled', 'unpublish_event', 'publish_without_email', 'remote_org_id', 'name' ,'self_signed', 'remove_missing_tags', 'cert_file', 'client_cert_file', 'push_rules', 'pull_rules', 'internal', 'skip_proxy'); $this->request->data['Server']['id'] = $id; if (isset($this->request->data['Server']['authkey']) && "" != $this->request->data['Server']['authkey']) { $fieldList[] = 'authkey'; diff --git a/app/Model/AppModel.php b/app/Model/AppModel.php index 2a1738f27..71dafaf07 100644 --- a/app/Model/AppModel.php +++ b/app/Model/AppModel.php @@ -90,7 +90,7 @@ class AppModel extends Model 51 => false, 52 => false, 53 => false, 54 => false, 55 => false, 56 => false, 57 => false, 58 => false, 59 => false, 60 => false, 61 => false, 62 => false, 63 => true, 64 => false, 65 => false, 66 => false, 67 => false, 68 => false, - 69 => false, 70 => false, + 69 => false, 70 => false, 71 => false ); public $advanced_updates_description = array( @@ -1603,6 +1603,9 @@ class AppModel extends Model case 70: $sqlArray[] = "ALTER TABLE `galaxies` ADD `enabled` tinyint(1) NOT NULL DEFAULT 1 AFTER `namespace`;"; break; + case 71: + $sqlArray[] = "ALTER TABLE `servers` ADD `remove_missing_tags` tinyint(1) NOT NULL DEFAULT 0 AFTER `skip_proxy`;"; + break; case 'fixNonEmptySharingGroupID': $sqlArray[] = 'UPDATE `events` SET `sharing_group_id` = 0 WHERE `distribution` != 4;'; $sqlArray[] = 'UPDATE `attributes` SET `sharing_group_id` = 0 WHERE `distribution` != 4;'; diff --git a/app/Model/Attribute.php b/app/Model/Attribute.php index c3798e51e..5504a0d14 100644 --- a/app/Model/Attribute.php +++ b/app/Model/Attribute.php @@ -3685,7 +3685,7 @@ class Attribute extends AppModel return $attribute; } - public function editAttribute($attribute, $eventId, $user, $objectId, $log = false, $force = false, &$nothingToChange = false) + public function editAttribute($attribute, $eventId, $user, $objectId, $log = false, $force = false, &$nothingToChange = false, $server = null) { $attribute['event_id'] = $eventId; $attribute['object_id'] = $objectId; @@ -3805,11 +3805,13 @@ class Attribute extends AppModel } if ($user['Role']['perm_tagger']) { /* - We should uncomment the line below in the future once we have tag soft-delete + We should unwrap the line below and remove the server option in the future once we have tag soft-delete A solution to still keep the behavior for previous instance could be to not soft-delete the Tag if the remote instance has a version below x */ - // $this->AttributeTag->pruneOutdatedAttributeTagsFromSync(isset($attribute['Tag']) ? $attribute['Tag'] : array(), $existingAttribute['AttributeTag']); + if (isset($server) && $server['Server']['remove_missing_tags']) { + $this->AttributeTag->pruneOutdatedAttributeTagsFromSync(isset($attribute['Tag']) ? $attribute['Tag'] : array(), $existingAttribute['AttributeTag']); + } if (isset($attribute['Tag'])) { foreach ($attribute['Tag'] as $tag) { $tag_id = $this->AttributeTag->Tag->captureTag($tag, $user); diff --git a/app/Model/Event.php b/app/Model/Event.php index 112bdb73e..507780cc2 100755 --- a/app/Model/Event.php +++ b/app/Model/Event.php @@ -4031,6 +4031,7 @@ class Event extends AppModel 'Server.unpublish_event', 'Server.publish_without_email', 'Server.internal', + 'Server.remove_missing_tags' ) )); } else { @@ -4129,7 +4130,7 @@ class Event extends AppModel $data['Event']['Attribute'] = array_values($data['Event']['Attribute']); foreach ($data['Event']['Attribute'] as $k => $attribute) { $nothingToChange = false; - $result = $this->Attribute->editAttribute($attribute, $this->id, $user, 0, $this->Log, $force, $nothingToChange); + $result = $this->Attribute->editAttribute($attribute, $this->id, $user, 0, $this->Log, $force, $nothingToChange, $server); if ($result !== true) { $validationErrors['Attribute'][] = $result; } diff --git a/app/View/Servers/edit.ctp b/app/View/Servers/edit.ctp index fd32d727d..7c7f6c504 100644 --- a/app/View/Servers/edit.ctp +++ b/app/View/Servers/edit.ctp @@ -103,6 +103,10 @@ )); echo '
'; echo $this->Form->input('skip_proxy', array('type' => 'checkbox', 'label' => 'Skip proxy (if applicable)')); + echo '
'; + echo $this->Form->input('remove_missing_tags', array( + 'type' => 'checkbox', + )); ?>

@@ -236,7 +240,8 @@ var formInfoValues = { 'ServerPublishWithoutEmail' : '', 'ServerSubmittedCert' : "", 'ServerSubmittedClientCert' : "", - 'ServerSelfSigned' : "" + 'ServerSelfSigned' : "", + 'ServerRemoveMissingTags': "" }; var rules = { @@ -264,11 +269,11 @@ $(document).ready(function() { serverOrgTypeChange(); }); - $("#ServerUrl, #ServerOrganization, #ServerName, #ServerAuthkey, #ServerPush, #ServerPull, #ServerUnpublishEvent, #ServerPublishWithoutEmail, #ServerSubmittedCert, #ServerSubmittedClientCert, #ServerSelfSigned").on('mouseleave', function(e) { + $("#ServerUrl, #ServerOrganization, #ServerName, #ServerAuthkey, #ServerPush, #ServerPull, #ServerUnpublishEvent, #ServerPublishWithoutEmail, #ServerSubmittedCert, #ServerSubmittedClientCert, #ServerSelfSigned, #ServerRemoveMissingTags").on('mouseleave', function(e) { $('#'+e.currentTarget.id).popover('destroy'); }); - $("#ServerUrl, #ServerOrganization, #ServerName, #ServerAuthkey, #ServerPush, #ServerPull, #ServerUnpublishEvent, #ServerPublishWithoutEmail, #ServerSubmittedCert, #ServerSubmittedClientCert, #ServerSelfSigned").on('mouseover', function(e) { + $("#ServerUrl, #ServerOrganization, #ServerName, #ServerAuthkey, #ServerPush, #ServerPull, #ServerUnpublishEvent, #ServerPublishWithoutEmail, #ServerSubmittedCert, #ServerSubmittedClientCert, #ServerSelfSigned, #ServerRemoveMissingTags").on('mouseover', function(e) { var $e = $(e.target); $('#'+e.currentTarget.id).popover('destroy'); $('#'+e.currentTarget.id).popover({ diff --git a/db_schema.json b/db_schema.json index f9888d44d..17c484c17 100644 --- a/db_schema.json +++ b/db_schema.json @@ -5225,6 +5225,17 @@ "column_default": null, "extra": "" }, + { + "column_name": "remove_missing_tags", + "is_nullable": "NO", + "data_type": "tinyint", + "character_maximum_length": null, + "numeric_precision": "3", + "collation_name": null, + "column_type": "tinyint(1)", + "column_default": "0", + "extra": "" + }, { "column_name": "pull_rules", "is_nullable": "NO", @@ -8169,5 +8180,5 @@ "id": true } }, - "db_version": "70" + "db_version": "71" }