From 583bd2a5dfb3e7006ac0b3a56523e7d7fa149ee8 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 17 Jan 2016 23:53:39 +0000 Subject: [PATCH] CRM-14901 Add in entity_table whitelists for uf_join, entity_tag, mailing_group and note --- CRM/Core/BAO/Note.php | 15 +++++++++++++++ CRM/Core/BAO/UFJoin.php | 13 +++++++++++++ CRM/Mailing/BAO/Mailing.php | 13 +++++++++++++ xml/schema/Core/EntityTag.xml | 3 +++ xml/schema/Core/Note.xml | 3 +++ xml/schema/Core/UFJoin.xml | 1 + xml/schema/Mailing/MailingGroup.xml | 1 + 7 files changed, 49 insertions(+) diff --git a/CRM/Core/BAO/Note.php b/CRM/Core/BAO/Note.php index ef7dff898c..da068241b6 100644 --- a/CRM/Core/BAO/Note.php +++ b/CRM/Core/BAO/Note.php @@ -574,4 +574,19 @@ WHERE participant.contact_id = %1 AND note.entity_table = 'civicrm_participant' } } + /** + * Whitelist of possible values for the entity_table field + * @return array + */ + public static function entityTables() { + $tables = array( + 'civicrm_relationship', + 'civicrm_contact', + 'civicrm_participant', + 'civicrm_contribution', + ); + // Identical keys & values + return array_combine($tables, $tables); + } + } diff --git a/CRM/Core/BAO/UFJoin.php b/CRM/Core/BAO/UFJoin.php index ba9dbf3fa2..92bd4cf9cd 100644 --- a/CRM/Core/BAO/UFJoin.php +++ b/CRM/Core/BAO/UFJoin.php @@ -180,4 +180,17 @@ class CRM_Core_BAO_UFJoin extends CRM_Core_DAO_UFJoin { return array($first, $second, $firstActive, $secondActive); } + /** + * Whitelist of possible values for the entity_table field + * @return array + */ + public static function entityTables() { + $tables = array( + 'civicrm_event', + 'civicrm_contribution_page', + ); + // Identical keys & values + return array_combine($tables, $tables); + } + } diff --git a/CRM/Mailing/BAO/Mailing.php b/CRM/Mailing/BAO/Mailing.php index 31fd72c736..7c3eff86f5 100644 --- a/CRM/Mailing/BAO/Mailing.php +++ b/CRM/Mailing/BAO/Mailing.php @@ -3133,4 +3133,17 @@ AND m.id = %1 return $fieldPerms; } + /** + * Whitelist of possible values for the entity_table field + * @return array + */ + public static function mailingGroupEntityTables() { + $tables = array( + 'civicrm_group', + 'civicrm_mailing', + ); + // Identical keys & values + return array_combine($tables, $tables); + } + } diff --git a/xml/schema/Core/EntityTag.xml b/xml/schema/Core/EntityTag.xml index 0539e4ed7e..1f3543dcf0 100644 --- a/xml/schema/Core/EntityTag.xml +++ b/xml/schema/Core/EntityTag.xml @@ -40,6 +40,9 @@ Entity Table 64 physical tablename for entity being joined to file, e.g. civicrm_contact + + tag_used_for + 3.2 diff --git a/xml/schema/Core/Note.xml b/xml/schema/Core/Note.xml index 128da7796e..b6e60dfb17 100644 --- a/xml/schema/Core/Note.xml +++ b/xml/schema/Core/Note.xml @@ -26,6 +26,9 @@ 64 true Name of table where item being referenced is stored. + + CRM_Core_BAO_Note::entityTables + 1.1 diff --git a/xml/schema/Core/UFJoin.xml b/xml/schema/Core/UFJoin.xml index c3add7f136..86e447825b 100644 --- a/xml/schema/Core/UFJoin.xml +++ b/xml/schema/Core/UFJoin.xml @@ -42,6 +42,7 @@ varchar 64 Name of table where item being referenced is stored. Modules which only need a single collection of uf_join instances may choose not to populate entity_table and entity_id. + CRM_Core_BAO_UFJoin::entityTables 1.3 diff --git a/xml/schema/Mailing/MailingGroup.xml b/xml/schema/Mailing/MailingGroup.xml index 3bb7ec4fa6..7e586e859d 100644 --- a/xml/schema/Mailing/MailingGroup.xml +++ b/xml/schema/Mailing/MailingGroup.xml @@ -49,6 +49,7 @@ 64 true Name of table where item being referenced is stored. + CRM_Mailing_BAO_Mailing::mailingGroupEntityTables entity_id -- 2.25.1