dev/core/248 - Fixes advanced search results headers mailings
authorLuke Stewart <luke@fuzion.co.nz>
Fri, 26 Apr 2019 08:00:45 +0000 (20:00 +1200)
committerLuke Stewart <luke@fuzion.co.nz>
Fri, 26 Apr 2019 08:00:45 +0000 (20:00 +1200)
Removes language from advanced search results mailings column
headers for non-multilingual sites.

CRM/Mailing/Selector/Search.php

index e50406bd8359b9560cfefa4d5dbf3d78aaedcede..f273df793bed5cc60655dd32d65720428b238d78 100644 (file)
@@ -341,8 +341,12 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
    *   the column headers that need to be displayed
    */
   public function &getColumnHeaders($action = NULL, $output = NULL) {
+
     if (!isset(self::$_columnHeaders)) {
-      self::$_columnHeaders = [
+      $enabledLanguages = CRM_Core_I18n::languages(TRUE);
+      $isMultiLingual = (count($enabledLanguages) > 1);
+
+      $headers = [
         ['desc' => ts('Contact Type')],
         [
           'name' => ts('Name'),
@@ -359,11 +363,17 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
           'sort' => 'mailing_name',
           'direction' => CRM_Utils_Sort::DONTCARE,
         ],
-        [
+      ];
+
+      // Check to see if languages column should be displayed.
+      if ($isMultiLingual) {
+        $headers[] =  [
           'name' => ts('Language'),
           'sort' => 'language',
           'direction' => CRM_Utils_Sort::DONTCARE,
-        ],
+        ];
+      }
+      self::$_columnHeaders = array_merge($headers, [
         [
           'name' => ts('Mailing Subject'),
           'sort' => 'mailing_subject',
@@ -380,7 +390,7 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
           'direction' => CRM_Utils_Sort::DONTCARE,
         ],
         ['desc' => ts('Actions')],
-      ];
+      ]);
     }
     return self::$_columnHeaders;
   }