Skip to content
Snippets Groups Projects
Commit c820f3b7 authored by Patrick Barroca's avatar Patrick Barroca 😁
Browse files

Merge branch 'hotline_#16538_issue_with_biblio_records_url_in_newsletters' into 'hotline_6.54'

Hotline #16538 issue with biblio records url in newsletters

See merge request !473
parents f7df43c4 7c7aeea4
4 merge requests!529Hotline 6.56,!512Master,!484Master,!483Hotline 6.54
- ticket #16538: correction des urls des notices dans une newsletter
\ No newline at end of file
...@@ -16,14 +16,14 @@ ...@@ -16,14 +16,14 @@
* *
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with AFI-OPAC 2.0; if not, write to the Free Software * along with AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
class Class_Batch_SendNewsletters extends Class_Batch_Abstract { class Class_Batch_SendNewsletters extends Class_Batch_Abstract {
protected $_newsletter; protected $_newsletter;
public function __construct($newsletter) { public function __construct($newsletter) {
$this->_newsletter = $newsletter; $this->_newsletter = $newsletter;
...@@ -36,9 +36,23 @@ class Class_Batch_SendNewsletters extends Class_Batch_Abstract { ...@@ -36,9 +36,23 @@ class Class_Batch_SendNewsletters extends Class_Batch_Abstract {
} }
public function getExecParamsAsArray() {
return [$_SERVER['HTTP_HOST'],
$_SERVER['SERVER_NAME'],
BASE_URL,
$this->_newsletter->getId()];
}
public function getExecParams() {
return '"' . implode('" "', $this->getExecParamsAsArray()) . '"';
}
public function run() { public function run() {
exec("/usr/bin/php -f ".realpath(dirname(__FILE__))."/../../../scripts/sendNewsletter.php " exec("/usr/bin/php -f ".realpath(dirname(__FILE__))."/../../../scripts/sendNewsletter.php "
.$this->_newsletter->getId().' "'.$_SERVER['HTTP_HOST'].'"'." > /dev/null &"); .$this->getExecParams()
." > /dev/null &");
return $this; return $this;
} }
} }
......
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
* *
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with AFI-OPAC 2.0; if not, write to the Free Software * along with AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
define("BASE_URL", "/"); define("BASE_URL", $argv[3]);
$_SERVER['SERVER_NAME'] = $argv[2];
$_SERVER['HTTP_HOST'] = $argv[1];
set_include_path('.'
set_include_path('.'
. PATH_SEPARATOR .realpath(dirname(__FILE__)). '/../library' . PATH_SEPARATOR .realpath(dirname(__FILE__)). '/../library'
. PATH_SEPARATOR .realpath(dirname(__FILE__)). '/../library/storm/zf/library' . PATH_SEPARATOR .realpath(dirname(__FILE__)). '/../library/storm/zf/library'
. PATH_SEPARATOR .realpath(dirname(__FILE__)). '/../library/storm/src' . PATH_SEPARATOR .realpath(dirname(__FILE__)). '/../library/storm/src'
...@@ -31,14 +31,13 @@ set_include_path('.' ...@@ -31,14 +31,13 @@ set_include_path('.'
. PATH_SEPARATOR . realpath(dirname(__FILE__)).'/../application/modules' . PATH_SEPARATOR . realpath(dirname(__FILE__)).'/../application/modules'
. PATH_SEPARATOR . realpath(dirname(__FILE__)).'/application/modules' . PATH_SEPARATOR . realpath(dirname(__FILE__)).'/application/modules'
); );
$newsletter_id=$argv[1];
$_SERVER['HTTP_HOST']=$argv[2];
include_once "local.php"; include_once "local.php";
include_once "fonctions/fonctions.php"; include_once "fonctions/fonctions.php";
require_once "Zend/Loader.php"; require_once "Zend/Loader.php";
require_once "startup.php"; require_once "startup.php";
setupOpac(); setupOpac();
$news=(Class_Newsletter::find($newsletter_id));
$news->generateMails(20); Class_Newsletter::find($argv[4])->generateMails(20);
?> ?>
\ No newline at end of file
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with AFI-OPAC 2.0; if not, write to the Free Software * along with AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
require_once 'ModelTestCase.php'; require_once 'ModelTestCase.php';
...@@ -24,7 +24,7 @@ require_once 'ModelTestCase.php'; ...@@ -24,7 +24,7 @@ require_once 'ModelTestCase.php';
abstract class NewsletterMailingTestCase extends ModelTestCase { abstract class NewsletterMailingTestCase extends ModelTestCase {
public function setup() { public function setup() {
parent::setup(); parent::setup();
Class_PanierNotice::beVolatile(); Class_PanierNotice::beVolatile();
Class_Catalogue::beVolatile(); Class_Catalogue::beVolatile();
...@@ -48,7 +48,7 @@ abstract class NewsletterMailingTestCase extends ModelTestCase { ...@@ -48,7 +48,7 @@ abstract class NewsletterMailingTestCase extends ModelTestCase {
'auteur_principal' => 'Stieg Larsson', 'auteur_principal' => 'Stieg Larsson',
'annee' => 2005, 'annee' => 2005,
'url_vignette' => 'http://afi-sa.fr/millenium.png']); 'url_vignette' => 'http://afi-sa.fr/millenium.png']);
$this->potter = $this->fixture('Class_Notice', $this->potter = $this->fixture('Class_Notice',
['id' => 987, ['id' => 987,
'titre_principal' => "Harry Potter à l'école des sorciers", 'titre_principal' => "Harry Potter à l'école des sorciers",
...@@ -62,11 +62,11 @@ abstract class NewsletterMailingTestCase extends ModelTestCase { ...@@ -62,11 +62,11 @@ abstract class NewsletterMailingTestCase extends ModelTestCase {
$this->rdubois = $this->fixture('Class_Users', $this->rdubois = $this->fixture('Class_Users',
['id' => 1, ['id' => 1,
'login' => 'rdub', 'login' => 'rdub',
'password' => 'pwd', 'password' => 'pwd',
'prenom' => 'Rémy', 'prenom' => 'Rémy',
'nom' => 'Dubois', 'nom' => 'Dubois',
'mail' => 'rdubois@afi-sa.fr']); 'mail' => 'rdubois@afi-sa.fr']);
$this->mduchamp = $this->fixture('Class_Users', $this->mduchamp = $this->fixture('Class_Users',
['id' => 2, ['id' => 2,
'login' => 'duchamp', 'login' => 'duchamp',
...@@ -116,7 +116,7 @@ abstract class NewsletterMailingTestCase extends ModelTestCase { ...@@ -116,7 +116,7 @@ abstract class NewsletterMailingTestCase extends ModelTestCase {
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_NewsletterSubscription') Storm_Test_ObjectWrapper::onLoaderOfModel('Class_NewsletterSubscription')
->whenCalled('clearCache') ->whenCalled('clearCache')
->answers(true) ->answers(true)
->whenCalled('countDistributionProgress') ->whenCalled('countDistributionProgress')
->with(1) ->with(1)
...@@ -136,7 +136,7 @@ abstract class NewsletterMailingTestCase extends ModelTestCase { ...@@ -136,7 +136,7 @@ abstract class NewsletterMailingTestCase extends ModelTestCase {
->whenCalled('resetSendFlagForNewsletter') ->whenCalled('resetSendFlagForNewsletter')
->with(1) ->with(1)
->answers(true) ->answers(true)
->beStrict(); ->beStrict();
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Notice') Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Notice')
...@@ -145,13 +145,13 @@ abstract class NewsletterMailingTestCase extends ModelTestCase { ...@@ -145,13 +145,13 @@ abstract class NewsletterMailingTestCase extends ModelTestCase {
$this->mock_transport = new MockMailTransport(); $this->mock_transport = new MockMailTransport();
Zend_Mail::setDefaultTransport($this->mock_transport); Zend_Mail::setDefaultTransport($this->mock_transport);
$this->animations->generateMails(20); $this->animations->generateMails(20);
$this->mail = $this->mock_transport->sent_mail; $this->mail = $this->mock_transport->sent_mail;
} }
protected function getReceivers() { protected function getReceivers() {
if ($this->user_model->methodCallCount('getNewslettersReceivers')>1) if ($this->user_model->methodCallCount('getNewslettersReceivers')>1)
return []; return [];
...@@ -170,8 +170,15 @@ class NewsletterMailingAnimationsTestSendMail extends NewsletterMailingTestCase ...@@ -170,8 +170,15 @@ class NewsletterMailingAnimationsTestSendMail extends NewsletterMailingTestCase
parent::setup(); parent::setup();
$this->animations->generateMails(20); $this->animations->generateMails(20);
$this->mail = $this->mock_transport->sent_mail; $this->mail = $this->mock_transport->sent_mail;
$this->batch_send = new Class_Batch_SendNewsletters($this->animations);
}
/** @test */
public function batchSendParamsShouldBeAsExpected() {
$this->assertEquals('"'.$_SERVER['HTTP_HOST'].'" "'.$_SERVER['SERVER_NAME'].'" "'.BASE_URL.'" "1"', $this->batch_send->getExecParams());
} }
/** @test */ /** @test */
public function floShouldBeExpeditor() { public function floShouldBeExpeditor() {
......
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