if ($this->body_html) {
$this->_getTokens('html');
+ if (!$this->body_text) {
+ // Since the text template was created from html, use the html tokens.
+ // @see CRM_Mailing_BAO_Mailing::getTemplates()
+ $this->tokens['text'] = $this->tokens['html'];
+ }
}
if ($this->body_text) {
$this->_domain = CRM_Core_BAO_Domain::getDomain();
}
- list($verp, $urls, $headers) = $this->getVerpAndUrlsAndHeaders($job_id,
+ list($verp, $urls, $headers) = $this->getVerpAndUrlsAndHeaders(
+ $job_id,
$event_queue_id,
$hash,
$email,
$isForward
);
+
//set from email who is forwarding it and not original one.
if ($fromEmail) {
unset($headers['From']);
* domain and mailing tokens
*
*/
- function tokenReplace(&$mailing) {
+ public static function tokenReplace(&$mailing) {
$domain = CRM_Core_BAO_Domain::getDomain();
foreach (array(
/**
* 'approval_status_id' set in
- * CRM_Mailing_Form_Mailing_Schedule::postProcess() or via API.
+ * CRM_Mailing_Form_Schedule::postProcess() or via API.
*/
if (isset($params['approval_status_id']) && $params['approval_status_id']) {
$job = new CRM_Mailing_BAO_Job();
$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;
// 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';
* @return $report array content/component.
* @access public
*/
- public function getMailingContent(&$report, &$form, $isSMS = FALSE) {
+ public static function getMailingContent(&$report, &$form, $isSMS = FALSE) {
$htmlHeader = $textHeader = NULL;
$htmlFooter = $textFooter = NULL;
shuffle($lockArray);
// check if we are using global locks
- $serverWideLock = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
+ $serverWideLock = CRM_Core_BAO_Setting::getItem(
+ CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'civimail_server_wide_lock'
);
foreach ($lockArray as $lockID) {
$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']);
+ }
}