本文整理汇总了PHP中CRM_Core_BAO_Email::isMultipleBulkMail方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_Email::isMultipleBulkMail方法的具体用法?PHP CRM_Core_BAO_Email::isMultipleBulkMail怎么用?PHP CRM_Core_BAO_Email::isMultipleBulkMail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_Email
的用法示例。
在下文中一共展示了CRM_Core_BAO_Email::isMultipleBulkMail方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: buildQuickForm
/**
* Build the form object elements for an email object.
*
* @param CRM_Core_Form $form
* Reference to the form object.
* @param int $blockCount
* Block number to build.
* @param bool $blockEdit
* Is it block edit.
*/
public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE)
{
// passing this via the session is AWFUL. we need to fix this
if (!$blockCount) {
$blockId = $form->get('Email_Block_Count') ? $form->get('Email_Block_Count') : 1;
} else {
$blockId = $blockCount;
}
$form->applyFilter('__ALL__', 'trim');
//Email box
$form->addField("email[{$blockId}][email]", array('entity' => 'email'));
$form->addRule("email[{$blockId}][email]", ts('Email is not valid.'), 'email');
if (isset($form->_contactType) || $blockEdit) {
//Block type
$form->addField("email[{$blockId}][location_type_id]", array('entity' => 'email', 'placeholder' => NULL, 'class' => 'eight'));
//TODO: Refactor on_hold field to select.
$multipleBulk = CRM_Core_BAO_Email::isMultipleBulkMail();
//On-hold select
if ($multipleBulk) {
$holdOptions = array(0 => ts('- select -'), 1 => ts('On Hold Bounce'), 2 => ts('On Hold Opt Out'));
$form->addElement('select', "email[{$blockId}][on_hold]", '', $holdOptions);
} else {
$form->addField("email[{$blockId}][on_hold]", array('entity' => 'email', 'type' => 'advcheckbox'));
}
//Bulkmail checkbox
$form->assign('multipleBulk', $multipleBulk);
if ($multipleBulk) {
$js = array('id' => "Email_" . $blockId . "_IsBulkmail");
$form->addElement('advcheckbox', "email[{$blockId}][is_bulkmail]", NULL, '', $js);
} else {
$js = array('id' => "Email_" . $blockId . "_IsBulkmail");
if (!$blockEdit) {
$js['onClick'] = 'singleSelect( this.id );';
}
$form->addElement('radio', "email[{$blockId}][is_bulkmail]", '', '', '1', $js);
}
//is_Primary radio
$js = array('id' => "Email_" . $blockId . "_IsPrimary");
if (!$blockEdit) {
$js['onClick'] = 'singleSelect( this.id );';
}
$form->addElement('radio', "email[{$blockId}][is_primary]", '', '', '1', $js);
if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Contact') {
$form->add('textarea', "email[{$blockId}][signature_text]", ts('Signature (Text)'), array('rows' => 2, 'cols' => 40));
$form->add('wysiwyg', "email[{$blockId}][signature_html]", ts('Signature (HTML)'), array('rows' => 2, 'cols' => 40));
}
}
}
示例3: writeToDB
/**
* @param array $deliveredParams
* @param array $targetParams
* @param $mailing
* @param $job_date
*
* @return bool
* @throws CRM_Core_Exception
* @throws Exception
*/
public function writeToDB(&$deliveredParams, &$targetParams, &$mailing, $job_date)
{
static $activityTypeID = NULL;
static $writeActivity = NULL;
if (!empty($deliveredParams)) {
CRM_Mailing_Event_BAO_Delivered::bulkCreate($deliveredParams);
$deliveredParams = array();
}
if ($writeActivity === NULL) {
$writeActivity = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'write_activity_record', NULL, TRUE);
}
if (!$writeActivity) {
return TRUE;
}
$result = TRUE;
if (!empty($targetParams) && !empty($mailing->scheduled_id)) {
if (!$activityTypeID) {
if ($mailing->sms_provider_id) {
$mailing->subject = $mailing->name;
$activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Mass SMS', 'name');
} else {
$activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Bulk Email', 'name');
}
if (!$activityTypeID) {
CRM_Core_Error::fatal();
}
}
$activity = array('source_contact_id' => $mailing->scheduled_id, 'target_contact_id' => array_unique($targetParams), 'activity_type_id' => $activityTypeID, 'source_record_id' => $this->mailing_id, 'activity_date_time' => $job_date, 'subject' => $mailing->subject, 'status_id' => 2, 'deleteActivityTarget' => FALSE, 'campaign_id' => $mailing->campaign_id);
//check whether activity is already created for this mailing.
//if yes then create only target contact record.
$query = "\nSELECT id\nFROM civicrm_activity\nWHERE civicrm_activity.activity_type_id = %1\nAND civicrm_activity.source_record_id = %2\n";
$queryParams = array(1 => array($activityTypeID, 'Integer'), 2 => array($this->mailing_id, 'Integer'));
$activityID = CRM_Core_DAO::singleValueQuery($query, $queryParams);
if ($activityID) {
$activity['id'] = $activityID;
// CRM-9519
if (CRM_Core_BAO_Email::isMultipleBulkMail()) {
static $targetRecordID = NULL;
if (!$targetRecordID) {
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$targetRecordID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
}
// make sure we don't attempt to duplicate the target activity
foreach ($activity['target_contact_id'] as $key => $targetID) {
$sql = "\nSELECT id\nFROM civicrm_activity_contact\nWHERE activity_id = {$activityID}\nAND contact_id = {$targetID}\nAND record_type_id = {$targetRecordID}\n";
if (CRM_Core_DAO::singleValueQuery($sql)) {
unset($activity['target_contact_id'][$key]);
}
}
}
}
if (is_a(CRM_Activity_BAO_Activity::create($activity), 'CRM_Core_Error')) {
$result = FALSE;
}
$targetParams = array();
}
return $result;
}