Browse Source

no guest access

2.x
Paul Pound 2 years ago
parent
commit
0b52c19cd3
  1. 6
      modules/roblib_search_eds/src/Controller/RoblibSearchEdsController.php
  2. 32
      modules/roblib_search_eds/src/Lib/EBSCOConnector.php

6
modules/roblib_search_eds/src/Controller/RoblibSearchEdsController.php

@ -16,7 +16,7 @@ class RoblibSearchEdsController extends ControllerBase {
*/
public function articleResults($query = NULL) {
print $this->eds_get_results($query, 'Articles');
exit();
exit();
}
/**
@ -63,7 +63,7 @@ class RoblibSearchEdsController extends ControllerBase {
$search = array('lookfor' => $query, 'type' => 'ALLFields', 'index' => 'AllFields', 'q' => 'ebsco/results', 'op' => 'Search');
$eds_api = new EBSCOAPI($eds_config);
$is_local_ip = $eds_api->connector()->isGuestIPAddress($_SERVER["REMOTE_ADDR"]);
$eds_api->isGuest(!$is_local_ip);
$eds_api->isGuest(FALSE);
$output = $eds_api->apiSearch($search, $filters, 1, $number_per_page);
$output['is_local_ip'] = $is_local_ip;
@ -103,7 +103,7 @@ class RoblibSearchEdsController extends ControllerBase {
$ebsco_config['user'] = $roblib_search_config->get('eds_user');
$ebsco_config['password'] = $roblib_search_config->get('eds_pass');
//get the local ips allowed from ebsco
//TODO move this to a variable
//TODO move this to a variable
$ebsco_config['local_ip_address'] = $roblib_search_config->get('eds_local_ip');
$ebsco_config['profile'] = ($type === 'Books') ? $roblib_search_config->get
('eds_book_profile') : $roblib_search_config->get('eds_article_profile');

32
modules/roblib_search_eds/src/Lib/EBSCOConnector.php

@ -214,9 +214,9 @@ class EBSCOConnector {
$this->autoComplete = $config['autocomplete'];
$this->orgId = $config['organization'];
$this->local_ip_address = $config['local_ip_address'];
$this->isGuest = (\Drupal::currentUser()->isAuthenticated() || $this->isGuestIPAddress($_SERVER["REMOTE_ADDR"])) ? 'n' : 'y';
$this->isGuest = 'n';
$this->logAPIRequests = ($config['log'] == 1);
}
/**
@ -381,12 +381,12 @@ class EBSCOConnector {
public function requestCitationStyles($params, $headers) {
$url = self::$end_point . '/CitationStyles';
$responseCitation = $this->request($url, $params, $headers);
$response = $responseCitation->Citations;
return $response;
}
@ -405,7 +405,7 @@ class EBSCOConnector {
public function requestInfo($params, $headers) {
$url = self::$end_point . '/Info';
$response = $this->request($url, $params, $headers);
return $response;
}
@ -441,34 +441,34 @@ class EBSCOConnector {
$data=$params;
// Send the request.
$response=null;
try {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_MAXREDIRS, 10 );
curl_setopt($curl, CURLOPT_MAXREDIRS, 10 );
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
switch ($method)
{
case 'GET':
if ($data) { $url = sprintf('%s?%s', $url, http_build_query($data)); }
curl_setopt($curl, CURLOPT_URL, $url);
break;
case 'POST':
if ($data) {
if ($data) {
curl_setopt($curl,CURLOPT_POST, 1);
curl_setopt($curl,CURLOPT_POSTFIELDS, $data);
}
}
break;
case 'DELETE':
if ($data) {
if ($data) {
if (count($headers)>0) {
curl_setopt($curl,CURLOPT_HTTPHEADER, $headers);
}
@ -476,12 +476,12 @@ class EBSCOConnector {
}
break;
}
$response = curl_exec($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
switch ($code) {
case self::HTTP_OK:

Loading…
Cancel
Save