From 8a4cd1f8379e13d70790aac10619a60569390777 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 3 Jan 2019 07:45:16 +1100 Subject: [PATCH] (dev/core#491) Standardise the adding of campaign fields on the mailing summary report and add a post upgrade message about needing to re-save report given the changes made to the report template Update language on postupgrade message Move upgrade to 5.13 --- CRM/Report/Form/Mailing/Summary.php | 34 ++++++-------------- CRM/Upgrade/Incremental/php/FiveThirteen.php | 9 +++--- 2 files changed, 14 insertions(+), 29 deletions(-) diff --git a/CRM/Report/Form/Mailing/Summary.php b/CRM/Report/Form/Mailing/Summary.php index e1397b6886..b862ffcc72 100644 --- a/CRM/Report/Form/Mailing/Summary.php +++ b/CRM/Report/Form/Mailing/Summary.php @@ -45,8 +45,6 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { 'bar_3dChart' => 'Bar Chart', ); - public $campaignEnabled = FALSE; - /** * Class constructor. */ @@ -297,23 +295,8 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { ), ), ); - $config = CRM_Core_Config::singleton(); - $this->campaignEnabled = in_array("CiviCampaign", $config->enableComponents); - if ($this->campaignEnabled) { - $this->_columns['civicrm_campaign'] = array( - 'dao' => 'CRM_Campaign_DAO_Campaign', - 'fields' => array( - 'title' => array( - 'title' => ts('Campaign Name'), - ), - ), - 'filters' => array( - 'title' => array( - 'type' => CRM_Utils_Type::T_STRING, - ), - ), - ); - } + // If we have campaigns enabled, add those elements to both the fields, filters. + $this->addCampaignFields('civicrm_mailing'); parent::__construct(); } @@ -428,12 +411,6 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { LEFT JOIN civicrm_mailing_group {$this->_aliases['civicrm_mailing_group']} ON {$this->_aliases['civicrm_mailing_group']}.mailing_id = {$this->_aliases['civicrm_mailing']}.id"; } - if ($this->campaignEnabled) { - $this->_from .= " - LEFT JOIN civicrm_campaign {$this->_aliases['civicrm_campaign']} - ON {$this->_aliases['civicrm_campaign']}.id = {$this->_aliases['civicrm_mailing']}.campaign_id"; - } - // need group by and order by //print_r($this->_from); @@ -679,6 +656,13 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { $entryFound = TRUE; } } + // convert campaign_id to campaign title + if (array_key_exists('civicrm_mailing_campaign_id', $row)) { + if ($value = $row['civicrm_mailing_campaign_id']) { + $rows[$rowNum]['civicrm_mailing_campaign_id'] = $this->campaigns[$value]; + $entryFound = TRUE; + } + } // skip looking further in rows, if first row itself doesn't // have the column we need if (!$entryFound) { diff --git a/CRM/Upgrade/Incremental/php/FiveThirteen.php b/CRM/Upgrade/Incremental/php/FiveThirteen.php index 1e41312265..81dc3c42fa 100644 --- a/CRM/Upgrade/Incremental/php/FiveThirteen.php +++ b/CRM/Upgrade/Incremental/php/FiveThirteen.php @@ -55,10 +55,11 @@ class CRM_Upgrade_Incremental_php_FiveThirteen extends CRM_Upgrade_Incremental_B * an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs. */ public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) { - // Example: Generate a post-upgrade message. - // if ($rev == '5.12.34') { - // $postUpgradeMessage .= '

' . ts("By default, CiviCRM now disables the ability to import directly from SQL. To use this feature, you must explicitly grant permission 'import SQL datasource'."); - // } + $config = CRM_Core_Config::singleton(); + $campaignEnabled = in_array("CiviCampaign", $config->enableComponents); + if ($rev == '5.13.alpha1' && $campaignEnabled) { + $postUpgradeMessage .= '

' . ts("If you have created a report based on the Mailing Summary Report template and it outputs or filters on campaigns, You will need to go back to that report and re-save the report after selecting and or setting the campaign filters up again"); + } } /* -- 2.25.1