3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
36 require_once '../civicrm.config.php';
38 require_once 'CRM/Core/Config.php';
39 require_once 'CRM/Core/Error.php';
40 require_once 'CRM/Core/I18n.php';
42 require_once 'CRM/Mailing/BAO/Mailing.php';
43 require_once 'CRM/Mailing/BAO/Job.php';
44 require_once 'CRM/Mailing/DAO/Group.php';
46 $config = CRM_Core_Config
::singleton();
49 'civicrm_mailing_event_delivered',
50 'civicrm_mailing_event_queue',
51 'civicrm_mailing_job',
52 'civicrm_mailing_group',
55 foreach ($tables as $t) {
56 $query = "DELETE FROM $t";
57 CRM_Core_DAO
::executeQuery($query, CRM_Core_DAO
::$_nullArray);
60 $prefix = 'Automated Mailing Gen: ';
63 $status = array('Scheduled', 'Running', 'Complete', 'Paused', 'Canceled', 'Testing');
65 for ($i = 1; $i <= $numGroups; $i++
) {
66 $mailing = new CRM_Mailing_BAO_Mailing();
68 $alphabet = mt_rand(97, 122);
70 $cnt = sprintf('%05d', $i);
71 $mailing->name
= chr($alphabet) . ": $prefix $cnt";
72 $mailing->header_id
= $mailing->footer_id
= $mailing->reply_id
= $mailing->unsubscribe_id
= $mailing->optout_id
= 1;
73 $mailing->is_completed
= 1;
76 $job = new CRM_Mailing_BAO_MailingJob();
77 $job->mailing_id
= $mailing->id
;
78 $job->scheduled_date
= generateRandomDate();
79 $job->start_date
= generateRandomDate();
80 $job->end_date
= generateRandomDate();
81 $job->status
= 'Complete';
84 $group = new CRM_Mailing_DAO_MailingGroup();
85 $group->mailing_id
= $mailing->id
;
86 $group->group_type
= 'Include';
87 $group->entity_table
= 'civicrm_group';
88 $group->entity_id
= 1;
95 function generateRandomDate() {
96 $year = 2006 +
mt_rand(0, 2);
97 $month = 1 +
mt_rand(0, 11);
98 $day = 1 +
mt_rand(0, 27);
100 $date = sprintf("%4d%02d%02d", $year, $month, $day) . '000000';