Commit a399bd3d authored by Patrick Barroca's avatar Patrick Barroca 🎮

version 7.3.11

Merge remote-tracking branch 'refs/remotes/afi/stable' into afi-hotline-master

# Conflicts:
#	VERSIONS
#	cosmogramme/php/classes/classe_notice_integration.php
#	library/startup.php
parents 3a50b9d0 4ff008b5
17/09/2015 - v7.3.11
- ticket #28958 : Le lien pour ouvrir la ressource 1dtouch devrait ouvrir un nouvel onglet
- ticket #26993 : PB Affichage incorrect dans Bokeh des notices de dépouillement
- ticket #29472 : L'Identification des usagers de type abonnés SIGB provenant de la base Koha de la BDM aboutit à une page blanche
- ticket #29441 : newsletter qui ne part pas
- ticket #29689 : Correction d'une erreur à l'intégration des articles de dépouillement dans cosmogramme
15/09/2015 - v7.3.10
- correction compatibilité PHP 5.4
14/09/2015 - v7.3.9
- sandbox : ajout de l'icône type doc sur les vignettes des avis
......
- ticket #26993 : PB Affichage incorrect dans Bokeh des notices de dépouillement
\ No newline at end of file
- ticket #28958 : Le lien pour ouvrir la ressource 1dtouch devrait ouvrir un nouvel onglet
\ No newline at end of file
- ticket #29472 : L'Identification des usagers de type abonnés SIGB provenant de la base Koha de la BDM aboutit à une page blanche
\ No newline at end of file
......@@ -919,8 +919,6 @@ class notice_integration {
// Ecrit une notice : article de périodique
// --------------------------------------------------------------------------------
private function ecrireArticlePeriodique() {
global $sql;
if( 1 == $this->notice["statut"])
return $this->deleteRecordArticles();
......@@ -980,6 +978,8 @@ class notice_integration {
protected function deleteRecordArticles() {
global $sql;
$this->statut = self::RECORD_DELETE;
if($this->notice["clef_unimarc"])
......@@ -988,9 +988,9 @@ class notice_integration {
$controle = $sql->execute("delete from notices_articles where clef_chapeau='$clef_chapeau' and clef_numero='$clef_numero' and clef_article='$clef_article'" );
if(!$controle) {
$this->statut = 0;
$this->erreur = "notice à supprimer non reconnue";
}
$this->statut = 0;
$this->erreur = "notice à supprimer non reconnue";
}
}
......
......@@ -187,26 +187,36 @@ class Class_Newsletter extends Storm_Model_Abstract {
}
protected function _getBodyText($notices) {
$lines = array($this->_htmlToText($this->getContenu()));
protected function _getBodyText($records) {
$lines = [$this->_htmlToText($this->getContenu())];
foreach($notices as $notice) {
$url_notice = sprintf('http://%s/recherche/viewnotice/id/%d',
$_SERVER['SERVER_NAME'].BASE_URL,
$notice->getId());
$lines []= '- '.$this->_getTitleForNotice($notice);
$lines []= $notice->getResume();
$lines []= "Lien: $url_notice";
$lines []= "\n";
}
foreach($records as $record)
$this->_addBodyTextRecordInto($record, $lines);
$lines[] = $this->_getUnsubscribeText();
return implode("\n", $lines);
}
protected function _addBodyTextRecordInto($record, &$data) {
if (!$record)
return;
$data[] = '- ' . $this->_getTitleForNotice($record);
$data[] = $record->getResume();
$data[] = 'Lien: ' . $this->_getRecordUrlWithoutRouter($record);
$data[] = "\n";
}
protected function _getRecordUrlWithoutRouter($record) {
return sprintf('http://%s/recherche/viewnotice/id/%d',
$_SERVER['SERVER_NAME'].BASE_URL,
$record->getId());
}
/**
* @return string
*/
......@@ -216,42 +226,42 @@ class Class_Newsletter extends Storm_Model_Abstract {
/**
* @param array $notices
* /!\ maybe in cli context : cannot rely on view helpers
* @see scripts/sendNewsletter.php
*
* @param array $records
* @return string
*/
protected function _getBodyHTML($notices) {
$view = new ZendAfi_Controller_Action_Helper_View();
protected function _getBodyHTML($records) {
$html = $this->getContenu();
foreach($notices as $notice) {
$title = $this->_getTitleForNotice($notice);
$vignette = $notice->fetchUrlVignette();
$resume = $notice->getResume();
$anchor_notice = $view
->tagAnchor($view->absoluteUrl(
[ 'controller' => 'recherche',
'action' => 'viewnotice',
'id' => $notice->getId()],
null, true
),
$view->tagImg($vignette,
['style' => 'float:left;width:50px;vertical-align:top;padding:5px',
'alt' => 'vignette']
) . $title);
$html.=
'<div style="padding:5px">' .
$anchor_notice .
'<div>' . $resume . '</div>' .
'<div style="clear:both"></div>'.
'</div>';
}
$html.=$this->_getUnsubscribeHTML();
foreach($records as $record)
$html .= $this->_getBodyHTMLRecord($record);
$html .= $this->_getUnsubscribeHTML();
return $html;
}
protected function _getBodyHTMLRecord($record) {
$title = $this->_getTitleForNotice($record);
$anchor = '<a href="' . $this->_getRecordUrlWithoutRouter($record) . '">'
. $this->_getRecordThumbWithoutRouter($record) . $title . '</a>';
return '<div style="padding:5px">' .
$anchor .
'<div>' . $record->getResume() . '</div>' .
'<div style="clear:both"></div>'.
'</div>';
}
protected function _getRecordThumbWithoutRouter($record) {
return $record->hasVignette() ?
'<img src="' . $record->getUrlVignette() . '" style="float:left;width:50px;vertical-align:top;padding:5px" alt="" />'
: '';
}
......
......@@ -334,38 +334,41 @@ class Class_Notice extends Storm_Model_Abstract {
}
public function getAvisBibliothecaires() {
public function getAvisBibliothecaires() {
return Class_AvisNotice::filterByBibliothecaire($this->getAvis());
}
public function numberOfAvisBibliothecaire() {
return Class_AvisNotice::countBy(['abon_ou_bib' => 1, 'clef_oeuvre' => $this->getClefOeuvre()]);
}
public function getAvisAbonnes()
{
public function getAvisAbonnes() {
return Class_AvisNotice::filterByAbonne($this->getAvis());
}
public function numberOfAvisAbonne() {
return Class_AvisNotice::countBy(['abon_ou_bib' => 0, 'clef_oeuvre' => $this->getClefOeuvre()]);
}
public function getNoteMoyenneAvisBibliothecaires()
{
public function getNoteMoyenneAvisBibliothecaires() {
return Class_AvisNotice::getNoteAverage($this->getAvisBibliothecaires());
}
public function getNoteMoyenneAvisAbonnes()
{
public function getNoteMoyenneAvisAbonnes() {
return Class_AvisNotice::getNoteAverage($this->getAvisAbonnes());
}
public function setAvis($list_avis)
{
public function setAvis($list_avis) {
$this->_avis = $list_avis;
}
public function setUnimarc($unimarc) {
$this->getNoticeUnimarc()->setNotice($unimarc);
return parent::setUnimarc($unimarc);
......@@ -454,18 +457,22 @@ class Class_Notice extends Storm_Model_Abstract {
return ($this->getTypeDoc() == Class_TypeDoc::ARTICLE);
}
public function isRSS() {
return ($this->getTypeDoc() == Class_TypeDoc::RSS);
}
public function isAudioRecord() {
return ($this->getTypeDoc() == Class_TypeDoc::AUDIO_RECORD);
}
public function isSite() {
return ($this->getTypeDoc() == Class_TypeDoc::SITE);
}
public function getArticleCms() {
if (!$this->isArticleCms())
return null;
......@@ -474,6 +481,7 @@ class Class_Notice extends Storm_Model_Abstract {
return Class_Article::find($id);
}
public function getSite() {
if (!$this->isSite())
return null;
......
This diff is collapsed.
......@@ -18,7 +18,8 @@
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
define("BASE_URL", $argv[3]);
define('BASE_URL', $argv[3]);
$_SERVER['SERVER_NAME'] = $argv[2];
$_SERVER['HTTP_HOST'] = $argv[1];
......
......@@ -82,9 +82,6 @@ $translate->addTranslation(LANG_DIR.'ro.mo', 'ro');
$translate->addTranslation(LANG_DIR.'en.mo', 'en');
$translate->setLocale('fr');
//Initialize the router for tests that do not rely on dispatch
Zend_Controller_Front::getInstance()->getRouter()->route(new Zend_Controller_Request_Http('http://localhost/'));
require_once 'tests/library/ZendAfi/View/Helper/ViewHelperTestCase.php';
require_once 'tests/application/modules/admin/controllers/AdminAbstractControllerTestCase.php';
require_once 'tests/fixtures/RessourcesNumeriquesFixtures.php';
......
......@@ -444,12 +444,12 @@ class NewsletterMailingConcertsPanierHtmlTest extends NewsletterMailingTestCase
/** @see http://forge.afi-sa.fr/issues/18661 */
class NewsletterMailingDedupTest extends ModelTestCase {
protected
$_storm_default_to_volatile = true,
$_fetch_users_calls = 0,
$_letter;
public function setUp() {
parent::setUp();
Storm_Model_Loader::defaultToVolatile();
$this->mock_transport = new MockMailTransport();
Zend_Mail::setDefaultTransport($this->mock_transport);
......@@ -495,12 +495,6 @@ class NewsletterMailingDedupTest extends ModelTestCase {
}
public function tearDown() {
Storm_Model_Loader::defaultToDb();
parent::tearDown();
}
/** @test */
public function procyonInOnePageShouldNotReceiveTwoMails() {
$this->expectUserFetchAndDo(
......@@ -554,4 +548,109 @@ class NewsletterMailingDedupTest extends ModelTestCase {
->with('select bib_admin_users.* from bib_admin_users join newsletters_users on bib_admin_users.id_user = newsletters_users.user_id where newsletter_id = 23 and newsletters_users.send is false order by bib_admin_users.mail limit 20')
->willDo($closure);
}
}
\ No newline at end of file
}
/** @see http://forge.afi-sa.fr/issues/29441 */
class NewsletterMailingRecordAbsoluteUrlTest extends ModelTestCase {
protected
$_text_content = '',
$_html_content = '',
$_xpath,
$_base_url = '';
public function setUp() {
parent::setUp();
$this->_xpath = new Storm_Test_XPath();
$this->_base_url = 'http://' . $_SERVER['HTTP_HOST'] . BASE_URL;
$time_source = new TimeSourceForTest('2014-05-23 14:30:00');
Class_Newsletter::setTimeSource($time_source);
$this->alcor = $this->fixture('Class_Users',
['id' => 120,
'login' => 'alc',
'password' => 'or',
'mail' => 'procyon@centre-de-recherche.fr']);
$this->_letter = $this->fixture('Class_Newsletter',
['id' => 23,
'titre' => 'Alerte vega',
'id_panier' => 1,
'nb_notices' => 50,
'id_catalogue' => 0,
'expediteur' => 'professeur@centre-de-recherche.fr',
'contenu' => 'Golgoth aperçu azimut 234.53',
'last_distribution_date' => '',
'users' => [$this->alcor]]);
$this->onLoaderOfModel('Class_Notice')
->whenCalled('getNoticesFromPreferences')
->answers([$this->fixture('Class_Notice',
['id' => 12,
'titre_principal' => 'UFO robot']),
$this->fixture('Class_Notice',
['id' => 14,
'titre_principal' => 'To test is to doubt',
'url_vignette' => 'http://server.com/test.png'])]);
$mail = $this->_letter
->newMailFromTemplate($this->_letter->newTemplate(), $this->alcor);
$this->_text_content = $mail->getBodyText(true);
$this->_html_content = quoted_printable_decode($mail->getBodyHtml(true));
}
public function recordIds() {
return [[12], [14]];
}
/**
* @test
* @dataProvider recordIds
*/
public function textShouldContainRecordUrl($record_id) {
$this->assertContains($this->_recordUrlOf($record_id), $this->_text_content);
}
/**
* @test
* @dataProvider recordIds
*/
public function htmlShouldContainRecordLink($record_id) {
$this->_xpath->assertXPath($this->_html_content,
'//a[@href="' . $this->_recordUrlOf($record_id) . '"]');
}
/** @test */
public function htmlShouldNotContainUfoRobotThumb() {
$this->_xpath->assertNotXPath($this->_html_content,
'//a[@href="' . $this->_recordUrlOf(12) . '"]//img');
}
/** @test */
public function htmlShouldContainsDoubtThumb() {
$this->_xpath->assertXPath($this->_html_content,
'//a[@href="' . $this->_recordUrlOf(14) . '"]//img[@src="http://server.com/test.png"]',
$this->_html_content);
}
protected function _recordUrlOf($id) {
return $this->_basedUrl('/recherche/viewnotice/id/' . $id);
}
protected function _basedUrl($url) {
return $this->_base_url . $url;
}
}
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