From 4645e9b94b4ecbc350bb68167681eac3a253ad1c Mon Sep 17 00:00:00 2001 From: vdumas Date: Wed, 19 Apr 2023 16:34:49 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B06210=20-=20Avoid=20n:n=20duplicates=20on?= =?UTF-8?q?=20User-Profile=20and=20Trigger-Actions=20-=20uniqueness=20rule?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../userrightsprofile.class.inc.php | 11 ++++++++ core/trigger.class.inc.php | 27 +++++++++++++------ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/addons/userrights/userrightsprofile.class.inc.php b/addons/userrights/userrightsprofile.class.inc.php index 688978db5..610cb9183 100644 --- a/addons/userrights/userrightsprofile.class.inc.php +++ b/addons/userrights/userrightsprofile.class.inc.php @@ -228,6 +228,17 @@ class URP_UserProfile extends UserRightsBaseClassGUI "db_table" => "priv_urp_userprofile", "db_key_field" => "id", "db_finalclass_field" => "", + 'uniqueness_rules' => array( + 'no_duplicate' => array( + 'attributes' => array( + 0 => 'userid', + 1 => 'profileid', + ), + 'filter' => '', + 'disabled' => false, + 'is_blocking' => true, + ), + ), ); MetaModel::Init_Params($aParams); //MetaModel::Init_InheritAttributes(); diff --git a/core/trigger.class.inc.php b/core/trigger.class.inc.php index ae16a9ca0..dde325629 100644 --- a/core/trigger.class.inc.php +++ b/core/trigger.class.inc.php @@ -710,15 +710,26 @@ class lnkTriggerAction extends cmdbAbstractObject { $aParams = array ( - "category" => "grant_by_profile,core/cmdb,application", - "key_type" => "autoincrement", - "name_attcode" => "", - "state_attcode" => "", - "reconc_keys" => array('action_id', 'trigger_id'), - "db_table" => "priv_link_action_trigger", - "db_key_field" => "link_id", + "category" => "grant_by_profile,core/cmdb,application", + "key_type" => "autoincrement", + "name_attcode" => "", + "state_attcode" => "", + "reconc_keys" => array('action_id', 'trigger_id'), + "db_table" => "priv_link_action_trigger", + "db_key_field" => "link_id", "db_finalclass_field" => "", - "is_link" => true, + "is_link" => true, + 'uniqueness_rules' => array( + 'no_duplicate' => array( + 'attributes' => array( + 0 => 'action_id', + 1 => 'trigger_id', + ), + 'filter' => '', + 'disabled' => false, + 'is_blocking' => true, + ), + ), ); MetaModel::Init_Params($aParams); MetaModel::Init_AddAttribute(new AttributeExternalKey("action_id", array("targetclass" => "Action", "jointype" => '', "allowed_values" => null, "sql" => "action_id", "is_null_allowed" => false, "on_target_delete" => DEL_AUTO, "depends_on" => array())));