function _civicrm_api3_mailing_create_spec(&$params) {
$params['created_id']['api.required'] = 1;
$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
$updateParams = array();
$updateParams['id'] = $params['id'];
- // The BAO will auto-create the job - note: exact match to API default.
- $updateParams['api.mailing_job.create'] = 0;
-
// Note: we'll pass along scheduling/approval fields, but they may get ignored
// if we don't have permission.
if (isset($params['scheduled_date'])) {
// @param mailing Object (per APIv3)
// @return Promise
save: function(mailing) {
- var params = angular.extend({}, mailing, {
- 'api.mailing_job.create': 0 // note: exact match to API default
- });
+ var params = angular.extend({}, mailing);
// Angular ngModel sometimes treats blank fields as undefined.
angular.forEach(mailing, function(value, key) {
* Test civicrm_mailing_create.
*/
public function testMailerCreateSuccess() {
- $result = $this->callAPIAndDocument('mailing', 'create', $this->_params, __FUNCTION__, __FILE__);
+ $result = $this->callAPIAndDocument('mailing', 'create', $this->_params + array('scheduled_date' => 'now'), __FUNCTION__, __FILE__);
$jobs = $this->callAPISuccess('mailing_job', 'get', array('mailing_id' => $result['id']));
$this->assertEquals(1, $jobs['count']);
unset($this->_params['created_id']); // return isn't working on this in getAndCheck so lets not check it for now
$createParams['groups']['exclude'] = array();
$createParams['mailings']['include'] = array();
$createParams['mailings']['exclude'] = array();
+ $createParams['api.mailing_job.create'] = 1;
$createResult = $this->callAPISuccess('Mailing', 'create', $createParams);
$getGroup1 = $this->callAPISuccess('MailingGroup', 'get', array('mailing_id' => $createResult['id']));
$getGroup1_ids = array_values(CRM_Utils_Array::collect('entity_id', $getGroup1['values']));
$params['mailings']['include'] = array();
$params['mailings']['exclude'] = array();
$params['options']['force_rollback'] = 1;
+ $params['api.mailing_job.create'] = 1;
$params['api.MailingRecipients.get'] = array(
'mailing_id' => '$value.id',
'api.contact.getvalue' => array(
*/
public function createDraftMailing($params = array()) {
$createParams = array_merge($this->_params, $params);
- $createParams['api.mailing_job.create'] = 0; // note: exact match to API default
$createResult = $this->callAPISuccess('mailing', 'create', $createParams, __FUNCTION__, __FILE__);
$this->assertTrue(is_numeric($createResult['id']));
$this->assertDBQuery(0, 'SELECT count(*) FROM civicrm_mailing_job WHERE mailing_id = %1', array(