$tokenText,
$tokenHtml,
$smsParams,
- $activityID
+ $activityID,
+ $userID
);
if (PEAR::isError($sendResult)) {
&$tokenText,
&$tokenHtml,
$smsParams = array(),
- $activityID
+ $activityID,
+ $userID = null
) {
$toDoNotSms = "";
$toPhoneNumber = "";
$smsParams['parent_activity_id'] = $activityID;
$providerObj = CRM_SMS_Provider::singleton(array('provider_id' => $smsParams['provider_id']));
- $sendResult = $providerObj->send($recipient, $smsParams, $message, NULL);
+ $sendResult = $providerObj->send($recipient, $smsParams, $message, NULL, $userID);
if (PEAR::isError($sendResult)) {
return $sendResult;
}
}
}
if ($entityID && !empty($singleFieldTables)) {
- self::buildEntityTreeSingleFields(&$groupTree, $entityID, $entitySingleSelectClauses, $singleFieldTables);
+ self::buildEntityTreeSingleFields($groupTree, $entityID, $entitySingleSelectClauses, $singleFieldTables);
}
$multipleFieldTablesWithEntityData = array_keys($entityMultipleSelectClauses);
if(!empty($multipleFieldTablesWithEntityData)){
- self::buildEntityTreeMultipleFields(&$groupTree, $entityID, $entityMultipleSelectClauses, $multipleFieldTablesWithEntityData);
+ self::buildEntityTreeMultipleFields($groupTree, $entityID, $entityMultipleSelectClauses, $multipleFieldTablesWithEntityData);
}
}
FROM $fromSQL
WHERE first.entity_id = $entityID
";
- self::buildTreeEntityDataFromQuery(&$groupTree, $query, $singleFieldTablesWithEntityData);
+ self::buildTreeEntityDataFromQuery($groupTree, $query, $singleFieldTablesWithEntityData);
}
/**
FROM $table
WHERE entity_id = $entityID
";
- self::buildTreeEntityDataFromQuery(&$groupTree, $query, array($table));
+ self::buildTreeEntityDataFromQuery($groupTree, $query, array($table));
}
}
* @static
*/
static private $_singleton = array();
- CONST MAX_SMS_CHAR = 160;
+ CONST MAX_SMS_CHAR = 460;
/**
* singleton function used to manage this object
}
function createActivity($apiMsgID, $message, $headers = array(
- ), $jobID = NULL) {
+ ), $jobID = NULL, $userID = NULL) {
if ($jobID) {
$sql = "
SELECT scheduled_id FROM civicrm_mailing m
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) {
+ $sourceContactID=$userID;
+ }
else {
$session = CRM_Core_Session::singleton();
$sourceContactID = $session->get('userID');
return false;
}
- $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'SMS', 'name');
+ $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'SMS delivery', 'name');
// note: lets not pass status here, assuming status will be updated by callback
$activityParams = array(
'source_contact_id' => $sourceContactID,
'target_contact_id' => $headers['contact_id'],
'activity_type_id' => $activityTypeID,
'activity_date_time' => date('YmdHis'),
- 'subject' => 'SMS Sent',
'details' => $message,
'result' => $apiMsgID,
);
function processInbound($from, $body, $to = NULL, $trackID = NULL) {
$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 WHERE phone LIKE "' . $escapedFrom . '"');
+ $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) {
// unknown mobile sender -- create new contact
if ($to) {
$to = CRM_Utils_Type::escape($to, 'String');
- $toContactID = CRM_Core_DAO::singleValueQuery('SELECT contact_id FROM civicrm_phone WHERE phone LIKE "' . $to . '"');
+ $toContactID = 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 "%' . $to . '"');
}
else {
$toContactID = $fromContactID;
if ($fromContactID) {
$actStatusIDs = array_flip(CRM_Core_OptionGroup::values('activity_status'));
- $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'SMS', 'name');
+ $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Inbound SMS', 'name');
// note: lets not pass status here, assuming status will be updated by callback
$activityParams = array(
'target_contact_id' => $fromContactID,
'activity_type_id' => $activityTypeID,
'activity_date_time' => date('YmdHis'),
- 'subject' => 'SMS Received',
'status_id' => $actStatusIDs['Completed'],
'details' => $body,
'phone_number' => $from
if (!array_key_exists($versionName, $incrementalPhpObject)) {
$className = "CRM_Upgrade_Incremental_php_{$versionName}";
- $incrementalPhpObject['$versionName'] = new $className();
+ $incrementalPhpObject[$versionName] = new $className();
}
return $incrementalPhpObject[$versionName];
}
-- CRM-12716
UPDATE civicrm_custom_field SET text_length = NULL WHERE html_type = 'TextArea' AND text_length = 255;
+-- CRM-12288
+
+SELECT @option_group_id_activity_type := max(id) from civicrm_option_group where name = 'activity_type';
+SELECT @max_val := MAX(ROUND(op.value)) FROM civicrm_option_value op WHERE op.option_group_id = @option_group_id_activity_type;
+SELECT @max_wt := max(weight) from civicrm_option_value where option_group_id=@option_group_id_activity_type;
+
+INSERT INTO civicrm_option_value
+ (option_group_id, {localize field='label'}label{/localize}, {localize field='description'}description{/localize}, value, name, weight, filter, component_id)
+VALUES
+ (@option_group_id_activity_type, {localize}'Inbound SMS'{/localize},{localize}'Inbound SMS'{/localize}, (SELECT @max_val := @max_val+1), 'Inbound SMS', (SELECT @max_wt := @max_wt+1), 1, NULL),
+ (@option_group_id_activity_type, {localize}'SMS delivery'{/localize},{localize}'SMS delivery'{/localize}, (SELECT @max_val := @max_val+1), 'SMS delivery', (SELECT @max_wt := @max_wt+1), 1, NULL);
+
+{if $multilingual}
+ {foreach from=$locales item=locale}
+ UPDATE civicrm_option_value SET label_{$locale} ='Outbound SMS' WHERE name = 'SMS' and option_group_id = @option_group_id_activity_type;
+ {/foreach}
+{else}
+ UPDATE civicrm_option_value SET label ='Outbound SMS' WHERE name = 'SMS' and option_group_id = @option_group_id_activity_type;
+{/if}
* @return mixed true on sucess or PEAR_Error object
* @access public
*/
- function send($recipients, $header, $message, $jobID = NULL) {
+ function send($recipients, $header, $message, $jobID = NULL, $userID = NULL) {
if ($this->_apiType == 'http') {
$postDataArray = array( );
$url = $this->formURLPostData("/http/sendmsg", $postDataArray);
if (array_key_exists('from', $this->_providerInfo['api_params'])) {
$postDataArray['from'] = $this->_providerInfo['api_params']['from'];
}
+ if (array_key_exists('concat', $this->_providerInfo['api_params'])) {
+ $postDataArray['concat'] = $this->_providerInfo['api_params']['concat'];
+ }
+ //TODO:
$postDataArray['to'] = $header['To'];
- $postDataArray['text'] = substr($message, 0, 160); // max of 160 characters, is probably not multi-lingual
+ $postDataArray['text'] = substr($message, 0, 460); // max of 460 characters, is probably not multi-lingual
if (array_key_exists('mo', $this->_providerInfo['api_params'])) {
$postDataArray['mo'] = $this->_providerInfo['api_params']['mo'];
}
$send = explode(":", $response['data']);
if ($send[0] == "ID") {
- $this->createActivity($send[1], $message, $header, $jobID);
+ $this->createActivity($send[1], $message, $header, $jobID, $userID);
return $send[1];
}
else {
* @return mixed SID on success or PEAR_Error object
* @access public
*/
- function send($recipients, $header, $message, $jobID = NULL) {
+ function send($recipients, $header, $message, $jobID = NULL, $userID = NULL) {
if ($this->_apiType == 'http') {
$from = '';
if (array_key_exists('From', $this->_providerInfo['api_params'])) {
}
$sid = $twilioMessage->sid;
- $this->createActivity($sid, $message, $header, $jobID);
+ $this->createActivity($sid, $message, $header, $jobID, $userID);
return $sid;
}
}
(@option_group_id_act, '{ts escape="sql"}Meeting{/ts}', 1, 'Meeting', NULL, 0, NULL, 1, NULL, 0, 1, 1, NULL, NULL),
(@option_group_id_act, '{ts escape="sql"}Phone Call{/ts}', 2, 'Phone Call', NULL, 0, NULL, 2, NULL, 0, 1, 1, NULL, NULL),
(@option_group_id_act, '{ts escape="sql"}Email{/ts}', 3, 'Email', NULL, 1, NULL, 3, '{ts escape="sql"}Email sent.{/ts}', 0, 1, 1, NULL, NULL),
- (@option_group_id_act, '{ts escape="sql"}Text Message (SMS){/ts}', 4, 'SMS', NULL, 1, NULL, 4, '{ts escape="sql"}Text message (SMS) sent.{/ts}', 0, 1, 1, NULL, NULL),
+ (@option_group_id_act, '{ts escape="sql"}Outbound SMS{/ts}', 4, 'SMS', NULL, 1, NULL, 4, '{ts escape="sql"}Text message (SMS) sent.{/ts}', 0, 1, 1, NULL, NULL),
(@option_group_id_act, '{ts escape="sql"}Event Registration{/ts}', 5, 'Event Registration', NULL, 1, NULL, 5, '{ts escape="sql"}Online or offline event registration.{/ts}', 0, 1, 1, @eventCompId, NULL),
(@option_group_id_act, '{ts escape="sql"}Contribution{/ts}', 6, 'Contribution', NULL, 1, NULL, 6, '{ts escape="sql"}Online or offline contribution.{/ts}', 0, 1, 1, @contributeCompId, NULL),
(@option_group_id_act, '{ts escape="sql"}Membership Signup{/ts}', 7, 'Membership Signup', NULL, 1, NULL, 7, '{ts escape="sql"}Online or offline membership signup.{/ts}', 0, 1, 1, @memberCompId, NULL),
(@option_group_id_act, '{ts escape="sql"}Create Batch{/ts}', 42, 'Create Batch', NULL, 1, 0, 42, 'Create Batch', 0, 1, 1, @contributeCompId, NULL),
(@option_group_id_act, '{ts escape="sql"}Edit Batch{/ts}', 43, 'Edit Batch', NULL, 1, 0, 43, 'Edit Batch', 0, 1, 1, @contributeCompId, NULL),
+-- new sms options
+ (@option_group_id_act, '{ts escape="sql"}SMS delivery{/ts}', 44, 'SMS delivery', NULL, 1, NULL, 44, '{ts escape="sql"}SMS delivery.{/ts}', 0, 1, 1, NULL, NULL),
+ (@option_group_id_act, '{ts escape="sql"}Inbound SMS{/ts}', 45, 'Inbound SMS', NULL, 1, NULL, 45, '{ts escape="sql"}Inbound SMS.{/ts}', 0, 1, 1, NULL, NULL),
+
(@option_group_id_gender, '{ts escape="sql"}Female{/ts}', 1, 'Female', NULL, 0, NULL, 1, NULL, 0, 0, 1, NULL, NULL),
(@option_group_id_gender, '{ts escape="sql"}Male{/ts}', 2, 'Male', NULL, 0, NULL, 2, NULL, 0, 0, 1, NULL, NULL),
(@option_group_id_gender, '{ts escape="sql"}Transgender{/ts}', 3, 'Transgender', NULL, 0, NULL, 3, NULL, 0, 0, 1, NULL, NULL),