Skip to content
Snippets Groups Projects
Commit 1da9a0a6 authored by Demian Katz's avatar Demian Katz
Browse files

Style fixes.

parent 4f08d2ae
No related merge requests found
...@@ -27,10 +27,11 @@ ...@@ -27,10 +27,11 @@
* @link https://vufind.org/wiki/development:plugins:ils_drivers Wiki * @link https://vufind.org/wiki/development:plugins:ils_drivers Wiki
*/ */
namespace VuFind\ILS\Driver; namespace VuFind\ILS\Driver;
use PDO, PDOException,
VuFind\Exception\ILS as ILSException, use PDO;
Zend\Log\LoggerAwareInterface, use VuFind\Exception\ILS as ILSException;
VuFind\Log\LoggerAwareTrait; use VuFind\Log\LoggerAwareTrait;
use Zend\Log\LoggerAwareInterface;
/** /**
* Horizon ILS Driver * Horizon ILS Driver
...@@ -45,7 +46,7 @@ use PDO, PDOException, ...@@ -45,7 +46,7 @@ use PDO, PDOException,
class Horizon extends AbstractBase implements LoggerAwareInterface class Horizon extends AbstractBase implements LoggerAwareInterface
{ {
use LoggerAwareTrait; use LoggerAwareTrait;
/** /**
* Date converter object * Date converter object
* *
...@@ -84,7 +85,7 @@ class Horizon extends AbstractBase implements LoggerAwareInterface ...@@ -84,7 +85,7 @@ class Horizon extends AbstractBase implements LoggerAwareInterface
if (empty($this->config)) { if (empty($this->config)) {
throw new ILSException('Configuration needs to be set.'); throw new ILSException('Configuration needs to be set.');
} }
// Connect to database // Connect to database
try { try {
$this->db = new PDO( $this->db = new PDO(
...@@ -94,13 +95,14 @@ class Horizon extends AbstractBase implements LoggerAwareInterface ...@@ -94,13 +95,14 @@ class Horizon extends AbstractBase implements LoggerAwareInterface
$this->config['Catalog']['username'], $this->config['Catalog']['username'],
$this->config['Catalog']['password'] $this->config['Catalog']['password']
); );
// throw an exception instead of false on sql errors // throw an exception instead of false on sql errors
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logError($e->getMessage()); $this->logError($e->getMessage());
throw new ILSException('ILS Configuration problem : ' . $e->getMessage()); throw new ILSException(
'ILS Configuration problem : ' . $e->getMessage()
);
} }
} }
...@@ -350,9 +352,9 @@ class Horizon extends AbstractBase implements LoggerAwareInterface ...@@ -350,9 +352,9 @@ class Horizon extends AbstractBase implements LoggerAwareInterface
foreach ($sqlStmt as $row) { foreach ($sqlStmt as $row) {
$holding[] = $this->processHoldingRow($id, $row, $patron); $holding[] = $this->processHoldingRow($id, $row, $patron);
} }
$this->debug(json_encode($holding)); $this->debug(json_encode($holding));
return $holding; return $holding;
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logError($e->getMessage()); $this->logError($e->getMessage());
...@@ -441,7 +443,6 @@ class Horizon extends AbstractBase implements LoggerAwareInterface ...@@ -441,7 +443,6 @@ class Horizon extends AbstractBase implements LoggerAwareInterface
'innerJoin' => $sqlInnerJoin, 'innerJoin' => $sqlInnerJoin,
'where' => $sqlWhere 'where' => $sqlWhere
]; ];
return $sqlArray; return $sqlArray;
} }
...@@ -527,13 +528,13 @@ class Horizon extends AbstractBase implements LoggerAwareInterface ...@@ -527,13 +528,13 @@ class Horizon extends AbstractBase implements LoggerAwareInterface
"where borrower_barcode.bbarcode = " . "where borrower_barcode.bbarcode = " .
"'" . addslashes($username) . "' " . "'" . addslashes($username) . "' " .
"and pin# = '" . addslashes($password) . "'"; "and pin# = '" . addslashes($password) . "'";
try { try {
$user = []; $user = [];
$sqlStmt = $this->db->query($sql); $sqlStmt = $this->db->query($sql);
foreach ($sqlStmt as $row) { foreach ($sqlStmt as $row) {
list($lastname,$firstname) = explode(', ', $row['FULLNAME']); list($lastname, $firstname) = explode(', ', $row['FULLNAME']);
$user = [ $user = [
'id' => $username, 'id' => $username,
'firstname' => $firstname, 'firstname' => $firstname,
...@@ -544,12 +545,12 @@ class Horizon extends AbstractBase implements LoggerAwareInterface ...@@ -544,12 +545,12 @@ class Horizon extends AbstractBase implements LoggerAwareInterface
'major' => null, 'major' => null,
'college' => null 'college' => null
]; ];
$this->debug(json_encode($user)); $this->debug(json_encode($user));
return $user; return $user;
} }
throw new ILSException( throw new ILSException(
'Unable to login patron ' . $patron['id'] 'Unable to login patron ' . $patron['id']
); );
...@@ -708,9 +709,9 @@ class Horizon extends AbstractBase implements LoggerAwareInterface ...@@ -708,9 +709,9 @@ class Horizon extends AbstractBase implements LoggerAwareInterface
$holdList[] = $hold; $holdList[] = $hold;
} }
} }
$this->debug(json_encode($holdList)); $this->debug(json_encode($holdList));
return $holdList; return $holdList;
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logError($e->getMessage()); $this->logError($e->getMessage());
...@@ -806,9 +807,9 @@ class Horizon extends AbstractBase implements LoggerAwareInterface ...@@ -806,9 +807,9 @@ class Horizon extends AbstractBase implements LoggerAwareInterface
'title' => $row['TITLE'] 'title' => $row['TITLE']
]; ];
} }
$this->debug(json_encode($fineList)); $this->debug(json_encode($fineList));
return $fineList; return $fineList;
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logError($e->getMessage()); $this->logError($e->getMessage());
...@@ -840,11 +841,11 @@ class Horizon extends AbstractBase implements LoggerAwareInterface ...@@ -840,11 +841,11 @@ class Horizon extends AbstractBase implements LoggerAwareInterface
"inner join borrower_barcode on " . "inner join borrower_barcode on " .
"borrower_barcode.borrower# = borrower.borrower# " . "borrower_barcode.borrower# = borrower.borrower# " .
"where borrower_barcode.bbarcode = '" . addslashes($patron['id']) . "'"; "where borrower_barcode.bbarcode = '" . addslashes($patron['id']) . "'";
try { try {
$sqlStmt = $this->db->query($sql); $sqlStmt = $this->db->query($sql);
foreach ($sqlStmt as $row) { foreach ($sqlStmt as $row) {
list($lastname,$firstname) = explode(', ', $row['FULLNAME']); list($lastname, $firstname) = explode(', ', $row['FULLNAME']);
$profile = [ $profile = [
'lastname' => $lastname, 'lastname' => $lastname,
'firstname' => $firstname, 'firstname' => $firstname,
...@@ -854,12 +855,12 @@ class Horizon extends AbstractBase implements LoggerAwareInterface ...@@ -854,12 +855,12 @@ class Horizon extends AbstractBase implements LoggerAwareInterface
'phone' => $row['PHONE'], 'phone' => $row['PHONE'],
'group' => null 'group' => null
]; ];
$this->debug(json_encode($profile)); $this->debug(json_encode($profile));
return $profile; return $profile;
} }
throw new ILSException( throw new ILSException(
'Unable to retrieve profile for patron ' . $patron['id'] 'Unable to retrieve profile for patron ' . $patron['id']
); );
...@@ -997,9 +998,9 @@ class Horizon extends AbstractBase implements LoggerAwareInterface ...@@ -997,9 +998,9 @@ class Horizon extends AbstractBase implements LoggerAwareInterface
foreach ($sqlStmt as $row) { foreach ($sqlStmt as $row) {
$transList[] = $this->processTransactionsRow($row); $transList[] = $this->processTransactionsRow($row);
} }
$this->debug(json_encode($transList)); $this->debug(json_encode($transList));
return $transList; return $transList;
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logError($e->getMessage()); $this->logError($e->getMessage());
...@@ -1074,7 +1075,7 @@ class Horizon extends AbstractBase implements LoggerAwareInterface ...@@ -1074,7 +1075,7 @@ class Horizon extends AbstractBase implements LoggerAwareInterface
foreach ($sqlStmt as $row) { foreach ($sqlStmt as $row) {
$results[] = $row['bib#']; $results[] = $row['bib#'];
} }
$retVal = ['count' => count($results), 'results' => []]; $retVal = ['count' => count($results), 'results' => []];
foreach ($results as $result) { foreach ($results as $result) {
$retVal['results'][] = ['id' => $result]; $retVal['results'][] = ['id' => $result];
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment