From: Tim Otten Date: Fri, 6 Feb 2015 19:31:15 +0000 (-0800) Subject: CRM-15578 - Mailing.create API - Set defaults that match UX X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b0a317143b2c1a6aee3b6bc99ef31532881f652e;p=civicrm-core.git CRM-15578 - Mailing.create API - Set defaults that match UX --- diff --git a/api/v3/Mailing.php b/api/v3/Mailing.php index 42347376b9..b1711efdf9 100755 --- a/api/v3/Mailing.php +++ b/api/v3/Mailing.php @@ -107,6 +107,32 @@ function _civicrm_api3_mailing_create_spec(&$params) { $params['created_id']['api.default'] = 'user_contact_id'; $params['api.mailing_job.create']['api.default'] = 1; $params['api.mailing_job.create']['title'] = 'Schedule Mailing?'; + + $params['override_verp']['api.default'] = !CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, + 'track_civimail_replies', NULL, FALSE + ); + $params['visibility']['api.default'] = 'Public Pages'; + $params['dedupe_email']['api.default'] = TRUE; + + $params['forward_replies']['api.default'] = FALSE; + $params['auto_responder']['api.default'] = FALSE; + $params['open_tracking']['api.default'] = TRUE; + $params['url_tracking']['api.default'] = TRUE; + + $params['header_id']['api.default'] = CRM_Mailing_PseudoConstant::defaultComponent('Header', ''); + $params['footer_id']['api.default'] = CRM_Mailing_PseudoConstant::defaultComponent('Footer', ''); + $params['optout_id']['api.default'] = CRM_Mailing_PseudoConstant::defaultComponent('OptOut', ''); + $params['reply_id']['api.default'] = CRM_Mailing_PseudoConstant::defaultComponent('Reply', ''); + $params['resubscribe_id']['api.default'] = CRM_Mailing_PseudoConstant::defaultComponent('Resubscribe', ''); + $params['unsubscribe_id']['api.default'] = CRM_Mailing_PseudoConstant::defaultComponent('Unsubscribe', ''); + + $defaultAddress = CRM_Core_OptionGroup::values('from_email_address', NULL, NULL, NULL, ' AND is_default = 1'); + foreach ($defaultAddress as $id => $value) { + if (preg_match('/"(.*)" <(.*)>/', $value, $match)) { + $params['from_email']['api.default'] = $match[2]; + $params['from_name']['api.default'] = $match[1]; + } + } } /** diff --git a/tests/phpunit/api/v3/MailingTest.php b/tests/phpunit/api/v3/MailingTest.php index c01ab57af2..1f6cdd95ac 100755 --- a/tests/phpunit/api/v3/MailingTest.php +++ b/tests/phpunit/api/v3/MailingTest.php @@ -52,6 +52,8 @@ class api_v3_MailingTest extends CiviUnitTestCase { 'body_html' => "

This is {contact.display_name}

", 'name' => 'mailing name', 'created_id' => $this->_contactID, + 'header_id' => '', + 'footer_id' => '', ); }