worked on CRM-12357, basic mailing tab is now functional to display contact mailings
authorKurund Jalmi <kurund@civicrm.org>
Mon, 22 Apr 2013 01:44:48 +0000 (18:44 -0700)
committerKurund Jalmi <kurund@civicrm.org>
Mon, 22 Apr 2013 01:44:48 +0000 (18:44 -0700)
CRM/Contact/BAO/Contact.php
CRM/Mailing/BAO/Mailing.php
CRM/Mailing/Page/AJAX.php
CRM/Mailing/xml/Menu/Mailing.xml
CRM/Utils/System.php
templates/CRM/Mailing/Page/Tab.tpl

index bf15c462edfb2d4ea3b4b2a079b231147b6883aa..23a15b594dce2e29332f48ccc6be575af50a2ee6 100644 (file)
@@ -2367,9 +2367,12 @@ AND       civicrm_openid.is_primary = 1";
         return CRM_Activity_BAO_Activity::getActivitiesCount($input);
 
       case 'mailing':
-          //FIX ME: calculate count
+        $params = array(
+          'contact_id' => $contactId,
+          'admin' => FALSE,
+        );
+        return CRM_Mailing_BAO_Mailing::getContactMailingsCount($params);
 
-        return;  
       default:
         $custom = explode('_', $component);
         if ($custom['0'] = 'custom') {
index 515bf974177779841a8a606189ecc353d414533e..2231ca62f9139b247e9394470f825c3dd05e1064 100644 (file)
@@ -1600,7 +1600,7 @@ ORDER BY   civicrm_email.is_bulkmail DESC
       $job->scheduled_date = $params['scheduled_date'];
       $job->save();
       // Populate the recipients.
-      $mailing->getRecipients($job->id, $mailing->id, NULL, NULL, true, false);
+      $mailing->getRecipients($job->id, $mailing->id, NULL, NULL, TRUE, FALSE);
     }
 
     return $mailing;
@@ -2149,7 +2149,7 @@ ORDER BY   civicrm_email.is_bulkmail DESC
 
     // get all the groups that this user can access
     // if they dont have universal access
-    $groups = CRM_Core_PseudoConstant::group(null, false);
+    $groups = CRM_Core_PseudoConstant::group(NULL, FALSE);
     if (!empty($groups)) {
       $groupIDs = implode(',', array_keys($groups));
       $selectClause = ($count) ? 'COUNT( DISTINCT m.id) as count' : 'DISTINCT( m.id ) as id';
@@ -2729,5 +2729,80 @@ AND        m.id = %1
     $params = array( 1 => array( $mid, 'Integer' ) );
     return CRM_Core_DAO::singleValueQuery($sql, $params);
   }
+
+  /**
+   * This function is a wrapper for ajax activity selector
+   *
+   * @param  array   $params associated array for params record id.
+   *
+   * @return array   $contactActivities associated array of contact activities
+   * @access public
+   */
+  public static function getContactMailingSelector(&$params) {
+    // format the params
+    $params['offset']   = ($params['page'] - 1) * $params['rp'];
+    $params['rowCount'] = $params['rp'];
+    $params['sort']     = CRM_Utils_Array::value('sortBy', $params);
+    $params['caseId']   = NULL;
+    $context            = CRM_Utils_Array::value('context', $params);
+
+    // get contact mailings
+    $mailings = CRM_Mailing_BAO_Mailing::getContactMailings($params);
+
+    // add total
+    $params['total'] = CRM_Mailing_BAO_Mailing::getContactMailingsCount($params);
+
+    // format params and add links
+    $contactMailings = array();
+    foreach ($mailings as $mailingId => $values) {
+      $contactMailings[$mailingId]['subject'] = $values['subject'];
+      $contactMailings[$mailingId]['start_date'] = CRM_Utils_Date::customFormat($values['start_date']);
+
+      $contactMailings[$mailingId]['mailing_creator'] = CRM_Utils_System::href(
+          $values['creator_name'],
+          'civicrm/contact/view',
+          "reset=1&cid={$values['creator_id']}");
+
+      $contactMailings[$mailingId]['links'] = CRM_Utils_System::href(
+        ts('View Mailing'),
+        'civicrm/mailing/view',
+        "reset=1&id={$values['mailing_id']}");
+    }
+
+    return $contactMailings;
+  }
+
+  /**
+   * Function to retrieve contact mailing
+   *
+   * @param array $params associated array
+   *
+   * @return array of mailings for a contact
+   *
+   * @static
+   * @access public
+   */
+  static public function getContactMailings(&$params) {
+    $params['version'] = 3;
+    $result = civicrm_api('MailingContact', 'get', $params);
+    return $result['values'];
+  }
+
+  /**
+   * Function to retrieve contact mailing count
+   *
+   * @param array $params associated array
+   *
+   * @return int count of mailings for a contact
+   *
+   * @static
+   * @access public
+   */
+  static public function getContactMailingsCount(&$params) {
+    //FIX ME: need to implement getcount api for MailingContact
+    $params['version'] = 3;
+    $result = civicrm_api('MailingContact', 'get', $params);
+    return count($result['values']);
+  }
 }
 
index cf023f2837e81975dea0d484808ac88eb9b272c9..3032533d660e222a73773ad2b8aa707b6a580c9f 100644 (file)
@@ -59,5 +59,46 @@ class CRM_Mailing_Page_AJAX {
     echo json_encode($messages);
     CRM_Utils_System::civiExit();
   }
+
+  /**
+   * Function to retrieve contact mailings
+   */
+  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 => 'mailing_creator', 2 => 'start_date', 3 => 'links',
+    );
+
+    $sEcho     = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
+    $offset    = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
+    $rowCount  = isset($_REQUEST['iDisplayLength']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayLength'], 'Integer') : 25;
+    $sort      = isset($_REQUEST['iSortCol_0']) ? CRM_Utils_Array::value(CRM_Utils_Type::escape($_REQUEST['iSortCol_0'], 'Integer'), $sortMapper) : NULL;
+    $sortOrder = isset($_REQUEST['sSortDir_0']) ? CRM_Utils_Type::escape($_REQUEST['sSortDir_0'], 'String') : 'asc';
+
+    $params = $_POST;
+    if ($sort && $sortOrder) {
+      $params['sortBy'] = $sort . ' ' . $sortOrder;
+    }
+
+    $params['page'] = ($offset / $rowCount) + 1;
+    $params['rp'] = $rowCount;
+
+    $params['contact_id'] = $contactID;
+    $params['context'] = $context;
+
+    // get the contact mailings
+    $mailings = CRM_Mailing_BAO_Mailing::getContactMailingSelector($params);
+
+    $iFilteredTotal = $iTotal = $params['total'];
+    $selectorElements = array(
+      'subject', 'mailing_creator',
+      'start_date', 'links',
+    );
+
+    echo CRM_Utils_JSON::encodeDataTableSelector($mailings, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
+    CRM_Utils_System::civiExit();
+  }
 }
 
index 52f972474e0e7e99323dc7f391900d9ec3ea6c55..7b63894b6b09e27413fe4a2ae60ddd3365e0e92d 100644 (file)
 
 <menu>
   <item>
-     <path>civicrm/mailing</path>
-     <title>CiviMail</title>
-     <page_callback>CRM_Mailing_Page_Browse</page_callback>
-     <access_arguments>access CiviMail;create mailings</access_arguments>
-     <page_type>1</page_type>
-     <weight>600</weight>
-     <component>CiviMail</component>
-  </item>
-  <item>
-     <path>civicrm/admin/mail</path>
-     <title>Mailer Settings</title>
-     <page_callback>CRM_Admin_Form_Setting_Mail</page_callback>
-     <desc>Configure spool period, throttling and other mailer settings.</desc>
-     <access_arguments>access CiviMail</access_arguments>
-     <adminGroup>CiviMail</adminGroup>
-     <icon>admin/small/07.png</icon>
-     <weight>400</weight>
-  </item>
-  <item>
-     <path>civicrm/admin/component</path>
-     <title>Headers, Footers, and Automated Messages</title>
-     <page_callback>CRM_Mailing_Page_Component</page_callback>
-     <desc>Configure the header and footer used for mailings. Customize the content of automated Subscribe, Unsubscribe, Resubscribe and Opt-out messages.</desc>
-     <access_arguments>access CiviMail</access_arguments>
-     <adminGroup>CiviMail</adminGroup>
-     <icon>admin/small/Profile.png</icon>
-     <weight>410</weight>
-  </item>
-  <item>
-     <path>civicrm/admin/options/from_email</path>
-     <title>From Email Addresses</title>
-     <desc>List of Email Addresses which can be used when sending emails to contacts.</desc>
-     <path_arguments>group=from_email_address</path_arguments>
-     <page_callback>CRM_Admin_Page_Options</page_callback>
-     <adminGroup>CiviMail</adminGroup>
-     <icon>admin/small/title.png</icon>
-     <weight>415</weight>
-  </item>
-  <item>
-     <path>civicrm/admin/mailSettings</path>
-     <title>Mail Accounts</title>
-     <page_callback>CRM_Admin_Page_MailSettings</page_callback>
-     <desc>Configure email account setting.</desc>
-     <access_arguments>access CiviMail</access_arguments>
-     <adminGroup>CiviMail</adminGroup>
-     <icon>admin/small/07.png</icon>
-     <weight>420</weight>
-  </item>
-  <item>
-     <path>civicrm/admin/setting/preferences/mailing</path>
-     <title>CiviMail Component Settings</title>
-     <page_callback>CRM_Admin_Form_Preferences_Mailing</page_callback>
-     <desc>Configure global CiviMail behaviors.</desc>
-     <access_arguments>access CiviMail,administer CiviCRM</access_arguments>
-     <adminGroup>CiviMail</adminGroup>
-     <weight>430</weight>
-  </item>
-    <item>
-     <path>civicrm/mailing/send</path>
-     <title>New Mailing</title>
-     <page_callback>CRM_Mailing_Controller_Send</page_callback>
-     <access_arguments>access CiviMail;create mailings;schedule mailings</access_arguments>
-     <page_type>1</page_type>
-     <weight>610</weight>
-  </item>
-  <item>
-     <path>civicrm/mailing/browse/scheduled</path>
-     <title>Scheduled and Sent Mailings</title>
-     <path_arguments>scheduled=true</path_arguments>
-     <page_callback>CRM_Mailing_Page_Browse</page_callback>
-     <access_arguments>access CiviMail;approve mailings;create mailings;schedule mailings</access_arguments>
-     <page_type>1</page_type>
-     <weight>620</weight>
-  </item>
-  <item>
-     <path>civicrm/mailing/browse/unscheduled</path>
-     <title>Draft and Unscheduled Mailings</title>
-     <path_arguments>scheduled=false</path_arguments>
-     <page_callback>CRM_Mailing_Page_Browse</page_callback>
-     <access_arguments>access CiviMail;create mailings;schedule mailings</access_arguments>
-     <page_type>1</page_type>
-     <weight>620</weight>
-  </item>
-  <item>
-     <path>civicrm/mailing/browse/archived</path>
-     <title>Archived Mailings</title>
-     <page_callback>CRM_Mailing_Page_Browse</page_callback>
-     <access_arguments>access CiviMail;create mailings</access_arguments>
-     <page_type>1</page_type>
-     <weight>625</weight>
-  </item>
-  <item>
-     <path>civicrm/mailing/component</path>
-     <title>Headers, Footers, and Automated Messages</title>
-     <page_callback>CRM_Mailing_Page_Component</page_callback>
-     <access_arguments>administer CiviCRM</access_arguments>
-     <page_type>1</page_type>
-     <weight>630</weight>
-  </item>
-  <item>
-     <path>civicrm/mailing/unsubscribe</path>
-     <title>Unsubscribe</title>
-     <page_callback>CRM_Mailing_Page_Unsubscribe</page_callback>
-     <access_arguments>access CiviMail subscribe/unsubscribe pages</access_arguments>
-     <is_public>true</is_public>
-     <weight>640</weight>
-  </item>
+    <path>civicrm/mailing</path>
+    <title>CiviMail</title>
+    <page_callback>CRM_Mailing_Page_Browse</page_callback>
+    <access_arguments>access CiviMail;create mailings</access_arguments>
+    <page_type>1</page_type>
+    <weight>600</weight>
+    <component>CiviMail</component>
+  </item>
+  <item>
+    <path>civicrm/admin/mail</path>
+    <title>Mailer Settings</title>
+    <page_callback>CRM_Admin_Form_Setting_Mail</page_callback>
+    <desc>Configure spool period, throttling and other mailer settings.</desc>
+    <access_arguments>access CiviMail</access_arguments>
+    <adminGroup>CiviMail</adminGroup>
+    <icon>admin/small/07.png</icon>
+    <weight>400</weight>
+  </item>
+  <item>
+    <path>civicrm/admin/component</path>
+    <title>Headers, Footers, and Automated Messages</title>
+    <page_callback>CRM_Mailing_Page_Component</page_callback>
+    <desc>Configure the header and footer used for mailings. Customize the content of automated Subscribe, Unsubscribe, Resubscribe and Opt-out messages.</desc>
+    <access_arguments>access CiviMail</access_arguments>
+    <adminGroup>CiviMail</adminGroup>
+    <icon>admin/small/Profile.png</icon>
+    <weight>410</weight>
+  </item>
+  <item>
+    <path>civicrm/admin/options/from_email</path>
+    <title>From Email Addresses</title>
+    <desc>List of Email Addresses which can be used when sending emails to contacts.</desc>
+    <path_arguments>group=from_email_address</path_arguments>
+    <page_callback>CRM_Admin_Page_Options</page_callback>
+    <adminGroup>CiviMail</adminGroup>
+    <icon>admin/small/title.png</icon>
+    <weight>415</weight>
+  </item>
+  <item>
+    <path>civicrm/admin/mailSettings</path>
+    <title>Mail Accounts</title>
+    <page_callback>CRM_Admin_Page_MailSettings</page_callback>
+    <desc>Configure email account setting.</desc>
+    <access_arguments>access CiviMail</access_arguments>
+    <adminGroup>CiviMail</adminGroup>
+    <icon>admin/small/07.png</icon>
+    <weight>420</weight>
+  </item>
+  <item>
+    <path>civicrm/admin/setting/preferences/mailing</path>
+    <title>CiviMail Component Settings</title>
+    <page_callback>CRM_Admin_Form_Preferences_Mailing</page_callback>
+    <desc>Configure global CiviMail behaviors.</desc>
+    <access_arguments>access CiviMail,administer CiviCRM</access_arguments>
+    <adminGroup>CiviMail</adminGroup>
+    <weight>430</weight>
+  </item>
+  <item>
+    <path>civicrm/mailing/send</path>
+    <title>New Mailing</title>
+    <page_callback>CRM_Mailing_Controller_Send</page_callback>
+    <access_arguments>access CiviMail;create mailings;schedule mailings</access_arguments>
+    <page_type>1</page_type>
+    <weight>610</weight>
+  </item>
+  <item>
+    <path>civicrm/mailing/browse/scheduled</path>
+    <title>Scheduled and Sent Mailings</title>
+    <path_arguments>scheduled=true</path_arguments>
+    <page_callback>CRM_Mailing_Page_Browse</page_callback>
+    <access_arguments>access CiviMail;approve mailings;create mailings;schedule mailings</access_arguments>
+    <page_type>1</page_type>
+    <weight>620</weight>
+  </item>
+  <item>
+    <path>civicrm/mailing/browse/unscheduled</path>
+    <title>Draft and Unscheduled Mailings</title>
+    <path_arguments>scheduled=false</path_arguments>
+    <page_callback>CRM_Mailing_Page_Browse</page_callback>
+    <access_arguments>access CiviMail;create mailings;schedule mailings</access_arguments>
+    <page_type>1</page_type>
+    <weight>620</weight>
+  </item>
+  <item>
+    <path>civicrm/mailing/browse/archived</path>
+    <title>Archived Mailings</title>
+    <page_callback>CRM_Mailing_Page_Browse</page_callback>
+    <access_arguments>access CiviMail;create mailings</access_arguments>
+    <page_type>1</page_type>
+    <weight>625</weight>
+  </item>
+  <item>
+    <path>civicrm/mailing/component</path>
+    <title>Headers, Footers, and Automated Messages</title>
+    <page_callback>CRM_Mailing_Page_Component</page_callback>
+    <access_arguments>administer CiviCRM</access_arguments>
+    <page_type>1</page_type>
+    <weight>630</weight>
+  </item>
+  <item>
+    <path>civicrm/mailing/unsubscribe</path>
+    <title>Unsubscribe</title>
+    <page_callback>CRM_Mailing_Page_Unsubscribe</page_callback>
+    <access_arguments>access CiviMail subscribe/unsubscribe pages</access_arguments>
+    <is_public>true</is_public>
+    <weight>640</weight>
+  </item>
+  <item>
+    <path>civicrm/mailing/resubscribe</path>
+    <title>Resubscribe</title>
+    <page_callback>CRM_Mailing_Page_Resubscribe</page_callback>
+    <access_arguments>access CiviMail subscribe/unsubscribe pages</access_arguments>
+    <is_public>true</is_public>
+    <weight>645</weight>
+  </item>
   <item>
-     <path>civicrm/mailing/resubscribe</path>
-     <title>Resubscribe</title>
-     <page_callback>CRM_Mailing_Page_Resubscribe</page_callback>
-     <access_arguments>access CiviMail subscribe/unsubscribe pages</access_arguments>
-     <is_public>true</is_public>
-     <weight>645</weight>
-  </item>
+    <path>civicrm/mailing/optout</path>
+    <title>Optout</title>
+    <page_callback>CRM_Mailing_Page_Optout</page_callback>
+    <access_arguments>access CiviMail subscribe/unsubscribe pages</access_arguments>
+    <is_public>true</is_public>
+    <weight>650</weight>
+  </item>
   <item>
-     <path>civicrm/mailing/optout</path>
-     <title>Optout</title>
-     <page_callback>CRM_Mailing_Page_Optout</page_callback>
-     <access_arguments>access CiviMail subscribe/unsubscribe pages</access_arguments>
-     <is_public>true</is_public>
-     <weight>650</weight>
-  </item>
+    <path>civicrm/mailing/confirm</path>
+    <title>Confirm</title>
+    <page_callback>CRM_Mailing_Page_Confirm</page_callback>
+    <access_arguments>access CiviMail subscribe/unsubscribe pages</access_arguments>
+    <is_public>true</is_public>
+    <weight>660</weight>
+  </item>
   <item>
-     <path>civicrm/mailing/confirm</path>
-     <title>Confirm</title>
-     <page_callback>CRM_Mailing_Page_Confirm</page_callback>
-     <access_arguments>access CiviMail subscribe/unsubscribe pages</access_arguments>
-     <is_public>true</is_public>
-     <weight>660</weight>
-  </item>
+    <path>civicrm/mailing/subscribe</path>
+    <title>Subscribe</title>
+    <page_callback>CRM_Mailing_Form_Subscribe</page_callback>
+    <access_arguments>access CiviMail subscribe/unsubscribe pages</access_arguments>
+    <is_public>true</is_public>
+    <weight>660</weight>
+  </item>
   <item>
-     <path>civicrm/mailing/subscribe</path>
-     <title>Subscribe</title>
-     <page_callback>CRM_Mailing_Form_Subscribe</page_callback>
-     <access_arguments>access CiviMail subscribe/unsubscribe pages</access_arguments>
-     <is_public>true</is_public>
-     <weight>660</weight>
+    <path>civicrm/mailing/preview</path>
+    <title>Preview Mailing</title>
+    <page_callback>CRM_Mailing_Page_Preview</page_callback>
+    <access_arguments>access CiviMail;approve mailings;create mailings;schedule mailings</access_arguments>
+    <weight>670</weight>
   </item>
   <item>
-     <path>civicrm/mailing/preview</path>
-     <title>Preview Mailing</title>
-     <page_callback>CRM_Mailing_Page_Preview</page_callback>
-     <access_arguments>access CiviMail;approve mailings;create mailings;schedule mailings</access_arguments>
-     <weight>670</weight>
+    <path>civicrm/mailing/report</path>
+    <title>Mailing Report</title>
+    <page_callback>CRM_Mailing_Page_Report</page_callback>
+    <access_arguments>access CiviMail;create mailings</access_arguments>
+    <path_arguments>mid=%%mid%%</path_arguments>
+    <weight>680</weight>
   </item>
   <item>
-     <path>civicrm/mailing/report</path>
-     <title>Mailing Report</title>
-     <page_callback>CRM_Mailing_Page_Report</page_callback>
-     <access_arguments>access CiviMail;create mailings</access_arguments>
-     <path_arguments>mid=%%mid%%</path_arguments>
-     <weight>680</weight>
+    <path>civicrm/mailing/forward</path>
+    <title>Forward Mailing</title>
+    <page_callback>CRM_Mailing_Form_ForwardMailing</page_callback>
+    <access_arguments>access CiviMail subscribe/unsubscribe pages</access_arguments>
+    <is_public>true</is_public>
+    <weight>685</weight>
   </item>
   <item>
-     <path>civicrm/mailing/forward</path>
-     <title>Forward Mailing</title>
-     <page_callback>CRM_Mailing_Form_ForwardMailing</page_callback>
-     <access_arguments>access CiviMail subscribe/unsubscribe pages</access_arguments>
-     <is_public>true</is_public>
-     <weight>685</weight>
+    <path>civicrm/mailing/queue</path>
+    <title>Sending Mail</title>
+    <page_callback>CRM_Mailing_Page_Browse</page_callback>
+    <access_arguments>access CiviMail</access_arguments>
+    <weight>690</weight>
   </item>
   <item>
-     <path>civicrm/mailing/queue</path>
-     <title>Sending Mail</title>
-     <page_callback>CRM_Mailing_Page_Browse</page_callback>
-     <access_arguments>access CiviMail</access_arguments>
-     <weight>690</weight>
+    <path>civicrm/mailing/report/event</path>
+    <title>Mailing Event</title>
+    <page_callback>CRM_Mailing_Page_Event</page_callback>
+    <access_arguments>access CiviMail</access_arguments>
+    <weight>695</weight>
   </item>
   <item>
-     <path>civicrm/mailing/report/event</path>
-     <title>Mailing Event</title>
-     <page_callback>CRM_Mailing_Page_Event</page_callback>
-     <access_arguments>access CiviMail</access_arguments>
-     <weight>695</weight>
+    <path>civicrm/ajax/template</path>
+    <page_callback>CRM_Mailing_Page_AJAX::template</page_callback>
+    <access_arguments>access CiviCRM</access_arguments>
   </item>
   <item>
-     <path>civicrm/ajax/template</path>
-     <page_callback>CRM_Mailing_Page_AJAX::template</page_callback>
-     <access_arguments>access CiviCRM</access_arguments>
+    <path>civicrm/mailing/schedule</path>
+    <title>Schedule Mailing</title>
+    <page_callback>CRM_Mailing_Form_Schedule</page_callback>
+    <access_arguments>schedule mailings</access_arguments>
+    <weight>700</weight>
   </item>
   <item>
-     <path>civicrm/mailing/schedule</path>
-     <title>Schedule Mailing</title>
-     <page_callback>CRM_Mailing_Form_Schedule</page_callback>
-     <access_arguments>schedule mailings</access_arguments>
-     <weight>700</weight>
+    <path>civicrm/mailing/view</path>
+    <title>View Mailing</title>
+    <page_callback>CRM_Mailing_Page_View</page_callback>
+    <access_arguments>view public CiviMail content;access CiviMail;approve mailings</access_arguments>
+    <is_public>true</is_public>
+    <weight>800</weight>
   </item>
   <item>
-     <path>civicrm/mailing/view</path>
-     <title>View Mailing</title>
-     <page_callback>CRM_Mailing_Page_View</page_callback>
-     <access_arguments>view public CiviMail content;access CiviMail;approve mailings</access_arguments>
-     <is_public>true</is_public>
-     <weight>800</weight>
+    <path>civicrm/mailing/approve</path>
+    <title>Approve Mailing</title>
+    <page_callback>CRM_Mailing_Form_Approve</page_callback>
+    <access_arguments>approve mailings</access_arguments>
+    <weight>850</weight>
   </item>
   <item>
-     <path>civicrm/mailing/approve</path>
-     <title>Approve Mailing</title>
-     <page_callback>CRM_Mailing_Form_Approve</page_callback>
-     <access_arguments>approve mailings</access_arguments>
-     <weight>850</weight>
+    <path>civicrm/contact/view/mailing</path>
+    <page_callback>CRM_Mailing_Page_Tab</page_callback>
   </item>
   <item>
-     <path>civicrm/contact/view/mailing</path>
-     <page_callback>CRM_Mailing_Page_Tab</page_callback>
+    <path>civicrm/ajax/contactmailing</path>
+    <page_callback>CRM_Mailing_Page_AJAX::getContactMailings</page_callback>
+    <access_arguments>access CiviCRM</access_arguments>
   </item>
 </menu>
index 13d73224253d040e0c937399684236c9ffdb9df6..7ca056c27fade8efbbf98d5fedba51f9c7323339 100644 (file)
@@ -208,7 +208,7 @@ class CRM_Utils_System {
     return $config->userSystem->url($path, $query, $absolute, $fragment, $htmlize, $frontend, $forceBackend);
   }
 
-  function href($text, $path = NULL, $query = NULL, $absolute = TRUE,
+  static function href($text, $path = NULL, $query = NULL, $absolute = TRUE,
     $fragment = NULL, $htmlize = TRUE, $frontend = FALSE, $forceBackend = FALSE
   ) {
     $url = self::url($path, $query, $absolute, $fragment, $htmlize, $frontend, $forceBackend);
index 0d06a3d11310365d24db18211dd79acb59eb8333..bf60765b417a5020e425030fbf87955cdc9e148d 100644 (file)
@@ -32,7 +32,6 @@
       <th class='crm-mailing-contact_created'>{ts}Created By{/ts}</th>
       <th class='crm-mailing-contact-date'>{ts}Date{/ts}</th>
       <th class='crm-mailing-contact-links nosort'>&nbsp;</th>
-      <th class='hiddenElement'>&nbsp;</th>
     </tr>
     </thead>
   </table>
   });
 
 function buildMailingContact() {
-  oTable.fnDestroy();
 
   var columns = '';
-  var sourceUrl = {/literal}'{crmURL p="civicrm/ajax/rest" h=0 q="entity=MailingContact&action=get&sequential=1&json=1&contact_id=$contactId"}'{literal};
+  var sourceUrl = {/literal}'{crmURL p="civicrm/ajax/contactmailing" h=0 q="contact_id=$contactId"}'{literal};
 
   var ZeroRecordText = {/literal}'{ts escape="js"}No mailings found{/ts}.'{literal};
 
-  oTable = cj('#mailing-contact-selector').dataTable({
+  oTable = cj('#contact-mailing-selector').dataTable({
     "bFilter"    : false,
     "bAutoWidth" : false,
     "aaSorting"  : [],
@@ -61,8 +59,7 @@ function buildMailingContact() {
       {sClass:'crm-mailing-contact-subject'},
       {sClass:'crm-mailing-contact_created'},
       {sClass:'crm-mailing-contact-date'},
-      {sClass:'crm-mailing-contact-links', bSortable:false},
-      {sClass:'hiddenElement', bSortable:false}
+      {sClass:'crm-mailing-contact-links', bSortable:false}
     ],
     "bProcessing": true,
     "sPaginationType": "full_numbers",
@@ -85,22 +82,6 @@ function buildMailingContact() {
         "sNext":     {/literal}"{ts escape='js'}Next{/ts}"{literal},
         "sLast":     {/literal}"{ts escape='js'}Last{/ts}"{literal}
       }
-    },
-    "fnDrawCallback": function() { setSelectorClass(); },
-    "fnServerData": function ( sSource, aoData, fnCallback ) {
-        aoData.push( {name:'contact_id', value: {/literal}{$contactId}{literal}},
-      {name:'admin',   value: {/literal}'{$admin}'{literal}}
-      );
-
-      cj.ajax( {
-        "dataType": 'json',
-        "type": "POST",
-        "url": sSource,
-        "data": aoData,
-        "success": fnCallxback,
-        // CRM-10244
-        "dataFilter": function(data, type) { return data.replace(/[\n\v\t]/g, " "); }
-      });
     }
   });
 }