本文整理汇总了PHP中_civicrm_api3_deprecated_add_formatted_param函数的典型用法代码示例。如果您正苦于以下问题:PHP _civicrm_api3_deprecated_add_formatted_param函数的具体用法?PHP _civicrm_api3_deprecated_add_formatted_param怎么用?PHP _civicrm_api3_deprecated_add_formatted_param使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_civicrm_api3_deprecated_add_formatted_param函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddFormattedParam
function testAddFormattedParam()
{
$values = array('contact_type' => 'Individual');
$params = array('something' => 1);
$result = _civicrm_api3_deprecated_add_formatted_param($values, $params);
$this->assertTrue($result);
}
示例2: array
/**
* Register a subscription event. Create a new contact if one does not
* already exist.
*
* @param int $group_id
* The group id to subscribe to.
* @param string $email
* The email address of the (new) contact.
* @param int $contactId
* Currently used during event registration/contribution.
* Specifically to avoid linking group to wrong duplicate contact
* during event registration.
* @param string $context
*
* @return int|null
* $se_id The id of the subscription event, null on failure
*/
public static function &subscribe($group_id, $email, $contactId = NULL, $context = NULL)
{
// CRM-1797 - allow subscription only to public groups
$params = array('id' => (int) $group_id);
$defaults = array();
$contact_id = NULL;
$success = NULL;
$bao = CRM_Contact_BAO_Group::retrieve($params, $defaults);
if ($bao && substr($bao->visibility, 0, 6) != 'Public' && $context != 'profile') {
return $success;
}
$strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
$email = $strtolower($email);
// process the query only if no contactId
if ($contactId) {
$contact_id = $contactId;
} else {
/* First, find out if the contact already exists */
$query = "\n SELECT DISTINCT contact_a.id as contact_id\n FROM civicrm_contact contact_a\nLEFT JOIN civicrm_email ON contact_a.id = civicrm_email.contact_id\n WHERE civicrm_email.email = %1 AND contact_a.is_deleted = 0";
$params = array(1 => array($email, 'String'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
$id = array();
// lets just use the first contact id we got
if ($dao->fetch()) {
$contact_id = $dao->contact_id;
}
$dao->free();
}
$transaction = new CRM_Core_Transaction();
if (!$contact_id) {
require_once 'CRM/Utils/DeprecatedUtils.php';
/* If the contact does not exist, create one. */
$formatted = array('contact_type' => 'Individual', 'version' => 3);
$locationType = CRM_Core_BAO_LocationType::getDefault();
$value = array('email' => $email, 'location_type_id' => $locationType->id);
_civicrm_api3_deprecated_add_formatted_param($value, $formatted);
$formatted['onDuplicate'] = CRM_Import_Parser::DUPLICATE_SKIP;
$formatted['fixAddress'] = TRUE;
require_once 'api/api.php';
$contact = civicrm_api('contact', 'create', $formatted);
if (civicrm_error($contact)) {
return $success;
}
$contact_id = $contact['id'];
} elseif (!is_numeric($contact_id) && (int) $contact_id > 0) {
// make sure contact_id is numeric
return $success;
}
/* Get the primary email id from the contact to use as a hash input */
$dao = new CRM_Core_DAO();
$query = "\nSELECT civicrm_email.id as email_id\n FROM civicrm_email\n WHERE civicrm_email.email = %1\n AND civicrm_email.contact_id = %2";
$params = array(1 => array($email, 'String'), 2 => array($contact_id, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
if (!$dao->fetch()) {
CRM_Core_Error::fatal('Please file an issue with the backtrace');
return $success;
}
$se = new CRM_Mailing_Event_BAO_Subscribe();
$se->group_id = $group_id;
$se->contact_id = $contact_id;
$se->time_stamp = date('YmdHis');
$se->hash = substr(sha1("{$group_id}:{$contact_id}:{$dao->email_id}:" . time()), 0, 16);
$se->save();
$contacts = array($contact_id);
CRM_Contact_BAO_GroupContact::addContactsToGroup($contacts, $group_id, 'Email', 'Pending', $se->id);
$transaction->commit();
return $se;
}
示例3: formatCommonData
/**
* Format common params data to proper format to store.
*
* @param array $params
* Contain record values.
* @param array $formatted
* Array of formatted data.
* @param array $contactFields
* Contact DAO fields.
*/
public function formatCommonData($params, &$formatted, &$contactFields)
{
$csType = array(CRM_Utils_Array::value('contact_type', $formatted));
//CRM-5125
//add custom fields for contact sub type
if (!empty($this->_contactSubType)) {
$csType = $this->_contactSubType;
}
if ($relCsType = CRM_Utils_Array::value('contact_sub_type', $formatted)) {
$csType = $relCsType;
}
$customFields = CRM_Core_BAO_CustomField::getFields($formatted['contact_type'], FALSE, FALSE, $csType);
$addressCustomFields = CRM_Core_BAO_CustomField::getFields('Address');
$customFields = $customFields + $addressCustomFields;
//if a Custom Email Greeting, Custom Postal Greeting or Custom Addressee is mapped, and no "Greeting / Addressee Type ID" is provided, then automatically set the type = Customized, CRM-4575
$elements = array('email_greeting_custom' => 'email_greeting', 'postal_greeting_custom' => 'postal_greeting', 'addressee_custom' => 'addressee');
foreach ($elements as $k => $v) {
if (array_key_exists($k, $params) && !array_key_exists($v, $params)) {
$label = key(CRM_Core_OptionGroup::values($v, TRUE, NULL, NULL, 'AND v.name = "Customized"'));
$params[$v] = $label;
}
}
//format date first
$session = CRM_Core_Session::singleton();
$dateType = $session->get("dateTypes");
foreach ($params as $key => $val) {
$customFieldID = CRM_Core_BAO_CustomField::getKeyID($key);
if ($customFieldID && !array_key_exists($customFieldID, $addressCustomFields)) {
//we should not update Date to null, CRM-4062
if ($val && $customFields[$customFieldID]['data_type'] == 'Date') {
self::formatCustomDate($params, $formatted, $dateType, $key);
} elseif ($customFields[$customFieldID]['data_type'] == 'Boolean') {
if (empty($val) && !is_numeric($val) && $this->_onDuplicate == CRM_Import_Parser::DUPLICATE_FILL) {
//retain earlier value when Import mode is `Fill`
unset($params[$key]);
} else {
$params[$key] = CRM_Utils_String::strtoboolstr($val);
}
}
if ($key == 'birth_date' && $val) {
CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key);
} elseif ($key == 'deceased_date' && $val) {
CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key);
} elseif ($key == 'is_deceased' && $val) {
$params[$key] = CRM_Utils_String::strtoboolstr($val);
} elseif ($key == 'gender') {
//CRM-4360
$params[$key] = $this->checkGender($val);
}
}
}
//now format custom data.
foreach ($params as $key => $field) {
if (is_array($field)) {
$isAddressCustomField = FALSE;
foreach ($field as $value) {
$break = FALSE;
if (is_array($value)) {
foreach ($value as $name => $testForEmpty) {
if ($addressCustomFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
$isAddressCustomField = TRUE;
break;
}
// check if $value does not contain IM provider or phoneType
if (($name !== 'phone_type_id' || $name !== 'provider_id') && ($testForEmpty === '' || $testForEmpty == NULL)) {
$break = TRUE;
break;
}
}
} else {
$break = TRUE;
}
if (!$break) {
require_once 'CRM/Utils/DeprecatedUtils.php';
_civicrm_api3_deprecated_add_formatted_param($value, $formatted);
}
}
if (!$isAddressCustomField) {
continue;
}
}
$formatValues = array($key => $field);
if ($key !== 'preferred_communication_method' && array_key_exists($key, $contactFields)) {
// due to merging of individual table and
// contact table, we need to avoid
// preferred_communication_method forcefully
$formatValues['contact_type'] = $formatted['contact_type'];
}
if ($key == 'id' && isset($field)) {
$formatted[$key] = $field;
//.........这里部分代码省略.........
示例4: _civicrm_api3_deprecated_check_contact_dedupe
/**
* check duplicate contacts based on de-deupe parameters
*/
function _civicrm_api3_deprecated_check_contact_dedupe($params)
{
static $cIndieFields = NULL;
static $defaultLocationId = NULL;
$contactType = $params['contact_type'];
if ($cIndieFields == NULL) {
require_once 'CRM/Contact/BAO/Contact.php';
$cTempIndieFields = CRM_Contact_BAO_Contact::importableFields($contactType);
$cIndieFields = $cTempIndieFields;
require_once "CRM/Core/BAO/LocationType.php";
$defaultLocation = CRM_Core_BAO_LocationType::getDefault();
// set the value to default location id else set to 1
if (!($defaultLocationId = (int) $defaultLocation->id)) {
$defaultLocationId = 1;
}
}
require_once 'CRM/Contact/BAO/Query.php';
$locationFields = CRM_Contact_BAO_Query::$_locationSpecificFields;
$contactFormatted = array();
foreach ($params as $key => $field) {
if ($field == NULL || $field === '') {
continue;
}
if (is_array($field)) {
foreach ($field as $value) {
$break = FALSE;
if (is_array($value)) {
foreach ($value as $name => $testForEmpty) {
if ($name !== 'phone_type' && ($testForEmpty === '' || $testForEmpty == NULL)) {
$break = TRUE;
break;
}
}
} else {
$break = TRUE;
}
if (!$break) {
_civicrm_api3_deprecated_add_formatted_param($value, $contactFormatted);
}
}
continue;
}
$value = array($key => $field);
// check if location related field, then we need to add primary location type
if (in_array($key, $locationFields)) {
$value['location_type_id'] = $defaultLocationId;
} elseif (array_key_exists($key, $cIndieFields)) {
$value['contact_type'] = $contactType;
}
_civicrm_api3_deprecated_add_formatted_param($value, $contactFormatted);
}
$contactFormatted['contact_type'] = $contactType;
return _civicrm_api3_deprecated_duplicate_formatted_contact($contactFormatted);
}
示例5: CRM_Core_Dao
/**
* Create a new forward event, create a new contact if necessary
*
* @param $job_id
* @param $queue_id
* @param $hash
* @param $forward_email
* @param null $fromEmail
* @param null $comment
*
* @return bool
*/
public static function &forward($job_id, $queue_id, $hash, $forward_email, $fromEmail = NULL, $comment = NULL)
{
$q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
$successfulForward = FALSE;
$contact_id = NULL;
if (!$q) {
return $successfulForward;
}
/* Find the email address/contact, if it exists */
$contact = CRM_Contact_BAO_Contact::getTableName();
$location = CRM_Core_BAO_Location::getTableName();
$email = CRM_Core_BAO_Email::getTableName();
$queueTable = CRM_Mailing_Event_BAO_Queue::getTableName();
$job = CRM_Mailing_BAO_MailingJob::getTableName();
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
$forward = self::getTableName();
$domain = CRM_Core_BAO_Domain::getDomain();
$dao = new CRM_Core_Dao();
$dao->query("\n SELECT {$contact}.id as contact_id,\n {$email}.id as email_id,\n {$contact}.do_not_email as do_not_email,\n {$queueTable}.id as queue_id\n FROM ({$email}, {$job} as temp_job)\n INNER JOIN {$contact}\n ON {$email}.contact_id = {$contact}.id\n LEFT JOIN {$queueTable}\n ON {$email}.id = {$queueTable}.email_id\n LEFT JOIN {$job}\n ON {$queueTable}.job_id = {$job}.id\n AND temp_job.mailing_id = {$job}.mailing_id\n WHERE {$queueTable}.job_id = {$job_id}\n AND {$email}.email = '" . CRM_Utils_Type::escape($forward_email, 'String') . "'");
$dao->fetch();
$transaction = new CRM_Core_Transaction();
if (isset($dao->queue_id) || isset($dao->do_not_email) && $dao->do_not_email == 1) {
/* We already sent this mailing to $forward_email, or we should
* never email this contact. Give up. */
return $successfulForward;
}
require_once 'api/api.php';
$contactParams = array('email' => $forward_email, 'version' => 3);
$contactValues = civicrm_api('contact', 'get', $contactParams);
$count = $contactValues['count'];
if ($count == 0) {
/* If the contact does not exist, create one. */
$formatted = array('contact_type' => 'Individual', 'version' => 3);
$locationType = CRM_Core_BAO_LocationType::getDefault();
$value = array('email' => $forward_email, 'location_type_id' => $locationType->id);
require_once 'CRM/Utils/DeprecatedUtils.php';
_civicrm_api3_deprecated_add_formatted_param($value, $formatted);
$formatted['onDuplicate'] = CRM_Import_Parser::DUPLICATE_SKIP;
$formatted['fixAddress'] = TRUE;
$contact = civicrm_api('contact', 'create', $formatted);
if (civicrm_error($contact)) {
return $successfulForward;
}
$contact_id = $contact['id'];
}
$email = new CRM_Core_DAO_Email();
$email->email = $forward_email;
$email->find(TRUE);
$email_id = $email->id;
if (!$contact_id) {
$contact_id = $email->contact_id;
}
/* Create a new queue event */
$queue_params = array('email_id' => $email_id, 'contact_id' => $contact_id, 'job_id' => $job_id);
$queue = CRM_Mailing_Event_BAO_Queue::create($queue_params);
$forward = new CRM_Mailing_Event_BAO_Forward();
$forward->time_stamp = date('YmdHis');
$forward->event_queue_id = $queue_id;
$forward->dest_queue_id = $queue->id;
$forward->save();
$dao->reset();
$dao->query(" SELECT {$job}.mailing_id as mailing_id\n FROM {$job}\n WHERE {$job}.id = " . CRM_Utils_Type::escape($job_id, 'Integer'));
$dao->fetch();
$mailing_obj = new CRM_Mailing_BAO_Mailing();
$mailing_obj->id = $dao->mailing_id;
$mailing_obj->find(TRUE);
$config = CRM_Core_Config::singleton();
$mailer = $config->getMailer();
$recipient = NULL;
$attachments = NULL;
$message = $mailing_obj->compose($job_id, $queue->id, $queue->hash, $queue->contact_id, $forward_email, $recipient, FALSE, NULL, $attachments, TRUE, $fromEmail);
//append comment if added while forwarding.
if (count($comment)) {
$message->_txtbody = CRM_Utils_Array::value('body_text', $comment) . $message->_txtbody;
if (!empty($comment['body_html'])) {
$message->_htmlbody = $comment['body_html'] . '<br />---------------Original message---------------------<br />' . $message->_htmlbody;
}
}
$body = $message->get();
$headers = $message->headers();
$result = NULL;
if (is_object($mailer)) {
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
$result = $mailer->send($recipient, $headers, $body);
unset($errorScope);
}
$params = array('event_queue_id' => $queue->id, 'job_id' => $job_id, 'hash' => $queue->hash);
if (is_a($result, 'PEAR_Error')) {
//.........这里部分代码省略.........