CRM-16352 - improve browsing by language
authorSamuel Vanhove <samuel@symbiotic.coop>
Fri, 30 Sep 2016 17:03:03 +0000 (13:03 -0400)
committerSamuel Vanhove <samuel@symbiotic.coop>
Thu, 6 Oct 2016 14:38:01 +0000 (10:38 -0400)
CRM/Mailing/Selector/Browse.php
templates/CRM/Mailing/Page/Browse.hlp
templates/CRM/Mailing/Page/Browse.tpl

index 2d7474c54c2873d8836c31935b8b8c4a35da69bd..9592426347f3dad40954f3d11c8ed61b99249591 100644 (file)
@@ -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(
index 5f1c3ce67f0b564b2b3307943ce2767d8a7a2391..06b18583e82776f4f1a6295f96b10f55e1b10c0a 100644 (file)
 {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}
+
+
index 11454a4b5e3f3f795d16c01ef00120aa2bf6bb7b..2b4a147327d5d80b7853e99cd7c23669a9c62832 100644 (file)
@@ -65,8 +65,9 @@
       {foreach from=$rows item=row}
       <tr id="crm-mailing_{$row.id}" class="{cycle values="odd-row,even-row"} crm-mailing crm-mailing_status-{$row.status}">
         <td class="crm-mailing-name">{$row.name}</td>
-        {* TODO if multilingual? *}
-        <td class="crm-mailing-language">{$row.language}</td>
+        {if $multilingual}
+          <td class="crm-mailing-language">{$row.language}</td>
+        {/if}
         <td class="crm-mailing-status crm-mailing_status-{$row.status}">{$row.status}</td>
         <td class="crm-mailing-created_by"><a href ={crmURL p='civicrm/contact/view' q="reset=1&cid="}{$row.created_id}>{$row.created_by}</a></td>
         <td class="crm-mailing-created_date">{$row.created_date}</td>