[REF] Reduce places where we pass ids into Mailing::create
authoreileen <emcnaughton@wikimedia.org>
Thu, 9 Jan 2020 21:12:42 +0000 (10:12 +1300)
committereileen <emcnaughton@wikimedia.org>
Thu, 9 Jan 2020 21:29:01 +0000 (10:29 +1300)
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
CRM/SMS/Form/Schedule.php
CRM/SMS/Form/Upload.php

index 7eede68d13327250f2780d66490e2d169c4b0054..ed5692da1b4ae791b8964ee8b03046120f3d6589 100644 (file)
@@ -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
index 5cdf860cac108dfcf7781c40a73b7709d32709f9..a3f0a76374ed09a969399b6b05ac5fadf2c96a48 100644 (file)
@@ -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',
index 1c5f6aa80c4be281aef8ac2f663428116b15c99a..922b2812257e66eadd9905c661b0e88cd2412cdf 100644 (file)
@@ -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);
   }
 
   /**