From 77552d44f3e7a215be684917a6f9abff369c2b02 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 10 Jan 2020 10:12:42 +1300 Subject: [PATCH] [REF] Reduce places where we pass ids into Mailing::create In general the goal is to stop passing the ids variable. This removes a couple of places. Note that the value in params should be id not mailing_id --- CRM/Mailing/BAO/Mailing.php | 7 ++++--- CRM/SMS/Form/Schedule.php | 6 +++--- CRM/SMS/Form/Upload.php | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CRM/Mailing/BAO/Mailing.php b/CRM/Mailing/BAO/Mailing.php index 7eede68d13..ed5692da1b 100644 --- a/CRM/Mailing/BAO/Mailing.php +++ b/CRM/Mailing/BAO/Mailing.php @@ -1514,7 +1514,9 @@ ORDER BY civicrm_email.is_bulkmail DESC * * @return object * $mailing The new mailing object - * @throws \Exception + * + * @throws \CRM_Core_Exception + * @throws \CiviCRM_API3_Exception */ public static function create(&$params, $ids = []) { @@ -1546,8 +1548,7 @@ ORDER BY civicrm_email.is_bulkmail DESC $domain_name = 'EXAMPLE.ORG'; } if (!isset($params['created_id'])) { - $session =& CRM_Core_Session::singleton(); - $params['created_id'] = $session->get('userID'); + $params['created_id'] = CRM_Core_Session::getLoggedInContactID(); } $defaults = [ // load the default config settings for each diff --git a/CRM/SMS/Form/Schedule.php b/CRM/SMS/Form/Schedule.php index 5cdf860cac..a3f0a76374 100644 --- a/CRM/SMS/Form/Schedule.php +++ b/CRM/SMS/Form/Schedule.php @@ -131,9 +131,9 @@ class CRM_SMS_Form_Schedule extends CRM_Core_Form { public function postProcess() { $params = []; - $params['mailing_id'] = $ids['mailing_id'] = $this->_mailingID; + $params['id'] = $this->_mailingID; - if (empty($params['mailing_id'])) { + if (empty($params['id'])) { CRM_Core_Error::statusBounce(ts('Could not find a mailing id')); } @@ -157,7 +157,7 @@ class CRM_SMS_Form_Schedule extends CRM_Core_Form { } // Build the mailing object. - CRM_Mailing_BAO_Mailing::create($params, $ids); + CRM_Mailing_BAO_Mailing::create($params); $session = CRM_Core_Session::singleton(); $session->pushUserContext(CRM_Utils_System::url('civicrm/mailing/browse/scheduled', diff --git a/CRM/SMS/Form/Upload.php b/CRM/SMS/Form/Upload.php index 1c5f6aa80c..922b281225 100644 --- a/CRM/SMS/Form/Upload.php +++ b/CRM/SMS/Form/Upload.php @@ -144,7 +144,7 @@ class CRM_SMS_Form_Upload extends CRM_Core_Form { } public function postProcess() { - $params = $ids = []; + $params = []; $uploadParams = ['from_name']; $formValues = $this->controller->exportValues($this->_name); @@ -232,10 +232,10 @@ class CRM_SMS_Form_Upload extends CRM_Core_Form { $this->set('template', $params['msg_template_id']); } - $ids['mailing_id'] = $this->_mailingID; + $params['id'] = $this->_mailingID; // Build SMS in mailing table. - CRM_Mailing_BAO_Mailing::create($params, $ids); + CRM_Mailing_BAO_Mailing::create($params); } /** -- 2.25.1