From a98504a721727f6dc1b48793fd5b3dc04b7dac07 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 19 Apr 2017 11:00:06 +1200 Subject: [PATCH] CRM-20316 the mailing should still create without created_id (not mandatory). --- api/v3/Mailing.php | 4 ++-- api/v3/utils.php | 2 +- tests/phpunit/api/v3/ActivityContactTest.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/v3/Mailing.php b/api/v3/Mailing.php index c6a72f6504..ae0a246cf8 100644 --- a/api/v3/Mailing.php +++ b/api/v3/Mailing.php @@ -133,8 +133,8 @@ function _civicrm_api3_mailing_gettokens_spec(&$params) { * Array of parameters determined by getfields. */ function _civicrm_api3_mailing_create_spec(&$params) { - $params['created_id']['api.required'] = 1; $params['created_id']['api.default'] = 'user_contact_id'; + $params['subject']['api.required'] = TRUE; $params['override_verp']['api.default'] = !CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'track_civimail_replies'); $params['visibility']['api.default'] = 'Public Pages'; @@ -153,7 +153,7 @@ function _civicrm_api3_mailing_create_spec(&$params) { $params['unsubscribe_id']['api.default'] = CRM_Mailing_PseudoConstant::defaultComponent('Unsubscribe', ''); $params['mailing_type']['api.default'] = 'standalone'; $defaultAddress = CRM_Core_OptionGroup::values('from_email_address', NULL, NULL, NULL, ' AND is_default = 1'); - foreach ($defaultAddress as $id => $value) { + foreach ($defaultAddress as $value) { if (preg_match('/"(.*)" <(.*)>/', $value, $match)) { $params['from_email']['api.default'] = $match[2]; $params['from_name']['api.default'] = $match[1]; diff --git a/api/v3/utils.php b/api/v3/utils.php index 8164a31ef2..dd55453e45 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -2083,7 +2083,7 @@ function _civicrm_api3_validate_integer(&$params, $fieldName, &$fieldInfo, $enti elseif (is_numeric($realContactId)) { $fieldValue = $realContactId; } - elseif (is_null($realContactId) && empty($fieldInfo['api.required'])) { + elseif (is_null($realContactId) && empty($fieldInfo['api.required']) && $fieldValue === 'user_contact_id') { // If not mandatory this will be OK. If mandatory it should fail. $fieldValue = NULL; } diff --git a/tests/phpunit/api/v3/ActivityContactTest.php b/tests/phpunit/api/v3/ActivityContactTest.php index a12b7532c3..8f9824bfe7 100644 --- a/tests/phpunit/api/v3/ActivityContactTest.php +++ b/tests/phpunit/api/v3/ActivityContactTest.php @@ -84,7 +84,7 @@ class api_v3_ActivityContactTest extends CiviUnitTestCase { $this->callAPISuccess('ActivityContact', 'Get', array('contact_id' => $this->_contactID)); } - public function testGetParticipantsByActivity() { + public function testGetActivitiesByActivity() { $this->callAPISuccess('ActivityContact', 'Get', array('activity_id' => $this->_activityID)); } @@ -92,7 +92,7 @@ class api_v3_ActivityContactTest extends CiviUnitTestCase { * Test civicrm_activity_contact_get with empty params. */ public function testGetEmptyParams() { - $result = $this->callAPISuccess('ActivityContact', 'Get', array()); + $this->callAPISuccess('ActivityContact', 'Get', array()); } /** -- 2.25.1