本文整理汇总了PHP中CRM_Mailing_DAO_Mailing类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Mailing_DAO_Mailing类的具体用法?PHP CRM_Mailing_DAO_Mailing怎么用?PHP CRM_Mailing_DAO_Mailing使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Mailing_DAO_Mailing类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setDefaultValues
/**
* Set default values for the form.
* the default values are retrieved from the database
*
*
* @return void
*/
public function setDefaultValues()
{
$mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL);
// CRM-14716 - Pick up mailingID from session since most of the time it's not in the URL
if (!$mailingID) {
$mailingID = $this->get('mailing_id');
}
$count = $this->get('count');
$this->assign('count', $count);
$defaults = array();
$componentFields = array('reply_id' => 'Reply', 'optout_id' => 'OptOut', 'unsubscribe_id' => 'Unsubscribe', 'resubscribe_id' => 'Resubscribe');
foreach ($componentFields as $componentVar => $componentType) {
$defaults[$componentVar] = CRM_Mailing_PseudoConstant::defaultComponent($componentType, '');
}
if ($mailingID) {
$dao = new CRM_Mailing_DAO_Mailing();
$dao->id = $mailingID;
$dao->find(TRUE);
// override_verp must be flipped, as in 3.2 we reverted
// its meaning to ‘should CiviMail manage replies?’ – i.e.,
// ‘should it *not* override Reply-To: with VERP-ed address?’
$dao->override_verp = !$dao->override_verp;
$dao->storeValues($dao, $defaults);
$defaults['visibility'] = $dao->visibility;
}
return $defaults;
}
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:34,代码来源:Settings.php
示例2: setDefaultValues
/**
* Set default values for the form.
* The default values are retrieved from the database.
*/
public function setDefaultValues()
{
$mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL);
$continue = CRM_Utils_Request::retrieve('continue', 'String', $this, FALSE, NULL);
$defaults = array();
if ($mailingID) {
$mailing = new CRM_Mailing_DAO_Mailing();
$mailing->id = $mailingID;
$mailing->addSelect('name');
$mailing->find(TRUE);
$defaults['name'] = $mailing->name;
if (!$continue) {
$defaults['name'] = ts('Copy of %1', array(1 => $mailing->name));
} else {
// CRM-7590, reuse same mailing ID if we are continuing
$this->set('mailing_id', $mailingID);
}
$dao = new CRM_Mailing_DAO_MailingGroup();
$mailingGroups = array();
$dao->mailing_id = $mailingID;
$dao->find();
while ($dao->fetch()) {
$mailingGroups[$dao->entity_table][$dao->group_type][] = $dao->entity_id;
}
$defaults['includeGroups'] = $mailingGroups['civicrm_group']['Include'];
$defaults['excludeGroups'] = CRM_Utils_Array::value('Exclude', $mailingGroups['civicrm_group']);
$defaults['includeMailings'] = CRM_Utils_Array::value('Include', CRM_Utils_Array::value('civicrm_mailing', $mailingGroups));
$defaults['excludeMailings'] = CRM_Utils_Array::value('Exclude', CRM_Utils_Array::value('civicrm_mailing', $mailingGroups));
}
return $defaults;
}
开发者ID:sarehag,项目名称:civicrm-core,代码行数:35,代码来源:Group.php
示例3: setDefaultValues
/**
* This function sets the default values for the form.
* the default values are retrieved from the database
*
* @access public
*
* @return None
*/
function setDefaultValues()
{
$mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL);
$continue = CRM_Utils_Request::retrieve('continue', 'String', $this, FALSE, NULL);
// check that the user has permission to access mailing id
CRM_Mailing_BAO_Mailing::checkPermission($mailingID);
$defaults = array();
if ($mailingID) {
$mailing = new CRM_Mailing_DAO_Mailing();
$mailing->id = $mailingID;
$mailing->addSelect('name', 'campaign_id');
$mailing->find(TRUE);
$defaults['name'] = $mailing->name;
if (!$continue) {
$defaults['name'] = ts('Copy of %1', array(1 => $mailing->name));
} else {
// CRM-7590, reuse same mailing ID if we are continuing
$this->set('mailing_id', $mailingID);
}
$defaults['campaign_id'] = $mailing->campaign_id;
$defaults['dedupe_email'] = $mailing->dedupe_email;
$dao = new CRM_Mailing_DAO_Group();
$mailingGroups = array();
$dao->mailing_id = $mailingID;
$dao->find();
while ($dao->fetch()) {
$mailingGroups[$dao->entity_table][$dao->group_type][] = $dao->entity_id;
}
$defaults['includeGroups'] = $mailingGroups['civicrm_group']['Include'];
$defaults['excludeGroups'] = CRM_Utils_Array::value('Exclude', $mailingGroups['civicrm_group']);
$defaults['includeMailings'] = CRM_Utils_Array::value('Include', $mailingGroups['civicrm_mailing']);
$defaults['excludeMailings'] = $mailingGroups['civicrm_mailing']['Exclude'];
}
//when the context is search hide the mailing recipients.
$showHide = new CRM_Core_ShowHideBlocks();
$showGroupSelector = TRUE;
if ($this->_searchBasedMailing) {
$showGroupSelector = FALSE;
$formElements = array('includeGroups', 'excludeGroups', 'includeMailings', 'excludeMailings');
$formValues = $this->controller->exportValues($this->_name);
foreach ($formElements as $element) {
if (!empty($formValues[$element])) {
$showGroupSelector = TRUE;
break;
}
}
}
if ($showGroupSelector) {
$showHide->addShow("id-additional");
$showHide->addHide("id-additional-show");
} else {
$showHide->addShow("id-additional-show");
$showHide->addHide("id-additional");
}
$showHide->addToTemplate();
return $defaults;
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:65,代码来源:Group.php
示例4: setDefaultValues
/**
* This function sets the default values for the form.
* the default values are retrieved from the database
*
* @access public
*
* @return void
*/
function setDefaultValues()
{
$mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL);
//need to differentiate new/reuse mailing, CRM-2873
$reuseMailing = FALSE;
if ($mailingID) {
$reuseMailing = TRUE;
} else {
$mailingID = $this->_mailingID;
}
$count = $this->get('count');
$this->assign('count', $count);
$this->set('skipTextFile', FALSE);
$defaults = array();
if ($mailingID) {
$dao = new CRM_Mailing_DAO_Mailing();
$dao->id = $mailingID;
$dao->find(TRUE);
$dao->storeValues($dao, $defaults);
//we don't want to retrieve template details once it is
//set in session
$templateId = $this->get('template');
$this->assign('templateSelected', $templateId ? $templateId : 0);
if (isset($defaults['msg_template_id']) && !$templateId) {
$defaults['template'] = $defaults['msg_template_id'];
$messageTemplate = new CRM_Core_DAO_MessageTemplate();
$messageTemplate->id = $defaults['msg_template_id'];
$messageTemplate->selectAdd();
$messageTemplate->selectAdd('msg_text');
$messageTemplate->find(TRUE);
$defaults['text_message'] = $messageTemplate->msg_text;
}
if (isset($defaults['body_text'])) {
$defaults['text_message'] = $defaults['body_text'];
$this->set('textFile', $defaults['body_text']);
$this->set('skipTextFile', TRUE);
}
}
//fix for CRM-2873
if (!$reuseMailing) {
$textFilePath = $this->get('textFilePath');
if ($textFilePath && file_exists($textFilePath)) {
$defaults['text_message'] = file_get_contents($textFilePath);
if (strlen($defaults['text_message']) > 0) {
$this->set('skipTextFile', TRUE);
}
}
}
$defaults['upload_type'] = 1;
return $defaults;
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:59,代码来源:Upload.php
示例5: del
/**
* Delete Mails and all its associated records
*
* @param int $id id of the mail to delete
*
* @return void
* @access public
* @static
*/
public static function del($id)
{
if (empty($id)) {
CRM_Core_Error::fatal();
}
// delete all file attachments
CRM_Core_BAO_File::deleteEntityFile('civicrm_mailing', $id);
$dao = new CRM_Mailing_DAO_Mailing();
$dao->id = $id;
$dao->delete();
CRM_Core_Session::setStatus(ts('Selected mailing has been deleted.'));
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:21,代码来源:Mailing.php
示例6: array
/**
* returns the list of fields that can be exported
*
* @access public
* return array
*/
function &export($prefix = false)
{
if (!$GLOBALS['_CRM_MAILING_DAO_MAILING']['_export']) {
$GLOBALS['_CRM_MAILING_DAO_MAILING']['_export'] = array();
$fields =& CRM_Mailing_DAO_Mailing::fields();
foreach ($fields as $name => $field) {
if (CRM_Utils_Array::value('export', $field)) {
if ($prefix) {
$GLOBALS['_CRM_MAILING_DAO_MAILING']['_export']['mailing'] =& $fields[$name];
} else {
$GLOBALS['_CRM_MAILING_DAO_MAILING']['_export'][$name] =& $fields[$name];
}
}
}
}
return $GLOBALS['_CRM_MAILING_DAO_MAILING']['_export'];
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:23,代码来源:Mailing.php
示例7: send_unsub_response
/**
* Send a response email informing the contact of the groups from which he.
* has been unsubscribed.
*
* @param string $queue_id
* The queue event ID.
* @param array $groups
* List of group IDs.
* @param bool $is_domain
* Is this domain-level?.
* @param int $job
* The job ID.
*/
public static function send_unsub_response($queue_id, $groups, $is_domain = FALSE, $job)
{
$config = CRM_Core_Config::singleton();
$domain = CRM_Core_BAO_Domain::getDomain();
$jobObject = new CRM_Mailing_BAO_MailingJob();
$jobTable = $jobObject->getTableName();
$mailingObject = new CRM_Mailing_DAO_Mailing();
$mailingTable = $mailingObject->getTableName();
$contactsObject = new CRM_Contact_DAO_Contact();
$contacts = $contactsObject->getTableName();
$emailObject = new CRM_Core_DAO_Email();
$email = $emailObject->getTableName();
$queueObject = new CRM_Mailing_Event_BAO_Queue();
$queue = $queueObject->getTableName();
//get the default domain email address.
list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail();
$dao = new CRM_Mailing_BAO_Mailing();
$dao->query(" SELECT * FROM {$mailingTable}\n INNER JOIN {$jobTable} ON\n {$jobTable}.mailing_id = {$mailingTable}.id\n WHERE {$jobTable}.id = {$job}");
$dao->fetch();
$component = new CRM_Mailing_BAO_Component();
if ($is_domain) {
$component->id = $dao->optout_id;
} else {
$component->id = $dao->unsubscribe_id;
}
$component->find(TRUE);
$html = $component->body_html;
if ($component->body_text) {
$text = $component->body_text;
} else {
$text = CRM_Utils_String::htmlToText($component->body_html);
}
$eq = new CRM_Core_DAO();
$eq->query("SELECT {$contacts}.preferred_mail_format as format,\n {$contacts}.id as contact_id,\n {$email}.email as email,\n {$queue}.hash as hash\n FROM {$contacts}\n INNER JOIN {$queue} ON {$queue}.contact_id = {$contacts}.id\n INNER JOIN {$email} ON {$queue}.email_id = {$email}.id\n WHERE {$queue}.id = " . CRM_Utils_Type::escape($queue_id, 'Integer'));
$eq->fetch();
if ($groups) {
foreach ($groups as $key => $value) {
if (!$value) {
unset($groups[$key]);
}
}
}
$message = new Mail_mime("\n");
list($addresses, $urls) = CRM_Mailing_BAO_Mailing::getVerpAndUrls($job, $queue_id, $eq->hash, $eq->email);
$bao = new CRM_Mailing_BAO_Mailing();
$bao->body_text = $text;
$bao->body_html = $html;
$tokens = $bao->getTokens();
if ($eq->format == 'HTML' || $eq->format == 'Both') {
$html = CRM_Utils_Token::replaceDomainTokens($html, $domain, TRUE, $tokens['html']);
$html = CRM_Utils_Token::replaceUnsubscribeTokens($html, $domain, $groups, TRUE, $eq->contact_id, $eq->hash);
$html = CRM_Utils_Token::replaceActionTokens($html, $addresses, $urls, TRUE, $tokens['html']);
$html = CRM_Utils_Token::replaceMailingTokens($html, $dao, NULL, $tokens['html']);
$message->setHTMLBody($html);
}
if (!$html || $eq->format == 'Text' || $eq->format == 'Both') {
$text = CRM_Utils_Token::replaceDomainTokens($text, $domain, FALSE, $tokens['text']);
$text = CRM_Utils_Token::replaceUnsubscribeTokens($text, $domain, $groups, FALSE, $eq->contact_id, $eq->hash);
$text = CRM_Utils_Token::replaceActionTokens($text, $addresses, $urls, FALSE, $tokens['text']);
$text = CRM_Utils_Token::replaceMailingTokens($text, $dao, NULL, $tokens['text']);
$message->setTxtBody($text);
}
$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
$headers = array('Subject' => $component->subject, 'From' => "\"{$domainEmailName}\" <do-not-reply@{$emailDomain}>", 'To' => $eq->email, 'Reply-To' => "do-not-reply@{$emailDomain}", 'Return-Path' => "do-not-reply@{$emailDomain}");
CRM_Mailing_BAO_Mailing::addMessageIdHeader($headers, 'u', $job, $queue_id, $eq->hash);
$b = CRM_Utils_Mail::setMimeParams($message);
$h = $message->headers($headers);
$mailer = \Civi::service('pear_mail');
if (is_object($mailer)) {
$errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
$mailer->send($eq->email, $h, $b);
unset($errorScope);
}
}
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:87,代码来源:Unsubscribe.php
示例8: CRM_Mailing_BAO_Mailing
/**
* class constructor
*/
function CRM_Mailing_BAO_Mailing()
{
parent::CRM_Mailing_DAO_Mailing();
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:7,代码来源:Mailing.php
示例9: del
/**
* Delete Mails and all its associated records
*
* @param int $id id of the mail to delete
*
* @return void
* @access public
* @static
*/
public static function del($id)
{
if (empty($id)) {
CRM_Core_Error::fatal();
}
CRM_Utils_Hook::pre('delete', 'Mailing', $id, CRM_Core_DAO::$_nullArray);
// delete all file attachments
CRM_Core_BAO_File::deleteEntityFile('civicrm_mailing', $id);
$dao = new CRM_Mailing_DAO_Mailing();
$dao->id = $id;
$dao->delete();
CRM_Core_Session::setStatus(ts('Selected mailing has been deleted.'), ts('Deleted'), 'success');
CRM_Utils_Hook::post('delete', 'Mailing', $id, $dao);
}
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:23,代码来源:Mailing.php
示例10: runJobs_pre
/**
* before we run jobs, we need to split the jobs
* @param int $offset
* @param null $mode
*/
public static function runJobs_pre($offset = 200, $mode = NULL)
{
$job = new CRM_Mailing_BAO_MailingJob();
$jobTable = CRM_Mailing_DAO_MailingJob::getTableName();
$mailingTable = CRM_Mailing_DAO_Mailing::getTableName();
$currentTime = date('YmdHis');
$mailingACL = CRM_Mailing_BAO_Mailing::mailingACL('m');
$workflowClause = CRM_Mailing_BAO_MailingJob::workflowClause();
$domainID = CRM_Core_Config::domainID();
$modeClause = 'AND m.sms_provider_id IS NULL';
if ($mode == 'sms') {
$modeClause = 'AND m.sms_provider_id IS NOT NULL';
}
// Select all the mailing jobs that are created from
// when the mailing is submitted or scheduled.
$query = "\n SELECT j.*\n FROM {$jobTable} j,\n {$mailingTable} m\n WHERE m.id = j.mailing_id AND m.domain_id = {$domainID}\n {$workflowClause}\n {$modeClause}\n AND j.is_test = 0\n AND ( ( j.start_date IS null\n AND j.scheduled_date <= {$currentTime}\n AND j.status = 'Scheduled'\n AND j.end_date IS null ) )\n AND ((j.job_type is NULL) OR (j.job_type <> 'child'))\n ORDER BY j.scheduled_date,\n j.start_date";
$job->query($query);
// For each of the "Parent Jobs" we find, we split them into
// X Number of child jobs
while ($job->fetch()) {
// still use job level lock for each child job
$lockName = "civimail.job.{$job->id}";
$lock = new CRM_Core_Lock($lockName);
if (!$lock->isAcquired()) {
continue;
}
// Re-fetch the job status in case things
// changed between the first query and now
// to avoid race conditions
$job->status = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_MailingJob', $job->id, 'status', 'id', TRUE);
if ($job->status != 'Scheduled') {
$lock->release();
continue;
}
$job->split_job($offset);
// update the status of the parent job
$transaction = new CRM_Core_Transaction();
$saveJob = new CRM_Mailing_DAO_MailingJob();
$saveJob->id = $job->id;
$saveJob->start_date = date('YmdHis');
$saveJob->status = 'Running';
$saveJob->save();
$transaction->commit();
// Release the job lock
$lock->release();
}
}
开发者ID:vakeesan26,项目名称:civicrm-core,代码行数:52,代码来源:MailingJob.php
示例11: _civicrm_api3_mailing_submit_spec
/**
* Adjust metadata for mailing submit api function.
*
* @param array $spec
*/
function _civicrm_api3_mailing_submit_spec(&$spec)
{
$mailingFields = CRM_Mailing_DAO_Mailing::fields();
$spec['id'] = $mailingFields['id'];
$spec['scheduled_date'] = $mailingFields['scheduled_date'];
$spec['approval_date'] = $mailingFields['approval_date'];
$spec['approval_status_id'] = $mailingFields['approval_status_id'];
$spec['approval_note'] = $mailingFields['approval_note'];
// _skip_evil_bao_auto_recipients_: bool
}
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:15,代码来源:Mailing.php
示例12: setDefaultValues
/**
* Set default values for the form.
* the default values are retrieved from the database
*
*
* @return void
*/
public function setDefaultValues()
{
$mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL);
//need to differentiate new/reuse mailing, CRM-2873
$reuseMailing = FALSE;
if ($mailingID) {
$reuseMailing = TRUE;
} else {
$mailingID = $this->_mailingID;
}
$count = $this->get('count');
$this->assign('count', $count);
$this->set('skipTextFile', FALSE);
$this->set('skipHtmlFile', FALSE);
$defaults = array();
$htmlMessage = NULL;
if ($mailingID) {
$dao = new CRM_Mailing_DAO_Mailing();
$dao->id = $mailingID;
$dao->find(TRUE);
$dao->storeValues($dao, $defaults);
//we don't want to retrieve template details once it is
//set in session
$templateId = $this->get('template');
$this->assign('templateSelected', $templateId ? $templateId : 0);
if (isset($defaults['msg_template_id']) && !$templateId) {
$defaults['template'] = $defaults['msg_template_id'];
$messageTemplate = new CRM_Core_DAO_MessageTemplate();
$messageTemplate->id = $defaults['msg_template_id'];
$messageTemplate->selectAdd();
$messageTemplate->selectAdd('msg_text, msg_html');
$messageTemplate->find(TRUE);
$defaults['text_message'] = $messageTemplate->msg_text;
$htmlMessage = $messageTemplate->msg_html;
}
if (isset($defaults['body_text'])) {
$defaults['text_message'] = $defaults['body_text'];
$this->set('textFile', $defaults['body_text']);
$this->set('skipTextFile', TRUE);
}
if (isset($defaults['body_html'])) {
$htmlMessage = $defaults['body_html'];
$this->set('htmlFile', $defaults['body_html']);
$this->set('skipHtmlFile', TRUE);
}
//set default from email address.
if (!empty($defaults['from_name']) && !empty($defaults['from_email'])) {
$defaults['from_email_address'] = array_search('"' . $defaults['from_name'] . '" <' . $defaults['from_email'] . '>', CRM_Core_OptionGroup::values('from_email_address'));
} else {
//get the default from email address.
$defaultAddress = CRM_Core_OptionGroup::values('from_email_address', NULL, NULL, NULL, ' AND is_default = 1');
foreach ($defaultAddress as $id => $value) {
$defaults['from_email_address'] = $id;
}
}
if (!empty($defaults['replyto_email'])) {
$replyToEmail = CRM_Core_OptionGroup::values('from_email_address');
foreach ($replyToEmail as $value) {
if (strstr($value, $defaults['replyto_email'])) {
$replyToEmailAddress = $value;
break;
}
}
$replyToEmailAddress = explode('<', $replyToEmailAddress);
if (count($replyToEmailAddress) > 1) {
$replyToEmailAddress = $replyToEmailAddress[0] . '<' . $replyToEmailAddress[1];
}
$defaults['reply_to_address'] = array_search($replyToEmailAddress, $replyToEmail);
}
}
//fix for CRM-2873
if (!$reuseMailing) {
$textFilePath = $this->get('textFilePath');
if ($textFilePath && file_exists($textFilePath)) {
$defaults['text_message'] = file_get_contents($textFilePath);
if (strlen($defaults['text_message']) > 0) {
$this->set('skipTextFile', TRUE);
}
}
$htmlFilePath = $this->get('htmlFilePath');
if ($htmlFilePath && file_exists($htmlFilePath)) {
$defaults['html_message'] = file_get_contents($htmlFilePath);
if (strlen($defaults['html_message']) > 0) {
$htmlMessage = $defaults['html_message'];
$this->set('skipHtmlFile', TRUE);
}
}
}
if ($this->get('html_message')) {
$htmlMessage = $this->get('html_message');
}
$htmlMessage = str_replace(array("\n", "\r"), ' ', $htmlMessage);
$htmlMessage = str_replace("'", "\\'", $htmlMessage);
//.........这里部分代码省略.........
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:101,代码来源:Upload.php
示例13: runJobs
/**
* Initiate all pending/ready jobs
*
* @return void
* @access public
* @static
*/
public static function runJobs($testParams = null)
{
$job =& new CRM_Mailing_BAO_Job();
$mailing =& new CRM_Mailing_DAO_Mailing();
$config =& CRM_Core_Config::singleton();
$jobTable = CRM_Mailing_DAO_Job::getTableName();
$mailingTable = CRM_Mailing_DAO_Mailing::getTableName();
if (!empty($testParams)) {
$query = "\nSELECT *\n FROM {$jobTable}\n WHERE id = {$testParams['job_id']}";
$job->query($query);
} else {
$currentTime = date('YmdHis');
/* FIXME: we might want to go to a progress table.. */
$query = "\nSELECT j.*\n FROM {$jobTable} j,\n {$mailingTable} m\n WHERE m.id = j.mailing_id\n AND j.is_test = 0\n AND ( ( j.start_date IS null\n AND j.scheduled_date <= {$currentTime}\n AND j.status = 'Scheduled' )\n OR ( j.status = 'Running'\n AND j.end_date IS null ) )\nORDER BY j.scheduled_date,\n j.start_date";
$job->query($query);
}
require_once 'CRM/Core/Lock.php';
/* TODO We should parallelize or prioritize this */
while ($job->fetch()) {
// fix for cancel job at run time which is in queue, CRM-4246
if (CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Job', $job->id, 'status') == 'Canceled') {
continue;
}
$lockName = "civimail.job.{$job->id}";
// get a lock on this job id
$lock = new CRM_Core_Lock($lockName);
if (!$lock->isAcquired()) {
continue;
}
/* Queue up recipients for all jobs being launched */
if ($job->status != 'Running') {
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
$job->queue($testParams);
/* Start the job */
// use a seperate DAO object to protect the loop
// integrity. I think transactions messes it up
// check CRM-2469
$saveJob = new CRM_Mailing_DAO_Job();
$saveJob->id = $job->id;
$saveJob->start_date = date('YmdHis');
$saveJob->status = 'Running';
$saveJob->save();
$transaction->commit();
}
$mailer =& $config->getMailer();
/* Compose and deliver */
$isComplete = $job->deliver($mailer, $testParams);
require_once 'CRM/Utils/Hook.php';
CRM_Utils_Hook::post('create', 'CRM_Mailing_DAO_Spool', $job->id, $isComplete);
if ($isComplete) {
/* Finish the job */
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
// use a seperate DAO object to protect the loop
// integrity. I think transactions messes it up
// check CRM-2469
$saveJob = new CRM_Mailing_DAO_Job();
$saveJob->id = $job->id;
$saveJob->end_date = date('YmdHis');
$saveJob->status = 'Complete';
$saveJob->save();
$mailing->reset();
$mailing->id = $job->mailing_id;
$mailing->is_completed = true;
$mailing->save();
$transaction->commit();
}
$lock->release();
if ($testParams) {
return $isComplete;
}
}
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:81,代码来源:Job.php
示例14: addDisplayEnums
/**
* adds $value['foo_display'] for each $value['foo'] enum from civicrm_mailing
*
* @param array $values (reference) the array up for enhancing
* @return void
*/
static function addDisplayEnums(&$values)
{
$enumFields =& CRM_Mailing_DAO_Mailing::getEnums();
foreach ($enumFields as $enum) {
if (isset($values[$enum])) {
$values[$enum . '_display'] = CRM_Mailing_DAO_Mailing::tsEnum($enum, $values[$enum]);
}
}
}
开发者ID:hguru,项目名称:224Civi,代码行数:15,代码来源:Mailing.php
示例15: mte_createQueue
function mte_createQueue(&$mandrillHeader, $toEmail)
{
$mail = new CRM_Mailing_DAO_Mailing();
$mail->subject = "***All Transactional Emails***";
$mail->url_tracking = TRUE;
$mail->forward_replies = FALSE;
$mail->auto_responder = FALSE;
$mail->open_tracking = TRUE;
if ($mail->find(TRUE)) {
$emails = CRM_Mte_BAO_Mandrill::retrieveEmailContactId($toEmail);
$jobCLassName = 'CRM_Mailing_DAO_MailingJob';
if (version_compare('4.4alpha1', CRM_Core_Config::singleton()->civiVersion) > 0) {
$jobCLassName = 'CRM_Mailing_DAO_Job';
}
$params = array('job_id' => CRM_Core_DAO::getFieldValue($jobCLassName, $mail->id, 'id', 'mailing_id'), 'contact_id' => $emails['email']['contact_id'], 'email_id' => $emails['email']['id']);
$eventQueue = CRM_Mailing_Event_BAO_Queue::create($params);
$mandrillHeader = implode(CRM_Core_Config::singleton()->verpSeparator, array($mandrillHeader, 'm', $params['job_id'], $eventQueue->id, $eventQueue->hash));
}
}
开发者ID:vakeesan26,项目名称:biz.jmaconsulting.mte,代码行数:19,代码来源:mte.php
示例16: setDefaultValues
/**
* This function sets the default values for the form.
* the default values are retrieved from the database
*
* @access public
* @return None
*/
function setDefaultValues()
{
$mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, false, null);
//need to differentiate new/reuse mailing, CRM-2873
$reuseMailing = false;
if ($mailingID) {
$reuseMailing = true;
} else {
$mailingID = $this->_mailingID;
}
$count = $this->get('count');
$this->assign('count', $count);
$this->set('skipTextFile', false);
$this->set('skipHtmlFile', false);
$defaults = array();
$htmlMessage = null;
if ($mailingID) {
require_once 'CRM/Mailing/DAO/Mailing.php';
$dao = new CRM_Mailing_DAO_Mailing();
$dao->id = $mailingID;
$dao->find(true);
$dao->storeValues($dao, $defaults);
//we don't want to retrieve template details once it is
//set in session
$templateId = $this->get('template');
$this->assign('templateSelected', $templateId ? $templateId : 0);
if (isset($defaults['msg_template_id']) && !$templateId) {
$defaults['template'] = $defaults['msg_template_id'];
$messageTemplate = new CRM_Core_DAO_MessageTemplates();
$messageTemplate->id = $defaults['msg_template_id'];
$messageTemplate->selectAdd();
$messageTemplate->selectAdd('msg_text, msg_html');
$messageTemplate->find(true);
$defaults['text_message'] = $messageTemplate->msg_text;
$htmlMessage = $messageTemplate->msg_html;
}
if (isset($defaults['body_text'])) {
$defaults['text_message'] = $defaults['body_text'];
$this->set('textFile', $defaults['body_text']);
$this->set('skipTextFile', true);
}
if (isset($defaults['body_html'])) {
$htmlMessage = $defaults['body_html'];
$this->set('htmlFile', $defaults['body_html']);
$this->set('skipHtmlFile', true);
}
//set default from email address.
require_once 'CRM/Core/OptionGroup.php';
if (CRM_Utils_Array::value('from_name', $defaults) && CRM_Utils_Array::value('from_email', $defaults)) {
$defaults['from_email_address'] = array_search('"' . $defaults['from_name'] . '" <' . $defaults['from_email'] . '>', CRM_Core_OptionGroup::values('from_email_address'));
} else {
//get the default from email address.
$defaultAddress = CRM_Core_OptionGroup::values('from_email_address', null, null, null, ' AND is_default = 1');
foreach ($defaultAddress as $id => $value) {
$defaults['from_email_address'] = $id;
}
}
}
//fix for CRM-2873
if (!$reuseMailing) {
$textFilePath = $this->get('textFilePath');
if ($textFilePath && file_exists($textFilePath)) {
$defaults['text_message'] = file_get_contents($textFilePath);
if (strlen($defaults['text_message']) > 0) {
$this->set('skipTextFile', true);
}
}
$htmlFilePath = $this->get('htmlFilePath');
if ($htmlFilePath && file_exists($htmlFilePath)) {
$defaults['html_message'] = file_get_contents($htmlFilePath);
if (strlen($defaults['html_message']) > 0) {
$htmlMessage = $defaults['html_message'];
$this->set('skipHtmlFile', true);
}
}
}
if ($this->get('html_message')) {
$htmlMessage = $this->get('html_message');
}
$htmlMessage = str_replace(array("\n", "\r"), ' ', $htmlMessage);
$htmlMessage = str_replace("'", "\\'", $htmlMessage);
$this->assign('message_html', $htmlMessage);
$defaults['upload_type'] = 1;
if (isset($defaults['body_html'])) {
$defaults['html_message'] = $defaults['body_html'];
}
//CRM-4678 setdefault to default component when composing new mailing.
if (!$reuseMailing) {
$componentFields = array('header_id' => 'Header', 'footer_id' => 'Footer');
foreach ($componentFields as $componentVar => $componentType) {
$defaults[$componentVar] = CRM_Mailing_PseudoConstant::defaultComponent($componentType, '');
}
}
//.........这里部分代码省略.........
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Upload.php
示例17: runJobs_pre
public static function runJobs_pre($offset = 200)
{
$job = new CRM_Mailing_BAO_Job();
$config = CRM_Core_Config::singleton();
$jobTable = CRM_Mailing_DAO_Job::getTableName();
$mailingTable = CRM_Mailing_DAO_Mailing::getTableName();
$currentTime = date('YmdHis');
$mailingACL = CRM_Mailing_BAO_Mailing::mailingACL('m');
// add an additional check and only process
// jobs that are approved
$workflowClause = null;
require_once 'CRM/Mailing/Info.php';
if (CRM_Mailing_Info::workflowEnabled()) {
require_once 'CRM/Core/OptionGroup.php';
$approveOptionID = CRM_Core_OptionGroup::getValue('mail_approval_status', 'Approved', 'name');
if ($approveOptionID) {
$workflowClause = " AND m.approval_status_id = {$approveOptionID} ";
}
}
// Select all the mailing jobs that are created from
// when the mailing is submitted or scheduled.
$query = "\n\t\tSELECT j.*\n\t\t FROM {$jobTable} j,\n\t\t\t\t {$mailingTable} m\n\t\t WHERE m.id = j.mailing_id\n {$workflowClause}\n\t\t AND j.is_test = 0\n\t\t AND ( ( j.start_date IS null\n\t\t AND j.scheduled_date <= {$currentTime}\n\t\t AND j.status = 'Scheduled'\n\t\t AND j.end_date IS null ) )\n\t\t AND ((j.job_type is NULL) OR (j.job_type <> 'child'))\n\t\tORDER BY j.scheduled_date,\n\t\t\t\t j.start_date";
$job->query($query);
require_once 'CRM/Core/Lock.php';
// For reach of the "Parent Jobs" we find, we split them into
// X Number of child jobs
while ($job->fetch()) {
// still use job level lock for each child job
$lockName = "civimail.job.{$job->id}";
$lock = new CRM_Core_Lock($lockName);
if (!$lock->isAcquired()) {
continue;
}
// refetch the job status in case things
// changed between the first query and now
// avoid race conditions
$job->status = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Job', $job->id, 'status');
if ($job->status != 'Scheduled') {
$lock->release();
continue;
}
$job->split_job($offset);
// update the status of the parent job
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
$saveJob = new CRM_Mailing_DAO_Job();
$saveJob->id = $job->id;
$saveJob->start_date = date('YmdHis');
$saveJob->status = 'Running';
$saveJob->save();
$transaction->commit();
// Release the job lock
$lock->release();
}
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:55,代码来源:Job.php
示例18: getWorkflowFieldPerms
/**
* Get a list of permissions required for CRUD'ing each field
* (when workflow is enabled).
*
* @return array
* Array (string $fieldName => string $permName)
*/
public static function getWorkflowFieldPerms()
{
$fieldNames = array_keys(CRM_Mailing_DAO_Mailing::fields());
$fieldPerms = array();
foreach ($fieldNames as $fieldName) {
if ($fieldName == 'id') {
$fieldPerms[$fieldName] = array(array('access CiviMail', 'schedule mailings', 'approve mailings', 'create mailings'));
} elseif (in_array($fieldName, array('scheduled_date', 'scheduled_id'))) {
$fieldPerms[$fieldName] = array(array('access CiviMail', 'schedule mailings'));
} elseif (in_array($fieldName, array('approval_date', 'approver_id', 'approval_status_id', 'approval_note'))) {
$fieldPerms[$fieldName] = array(array('access CiviMail', 'approve mailings'));
} else {
$fieldPerms[$fieldName] = array(array('access CiviMail', 'create mailings'));
}
}
return $fieldPerms;
}
开发者ID:scardinius,项目名称:civicrm-core-api-mailing,代码行数:24,代码来源:Mailing.php
示例19: setDefaultValues
/**
* Set default values for the form.
* the default values are retrieved from the database
*
*
* @return void
*/
public function setDefaultValues()
{
$continue = CRM_Utils_Request::retrieve('continue', 'String', $this, FALSE, NULL);
$defaults = array();
$defaults['dedupe_email'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'dedupe_email_default', NULL, FALSE);
if ($this->_mailingID) {
// check that the user has permission to access mailing id
CRM_Mailing_BAO_Mailing::checkPermission($this->_mailingID);
$mailing = new CRM_Mailing_DAO_Mailing();
$mailing->id = $this->_mailingID;
$mailing->addSelect('name', 'campaign_id');
$mailing->find(TRUE);
$defaults['name'] = $mailing->name;
if (!$continue) {
$defaults['name'] = ts('Copy of %1', array(1 => $mailing->name));
} else {
// CRM-7590, reuse same mailing ID if we are continuing
$this->set('mailing_id', $this->_mailingID);
}
$defaults['campaign_id'] = $mailing->campaign_id;
$defaults['dedupe_email'] = $mailing->dedupe_email;
$defaults['location_type_id'] = $mailing->location_type_id;
$defaults['email_selection_method'] = $mailing->email_selection_method;
$dao = new CRM_Mailing_DAO_MailingGroup();
$mailingGroups = array('civicrm_group' => array(), 'civicrm_mailing' => array());
$dao->m
|
请发表评论