本文整理匯總了PHP中CRM_Mailing_BAO_Mailing::reset方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Mailing_BAO_Mailing::reset方法的具體用法?PHP CRM_Mailing_BAO_Mailing::reset怎麽用?PHP CRM_Mailing_BAO_Mailing::reset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CRM_Mailing_BAO_Mailing
的用法示例。
在下文中一共展示了CRM_Mailing_BAO_Mailing::reset方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: runJobs_post
/**
* post process to determine if the parent job.
* as well as the mailing is complete after the run
* @param null $mode
*/
public static function runJobs_post($mode = NULL)
{
$job = new CRM_Mailing_BAO_MailingJob();
$mailing = new CRM_Mailing_BAO_Mailing();
$config = CRM_Core_Config::singleton();
$jobTable = CRM_Mailing_DAO_MailingJob::getTableName();
$mailingTable = CRM_Mailing_DAO_Mailing::getTableName();
$currentTime = date('YmdHis');
$mailingACL = CRM_Mailing_BAO_Mailing::mailingACL('m');
$domainID = CRM_Core_Config::domainID();
$query = "\n SELECT j.*\n FROM {$jobTable} j,\n {$mailingTable} m\n WHERE m.id = j.mailing_id AND m.domain_id = {$domainID}\n AND j.is_test = 0\n AND j.scheduled_date <= {$currentTime}\n AND j.status = 'Running'\n AND j.end_date IS null\n AND (j.job_type != 'child' OR j.job_type is NULL)\n ORDER BY j.scheduled_date,\n j.start_date";
$job->query($query);
// For each parent job that is running, let's look at their child jobs
while ($job->fetch()) {
$child_job = new CRM_Mailing_BAO_MailingJob();
$child_job_sql = "\n SELECT count(j.id)\n FROM civicrm_mailing_job j, civicrm_mailing m\n WHERE m.id = j.mailing_id\n AND j.job_type = 'child'\n AND j.parent_id = %1\n AND j.status <> 'Complete'";
$params = array(1 => array($job->id, 'Integer'));
$anyChildLeft = CRM_Core_DAO::singleValueQuery($child_job_sql, $params);
// all of the child jobs are complete, update
// the parent job as well as the mailing status
if (!$anyChildLeft) {
$transaction = new CRM_Core_Transaction();
$saveJob = new CRM_Mailing_DAO_MailingJob();
$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();
}
}
}