本文整理汇总了PHP中CRM_Core_BAO_Location::getTableName方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_Location::getTableName方法的具体用法?PHP CRM_Core_BAO_Location::getTableName怎么用?PHP CRM_Core_BAO_Location::getTableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_Location
的用法示例。
在下文中一共展示了CRM_Core_BAO_Location::getTableName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Register a subscription event. Create a new contact if one does not
* already exist.
*
* @param int $domain_id The domain id of the new subscription
* @param int $group_id The group id to subscribe to
* @param string $email The email address of the (new) contact
* @return int|null $se_id The id of the subscription event, null on failure
* @access public
* @static
*/
function &subscribe($domain_id, $group_id, $email)
{
/* First, find out if the contact already exists */
$params = array('email' => $email, 'domain_id' => $domain_id);
require_once 'CRM/Core/BAO/UFGroup.php';
$contact_id = CRM_Core_BAO_UFGroup::findContact($params);
CRM_Core_DAO::transaction('BEGIN');
if (is_a($contact_id, CRM_Core_Error)) {
require_once 'CRM/Core/BAO/LocationType.php';
/* If the contact does not exist, create one. */
$formatted = array('contact_type' => 'Individual');
$value = array('email' => $email, 'location_type' => CRM_Core_BAO_LocationType::getDefaultID());
_crm_add_formatted_param($value, $formatted);
$contact =& crm_create_contact_formatted($formatted, CRM_IMPORT_PARSER_DUPLICATE_SKIP);
if (is_a($contact, CRM_Core_Error)) {
return null;
}
$contact_id = $contact->id;
}
require_once 'CRM/Core/BAO/Email.php';
require_once 'CRM/Core/BAO/Location.php';
require_once 'CRM/Contact/BAO/Contact.php';
/* Get the primary email id from the contact to use as a hash input */
$dao =& new CRM_Core_DAO();
$emailTable = CRM_Core_BAO_Email::getTableName();
$locTable = CRM_Core_BAO_Location::getTableName();
$contactTable = CRM_Contact_BAO_Contact::getTableName();
$dao->query("SELECT {$emailTable}.id as email_id\n FROM {$emailTable}\n INNER JOIN {$locTable}\n ON {$emailTable}.location_id = {$locTable}.id\n WHERE {$emailTable}.is_primary = 1\n AND {$locTable}.is_primary = 1\n AND {$locTable}.entity_table = '{$contactTable}'\n AND {$locTable}.entity_id = " . CRM_Utils_Type::escape($contact_id, 'Integer'));
$dao->fetch();
$se =& new CRM_Mailing_Event_BAO_Subscribe();
$se->group_id = $group_id;
$se->contact_id = $contact_id;
$se->time_stamp = date('YmdHis');
$se->hash = sha1("{$group_id}:{$contact_id}:{$dao->email_id}");
$se->save();
$contacts = array($contact_id);
require_once 'CRM/Contact/BAO/GroupContact.php';
CRM_Contact_BAO_GroupContact::addContactsToGroup($contacts, $group_id, 'Email', 'Pending', $se->id);
CRM_Core_DAO::transaction('COMMIT');
return $se;
}
示例2: array
/**
* Create a new forward event, create a new contact if necessary
*/
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;
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_Job::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();
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
if (isset($dao->queue_id) || $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/v2/Contact.php';
$contact_params = array('email' => $forward_email);
$count = civicrm_contact_search_count($contact_params);
if ($count == 0) {
require_once 'CRM/Core/BAO/LocationType.php';
/* If the contact does not exist, create one. */
$formatted = array('contact_type' => 'Individual');
$locationType = CRM_Core_BAO_LocationType::getDefault();
$value = array('email' => $forward_email, 'location_type_id' => $locationType->id);
_civicrm_add_formatted_param($value, $formatted);
require_once 'CRM/Import/Parser.php';
$formatted['onDuplicate'] = CRM_Import_Parser::DUPLICATE_SKIP;
$formatted['fixAddress'] = true;
$contact =& civicrm_contact_format_create($formatted);
if (civicrm_error($contact, CRM_Core_Error)) {
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 = $comment['body_text'] . $message->_txtbody;
if (CRM_Utils_Array::value('body_html', $comment)) {
$message->_htmlbody = $comment['body_html'] . '<br />---------------Original message---------------------<br />' . $message->_htmlbody;
}
}
$body = $message->get();
$headers = $message->headers();
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array('CRM_Core_Error', 'nullHandler'));
$result = null;
if (is_object($mailer)) {
$result = $mailer->send($recipient, $headers, $body);
CRM_Core_Error::setCallback();
}
$params = array('event_queue_id' => $queue->id, 'job_id' => $job_id, 'hash' => $queue->hash);
if (is_a($result, PEAR_Error)) {
/* Register the bounce event */
$params = array_merge($params, CRM_Mailing_BAO_BouncePattern::match($result->getMessage()));
CRM_Mailing_Event_BAO_Bounce::create($params);
} else {
$successfulForward = true;
/* Register the delivery event */
CRM_Mailing_Event_BAO_Delivered::create($params);
}
$transaction->commit();
//.........这里部分代码省略.........
示例3: array
/**
* 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')) {
//.........这里部分代码省略.........
示例4: add
/**
* takes an associative array and creates a contact object
*
* the function extract all the params it needs to initialize the create a
* contact object. the params array could contain additional unused name/value
* pairs
*
* @param array $params (reference ) an assoc array of name/value pairs
* @param array $ids the array that holds all the db ids
* @param array $locationId
*
* @return object CRM_Core_BAO_Location object on success, null otherwise
* @access public
* @static
*/
function add(&$params, &$ids, $locationId)
{
if (!CRM_Core_BAO_Location::dataExists($params, $locationId, $ids)) {
return null;
}
$location =& new CRM_Core_BAO_Location();
if (!isset($params['contact_id'])) {
require_once 'CRM/Core/BAO/Domain.php';
$location->entity_table = CRM_Core_BAO_Domain::getTableName();
$location->entity_id = $params['domain_id'];
} else {
$location->entity_table = CRM_Contact_BAO_Contact::getTableName();
$location->entity_id = $params['contact_id'];
}
$location->location_type_id = CRM_Utils_Array::value('location_type_id', $params['location'][$locationId]);
$location->name = CRM_Utils_Array::value('name', $params['location'][$locationId]);
$location->is_primary = CRM_Utils_Array::value('is_primary', $params['location'][$locationId], false);
// check if there exists another location has is_primary set, and if so reset that
// if no location has is_primary, make this one is_primart
if ($location->is_primary) {
// reset all other locations with the same entity table entity id
$sql = "UPDATE " . CRM_Core_BAO_Location::getTableName() . "\n SET is_primary = 0 WHERE \n entity_table = '{$location->entity_table}' AND\n entity_id = '{$location->entity_id}' ";
CRM_Core_DAO::executeQuery($sql);
} else {
// make sure there is at once location with is_primary set
$sql = "SELECT count( " . CRM_Core_BAO_Location::getTableName() . ".id )\n FROM " . CRM_Core_BAO_Location::getTableName() . " WHERE\n entity_table = '{$location->entity_table}' AND\n entity_id = '{$location->entity_id}' AND\n is_primary = 1";
$count = CRM_Core_DAO::singleValueQuery($sql);
if ($count == 0) {
$location->is_primary = true;
}
}
$location->id = CRM_Utils_Array::value('id', $ids['location'][$locationId]);
$location->save();
$params['location'][$locationId]['id'] = $location->id;
$address_object = CRM_Core_BAO_Address::add($params, $ids, $locationId);
$location->address = $address_object;
// set this to true if this has been made the primary IM.
// the rule is the first entered value is the primary object
$isPrimaryPhone = $isPrimaryEmail = $isPrimaryIM = true;
$location->phone = array();
$location->email = array();
$location->im = array();
for ($i = 1; $i <= CRM_CONTACT_FORM_LOCATION_BLOCKS; $i++) {
$location->phone[$i] = CRM_Core_BAO_Phone::add($params, $ids, $locationId, $i, $isPrimaryPhone);
$location->email[$i] = CRM_Core_BAO_Email::add($params, $ids, $locationId, $i, $isPrimaryEmail);
$location->im[$i] = CRM_Core_BAO_IM::add($params, $ids, $locationId, $i, $isPrimaryIM);
}
return $location;
}
示例5: elseif
/**
* Create a new forward event, create a new contact if necessary
*/
function &forward($job_id, $queue_id, $hash, $forward_email)
{
$q =& CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
if (!$q) {
return null;
}
/* 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_Job::getTableName();
$mailing = CRM_Mailing_BAO_Mailing::getTableName();
$forward = CRM_Mailing_Event_BAO_Forward::getTableName();
$domain =& CRM_Mailing_Event_BAO_Queue::getDomain($queue_id);
$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 {$location}\n ON {$email}.location_id = {$location}.id\n INNER JOIN {$contact}\n ON {$location}.entity_table = '{$contact}'\n AND {$location}.entity_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 temp_job.id = {$job_id}\n AND {$email}.email = '" . CRM_Utils_Type::escape($forward_email, 'String') . "'");
$dao->fetch();
CRM_Core_DAO::transaction('BEGIN');
if (isset($dao->queue_id) || $dao->do_not_email == 1) {
/* We already sent this mailing to $forward_email, or we should
* never email this contact. Give up. */
return false;
} elseif (empty($dao->contact_id)) {
/* No contact found, we'll have to create a new one */
$contact_params = array('email' => $forward_email);
$contact =& crm_create_contact($contact_params);
if (is_a($contact, 'CRM_Core_Error')) {
return false;
}
/* This is an ugly hack, but the API doesn't really support
* overriding the domain ID any other way */
$contact->domain_id = $domain->id;
$contact->save();
$contact_id = $contact->id;
$email_id = $contact->location[1]->email[1]->id;
} else {
$contact_id = $dao->contact_id;
$email_id = $dao->email_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;
$message =& $mailing_obj->compose($job_id, $queue->id, $queue->hash, $queue->contact_id, $forward_email, $recipient);
$body = $message->get();
$headers = $message->headers();
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array('CRM_Mailing_BAO_Mailing', 'catchSMTP'));
$result = $mailer->send($recipient, $headers, $body);
CRM_Core_Error::setCallback();
$params = array('event_queue_id' => $queue->id, 'job_id' => $job_id, 'hash' => $queue->hash);
if (is_a($result, PEAR_Error)) {
/* Register the bounce event */
$params = array_merge($params, CRM_Mailing_BAO_BouncePattern::match($result->getMessage()));
CRM_Mailing_Event_BAO_Bounce::create($params);
} else {
/* Register the delivery event */
CRM_Mailing_Event_BAO_Delivered::create($params);
}
CRM_Core_DAO::transaction('COMMIT');
return true;
}