Blabla.
This commit is contained in:
@@ -42,12 +42,12 @@ class Configuration {
|
||||
// 0 : no log at all
|
||||
// 1 : log summary
|
||||
// 2 : log response
|
||||
'verbosity' => 2,
|
||||
'verbosity' => 0,
|
||||
),
|
||||
'session' => array(
|
||||
'save_path' => ''
|
||||
),
|
||||
'checkfile_url' => 'http://85.218.123.89/checkfile.php?',
|
||||
'checkfile_url' => 'http://medias.bibliothequesonore.ch/checkfile.php?',
|
||||
'checkfile_url_old' => 'http://fichiers.bibliothequesonore.ch/checkfile.php?',
|
||||
'netbiblio_worker_id' => 45,
|
||||
'www_employee_id' => 45,
|
||||
|
||||
@@ -48,6 +48,7 @@ abstract class Formatter {
|
||||
* @return string The class name to instantiate in accord to the Accept header
|
||||
*/
|
||||
private static function getFormatFromHeader() {
|
||||
return 'BSR\Lib\Formatter\Json';
|
||||
if(isset($_SERVER['HTTP_ACCEPT'])) {
|
||||
$formats = array_map(function($f) {
|
||||
$parts = explode(';', $f);
|
||||
|
||||
@@ -19,7 +19,7 @@ class Renderer {
|
||||
|
||||
public function render($status, $data) {
|
||||
header(sprintf('HTTP/1.0 %s %s', $status, self::$statusMessages[$status]));
|
||||
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
ob_clean();
|
||||
flush();
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace BSR\Lib\Search;
|
||||
|
||||
use BSR\Lib\Configuration;
|
||||
use BSR\Lib\Exception\WebException;
|
||||
use BSR\Lib\Logger;
|
||||
|
||||
mb_http_output('UTF-8');
|
||||
|
||||
@@ -148,6 +149,7 @@ class BookSearch
|
||||
*/
|
||||
public function getResults($start = 0, $count = 15, $facets = false, $spellcheck = false, $highlight = false)
|
||||
{
|
||||
//Logger::log(print_r($this->queryParts, true), $verbosity = Logger::QUIET);
|
||||
if (count($this->queryParts) == 0)
|
||||
$query = '*:*';
|
||||
else {
|
||||
@@ -295,6 +297,7 @@ class BookSearch
|
||||
|
||||
$bs = new static();
|
||||
$bs->addOrQuery($codes, $field);
|
||||
|
||||
$results = $bs->getResults(0, $count);
|
||||
return $results['books'];
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ abstract class WebService
|
||||
$result = $this->Call();
|
||||
$data["result"][$this->func] = $result;
|
||||
|
||||
Logger::log(print_r($result, true));
|
||||
// Logger::log(print_r($result, true));
|
||||
} catch (WebException $e) {
|
||||
$data["error"]["code"] = $e->getCode();
|
||||
$data["error"]["reason"] = $e->getMessage();
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace BSR\Lib\db;
|
||||
|
||||
use BSR\Lib\Configuration;
|
||||
use BSR\Lib\Search\BookSearch;
|
||||
use BSR\Lib\Logger;
|
||||
|
||||
/**
|
||||
* User is mapped on the UserAccounts table. Contains user information : id, login, firstName, lastName, displayName.
|
||||
@@ -76,7 +78,7 @@ class User extends DbMapping
|
||||
REPLACE(UserAccountNr, ' ', '') AS login
|
||||
FROM [UserAccounts] AS u
|
||||
LEFT JOIN [Addresses] AS a ON a.[AddressID] = u.[ActualAddressID]
|
||||
WHERE LTRIM(RTRIM(UserAccountNr)) = '%s' AND disabled = 1 %s;",
|
||||
WHERE LTRIM(RTRIM(UserAccountNr)) = '%s' AND disabled = 1 %s AND CategoryCode in ('A', 'M', 'G', 'D', 'I', 'EMP');",
|
||||
$login, $cond);
|
||||
|
||||
$results = Connection::execute($sql, $raiseError);
|
||||
@@ -122,18 +124,36 @@ class User extends DbMapping
|
||||
return $result ? $result->to_array() : array();
|
||||
}
|
||||
|
||||
public function getLoansData($table, $sort = "ItemNr ASC")
|
||||
public function GetOldLoansNrs()
|
||||
{
|
||||
$sql = sprintf("SELECT
|
||||
n.NoticeId,
|
||||
n.NoticeNr,
|
||||
CheckOutDate,
|
||||
ItemNr
|
||||
FROM %s AS c
|
||||
n.NoticeNr
|
||||
FROM OldCirculations AS c
|
||||
INNER JOIN Items AS i ON i.ItemId = c.ItemId
|
||||
INNER JOIN Notices AS n ON n.NoticeID = i.NoticeID
|
||||
WHERE
|
||||
c.UserAccountID = %s
|
||||
c.UserAccountID = %s AND
|
||||
n.MediaType1Code in ('CDD', 'CDA', 'DVD', 'CDS') AND n.deleted=1
|
||||
ORDER BY ItemNr ASC", $this->id);
|
||||
|
||||
$result = Connection::execute($sql);
|
||||
return $result ? $result->to_array() : array();
|
||||
}
|
||||
|
||||
public function getLoansData($table, $sort = "acquisitiondate DESC")
|
||||
{
|
||||
$sql = sprintf("SELECT top 50
|
||||
realn.NoticeId as NoticeID,
|
||||
realn.NoticeNr,
|
||||
CheckOutDate,
|
||||
c.Remark,
|
||||
ItemNr
|
||||
FROM %s AS c
|
||||
INNER JOIN Items AS i ON i.ItemId = c.ItemId
|
||||
INNER JOIN Notices AS lentn ON lentn.NoticeID = i.NoticeID
|
||||
INNER JOIN Notices AS realn ON REPLACE(ltrim(rtrim(lentn.noticenr)), 'V', '') = ltrim(rtrim(realn.noticenr))
|
||||
WHERE
|
||||
c.UserAccountID = %s
|
||||
ORDER BY %s", $table, $this->id, $sort);
|
||||
|
||||
return Connection::execute($sql)->to_array();
|
||||
@@ -142,20 +162,23 @@ class User extends DbMapping
|
||||
private function _getLoans($table, $count, $sort)
|
||||
{
|
||||
$circulations = $this->getLoansData($table, $sort);
|
||||
//Logger::log(print_r($circulations, true));
|
||||
// getting the intval of the NoticeNr will remove any 'V' or 'T' and thus we will have no issues with
|
||||
// the virtual books that are used for Downloads and so.
|
||||
$codes = array_unique(array_map(function($c) { return intval(trim($c['NoticeNr'])); }, $circulations));
|
||||
$codes = array_unique(array_map(function($c) {
|
||||
return trim($c['NoticeNr']); }, $circulations));
|
||||
|
||||
if($count) {
|
||||
return count($circulations);
|
||||
}
|
||||
|
||||
$books = count($codes) > 0 ? BookSearch::GetBooks($codes) : array();
|
||||
|
||||
//Logger::log(print_r($books, true));
|
||||
foreach($circulations as $c) {
|
||||
$id = $c['NoticeID'];
|
||||
if(isset($books[$id])) {
|
||||
$books[$id]['date'] = $c['CheckOutDate'];
|
||||
$books[$id]['itemNr'] = $c['ItemNr'];
|
||||
$books[$id]['checkoutDate'] = $c['CheckOutDate'];
|
||||
$books[$id]['remark'] = $c['Remark'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +217,6 @@ class User extends DbMapping
|
||||
INNER JOIN Notices AS n ON n.NoticeID = i.NoticeID
|
||||
WHERE
|
||||
c.UserAccountID = %s
|
||||
AND DATEDIFF(week, CheckOutDate, GETDATE()) > 1
|
||||
AND DATEDIFF(month, CheckOutDate, GETDATE()) < 5
|
||||
", $this->id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user