From 5e35d2f81d7ec776fb1acb2b078fad63b2aa03ef Mon Sep 17 00:00:00 2001
From: pbarroca <pbarroca@afi-sa.fr>
Date: Fri, 7 Feb 2014 19:42:56 +0100
Subject: [PATCH] SAV: Fix SIGB patron reader to comply with new Nanook
 suggests content

---
 .../SIGB/AbstractILSDIPatronInfoReader.php       | 16 ++++++++++++----
 .../Class/WebService/SIGB/NanookFixtures.php     | 11 +++++++++++
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/library/Class/WebService/SIGB/AbstractILSDIPatronInfoReader.php b/library/Class/WebService/SIGB/AbstractILSDIPatronInfoReader.php
index 60708b18200..65656723159 100644
--- a/library/Class/WebService/SIGB/AbstractILSDIPatronInfoReader.php
+++ b/library/Class/WebService/SIGB/AbstractILSDIPatronInfoReader.php
@@ -38,7 +38,6 @@ abstract class Class_WebService_SIGB_AbstractILSDIPatronInfoReader {
 	protected $_loans = [];
 
 
-
 	/**
 	 * @param Class_WebService_SIGB_Emprunteur $emprunteur
 	 * @return Class_WebService_SIGB_*_PatronInfoReader
@@ -99,7 +98,8 @@ abstract class Class_WebService_SIGB_AbstractILSDIPatronInfoReader {
 	 * @param string $data
 	 */
 	public function endLoan($data) {
-		$this->_loans []= $this->_currentLoan;
+		$this->_loans[] = $this->_currentLoan;
+		$this->_currentLoan = $this->_current_operation = null;
 	}
 
 
@@ -124,17 +124,19 @@ abstract class Class_WebService_SIGB_AbstractILSDIPatronInfoReader {
 	 */
 	public function endHold($data) {
 		$this->getEmprunteur()->reservationsAdd($this->_currentHold);
+		$this->_currentHold = $this->_current_operation = null;
 	}
 
 
 	public function endTitle($titre) {
-		if ($this->_xml_parser->inParents('loan') or $this->_xml_parser->inParents('hold'))
+		if ($this->_isLoanOrHold())
 			$this->_current_operation->getExemplaire()->setTitre($titre);
 	}
 
 
 	public function endAuthor($author) {
-		$this->_current_operation->getExemplaire()->setAuteur($author);
+		if ($this->_isLoanOrHold())
+			$this->_current_operation->getExemplaire()->setAuteur($author);
 	}
 
 
@@ -149,6 +151,12 @@ abstract class Class_WebService_SIGB_AbstractILSDIPatronInfoReader {
 	public function _getCurrentOperation() {
 		return $this->_current_operation;
 	}
+
+
+	protected function _isLoanOrHold() {
+		return ($this->_xml_parser->inParents('loan') 
+						or $this->_xml_parser->inParents('hold'));
+	}
 }
 
 ?>
\ No newline at end of file
diff --git a/tests/library/Class/WebService/SIGB/NanookFixtures.php b/tests/library/Class/WebService/SIGB/NanookFixtures.php
index a1d09dad2dc..b6f09761ee4 100644
--- a/tests/library/Class/WebService/SIGB/NanookFixtures.php
+++ b/tests/library/Class/WebService/SIGB/NanookFixtures.php
@@ -247,6 +247,17 @@ class NanookFixtures {
       <locationLabel>Site Principal</locationLabel>
     </hold>
   </holds>
+  <suggests>
+    <suggest>
+      <site>1</site>
+      <status>En attente</status>
+      <title></title>
+      <author></author>
+      <isbnEan></isbnEan>
+      <descLink></descLink>
+      <comment>Tittre :Alzheimer mon amour Auteur : Cécile HUGUENIN</comment>
+    </suggest>
+  </suggests>
 </GetPatronInfo>';
 	}
 
-- 
GitLab