From 62a20a2321f4ff9114c94c8ea42b7a247d5fa9a3 Mon Sep 17 00:00:00 2001 From: Iglocska Date: Thu, 7 Jan 2016 16:33:35 +0100 Subject: [PATCH] Fixed an issue where an event's sharing group ID would get set to the first available option even when a non sharing group distribution level is selected --- VERSION.json | 2 +- app/Model/AppModel.php | 5 ++++- app/Model/Attribute.php | 2 ++ app/Model/Event.php | 2 ++ app/View/Pages/administration.ctp | 1 + 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/VERSION.json b/VERSION.json index 6a22af108..c5a768b9c 100644 --- a/VERSION.json +++ b/VERSION.json @@ -1 +1 @@ -{"major":2, "minor":4, "hotfix":5} +{"major":2, "minor":4, "hotfix":6} diff --git a/app/Model/AppModel.php b/app/Model/AppModel.php index 83726dda9..788d92a5c 100755 --- a/app/Model/AppModel.php +++ b/app/Model/AppModel.php @@ -163,7 +163,10 @@ class AppModel extends Model { } } 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'; + break; default: return false; break; diff --git a/app/Model/Attribute.php b/app/Model/Attribute.php index bef869c0d..346c84961 100755 --- a/app/Model/Attribute.php +++ b/app/Model/Attribute.php @@ -518,6 +518,8 @@ class Attribute extends AppModel { $this->data['Attribute']['value'] = $result; } // always return true, otherwise the object cannot be saved + + if (!isset($this->data['Attribute']['distribution']) || $this->data['Attribute']['distribution'] != 4) $this->data['Attribute']['sharing_group_id'] = 0; return true; } diff --git a/app/Model/Event.php b/app/Model/Event.php index 2b1bfd0ac..f5bcf9b34 100755 --- a/app/Model/Event.php +++ b/app/Model/Event.php @@ -409,6 +409,8 @@ class Event extends AppModel { if (empty($this->data['Event']['date'])) { $this->data['Event']['date'] = date('Y-m-d'); } + + if (!isset($this->data['Event']['distribution']) || $this->data['Event']['distribution'] != 4) $this->data['Event']['sharing_group_id'] = 0; } public function isOwnedByOrg($eventid, $org) { diff --git a/app/View/Pages/administration.ctp b/app/View/Pages/administration.ctp index d0f961a6d..82cd4d330 100644 --- a/app/View/Pages/administration.ctp +++ b/app/View/Pages/administration.ctp @@ -24,6 +24,7 @@ if (!$isSiteAdmin) exit();
  • Form->postLink('Upgrade to 2.4', $baseurl . '/servers/upgrade2324');?> (This script will make the final changes to the database to bring it up to speed with 2.4)
  • Form->postLink('BETA UPDATES', $baseurl . '/servers/updateDatabase/24betaupdates');?> (This script will update your db from an earlier version of the beta)
  • Form->postLink('Index tables', $baseurl . '/servers/updateDatabase/indexTables');?> (This script will create indeces for all of the tables in MISP (other than primary keys))
  • +
  • Form->postLink('Fix non-empty sharing group IDs', $baseurl . '/servers/updateDatabase/fixNonEmptySharingGroupID');?> (This script will change the sharing_group_id to 0 in all non sharing group setting events and attributes))