本文整理匯總了PHP中CRM_Mailing_BAO_Mailing::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Mailing_BAO_Mailing::save方法的具體用法?PHP CRM_Mailing_BAO_Mailing::save怎麽用?PHP CRM_Mailing_BAO_Mailing::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CRM_Mailing_BAO_Mailing
的用法示例。
在下文中一共展示了CRM_Mailing_BAO_Mailing::save方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: array
$tables = array('civicrm_mailing_event_delivered', 'civicrm_mailing_event_queue', 'civicrm_mailing_job', 'civicrm_mailing_group', 'civicrm_mailing');
foreach ($tables as $t) {
$query = "DELETE FROM {$t}";
CRM_Core_DAO::executeQuery($query);
}
$prefix = 'Automated Mailing Gen: ';
$numGroups = 153;
$status = array('Scheduled', 'Running', 'Complete', 'Paused', 'Canceled', 'Testing');
for ($i = 1; $i <= $numGroups; $i++) {
$mailing = new CRM_Mailing_BAO_Mailing();
$alphabet = mt_rand(97, 122);
$cnt = sprintf('%05d', $i);
$mailing->name = chr($alphabet) . ": {$prefix} {$cnt}";
$mailing->header_id = $mailing->footer_id = $mailing->reply_id = $mailing->unsubscribe_id = $mailing->optout_id = 1;
$mailing->is_completed = 1;
$mailing->save();
$job = new CRM_Mailing_BAO_MailingJob();
$job->mailing_id = $mailing->id;
$job->scheduled_date = generateRandomDate();
$job->start_date = generateRandomDate();
$job->end_date = generateRandomDate();
$job->status = 'Complete';
$job->save();
$group = new CRM_Mailing_DAO_MailingGroup();
$group->mailing_id = $mailing->id;
$group->group_type = 'Include';
$group->entity_table = 'civicrm_group';
$group->entity_id = 1;
$group->save();
}
/**
示例2: 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();
}
}
}
示例3: postProcess
/**
* Process the posted form values. Create and schedule a Mass SMS.
*
* @param
*
* @return void
* @access public
*/
public function postProcess()
{
$params = array();
$params['mailing_id'] = $ids['mailing_id'] = $this->_mailingID;
if (empty($params['mailing_id'])) {
CRM_Core_Error::fatal(ts('Could not find a mailing id'));
}
foreach (array('now', 'start_date', 'start_date_time') as $parameter) {
$params[$parameter] = $this->controller->exportValue($this->_name, $parameter);
}
$mailing = new CRM_Mailing_BAO_Mailing();
$mailing->id = $ids['mailing_id'];
if ($mailing->find(TRUE)) {
$job = new CRM_Mailing_BAO_Job();
$job->mailing_id = $mailing->id;
$job->is_test = 0;
if ($job->find(TRUE)) {
CRM_Core_Error::fatal(ts('A job for this mailing already exists'));
}
if (empty($mailing->is_template)) {
$job->status = 'Scheduled';
if ($params['now']) {
$job->scheduled_date = date('YmdHis');
} else {
$job->scheduled_date = CRM_Utils_Date::processDate($params['start_date'] . ' ' . $params['start_date_time']);
}
$job->save();
}
// also set the scheduled_id
$session = CRM_Core_Session::singleton();
$mailing->scheduled_id = $session->get('userID');
$mailing->scheduled_date = date('YmdHis');
$mailing->created_date = CRM_Utils_Date::isoToMysql($mailing->created_date);
$mailing->save();
}
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url('civicrm/mailing/browse/scheduled', 'reset=1&scheduled=true&sms=1'));
}
示例4: postProcess
/**
* Process the posted form values. Create and schedule a mailing.
*
* @param
*
* @return void
* @access public
*/
public function postProcess()
{
$params = array();
$params['mailing_id'] = $ids['mailing_id'] = $this->_mailingID;
if (empty($params['mailing_id'])) {
CRM_Core_Error::fatal(ts('Could not find a mailing id'));
}
foreach (array('now', 'start_date', 'start_date_time') as $parameter) {
$params[$parameter] = $this->controller->exportValue($this->_name, $parameter);
}
$mailing = new CRM_Mailing_BAO_Mailing();
$mailing->id = $ids['mailing_id'];
if ($mailing->find(TRUE)) {
$job = new CRM_Mailing_BAO_Job();
$job->mailing_id = $mailing->id;
$job->is_test = 0;
if ($job->find(TRUE)) {
CRM_Core_Error::fatal(ts('A job for this mailing already exists'));
}
if (empty($mailing->is_template)) {
$job->status = 'Scheduled';
if ($params['now']) {
$job->scheduled_date = date('YmdHis');
} else {
$job->scheduled_date = CRM_Utils_Date::processDate($params['start_date'] . ' ' . $params['start_date_time']);
}
$job->save();
}
// set approval details if workflow is not enabled
if (!CRM_Mailing_Info::workflowEnabled()) {
$session = CRM_Core_Session::singleton();
$mailing->approver_id = $session->get('userID');
$mailing->approval_date = date('YmdHis');
$mailing->approval_status_id = 1;
} else {
// reset them in case this mailing was rejected
$mailing->approver_id = 'null';
$mailing->approval_date = 'null';
$mailing->approval_status_id = 'null';
}
if ($mailing->approval_date) {
$mailing->approval_date = CRM_Utils_Date::isoToMysql($mailing->approval_date);
}
// also set the scheduled_id
$session = CRM_Core_Session::singleton();
$mailing->scheduled_id = $session->get('userID');
$mailing->scheduled_date = date('YmdHis');
$mailing->created_date = CRM_Utils_Date::isoToMysql($mailing->created_date);
$mailing->save();
}
//when user perform mailing from search context
//redirect it to search result CRM-3711.
$ssID = $this->get('ssID');
if ($ssID && $this->_searchBasedMailing && !CRM_Mailing_Info::workflowEnabled()) {
if ($this->_action == CRM_Core_Action::BASIC) {
$fragment = 'search';
} elseif ($this->_action == CRM_Core_Action::PROFILE) {
$fragment = 'search/builder';
} elseif ($this->_action == CRM_Core_Action::ADVANCED) {
$fragment = 'search/advanced';
} else {
$fragment = 'search/custom';
}
$context = $this->get('context');
if (!CRM_Contact_Form_Search::isSearchContext($context)) {
$context = 'search';
}
$urlParams = "force=1&reset=1&ssID={$ssID}&context={$context}";
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
if (CRM_Utils_Rule::qfKey($qfKey)) {
$urlParams .= "&qfKey={$qfKey}";
}
$url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams);
return $this->controller->setDestination($url);
}
$session = CRM_Core_Session::singleton();
$session->pushUserContext(CRM_Utils_System::url('civicrm/mailing/browse/scheduled', 'reset=1&scheduled=true'));
}
示例5: postProcess
function postProcess()
{
$params = array();
$params['mailing_id'] = $ids['mailing_id'] = $this->_mailingID;
if (empty($params['mailing_id'])) {
CRM_Core_Error::fatal(ts('Could not find a mailing id'));
}
foreach (array('now', 'start_date', 'start_date_time') as $parameter) {
$params[$parameter] = $this->controller->exportValue($this->_name, $parameter);
}
$mailing = new CRM_Mailing_BAO_Mailing();
$mailing->id = $ids['mailing_id'];
if ($mailing->find(TRUE)) {
$job = new CRM_Mailing_BAO_MailingJob();
$job->mailing_id = $mailing->id;
$job->is_test = 0;
if ($job->find(TRUE)) {
CRM_Core_Error::fatal(ts('A job for this mailing already exists'));
}
if (empty($mailing->is_template)) {
$job->status = 'Scheduled';
if ($params['now']) {
$job->scheduled_date = date('YmdHis');
} else {
$job->scheduled_date = CRM_Utils_Date::processDate($params['start_date'] . ' ' . $params['start_date_time']);
}
$job->save();
}
// set approval details if workflow is not enabled
if (!CRM_Mailing_Info::workflowEnabled()) {
$session = CRM_Core_Session::singleton();
$mailing->approver_id = $session->get('userID');
$mailing->approval_date = date('YmdHis');
$mailing->approval_status_id = 1;
} else {
// reset them in case this mailing was rejected
$mailing->approver_id = 'null';
$mailing->approval_date = 'null';
$mailing->approval_status_id = 'null';
}
if ($mailing->approval_date) {
$mailing->approval_date = CRM_Utils_Date::isoToMysql($mailing->approval_date);
}
// also set the scheduled_id
$session = CRM_Core_Session::singleton();
$mailing->scheduled_id = $session->get('userID');
$mailing->scheduled_date = date('YmdHis');
$mailing->created_date = CRM_Utils_Date::isoToMysql($mailing->created_date);
$mailing->save();
}
$status = ts("Your mailing has been saved.");
CRM_Core_Session::setStatus($status);
$url = CRM_Utils_System::url('civicrm/view/quickbulkemail');
return $this->controller->setDestination($url);
}