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
18 require_once '../civicrm.config.php';
20 require_once 'CRM/Core/Config.php';
21 require_once 'CRM/Core/Error.php';
22 require_once 'CRM/Core/I18n.php';
24 require_once 'CRM/Mailing/BAO/Mailing.php';
25 require_once 'CRM/Mailing/BAO/Job.php';
26 require_once 'CRM/Mailing/DAO/Group.php';
28 $config = CRM_Core_Config
::singleton();
31 'civicrm_mailing_event_delivered',
32 'civicrm_mailing_event_queue',
33 'civicrm_mailing_job',
34 'civicrm_mailing_group',
37 foreach ($tables as $t) {
38 $query = "DELETE FROM $t";
39 CRM_Core_DAO
::executeQuery($query);
42 $prefix = 'Automated Mailing Gen: ';
45 $status = array('Scheduled', 'Running', 'Complete', 'Paused', 'Canceled', 'Testing');
47 for ($i = 1; $i <= $numGroups; $i++
) {
48 $mailing = new CRM_Mailing_BAO_Mailing();
50 $alphabet = mt_rand(97, 122);
52 $cnt = sprintf('%05d', $i);
53 $mailing->name
= chr($alphabet) . ": $prefix $cnt";
54 $mailing->header_id
= $mailing->footer_id
= $mailing->reply_id
= $mailing->unsubscribe_id
= $mailing->optout_id
= 1;
55 $mailing->is_completed
= 1;
58 $job = new CRM_Mailing_BAO_MailingJob();
59 $job->mailing_id
= $mailing->id
;
60 $job->scheduled_date
= generateRandomDate();
61 $job->start_date
= generateRandomDate();
62 $job->end_date
= generateRandomDate();
63 $job->status
= 'Complete';
66 $group = new CRM_Mailing_DAO_MailingGroup();
67 $group->mailing_id
= $mailing->id
;
68 $group->group_type
= 'Include';
69 $group->entity_table
= 'civicrm_group';
70 $group->entity_id
= 1;
77 function generateRandomDate() {
78 $year = 2006 +
mt_rand(0, 2);
79 $month = 1 +
mt_rand(0, 11);
80 $day = 1 +
mt_rand(0, 27);
82 $date = sprintf("%4d%02d%02d", $year, $month, $day) . '000000';