当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Mailing_BAO_MailingJob::find方法代码示例

本文整理汇总了PHP中CRM_Mailing_BAO_MailingJob::find方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Mailing_BAO_MailingJob::find方法的具体用法?PHP CRM_Mailing_BAO_MailingJob::find怎么用?PHP CRM_Mailing_BAO_MailingJob::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Mailing_BAO_MailingJob的用法示例。


在下文中一共展示了CRM_Mailing_BAO_MailingJob::find方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create


//.........这里部分代码省略.........
     // WTH $ids
     if (empty($ids) && isset($params['id'])) {
         $ids['mailing_id'] = $ids['id'] = $params['id'];
     }
     // CRM-12430
     // Do the below only for an insert
     // for an update, we should not set the defaults
     if (!isset($ids['id']) && !isset($ids['mailing_id'])) {
         // Retrieve domain email and name for default sender
         $domain = civicrm_api('Domain', 'getsingle', array('version' => 3, 'current_domain' => 1, 'sequential' => 1));
         if (isset($domain['from_email'])) {
             $domain_email = $domain['from_email'];
             $domain_name = $domain['from_name'];
         } else {
             $domain_email = 'info@EXAMPLE.ORG';
             $domain_name = 'EXAMPLE.ORG';
         }
         if (!isset($params['created_id'])) {
             $session =& CRM_Core_Session::singleton();
             $params['created_id'] = $session->get('userID');
         }
         $defaults = array('override_verp' => TRUE, 'forward_replies' => FALSE, 'open_tracking' => TRUE, 'url_tracking' => TRUE, 'visibility' => 'Public Pages', 'replyto_email' => $domain_email, 'header_id' => CRM_Mailing_PseudoConstant::defaultComponent('header_id', ''), 'footer_id' => CRM_Mailing_PseudoConstant::defaultComponent('footer_id', ''), 'from_email' => $domain_email, 'from_name' => $domain_name, 'msg_template_id' => NULL, 'created_id' => $params['created_id'], 'approver_id' => NULL, 'auto_responder' => 0, 'created_date' => date('YmdHis'), 'scheduled_date' => NULL, 'approval_date' => NULL);
         // Get the default from email address, if not provided.
         if (empty($defaults['from_email'])) {
             $defaultAddress = CRM_Core_OptionGroup::values('from_email_address', NULL, NULL, NULL, ' AND is_default = 1');
             foreach ($defaultAddress as $id => $value) {
                 if (preg_match('/"(.*)" <(.*)>/', $value, $match)) {
                     $defaults['from_email'] = $match[2];
                     $defaults['from_name'] = $match[1];
                 }
             }
         }
         $params = array_merge($defaults, $params);
     }
     /**
      * Could check and warn for the following cases:
      *
      * - groups OR mailings should be populated.
      * - body html OR body text should be populated.
      */
     $transaction = new CRM_Core_Transaction();
     $mailing = self::add($params, $ids);
     if (is_a($mailing, 'CRM_Core_Error')) {
         $transaction->rollback();
         return $mailing;
     }
     // update mailings with hash values
     CRM_Contact_BAO_Contact_Utils::generateChecksum($mailing->id, NULL, NULL, NULL, 'mailing', 16);
     $groupTableName = CRM_Contact_BAO_Group::getTableName();
     $mailingTableName = CRM_Mailing_BAO_Mailing::getTableName();
     /* Create the mailing group record */
     $mg = new CRM_Mailing_DAO_MailingGroup();
     $groupTypes = array('include' => 'Include', 'exclude' => 'Exclude', 'base' => 'Base');
     foreach (array('groups', 'mailings') as $entity) {
         foreach (array('include', 'exclude', 'base') as $type) {
             if (isset($params[$entity][$type])) {
                 self::replaceGroups($mailing->id, $groupTypes[$type], $entity, $params[$entity][$type]);
             }
         }
     }
     if (!empty($params['search_id']) && !empty($params['group_id'])) {
         $mg->reset();
         $mg->mailing_id = $mailing->id;
         $mg->entity_table = $groupTableName;
         $mg->entity_id = $params['group_id'];
         $mg->search_id = $params['search_id'];
         $mg->search_args = $params['search_args'];
         $mg->group_type = 'Include';
         $mg->save();
     }
     // check and attach and files as needed
     CRM_Core_BAO_File::processAttachment($params, 'civicrm_mailing', $mailing->id);
     // If we're going to autosend, then check validity before saving.
     if (!empty($params['scheduled_date']) && $params['scheduled_date'] != 'null' && !empty($params['_evil_bao_validator_'])) {
         $cb = Civi\Core\Resolver::singleton()->get($params['_evil_bao_validator_']);
         $errors = call_user_func($cb, $mailing);
         if (!empty($errors)) {
             $fields = implode(',', array_keys($errors));
             throw new CRM_Core_Exception("Mailing cannot be sent. There are missing or invalid fields ({$fields}).", 'cannot-send', $errors);
         }
     }
     $transaction->commit();
     // Create parent job if not yet created.
     // Condition on the existence of a scheduled date.
     if (!empty($params['scheduled_date']) && $params['scheduled_date'] != 'null' && empty($params['_skip_evil_bao_auto_schedule_'])) {
         $job = new CRM_Mailing_BAO_MailingJob();
         $job->mailing_id = $mailing->id;
         $job->status = 'Scheduled';
         $job->is_test = 0;
         if (!$job->find(TRUE)) {
             $job->scheduled_date = $params['scheduled_date'];
             $job->save();
         }
         // Populate the recipients.
         if (empty($params['_skip_evil_bao_auto_recipients_'])) {
             self::getRecipients($job->id, $mailing->id, TRUE, $mailing->dedupe_email);
         }
     }
     return $mailing;
 }
开发者ID:scardinius,项目名称:civicrm-core-api-mailing,代码行数:101,代码来源:Mailing.php

示例2: create

 /**
  * Construct a new mailing object, along with job and mailing_group
  * objects, from the form values of the create mailing wizard.
  *
  * @params array $params        Form values
  *
  * @return object $mailing      The new mailing object
  * @access public
  * @static
  */
 public static function create(&$params, $ids = array())
 {
     // CRM-12430
     // Do the below only for an insert
     // for an update, we should not set the defaults
     if (!isset($ids['id']) && !isset($ids['mailing_id'])) {
         // Retrieve domain email and name for default sender
         $domain = civicrm_api('Domain', 'getsingle', array('version' => 3, 'current_domain' => 1, 'sequential' => 1));
         if (isset($domain['from_email'])) {
             $domain_email = $domain['from_email'];
             $domain_name = $domain['from_name'];
         } else {
             $domain_email = 'info@EXAMPLE.ORG';
             $domain_name = 'EXAMPLE.ORG';
         }
         if (!isset($params['created_id'])) {
             $session =& CRM_Core_Session::singleton();
             $params['created_id'] = $session->get('userID');
         }
         $defaults = array('override_verp' => TRUE, 'forward_replies' => FALSE, 'open_tracking' => TRUE, 'url_tracking' => TRUE, 'visibility' => 'User and User Admin Only', 'replyto_email' => $domain_email, 'header_id' => CRM_Mailing_PseudoConstant::defaultComponent('header_id', ''), 'footer_id' => CRM_Mailing_PseudoConstant::defaultComponent('footer_id', ''), 'from_email' => $domain_email, 'from_name' => $domain_name, 'msg_template_id' => NULL, 'created_id' => $params['created_id'], 'approver_id' => NULL, 'auto_responder' => 0, 'created_date' => date('YmdHis'), 'scheduled_date' => NULL, 'approval_date' => NULL);
         // Get the default from email address, if not provided.
         if (empty($defaults['from_email'])) {
             $defaultAddress = CRM_Core_OptionGroup::values('from_email_address', NULL, NULL, NULL, ' AND is_default = 1');
             foreach ($defaultAddress as $id => $value) {
                 if (preg_match('/"(.*)" <(.*)>/', $value, $match)) {
                     $defaults['from_email'] = $match[2];
                     $defaults['from_name'] = $match[1];
                 }
             }
         }
         $params = array_merge($defaults, $params);
     }
     /**
      * Could check and warn for the following cases:
      *
      * - groups OR mailings should be populated.
      * - body html OR body text should be populated.
      */
     $transaction = new CRM_Core_Transaction();
     $mailing = self::add($params, $ids);
     if (is_a($mailing, 'CRM_Core_Error')) {
         $transaction->rollback();
         return $mailing;
     }
     $groupTableName = CRM_Contact_BAO_Group::getTableName();
     $mailingTableName = CRM_Mailing_BAO_Mailing::getTableName();
     /* Create the mailing group record */
     $mg = new CRM_Mailing_DAO_MailingGroup();
     foreach (array('groups', 'mailings') as $entity) {
         foreach (array('include', 'exclude', 'base') as $type) {
             if (isset($params[$entity]) && CRM_Utils_Array::value($type, $params[$entity]) && is_array($params[$entity][$type])) {
                 foreach ($params[$entity][$type] as $entityId) {
                     $mg->reset();
                     $mg->mailing_id = $mailing->id;
                     $mg->entity_table = $entity == 'groups' ? $groupTableName : $mailingTableName;
                     $mg->entity_id = $entityId;
                     $mg->group_type = $type;
                     $mg->save();
                 }
             }
         }
     }
     if (!empty($params['search_id']) && !empty($params['group_id'])) {
         $mg->reset();
         $mg->mailing_id = $mailing->id;
         $mg->entity_table = $groupTableName;
         $mg->entity_id = $params['group_id'];
         $mg->search_id = $params['search_id'];
         $mg->search_args = $params['search_args'];
         $mg->group_type = 'Include';
         $mg->save();
     }
     // check and attach and files as needed
     CRM_Core_BAO_File::processAttachment($params, 'civicrm_mailing', $mailing->id);
     $transaction->commit();
     /**
      * create parent job if not yet created
      * condition on the existence of a scheduled date
      */
     if (!empty($params['scheduled_date']) && $params['scheduled_date'] != 'null') {
         $job = new CRM_Mailing_BAO_MailingJob();
         $job->mailing_id = $mailing->id;
         $job->status = 'Scheduled';
         $job->is_test = 0;
         if (!$job->find(TRUE)) {
             $job->scheduled_date = $params['scheduled_date'];
             $job->save();
         }
         // Populate the recipients.
         $mailing->getRecipients($job->id, $mailing->id, NULL, NULL, TRUE, FALSE);
//.........这里部分代码省略.........
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:101,代码来源:Mailing.php

示例3: getMailingJobs

 private static function getMailingJobs($params)
 {
     if (is_array(static::$jobs)) {
         return static::$jobs;
     }
     static::$jobs = array();
     if (empty($params['crm_mailing_id'])) {
         return static::$jobs;
     }
     $jobBao = new CRM_Mailing_BAO_MailingJob();
     // This needs to be done as there can only be one query per DAO (see docs for reset()) - without this, the DAO
     // object was keeping residual data from previous operations elsewhere on the same DAO, making the below operations
     // unpredictable and fail
     $jobBao->reset();
     // This is needed as the reset() above clears the query completely
     $jobBao->selectAdd('*');
     $jobBao->mailing_id = $params['crm_mailing_id'];
     $jobBao->is_test = 0;
     if ($jobBao->find()) {
         while ($jobBao->fetch()) {
             static::$jobs[] = $jobBao->toArray();
         }
     }
     $jobBao->free();
     return static::$jobs;
 }
开发者ID:jaapjansma,项目名称:uk.co.compucorp.civicrm.simplemail,代码行数:26,代码来源:SimpleMail.php

示例4: 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);
 }
开发者ID:krishgopi,项目名称:uk.co.vedaconsulting.quickbulkemail,代码行数:55,代码来源:QuickBulkEmailSchedule.php


注:本文中的CRM_Mailing_BAO_MailingJob::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。