From cc6d14772c2d25b9385b397fa16002b8b24e83a9 Mon Sep 17 00:00:00 2001 From: Samuel Vanhove Date: Fri, 30 Sep 2016 13:03:03 -0400 Subject: [PATCH] CRM-16352 - improve browsing by language --- CRM/Mailing/Selector/Browse.php | 103 ++++++++++++++++---------- templates/CRM/Mailing/Page/Browse.hlp | 9 +++ templates/CRM/Mailing/Page/Browse.tpl | 5 +- 3 files changed, 75 insertions(+), 42 deletions(-) diff --git a/CRM/Mailing/Selector/Browse.php b/CRM/Mailing/Selector/Browse.php index 2d7474c54c..9592426347 100644 --- a/CRM/Mailing/Selector/Browse.php +++ b/CRM/Mailing/Selector/Browse.php @@ -121,47 +121,61 @@ class CRM_Mailing_Selector_Browse extends CRM_Core_Selector_Base implements CRM_ 'name' => $nameHeaderLabel, 'sort' => 'name', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( - 'name' => ts('Language'), - 'sort' => 'language', - 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( - 'name' => ts('Status'), - 'sort' => 'status', - 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( - 'name' => ts('Created By'), - 'sort' => 'created_by', - 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( - 'name' => ts('Created Date'), - 'sort' => 'created_date', - 'direction' => $unscheduledOrder, - ), - array( - 'name' => ts('Sent By'), - 'sort' => 'scheduled_by', - 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( - 'name' => ts('Scheduled'), - 'sort' => 'scheduled_date', - 'direction' => $scheduledOrder, - ), - array( - 'name' => ts('Started'), - 'sort' => 'start_date', - 'direction' => CRM_Utils_Sort::DONTCARE, - ), + ) + ); + + if (CRM_Core_I18n::isMultilingual()) { + self::$_columnHeaders = array_merge( + self::$_columnHeaders, + array( + array( + 'name' => ts('Language'), + 'sort' => 'language', + 'direction' => CRM_Utils_Sort::DONTCARE, + ) + ) + ); + } + + self::$_columnHeaders = array_merge( + self::$_columnHeaders, array( - 'name' => ts('Completed'), - 'sort' => 'end_date', - 'direction' => $completedOrder, - ), + array( + 'name' => ts('Status'), + 'sort' => 'status', + 'direction' => CRM_Utils_Sort::DONTCARE, + ), + array( + 'name' => ts('Created By'), + 'sort' => 'created_by', + 'direction' => CRM_Utils_Sort::DONTCARE, + ), + array( + 'name' => ts('Created Date'), + 'sort' => 'created_date', + 'direction' => $unscheduledOrder, + ), + array( + 'name' => ts('Sent By'), + 'sort' => 'scheduled_by', + 'direction' => CRM_Utils_Sort::DONTCARE, + ), + array( + 'name' => ts('Scheduled'), + 'sort' => 'scheduled_date', + 'direction' => $scheduledOrder, + ), + array( + 'name' => ts('Started'), + 'sort' => 'start_date', + 'direction' => CRM_Utils_Sort::DONTCARE, + ), + array( + 'name' => ts('Completed'), + 'sort' => 'end_date', + 'direction' => $completedOrder, + ), + ) ); if (CRM_Campaign_BAO_Campaign::isCampaignEnable()) { @@ -176,6 +190,8 @@ class CRM_Mailing_Selector_Browse extends CRM_Core_Selector_Base implements CRM_ self::$_columnHeaders[] = array('name' => ts('Action')); } } + + CRM_Core_Smarty::singleton()->assign('multilingual', CRM_Core_I18n::isMultilingual()); return self::$_columnHeaders; } @@ -338,6 +354,9 @@ LEFT JOIN civicrm_contact scheduledContact ON ( $mailing.scheduled_id = schedul } $opString = implode('.', $pageTypes); + // get languages for later conversion + $languages = CRM_Core_I18n::languages(); + foreach ($rows as $key => $row) { $actionMask = NULL; if ($row['sms_provider_id']) { @@ -398,6 +417,10 @@ LEFT JOIN civicrm_contact scheduledContact ON ( $mailing.scheduled_id = schedul } // get status strings as per locale settings CRM-4411. $rows[$key]['status'] = CRM_Mailing_BAO_MailingJob::status($row['status']); + + // get language string + $rows[$key]['language'] = $languages[$row['language']]; + $validLinks = $actionLinks; if (($mailingUrl = CRM_Mailing_BAO_Mailing::getPublicViewUrl($row['id'])) != FALSE) { $validLinks[] = array( diff --git a/templates/CRM/Mailing/Page/Browse.hlp b/templates/CRM/Mailing/Page/Browse.hlp index 5f1c3ce67f..06b18583e8 100644 --- a/templates/CRM/Mailing/Page/Browse.hlp +++ b/templates/CRM/Mailing/Page/Browse.hlp @@ -43,3 +43,12 @@ {htxt id="is_archived"} {ts}This field is disabled when searching for Draft/Unscheduled mailings.{/ts} {/htxt} + +{htxt id="id-language-title"} + {ts}Language{/ts} +{/htxt} +{htxt id="id-language"} + {ts}Find mailing by language.{/ts} +{/htxt} + + diff --git a/templates/CRM/Mailing/Page/Browse.tpl b/templates/CRM/Mailing/Page/Browse.tpl index 11454a4b5e..2b4a147327 100644 --- a/templates/CRM/Mailing/Page/Browse.tpl +++ b/templates/CRM/Mailing/Page/Browse.tpl @@ -65,8 +65,9 @@ {foreach from=$rows item=row} {$row.name} - {* TODO if multilingual? *} - {$row.language} + {if $multilingual} + {$row.language} + {/if} {$row.status} {$row.created_by} {$row.created_date} -- 2.25.1