本文整理汇总了PHP中CRM_Contact_BAO_Contact::save方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Contact::save方法的具体用法?PHP CRM_Contact_BAO_Contact::save怎么用?PHP CRM_Contact_BAO_Contact::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Contact
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Contact::save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unsub_from_domain
/**
* Unsubscribe a contact from the domain.
*
* @param int $job_id
* The job ID.
* @param int $queue_id
* The Queue Event ID of the recipient.
* @param string $hash
* The hash.
*
* @return bool
* Was the contact successfully unsubscribed?
*/
public static function unsub_from_domain($job_id, $queue_id, $hash)
{
$q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
if (!$q) {
return FALSE;
}
$transaction = new CRM_Core_Transaction();
$now = date('YmdHis');
if (CRM_Core_BAO_Email::isMultipleBulkMail()) {
$email = new CRM_Core_BAO_Email();
$email->id = $q->email_id;
if ($email->find(TRUE)) {
$sql = "\nUPDATE civicrm_email\nSET on_hold = 2,\n hold_date = %1\nWHERE email = %2\n";
$sqlParams = array(1 => array($now, 'Timestamp'), 2 => array($email->email, 'String'));
CRM_Core_DAO::executeQuery($sql, $sqlParams);
}
} else {
$contact = new CRM_Contact_BAO_Contact();
$contact->id = $q->contact_id;
$contact->is_opt_out = TRUE;
$contact->save();
}
$ue = new CRM_Mailing_Event_BAO_Unsubscribe();
$ue->event_queue_id = $queue_id;
$ue->org_unsubscribe = 1;
$ue->time_stamp = $now;
$ue->save();
$shParams = array('contact_id' => $q->contact_id, 'group_id' => NULL, 'status' => 'Removed', 'method' => 'Email', 'tracking' => $ue->id);
CRM_Contact_BAO_SubscriptionHistory::create($shParams);
$transaction->commit();
return TRUE;
}
示例2: unsub_from_domain
/**
* Unsubscribe a contact from the domain
*
* @param int $job_id The job ID
* @param int $queue_id The Queue Event ID of the recipient
* @param string $hash The hash
* @return boolean Was the contact succesfully unsubscribed?
* @access public
* @static
*/
public static function unsub_from_domain($job_id, $queue_id, $hash)
{
$q =& CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
if (!$q) {
return false;
}
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
$contact = new CRM_Contact_BAO_Contact();
$contact->id = $q->contact_id;
$contact->is_opt_out = true;
$contact->save();
$ue = new CRM_Mailing_Event_BAO_Unsubscribe();
$ue->event_queue_id = $queue_id;
$ue->org_unsubscribe = 1;
$ue->time_stamp = date('YmdHis');
$ue->save();
$shParams = array('contact_id' => $q->contact_id, 'group_id' => null, 'status' => 'Removed', 'method' => 'Email', 'tracking' => $ue->id);
CRM_Contact_BAO_SubscriptionHistory::create($shParams);
$transaction->commit();
return true;
}
示例3: postProcess
/**
* process the form after the input has been submitted and validated
*
* @access public
*
* @return void
*/
public function postProcess()
{
//get the submitted values in an array
$params = $this->controller->exportValues($this->_name);
$actionTypeOption = CRM_Utils_Array::value('actionTypeOption', $params, NULL);
// If remove option has been selected set new privacy value to "false"
$privacyValueNew = empty($actionTypeOption);
// check if any privay option has been checked
if (!empty($params['pref'])) {
$privacyValues = $params['pref'];
$count = 0;
foreach ($this->_contactIds as $contact_id) {
$contact = new CRM_Contact_BAO_Contact();
$contact->id = $contact_id;
foreach ($privacyValues as $privacy_key => $privacy_value) {
$contact->{$privacy_key} = $privacyValueNew;
}
$contact->save();
$count++;
}
// Status message
$privacyOptions = CRM_Core_SelectValues::privacy();
$status = array();
foreach ($privacyValues as $privacy_key => $privacy_value) {
$label = $privacyOptions[$privacy_key];
$status[] = $privacyValueNew ? ts("Added '%1'", array(1 => $label)) : ts("Removed '%1'", array(1 => $label));
}
$status = '<ul><li>' . implode('</li><li>', $status) . '</li></ul>';
if ($count > 1) {
$title = ts('%1 Contacts Updated', array(1 => $count));
} else {
$name = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contact_id, 'display_name');
$title = ts('%1 Updated', array(1 => $name));
}
CRM_Core_Session::setStatus($status, $title, 'success');
}
}
示例4: updateDisplayNames
/**
* Regenerates display_name for contacts with given prefixes/suffixes.
*
* @param array $ids
* The array with the prefix/suffix id governing which contacts to regenerate.
* @param int $action
* The action describing whether prefix/suffix was UPDATED or DELETED.
*/
public static function updateDisplayNames(&$ids, $action)
{
// get the proper field name (prefix_id or suffix_id) and its value
$fieldName = '';
foreach ($ids as $key => $value) {
switch ($key) {
case 'individualPrefix':
$fieldName = 'prefix_id';
$fieldValue = $value;
break 2;
case 'individualSuffix':
$fieldName = 'suffix_id';
$fieldValue = $value;
break 2;
}
}
if ($fieldName == '') {
return;
}
// query for the affected individuals
$fieldValue = CRM_Utils_Type::escape($fieldValue, 'Integer');
$contact = new CRM_Contact_BAO_Contact();
$contact->{$fieldName} = $fieldValue;
$contact->find();
// iterate through the affected individuals and rebuild their display_names
while ($contact->fetch()) {
$contact = new CRM_Contact_BAO_Contact();
$contact->id = $contact->contact_id;
if ($action == CRM_Core_Action::DELETE) {
$contact->{$fieldName} = 'NULL';
$contact->save();
}
$contact->display_name = $contact->displayName();
$contact->save();
}
}