From da2dec3a159c38d27c87c85822381b831e153d97 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 26 Feb 2018 17:15:50 +1300 Subject: [PATCH] Enable custom data on PaymentProcessorType and note entities --- CRM/Core/BAO/Note.php | 15 ++++++++------- api/v3/PaymentProcessorType.php | 12 +----------- tests/phpunit/api/v3/SyntaxConformanceTest.php | 2 -- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/CRM/Core/BAO/Note.php b/CRM/Core/BAO/Note.php index feeff4f213..3457c4e08d 100644 --- a/CRM/Core/BAO/Note.php +++ b/CRM/Core/BAO/Note.php @@ -133,9 +133,9 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note { * (reference) an assoc array of name/value pairs. * @param array $ids * (deprecated) associated array with note id - preferably set $params['id']. - * - * @return object|null + * @return null|object $note * $note CRM_Core_BAO_Note object + * @throws \CRM_Exception */ public static function add(&$params, $ids = array()) { $dataExists = self::dataExists($params); @@ -161,7 +161,7 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note { $note->copyValues($params); if (empty($params['contact_id'])) { - if ($params['entity_table'] == 'civicrm_contact') { + if (CRM_Utils_Array::value('entity_table', $params) == 'civicrm_contact') { $note->contact_id = $params['entity_id']; } } @@ -183,9 +183,10 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note { $displayName = CRM_Contact_BAO_Contact::displayName($note->entity_id); $noteActions = FALSE; - $session = CRM_Core_Session::singleton(); - if ($session->get('userID')) { - if ($session->get('userID') == $note->entity_id) { + + $loggedInContactID = CRM_Core_Session::singleton()->getLoggedInContactID(); + if ($loggedInContactID) { + if ($loggedInContactID == $note->entity_id) { $noteActions = TRUE; } elseif (CRM_Contact_BAO_Contact_Permission::allow($note->entity_id, CRM_Core_Permission::EDIT)) { @@ -231,7 +232,7 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note { */ public static function dataExists(&$params) { // return if no data present - if (!strlen($params['note'])) { + if (empty($params['id']) && !strlen($params['note'])) { return FALSE; } return TRUE; diff --git a/api/v3/PaymentProcessorType.php b/api/v3/PaymentProcessorType.php index 9f3f4c09e0..9c2799650f 100644 --- a/api/v3/PaymentProcessorType.php +++ b/api/v3/PaymentProcessorType.php @@ -40,17 +40,7 @@ * @return array */ function civicrm_api3_payment_processor_type_create($params) { - if (isset($params['id']) && !CRM_Utils_Rule::integer($params['id'])) { - return civicrm_api3_create_error('Invalid value for payment_processor type ID'); - } - - $paymentProcessorType = CRM_Financial_BAO_PaymentProcessorType::create($params); - - $relType = array(); - - _civicrm_api3_object_to_array($paymentProcessorType, $relType[$paymentProcessorType->id]); - - return civicrm_api3_create_success($relType, $params, 'PaymentProcessorType', 'create', $paymentProcessorType); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'PaymentProcessorType'); } /** diff --git a/tests/phpunit/api/v3/SyntaxConformanceTest.php b/tests/phpunit/api/v3/SyntaxConformanceTest.php index 1274ddad78..f549e00f59 100644 --- a/tests/phpunit/api/v3/SyntaxConformanceTest.php +++ b/tests/phpunit/api/v3/SyntaxConformanceTest.php @@ -386,7 +386,6 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { 'MailingEventUnsubscribe', 'MailingJob', 'MembershipPayment', - 'Note', 'SavedSearch', 'UFJoin', 'UFField', @@ -394,7 +393,6 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { 'GroupContact', 'EntityTag', 'PledgePayment', - 'PaymentProcessorType', 'Relationship', // ones that are not real entities hence not extendable. -- 2.25.1