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
17 if (!(php_sapi_name() == 'cli' ||
(is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0))) {
18 header("HTTP/1.0 404 Not Found");
23 require_once '../civicrm.config.php';
25 require_once 'CRM/Core/Config.php';
26 require_once 'CRM/Core/Error.php';
27 require_once 'CRM/Core/I18n.php';
29 require_once 'CRM/Mailing/BAO/Mailing.php';
30 require_once 'CRM/Mailing/BAO/Job.php';
31 require_once 'CRM/Mailing/DAO/Group.php';
33 $config = CRM_Core_Config
::singleton();
36 'civicrm_mailing_event_delivered',
37 'civicrm_mailing_event_queue',
38 'civicrm_mailing_job',
39 'civicrm_mailing_group',
42 foreach ($tables as $t) {
43 $query = "DELETE FROM $t";
44 CRM_Core_DAO
::executeQuery($query);
47 $prefix = 'Automated Mailing Gen: ';
50 $status = array('Scheduled', 'Running', 'Complete', 'Paused', 'Canceled', 'Testing');
52 for ($i = 1; $i <= $numGroups; $i++
) {
53 $mailing = new CRM_Mailing_BAO_Mailing();
55 $alphabet = mt_rand(97, 122);
57 $cnt = sprintf('%05d', $i);
58 $mailing->name
= chr($alphabet) . ": $prefix $cnt";
59 $mailing->header_id
= $mailing->footer_id
= $mailing->reply_id
= $mailing->unsubscribe_id
= $mailing->optout_id
= 1;
60 $mailing->is_completed
= 1;
63 $job = new CRM_Mailing_BAO_MailingJob();
64 $job->mailing_id
= $mailing->id
;
65 $job->scheduled_date
= generateRandomDate();
66 $job->start_date
= generateRandomDate();
67 $job->end_date
= generateRandomDate();
68 $job->status
= 'Complete';
71 $group = new CRM_Mailing_DAO_MailingGroup();
72 $group->mailing_id
= $mailing->id
;
73 $group->group_type
= 'Include';
74 $group->entity_table
= 'civicrm_group';
75 $group->entity_id
= 1;
82 function generateRandomDate() {
83 $year = 2006 +
mt_rand(0, 2);
84 $month = 1 +
mt_rand(0, 11);
85 $day = 1 +
mt_rand(0, 27);
87 $date = sprintf("%4d%02d%02d", $year, $month, $day) . '000000';