本文整理汇总了PHP中CRM_Utils_Token::getDomainTokenReplacement方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Token::getDomainTokenReplacement方法的具体用法?PHP CRM_Utils_Token::getDomainTokenReplacement怎么用?PHP CRM_Utils_Token::getDomainTokenReplacement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Token
的用法示例。
在下文中一共展示了CRM_Utils_Token::getDomainTokenReplacement方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preg_replace_callback
/**
* Replace all the domain-level tokens in $str
*
* @param string $str
* The string with tokens to be replaced.
* @param object $domain
* The domain BAO.
* @param bool $html
* Replace tokens with HTML or plain text.
*
* @param null $knownTokens
* @param bool $escapeSmarty
*
* @return string
* The processed string
*/
public static function &replaceDomainTokens($str, &$domain, $html = FALSE, $knownTokens = NULL, $escapeSmarty = FALSE)
{
$key = 'domain';
if (!$knownTokens || empty($knownTokens[$key])) {
return $str;
}
$str = preg_replace_callback(self::tokenRegex($key), function ($matches) use(&$domain, $html, $escapeSmarty) {
return CRM_Utils_Token::getDomainTokenReplacement($matches[1], $domain, $html, $escapeSmarty);
}, $str);
return $str;
}
示例2: transitionParticipants
/**
* Function takes participant ids and statuses
* update status from $fromStatusId to $toStatusId
* and send mail + create activities.
*
* @param array $participantIds
* Participant ids.
* @param int $toStatusId
* Update status id.
* @param int $fromStatusId
* From status id.
* @param bool $returnResult
* @param bool $skipCascadeRule
*
* @return array|NULL
*/
public static function transitionParticipants($participantIds, $toStatusId, $fromStatusId = NULL, $returnResult = FALSE, $skipCascadeRule = FALSE)
{
if (!is_array($participantIds) || empty($participantIds) || !$toStatusId) {
return NULL;
}
//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();
$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.
$domain = CRM_Core_BAO_Domain::getDomain();
$tokens = array('domain' => array('name', 'phone', 'address', 'email'), 'contact' => CRM_Core_SelectValues::contactTokens());
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.
list($currentContactDetails) = CRM_Utils_Token::getTokenDetails($contactIds, NULL, FALSE, FALSE, NULL, array(), 'CRM_Event_BAO_Participant');
foreach ($currentContactDetails as $contactId => $contactValues) {
$contactDetails[$contactId] = $contactValues;
}
}
//get all required events detail.
if (!empty($eventIds)) {
foreach ($eventIds as $eventId) {
//retrieve event information
$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');
$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':
//.........这里部分代码省略.........
示例3: cancelParticipant
/**
* Cancel this participant and finish, send cancellation email. At this point no
* auto-cancellation of payment is handled, so payment needs to be manually cancelled
*
* return @void
*/
public function cancelParticipant($params)
{
//set participant record status to Cancelled, refund payment if possible
// send email to participant and admin, and log Activity
$value = array();
$value['id'] = $this->_participant_id;
$cancelledId = array_search('Cancelled', CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'"));
$value['status_id'] = $cancelledId;
CRM_Event_BAO_Participant::create($value);
$domainValues = array();
$domain = CRM_Core_BAO_Domain::getDomain();
$tokens = array('domain' => array('name', 'phone', 'address', 'email'), 'contact' => CRM_Core_SelectValues::contactTokens());
foreach ($tokens['domain'] as $token) {
$domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain);
}
$participantRoles = array();
$participantRoles = CRM_Event_PseudoConstant::participantRole();
$participantDetails = array();
$query = "SELECT * FROM civicrm_participant WHERE id = {$this->_participant_id}";
$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);
}
$eventDetails = array();
$eventParams = array('id' => $this->_event_id);
CRM_Event_BAO_Event::retrieve($eventParams, $eventDetails[$this->_event_id]);
//get default participant role.
$eventDetails[$this->_event_id]['participant_role'] = CRM_Utils_Array::value($eventDetails[$this->_event_id]['default_role_id'], $participantRoles);
//get the location info
$locParams = array('entity_id' => $this->_event_id, 'entity_table' => 'civicrm_event');
$eventDetails[$this->_event_id]['location'] = CRM_Core_BAO_Location::getValues($locParams, TRUE);
//get contact details
$contactIds[$this->_contact_id] = $this->_contact_id;
list($currentContactDetails) = CRM_Utils_Token::getTokenDetails($contactIds, NULL, FALSE, FALSE, NULL, array(), 'CRM_Event_BAO_Participant');
foreach ($currentContactDetails as $contactId => $contactValues) {
$contactDetails[$this->_contact_id] = $contactValues;
}
//send a 'cancelled' email to user, and cc the event's cc_confirm email
$mail = CRM_Event_BAO_Participant::sendTransitionParticipantMail($this->_participant_id, $participantDetails[$this->_participant_id], $eventDetails[$this->_event_id], $contactDetails[$this->_contact_id], $domainValues, "Cancelled", "");
$statusMsg = ts('Event registration information for %1 has been updated.', array(1 => $this->_contact_name));
$statusMsg .= ' ' . ts('A cancellation email has been sent to %1.', array(1 => $this->_contact_email));
CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success');
$url = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$this->_event_id}&noFullMsg=true");
CRM_Utils_System::redirect($url);
}
示例4: updatePledgeStatus
public static function updatePledgeStatus($params)
{
$returnMessages = array();
$sendReminders = CRM_Utils_Array::value('send_reminders', $params, FALSE);
$allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
//unset statues that we never use for pledges
foreach (array('Completed', 'Cancelled', 'Failed') as $statusKey) {
if ($key = CRM_Utils_Array::key($statusKey, $allStatus)) {
unset($allStatus[$key]);
}
}
$statusIds = implode(',', array_keys($allStatus));
$updateCnt = 0;
$query = "\nSELECT pledge.contact_id as contact_id,\n pledge.id as pledge_id,\n pledge.amount as amount,\n payment.scheduled_date as scheduled_date,\n pledge.create_date as create_date,\n payment.id as payment_id,\n pledge.currency as currency,\n pledge.contribution_page_id as contribution_page_id,\n payment.reminder_count as reminder_count,\n pledge.max_reminders as max_reminders,\n payment.reminder_date as reminder_date,\n pledge.initial_reminder_day as initial_reminder_day,\n pledge.additional_reminder_day as additional_reminder_day,\n pledge.status_id as pledge_status,\n payment.status_id as payment_status,\n pledge.is_test as is_test,\n pledge.campaign_id as campaign_id,\n SUM(payment.scheduled_amount) as amount_due,\n ( SELECT sum(civicrm_pledge_payment.actual_amount)\n FROM civicrm_pledge_payment\n WHERE civicrm_pledge_payment.status_id = 1\n AND civicrm_pledge_payment.pledge_id = pledge.id\n ) as amount_paid\n FROM civicrm_pledge pledge, civicrm_pledge_payment payment\n WHERE pledge.id = payment.pledge_id\n AND payment.status_id IN ( {$statusIds} ) AND pledge.status_id IN ( {$statusIds} )\n GROUP By payment.id\n ";
$dao = CRM_Core_DAO::executeQuery($query);
$now = date('Ymd');
$pledgeDetails = $contactIds = $pledgePayments = $pledgeStatus = array();
while ($dao->fetch()) {
$checksumValue = CRM_Contact_BAO_Contact_Utils::generateChecksum($dao->contact_id);
$pledgeDetails[$dao->payment_id] = array('scheduled_date' => $dao->scheduled_date, 'amount_due' => $dao->amount_due, 'amount' => $dao->amount, 'amount_paid' => $dao->amount_paid, 'create_date' => $dao->create_date, 'contact_id' => $dao->contact_id, 'pledge_id' => $dao->pledge_id, 'checksumValue' => $checksumValue, 'contribution_page_id' => $dao->contribution_page_id, 'reminder_count' => $dao->reminder_count, 'max_reminders' => $dao->max_reminders, 'reminder_date' => $dao->reminder_date, 'initial_reminder_day' => $dao->initial_reminder_day, 'additional_reminder_day' => $dao->additional_reminder_day, 'pledge_status' => $dao->pledge_status, 'payment_status' => $dao->payment_status, 'is_test' => $dao->is_test, 'currency' => $dao->currency, 'campaign_id' => $dao->campaign_id);
$contactIds[$dao->contact_id] = $dao->contact_id;
$pledgeStatus[$dao->pledge_id] = $dao->pledge_status;
if (CRM_Utils_Date::overdue(CRM_Utils_Date::customFormat($dao->scheduled_date, '%Y%m%d'), $now) && $dao->payment_status != array_search('Overdue', $allStatus)) {
$pledgePayments[$dao->pledge_id][$dao->payment_id] = $dao->payment_id;
}
}
// process the updating script...
foreach ($pledgePayments as $pledgeId => $paymentIds) {
// 1. update the pledge /pledge payment status. returns new status when an update happens
$returnMessages[] = "Checking if status update is needed for Pledge Id: {$pledgeId} (current status is {$allStatus[$pledgeStatus[$pledgeId]]})";
$newStatus = CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeId, $paymentIds, array_search('Overdue', $allStatus), NULL, 0, FALSE, TRUE);
if ($newStatus != $pledgeStatus[$pledgeId]) {
$returnMessages[] = "- status updated to: {$allStatus[$newStatus]}";
$updateCnt += 1;
}
}
if ($sendReminders) {
// retrieve domain tokens
$domain = CRM_Core_BAO_Domain::getDomain();
$tokens = array('domain' => array('name', 'phone', 'address', 'email'), 'contact' => CRM_Core_SelectValues::contactTokens());
$domainValues = array();
foreach ($tokens['domain'] as $token) {
$domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain);
}
//get the domain email address, since we don't carry w/ object.
$domainValue = CRM_Core_BAO_Domain::getNameAndEmail();
$domainValues['email'] = $domainValue[1];
// retrieve contact tokens
// this function does NOT return Deceased contacts since we don't want to send them email
list($contactDetails) = CRM_Utils_Token::getTokenDetails($contactIds, NULL, FALSE, FALSE, NULL, $tokens, 'CRM_UpdatePledgeRecord');
// assign domain values to template
$template = CRM_Core_Smarty::singleton();
$template->assign('domain', $domainValues);
//set receipt from
$receiptFrom = '"' . $domainValues['name'] . '" <' . $domainValues['email'] . '>';
foreach ($pledgeDetails as $paymentId => $details) {
if (array_key_exists($details['contact_id'], $contactDetails)) {
$contactId = $details['contact_id'];
$pledgerName = $contactDetails[$contactId]['display_name'];
} else {
continue;
}
if (empty($details['reminder_date'])) {
$nextReminderDate = new DateTime($details['scheduled_date']);
$nextReminderDate->modify("-" . $details['initial_reminder_day'] . "day");
$nextReminderDate = $nextReminderDate->format("Ymd");
} else {
$nextReminderDate = new DateTime($details['reminder_date']);
$nextReminderDate->modify("+" . $details['additional_reminder_day'] . "day");
$nextReminderDate = $nextReminderDate->format("Ymd");
}
if ($details['reminder_count'] < $details['max_reminders'] && $nextReminderDate <= $now) {
$toEmail = $doNotEmail = $onHold = NULL;
if (!empty($contactDetails[$contactId]['email'])) {
$toEmail = $contactDetails[$contactId]['email'];
}
if (!empty($contactDetails[$contactId]['do_not_email'])) {
$doNotEmail = $contactDetails[$contactId]['do_not_email'];
}
if (!empty($contactDetails[$contactId]['on_hold'])) {
$onHold = $contactDetails[$contactId]['on_hold'];
}
// 2. send acknowledgement mail
if ($toEmail && !($doNotEmail || $onHold)) {
//assign value to template
$template->assign('amount_paid', $details['amount_paid'] ? $details['amount_paid'] : 0);
$template->assign('contact', $contactDetails[$contactId]);
$template->assign('next_payment', $details['scheduled_date']);
$template->assign('amount_due', $details['amount_due']);
$template->assign('checksumValue', $details['checksumValue']);
$template->assign('contribution_page_id', $details['contribution_page_id']);
$template->assign('pledge_id', $details['pledge_id']);
$template->assign('scheduled_payment_date', $details['scheduled_date']);
$template->assign('amount', $details['amount']);
$template->assign('create_date', $details['create_date']);
$template->assign('currency', $details['currency']);
list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_pledge', 'valueName' => 'pledge_reminder', 'contactId' => $contactId, 'from' => $receiptFrom, 'toName' => $pledgerName, 'toEmail' => $toEmail));
// 3. update pledge payment details
if ($mailSent) {
CRM_Pledge_BAO_PledgePayment::updateReminderDetails($paymentId);
//.........这里部分代码省略.........
示例5: getTokenData
/**
*
* getTokenData receives a token from an email
* and returns the appropriate data for the token
*/
private function getTokenData(&$token_a, $html = FALSE, &$contact, &$verp, &$urls, $event_queue_id)
{
$type = $token_a['type'];
$token = $token_a['token'];
$data = $token;
$useSmarty = defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY ? TRUE : FALSE;
if ($type == 'embedded_url') {
$embed_data = array();
foreach ($token as $t) {
$embed_data[] = $this->getTokenData($t, $html = FALSE, $contact, $verp, $urls, $event_queue_id);
}
$numSlices = count($embed_data);
$url = '';
for ($i = 0; $i < $numSlices; $i++) {
$url .= "{$token_a['embed_parts'][$i]}{$embed_data[$i]}";
}
if (isset($token_a['embed_parts'][$numSlices])) {
$url .= $token_a['embed_parts'][$numSlices];
}
// add trailing quote since we've gobbled it up in a previous regex
// function getPatterns, line 431
if (preg_match('/^href[ ]*=[ ]*\'/', $url)) {
$url .= "'";
} elseif (preg_match('/^href[ ]*=[ ]*\\"/', $url)) {
$url .= '"';
}
$data = $url;
} elseif ($type == 'url') {
if ($this->url_tracking) {
$data = CRM_Mailing_BAO_TrackableURL::getTrackerURL($token, $this->id, $event_queue_id);
if (!empty($html)) {
$data = htmlentities($data, ENT_NOQUOTES);
}
} else {
$data = $token;
}
} elseif ($type == 'contact') {
$data = CRM_Utils_Token::getContactTokenReplacement($token, $contact, FALSE, FALSE, $useSmarty);
} elseif ($type == 'action') {
$data = CRM_Utils_Token::getActionTokenReplacement($token, $verp, $urls, $html);
} elseif ($type == 'domain') {
$domain = CRM_Core_BAO_Domain::getDomain();
$data = CRM_Utils_Token::getDomainTokenReplacement($token, $domain, $html);
} elseif ($type == 'mailing') {
if ($token == 'name') {
$data = $this->name;
} elseif ($token == 'group') {
$groups = $this->getGroupNames();
$data = implode(', ', $groups);
}
} else {
$data = CRM_Utils_Array::value("{$type}.{$token}", $contact);
}
return $data;
}
示例6: 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);
//.........这里部分代码省略.........
示例7: sendCancellation
/**
* Send confirmation of cancellation to source participant
*
* return @ void
*/
public function sendCancellation()
{
$domainValues = array();
$domain = CRM_Core_BAO_Domain::getDomain();
$tokens = array('domain' => array('name', 'phone', 'address', 'email'), 'contact' => CRM_Core_SelectValues::contactTokens());
foreach ($tokens['domain'] as $token) {
$domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain);
}
$participantRoles = array();
$participantRoles = CRM_Event_PseudoConstant::participantRole();
$participantDetails = array();
$query = "SELECT * FROM civicrm_participant WHERE id = {$this->_from_participant_id}";
$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);
}
$eventDetails = array();
$eventParams = array('id' => $this->_event_id);
CRM_Event_BAO_Event::retrieve($eventParams, $eventDetails[$this->_event_id]);
//get default participant role.
$eventDetails[$this->_event_id]['participant_role'] = CRM_Utils_Array::value($eventDetails[$this->_event_id]['default_role_id'], $participantRoles);
//get the location info
$locParams = array('entity_id' => $this->_event_id, 'entity_table' => 'civicrm_event');
$eventDetails[$this->_event_id]['location'] = CRM_Core_BAO_Location::getValues($locParams, TRUE);
//get contact details
$contactIds[$this->_from_contact_id] = $this->_from_contact_id;
list($currentContactDetails) = CRM_Utils_Token::getTokenDetails($contactIds, NULL, FALSE, FALSE, NULL, array(), 'CRM_Event_BAO_Participant');
foreach ($currentContactDetails as $contactId => $contactValues) {
$contactDetails[$this->_from_contact_id] = $contactValues;
}
//send a 'cancelled' email to user, and cc the event's cc_confirm email
$mail = CRM_Event_BAO_Participant::sendTransitionParticipantMail($this->_from_participant_id, $participantDetails[$this->_from_participant_id], $eventDetails[$this->_event_id], $contactDetails[$this->_from_contact_id], $domainValues, "Transferred", "");
$statusMsg = ts('Event registration information for %1 has been updated.', array(1 => $this->_contact_name));
$statusMsg .= ' ' . ts('A cancellation email has been sent to %1.', array(1 => $this->_contact_email));
CRM_Core_Session::setStatus($statusMsg, ts('Thanks'), 'success');
}
示例8: getTokenData
/**
*
* getTokenData receives a token from an email
* and returns the appropriate data for the token
*
*/
private function getTokenData(&$token_a, $html = false, &$contact, &$verp, &$urls, $event_queue_id)
{
$type = $token_a['type'];
$token = $token_a['token'];
$data = $token;
$escapeSmarty = defined('CIVICRM_MAIL_SMARTY') ? true : false;
if ($type == 'embedded_url') {
$embed_data = array();
foreach ($token as $t) {
$embed_data[] = $this->getTokenData($t, $html = false, $contact, $verp, $urls, $event_queue_id);
}
$numSlices = count($embed_data);
$url = '';
for ($i = 0; $i < $numSlices; $i++) {
$url .= "{$token_a['embed_parts'][$i]}{$embed_data[$i]}";
}
if (isset($token_a['embed_parts'][$numSlices])) {
$url .= $token_a['embed_parts'][$numSlices];
}
// add trailing quote since we've gobbled it up in a previous regex
// function getPatterns, line 431
if (preg_match('/^href[ ]*=[ ]*\'/', $url)) {
$url .= "'";
} else {
if (preg_match('/^href[ ]*=[ ]*\\"/', $url)) {
$url .= '"';
}
}
$data = $url;
} else {
if ($type == 'url') {
if ($this->url_tracking) {
$data = CRM_Mailing_BAO_TrackableURL::getTrackerURL($token, $this->id, $event_queue_id);
} else {
$data = $token;
}
} else {
if ($type == 'contact') {
$data = CRM_Utils_Token::getContactTokenReplacement($token, $contact, false, false, $escapeSmarty);
} else {
if ($type == 'action') {
$data = CRM_Utils_Token::getActionTokenReplacement($token, $verp, $urls, $html);
} else {
if ($type == 'domain') {
require_once 'CRM/Core/BAO/Domain.php';
$domain =& CRM_Core_BAO_Domain::getDomain();
$data = CRM_Utils_Token::getDomainTokenReplacement($token, $domain, $html);
} else {
if ($type == 'mailing') {
require_once 'CRM/Mailing/BAO/Mailing.php';
$mailing = new CRM_Mailing_BAO_Mailing();
$mailing->find(true);
if ($token == 'name') {
$data = $mailing->name;
} else {
if ($token == 'group') {
$groups = $mailing->getGroupNames();
$data = implode(', ', $groups);
}
}
} else {
$data = CRM_Utils_Array::value("{$type}.{$token}", $contact);
}
}
}
}
}
}
return $data;
}
示例9: render_beleg_pdf
function render_beleg_pdf($contact_id, $address, $total, $items, $from_date, $to_date, $comment)
{
global $civicrm_root;
$docs = get_docs_table();
$config = CRM_Core_Config::singleton(true, true);
/* If receipts already exist for a date range overlapping the requested range, readjust the from date for the new receipt to follow the lastest date for which receipts were already generated. */
$query = "SELECT GREATEST(MAX(DATE_ADD({$docs['field_to']}, INTERVAL 1 DAY)), '{$from_date}' ) AS from_date\n FROM {$docs['table']}\n WHERE entity_id = {$contact_id}\n AND {$docs['field_from']} < '{$to_date}' -- Ignore existing receipts for a date range beginning after the end of the requested range.\n ";
$from_ts = strtotime($from_date);
$to_ts = strtotime($to_date);
$res = CRM_Core_DAO::executeQuery($query);
$res->fetch();
if ($res->from_date) {
$from_date = $res->from_date;
}
$from_ts = strtotime($from_date);
$to_ts = strtotime($to_date);
$template = CRM_Core_Smarty::singleton();
list($html, $page_format) = get_template();
// select and set up template type
if (count($items) > 1) {
// more than one payment -> "Sammelbescheinigung" with itemized list
$item_table = array();
foreach ($items as $item) {
$item_table[] = array('date' => date("j.n.Y", strtotime($item["date"])), 'art' => $item["art"], 'amount' => number_format($item["amount"], 2, ',', '.'), 'amounttext' => num_to_text($item["amount"]));
}
$template->assign("items", $item_table);
} else {
// one payment only -> "Einzelbescheinigung"
$template->assign("items", null);
/* When generating multiple receipts in a batch (Jahresbescheinigungen), the smarty object is reused between the individual receipts (singleton) -- so need to reset this explicitly! */
$template->assign("date", date("d.m.Y", strtotime($items[0]["date"])));
}
// fill further template fields
if (date("m-d", $from_ts) == "01-01" && date("m-d", $to_ts) == "12-31") {
$daterange = date("Y", $from_ts);
} else {
$daterange = date("j.n.", $from_ts) . " bis " . date("j.n.Y", $to_ts);
}
$template->assign("daterange", $daterange);
$template->assign("donor", $address);
$template->assign("total", number_format($total, 2, ',', '.'));
$template->assign("totaltext", num_to_text($total));
$template->assign("today", date("j.n.Y", time()));
if (date("m-d", $from_ts) == "01-01" && date("m-d", $to_ts) == "12-31") {
$rangespec = date("Y", $from_ts);
} else {
$rangespec = date("Y-m-d", $from_ts) . "_" . date("m-d", $to_ts);
}
$domain = CRM_Core_BAO_Domain::getDomain();
$domain_tokens = array();
foreach (array('name', 'address') as $token) {
$domain_tokens[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain, true, true);
}
$domain_tokens['address'] = str_replace('> <', '> <', $domain_tokens['address']);
/* Hack to work around (yet another) bug in dompdf... */
$template->assign('organisation', $domain_tokens);
$html = $template->fetch("string:{$html}");
// set up file names
$basename = CRM_Utils_File::makeFileName("Zuwendungen_" . $rangespec . "_" . $contact_id . ".pdf");
$outfile = $config->customFileUploadDir;
$outfile .= "/{$basename}";
// render PDF receipt
file_put_contents($outfile, CRM_Utils_PDF_Utils::html2pdf($html, null, true, $page_format));
$file_id = saveDocument($contact_id, $basename, "application/pdf", "Spendenbescheinigung", date("Y-m-d h:i:s"), $from_date, $to_date, $comment);
// return summary data and CiviCRM URL to generated file
return array("contact_id" => $contact_id, "file_id" => $file_id, "from_date" => $from_date, "to_date" => $to_date, "total_amount" => $total, "filename" => "{$basename}", "url" => CRM_Utils_System::url("civicrm/file", "reset=1&id={$file_id}&eid={$contact_id}"));
}