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


PHP CRM_Activity_BAO_Activity::sendSMSMessage方法代码示例

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


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

示例1: sendReminder

 /**
  * @param $contactId
  * @param $to
  * @param $scheduleID
  * @param $from
  * @param $tokenParams
  *
  * @return bool|null
  * @throws CRM_Core_Exception
  */
 static function sendReminder($contactId, $to, $scheduleID, $from, $tokenParams)
 {
     $email = $to['email'];
     $phoneNumber = $to['phone'];
     $schedule = new CRM_Core_DAO_ActionSchedule();
     $schedule->id = $scheduleID;
     $domain = CRM_Core_BAO_Domain::getDomain();
     $result = NULL;
     $hookTokens = array();
     if ($schedule->find(TRUE)) {
         $body_text = $schedule->body_text;
         $body_html = $schedule->body_html;
         $sms_body_text = $schedule->sms_body_text;
         $body_subject = $schedule->subject;
         if (!$body_text) {
             $body_text = CRM_Utils_String::htmlToText($body_html);
         }
         $params = array(array('contact_id', '=', $contactId, 0, 0));
         list($contact, $_) = CRM_Contact_BAO_Query::apiQuery($params);
         //CRM-4524
         $contact = reset($contact);
         if (!$contact || is_a($contact, 'CRM_Core_Error')) {
             return NULL;
         }
         // merge activity tokens with contact array
         $contact = array_merge($contact, $tokenParams);
         //CRM-5734
         CRM_Utils_Hook::tokenValues($contact, $contactId);
         CRM_Utils_Hook::tokens($hookTokens);
         $categories = array_keys($hookTokens);
         $type = array('body_html' => 'html', 'body_text' => 'text', 'sms_body_text' => 'text');
         foreach ($type as $bodyType => $value) {
             $dummy_mail = new CRM_Mailing_BAO_Mailing();
             if ($bodyType == 'sms_body_text') {
                 $dummy_mail->body_text = ${$bodyType};
             } else {
                 $dummy_mail->{${$bodyType}} = ${$bodyType};
             }
             $tokens = $dummy_mail->getTokens();
             if (${$bodyType}) {
                 CRM_Utils_Token::replaceGreetingTokens(${$bodyType}, NULL, $contact['contact_id']);
                 ${$bodyType} = CRM_Utils_Token::replaceDomainTokens(${$bodyType}, $domain, TRUE, $tokens[$value], TRUE);
                 ${$bodyType} = CRM_Utils_Token::replaceContactTokens(${$bodyType}, $contact, FALSE, $tokens[$value], FALSE, TRUE);
                 ${$bodyType} = CRM_Utils_Token::replaceComponentTokens(${$bodyType}, $contact, $tokens[$value], TRUE, FALSE);
                 ${$bodyType} = CRM_Utils_Token::replaceHookTokens(${$bodyType}, $contact, $categories, TRUE);
             }
         }
         $html = $body_html;
         $text = $body_text;
         $sms_text = $sms_body_text;
         $smarty = CRM_Core_Smarty::singleton();
         foreach (array('text', 'html', 'sms_text') as $elem) {
             ${$elem} = $smarty->fetch("string:{${$elem}}");
         }
         $matches = array();
         preg_match_all('/(?<!\\{|\\\\)\\{(\\w+\\.\\w+)\\}(?!\\})/', $body_subject, $matches, PREG_PATTERN_ORDER);
         $subjectToken = NULL;
         if ($matches[1]) {
             foreach ($matches[1] as $token) {
                 list($type, $name) = preg_split('/\\./', $token, 2);
                 if ($name) {
                     if (!isset($subjectToken[$type])) {
                         $subjectToken[$type] = array();
                     }
                     $subjectToken[$type][] = $name;
                 }
             }
         }
         $messageSubject = CRM_Utils_Token::replaceContactTokens($body_subject, $contact, FALSE, $subjectToken);
         $messageSubject = CRM_Utils_Token::replaceDomainTokens($messageSubject, $domain, TRUE, $subjectToken);
         $messageSubject = CRM_Utils_Token::replaceComponentTokens($messageSubject, $contact, $subjectToken, TRUE);
         $messageSubject = CRM_Utils_Token::replaceHookTokens($messageSubject, $contact, $categories, TRUE);
         $messageSubject = $smarty->fetch("string:{$messageSubject}");
         if ($schedule->mode == 'SMS' or $schedule->mode == 'User_Preference') {
             $session = CRM_Core_Session::singleton();
             $userID = $session->get('userID') ? $session->get('userID') : $contactId;
             $smsParams = array('To' => $phoneNumber, 'provider_id' => $schedule->sms_provider_id, 'activity_subject' => $messageSubject);
             $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'SMS', 'name');
             $activityParams = array('source_contact_id' => $userID, 'activity_type_id' => $activityTypeID, 'activity_date_time' => date('YmdHis'), 'subject' => $messageSubject, 'details' => $sms_text, 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'));
             $activity = CRM_Activity_BAO_Activity::create($activityParams);
             CRM_Activity_BAO_Activity::sendSMSMessage($contactId, $sms_text, $html, $smsParams, $activity->id, $userID);
         }
         if ($schedule->mode == 'Email' or $schedule->mode == 'User_Preference') {
             // set up the parameters for CRM_Utils_Mail::send
             $mailParams = array('groupName' => 'Scheduled Reminder Sender', 'from' => $from, 'toName' => $contact['display_name'], 'toEmail' => $email, 'subject' => $messageSubject, 'entity' => 'action_schedule', 'entity_id' => $scheduleID);
             if (!$html || $contact['preferred_mail_format'] == 'Text' || $contact['preferred_mail_format'] == 'Both') {
                 // render the &amp; entities in text mode, so that the links work
                 $mailParams['text'] = str_replace('&amp;', '&', $text);
             }
             if ($html && ($contact['preferred_mail_format'] == 'HTML' || $contact['preferred_mail_format'] == 'Both')) {
//.........这里部分代码省略.........
开发者ID:ruchirapingale,项目名称:civicrm-core,代码行数:101,代码来源:ActionSchedule.php

示例2: sendReminderSms

 /**
  * @param \Civi\Token\TokenRow $tokenRow
  * @param CRM_Core_DAO_ActionSchedule $schedule
  * @param int $toContactID
  * @throws CRM_Core_Exception
  * @return array
  *   List of error messages.
  */
 protected static function sendReminderSms($tokenRow, $schedule, $toContactID)
 {
     $toPhoneNumber = self::pickSmsPhoneNumber($toContactID);
     if (!$toPhoneNumber) {
         return array("sms_phone_missing" => "Couldn't find recipient's phone number.");
     }
     $messageSubject = $tokenRow->render('subject');
     $sms_body_text = $tokenRow->render('sms_body_text');
     $session = CRM_Core_Session::singleton();
     $userID = $session->get('userID') ? $session->get('userID') : $tokenRow->context['contactId'];
     $smsParams = array('To' => $toPhoneNumber, 'provider_id' => $schedule->sms_provider_id, 'activity_subject' => $messageSubject);
     $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'SMS', 'name');
     $activityParams = array('source_contact_id' => $userID, 'activity_type_id' => $activityTypeID, 'activity_date_time' => date('YmdHis'), 'subject' => $messageSubject, 'details' => $sms_body_text, 'status_id' => CRM_Core_OptionGroup::getValue('activity_status', 'Completed', 'name'));
     $activity = CRM_Activity_BAO_Activity::create($activityParams);
     CRM_Activity_BAO_Activity::sendSMSMessage($tokenRow->context['contactId'], $sms_body_text, $smsParams, $activity->id, $userID);
     return array();
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:25,代码来源:ActionSchedule.php


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