CRM-12814, fixed the total issue, code cleanup and notice fixes
authorkurund <kurund@civicrm.org>
Tue, 30 Jul 2013 22:18:32 +0000 (03:48 +0530)
committerkurund <kurund@civicrm.org>
Tue, 30 Jul 2013 22:18:32 +0000 (03:48 +0530)
----------------------------------------
* CRM-12814: mailings tab slow performance
  http://issues.civicrm.org/jira/browse/CRM-12814

CRM/Contact/BAO/Contact.php
CRM/Mailing/BAO/Mailing.php
CRM/Mailing/Page/AJAX.php
CRM/Mailing/Page/Tab.php

index 2edbefdf598a5f3514f49cbddbc98352200a0871..b2f1eefe00b7db8f827adcfa55fdb4eaebe47e8c 100644 (file)
@@ -2448,10 +2448,7 @@ AND       civicrm_openid.is_primary = 1";
         return CRM_Activity_BAO_Activity::getActivitiesCount($input);
 
       case 'mailing':
-        $params = array(
-          'contact_id' => $contactId,
-          'admin' => FALSE,
-        );
+        $params = array('contact_id' => $contactId);
         return CRM_Mailing_BAO_Mailing::getContactMailingsCount($params);
 
       default:
index a38ddbf2f4303f069393b9dcd032369e6e02124c..ee75e2aff585b1caa4c22139a6355f7418e31bd3 100644 (file)
@@ -2762,7 +2762,7 @@ AND        m.id = %1
     $params['total'] = CRM_Mailing_BAO_Mailing::getContactMailingsCount($params);
 
     //CRM-12814
-    if ( !empty($mailings) ) {
+    if (!empty($mailings)) {
       $openCounts = CRM_Mailing_Event_BAO_Opened::getMailingTotalCount(array_keys($mailings));
       $clickCounts = CRM_Mailing_Event_BAO_TrackableURLOpen::getMailingTotalCount(array_keys($mailings));
     }
@@ -2774,20 +2774,21 @@ AND        m.id = %1
       $contactMailings[$mailingId]['start_date'] = CRM_Utils_Date::customFormat($values['start_date']);
       $contactMailings[$mailingId]['recipients'] = CRM_Utils_System::href(ts('(recipients)'), 'civicrm/mailing/report/event',
         "mid={$values['mailing_id']}&reset=1&cid={$params['contact_id']}&event=queue&context=mailing");
+
       $contactMailings[$mailingId]['mailing_creator'] = CRM_Utils_System::href(
-          $values['creator_name'],
-          'civicrm/contact/view',
-          "reset=1&cid={$values['creator_id']}");
+        $values['creator_name'],
+        'civicrm/contact/view',
+        "reset=1&cid={$values['creator_id']}");
 
       //CRM-12814
-      $contactMailings[$mailingId]['openstats'] = "Opens: ".$openCounts[$values['mailing_id']].
-        "<br />Clicks: ".$clickCounts[$values['mailing_id']];
+      $contactMailings[$mailingId]['openstats'] = ts('Opens') . ': ' . $openCounts[$values['mailing_id']] .
+        '<br />' . ts('Clicks') . ': ' . $clickCounts[$values['mailing_id']];
 
       $actionLinks = array(
         CRM_Core_Action::VIEW => array(
-          'name'  => ts('View'),
-          'url'   => 'civicrm/mailing/view',
-          'qs'    => "reset=1&id={$values['mailing_id']}",
+          'name' => ts('View'),
+          'url' => 'civicrm/mailing/view',
+          'qs' => "reset=1&id={$values['mailing_id']}",
           'title' => ts('View Mailing'),
           'class' => 'crm-mailing-view',
         ),
@@ -2837,9 +2838,7 @@ AND        m.id = %1
    */
   static public function getContactMailingsCount(&$params) {
     $params['version'] = 3;
-
-    $result = civicrm_api('MailingContact', 'getcount', $params);
-    return $result['values']['count'];
+    return civicrm_api('MailingContact', 'getcount', $params);
   }
 }
 
index 5810cb890f66e61f68b3f26393a2546c18bf48d8..73c2ae8d21e12dc4ee676f6d1554ffbfdd6e06f7 100644 (file)
@@ -41,7 +41,7 @@ class CRM_Mailing_Page_AJAX {
   /**
    * Function to fetch the template text/html messages
    */
-  static function template() {
+  public static function template() {
     $templateId = CRM_Utils_Type::escape($_POST['tid'], 'Integer');
 
     $messageTemplate = new CRM_Core_DAO_MessageTemplates();
@@ -63,9 +63,8 @@ class CRM_Mailing_Page_AJAX {
   /**
    * Function to retrieve contact mailings
    */
-  function getContactMailings() {
+  public static function getContactMailings() {
     $contactID = CRM_Utils_Type::escape($_GET['contact_id'], 'Integer');
-    //$context = CRM_Utils_Type::escape(CRM_Utils_Array::value('context', $_GET), 'String');
 
     $sortMapper = array(
       0 => 'subject', 1 => 'creator_name', 2 => '', 3 => 'start_date', 4 => '', 5 => 'links',
index 68d135aca976684cc982bce36da59920a4e89b3a..8abb75ab4dcdc8adc00ba1069e6f04862afc6bb6 100644 (file)
@@ -64,7 +64,6 @@ class CRM_Mailing_Page_Tab extends CRM_Contact_Page_View {
    * @access public
    */
   function preProcess() {
-    $context       = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
     $this->_id     = CRM_Utils_Request::retrieve('id', 'Positive', $this);