当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_BAO_MessageTemplate::sendTemplate方法代码示例

本文整理汇总了PHP中CRM_Core_BAO_MessageTemplate::sendTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_MessageTemplate::sendTemplate方法的具体用法?PHP CRM_Core_BAO_MessageTemplate::sendTemplate怎么用?PHP CRM_Core_BAO_MessageTemplate::sendTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_BAO_MessageTemplate的用法示例。


在下文中一共展示了CRM_Core_BAO_MessageTemplate::sendTemplate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: participantTransfer

 /**
  * Based on input, create participant row for transferee and send email
  *
  * return @ void
  */
 public function participantTransfer($participant)
 {
     $contactDetails = array();
     $contactIds[] = $participant->contact_id;
     list($currentContactDetails) = CRM_Utils_Token::getTokenDetails($contactIds, NULL, FALSE, FALSE, NULL, array(), 'CRM_Event_BAO_Participant');
     foreach ($currentContactDetails as $contactId => $contactValues) {
         $contactDetails[$contactId] = $contactValues;
     }
     $participantRoles = CRM_Event_PseudoConstant::participantRole();
     $participantDetails = array();
     $query = "SELECT * FROM civicrm_participant WHERE id = " . $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);
     }
     $domainValues = array();
     if (empty($domainValues)) {
         $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);
         }
     }
     $eventDetails = array();
     $eventParams = array('id' => $participant->event_id);
     CRM_Event_BAO_Event::retrieve($eventParams, $eventDetails);
     //get default participant role.
     $eventDetails['participant_role'] = CRM_Utils_Array::value($eventDetails['default_role_id'], $participantRoles);
     //get the location info
     $locParams = array('entity_id' => $participant->event_id, 'entity_table' => 'civicrm_event');
     $eventDetails['location'] = CRM_Core_BAO_Location::getValues($locParams, TRUE);
     $toEmail = CRM_Utils_Array::value('email', $contactDetails[$participant->contact_id]);
     if ($toEmail) {
         //take a receipt from as event else domain.
         $receiptFrom = $domainValues['name'] . ' <' . $domainValues['email'] . '>';
         if (!empty($eventDetails['confirm_from_name']) && !empty($eventDetails['confirm_from_email'])) {
             $receiptFrom = $eventDetails['confirm_from_name'] . ' <' . $eventDetails['confirm_from_email'] . '>';
         }
         $participantName = $contactDetails[$participant->contact_id]['display_name'];
         $tplParams = array('event' => $eventDetails, 'participant' => $participantDetails[$participant->id], 'participantID' => $participant->id, 'participant_status' => 'Registered');
         $sendTemplateParams = array('groupName' => 'msg_tpl_workflow_event', 'valueName' => 'event_online_receipt', 'contactId' => $participantDetails[$participant->id]['contact_id'], 'tplParams' => $tplParams, 'from' => $receiptFrom, 'toName' => $participantName, 'toEmail' => $toEmail, 'cc' => CRM_Utils_Array::value('cc_confirm', $eventDetails), 'bcc' => CRM_Utils_Array::value('bcc_confirm', $eventDetails));
         CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
     }
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:49,代码来源:SelfSvcTransfer.php

示例2: emailReceipt


//.........这里部分代码省略.........
     if (property_exists($form, '_groupTree') && !empty($form->_groupTree)) {
         foreach ($form->_groupTree as $groupID => $group) {
             if ($groupID == 'info') {
                 continue;
             }
             foreach ($group['fields'] as $k => $field) {
                 $field['title'] = $field['label'];
                 $customFields["custom_{$k}"] = $field;
             }
         }
     }
     $members = array(array('member_id', '=', $membership->id, 0, 0));
     // check whether its a test drive
     if ($form->_mode == 'test') {
         $members[] = array('member_test', '=', 1, 0, 0);
     }
     CRM_Core_BAO_UFGroup::getValues($formValues['contact_id'], $customFields, $customValues, FALSE, $members);
     if ($form->_mode) {
         if (!empty($form->_params['billing_first_name'])) {
             $name = $form->_params['billing_first_name'];
         }
         if (!empty($form->_params['billing_middle_name'])) {
             $name .= " {$form->_params['billing_middle_name']}";
         }
         if (!empty($form->_params['billing_last_name'])) {
             $name .= " {$form->_params['billing_last_name']}";
         }
         $form->assign('billingName', $name);
         // assign the address formatted up for display
         $addressParts = array("street_address-{$form->_bltID}", "city-{$form->_bltID}", "postal_code-{$form->_bltID}", "state_province-{$form->_bltID}", "country-{$form->_bltID}");
         $addressFields = array();
         foreach ($addressParts as $part) {
             list($n, $id) = explode('-', $part);
             if (isset($form->_params['billing_' . $part])) {
                 $addressFields[$n] = $form->_params['billing_' . $part];
             }
         }
         $form->assign('address', CRM_Utils_Address::format($addressFields));
         $date = CRM_Utils_Date::format($form->_params['credit_card_exp_date']);
         $date = CRM_Utils_Date::mysqlToIso($date);
         $form->assign('credit_card_exp_date', $date);
         $form->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($form->_params['credit_card_number']));
         $form->assign('credit_card_type', $form->_params['credit_card_type']);
         $form->assign('contributeMode', 'direct');
         $form->assign('isAmountzero', 0);
         $form->assign('is_pay_later', 0);
         $form->assign('isPrimary', 1);
     }
     $form->assign('module', 'Membership');
     $form->assign('contactID', $formValues['contact_id']);
     $form->assign('membershipID', CRM_Utils_Array::value('membership_id', $form->_params, CRM_Utils_Array::value('membership_id', $form->_defaultValues)));
     if (!empty($formValues['contribution_id'])) {
         $form->assign('contributionID', $formValues['contribution_id']);
     } elseif (isset($form->_onlinePendingContributionId)) {
         $form->assign('contributionID', $form->_onlinePendingContributionId);
     }
     if (!empty($formValues['contribution_status_id'])) {
         $form->assign('contributionStatusID', $formValues['contribution_status_id']);
         $form->assign('contributionStatus', CRM_Contribute_PseudoConstant::contributionStatus($formValues['contribution_status_id'], 'name'));
     }
     if (!empty($formValues['is_renew'])) {
         $form->assign('receiptType', 'membership renewal');
     } else {
         $form->assign('receiptType', 'membership signup');
     }
     $form->assign('receive_date', CRM_Utils_Date::processDate(CRM_Utils_Array::value('receive_date', $formValues)));
     $form->assign('formValues', $formValues);
     if (empty($lineItem)) {
         $form->assign('mem_start_date', CRM_Utils_Date::customFormat($membership->start_date, '%B %E%f, %Y'));
         if (!CRM_Utils_System::isNull($membership->end_date)) {
             $form->assign('mem_end_date', CRM_Utils_Date::customFormat($membership->end_date, '%B %E%f, %Y'));
         }
         $form->assign('membership_name', CRM_Member_PseudoConstant::membershipType($membership->membership_type_id));
     }
     $form->assign('customValues', $customValues);
     $isBatchProcess = is_a($form, 'CRM_Batch_Form_Entry');
     if (empty($form->_contributorDisplayName) || empty($form->_contributorEmail) || $isBatchProcess) {
         // in this case the form is being called statically from the batch editing screen
         // having one class in the form layer call another statically is not greate
         // & we should aim to move this function to the BAO layer in future.
         // however, we can assume that the contact_id passed in by the batch
         // function will be the recipient
         list($form->_contributorDisplayName, $form->_contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($formValues['contact_id']);
         if (empty($form->_receiptContactId) || $isBatchProcess) {
             $form->_receiptContactId = $formValues['contact_id'];
         }
     }
     $template = CRM_Core_Smarty::singleton();
     $taxAmt = $template->get_template_vars('dataArray');
     $eventTaxAmt = $template->get_template_vars('totalTaxAmount');
     $prefixValue = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
     $invoicing = CRM_Utils_Array::value('invoicing', $prefixValue);
     if ((!empty($taxAmt) || isset($eventTaxAmt)) && (isset($invoicing) && isset($prefixValue['is_email_pdf']))) {
         $isEmailPdf = TRUE;
     } else {
         $isEmailPdf = FALSE;
     }
     list($mailSend, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_membership', 'valueName' => 'membership_offline_receipt', 'contactId' => $form->_receiptContactId, 'from' => $receiptFrom, 'toName' => $form->_contributorDisplayName, 'toEmail' => $form->_contributorEmail, 'PDFFilename' => ts('receipt') . '.pdf', 'isEmailPdf' => $isEmailPdf, 'contributionId' => $formValues['contribution_id'], 'isTest' => (bool) ($form->_action & CRM_Core_Action::PREVIEW)));
     return TRUE;
 }
开发者ID:indydas,项目名称:civi-demo,代码行数:101,代码来源:Membership.php

示例3: sendActivityCopy

 /**
  * Function that sends e-mail copy of activity
  *
  * @param $clientId
  * @param int $activityId activity Id
  * @param array $contacts array of related contact
  *
  * @param null $attachments
  * @param $caseId
  *
  * @return void
  * @access public
  */
 static function sendActivityCopy($clientId, $activityId, $contacts, $attachments = NULL, $caseId)
 {
     if (!$activityId) {
         return;
     }
     $tplParams = $activityInfo = array();
     //if its a case activity
     if ($caseId) {
         $activityTypeId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activityId, 'activity_type_id');
         $nonCaseActivityTypes = CRM_Core_PseudoConstant::activityType();
         if (!empty($nonCaseActivityTypes[$activityTypeId])) {
             $anyActivity = TRUE;
         } else {
             $anyActivity = FALSE;
         }
         $tplParams['isCaseActivity'] = 1;
         $tplParams['client_id'] = $clientId;
     } else {
         $anyActivity = TRUE;
     }
     $xmlProcessorProcess = new CRM_Case_XMLProcessor_Process();
     $isRedact = $xmlProcessorProcess->getRedactActivityEmail();
     $xmlProcessorReport = new CRM_Case_XMLProcessor_Report();
     $activityInfo = $xmlProcessorReport->getActivityInfo($clientId, $activityId, $anyActivity, $isRedact);
     if ($caseId) {
         $activityInfo['fields'][] = array('label' => 'Case ID', 'type' => 'String', 'value' => $caseId);
     }
     $tplParams['activity'] = $activityInfo;
     foreach ($tplParams['activity']['fields'] as $k => $val) {
         if (CRM_Utils_Array::value('label', $val) == ts('Subject')) {
             $activitySubject = $val['value'];
             break;
         }
     }
     $session = CRM_Core_Session::singleton();
     // CRM-8926 If user is not logged in, use the activity creator as userID
     if (!($userID = $session->get('userID'))) {
         $userID = CRM_Activity_BAO_Activity::getSourceContactID($activityId);
     }
     //also create activities simultaneously of this copy.
     $activityParams = array();
     $activityParams['source_record_id'] = $activityId;
     $activityParams['source_contact_id'] = $userID;
     $activityParams['activity_type_id'] = CRM_Core_OptionGroup::getValue('activity_type', 'Email', 'name');
     $activityParams['activity_date_time'] = date('YmdHis');
     $activityParams['status_id'] = CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name');
     $activityParams['medium_id'] = CRM_Core_OptionGroup::getValue('encounter_medium', 'email', 'name');
     $activityParams['case_id'] = $caseId;
     $activityParams['is_auto'] = 0;
     $activityParams['target_id'] = $clientId;
     $tplParams['activitySubject'] = $activitySubject;
     // if it’s a case activity, add hashed id to the template (CRM-5916)
     if ($caseId) {
         $tplParams['idHash'] = substr(sha1(CIVICRM_SITE_KEY . $caseId), 0, 7);
     }
     $result = array();
     list($name, $address) = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
     $receiptFrom = "{$name} <{$address}>";
     $recordedActivityParams = array();
     foreach ($contacts as $mail => $info) {
         $tplParams['contact'] = $info;
         self::buildPermissionLinks($tplParams, $activityParams);
         $displayName = CRM_Utils_Array::value('display_name', $info);
         list($result[CRM_Utils_Array::value('contact_id', $info)], $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_case', 'valueName' => 'case_activity', 'contactId' => CRM_Utils_Array::value('contact_id', $info), 'tplParams' => $tplParams, 'from' => $receiptFrom, 'toName' => $displayName, 'toEmail' => $mail, 'attachments' => $attachments));
         $activityParams['subject'] = $activitySubject . ' - copy sent to ' . $displayName;
         $activityParams['details'] = $message;
         if (!empty($result[$info['contact_id']])) {
             /*
              * Really only need to record one activity with all the targets combined.
              * Originally the template was going to possibly have different content, e.g. depending on permissions,
              * but it's always the same content at the moment.
              */
             if (empty($recordedActivityParams)) {
                 $recordedActivityParams = $activityParams;
             } else {
                 $recordedActivityParams['subject'] .= "; {$displayName}";
             }
             $recordedActivityParams['target_contact_id'][] = $info['contact_id'];
         } else {
             unset($result[CRM_Utils_Array::value('contact_id', $info)]);
         }
     }
     if (!empty($recordedActivityParams)) {
         $activity = CRM_Activity_BAO_Activity::create($recordedActivityParams);
         //create case_activity record if its case activity.
         if ($caseId) {
             $caseParams = array('activity_id' => $activity->id, 'case_id' => $caseId);
//.........这里部分代码省略.........
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:101,代码来源:Case.php

示例4: pcpNotifyOwner

 /**
  * Function used to send notification mail to pcp owner.
  *
  * This is used by contribution and also event PCPs.
  *
  * @param object $contribution
  * @param object $contributionSoft
  *   Contribution object.
  */
 public static function pcpNotifyOwner($contribution, $contributionSoft)
 {
     $params = array('id' => $contributionSoft->pcp_id);
     CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $params, $pcpInfo);
     $ownerNotifyID = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCPBlock', $pcpInfo['pcp_block_id'], 'owner_notify_id');
     if ($ownerNotifyID != CRM_Core_OptionGroup::getValue('pcp_owner_notify', 'no_notifications', 'name') && ($ownerNotifyID == CRM_Core_OptionGroup::getValue('pcp_owner_notify', 'owner_chooses', 'name') && CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $contributionSoft->pcp_id, 'is_notify') || $ownerNotifyID == CRM_Core_OptionGroup::getValue('pcp_owner_notify', 'all_owners', 'name'))) {
         $pcpInfoURL = CRM_Utils_System::url('civicrm/pcp/info', "reset=1&id={$contributionSoft->pcp_id}", TRUE, NULL, FALSE, TRUE);
         // set email in the template here
         if (CRM_Core_BAO_LocationType::getBilling()) {
             list($donorName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contribution->contact_id, FALSE, CRM_Core_BAO_LocationType::getBilling());
         }
         // get primary location email if no email exist( for billing location).
         if (!$email) {
             list($donorName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contribution->contact_id);
         }
         list($ownerName, $ownerEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contributionSoft->contact_id);
         $tplParams = array('page_title' => $pcpInfo['title'], 'receive_date' => $contribution->receive_date, 'total_amount' => $contributionSoft->amount, 'donors_display_name' => $donorName, 'donors_email' => $email, 'pcpInfoURL' => $pcpInfoURL, 'is_honor_roll_enabled' => $contributionSoft->pcp_display_in_roll, 'currency' => $contributionSoft->currency);
         $domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
         $sendTemplateParams = array('groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'pcp_owner_notify', 'contactId' => $contributionSoft->contact_id, 'toEmail' => $ownerEmail, 'toName' => $ownerName, 'from' => "{$domainValues['0']} <{$domainValues['1']}>", 'tplParams' => $tplParams, 'PDFFilename' => 'receipt.pdf');
         CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
     }
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:31,代码来源:Confirm.php

示例5: sendMail

 /**
  * Process that send tell a friend e-mails
  *
  * @param int $contactID
  * @param array $values
  *
  * @return void
  */
 public static function sendMail($contactID, &$values)
 {
     list($fromName, $email) = CRM_Contact_BAO_Contact::getContactDetails($contactID);
     // if no $fromName (only email collected from originating contact) - list returns single space
     if (trim($fromName) == '') {
         $fromName = $email;
     }
     // use contact email, CRM-4963
     if (empty($values['email_from'])) {
         $values['email_from'] = $email;
     }
     foreach ($values['email'] as $displayName => $emailTo) {
         if ($emailTo) {
             // FIXME: factor the below out of the foreach loop
             CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_friend', 'valueName' => 'friend', 'contactId' => $contactID, 'tplParams' => array($values['module'] => $values['module'], 'senderContactName' => $fromName, 'title' => $values['title'], 'generalLink' => $values['general_link'], 'pageURL' => $values['page_url'], 'senderMessage' => $values['message']), 'from' => "{$fromName} (via {$values['domain']}) <{$values['email_from']}>", 'toName' => $displayName, 'toEmail' => $emailTo, 'replyTo' => $email));
         }
     }
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:26,代码来源:Friend.php

示例6: sendMail

 /**
  * Process that send e-mails
  *
  * @return void
  * @access public
  */
 static function sendMail($contactID, &$values, $isTest = FALSE, $returnMessageText = FALSE)
 {
     //TODO:: check if from email address is entered
     $config = CRM_Booking_BAO_BookingConfig::getConfig();
     $template = CRM_Core_Smarty::singleton();
     list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
     //send email only when email is present
     if ($email) {
         $bookingId = $values['booking_id'];
         //get latest booking status
         $params = array('id' => $bookingId);
         $bookingLatest = civicrm_api3('Booking', 'get', $params);
         $bookingStatusValueItems = CRM_Booking_BAO_Booking::buildOptions('status_id', 'create');
         //get booking status option values
         $bookingLatestStatus = $bookingStatusValueItems[$bookingLatest['values'][$bookingId]['status_id']];
         //get booking detail
         $bookingDetail = CRM_Booking_BAO_Booking::getBookingDetails($values['booking_id']);
         $slots = CRM_Utils_Array::value('slots', $bookingDetail);
         $subSlots = CRM_Utils_Array::value('sub_slots', $bookingDetail);
         $adhocCharges = CRM_Utils_Array::value('adhoc_charges', $bookingDetail);
         $cancellationCharges = CRM_Utils_Array::value('cancellation_charges', $bookingDetail);
         //get contacts associating with booking
         $contactIds = array();
         $contactIds['primary_contact'] = CRM_Utils_Array::value('primary_contact_id', $values);
         $contactIds['secondary_contact'] = CRM_Utils_Array::value('secondary_contact_id', $values);
         $contactsDetail = array();
         foreach (array_filter($contactIds) as $k => $contactIdItem) {
             //get contact detail
             $contactDetail = array();
             $params = array('contact_id' => $contactIdItem);
             $contactDetailResult = civicrm_api3('Contact', 'get', $params);
             $contactValues = CRM_Utils_Array::value($contactDetailResult['id'], $contactDetailResult['values']);
             foreach ($contactValues as $key => $contactItem) {
                 $contactDetail[$key] = $contactItem;
             }
             $contactsDetail[$k] = $contactDetail;
         }
         //get Price elements(Subtotal, Discount, Total)
         $booking_amount = CRM_Booking_BAO_Booking::getBookingAmount($values['booking_id']);
         //get date booking made
         $dateBookingMade = new DateTime($values['booking_date']);
         $tplParams = array('email' => $email, 'today_date' => date('d.m.Y'), 'receipt_header_message' => $values['receipt_header_message'], 'receipt_footer_message' => $values['receipt_footer_message'], 'booking_id' => $bookingId, 'booking_title' => $values['booking_title'], 'booking_status' => $bookingLatestStatus, 'booking_date_made' => $values['booking_date'], 'booking_start_date' => $values['booking_start_date'], 'booking_end_date' => $values['booking_end_date'], 'booking_event_day' => $dateBookingMade->format('l'), 'booking_subtotal' => number_format($booking_amount['total_amount'] + $booking_amount['discount_amount'], 2, '.', ''), 'booking_total' => number_format($booking_amount['total_amount'], 2, '.', ''), 'booking_discount' => number_format($booking_amount['discount_amount'], 2, '.', ''), 'participants_estimate' => $values['participants_estimate'], 'participants_actual' => $values['participants_actual'], 'contacts' => $contactsDetail, 'slots' => $slots, 'sub_slots' => $subSlots, 'adhoc_charges' => $adhocCharges, 'cancellation_charges' => $cancellationCharges);
         $sendTemplateParams = array('groupName' => 'msg_tpl_workflow_booking', 'valueName' => 'booking_offline_receipt', 'contactId' => $contactID, 'isTest' => $isTest, 'tplParams' => $tplParams, 'PDFFilename' => 'bookingReceipt.pdf');
         //get include payment check box
         //if(CRM_Utils_Array::value('include_payment_info', $values)){
         if (CRM_Utils_Array::value('contribution', $bookingDetail)) {
             //get contribution record
             $contribution = array();
             $contributionResult = CRM_Utils_Array::value('contribution', $bookingDetail);
             foreach ($contributionResult as $kx => $ctbItem) {
                 $contribution = $ctbItem;
             }
             $sendTemplateParams['tplParams']['contribution'] = $contribution;
             //calculate Amount outstanding
             $sendTemplateParams['tplParams']['amount_outstanding'] = number_format($booking_amount['total_amount'] - $contribution['total_amount'], 2, '.', '');
         }
         //TODO:: add line item tpl params
         if ($lineItem = CRM_Utils_Array::value('lineItem', $values)) {
             $sendTemplateParams['tplParams']['lineItem'] = $lineItem;
         }
         $sendTemplateParams['from'] = $values['from_email_address'];
         $sendTemplateParams['toName'] = $displayName;
         $sendTemplateParams['toEmail'] = $email;
         //$sendTemplateParams['autoSubmitted'] = TRUE;
         $cc = CRM_Utils_Array::value('cc_email_address', $config);
         if ($cc) {
             $sendTemplateParams['cc'] = $cc;
         }
         $bcc = CRM_Utils_Array::value('bcc_email_address', $config);
         if ($bcc) {
             $sendTemplateParams['bcc'] = $bcc;
         }
         list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
         if ($sent && CRM_Utils_Array::value('log_confirmation_email', $config)) {
             //check log_email_confirmaiton
             $session =& CRM_Core_Session::singleton();
             $userId = $session->get('userID');
             // which is contact id of the user
             //create activity for sending email
             $params = array('option_group_name' => 'activity_type', 'name' => CRM_Booking_Utils_Constants::ACTIVITY_TYPE_SEND_EMAIL);
             $optionValue = civicrm_api3('OptionValue', 'get', $params);
             $activityTypeId = $optionValue['values'][$optionValue['id']]['value'];
             $params = array('source_contact_id' => $userId, 'activity_type_id' => $activityTypeId, 'subject' => ts('Send Booking Confirmation Email'), 'activity_date_time' => date('YmdHis'), 'target_contact_id' => $contactID, 'details' => $message, 'status_id' => 2, 'priority_id' => 2);
             $result = civicrm_api3('Activity', 'create', $params);
         }
         if ($returnMessageText) {
             return array('subject' => $subject, 'body' => $message, 'to' => $displayName, 'html' => $html);
         }
     }
 }
开发者ID:sushantpaste,项目名称:civibooking,代码行数:96,代码来源:Booking.php

示例7: sendEmail

 /**
 * takes an associative array and sends a thank you or email verification email
 *
 * @param array $params (reference ) an assoc array of name/value pairs
 *
 * @param $sendEmailMode
 *
 * @throws Exception
 * @return void
   @access public
 * @static
 */
 public static function sendEmail($params, $sendEmailMode)
 {
     /* sendEmailMode
      * CRM_Campaign_Form_Petition_Signature::EMAIL_THANK
      *   connected user via login/pwd - thank you
      *    or dedupe contact matched who doesn't have a tag CIVICRM_TAG_UNCONFIRMED - thank you
      *   or login using fb connect - thank you + click to add msg to fb wall
      *
      * CRM_Campaign_Form_Petition_Signature::EMAIL_CONFIRM
      *  send a confirmation request email
      */
     // check if the group defined by CIVICRM_PETITION_CONTACTS exists, else create it
     $petitionGroupName = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'petition_contacts', NULL, 'Petition Contacts');
     $dao = new CRM_Contact_DAO_Group();
     $dao->title = $petitionGroupName;
     if (!$dao->find(TRUE)) {
         $dao->is_active = 1;
         $dao->visibility = 'User and User Admin Only';
         $dao->save();
     }
     $group_id = $dao->id;
     // get petition info
     $petitionParams['id'] = $params['sid'];
     $petitionInfo = array();
     CRM_Campaign_BAO_Survey::retrieve($petitionParams, $petitionInfo);
     if (empty($petitionInfo)) {
         CRM_Core_Error::fatal('Petition doesn\'t exist.');
     }
     //get the default domain email address.
     list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
     $emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
     $toName = CRM_Contact_BAO_Contact::displayName($params['contactId']);
     $replyTo = "do-not-reply@{$emailDomain}";
     // set additional general message template params (custom tokens to use in email msg templates)
     // tokens then available in msg template as {$petition.title}, etc
     $petitionTokens['title'] = $petitionInfo['title'];
     $petitionTokens['petitionId'] = $params['sid'];
     $tplParams['petition'] = $petitionTokens;
     switch ($sendEmailMode) {
         case CRM_Campaign_Form_Petition_Signature::EMAIL_THANK:
             // add this contact to the CIVICRM_PETITION_CONTACTS group
             // Cannot pass parameter 1 by reference
             $p = array($params['contactId']);
             CRM_Contact_BAO_GroupContact::addContactsToGroup($p, $group_id, 'API');
             if ($params['email-Primary']) {
                 CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_petition', 'valueName' => 'petition_sign', 'contactId' => $params['contactId'], 'tplParams' => $tplParams, 'from' => "\"{$domainEmailName}\" <{$domainEmailAddress}>", 'toName' => $toName, 'toEmail' => $params['email-Primary'], 'replyTo' => $replyTo, 'petitionId' => $params['sid'], 'petitionTitle' => $petitionInfo['title']));
             }
             break;
         case CRM_Campaign_Form_Petition_Signature::EMAIL_CONFIRM:
             // create mailing event subscription record for this contact
             // this will allow using a hash key to confirm email address by sending a url link
             $se = CRM_Mailing_Event_BAO_Subscribe::subscribe($group_id, $params['email-Primary'], $params['contactId'], 'profile');
             //    require_once 'CRM/Core/BAO/Domain.php';
             //    $domain = CRM_Core_BAO_Domain::getDomain();
             $config = CRM_Core_Config::singleton();
             $localpart = CRM_Core_BAO_MailSettings::defaultLocalpart();
             $replyTo = implode($config->verpSeparator, array($localpart . 'c', $se->contact_id, $se->id, $se->hash)) . "@{$emailDomain}";
             $confirmUrl = CRM_Utils_System::url('civicrm/petition/confirm', "reset=1&cid={$se->contact_id}&sid={$se->id}&h={$se->hash}&a={$params['activityId']}&p={$params['sid']}", TRUE);
             $confirmUrlPlainText = CRM_Utils_System::url('civicrm/petition/confirm', "reset=1&cid={$se->contact_id}&sid={$se->id}&h={$se->hash}&a={$params['activityId']}&p={$params['sid']}", TRUE, NULL, FALSE);
             // set email specific message template params and assign to tplParams
             $petitionTokens['confirmUrl'] = $confirmUrl;
             $petitionTokens['confirmUrlPlainText'] = $confirmUrlPlainText;
             $tplParams['petition'] = $petitionTokens;
             if ($params['email-Primary']) {
                 CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_petition', 'valueName' => 'petition_confirmation_needed', 'contactId' => $params['contactId'], 'tplParams' => $tplParams, 'from' => "\"{$domainEmailName}\" <{$domainEmailAddress}>", 'toName' => $toName, 'toEmail' => $params['email-Primary'], 'replyTo' => $replyTo, 'petitionId' => $params['sid'], 'petitionTitle' => $petitionInfo['title'], 'confirmUrl' => $confirmUrl));
             }
             break;
     }
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:81,代码来源:Petition.php

示例8: emailReceipt

 /**
  * @param $events_in_cart
  * @param array $params
  */
 public function emailReceipt($events_in_cart, $params)
 {
     $contact_details = CRM_Contact_BAO_Contact::getContactDetails($this->payer_contact_id);
     $state_province = new CRM_Core_DAO_StateProvince();
     $state_province->id = $params["billing_state_province_id-{$this->_bltID}"];
     $state_province->find();
     $state_province->fetch();
     $country = new CRM_Core_DAO_Country();
     $country->id = $params["billing_country_id-{$this->_bltID}"];
     $country->find();
     $country->fetch();
     foreach ($this->line_items as &$line_item) {
         $location_params = array('entity_id' => $line_item['event']->id, 'entity_table' => 'civicrm_event');
         $line_item['location'] = CRM_Core_BAO_Location::getValues($location_params, TRUE);
         CRM_Core_BAO_Address::fixAddress($line_item['location']['address'][1]);
     }
     $send_template_params = array('table' => 'civicrm_msg_template', 'contactId' => $this->payer_contact_id, 'from' => $this->getDefaultFrom(), 'groupName' => 'msg_tpl_workflow_event', 'isTest' => FALSE, 'toEmail' => $contact_details[1], 'toName' => $contact_details[0], 'tplParams' => array('billing_name' => "{$params['billing_first_name']} {$params['billing_last_name']}", 'billing_city' => $params["billing_city-{$this->_bltID}"], 'billing_country' => $country->name, 'billing_postal_code' => $params["billing_postal_code-{$this->_bltID}"], 'billing_state' => $state_province->abbreviation, 'billing_street_address' => $params["billing_street_address-{$this->_bltID}"], 'credit_card_exp_date' => $params['credit_card_exp_date'], 'credit_card_type' => $params['credit_card_type'], 'credit_card_number' => "************" . substr($params['credit_card_number'], -4, 4), 'discounts' => $this->discounts, 'email' => $contact_details[1], 'events_in_cart' => $events_in_cart, 'line_items' => $this->line_items, 'name' => $contact_details[0], 'transaction_id' => $params['trxn_id'], 'transaction_date' => $params['trxn_date'], 'is_pay_later' => $this->is_pay_later, 'pay_later_receipt' => $this->pay_later_receipt), 'valueName' => 'event_registration_receipt', 'PDFFilename' => ts('confirmation') . '.pdf');
     $template_params_to_copy = array('billing_name', 'billing_city', 'billing_country', 'billing_postal_code', 'billing_state', 'billing_street_address', 'credit_card_exp_date', 'credit_card_type', 'credit_card_number');
     foreach ($template_params_to_copy as $template_param_to_copy) {
         $this->set($template_param_to_copy, $send_template_params['tplParams'][$template_param_to_copy]);
     }
     CRM_Core_BAO_MessageTemplate::sendTemplate($send_template_params);
 }
开发者ID:agloa,项目名称:tournament,代码行数:27,代码来源:Payment.php

示例9: emailReceipt


//.........这里部分代码省略.........
     // date to template
     if (!empty($params['hidden_Premium'])) {
         if (isset($params['product_name']) && is_array($params['product_name']) && !empty($params['product_name'])) {
             $productDAO = new CRM_Contribute_DAO_Product();
             $productDAO->id = $params['product_name'][0];
             $productOptionID = $params['product_name'][1];
             $productDAO->find(TRUE);
             $params['product_name'] = $productDAO->name;
             $params['product_sku'] = $productDAO->sku;
             if (empty($params['product_option']) && !empty($form->_options[$productDAO->id])) {
                 $params['product_option'] = $form->_options[$productDAO->id][$productOptionID];
             }
         }
         if (!empty($params['fulfilled_date'])) {
             $form->assign('fulfilled_date', CRM_Utils_Date::processDate($params['fulfilled_date']));
         }
     }
     $form->assign('ccContribution', $ccContribution);
     if ($ccContribution) {
         //build the name.
         $name = CRM_Utils_Array::value('billing_first_name', $params);
         if (!empty($params['billing_middle_name'])) {
             $name .= " {$params['billing_middle_name']}";
         }
         $name .= ' ' . CRM_Utils_Array::value('billing_last_name', $params);
         $name = trim($name);
         $form->assign('billingName', $name);
         //assign the address formatted up for display
         $addressParts = array("street_address" => "billing_street_address-{$form->_bltID}", "city" => "billing_city-{$form->_bltID}", "postal_code" => "billing_postal_code-{$form->_bltID}", "state_province" => "state_province-{$form->_bltID}", "country" => "country-{$form->_bltID}");
         $addressFields = array();
         foreach ($addressParts as $name => $field) {
             $addressFields[$name] = CRM_Utils_Array::value($field, $params);
         }
         $form->assign('address', CRM_Utils_Address::format($addressFields));
         $date = CRM_Utils_Date::format($params['credit_card_exp_date']);
         $date = CRM_Utils_Date::mysqlToIso($date);
         $form->assign('credit_card_type', CRM_Utils_Array::value('credit_card_type', $params));
         $form->assign('credit_card_exp_date', $date);
         $form->assign('credit_card_number', CRM_Utils_System::mungeCreditCard($params['credit_card_number']));
     } else {
         //offline contribution
         // assigned various dates to the templates
         $form->assign('receipt_date', CRM_Utils_Date::processDate($params['receipt_date']));
         if (!empty($params['cancel_date'])) {
             $form->assign('cancel_date', CRM_Utils_Date::processDate($params['cancel_date']));
         }
         if (!empty($params['thankyou_date'])) {
             $form->assign('thankyou_date', CRM_Utils_Date::processDate($params['thankyou_date']));
         }
         if ($form->_action & CRM_Core_Action::UPDATE) {
             $form->assign('lineItem', empty($form->_lineItems) ? FALSE : $form->_lineItems);
         }
     }
     //handle custom data
     if (!empty($params['hidden_custom'])) {
         $contribParams = array(array('contribution_id', '=', $params['contribution_id'], 0, 0));
         if ($form->_mode == 'test') {
             $contribParams[] = array('contribution_test', '=', 1, 0, 0);
         }
         //retrieve custom data
         $customGroup = array();
         foreach ($form->_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;
             }
             //build the array of customgroup contain customfields.
             CRM_Core_BAO_UFGroup::getValues($params['contact_id'], $customFields, $customValues, FALSE, $contribParams);
             $customGroup[$group['title']] = $customValues;
         }
         //assign all custom group and corresponding fields to template.
         $form->assign('customGroup', $customGroup);
     }
     $form->assign_by_ref('formValues', $params);
     list($contributorDisplayName, $contributorEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($params['contact_id']);
     $form->assign('contactID', $params['contact_id']);
     $form->assign('contributionID', $params['contribution_id']);
     if (!empty($params['currency'])) {
         $form->assign('currency', $params['currency']);
     }
     if (!empty($params['receive_date'])) {
         $form->assign('receive_date', CRM_Utils_Date::processDate($params['receive_date']));
     }
     $template = CRM_Core_Smarty::singleton();
     $taxAmt = $template->get_template_vars('dataArray');
     $eventTaxAmt = $template->get_template_vars('totalTaxAmount');
     $prefixValue = Civi::settings()->get('contribution_invoice_settings');
     $invoicing = CRM_Utils_Array::value('invoicing', $prefixValue);
     if ((!empty($taxAmt) || isset($eventTaxAmt)) && (isset($invoicing) && isset($prefixValue['is_email_pdf']))) {
         $isEmailPdf = TRUE;
     } else {
         $isEmailPdf = FALSE;
     }
     list($sendReceipt, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'contribution_offline_receipt', 'contactId' => $params['contact_id'], 'contributionId' => $params['contribution_id'], 'from' => $params['from_email_address'], 'toName' => $contributorDisplayName, 'toEmail' => $contributorEmail, 'isTest' => $form->_mode == 'test', 'PDFFilename' => ts('receipt') . '.pdf', 'isEmailPdf' => $isEmailPdf));
     return $sendReceipt;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:101,代码来源:AdditionalInfo.php

示例10: postProcess

 /**
  * @todo per totten's suggestion, wrap all these writes in a transaction;
  * see http://wiki.civicrm.org/confluence/display/CRMDOC43/Transaction+Reference
  */
 function postProcess()
 {
     $cid = CRM_Utils_Array::value('userID', $_SESSION['CiviCRM'], NULL);
     $values = $this->controller->exportValues();
     $profileFields = array();
     foreach ($this->getProfileIDs() as $profileID) {
         $profileFields += CRM_Core_BAO_UFGroup::getFields($profileID);
     }
     $profileValues = array_intersect_key($values, $profileFields);
     $activityValues = array_diff_key($values, $profileValues);
     // Search for duplicate
     if (!$cid) {
         $dedupeParams = CRM_Dedupe_Finder::formatParams($profileValues, 'Individual');
         $dedupeParams['check_permission'] = FALSE;
         $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
         if ($ids) {
             $cid = $ids[0];
         }
     }
     $cid = CRM_Contact_BAO_Contact::createProfileContact($profileValues, $profileFields, $cid);
     $activity_statuses = CRM_Activity_BAO_Activity::buildOptions('status_id', 'create');
     $projectNeeds = array();
     foreach ($this->_needs as $need) {
         $activityValues['volunteer_need_id'] = $need['id'];
         $activityValues['activity_date_time'] = CRM_Utils_Array::value('start_time', $need);
         $activityValues['assignee_contact_id'] = $cid;
         $activityValues['is_test'] = $this->_mode === 'test' ? 1 : 0;
         // below we assume that volunteers are always signing up only themselves;
         // for now this is a safe assumption, but we may need to revisit this.
         $activityValues['source_contact_id'] = $cid;
         // Set status to Available if user selected Flexible Need, else set to Scheduled.
         if (CRM_Utils_Array::value('is_flexible', $need)) {
             $activityValues['status_id'] = CRM_Utils_Array::key('Available', $activity_statuses);
         } else {
             $activityValues['status_id'] = CRM_Utils_Array::key('Scheduled', $activity_statuses);
         }
         $activityValues['time_scheduled_minutes'] = CRM_Utils_Array::value('duration', $need);
         CRM_Volunteer_BAO_Assignment::createVolunteerActivity($activityValues);
         if (!array_key_exists($need['project_id'], $projectNeeds)) {
             $projectNeeds[$need['project_id']] = array();
         }
         $need['role'] = $need['role_label'];
         $need['description'] = $need['role_description'];
         $need['duration'] = CRM_Utils_Array::value('duration', $need);
         $projectNeeds[$need['project_id']][$need['id']] = $need;
     }
     // Send confirmation email to volunteer
     list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($cid);
     list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
     if ($email) {
         $tplParams = $this->prepareTplParams($projectNeeds);
         $sendTemplateParams = array('contactId' => $cid, 'from' => "{$domainEmailName} <" . $domainEmailAddress . ">", 'groupName' => 'msg_tpl_workflow_volunteer', 'isTest' => $this->_mode === 'test', 'toName' => $displayName, 'toEmail' => $email, 'tplParams' => array("volunteer_projects" => $tplParams), 'valueName' => 'volunteer_registration');
         $bcc = array();
         foreach ($tplParams as $data) {
             foreach ($data['contacts'] as $manager) {
                 $bcc[$manager['contact_id']] = "{$manager['display_name']} <{$manager['email']}>";
             }
         }
         if (count($bcc)) {
             $sendTemplateParams['bcc'] = implode(', ', $bcc);
         }
         CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
     }
     $statusMsg = ts('You are scheduled to volunteer. Thank you!', array('domain' => 'org.civicrm.volunteer'));
     CRM_Core_Session::setStatus($statusMsg, '', 'success');
     CRM_Utils_System::redirect($this->_destination);
 }
开发者ID:JohnFF,项目名称:org.civicrm.volunteer,代码行数:71,代码来源:VolunteerSignUp.php

示例11: emailReceipt

 /**
  * @param $params
  *
  * @return mixed
  */
 function emailReceipt(&$params)
 {
     $updatedLineItem = CRM_Price_BAO_LineItem::getLineItems($this->_participantId, 'participant', NULL, FALSE);
     $lineItem = array();
     if ($updatedLineItem) {
         $lineItem[] = $updatedLineItem;
     }
     $this->assign('lineItem', empty($lineItem) ? FALSE : $lineItem);
     // offline receipt sending
     if (array_key_exists($params['from_email_address'], $this->_fromEmails['from_email_id'])) {
         $receiptFrom = $params['from_email_address'];
     }
     $this->assign('module', 'Event Registration');
     //use of the message template below requires variables in different format
     $event = $events = array();
     $returnProperties = array('fee_label', 'start_date', 'end_date', 'is_show_location', 'title');
     //get all event details.
     CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $params['event_id'], $events, $returnProperties);
     $event = $events[$params['event_id']];
     unset($event['start_date']);
     unset($event['end_date']);
     $role = CRM_Event_PseudoConstant::participantRole();
     $participantRoles = CRM_Utils_Array::value('role_id', $params);
     if (is_array($participantRoles)) {
         $selectedRoles = array();
         foreach (array_keys($participantRoles) as $roleId) {
             $selectedRoles[] = $role[$roleId];
         }
         $event['participant_role'] = implode(', ', $selectedRoles);
     } else {
         $event['participant_role'] = CRM_Utils_Array::value($participantRoles, $role);
     }
     $event['is_monetary'] = $this->_isPaidEvent;
     if ($params['receipt_text']) {
         $event['confirm_email_text'] = $params['receipt_text'];
     }
     $this->assign('isAmountzero', 1);
     $this->assign('event', $event);
     $this->assign('isShowLocation', $event['is_show_location']);
     if (CRM_Utils_Array::value('is_show_location', $event) == 1) {
         $locationParams = array('entity_id' => $params['event_id'], 'entity_table' => 'civicrm_event');
         $location = CRM_Core_BAO_Location::getValues($locationParams, TRUE);
         $this->assign('location', $location);
     }
     $status = CRM_Event_PseudoConstant::participantStatus();
     if ($this->_isPaidEvent) {
         $paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
         if (!$this->_mode) {
             if (isset($params['payment_instrument_id'])) {
                 $this->assign('paidBy', CRM_Utils_Array::value($params['payment_instrument_id'], $paymentInstrument));
             }
         }
         $this->assign('totalAmount', $this->contributionAmt);
         $this->assign('isPrimary', 1);
         $this->assign('checkNumber', CRM_Utils_Array::value('check_number', $params));
     }
     $this->assign('register_date', $params['register_date']);
     $template = CRM_Core_Smarty::singleton();
     // Retrieve the name and email of the contact - this will be the TO for receipt email
     list($this->_contributorDisplayName, $this->_contributorEmail, $this->_toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($this->_contactId);
     $this->_contributorDisplayName = $this->_contributorDisplayName == ' ' ? $this->_contributorEmail : $this->_contributorDisplayName;
     $waitStatus = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Waiting'");
     if ($waitingStatus = CRM_Utils_Array::value($params['status_id'], $waitStatus)) {
         $this->assign('isOnWaitlist', TRUE);
     }
     $this->assign('contactID', $this->_contactId);
     $this->assign('participantID', $this->_participantId);
     $sendTemplateParams = array('groupName' => 'msg_tpl_workflow_event', 'valueName' => 'event_offline_receipt', 'contactId' => $this->_contactId, 'isTest' => FALSE, 'PDFFilename' => ts('confirmation') . '.pdf');
     // try to send emails only if email id is present
     // and the do-not-email option is not checked for that contact
     if ($this->_contributorEmail && !$this->_toDoNotEmail) {
         $sendTemplateParams['from'] = $receiptFrom;
         $sendTemplateParams['toName'] = $this->_contributorDisplayName;
         $sendTemplateParams['toEmail'] = $this->_contributorEmail;
         $sendTemplateParams['cc'] = CRM_Utils_Array::value('cc', $this->_fromEmails);
         $sendTemplateParams['bcc'] = CRM_Utils_Array::value('bcc', $this->_fromEmails);
     }
     list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
     return $mailSent;
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:85,代码来源:ParticipantFeeSelection.php

示例12: _sendReceipt

/**
 * Version agnostic receipt sending function.
 *
 * @param array $params
 */
function _sendReceipt($params)
{
    if (_versionAtLeast(4.4)) {
        list($sent) = CRM_Core_BAO_MessageTemplate::sendTemplate($params);
    } else {
        list($sent) = CRM_Core_BAO_MessageTemplates::sendTemplate($params);
    }
    return $sent;
}
开发者ID:xurizaemon,项目名称:com.chrischinchilla.ewayrecurring,代码行数:14,代码来源:Eway.php

示例13: postProcess


//.........这里部分代码省略.........
     $processorParams['subscriptionId'] = $this->_subscriptionDetails->subscription_id;
     $processorParams['amount'] = $this->_subscriptionDetails->amount;
     $updateSubscription = $this->_paymentProcessorObj->updateSubscriptionBillingInfo($message, $processorParams);
     if (is_a($updateSubscription, 'CRM_Core_Error')) {
         CRM_Core_Error::displaySessionError($updateSubscription);
     } elseif ($updateSubscription) {
         $ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_subscriptionDetails->contact_id, 'contact_type');
         $contact =& CRM_Contact_BAO_Contact::createProfileContact($params, $fields, $this->_subscriptionDetails->contact_id, NULL, NULL, $ctype);
         // build tpl params
         if ($this->_subscriptionDetails->membership_id) {
             $inputParams = array('id' => $this->_subscriptionDetails->membership_id);
             CRM_Member_BAO_Membership::getValues($inputParams, $tplParams);
             $tplParams = $tplParams[$this->_subscriptionDetails->membership_id];
             $tplParams['membership_status'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $tplParams['status_id']);
             $tplParams['membershipType'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $tplParams['membership_type_id']);
             $status = ts('Billing details for your automatically renewed %1 membership have been updated.', array(1 => $tplParams['membershipType']));
             $msgTitle = ts('Details Updated');
             $msgType = 'success';
         } else {
             $status = ts('Billing details for the recurring contribution of %1, every %2 %3 have been updated.', array(1 => $this->_subscriptionDetails->amount, 2 => $this->_subscriptionDetails->frequency_interval, 3 => $this->_subscriptionDetails->frequency_unit));
             $msgTitle = ts('Details Updated');
             $msgType = 'success';
             $tplParams = array('recur_frequency_interval' => $this->_subscriptionDetails->frequency_interval, 'recur_frequency_unit' => $this->_subscriptionDetails->frequency_unit, 'amount' => $this->_subscriptionDetails->amount);
         }
         // format new address for display
         $addressParts = array("street_address", "city", "postal_code", "state_province", "country");
         foreach ($addressParts as $part) {
             $addressParts[$part] = CRM_Utils_Array::value($part, $processorParams);
         }
         $tplParams['address'] = CRM_Utils_Address::format($addressParts);
         // format old address to store in activity details
         $this->_defaults["state_province-{$this->_bltID}"] = CRM_Core_PseudoConstant::stateProvince($this->_defaults["state_province-{$this->_bltID}"], FALSE);
         $this->_defaults["country-{$this->_bltID}"] = CRM_Core_PseudoConstant::country($this->_defaults["country-{$this->_bltID}"], FALSE);
         $addressParts = array("street_address", "city", "postal_code", "state_province", "country");
         foreach ($addressParts as $part) {
             $key = "{$part}-{$this->_bltID}";
             $addressParts[$part] = CRM_Utils_Array::value($key, $this->_defaults);
         }
         $this->_defaults['address'] = CRM_Utils_Address::format($addressParts);
         // format new billing name
         $name = $processorParams['first_name'];
         if (!empty($processorParams['middle_name'])) {
             $name .= " {$processorParams['middle_name']}";
         }
         $name .= ' ' . $processorParams['last_name'];
         $name = trim($name);
         $tplParams['billingName'] = $name;
         // format old billing name
         $name = $this->_defaults['first_name'];
         if (!empty($this->_defaults['middle_name'])) {
             $name .= " {$this->_defaults['middle_name']}";
         }
         $name .= ' ' . $this->_defaults['last_name'];
         $name = trim($name);
         $this->_defaults['billingName'] = $name;
         $message .= "\n<br/><br/>New Billing Name and Address\n<br/>==============================\n<br/>{$tplParams['billingName']}\n<br/>{$tplParams['address']}\n\n<br/><br/>Previous Billing Name and Address\n<br/>==================================\n<br/>{$this->_defaults['billingName']}\n<br/>{$this->_defaults['address']}";
         $activityParams = array('source_contact_id' => $this->_subscriptionDetails->contact_id, 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', 'Update Recurring Contribution Billing Details', 'name'), 'subject' => ts('Recurring Contribution Billing Details Updated'), 'details' => $message, 'activity_date_time' => date('YmdHis'), 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'));
         $session = CRM_Core_Session::singleton();
         $cid = $session->get('userID');
         if ($cid) {
             $activityParams['target_contact_id'][] = $activityParams['source_contact_id'];
             $activityParams['source_contact_id'] = $cid;
         }
         CRM_Activity_BAO_Activity::create($activityParams);
         // send notification
         if ($this->_subscriptionDetails->contribution_page_id) {
             CRM_Core_DAO::commonRetrieveAll('CRM_Contribute_DAO_ContributionPage', 'id', $this->_subscriptionDetails->contribution_page_id, $value, array('title', 'receipt_from_name', 'receipt_from_email'));
             $receiptFrom = '"' . CRM_Utils_Array::value('receipt_from_name', $value[$this->_subscriptionDetails->contribution_page_id]) . '" <' . $value[$this->_subscriptionDetails->contribution_page_id]['receipt_from_email'] . '>';
         } else {
             $domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
             $receiptFrom = "{$domainValues['0']} <{$domainValues['1']}>";
         }
         list($donorDisplayName, $donorEmail) = CRM_Contact_BAO_Contact::getContactDetails($this->_subscriptionDetails->contact_id);
         $tplParams['contact'] = array('display_name' => $donorDisplayName);
         $date = CRM_Utils_Date::format($processorParams['credit_card_exp_date']);
         $tplParams['credit_card_exp_date'] = CRM_Utils_Date::mysqlToIso($date);
         $tplParams['credit_card_number'] = CRM_Utils_System::mungeCreditCard($processorParams['credit_card_number']);
         $tplParams['credit_card_type'] = $processorParams['credit_card_type'];
         $sendTemplateParams = array('groupName' => $this->_subscriptionDetails->membership_id ? 'msg_tpl_workflow_membership' : 'msg_tpl_workflow_contribution', 'valueName' => $this->_subscriptionDetails->membership_id ? 'membership_autorenew_billing' : 'contribution_recurring_billing', 'contactId' => $this->_subscriptionDetails->contact_id, 'tplParams' => $tplParams, 'isTest' => $this->_subscriptionDetails->is_test, 'PDFFilename' => 'receipt.pdf', 'from' => $receiptFrom, 'toName' => $donorDisplayName, 'toEmail' => $donorEmail);
         list($sent) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
     } else {
         $status = ts('There was some problem updating the billing details.');
         $msgTitle = ts('Update Error');
         $msgType = 'error';
     }
     $session = CRM_Core_Session::singleton();
     $userID = $session->get('userID');
     if ($userID && $status) {
         $session->setStatus($status, $msgTitle, $msgType);
     } elseif (!$userID) {
         if ($status) {
             CRM_Utils_System::setUFMessage($status);
         }
         $result = (int) ($updateSubscription && isset($ctype));
         if (isset($tplParams)) {
             $session->set('resultParams', $tplParams);
         }
         return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/subscriptionstatus', "reset=1&task=billing&result={$result}"));
     }
 }
开发者ID:indydas,项目名称:civi-demo,代码行数:101,代码来源:UpdateBilling.php

示例14: postProcess

 /**
  * Function to process the form
  *
  * @access public
  *
  * @return None
  */
 public function postProcess()
 {
     $status = $message = NULL;
     $cancelSubscription = TRUE;
     $params = $this->controller->exportValues($this->_name);
     if ($this->_selfService) {
         // for self service force sending-request & notify
         if ($this->_paymentProcessorObj->isSupported('cancelSubscription')) {
             $params['send_cancel_request'] = 1;
         }
         if ($this->_donorEmail) {
             $params['is_notify'] = 1;
         }
     }
     if (CRM_Utils_Array::value('send_cancel_request', $params) == 1) {
         $cancelParams = array('subscriptionId' => $this->_subscriptionDetails->subscription_id);
         $cancelSubscription = $this->_paymentProcessorObj->cancelSubscription($message, $cancelParams);
     }
     if (is_a($cancelSubscription, 'CRM_Core_Error')) {
         CRM_Core_Error::displaySessionError($cancelSubscription);
     } elseif ($cancelSubscription) {
         $activityParams = array('subject' => $this->_mid ? ts('Auto-renewal membership cancelled') : ts('Recurring contribution cancelled'), 'details' => $message);
         $cancelStatus = CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution($this->_subscriptionDetails->recur_id, CRM_Core_DAO::$_nullObject, $activityParams);
         if ($cancelStatus) {
             $tplParams = array();
             if ($this->_mid) {
                 $inputParams = array('id' => $this->_mid);
                 CRM_Member_BAO_Membership::getValues($inputParams, $tplParams);
                 $tplParams = $tplParams[$this->_mid];
                 $tplParams['membership_status'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $tplParams['status_id']);
                 $tplParams['membershipType'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $tplParams['membership_type_id']);
                 $status = ts('The automatic renewal of your %1 membership has been cancelled as requested. This does not affect the status of your membership - you will receive a separate notification when your membership is up for renewal.', array(1 => $tplParams['membershipType']));
                 $msgTitle = 'Membership Renewal Cancelled';
                 $msgType = 'info';
             } else {
                 $tplParams['recur_frequency_interval'] = $this->_subscriptionDetails->frequency_interval;
                 $tplParams['recur_frequency_unit'] = $this->_subscriptionDetails->frequency_unit;
                 $tplParams['amount'] = $this->_subscriptionDetails->amount;
                 $tplParams['contact'] = array('display_name' => $this->_donorDisplayName);
                 $status = ts('The recurring contribution of %1, every %2 %3 has been cancelled.', array(1 => $this->_subscriptionDetails->amount, 2 => $this->_subscriptionDetails->frequency_interval, 3 => $this->_subscriptionDetails->frequency_unit));
                 $msgTitle = 'Contribution Cancelled';
                 $msgType = 'success';
             }
             if (CRM_Utils_Array::value('is_notify', $params) == 1) {
                 if ($this->_subscriptionDetails->contribution_page_id) {
                     CRM_Core_DAO::commonRetrieveAll('CRM_Contribute_DAO_ContributionPage', 'id', $this->_subscriptionDetails->contribution_page_id, $value, array('title', 'receipt_from_name', 'receipt_from_email'));
                     $receiptFrom = '"' . CRM_Utils_Array::value('receipt_from_name', $value[$this->_subscriptionDetails->contribution_page_id]) . '" <' . $value[$this->_subscriptionDetails->contribution_page_id]['receipt_from_email'] . '>';
                 } else {
                     $domainValues = CRM_Core_BAO_Domain::getNameAndEmail();
                     $receiptFrom = "{$domainValues['0']} <{$domainValues['1']}>";
                 }
                 // send notification
                 $sendTemplateParams = array('groupName' => $this->_mode == 'auto_renew' ? 'msg_tpl_workflow_membership' : 'msg_tpl_workflow_contribution', 'valueName' => $this->_mode == 'auto_renew' ? 'membership_autorenew_cancelled' : 'contribution_recurring_cancelled', 'contactId' => $this->_subscriptionDetails->contact_id, 'tplParams' => $tplParams, 'PDFFilename' => 'receipt.pdf', 'from' => $receiptFrom, 'toName' => $this->_donorDisplayName, 'toEmail' => $this->_donorEmail);
                 list($sent) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
             }
         } else {
             $msgType = 'error';
             $msgTitle = ts('Error');
             if ($params['send_cancel_request'] == 1) {
                 $status = ts('Recurring contribution was cancelled successfully by the processor, but could not be marked as cancelled in the database.');
             } else {
                 $status = ts('Recurring contribution could not be cancelled in the database.');
             }
         }
     } else {
         $status = ts('The recurring contribution could not be cancelled.');
         $msgTitle = 'Error Cancelling Contribution';
         $msgType = 'error';
     }
     $session = CRM_Core_Session::singleton();
     $userID = $session->get('userID');
     if ($userID && $status) {
         $session->setStatus($status, $msgTitle, $msgType);
     } elseif (!$userID) {
         if ($status) {
             CRM_Utils_System::setUFMessage($status);
         }
         // keep result as 1, since we not displaying anything on the redirected page anyway
         return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contribute/subscriptionstatus', "reset=1&task=cancel&result=1"));
     }
 }
开发者ID:hguru,项目名称:224Civi,代码行数:88,代码来源:CancelSubscription.php

示例15: commonSendMail

 /**
  * Process that send notification e-mails
  *
  * @param int $contactID
  *   Contact id.
  * @param array $values
  *   Associative array of name/value pair.
  */
 public static function commonSendMail($contactID, &$values)
 {
     if (!$contactID || !$values) {
         return;
     }
     $template = CRM_Core_Smarty::singleton();
     $displayName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'display_name');
     self::profileDisplay($values['id'], $values['values'], $template);
     $emailList = explode(',', $values['email']);
     $contactLink = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$contactID}", TRUE, NULL, FALSE, FALSE, TRUE);
     //get the default domain email address.
     list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
     if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') {
         $fixUrl = CRM_Utils_System::url('civicrm/admin/domain', 'action=update&reset=1');
         CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in <a href="%1">Administer CiviCRM &raquo; Communications &raquo; FROM Email Addresses</a>. The email address used may need to be a valid mail account with your email service provider.', array(1 => $fixUrl)));
     }
     foreach ($emailList as $emailTo) {
         // FIXME: take the below out of the foreach loop
         CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_uf', 'valueName' => 'uf_notify', 'contactId' => $contactID, 'tplParams' => array('displayName' => $displayName, 'currentDate' => date('r'), 'contactLink' => $contactLink), 'from' => "{$domainEmailName} <{$domainEmailAddress}>", 'toEmail' => $emailTo));
     }
 }
开发者ID:rollox,项目名称:civicrm-core,代码行数:29,代码来源:UFGroup.php


注:本文中的CRM_Core_BAO_MessageTemplate::sendTemplate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。