Skip to content
Snippets Groups Projects
Commit 1258c3f4 authored by Demian Katz's avatar Demian Katz Committed by Robert Lange
Browse files

Code cleanup: remove unused variables and comments; adjust whitespace

parent ca0c1720
Branches
Tags
No related merge requests found
......@@ -195,7 +195,7 @@ class OverdriveConnector implements LoggerAwareInterface,
= $this->getResultObject(true);
} else {
$result = $this->getResultObject();
//there is some problem with the account
// there is some problem with the account
$result->code = "od_account_problem";
$conf = $this->getConfig();
......@@ -205,12 +205,12 @@ class OverdriveConnector implements LoggerAwareInterface,
$conf->noAccessString
) !== false
) {
//this user should not have access to OD
// this user should not have access to OD
$result->code = "od_account_noaccess";
}
}
//odAccessMessage is set in the session by the API call above
//maybe it should be saved to a class property instead
// odAccessMessage is set in the session by the API call above
// maybe it should be saved to a class property instead
$result->msg = $this->getSessionContainer()->odAccessMessage;
$this->getSessionContainer()->odAccess = $result;
}
......@@ -243,8 +243,8 @@ class OverdriveConnector implements LoggerAwareInterface,
if ($conf = $this->getConfig()) {
$collectionToken = $this->getCollectionToken();
//hmm. no token. if user is logged in let's check access
if (!$collectionToken && $user = $this->getUser()) {
// hmm. no token. if user is logged in let's check access
if (!$collectionToken && $this->getUser()) {
$accessResult = $this->getAccess();
if (!$accessResult->status) {
return $accessResult;
......@@ -258,9 +258,9 @@ class OverdriveConnector implements LoggerAwareInterface,
if ($res->errorCode == "NotFound") {
if ($conf->consortiumSupport && !$this->getUser()) {
//consortium support is turned on but user is not logged in;
//if the title is not found it probably means that it's only
//available to some users.
// consortium support is turned on but user is not logged in;
// if the title is not found it probably means that it's only
// available to some users.
$result->status = true;
$result->code = 'od_code_login_for_avail';
} else {
......@@ -303,8 +303,8 @@ class OverdriveConnector implements LoggerAwareInterface,
$loginRequired = true;
}
$collectionToken = $this->getCollectionToken();
//hmm. no token. if user is logged in let's check access
if (!$collectionToken && $user = $this->getUser()) {
// hmm. no token. if user is logged in let's check access
if (!$collectionToken && $this->getUser()) {
$accessResult = $this->getAccess();
if (!$accessResult->status) {
return $accessResult;
......@@ -321,10 +321,10 @@ class OverdriveConnector implements LoggerAwareInterface,
} else {
if ($res->errorCode == "NotFound" || $res->totalItems == 0) {
if ($loginRequired) {
//consortium support is turned on but user is
//not logged in
//if the title is not found it could mean that it's only
//available to some users.
// consortium support is turned on but user is
// not logged in
// if the title is not found it could mean that it's only
// available to some users.
$result->status = true;
$result->code = 'od_code_login_for_avail';
} else {
......@@ -337,7 +337,7 @@ class OverdriveConnector implements LoggerAwareInterface,
$this->debug("item:" . print_r($item, true));
$result->data[strtolower($item->reserveId)] = $item;
}
//now look for items not returned
// now look for items not returned
foreach ($overDriveIds as $id) {
if (!isset($result->data[$id])) {
if ($loginRequired) {
......@@ -451,7 +451,7 @@ class OverdriveConnector implements LoggerAwareInterface,
$result->status = true;
$result->data->expires = $expires;
$result->data->formats = $response->formats;
//add the checkout to the session cache
// add the checkout to the session cache
$this->getSessionContainer()->checkouts[] = $response;
} else {
$result->msg = $response->message;
......@@ -526,7 +526,6 @@ class OverdriveConnector implements LoggerAwareInterface,
{
$holdResult = $this->getResultObject();
$this->debug("OverdriveConnector: cancelHold");
//$this->debug(print_r($user,true));
if (!$user = $this->getUser()) {
$this->error("user is not logged in", false, true);
return $holdResult;
......@@ -538,7 +537,7 @@ class OverdriveConnector implements LoggerAwareInterface,
"DELETE"
);
//because this is a DELETE Call, we are just looking for a boolean
// because this is a DELETE Call, we are just looking for a boolean
if ($response) {
$holdResult->status = true;
} else {
......@@ -559,7 +558,6 @@ class OverdriveConnector implements LoggerAwareInterface,
public function returnResource($resourceID)
{
$result = $this->getResultObject();
//$this->debug(print_r($user,true));
if (!$user = $this->getUser()) {
$this->error("user is not logged in", false, true);
return $result;
......@@ -571,7 +569,7 @@ class OverdriveConnector implements LoggerAwareInterface,
$user["cat_password"], $url, null, "DELETE"
);
//because this is a DELETE Call, we are just looking for a boolean
// because this is a DELETE Call, we are just looking for a boolean
if ($response) {
$result->status = true;
} else {
......@@ -596,23 +594,22 @@ class OverdriveConnector implements LoggerAwareInterface,
$this->debug("getDownloadLink: id: $overDriveId, $format");
$result = $this->getResultObject();
$downloadLink = false;
//$this->debug(print_r($user,true));
if (!$user = $this->getUser()) {
$this->error("user is not logged in", false, true);
return $result;
}
$checkout = $this->getCheckout($overDriveId, false);
//either they are requesting a format that is always avail
//or it is locked in and they are requesting the format that
//is already locked in.
// either they are requesting a format that is always avail
// or it is locked in and they are requesting the format that
// is already locked in.
if ($template = $this->getLinkTemplate($checkout, $format)) {
$this->debug("template: " . print_r($template, true));
$downloadLink = $template->downloadLinkV2->href;
$this->debug("found the link: $downloadLink");
} elseif (!$checkout->isFormatLockedIn) {
//if we get this far, and the checkout is not locked in, then we should
//lock it in and try again
// if we get this far, and the checkout is not locked in, then we should
// lock it in and try again
$lockinResult = $this->lockinResource($overDriveId, $format);
if ($lockinResult->status) {
......@@ -623,9 +620,9 @@ class OverdriveConnector implements LoggerAwareInterface,
$result->msg = $lockinResult->msg;
}
} else {
//the checkout is locked in but we didn't find the template
//for this format, means that they are requesting the wrong
//format for the locked-in resource.
// the checkout is locked in but we didn't find the template
// for this format, means that they are requesting the wrong
// format for the locked-in resource.
$result->msg
= "The title appears to be already locked in for a different format";
$result->status = false;
......@@ -699,7 +696,7 @@ class OverdriveConnector implements LoggerAwareInterface,
$this->error("user is not logged in", false, true);
return $result;
}
//shouldn't need to refresh. This should be in the cache if it exists
// shouldn't need to refresh. This should be in the cache if it exists
$checkout = $this->getCheckout($overDriveId, false);
if (!$checkout) {
$result->msg
......@@ -708,9 +705,8 @@ class OverdriveConnector implements LoggerAwareInterface,
$this->debug("title not checked out.");
return $result;
}
//doublecheck this format is an option.
// doublecheck this format is an option.
$availableFormats = [];
//$params = array();
foreach ($checkout->actions->format->fields as $field) {
if ($field->name == 'formatType') {
$availableFormats = $field->options;
......@@ -933,9 +929,8 @@ class OverdriveConnector implements LoggerAwareInterface,
*/
public function getCheckouts($refresh = true)
{
//the checkouts are cached in the session, but we can force a refresh
// the checkouts are cached in the session, but we can force a refresh
$this->debug("get Overdrive Checkouts");
// $this->debug(print_r($user,true));
$result = $this->getResultObject();
if (!$user = $this->getUser()) {
......@@ -956,7 +951,7 @@ class OverdriveConnector implements LoggerAwareInterface,
$result->status = true;
$result->message = '';
$result->data = $response->checkouts;
//Convert dates to desired format
// Convert dates to desired format
foreach ($response->checkouts as $key => $checkout) {
$coExpires = new \DateTime($checkout->expires);
$result->data[$key]->expires = $coExpires->format(
......@@ -971,7 +966,6 @@ class OverdriveConnector implements LoggerAwareInterface,
} else {
$accessResult = $this->getAccess();
return $accessResult;
//$result->code = 'od_code_connection_failed';
}
}
} else {
......@@ -1017,13 +1011,13 @@ class OverdriveConnector implements LoggerAwareInterface,
$result->status = true;
$result->message = 'hold_place_success_html';
$result->data = $response->holds;
//Check for holds ready for chechout
// Check for holds ready for chechout
foreach ($response->holds as $key => $hold) {
if (!$hold->autoCheckout
&& $hold->holdListPosition == 1
) {
$result->data[$key]->holdReadyForCheckout = true;
//format the expires date.
// format the expires date.
$holdExpires = new \DateTime($hold->holdExpires);
$result->data[$key]->holdExpires
= $holdExpires->format(
......@@ -1088,7 +1082,7 @@ class OverdriveConnector implements LoggerAwareInterface,
$client->setMethod($requestType);
$client->setUri($url);
try {
//throw new Exception('testException');
// throw new Exception('testException');
$response = $client->send();
} catch (Exception $ex) {
$this->error(
......@@ -1115,7 +1109,7 @@ class OverdriveConnector implements LoggerAwareInterface,
);
if ($returnVal != null) {
if (isset($returnVal->errorCode)) {
//In some cases, this should be returned perhaps...
// In some cases, this should be returned perhaps...
$this->error("Overdrive Error: " . $returnVal->errorCode);
return $returnVal;
} else {
......@@ -1190,7 +1184,7 @@ class OverdriveConnector implements LoggerAwareInterface,
);
if ($tokenData != null) {
if (isset($tokenData->errorCode)) {
//In some cases, this should be returned perhaps...
// In some cases, this should be returned perhaps...
$this->error("Overdrive Error: " . $tokenData->errorCode);
return false;
} else {
......@@ -1276,8 +1270,8 @@ class OverdriveConnector implements LoggerAwareInterface,
}
$body = $response->getBody();
//if all goes well for DELETE, the code will be 204
//and response is empty.
// if all goes well for DELETE, the code will be 204
// and response is empty.
if ($requestType == "DELETE") {
if ($response->getStatusCode() == 204) {
$this->debug("DELETE Patron call appears to have worked.");
......@@ -1386,10 +1380,10 @@ class OverdriveConnector implements LoggerAwareInterface,
$patronTokenData, true
)
);
//if we have an unauthorized error, then we are going
//to cache that in the session so we don't keep making
//unnecessary calls, otherwise, just don't store the tokenData
//object so that it gets checked again next time
// if we have an unauthorized error, then we are going
// to cache that in the session so we don't keep making
// unnecessary calls, otherwise, just don't store the tokenData
// object so that it gets checked again next time
if ($patronTokenData->error == 'unauthorized_client') {
$this->getSessionContainer()->odAccessMessage
= $patronTokenData->error_description;
......@@ -1423,7 +1417,7 @@ class OverdriveConnector implements LoggerAwareInterface,
}
if (!$this->client) {
$this->client = $this->httpService->createClient($url);
//set keep alive to true since we are sending to the same server
// set keep alive to true since we are sending to the same server
$this->client->setOptions(['keepalive', true]);
}
$this->client->resetParameters();
......
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