3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
20 require_once '../civicrm.config.php';
22 require_once 'CRM/Core/Config.php';
23 require_once 'CRM/Core/Error.php';
24 require_once 'CRM/Core/I18n.php';
26 require_once 'CRM/Mailing/BAO/Mailing.php';
27 require_once 'CRM/Mailing/BAO/Job.php';
28 require_once 'CRM/Mailing/DAO/Group.php';
30 $config = CRM_Core_Config
::singleton();
33 'civicrm_mailing_event_delivered',
34 'civicrm_mailing_event_queue',
35 'civicrm_mailing_job',
36 'civicrm_mailing_group',
39 foreach ($tables as $t) {
40 $query = "DELETE FROM $t";
41 CRM_Core_DAO
::executeQuery($query);
44 $prefix = 'Automated Mailing Gen: ';
47 $status = array('Scheduled', 'Running', 'Complete', 'Paused', 'Canceled', 'Testing');
49 for ($i = 1; $i <= $numGroups; $i++
) {
50 $mailing = new CRM_Mailing_BAO_Mailing();
52 $alphabet = mt_rand(97, 122);
54 $cnt = sprintf('%05d', $i);
55 $mailing->name
= chr($alphabet) . ": $prefix $cnt";
56 $mailing->header_id
= $mailing->footer_id
= $mailing->reply_id
= $mailing->unsubscribe_id
= $mailing->optout_id
= 1;
57 $mailing->is_completed
= 1;
60 $job = new CRM_Mailing_BAO_MailingJob();
61 $job->mailing_id
= $mailing->id
;
62 $job->scheduled_date
= generateRandomDate();
63 $job->start_date
= generateRandomDate();
64 $job->end_date
= generateRandomDate();
65 $job->status
= 'Complete';
68 $group = new CRM_Mailing_DAO_MailingGroup();
69 $group->mailing_id
= $mailing->id
;
70 $group->group_type
= 'Include';
71 $group->entity_table
= 'civicrm_group';
72 $group->entity_id
= 1;
79 function generateRandomDate() {
80 $year = 2006 +
mt_rand(0, 2);
81 $month = 1 +
mt_rand(0, 11);
82 $day = 1 +
mt_rand(0, 27);
84 $date = sprintf("%4d%02d%02d", $year, $month, $day) . '000000';