<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*
*/
*
* @params array $params contains form values
*
+ * @param $testParams
+ *
* @return void
* @access public
*/
/**
* static wrapper for getting verp and urls
*
- * @param int $job_id ID of the Job associated with this message
- * @param int $event_queue_id ID of the EventQueue
- * @param string $hash Hash of the EventQueue
- * @param string $email Destination address
+ * @param int $job_id ID of the Job associated with this message
+ * @param int $event_queue_id ID of the EventQueue
+ * @param string $hash Hash of the EventQueue
+ * @param string $email Destination address
*
- * @return (reference) array array ref that hold array refs to the verp info and urls
+ * @return array (reference) array array ref that hold array refs to the verp info and urls
*/
static function getVerpAndUrls($job_id, $event_queue_id, $hash, $email) {
// create a skeleton object and set its properties that are required by getVerpAndUrlsAndHeaders()
/**
* get verp, urls and headers
*
- * @param int $job_id ID of the Job associated with this message
- * @param int $event_queue_id ID of the EventQueue
- * @param string $hash Hash of the EventQueue
- * @param string $email Destination address
+ * @param int $job_id ID of the Job associated with this message
+ * @param int $event_queue_id ID of the EventQueue
+ * @param string $hash Hash of the EventQueue
+ * @param string $email Destination address
*
- * @return (reference) array array ref that hold array refs to the verp info, urls, and headers
- * @access private
+ * @param bool $isForward
+ *
+ * @return array (reference) array array ref that hold array refs to the verp info, urls, and headers@access private
*/
private function getVerpAndUrlsAndHeaders($job_id, $event_queue_id, $hash, $email, $isForward = FALSE) {
$config = CRM_Core_Config::singleton();
/**
* Compose a message
*
- * @param int $job_id ID of the Job associated with this message
- * @param int $event_queue_id ID of the EventQueue
- * @param string $hash Hash of the EventQueue
- * @param string $contactId ID of the Contact
- * @param string $email Destination address
- * @param string $recipient To: of the recipient
- * @param boolean $test Is this mailing a test?
- * @param boolean $isForward Is this mailing compose for forward?
- * @param string $fromEmail email address of who is forwardinf it.
+ * @param int $job_id ID of the Job associated with this message
+ * @param int $event_queue_id ID of the EventQueue
+ * @param string $hash Hash of the EventQueue
+ * @param string $contactId ID of the Contact
+ * @param string $email Destination address
+ * @param string $recipient To: of the recipient
+ * @param boolean $test Is this mailing a test?
+ * @param $contactDetails
+ * @param $attachments
+ * @param boolean $isForward Is this mailing compose for forward?
+ * @param string $fromEmail email address of who is forwardinf it.
+ *
+ * @param null $replyToEmail
*
* @return object The mail object
* @access public
if ($contactDetails) {
$contact = $contactDetails;
}
+ elseif ($contactId === 0) {
+ //anonymous user
+ $contact = array();
+ CRM_Utils_Hook::tokenValues($contact, $contactId, $job_id);
+ }
else {
$params = array(array('contact_id', '=', $contactId, 0, 0));
list($contact, $_) = CRM_Contact_BAO_Query::apiQuery($params);
*
* @params array $params Form values
*
+ * @param $params
+ * @param array $ids
+ *
* @return object $mailing The new mailing object
* @access public
* @static
'forward_replies' => FALSE,
'open_tracking' => TRUE,
'url_tracking' => TRUE,
- 'visibility' => 'User and User Admin Only',
+ 'visibility' => 'Public Pages',
'replyto_email' => $domain_email,
'header_id' => CRM_Mailing_PseudoConstant::defaultComponent('header_id', ''),
'footer_id' => CRM_Mailing_PseudoConstant::defaultComponent('footer_id', ''),
$transaction->rollback();
return $mailing;
}
+ // update mailings with hash values
+ CRM_Contact_BAO_Contact_Utils::generateChecksum($mailing->id, NULL, NULL, NULL, 'mailing', 16);
$groupTableName = CRM_Contact_BAO_Group::getTableName();
$mailingTableName = CRM_Mailing_BAO_Mailing::getTableName();
return $mailing;
}
+ /**
+ * get hash value of the mailing
+ *
+ */
+ public static function getMailingHash($id) {
+ $hash = NULL;
+ if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'hash_mailing_url')) {
+ $hash = CRM_Core_DAO::getFieldValue('CRM_Mailing_BAO_Mailing', $id, 'hash', 'id');
+ }
+ return $hash;
+ }
+
/**
* Generate a report. Fetch event count information, mailing data, and job
* status.
*
- * @param int $id The mailing id to report
+ * @param int $id The mailing id to report
* @param boolean $skipDetails whether return all detailed report
*
+ * @param bool $isSMS
+ *
* @return array Associative array of reporting data
* @access public
* @static
/**
* Get the rows for a browse operation
*
- * @param int $offset The row number to start from
- * @param int $rowCount The nmber of rows to return
- * @param string $sort The sql string that describes the sort order
+ * @param int $offset The row number to start from
+ * @param int $rowCount The nmber of rows to return
+ * @param string $sort The sql string that describes the sort order
+ *
+ * @param null $additionalClause
+ * @param null $additionalParams
*
* @return array The rows
* @access public
*
* @param int $id
*
+ * @return string
* @static
* @access public
*/
*
* @param $form reference of this
*
- * @return $report array content/component.
- * @access public
+ * @param bool $isSMS
+ *
+ * @return array $report array content/component.@access public
*/
static function getMailingContent(&$report, &$form, $isSMS = FALSE) {
$htmlHeader = $textHeader = NULL;
}
}
- $text = CRM_Utils_Request::retrieve('text', 'Boolean', $form);
- if ($text) {
- echo "<pre>{$textHeader}</br>{$report['mailing']['body_text']}</br>{$textFooter}</pre>";
- CRM_Utils_System::civiExit();
- }
-
+ $mailingKey = $form->_mailing_id;
if (!$isSMS) {
- $html = CRM_Utils_Request::retrieve('html', 'Boolean', $form);
- if ($html) {
- $output = $htmlHeader . $report['mailing']['body_html'] . $htmlFooter ;
- echo str_replace( "\n", '<br />', $output );
- CRM_Utils_System::civiExit();
+ if ($hash = CRM_Mailing_BAO_Mailing::getMailingHash($mailingKey)) {
+ $mailingKey = $hash;
}
}
if (!empty($report['mailing']['body_text'])) {
- $url = CRM_Utils_System::url('civicrm/mailing/report', 'reset=1&text=1&mid=' . $form->_mailing_id);
- $popup = "javascript:popUp(\"$url\");";
- $form->assign('textViewURL', $popup);
+ $url = CRM_Utils_System::url('civicrm/mailing/view', 'reset=1&text=1&id=' . $mailingKey);
+ $form->assign('textViewURL', $url);
}
if (!$isSMS) {
if (!empty($report['mailing']['body_html'])) {
- $url = CRM_Utils_System::url('civicrm/mailing/report', 'reset=1&html=1&mid=' . $form->_mailing_id);
- $popup = "javascript:popUp(\"$url\");";
- $form->assign('htmlViewURL', $popup);
+ $url = CRM_Utils_System::url('civicrm/mailing/view', 'reset=1&id=' . $mailingKey);
+ $form->assign('htmlViewURL', $url);
}
}
CRM_Core_Action::VIEW => array(
'name' => ts('View'),
'url' => 'civicrm/mailing/view',
- 'qs' => "reset=1&id=%%mid%%",
+ 'qs' => "reset=1&id=%%mkey%%",
'title' => ts('View Mailing'),
- 'class' => 'crm-mailing-view',
+ 'class' => 'crm-popup',
),
CRM_Core_Action::BROWSE => array(
'name' => ts('Mailing Report'),
)
);
+ $mailingKey = $values['mailing_id'];
+ if ($hash = CRM_Mailing_BAO_Mailing::getMailingHash($mailingKey)) {
+ $mailingKey = $hash;
+ }
+
$contactMailings[$mailingId]['links'] = CRM_Core_Action::formLink(
$actionLinks,
null,
array(
'mid' => $values['mailing_id'],
'cid' => $params['contact_id'],
+ 'mkey' => $mailingKey,
),
ts('more'),
FALSE,
return civicrm_api('MailingContact', 'getcount', $params);
}
}
-