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


PHP CRM_Contact_BAO_Contact::getPhoneDetails方法代码示例

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


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

示例1: buildQuickForm

 /**
  * Build the form
  *
  * @access public
  * @return void
  */
 function buildQuickForm()
 {
     if (!$this->_single) {
         $toArray = array();
         foreach ($this->_contactIds as $contactId) {
             list($toDisplayName, $toSMS) = CRM_Contact_BAO_Contact::getPhoneDetails($contactId, 'Mobile');
             if (!empty($toSMS)) {
                 $toArray[] = "\"{$toDisplayName}\" <{$toSMS}>";
             }
         }
         $this->assign('to', implode(', ', $toArray));
     } else {
         $to =& $this->add('select', 'to', ts('To'), $this->_smsNumbers, true);
         if (count($this->_smsNumbers) <= 1) {
             foreach ($this->_smsNumbers as $number => $dontCare) {
                 $defaults = array('to' => $number);
                 $this->setDefaults($defaults);
             }
             $to->freeze();
         }
     }
     $session =& CRM_Core_Session::singleton();
     $userID = $session->get('userID');
     list($fromDisplayName, $fromSMS) = CRM_Contact_BAO_Contact::getPhoneDetails($userID, 'Mobile');
     if (!$fromSMS) {
         CRM_Utils_System::statusBounce(ts('Your user record does not have a valid SMS number'));
     }
     $from = '"' . $fromDisplayName . '"' . "<{$fromSMS}>";
     $this->assign('from', $from);
     $this->add('textarea', 'message', ts('Message'), CRM_Core_DAO::getAttribute('CRM_SMS_DAO_History', 'message'), true);
     if ($this->_single) {
         // also fix the user context stack
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view/activity', '&show=1&action=browse&cid=' . $this->_contactIds[0]));
         $this->addDefaultButtons(ts('Send SMS'), 'next', 'cancel');
     } else {
         $this->addDefaultButtons(ts('Send SMS'));
     }
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:44,代码来源:SMS.php

示例2: sendMessage

 /**
  * send the message to a specific contact
  *
  * @param string $from       the name and sms of the sender
  * @param int    $toID       the contact id of the recipient       
  * @param string $message    the message contents
  * @param string $smsNumber  use this 'number' instead of the default primary sms number
  * @param int    $activityID the activity ID that tracks the message
  *
  * @return array             (total, added, notAdded) count of emails sent
  * @access public
  * @static
  */
 function sendMessage($from, $toID, &$message, $smsNumber, $activityID)
 {
     list($toDisplayName, $toSMS) = CRM_Contact_BAO_Contact::getPhoneDetails($toID, 'Mobile');
     if ($toSMS) {
         $to = trim($toSMS);
     }
     // make sure sms number is non-empty
     if (empty($to)) {
         return false;
     }
     $params = array();
     $params['From'] = $from;
     $params['To'] = $to;
     $params['Body'] = $message;
     $params['id'] = substr(md5(uniqid(rand(), true)), 0, 31);
     $params['Type'] = "SMS_TEXT";
     $aggregator =& CRM_SMS_Protocol::singleton();
     if (!$aggregator->sendMessage($params)) {
         return false;
     }
     // we need to insert an activity history record here
     $params = array('entity_table' => 'civicrm_contact', 'entity_id' => $toID, 'activity_type' => ts('SMS Sent'), 'module' => 'CiviCRM', 'callback' => 'CRM_SMS_BAO_History::details', 'activity_id' => $activityID, 'activity_summary' => ts('To: %1; Message: %2', array(1 => "{$toDisplayName} <{$toSMS}>", 2 => $message)), 'activity_date' => date('YmdHis'));
     if (is_a(crm_create_activity_history($params), CRM_Core_Error)) {
         return false;
     }
     return true;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:40,代码来源:History.php


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