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