Various fixes and cleanup :
* Always return at least success information * Fix issues with Wishes * Fix issues with Circulations * Fix typos in exceptions
This commit is contained in:
@@ -42,7 +42,7 @@ class NetBiblio extends WebService
|
||||
private function getUser($login = null)
|
||||
{
|
||||
if(! is_null($login) && $_SESSION["user"]["login"] !== $login) {
|
||||
throw new AuthenticationException("BadLogin", "Login '$login' is invalid.'", AuthenticationException::BAD_LOGIN);
|
||||
throw new AuthenticationException("BadLogin", "Login '$login' is invalid.", AuthenticationException::BAD_LOGIN);
|
||||
}
|
||||
|
||||
$this->checkSession();
|
||||
@@ -50,7 +50,7 @@ class NetBiblio extends WebService
|
||||
$user = User::find($this->login);
|
||||
|
||||
if (!$user) {
|
||||
throw new AuthenticationException("UserNotFound", "No user found for '{$this->login}.", AuthenticationException::USER_NOT_FOUND);
|
||||
throw new AuthenticationException("UserNotFound", "No user found for '{$this->login}'.", AuthenticationException::USER_NOT_FOUND);
|
||||
}
|
||||
|
||||
return $user;
|
||||
@@ -157,8 +157,12 @@ class NetBiblio extends WebService
|
||||
$b['files'] = $files;
|
||||
}
|
||||
|
||||
// date will be already set if we are updating Circulations
|
||||
if(! isset($b['date'])) {
|
||||
$b['date'] = date('Y.m.d', strtotime($b['availabilityDate']));
|
||||
}
|
||||
|
||||
// add fields for mobile apps compatibility
|
||||
$b['date'] = date('Y.m.d', strtotime($b['availabilityDate']));
|
||||
$b['readBy'] = isset($b['reader']) ? $b['reader'] : 'Lecteur inconnu';
|
||||
$b['category'] = $b['genre'];
|
||||
$b['code3'] = $b['producerCode'];
|
||||
@@ -373,18 +377,20 @@ class NetBiblio extends WebService
|
||||
|
||||
public function AddWish($bookNr)
|
||||
{
|
||||
return $this->getUser()->addWish($bookNr);
|
||||
$status = $this->getUser()->addWish($bookNr);
|
||||
return array('success' => $status);
|
||||
}
|
||||
|
||||
public function DeleteWish($bookNr)
|
||||
{
|
||||
$this->getUser()->deleteWish($bookNr);
|
||||
$status = $this->getUser()->deleteWish($bookNr);
|
||||
return array('success' => $status);
|
||||
}
|
||||
|
||||
public function FindBooks($codes)
|
||||
{
|
||||
$this->CheckSession();
|
||||
return $this->AddBookData(BookSearch::GetBooks(json_decode($codes)));
|
||||
return array_values($this->AddBookData(BookSearch::GetBooks(json_decode($codes))));
|
||||
}
|
||||
|
||||
public function FindBook($code)
|
||||
|
||||
Reference in New Issue
Block a user