/
tiki-batch_send_newsletter.php
66 lines (56 loc) · 1.58 KB
/
tiki-batch_send_newsletter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* @package tikiwiki
*/
// (c) Copyright 2002-2013 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id: tiki-batch_send_newsletter.php 44849 2013-02-08 18:41:20Z lphuberdeau $
include('tiki-setup.php');
$access->check_feature('feature_newsletters');
if (php_sapi_name() != 'cli') {
$access->check_permission('tiki_p_send_newsletters');
}
global $nllib; include_once('lib/newsletters/nllib.php');
function display_usage()
{
$helpMsg = "\nUsage: php tiki-batch_send_newsletter.php editionId=X\n"
. "Usage: http://path_to_tiki/tiki-batch_send_newsletter.php?editionId=X\n";
if (php_sapi_name() == 'cli') {
echo $helpMsg;
} else {
echo nl2br($helpMsg);
}
die;
}
error_reporting(E_ALL);
$request = new Tiki_Request();
$editionId = $request->getProperty('editionId');
if (empty($editionId)) {
display_usage();
}
if (!($edition_info = $nllib->get_edition($editionId))) {
echo "Incorrect editionId: $editionId";
die;
}
if (!($nl_info = $nllib->get_newsletter($edition_info['nlId']))) {
echo 'Incorrect nlId: '.$edition_info['nlId'];
}
$edition_info['editionId'] = 0;
$sent = $errors = array();
$logFileName = '';
$edition_info['begin'] = 'y';
$nllib->send($nl_info, $edition_info, false, $sent, $errors, $logFileName);
if (!empty($errors)) {
echo "Errors\n";
foreach ($errors as $error) {
echo $error."\n";
}
die;
}
echo "Sent to\n";
foreach ($sent as $s) {
echo $s."\n";
}
echo "Log: $logFileName\n";