Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
b7c0a88f | 2 | $options = getopt('bc:ht:'); |
3 | if (isset($options['h'])) { | |
6a488035 TO |
4 | print ("\nUsage: php civimail-spooler.php [-bh] [-c <config>] [-t <period>]\n"); |
5 | print (" -b Run this process continuously\n"); | |
6 | print (" -c Path to CiviCRM civicrm.settings.php\n"); | |
7 | print (" -h Print this help message\n"); | |
8 | print (" -t In continuous mode, the period (in seconds) to wait between queue events\n\n"); | |
9 | exit(); | |
10 | } | |
11 | ||
12 | if (isset($options['c'])) { | |
13 | $config_file = $options['c']; | |
14 | } | |
15 | ||
16 | eval(' | |
17 | require_once "$config_file"; | |
18 | require_once "CRM/Core/Config.php"; | |
19 | '); | |
20 | ||
f3a87cf4 | 21 | $config = CRM_Core_Config::singleton(); |
6a488035 TO |
22 | |
23 | /* Temporary permissioning hack for now */ | |
24 | ||
25 | ||
26 | CRM_Utils_System_Soap::swapUF(); | |
27 | ||
28 | if (isset($options['t']) && is_int($options['t']) && $options['t'] > 0) { | |
29 | $config->mailerPeriod = $options['t']; | |
30 | } | |
31 | ||
32 | if (isset($options['b'])) { | |
33 | while (TRUE) { | |
34 | /* TODO: put some syslog calls in here. Also, we may want to fork the | |
35 | * process into the background and provide init.d scripts */ | |
36 | ||
37 | ||
9da8dc8c | 38 | CRM_Mailing_BAO_MailingJob::runJobs(); |
6a488035 TO |
39 | sleep($config->mailerPeriod); |
40 | } | |
41 | } | |
42 | else { | |
9da8dc8c | 43 | CRM_Mailing_BAO_MailingJob::runJobs(); |
6a488035 TO |
44 | } |
45 |