|
|
|
|
@ -15,8 +15,6 @@ require_once "lib/BookSearch.php";
|
|
|
|
|
|
|
|
|
|
class NetBiblio extends WebService
|
|
|
|
|
{
|
|
|
|
|
private $data = array();
|
|
|
|
|
|
|
|
|
|
private $login = '';
|
|
|
|
|
private $client = 'website';
|
|
|
|
|
|
|
|
|
|
@ -26,11 +24,10 @@ class NetBiblio extends WebService
|
|
|
|
|
* @param $login
|
|
|
|
|
* @param $code
|
|
|
|
|
* @throws SqlException
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function AddDownloadLog($IP, $client, $login, $code)
|
|
|
|
|
{
|
|
|
|
|
$this->data = array();
|
|
|
|
|
|
|
|
|
|
$client = str_replace("'", "", $client);
|
|
|
|
|
$login = str_replace("'", "", $login);
|
|
|
|
|
$code = ltrim(str_replace("'", "", $code), '0');
|
|
|
|
|
@ -123,6 +120,8 @@ class NetBiblio extends WebService
|
|
|
|
|
Connection::execute($incrementItemCountersSQL);
|
|
|
|
|
}
|
|
|
|
|
Connection::execute($logSql);
|
|
|
|
|
|
|
|
|
|
return array(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function Authenticate($login, $password, $client = "website")
|
|
|
|
|
@ -138,14 +137,14 @@ class NetBiblio extends WebService
|
|
|
|
|
$_SESSION["user"]["login"] = $login;
|
|
|
|
|
$_SESSION["user"]["client"] = $client;
|
|
|
|
|
|
|
|
|
|
$this->data = $user->toArray();
|
|
|
|
|
$this->login = $login;
|
|
|
|
|
$this->client = $client;
|
|
|
|
|
|
|
|
|
|
return $user->toArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function Disconnect()
|
|
|
|
|
{
|
|
|
|
|
$this->data = array();
|
|
|
|
|
$_SESSION = array();
|
|
|
|
|
|
|
|
|
|
if (ini_get("session.use_cookies")) {
|
|
|
|
|
@ -154,11 +153,13 @@ class NetBiblio extends WebService
|
|
|
|
|
$params["path"], $params["domain"],
|
|
|
|
|
$params["secure"], $params["httponly"]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return array();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function IsAuthenticated()
|
|
|
|
|
{
|
|
|
|
|
$this->data = $this->getUser()->toArray();
|
|
|
|
|
return $this->getUser()->toArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -207,30 +208,30 @@ class NetBiblio extends WebService
|
|
|
|
|
|
|
|
|
|
public function FindAccount($login)
|
|
|
|
|
{
|
|
|
|
|
$this->data = $this->getUser($login)->toArray();
|
|
|
|
|
return $this->getUser($login)->toArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function GetWishes()
|
|
|
|
|
{
|
|
|
|
|
$books = $this->getUser()->getWishes();
|
|
|
|
|
$this->data = array_values(array_map(array($this, 'AddFiles'), $books));
|
|
|
|
|
return array_values(array_map(array($this, 'AddFiles'), $books));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function GetCirculations()
|
|
|
|
|
{
|
|
|
|
|
$circulations = $this->getUser()->getCirculations();
|
|
|
|
|
$this->data = array_values(array_map(array($this, 'AddFiles'), $circulations));
|
|
|
|
|
return array_values(array_map(array($this, 'AddFiles'), $circulations));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function GetOldCirculations()
|
|
|
|
|
{
|
|
|
|
|
$circulations = $this->getUser()->getOldCirculations();
|
|
|
|
|
$this->data = array_values(array_map(array($this, 'AddFiles'), $circulations));
|
|
|
|
|
return array_values(array_map(array($this, 'AddFiles'), $circulations));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function AddWish($bookNr)
|
|
|
|
|
{
|
|
|
|
|
$this->data[] = $this->getUser()->addWish($bookNr);
|
|
|
|
|
return $this->getUser()->addWish($bookNr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function DeleteWish($bookNr)
|
|
|
|
|
@ -245,7 +246,7 @@ class NetBiblio extends WebService
|
|
|
|
|
$codes = json_decode($codes, true);
|
|
|
|
|
$codes = array_map('intval', $codes);
|
|
|
|
|
$books = AudioBook::findBy('NoticeNr', $codes, true);
|
|
|
|
|
$this->data = array_values(array_map(array($this, 'AddFiles'), $books));
|
|
|
|
|
return array_values(array_map(array($this, 'AddFiles'), $books));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function AddFiles(array $book)
|
|
|
|
|
@ -282,7 +283,7 @@ class NetBiblio extends WebService
|
|
|
|
|
|
|
|
|
|
$code = intval($code);
|
|
|
|
|
$book = AudioBook::findBy('NoticeNr', $code, true);
|
|
|
|
|
$this->data = $this->AddFiles($book);
|
|
|
|
|
return $this->AddFiles($book);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function Search($query, $start, $limit)
|
|
|
|
|
@ -293,11 +294,12 @@ class NetBiblio extends WebService
|
|
|
|
|
'count' => $limit,
|
|
|
|
|
'page' => 0,
|
|
|
|
|
);
|
|
|
|
|
$this->NewSearch(json_encode($query));
|
|
|
|
|
$data = $this->NewSearch(json_encode($query));
|
|
|
|
|
|
|
|
|
|
// remove fields that are not used in "old" search
|
|
|
|
|
unset($this->data['count']);
|
|
|
|
|
unset($this->data['facets']);
|
|
|
|
|
unset($data['count']);
|
|
|
|
|
unset($data['facets']);
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function NewSearch($values)
|
|
|
|
|
@ -352,37 +354,41 @@ class NetBiblio extends WebService
|
|
|
|
|
throw new WebException ("SolrError", $e->getMessage(), -700);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->data['count'] = $results['response']['numFound'];
|
|
|
|
|
$this->data['facets'] = $results['facet_counts']['facet_fields'];
|
|
|
|
|
$data = array(
|
|
|
|
|
'count' => $results['response']['numFound'],
|
|
|
|
|
'facets' => $results['facet_counts']['facet_fields'],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
foreach ($results['response']['docs'] as $doc) {
|
|
|
|
|
$book = AudioBook::findBy('NoticeID', $doc['id'], true);
|
|
|
|
|
if($book) {
|
|
|
|
|
$this->data[] = $this->AddFiles($book);
|
|
|
|
|
$data[] = $this->AddFiles($book);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function ListOfReaders()
|
|
|
|
|
{
|
|
|
|
|
$this->data = AudioBook::listOfReaders();
|
|
|
|
|
return AudioBook::listOfReaders();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function ListOfCategories()
|
|
|
|
|
{
|
|
|
|
|
$this->data = AudioBook::listOfCategories();
|
|
|
|
|
return AudioBook::listOfCategories();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function ListOfTypes()
|
|
|
|
|
{
|
|
|
|
|
$this->data = array_filter(AudioBook::listOfTypes(), function ($t) {
|
|
|
|
|
return array_filter(AudioBook::listOfTypes(), function ($t) {
|
|
|
|
|
return strlen($t) > 0;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function InReadingBooks()
|
|
|
|
|
{
|
|
|
|
|
$this->data = AudioBook::inReading();
|
|
|
|
|
return AudioBook::inReading();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function LastBooksByType($type, $itemsByGroup)
|
|
|
|
|
@ -407,13 +413,10 @@ class NetBiblio extends WebService
|
|
|
|
|
$books = AudioBook::findBy('NoticeID', $ids, true);
|
|
|
|
|
$books = array_map(array($this, 'AddFiles'), $books);
|
|
|
|
|
|
|
|
|
|
$data = array();
|
|
|
|
|
foreach($books as $b) {
|
|
|
|
|
$this->data[$b['type']][] = $b;
|
|
|
|
|
$data[$b['type']][] = $b;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function Output()
|
|
|
|
|
{
|
|
|
|
|
return $this->data;
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|