本文整理汇总了PHP中CRM_Mailing_BAO_Mailing::add方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Mailing_BAO_Mailing::add方法的具体用法?PHP CRM_Mailing_BAO_Mailing::add怎么用?PHP CRM_Mailing_BAO_Mailing::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Mailing_BAO_Mailing
的用法示例。
在下文中一共展示了CRM_Mailing_BAO_Mailing::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mte_civicrm_install
/**
* Implementation of hook_civicrm_install
*/
function mte_civicrm_install()
{
$mailingParams = array('subject' => '***All Transactional Emails***', 'name' => ts('Transaction Emails'), 'url_tracking' => TRUE, 'forward_replies' => FALSE, 'auto_responder' => FALSE, 'open_tracking' => TRUE, 'is_completed' => FALSE);
//create entry in civicrm_mailing
$mailing = CRM_Mailing_BAO_Mailing::add($mailingParams, CRM_Core_DAO::$_nullArray);
//add entry in civicrm_mailing_job
//MTE-17
$config = CRM_Core_Config::singleton();
if (property_exists($config, 'civiVersion')) {
$civiVersion = $config->civiVersion;
} else {
$civiVersion = CRM_Core_BAO_Domain::version();
}
$jobCLassName = 'CRM_Mailing_DAO_MailingJob';
if (version_compare('4.4alpha1', $civiVersion) > 0) {
$jobCLassName = 'CRM_Mailing_DAO_Job';
}
$changeENUM = FALSE;
if (version_compare('4.5alpha1', $civiVersion) > 0) {
$changeENUM = TRUE;
}
CRM_Core_Smarty::singleton()->assign('changeENUM', $changeENUM);
_mte_civix_civicrm_install();
$saveJob = new $jobCLassName();
$saveJob->start_date = $saveJob->end_date = date('YmdHis');
$saveJob->status = 'Complete';
$saveJob->job_type = "Special: All transactional emails being sent through Mandrill";
$saveJob->mailing_id = $mailing->id;
$saveJob->save();
// create mailing bounce type
$mailingBounceType = array('1' => array('name' => 'Mandrill Hard', 'description' => 'Mandrill hard bounce', 'hold_threshold' => 1), '2' => array('name' => 'Mandrill Soft', 'description' => 'Mandrill soft bounce', 'hold_threshold' => 3), '3' => array('name' => 'Mandrill Spam', 'description' => 'User marked a transactional email sent via Mandrill as spam', 'hold_threshold' => 1), '4' => array('name' => 'Mandrill Reject', 'description' => 'Mandrill rejected delivery to this email address', 'hold_threshold' => 1));
foreach ($mailingBounceType as $value) {
$bounceType = new CRM_Mailing_DAO_BounceType();
$bounceType->copyValues($value);
if (!$bounceType->find(true)) {
$bounceType->save();
}
}
return TRUE;
}
示例2: civicrm_api3_speakcivi_remind
function civicrm_api3_speakcivi_remind($params)
{
// how old not confirmed petitions
$start = microtime(true);
$days = $params['days'];
$daysContact = $params['days_contact'];
if ($daysContact < $days) {
$daysContact = $days;
}
$groupId = CRM_Core_BAO_Setting::getItem('Speakcivi API Preferences', 'group_id');
$activityTypeId = CRM_Core_OptionGroup::getValue('activity_type', 'Petition', 'name', 'String', 'value');
$adminId = 1;
$query = "SELECT acp.activity_id, ap.campaign_id, acp.contact_id\n FROM civicrm_activity ap\n JOIN civicrm_activity_contact acp ON acp.activity_id = ap.id\n JOIN civicrm_contact c ON c.id = acp.contact_id\n LEFT JOIN civicrm_group_contact gc ON gc.contact_id = acp.contact_id AND gc.group_id = %1 AND gc.status = 'Added'\n WHERE ap.activity_type_id = %2 AND ap.status_id = 1 AND ap.activity_date_time <= date_add(current_date, INTERVAL -%3 DAY)\n AND c.created_date >= date_add(current_date, INTERVAL -%4 DAY)\n AND c.is_opt_out = 0 AND c.is_deleted = 0 AND c.is_deceased = 0 AND c.do_not_email = 0 AND gc.id IS NULL";
$params = array(1 => array($groupId, 'Integer'), 2 => array($activityTypeId, 'Integer'), 3 => array($days, 'Integer'), 4 => array($daysContact, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
$contacts = array();
$campaigns = array();
while ($dao->fetch()) {
$contacts[$dao->campaign_id][$dao->contact_id] = $dao->contact_id;
$campaigns[$dao->campaign_id] = $dao->campaign_id;
}
$message = array();
$subject = array();
$utmCampaign = array();
$locale = array();
$language = array();
$email = array();
foreach ($campaigns as $cid) {
$campaignObj = new CRM_Speakcivi_Logic_Campaign($cid);
$message[$cid] = $campaignObj->getMessageNew();
$subject[$cid] = substr(removeSmartyIfClause(convertTokens($campaignObj->getSubjectNew())), 0, 128);
$utmCampaign[$cid] = $campaignObj->getUtmCampaign();
$locale[$cid] = $campaignObj->getLanguage();
$language[$cid] = strtoupper(substr($locale[$cid], 0, 2));
$email[$cid] = parseSenderEmail($campaignObj->getSenderMail());
}
// fetch confirmation block
$messageHtml = array();
$messageText = array();
foreach ($message as $cid => $msg) {
$url_confirm_and_keep = CRM_Utils_System::url('civicrm/speakcivi/confirm', null, true) . "?id={contact.contact_id}&cid={$cid}&hash={speakcivi.confirmation_hash}&utm_source=civicrm&utm_medium=email&utm_campaign=" . $utmCampaign[$cid];
$url_confirm_and_not_receive = CRM_Utils_System::url('civicrm/speakcivi/optout', null, true) . "?id={contact.contact_id}&cid={$cid}&hash={speakcivi.confirmation_hash}&utm_source=civicrm&utm_medium=email&utm_campaign=" . $utmCampaign[$cid];
$locales = getLocale($locale[$cid]);
$confirmationBlockHtml = implode('', file(dirname(__FILE__) . '/../../templates/CRM/Speakcivi/Page/ConfirmationBlock.' . $locales['html'] . '.html.tpl'));
$confirmationBlockText = implode('', file(dirname(__FILE__) . '/../../templates/CRM/Speakcivi/Page/ConfirmationBlock.' . $locales['text'] . '.text.tpl'));
$confirmationBlockHtml = str_replace('{$url_confirm_and_keep}', $url_confirm_and_keep, $confirmationBlockHtml);
$confirmationBlockHtml = str_replace('{$url_confirm_and_not_receive}', $url_confirm_and_not_receive, $confirmationBlockHtml);
$confirmationBlockText = str_replace('{$url_confirm_and_keep}', $url_confirm_and_keep, $confirmationBlockText);
$confirmationBlockText = str_replace('{$url_confirm_and_not_receive}', $url_confirm_and_not_receive, $confirmationBlockText);
$messageHtml[$cid] = removeSmartyIfClause(convertTokens(removeDelim(str_replace("#CONFIRMATION_BLOCK", $confirmationBlockHtml, $msg))));
$messageText[$cid] = convertHtmlToText(removeSmartyIfClause(convertTokens(removeDelim(str_replace("#CONFIRMATION_BLOCK", $confirmationBlockText, $msg)))));
}
foreach ($campaigns as $cid) {
$sentContacts = findSentContacts($cid);
$contacts[$cid] = excludeContacts($contacts[$cid], $sentContacts);
if (is_array($contacts[$cid]) && count($contacts[$cid]) > 0) {
if ($mailingId = findNotCompletedMailing($cid)) {
if ($linkedGroupId = findLinkedGroup($mailingId)) {
addContactsToGroup($contacts[$cid], $linkedGroupId);
} else {
$includeGroupId = createGroup($cid, $language[$cid]);
addContactsToGroup($contacts[$cid], $includeGroupId);
includeGroup($mailingId, $includeGroupId);
}
} else {
$name = determineMailingName($cid, $language[$cid]);
$params = array('name' => $name, 'subject' => $subject[$cid], 'body_text' => $messageText[$cid], 'body_html' => $messageHtml[$cid], 'created_id' => $adminId, 'created_date' => date('YmdHis'), 'campaign_id' => $cid, 'mailing_type' => 'standalone', 'unsubscribe_id' => 5, 'resubscribe_id' => 6, 'optout_id' => 7, 'reply_id' => 8, 'open_tracking' => 1, 'url_tracking' => 1, 'dedupe_email' => 1, 'from_name' => $email[$cid]['from_name'], 'from_email' => $email[$cid]['from_email'], 'footer_id' => chooseFooter($language[$cid]));
$mailing = new CRM_Mailing_BAO_Mailing();
$mm = $mailing->add($params);
excludeGroup($mm->id, $groupId);
if ($existingGroupId = findExistingGroup($cid)) {
cleanGroup($existingGroupId);
addContactsToGroup($contacts[$cid], $existingGroupId);
includeGroup($mm->id, $existingGroupId);
} else {
$includeGroupId = createGroup($cid, $language[$cid]);
addContactsToGroup($contacts[$cid], $includeGroupId);
includeGroup($mm->id, $includeGroupId);
}
}
}
}
$results = array('time' => microtime(true) - $start);
return civicrm_api3_create_success($results, $params);
}