+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
-
abstract class CRM_SMS_Provider {
/**
* pattern and cache the instance in this variable
*
* @var object
- * @static
*/
static private $_singleton = array();
const MAX_SMS_CHAR = 460;
/**
- * Singleton function used to manage this object
+ * Singleton function used to manage this object.
*
* @param array $providerParams
* @param bool $force
*
* @return object
- * @static
*/
public static function &singleton($providerParams = array(), $force = FALSE) {
- $mailingID = CRM_Utils_Array::value('mailing_id', $providerParams);
- $providerID = CRM_Utils_Array::value('provider_id', $providerParams);
+ $mailingID = CRM_Utils_Array::value('mailing_id', $providerParams);
+ $providerID = CRM_Utils_Array::value('provider_id', $providerParams);
$providerName = CRM_Utils_Array::value('provider', $providerParams);
if (!$providerID && $mailingID) {
}
$providerName = CRM_Utils_Type::escape($providerName, 'String');
- $cacheKey = "{$providerName}_" . (int) $providerID . "_" . (int) $mailingID;
+ $cacheKey = "{$providerName}_" . (int) $providerID . "_" . (int) $mailingID;
if (!isset(self::$_singleton[$cacheKey]) || $force) {
$ext = CRM_Extension_System::singleton()->getMapper();
}
/**
- * Send an SMS Message via the API Server
- *
+ * Send an SMS Message via the API Server.
*/
- abstract function send($recipients, $header, $message, $dncID = NULL);
+ abstract public function send($recipients, $header, $message, $dncID = NULL);
/**
* Return message text. Child class could override this function to have better control over the message being sent.
- *
*/
public function getMessage($message, $contactID, $contactDetails) {
$html = $message->getHTMLBody();
* @param int $jobID
* @param int $userID
*
- * @return $this|null|object
+ * @return self|null|object
* @throws CRM_Core_Exception
*/
public function createActivity($apiMsgID, $message, $headers = array(), $jobID = NULL, $userID = NULL) {
INNER JOIN civicrm_mailing_job mj ON mj.mailing_id = m.id AND mj.id = %1";
$sourceContactID = CRM_Core_DAO::singleValueQuery($sql, array(1 => array($jobID, 'Integer')));
}
- elseif($userID) {
+ elseif ($userID) {
$sourceContactID = $userID;
}
else {
* @param null $to
* @param int $trackID
*
- * @return $this|null|object
+ * @return self|null|object
* @throws CRM_Core_Exception
*/
public function processInbound($from, $body, $to = NULL, $trackID = NULL) {
- $formatFrom = $this->formatPhone($this->stripPhone($from), $like, "like");
- $escapedFrom = CRM_Utils_Type::escape($formatFrom, 'String');
+ $formatFrom = $this->formatPhone($this->stripPhone($from), $like, "like");
+ $escapedFrom = CRM_Utils_Type::escape($formatFrom, 'String');
$fromContactID = CRM_Core_DAO::singleValueQuery('SELECT contact_id FROM civicrm_phone JOIN civicrm_contact ON civicrm_contact.id = civicrm_phone.contact_id WHERE !civicrm_contact.is_deleted AND phone LIKE "%' . $escapedFrom . '"');
- if (! $fromContactID) {
+ if (!$fromContactID) {
// unknown mobile sender -- create new contact
// use fake @mobile.sms email address for new contact since civi
// requires email or name for all contacts
$contactparams = array(
'contact_type' => 'Individual',
'email' => array(
- 1 => array(
- 'location_type_id' => $phoneloc,
- 'email' => $stripFrom . '@mobile.sms'
- )),
+ 1 => array(
+ 'location_type_id' => $phoneloc,
+ 'email' => $stripFrom . '@mobile.sms',
+ ),
+ ),
'phone' => array(
- 1 => array(
- 'phone_type_id' => $phonetype,
- 'location_type_id' => $phoneloc,
- 'phone' => $stripFrom
- )),
+ 1 => array(
+ 'phone_type_id' => $phonetype,
+ 'location_type_id' => $phoneloc,
+ 'phone' => $stripFrom,
+ ),
+ ),
);
$fromContact = CRM_Contact_BAO_Contact::create($contactparams, FALSE, TRUE, FALSE);
$fromContactID = $fromContact->id;
'activity_date_time' => date('YmdHis'),
'status_id' => $actStatusIDs['Completed'],
'details' => $body,
- 'phone_number' => $from
+ 'phone_number' => $from,
);
if ($trackID) {
$trackID = CRM_Utils_Type::escape($trackID, 'String');
$area = "";
$exch = "";
$uniq = "";
- $ext = $phoneA[1];
+ $ext = $phoneA[1];
break;
case 7:
$area = "";
$exch = substr($phone, 0, 3);
$uniq = substr($phone, 3, 4);
- $ext = $phoneA[1];
+ $ext = $phoneA[1];
break;
case 10:
$area = substr($phone, 0, 3);
$exch = substr($phone, 3, 3);
$uniq = substr($phone, 6, 4);
- $ext = $phoneA[1];
+ $ext = $phoneA[1];
break;
default:
}
return $uri;
}
+
}