本文整理匯總了PHP中CRM_Mailing_BAO_Mailing::getDetails方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Mailing_BAO_Mailing::getDetails方法的具體用法?PHP CRM_Mailing_BAO_Mailing::getDetails怎麽用?PHP CRM_Mailing_BAO_Mailing::getDetails使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CRM_Mailing_BAO_Mailing
的用法示例。
在下文中一共展示了CRM_Mailing_BAO_Mailing::getDetails方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: sendAcknowledgment
/**
* Function to send Acknowledgment and create activity.
*
* @param object $form form object.
* @param array $params (reference ) an assoc array of name/value pairs.
* @access public
* @return None.
*/
function sendAcknowledgment(&$form, $params)
{
//handle Acknowledgment.
$allPayments = $payments = array();
//get All Payments status types.
require_once 'CRM/Contribute/PseudoConstant.php';
$paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus(null, 'name');
$returnProperties = array('status_id', 'scheduled_amount', 'scheduled_date', 'contribution_id');
//get all paymnets details.
CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_Payment', 'pledge_id', $params['id'], $allPayments, $returnProperties);
if (!empty($allPayments)) {
foreach ($allPayments as $payID => $values) {
$contributionValue = $contributionStatus = array();
if (isset($values['contribution_id'])) {
$contributionParams = array('id' => $values['contribution_id']);
$returnProperties = array('contribution_status_id', 'receive_date');
CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_Contribution', $contributionParams, $contributionStatus, $returnProperties);
$contributionValue = array('status' => CRM_Utils_Array::value('contribution_status_id', $contributionStatus), 'receive_date' => CRM_Utils_Array::value('receive_date', $contributionStatus));
}
$payments[$payID] = array_merge($contributionValue, array('amount' => CRM_Utils_Array::value('scheduled_amount', $values), 'due_date' => CRM_Utils_Array::value('scheduled_date', $values)));
//get the first valid payment id.
if (!$form->paymentId && ($paymentStatusTypes[$values['status_id']] == 'Pending' || $paymentStatusTypes[$values['status_id']] == 'Overdue')) {
$form->paymentId = $values['id'];
}
}
}
//end
//assign pledge fields value to template.
$pledgeFields = array('create_date', 'total_pledge_amount', 'frequency_interval', 'frequency_unit', 'installments', 'frequency_day', 'scheduled_amount');
foreach ($pledgeFields as $field) {
if (CRM_Utils_Array::value($field, $params)) {
$form->assign($field, $params[$field]);
}
}
//assign all payments details.
if ($payments) {
$form->assign('payments', $payments);
}
//assign honor fields.
$honor_block_is_active = false;
//make sure we have values for it
if (CRM_Utils_Array::value('honor_type_id', $params) && (!empty($params["honor_first_name"]) && !empty($params["honor_last_name"]) || !empty($params["honor_email"]))) {
$honor_block_is_active = true;
require_once "CRM/Core/PseudoConstant.php";
$prefix = CRM_Core_PseudoConstant::individualPrefix();
$honor = CRM_Core_PseudoConstant::honor();
$form->assign("honor_type", $honor[$params["honor_type_id"]]);
$form->assign("honor_prefix", $prefix[$params["honor_prefix_id"]]);
$form->assign("honor_first_name", $params["honor_first_name"]);
$form->assign("honor_last_name", $params["honor_last_name"]);
$form->assign("honor_email", $params["honor_email"]);
}
$form->assign('honor_block_is_active', $honor_block_is_active);
//handle domain token values
require_once 'CRM/Core/BAO/Domain.php';
$domain =& CRM_Core_BAO_Domain::getDomain();
$tokens = array('domain' => array('name', 'phone', 'address', 'email'), 'contact' => CRM_Core_SelectValues::contactTokens());
require_once 'CRM/Utils/Token.php';
$domainValues = array();
foreach ($tokens['domain'] as $token) {
$domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain);
}
$form->assign('domain', $domainValues);
//handle contact token values.
require_once 'CRM/Contact/BAO/Contact.php';
require_once 'CRM/Mailing/BAO/Mailing.php';
$ids = array($params['contact_id']);
$fields = array_merge(array_keys(CRM_Contact_BAO_Contact::importableFields()), array('display_name', 'checksum', 'contact_id'));
foreach ($fields as $key => $val) {
$returnProperties[$val] = true;
}
$details = CRM_Mailing_BAO_Mailing::getDetails($ids, $returnProperties);
$form->assign('contact', $details[0][$params['contact_id']]);
//handle custom data.
if (CRM_Utils_Array::value('hidden_custom', $params)) {
require_once 'CRM/Core/BAO/CustomGroup.php';
$groupTree =& CRM_Core_BAO_CustomGroup::getTree('Pledge', CRM_Core_DAO::$_nullObject, $params['id']);
$pledgeParams = array(array('pledge_id', '=', $params['id'], 0, 0));
$customGroup = array();
// retrieve custom data
require_once "CRM/Core/BAO/UFGroup.php";
foreach ($groupTree as $groupID => $group) {
$customFields = $customValues = array();
if ($groupID == 'info') {
continue;
}
foreach ($group['fields'] as $k => $field) {
$field['title'] = $field['label'];
$customFields["custom_{$k}"] = $field;
}
//to build array of customgroup & customfields in it
CRM_Core_BAO_UFGroup::getValues($params['contact_id'], $customFields, $customValues, false, $pledgeParams);
//.........這裏部分代碼省略.........
示例2: transitionParticipants
static function transitionParticipants($participantIds, $toStatusId, $fromStatusId = null, $returnResult = false, $skipCascadeRule = false)
{
if (!is_array($participantIds) || empty($participantIds) || !$toStatusId) {
return;
}
//thumb rule is if we triggering primary participant need to triggered additional
$allParticipantIds = $primaryANDAdditonalIds = array();
foreach ($participantIds as $id) {
$allParticipantIds[] = $id;
if (self::isPrimaryParticipant($id)) {
//filter additional as per status transition rules, CRM-5403
if ($skipCascadeRule) {
$additionalIds = self::getAdditionalParticipantIds($id);
} else {
$additionalIds = self::getValidAdditionalIds($id, $fromStatusId, $toStatusId);
}
if (!empty($additionalIds)) {
$allParticipantIds = array_merge($allParticipantIds, $additionalIds);
$primaryANDAdditonalIds[$id] = $additionalIds;
}
}
}
//get the unique participant ids,
$allParticipantIds = array_unique($allParticipantIds);
//pull required participants, contacts, events data, if not in hand
static $eventDetails = array();
static $domainValues = array();
static $contactDetails = array();
$contactIds = $eventIds = $participantDetails = array();
require_once 'CRM/Event/PseudoConstant.php';
$statusTypes = CRM_Event_PseudoConstant::participantStatus();
$participantRoles = CRM_Event_PseudoConstant::participantRole();
$pendingStatuses = CRM_Event_PseudoConstant::participantStatus(null, "class = 'Pending'");
//first thing is pull all necessory data from db.
$participantIdClause = "(" . implode(',', $allParticipantIds) . ")";
//get all participants data.
$query = "SELECT * FROM civicrm_participant WHERE id IN {$participantIdClause}";
$dao =& CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$participantDetails[$dao->id] = array('id' => $dao->id, 'role' => $participantRoles[$dao->role_id], 'is_test' => $dao->is_test, 'event_id' => $dao->event_id, 'status_id' => $dao->status_id, 'fee_amount' => $dao->fee_amount, 'contact_id' => $dao->contact_id, 'register_date' => $dao->register_date, 'registered_by_id' => $dao->registered_by_id);
if (!array_key_exists($dao->contact_id, $contactDetails)) {
$contactIds[$dao->contact_id] = $dao->contact_id;
}
if (!array_key_exists($dao->event_id, $eventDetails)) {
$eventIds[$dao->event_id] = $dao->event_id;
}
}
//get the domain values.
if (empty($domainValues)) {
// making all tokens available to templates.
require_once 'CRM/Core/BAO/Domain.php';
require_once 'CRM/Core/SelectValues.php';
$domain =& CRM_Core_BAO_Domain::getDomain();
$tokens = array('domain' => array('name', 'phone', 'address', 'email'), 'contact' => CRM_Core_SelectValues::contactTokens());
require_once 'CRM/Utils/Token.php';
foreach ($tokens['domain'] as $token) {
$domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain);
}
}
//get all required contacts detail.
if (!empty($contactIds)) {
// get the contact details.
require_once 'CRM/Mailing/BAO/Mailing.php';
list($currentContactDetails) = CRM_Mailing_BAO_Mailing::getDetails($contactIds, null, false, false);
foreach ($currentContactDetails as $contactId => $contactValues) {
$contactDetails[$contactId] = $contactValues;
}
}
//get all required events detail.
if (!empty($eventIds)) {
foreach ($eventIds as $eventId) {
//retrieve event information
require_once 'CRM/Event/BAO/Event.php';
$eventParams = array('id' => $eventId);
CRM_Event_BAO_Event::retrieve($eventParams, $eventDetails[$eventId]);
//get default participant role.
$eventDetails[$eventId]['participant_role'] = CRM_Utils_Array::value($eventDetails[$eventId]['default_role_id'], $participantRoles);
//get the location info
$locParams = array('entity_id' => $eventId, 'entity_table' => 'civicrm_event');
require_once 'CRM/Core/BAO/Location.php';
$eventDetails[$eventId]['location'] = CRM_Core_BAO_Location::getValues($locParams, true);
}
}
//now we are ready w/ all required data.
//take a decision as per statuses.
$emailType = null;
$toStatus = $statusTypes[$toStatusId];
$fromStatus = CRM_Utils_Array::value($fromStatusId, $statusTypes);
switch ($toStatus) {
case 'Pending from waitlist':
case 'Pending from approval':
switch ($fromStatus) {
case 'On waitlist':
case 'Awaiting approval':
$emailType = 'Confirm';
break;
}
break;
case 'Expired':
//no matter from where u come send expired mail.
//.........這裏部分代碼省略.........
示例3: buildQuickForm
/**
* Build the form
*
* @access public
* @return void
*/
static function buildQuickForm(&$form)
{
$toArray = $ccArray = $bccArray = array();
$suppressedEmails = 0;
$to = $form->add('text', 'to', ts('To'), '', true);
$cc = $form->add('text', 'cc_id', ts('CC'));
$bcc = $form->add('text', 'bcc_id', ts('BCC'));
$elements = array('cc', 'bcc');
foreach ($elements as $element) {
if (${$element}->getValue()) {
preg_match_all('!"(.*?)"\\s+<\\s*(.*?)\\s*>!', ${$element}->getValue(), $matches);
$elementValues = array();
for ($i = 0; $i < count($matches[0]); $i++) {
$name = '"' . $matches[1][$i] . '" <' . $matches[2][$i] . '>';
$elementValues[] = array('name' => $name, 'id' => $matches[0][$i]);
}
$var = "{$element}Contact";
$form->assign($var, json_encode($elementValues));
}
}
// when form is submitted recompute contactIds
$allToEmails = array();
if ($to->getValue()) {
$allToEmails = explode(',', $to->getValue());
$form->_contactIds = array();
foreach ($allToEmails as $value) {
list($contactId, $email) = explode('::', $value);
$form->_contactIds[] = $contactId;
$form->_toContactEmails[] = $email;
}
}
if (is_array($form->_contactIds)) {
$returnProperties = array('sort_name' => 1, 'email' => 1, 'do_not_email' => 1, 'on_hold' => 1, 'display_name' => 1, 'preferred_mail_format' => 1);
require_once 'CRM/Mailing/BAO/Mailing.php';
list($form->_contactDetails) = CRM_Mailing_BAO_Mailing::getDetails($form->_contactIds, $returnProperties, false, false);
// make a copy of all contact details
$form->_allContactDetails = $form->_contactDetails;
foreach ($form->_contactIds as $key => $contactId) {
$value = $form->_contactDetails[$contactId];
if ($value['do_not_email'] || empty($value['email']) || $value['is_deceased'] || $value['on_hold']) {
$suppressedEmails++;
// unset contact details for contacts that we won't be sending email. This is prevent extra computation
// during token evaluation etc.
unset($form->_contactDetails[$contactId]);
} else {
if (empty($form->_toContactEmails)) {
$email = $value['email'];
} else {
$email = $form->_toContactEmails[$key];
}
$toArray[] = array('name' => '"' . $value['sort_name'] . '" <' . $email . '>', 'id' => "{$contactId}::{$email}");
}
}
if (empty($toArray)) {
CRM_Core_Error::statusBounce(ts('Selected contact(s) do not have a valid email address, or communication preferences specify DO NOT EMAIL, or they are deceased or Primary email address is On Hold).'));
}
}
$form->assign('toContact', json_encode($toArray));
$form->assign('suppressedEmails', $suppressedEmails);
$form->assign('noEmails', $form->_noEmails);
$session =& CRM_Core_Session::singleton();
$userID = $session->get('userID');
list($fromDisplayName, $fromEmail, $fromDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($userID);
if (!$fromEmail) {
CRM_Core_Error::statusBounce(ts('Your user record does not have a valid email address'));
}
if (!trim($fromDisplayName)) {
$fromDisplayName = $fromEmail;
}
$form->assign('totalSelectedContacts', count($form->_contactIds));
$from = "{$fromDisplayName} <{$fromEmail}>";
$form->_fromEmails = array('0' => $from) + CRM_Core_PseudoConstant::fromEmailAddress();
$form->add('text', 'subject', ts('Subject'), 'size=50 maxlength=254', true);
$selectEmails = $form->_fromEmails;
foreach (array_keys($selectEmails) as $k) {
$selectEmails[$k] = htmlspecialchars($selectEmails[$k]);
}
$form->add('select', 'fromEmailAddress', ts('From'), $selectEmails, true);
require_once "CRM/Mailing/BAO/Mailing.php";
CRM_Mailing_BAO_Mailing::commonCompose($form);
// add attachments
require_once 'CRM/Core/BAO/File.php';
CRM_Core_BAO_File::buildAttachment($form, null);
if ($form->_single) {
// also fix the user context stack
if ($form->_caseId) {
$ccid = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseContact', $form->_caseId, 'contact_id', 'case_id');
$url = CRM_Utils_System::url('civicrm/contact/view/case', "&reset=1&action=view&cid={$ccid}&id={$form->_caseId}");
} else {
if ($form->_context) {
$url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
} else {
$url = CRM_Utils_System::url('civicrm/contact/view', "&show=1&action=browse&cid={$form->_contactIds[0]}&selectedChild=activity");
}
//.........這裏部分代碼省略.........
示例4: replaceGreetingTokens
/**
* replace greeting tokens exists in message/subject
*
* @access public
*/
function replaceGreetingTokens(&$tokenString, $contactDetails = null, $contactId = null)
{
if (!$contactDetails && !$contactId) {
return;
}
// check if there are any tokens
$greetingTokens = self::getTokens($tokenString);
if (!empty($greetingTokens)) {
// first use the existing contact object for token replacement
if (!empty($contactDetails)) {
require_once 'CRM/Utils/Token.php';
$tokenString = CRM_Utils_Token::replaceContactTokens($tokenString, $contactDetails, true, $greetingTokens, true);
}
// check if there are any unevaluated tokens
$greetingTokens = self::getTokens($tokenString);
// $greetingTokens not empty, means there are few tokens which are not evaluated, like custom data etc
// so retrieve it from database
if (!empty($greetingTokens)) {
$greetingsReturnProperties = array_flip(CRM_Utils_Array::value('contact', $greetingTokens));
$greetingsReturnProperties = array_fill_keys(array_keys($greetingsReturnProperties), 1);
$contactParams = array('contact_id' => $contactId);
require_once 'CRM/Mailing/BAO/Mailing.php';
$greetingDetails = CRM_Mailing_BAO_Mailing::getDetails($contactParams, $greetingsReturnProperties, false, false);
// again replace tokens
$tokenString = CRM_Utils_Token::replaceContactTokens($tokenString, $greetingDetails, true, $greetingTokens);
}
}
}
示例5: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
* @return None
*/
static function postProcess(&$form)
{
$formValues = $form->controller->exportValues($form->getName());
// process message template
require_once 'CRM/Core/BAO/MessageTemplates.php';
if (CRM_Utils_Array::value('saveTemplate', $formValues) || CRM_Utils_Array::value('updateTemplate', $formValues)) {
$messageTemplate = array('msg_text' => NULL, 'msg_html' => $formValues['html_message'], 'msg_subject' => NULL, 'is_active' => true);
if ($formValues['saveTemplate']) {
$messageTemplate['msg_title'] = $formValues['saveTemplateName'];
CRM_Core_BAO_MessageTemplates::add($messageTemplate);
}
if ($formValues['template'] && $formValues['updateTemplate']) {
$messageTemplate['id'] = $formValues['template'];
unset($messageTemplate['msg_title']);
CRM_Core_BAO_MessageTemplates::add($messageTemplate);
}
}
require_once 'dompdf/dompdf_config.inc.php';
$html = '<html><head><style>body { margin: 56px; }</style></head><body>';
require_once 'api/v2/Contact.php';
require_once 'CRM/Utils/Token.php';
$tokens = array();
CRM_Utils_Hook::tokens($tokens);
$categories = array_keys($tokens);
$html_message = $formValues['html_message'];
//time being hack to strip ' '
//from particular letter line, CRM-6798
self::formatMessage($html_message);
require_once 'CRM/Activity/BAO/Activity.php';
$messageToken = CRM_Activity_BAO_Activity::getTokens($html_message);
$returnProperties = array();
if (isset($messageToken['contact'])) {
foreach ($messageToken['contact'] as $key => $value) {
$returnProperties[$value] = 1;
}
}
require_once 'CRM/Mailing/BAO/Mailing.php';
$mailing = new CRM_Mailing_BAO_Mailing();
if (defined('CIVICRM_MAIL_SMARTY')) {
require_once 'CRM/Core/Smarty/resources/String.php';
civicrm_smarty_register_string_resource();
}
$first = TRUE;
foreach ($form->_contactIds as $item => $contactId) {
$params = array('contact_id' => $contactId);
list($contact) = $mailing->getDetails($params, $returnProperties, false);
if (civicrm_error($contact)) {
$notSent[] = $contactId;
continue;
}
$tokenHtml = CRM_Utils_Token::replaceContactTokens($html_message, $contact[$contactId], true, $messageToken);
$tokenHtml = CRM_Utils_Token::replaceHookTokens($tokenHtml, $contact[$contactId], $categories, true);
if (defined('CIVICRM_MAIL_SMARTY')) {
$smarty = CRM_Core_Smarty::singleton();
// also add the contact tokens to the template
$smarty->assign_by_ref('contact', $contact);
$tokenHtml = $smarty->fetch("string:{$tokenHtml}");
}
if ($first == TRUE) {
$first = FALSE;
$html .= $tokenHtml;
} else {
$html .= "<div STYLE='page-break-after: always'></div>{$tokenHtml}";
}
}
$html .= '</body></html>';
require_once 'CRM/Activity/BAO/Activity.php';
$session = CRM_Core_Session::singleton();
$userID = $session->get('userID');
$activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Print PDF Letter', 'name');
$activityParams = array('source_contact_id' => $userID, 'activity_type_id' => $activityTypeID, 'activity_date_time' => date('YmdHis'), 'details' => $html_message);
if ($form->_activityId) {
$activityParams += array('id' => $form->_activityId);
}
if ($form->_cid) {
$activity = CRM_Activity_BAO_Activity::create($activityParams);
} else {
// create Print PDF activity for each selected contact. CRM-6886
$activityIds = array();
foreach ($form->_contactIds as $contactId) {
$activityID = CRM_Activity_BAO_Activity::create($activityParams);
$activityIds[$contactId] = $activityID->id;
}
}
foreach ($form->_contactIds as $contactId) {
$activityTargetParams = array('activity_id' => empty($activity->id) ? $activityIds[$contactId] : $activity->id, 'target_contact_id' => $contactId);
CRM_Activity_BAO_Activity::createActivityTarget($activityTargetParams);
}
require_once 'CRM/Utils/PDF/Utils.php';
CRM_Utils_PDF_Utils::html2pdf($html, "CiviLetter.pdf", 'portrait', 'letter');
// we need to call the hook manually here since we redirect and never
// go back to CRM/Core/Form.php
CRM_Utils_Hook::postProcess(get_class($form), $form);
CRM_Utils_System::civiExit(1);
//.........這裏部分代碼省略.........
示例6: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
* @return None
*/
public function postProcess()
{
// get all the details needed to generate a receipt
$contribIDs = implode(',', $this->_contributionIds);
require_once 'CRM/Contribute/Form/Task/Status.php';
$details =& CRM_Contribute_Form_Task_Status::getDetails($contribIDs);
require_once 'CRM/Core/Payment/BaseIPN.php';
$baseIPN = new CRM_Core_Payment_BaseIPN();
$message = array();
$template = CRM_Core_Smarty::singleton();
$params = $this->controller->exportValues($this->_name);
$createPdf = false;
if ($params['output'] == "pdf_receipt") {
$createPdf = true;
}
$excludeContactIds = array();
if (!$createPdf) {
$returnProperties = array('email' => 1, 'do_not_email' => 1, 'is_deceased' => 1, 'on_hold' => 1);
require_once 'CRM/Mailing/BAO/Mailing.php';
list($contactDetails) = CRM_Mailing_BAO_Mailing::getDetails($this->_contactIds, $returnProperties, false, false);
foreach ($contactDetails as $id => $values) {
if (empty($values['email']) || CRM_Utils_Array::value('do_not_email', $values) || CRM_Utils_Array::value('is_deceased', $values) || CRM_Utils_Array::value('on_hold', $values)) {
$suppressedEmails++;
$excludeContactIds[] = $values['contact_id'];
}
}
}
foreach ($details as $contribID => $detail) {
$input = $ids = $objects = array();
if (in_array($detail['contact'], $excludeContactIds)) {
continue;
}
$input['component'] = $detail['component'];
$ids['contact'] = $detail['contact'];
$ids['contribution'] = $contribID;
$ids['contributionRecur'] = null;
$ids['contributionPage'] = null;
$ids['membership'] = $detail['membership'];
$ids['participant'] = $detail['participant'];
$ids['event'] = $detail['event'];
if (!$baseIPN->validateData($input, $ids, $objects, false)) {
CRM_Core_Error::fatal();
}
$contribution =& $objects['contribution'];
// CRM_Core_Error::debug('o',$objects);
// set some fake input values so we can reuse IPN code
$input['amount'] = $contribution->total_amount;
$input['is_test'] = $contribution->is_test;
$input['fee_amount'] = $contribution->fee_amount;
$input['net_amount'] = $contribution->net_amount;
$input['trxn_id'] = $contribution->trxn_id;
$input['trxn_date'] = isset($contribution->trxn_date) ? $contribution->trxn_date : null;
// CRM_Core_Error::debug('input',$input);
$values = array();
$mail = $baseIPN->sendMail($input, $ids, $objects, $values, false, $createPdf);
if (!$mail['html']) {
$mail = str_replace("\n\n", "<p>", $mail);
$mail = str_replace("\n", "<br/>", $mail);
}
$message[] = $mail;
// reset template values before processing next transactions
$template->clearTemplateVars();
}
if ($createPdf) {
require_once 'CRM/Utils/PDF/Utils.php';
CRM_Utils_PDF_Utils::domlib($message, 'civicrmContributionReceipt.pdf', false, 'portrait', 'letter');
CRM_Utils_System::civiExit();
} else {
if ($suppressedEmails) {
$status = array('', ts('Email was NOT sent to %1 contacts (no email address on file, or communication preferences specify DO NOT EMAIL, or contact is deceased).', array(1 => $suppressedEmails)));
} else {
$status = array('', ts('Your mail has been sent.'));
}
CRM_Core_Session::setStatus($status);
}
}
示例7: buildQuickForm
public function buildQuickForm()
{
$session = CRM_Core_Session::singleton();
$this->add('text', 'test_email', ts('Send to This Address'));
$defaults['test_email'] = $session->get('ufUniqID');
$qfKey = $this->get('qfKey');
$this->add('select', 'test_group', ts('Send to This Group'), array('' => ts('- none -')) + CRM_Core_PseudoConstant::group('Mailing'));
$this->setDefaults($defaults);
$this->add('submit', 'sendtest', ts('Send a Test Mailing'));
$name = ts('Next >>');
require_once 'CRM/Mailing/Info.php';
if (CRM_Mailing_Info::workflowEnabled()) {
if (!CRM_Core_Permission::check('schedule mailings') && CRM_Core_Permission::check('create mailings')) {
$name = ts('Inform Scheduler');
}
}
//FIXME : currently we are hiding save an continue later when
//search base mailing, we should handle it when we fix CRM-3876
$buttons = array(array('type' => 'back', 'name' => ts('<< Previous')), array('type' => 'next', 'name' => $name, 'spacing' => ' ', 'isDefault' => true), array('type' => 'submit', 'name' => ts('Save & Continue Later')), array('type' => 'cancel', 'name' => ts('Cancel')));
if ($this->_searchBasedMailing && $this->get('ssID')) {
$buttons = array(array('type' => 'back', 'name' => ts('<< Previous')), array('type' => 'next', 'name' => $name, 'spacing' => ' ', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')));
}
$this->addButtons($buttons);
$mailingID = $this->get('mailing_id');
$textFile = $this->get('textFile');
$htmlFile = $this->get('htmlFile');
$this->addFormRule(array('CRM_Mailing_Form_Test', 'testMail'), $this);
$preview = array();
if ($textFile) {
$preview['text_link'] = CRM_Utils_System::url('civicrm/mailing/preview', "type=text&qfKey={$qfKey}");
}
if ($htmlFile) {
$preview['html_link'] = CRM_Utils_System::url('civicrm/mailing/preview', "type=html&qfKey={$qfKey}");
}
require_once 'CRM/Core/BAO/File.php';
$preview['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_mailing', $mailingID);
$this->assign('preview', $preview);
//Token Replacement of Subject in preview mailing
$options = array();
$prefix = "CRM_Mailing_Controller_Send_{$qfKey}";
if ($this->_searchBasedMailing) {
$prefix = "CRM_Contact_Controller_Search_{$qfKey}";
}
$session->getVars($options, $prefix);
require_once 'CRM/Mailing/BAO/Mailing.php';
$mailing = new CRM_Mailing_BAO_Mailing();
$mailing->id = $options['mailing_id'];
$mailing->find(true);
$fromEmail = $mailing->from_email;
require_once 'CRM/Core/BAO/File.php';
$attachments =& CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id);
$returnProperties = $mailing->getReturnProperties();
$userID = $session->get('userID');
$params = array('contact_id' => $userID);
$details = $mailing->getDetails($params, $returnProperties);
$allDetails =& $mailing->compose(null, null, null, $userID, $fromEmail, $fromEmail, true, $details[0][$userID], $attachments);
$this->assign('subject', $allDetails->_headers['Subject']);
}