|
|
|
@ -6,11 +6,12 @@ use BSR\Lib\Configuration;
|
|
|
|
use BSR\Lib\db\DBHelper;
|
|
|
|
use BSR\Lib\db\DBHelper;
|
|
|
|
use BSR\Lib\db\Connection;
|
|
|
|
use BSR\Lib\db\Connection;
|
|
|
|
use BSR\Lib\db\User;
|
|
|
|
use BSR\Lib\db\User;
|
|
|
|
use BSR\Lib\Logger;
|
|
|
|
|
|
|
|
use BSR\Lib\Exception\AuthenticationException;
|
|
|
|
use BSR\Lib\Exception\AuthenticationException;
|
|
|
|
use BSR\Lib\Exception\WebException;
|
|
|
|
use BSR\Lib\Exception\WebException;
|
|
|
|
use BSR\Lib\Search\BookSearch;
|
|
|
|
use BSR\Lib\Search\BookSearch;
|
|
|
|
use BSR\Lib\WebService;
|
|
|
|
use BSR\Lib\WebService;
|
|
|
|
|
|
|
|
use BSR\Lib\Logger;
|
|
|
|
|
|
|
|
|
|
|
|
class NetBiblio extends WebService
|
|
|
|
class NetBiblio extends WebService
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/** @var string $version version number */
|
|
|
|
/** @var string $version version number */
|
|
|
|
@ -84,7 +85,7 @@ class NetBiblio extends WebService
|
|
|
|
Configuration::get('checkfile_url'),
|
|
|
|
Configuration::get('checkfile_url'),
|
|
|
|
http_build_query(array("book" => implode(',', $codes)))
|
|
|
|
http_build_query(array("book" => implode(',', $codes)))
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
// Logger::log($uri);
|
|
|
|
$ch = curl_init($uri);
|
|
|
|
$ch = curl_init($uri);
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
|
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
|
|
@ -141,9 +142,7 @@ class NetBiblio extends WebService
|
|
|
|
* @return array either one or a list of books
|
|
|
|
* @return array either one or a list of books
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function AddBookData(array $books)
|
|
|
|
private function AddBookData(array $books)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logger::log(print_r($books, true), 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isset($books['code'])) {
|
|
|
|
if(isset($books['code'])) {
|
|
|
|
$result = $this->AddBookData(array($books));
|
|
|
|
$result = $this->AddBookData(array($books));
|
|
|
|
return reset($result);
|
|
|
|
return reset($result);
|
|
|
|
@ -485,6 +484,7 @@ class NetBiblio extends WebService
|
|
|
|
return array_values($this->AddBookData($circulations));
|
|
|
|
return array_values($this->AddBookData($circulations));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* This method returns the list of books that the currently authenticated user
|
|
|
|
* This method returns the list of books that the currently authenticated user
|
|
|
|
* has downloaded or that were lent to him.
|
|
|
|
* has downloaded or that were lent to him.
|
|
|
|
@ -495,7 +495,20 @@ class NetBiblio extends WebService
|
|
|
|
public function GetOldLoans()
|
|
|
|
public function GetOldLoans()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$circulations = $this->getUser()->GetOldLoans();
|
|
|
|
$circulations = $this->getUser()->GetOldLoans();
|
|
|
|
return array_values($this->AddBookData($circulations));
|
|
|
|
return $circulations; //array_values($this->AddBookData($circulations));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* This method returns the list of noticenr that
|
|
|
|
|
|
|
|
* were lent to the currently authenticated user.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @return array
|
|
|
|
|
|
|
|
* @throws AuthenticationException
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function GetOldLoansNrs()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$circulations = $this->getUser()->GetOldLoansNrs();
|
|
|
|
|
|
|
|
return $circulations;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -712,14 +725,14 @@ class NetBiblio extends WebService
|
|
|
|
$bs = new BookSearch();
|
|
|
|
$bs = new BookSearch();
|
|
|
|
|
|
|
|
|
|
|
|
// when search on a particular field, put results in descending date order
|
|
|
|
// when search on a particular field, put results in descending date order
|
|
|
|
if(!isset($queryArray['queryText'])) {
|
|
|
|
if(!isset($queryArray['queryText']) && !isset($queryArray['author_fr']) && !isset($queryArray['title_fr']) ) {
|
|
|
|
$bs->addSortField('availabilityDate');
|
|
|
|
$bs->addSortField('availabilityDate');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($queryArray['queryText']) && strlen($queryArray['queryText']) > 0) {
|
|
|
|
if (isset($queryArray['queryText']) && strlen($queryArray['queryText']) > 0) {
|
|
|
|
$type = isset($queryArray['queryType']) ? $queryArray['queryType'] : null;
|
|
|
|
$type = isset($queryArray['queryType']) ? $queryArray['queryType'] : null;
|
|
|
|
|
|
|
|
|
|
|
|
if($this->client != 'website' && in_array($type, array('title', 'author', 'reader'))) {
|
|
|
|
if(in_array($type, array('title', 'author', 'reader'))) {
|
|
|
|
// we don't want an exact search on mobile apps
|
|
|
|
// we don't want an exact search on mobile apps
|
|
|
|
$type = $type.'_fr';
|
|
|
|
$type = $type.'_fr';
|
|
|
|
} else if($type == 'text') {
|
|
|
|
} else if($type == 'text') {
|
|
|
|
@ -782,8 +795,6 @@ class NetBiblio extends WebService
|
|
|
|
|
|
|
|
|
|
|
|
$results = $bs->getResults($start, $count, $facets, $spellcheck, $highlight);
|
|
|
|
$results = $bs->getResults($start, $count, $facets, $spellcheck, $highlight);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$data = array(
|
|
|
|
$data = array(
|
|
|
|
'count' => $results['count'],
|
|
|
|
'count' => $results['count'],
|
|
|
|
'facets' => $results['facets'],
|
|
|
|
'facets' => $results['facets'],
|
|
|
|
@ -812,6 +823,21 @@ class NetBiblio extends WebService
|
|
|
|
return $this->AddBookData($results['books']);
|
|
|
|
return $this->AddBookData($results['books']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* This method return books similar to the one given.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param int|array $ids One or multiple book ids
|
|
|
|
|
|
|
|
* @param int number of books
|
|
|
|
|
|
|
|
* @return array
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function MoreLikeThisByCode($codes, $number = 8)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$bs = new BookSearch(false);
|
|
|
|
|
|
|
|
$bs->addOrQuery(is_array($code) ? $codes : array($codes), 'code');
|
|
|
|
|
|
|
|
$bs->setHandler('more');
|
|
|
|
|
|
|
|
$results = $bs->getResults(0, $number);
|
|
|
|
|
|
|
|
return array_values($this->AddBookData($results['books']));
|
|
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* This method returns books similar to the books already
|
|
|
|
* This method returns books similar to the books already
|
|
|
|
* loaned by the current user.
|
|
|
|
* loaned by the current user.
|
|
|
|
|