Commit e1750131 authored by sampaioprimo's avatar sampaioprimo

adjustments to be able to call tiki-batch_send_newsletter.php and...

adjustments to be able to call tiki-batch_send_newsletter.php and tiki-user_reports_send.php remotely using token access
parent ffb44128
......@@ -203,8 +203,8 @@ class AuthTokensTest extends TikiDatabaseTestCase
function testGetTokens_shouldReturnAllTokens()
{
$token1 = '823bde97a717c55b2cfbf9fbd6c81816';
$token2 = '91bba2f998b48fce0146016809886127';
$token1 = '91bba2f998b48fce0146016809886127';
$token2 = '823bde97a717c55b2cfbf9fbd6c81816';
$token3 = 'e2990f7983b7b6c46b3987536aa38d32';
$tokens = $this->obj->getTokens();
......
......@@ -4,30 +4,41 @@
// 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$
if (empty($argv)) { // can only be used in a cron or line command
return;
}
include('tiki-setup.php');
require_once('lib/core/Request.php');
$access->check_feature('feature_newsletters');
$access->check_permission('tiki_p_send_newsletters');
if (php_sapi_name() != 'cli') {
$access->check_permission('tiki_p_send_newsletters');
}
global $nllib; include_once('lib/newsletters/nllib.php');
function display_usage() {
echo 'Usage: php tiki-batch_send_newsletter.php <editionId>';
$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);
if (empty($argv[1])) {
$request = new Request();
$editionId = $request->getProperty('editionId');
if (empty($editionId)) {
display_usage();
}
$editionId = $argv[1];
if (!($edition_info = $nllib->get_edition($editionId))) {
echo "Incorrect editionId; $editionId";
echo "Incorrect editionId: $editionId";
die;
}
if (!($nl_info = $nllib->get_newsletter($edition_info['nlId']))) {
......
......@@ -7,8 +7,8 @@
include_once ('tiki-setup.php');
if ( '127.0.0.1' != $tikilib->get_ip_address() ) {
die(tr('This script can only be called by the server!'));
if (php_sapi_name() != 'cli') {
$access->check_permission('tiki_p_admin');
}
if ($prefs['feature_daily_report_watches'] != 'y') {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment