/** * adds $value['foo_display'] for each $value['foo'] enum from civicrm_mailing_job * * @param array $values (reference) the array up for enhancing * @return void */ static function addDisplayEnums(&$values) { $enumFields =& CRM_Mailing_DAO_MailingJob::getEnums(); foreach ($enumFields as $enum) { if (isset($values[$enum])) { $values[$enum . '_display'] = CRM_Mailing_DAO_MailingJob::tsEnum($enum, $values[$enum]); } } }
/** * Split the parent job into n number of child job based on an offset. * If null or 0 , we create only one child job * @param int $offset */ public function split_job($offset = 200) { $recipient_count = CRM_Mailing_BAO_Recipients::mailingSize($this->mailing_id); $jobTable = CRM_Mailing_DAO_MailingJob::getTableName(); $dao = new CRM_Core_DAO(); $sql = "\nINSERT INTO civicrm_mailing_job\n(`mailing_id`, `scheduled_date`, `status`, `job_type`, `parent_id`, `job_offset`, `job_limit`)\nVALUES (%1, %2, %3, %4, %5, %6, %7)\n"; $params = array(1 => array($this->mailing_id, 'Integer'), 2 => array($this->scheduled_date, 'String'), 3 => array('Scheduled', 'String'), 4 => array('child', 'String'), 5 => array($this->id, 'Integer'), 6 => array(0, 'Integer'), 7 => array($recipient_count, 'Integer')); // create one child job if the mailing size is less than the offset // probably use a CRM_Mailing_DAO_MailingJob( ); if (empty($offset) || $recipient_count <= $offset) { CRM_Core_DAO::executeQuery($sql, $params); } else { // Creating 'child jobs' for ($i = 0; $i < $recipient_count; $i = $i + $offset) { $params[6][0] = $i; $params[7][0] = $offset; CRM_Core_DAO::executeQuery($sql, $params); } } }
/** * Returns the list of fields that can be exported * * @param bool $prefix * * @return array */ static function &export($prefix = false) { if (!self::$_export) { self::$_export = array(); $fields = self::fields(); foreach ($fields as $name => $field) { if (CRM_Utils_Array::value('export', $field)) { if ($prefix) { self::$_export['mailing_job'] =& $fields[$name]; } else { self::$_export[$name] =& $fields[$name]; } } } } return self::$_export; }