Grima  2018-08
Whispering into Alma's ear
Public Member Functions | Public Attributes | List of all members
Grima Class Reference

grima-lib.php - a library for running API calls in Alma More...

Public Member Functions

  session_init ( $force=false)
 
  session_save ($result)
 
  session_destroy ()
 
  __construct ()
 
  request ($method, $url, $URLparams, $QSparams, $body=null)
  general function for REST API calls More...
 
  get ($url, $URLparams, $QSparams)
  general function for GET (retrieve) API calls More...
 
  post ($url, $URLparams, $QSparams, $body)
  general function for POST (create) API calls More...
 
  put ($url, $URLparams, $QSparams, $body)
  general function for PUT (update) API calls More...
 
  delete ($url, $URLparams, $QSparams)
  general function for DELETE API calls More...
 
  checkForErrorMessage ($xml)
  checks for errorMessage tag, throws exceptions More...
 
Bib APIs
  getBib ($mms_id, $view='full', $expand='None')
  Retrieve Bib - retrieve a bib record from Alma. More...
 
  postBib ($bib)
  Create Record - adds a new bib record to Alma. More...
 
  putBib ($mms_id, $bib)
  Update Bib Record - updates the copy of the bib in Alma. More...
 
  deleteBib ($mms_id, $override='false')
  Delete Bib Record - deletes the bib record from Alma. More...
 
Holdings List APIs
  getHoldingsList ($mms_id)
  Retrieve Holdings list - download brief descriptions of holdings for the bib. More...
 
Holding APIs
  getHolding ($mms_id, $holding_id)
  Retrieve Holdings Record - retrieve holdings record from Alma. More...
 
  postHolding ($mms_id, $holding)
  Create holding record - add a new holdings record to a bib. More...
 
  putHolding ($mms_id, $holding_id, $holding)
  Update Holdings Record - replace the holdings record in Alma. More...
 
  deleteHolding ($mms_id, $holding_id, $override='false')
  Delete Holdings Record - delete the holdings record from Alma. More...
 
Item List APIs
  getItemList ($mms_id, $holding_id, $limit, $offset)
  Retrieve Items list - retrieve the items list from a holding or bib from Alma. More...
 
Item APIs
  getItem ($mms_id, $holding_id, $item_pid)
  Retrieve Item and print label information. More...
 
  getItemBC ($barcode)
  Retrieve Item and print label information (by barcode)) More...
 
  postItem ($mms_id, $holding_id, $item)
  Create Item - add a new item to a holding in Alma. More...
 
  putItem ($mms_id, $holding_id, $item_pid, $item)
  Update Item information - replace item record in Alma. More...
 
  deleteItem ($mms_id, $holding_id, $item_pid, $override="false", $holdings="retain")
  Withdraw Item - delete an item record from Alma. More...
 
Electronic APIs
  getElectronicPortfolio ($collection_id, $service_id, $portfolio_id)
  Retrieve Portfolio - retrieve a portfolio record from Alma. More...
 
  getElectronicPortfolioFromBib ($mms_id, $portfolio_id)
  Retrieve Portfolio - retrieve a portfolio record from Alma. More...
 
  postElectronicPortfolio ($collection_id, $service_id, $portfolio)
  Create Electronic Portfolio - add a new portfolio to Alma. More...
 
  postElectronicPortfolioOnBib ($mms_id, $portfolio, $update=true)
  Create Electronic Portfolio - add a new portfolio to Alma Bib. More...
 
  putElectronicPortfolioOnBib ($mms_id, $portfolio_id, $portfolio)
  Update Electronic Portfolio - update portfolio in Alma. More...
 
  deleteElectronicPortfolio ($collection_id, $service_id, $portfolio_id)
  Delete Electronic Portfolio - delete portfolio from Alma. More...
 
  getElectronicPortfoliosForService ($collection_id, $service_id, $limit, $offset)
  Retrieve Portfolios - retrieve a list of portfolios from Alma. More...
 
  getElectronicPortfoliosForBib ($mms_id, $limit, $offset)
  Retrieve Portfolios list (Bib) - retrieve a list of portfolios from Alma. More...
 
  getElectronicCollection ($collection_id)
  Retrieve Electronic Collection - retrieve a collection record from Alma. More...
 
  putElectronicCollection ($collection_id, $collection)
  Update Electronic Collection Record - updates the copy of the collection in Alma. More...
 
  getElectronicServices ($collection_id)
  Retrieve Electronic Services - retrieve a list of services from a collection in Alma. More...
 
Library APIs
  getLibrary ($libraryCode)
  Retrieve a Library - retrieve a Library from Alma. More...
 
  getAllLibraries ()
  Retrieve Libraries - retrieve all libraries. More...
 
  getAllLocations ($libraryCode)
  Retrieve Locations - retrieve all locations in a library. More...
 
Location APIs
  getLocation ($libraryCode, $locationCode)
  Retrieve Location - retrieve a Library Location from Alma. More...
 
Set APIs
  getSet ($set_id)
  Retrieve a Set - retrieve a Set from Alma. More...
 
  postSet ($set)
  Create a Set - add a new set to Alma. More...
 
  postSetManageMembers ($set_id, $id_type, $op, $set)
  Manage Members - modify sets in Alma. More...
 
  createSetFromImport ($job_instance_id, $population)
  Create a Set from an import job. More...
 
  deleteSet ($set_id)
  Delete a Set - delete a set (not its items) from Alma. More...
 
  getSetMembers ($set_id, $limit=10, $offset=0)
  get the members of a set, IF IT WORKS?!?! More...
 
Analytics APIs
  getAnalytics ($path, $filter, $limit=25, $token=null)
 
Job APIs
  postJob ($job_id, $op, $job)
  Submit a manual or scheduled job. More...
 

Public Attributes

  $server
 
  $apikey
 

Detailed Description

grima-lib.php - a library for running API calls in Alma

(c) 2019 Kathryn Lybarger. CC-BY-SA

Definition at line 15 of file grima-lib.php.

Constructor & Destructor Documentation

◆ __construct()

Grima::__construct ( )

Definition at line 83 of file grima-lib.php.

References $apikey, $server, getenvWithFileFallbackAndDefault(), and session_init().

83  {
84 
85  $this->session_init();
86 
87  $this->apikey =
88  isset($_REQUEST['apikey']) && $_REQUEST['apikey'] ? $_REQUEST['apikey'] : (
89  isset($_SESSION['apikey']) && $_SESSION['apikey'] ? $_SESSION['apikey'] : (
90  getenvWithFileFallbackAndDefault('apikey','') ) );
91 
92  $this->server =
93  isset($_REQUEST['server']) && $_REQUEST['server'] ? $_REQUEST['server'] : (
94  isset($_SESSION['server']) && $_SESSION['server'] ? $_SESSION['server'] : (
95  getenvWithFileFallbackAndDefault('server','') ) );
96 
97  if (strlen($this->server)==2) {
98  $this->server = "https://api-" . $this->server . ".hosted.exlibrisgroup.com";
99  }
100 
101  if (!preg_match('!https://api-[a-z]*\.hosted\.exlibrisgroup\.com!',$this->server)) {
102  $this->server = "";
103  }
104 
105  if ($this->apikey=='EDITME') {
106  $this->apikey = "";
107  }
108 
109  if ($this->apikey && $this->server) {
110  $_SESSION['apikey'] = $this->apikey;
111  $_SESSION['server'] = $this->server;
112  }
113 
114  session_write_close();
115 
116  return false;
117  }
$apikey
Definition: grima-lib.php:17
$server
Definition: grima-lib.php:16
session_init( $force=false)
Definition: grima-lib.php:21
getenvWithFileFallbackAndDefault( $env_name, $default=false)
Definition: grima-util.php:52

Member Function Documentation

◆ checkForErrorMessage()

Grima::checkForErrorMessage (   $xml )

checks for errorMessage tag, throws exceptions

Parameters
DomDocument $xml

Definition at line 288 of file grima-lib.php.

Referenced by createSetFromImport(), deleteBib(), deleteElectronicPortfolio(), deleteHolding(), deleteItem(), deleteSet(), getAllLibraries(), getAllLocations(), getBib(), getElectronicCollection(), getElectronicPortfolio(), getElectronicPortfolioFromBib(), getElectronicPortfoliosForBib(), getElectronicPortfoliosForService(), getElectronicServices(), getHolding(), getHoldingsList(), getItem(), getItemBC(), getItemList(), getLibrary(), getLocation(), getSet(), getSetMembers(), postBib(), postElectronicPortfolio(), postElectronicPortfolioOnBib(), postHolding(), postItem(), postJob(), postSet(), postSetManageMembers(), putBib(), putElectronicCollection(), and putElectronicPortfolioOnBib().

288  {
289  if ($xml instanceOf DomDocument) {
290  $xpath = new DomXpath($xml);
291  $xpath->registerNamespace("err","http://com/exlibris/urm/general/xmlbeans");
292  $error = $xpath->query('//err:errorMessage');
293  if ($error->length > 0) {
294  throw new Exception("Alma says: " . $error[0]->nodeValue);
295  }
296  }
297  }

◆ createSetFromImport()

Grima::createSetFromImport (   $job_instance_id,
  $population 
)

Create a Set from an import job.

Makes a call to the API: (API docs)

POST /almaws/v1/conf/sets
Parameters
string $job_instance_id ID of the import job
string $population ...
Returns
DomDocument Set object

Definition at line 1161 of file grima-lib.php.

References checkForErrorMessage(), and post().

1161  {
1162  # create blank set
1163 
1164  $body = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?' . '>
1165 <set>
1166  <name>Grima set from ' . $job_instance_id . '</name>
1167  <description>members of ' . $job_instance_id . '</description>
1168  <type desc="Itemized">ITEMIZED</type>
1169  <content desc="All Titles">BIB_MMS</content>
1170  <private desc="No">false</private>
1171 </set>';
1172 
1173 /*
1174  Content:
1175  BIB_MMS -- all titles
1176  ITEM
1177  PORTFOLIO
1178  IEPA
1179  FILE
1180  AUTHORITY_MMS
1181  IEP
1182  IEE
1183  IED
1184  IEC
1185 */
1186 
1187 /*
1188  Population:
1189 */
1190 
1191  $bodyxml = new DomDocument();
1192  $bodyxml->loadXML($body);
1193 
1194  $ret = $this->post('/almaws/v1/conf/sets', array(), array('job_instance_id' => $job_instance_id, 'population' => $population),$bodyxml);
1195  $this->checkForErrorMessage($ret);
1196  return $ret;
1197 
1198  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288
post($url, $URLparams, $QSparams, $body)
general function for POST (create) API calls
Definition: grima-lib.php:249

◆ delete()

Grima::delete (   $url,
  $URLparams,
  $QSparams 
)

general function for DELETE API calls

Parameters
string $url - URL pattern string with parameters in {}
array $URLparams - URL parameters
array $QSparams - query string parameters
Returns
null|DomDocument - usually return nothing, but return the error document on error

Definition at line 278 of file grima-lib.php.

References request().

278  {
279  return $this->request("DELETE",$url,$URLparams,$QSparams,null);
280  }
request($method, $url, $URLparams, $QSparams, $body=null)
general function for REST API calls
Definition: grima-lib.php:135

◆ deleteBib()

Grima::deleteBib (   $mms_id,
  $override = 'false' 
)

Delete Bib Record - deletes the bib record from Alma.

Makes a call to the API: (API docs)

DELETE /almaws/v1/bibs/{mms_id}
Parameters
string $mms_id MMS ID of Alma Bib record to delete
string $override Optional. Default=false

Definition at line 389 of file grima-lib.php.

References checkForErrorMessage().

389  {
390  $ret = $this->delete('/almaws/v1/bibs/{mms_id}',
391  array('mms_id' => $mms_id),
392  array('override' => $override)
393  );
394  $this->checkForErrorMessage($ret);
395  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ deleteElectronicPortfolio()

Grima::deleteElectronicPortfolio (   $collection_id,
  $service_id,
  $portfolio_id 
)

Delete Electronic Portfolio - delete portfolio from Alma.

Makes a call to the API: (API docs)

   DELETE /almaws/v1/electronic/e-collections/{collection_id}/e-services/{service_id}/portfolios/{portfolio_id}
Parameters
string $collection_id ID of collection
string $service_id ID of service
string $portfolio_id ID of portfolio

Definition at line 842 of file grima-lib.php.

References checkForErrorMessage().

842  {
843  $ret = $this->delete('/almaws/v1/electronic/e-collections/{collection_id}/e-services/{service_id}/portfolios/{portfolio_id}',
844  array('collection_id' => $collection_id, 'service_id' => $service_id, 'portfolio_id' => $portfolio_id),
845  array()
846  );
847  $this->checkForErrorMessage($ret);
848  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ deleteHolding()

Grima::deleteHolding (   $mms_id,
  $holding_id,
  $override = 'false' 
)

Delete Holdings Record - delete the holdings record from Alma.

Makes a call to the API: (API docs)

DELETE /almaws/v1/bibs/{mms_id}/holdings/{holding_id}
Parameters
string $mms_id MMS ID of Alma Bib record
string $holding_id Holding ID of Holding record to delete from Alma
string $override Optional. Default=false

Definition at line 521 of file grima-lib.php.

References checkForErrorMessage().

521  {
522  $ret = $this->delete('/almaws/v1/bibs/{mms_id}/holdings/{holding_id}',
523  array(
524  'mms_id' => $mms_id,
525  'holding_id' => $holding_id
526  ),
527  array('override' => $override)
528  );
529  $this->checkForErrorMessage($ret);
530  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ deleteItem()

Grima::deleteItem (   $mms_id,
  $holding_id,
  $item_pid,
  $override = "false",
  $holdings = "retain" 
)

Withdraw Item - delete an item record from Alma.

Makes a call to the API: (API docs)

DELETE /almaws/v1/bibs/{mms_id}/holdings/{holding_id}/items/{item_pid}
Parameters
string $mms_id MMS ID of Bib record
string $holding_id Holding ID of holding record
string $item_pid Item ID of item record
string $override Override warnings? (false, true)
string $holdings How to handle holdings with inventory? (retain, delete or suppress)

Definition at line 685 of file grima-lib.php.

References checkForErrorMessage().

686  {
687  $ret = $this->delete('/almaws/v1/bibs/{mms_id}/holdings/{holding_id}/items/{item_pid}', array(
688  'mms_id' => $mms_id,
689  'holding_id' => $holding_id,
690  'item_pid' => $item_pid
691  ), array(
692  'override' => $override,
693  'holdings' => $holdings
694  )
695  );
696  $this->checkForErrorMessage($ret);
697  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ deleteSet()

Grima::deleteSet (   $set_id )

Delete a Set - delete a set (not its items) from Alma.

Makes a call to the API: (API docs)

DELETE /almaws/v1/conf/sets/{set_id}
Parameters
string $set_id Set ID

Definition at line 1212 of file grima-lib.php.

References checkForErrorMessage().

1212  {
1213  $ret = $this->delete('/almaws/v1/conf/sets/{set_id}',
1214  array(
1215  'set_id' => $set_id,
1216  ),
1217  array()
1218  );
1219  $this->checkForErrorMessage($ret);
1220  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ get()

Grima::get (   $url,
  $URLparams,
  $QSparams 
)

general function for GET (retrieve) API calls

Parameters
string $url - URL pattern string with parameters in {}
array $URLparams - URL parameters
array $QSparams - query string parameters
Returns
DomDocument of requested record

Definition at line 234 of file grima-lib.php.

References request().

234  {
235  return $this->request("GET",$url,$URLparams,$QSparams,null);
236  }
request($method, $url, $URLparams, $QSparams, $body=null)
general function for REST API calls
Definition: grima-lib.php:135

◆ getAllLibraries()

Grima::getAllLibraries ( )

Retrieve Libraries - retrieve all libraries.

Makes a call to the API: (API docs)

GET /almaws/v1/conf/libraries
Returns
DomDocument Libraries object

Definition at line 1009 of file grima-lib.php.

References checkForErrorMessage().

1009  {
1010  $ret = $this->get('/almaws/v1/conf/libraries',
1011  array(),
1012  array()
1013  );
1014  $this->checkForErrorMessage($ret);
1015  return $ret;
1016  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ getAllLocations()

Grima::getAllLocations (   $libraryCode )

Retrieve Locations - retrieve all locations in a library.

Makes a call to the API: (API docs)

GET /almaws/v1/conf/libraries/{libraryCode}/locations
Returns
DomDocument Locations object

Definition at line 1030 of file grima-lib.php.

References checkForErrorMessage().

1030  {
1031  $ret = $this->get('/almaws/v1/conf/libraries/{libraryCode}/locations',
1032  array('libraryCode' => $libraryCode),
1033  array()
1034  );
1035  $this->checkForErrorMessage($ret);
1036  return $ret;
1037  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ getAnalytics()

Grima::getAnalytics (   $path,
  $filter,
  $limit = 25,
  $token = null 
)

Definition at line 1254 of file grima-lib.php.

1254  {
1255  return $this->get('/almaws/v1/analytics/reports',
1256  array(),
1257  array('path' => urlencode($path), 'filter' => urlencode($filter),
1258  'limit' => $limit, 'token' => $token)
1259  );
1260  }

◆ getBib()

Grima::getBib (   $mms_id,
  $view = 'full',
  $expand = 'None' 
)

Retrieve Bib - retrieve a bib record from Alma.

Makes a call to the API: (API docs)

GET /almaws/v1/bibs/{mms_id}
Parameters
string $mms_id The Bib Record ID.
string $view Optional. Default=full
string $expand Optional. Default=None
Returns
DomDocument Bib object https://developers.exlibrisgroup.com/alma/apis/xsd/rest_bib.xsd?tags=GET

Definition at line 320 of file grima-lib.php.

References checkForErrorMessage().

320  {
321  $ret = $this->get('/almaws/v1/bibs/{mms_id}',
322  array('mms_id' => $mms_id),
323  array('view' => $view, 'expand' => $expand)
324  );
325  $this->checkForErrorMessage($ret);
326  return $ret;
327  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ getElectronicCollection()

Grima::getElectronicCollection (   $collection_id )

Retrieve Electronic Collection - retrieve a collection record from Alma.

Makes a call to the API: (API docs)

GET /almaws/v1/electronic/e-collections/{collection_id}
Parameters
string $collection_id ID of collection
Returns
DomDocument Electronic Collection object

Definition at line 912 of file grima-lib.php.

References checkForErrorMessage().

912  {
913  $ret = $this->get('/almaws/v1/electronic/e-collections/{collection_id}',
914  array('collection_id' => $collection_id),
915  array()
916  );
917  $this->checkForErrorMessage($ret);
918  return $ret;
919  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ getElectronicPortfolio()

Grima::getElectronicPortfolio (   $collection_id,
  $service_id,
  $portfolio_id 
)

Retrieve Portfolio - retrieve a portfolio record from Alma.

Makes a call to the API: (API docs)

GET /almaws/v1/electronic/e-collections/{collection_id}/e-services/{service_id}/portfolios/{portfolio_id}
Parameters
string $collection_id ID of collection
string $service_id ID of service
string $portfolio_id ID of portfolio
Returns
DomDocument Electronic Portfolio object

Definition at line 721 of file grima-lib.php.

References checkForErrorMessage().

721  {
722  $ret = $this->get('/almaws/v1/electronic/e-collections/{collection_id}/e-services/{service_id}/portfolios/{portfolio_id}',
723  array('collection_id' => $collection_id, 'service_id' => $service_id, 'portfolio_id' => $portfolio_id),
724  array()
725  );
726  $this->checkForErrorMessage($ret);
727  return $ret;
728  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ getElectronicPortfolioFromBib()

Grima::getElectronicPortfolioFromBib (   $mms_id,
  $portfolio_id 
)

Retrieve Portfolio - retrieve a portfolio record from Alma.

Makes a call to the API: (API docs)

GET /almaws/v1/bibs/{mms_id}/portfolios/{portfolio_id}

Parameters
string $mms_id ID of bib record
string $portfolio_id ID of portfolio
Returns
DomDocument Electronic Portfolio object

Definition at line 744 of file grima-lib.php.

References checkForErrorMessage().

744  {
745  $ret = $this->get('/almaws/v1/bibs/{mms_id}/portfolios/{portfolio_id}',
746  array('mms_id' => $mms_id, 'portfolio_id' => $portfolio_id),
747  array()
748  );
749  $this->checkForErrorMessage($ret);
750  return $ret;
751  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ getElectronicPortfoliosForBib()

Grima::getElectronicPortfoliosForBib (   $mms_id,
  $limit,
  $offset 
)

Retrieve Portfolios list (Bib) - retrieve a list of portfolios from Alma.

Makes a call to the API: (API docs)

GET /almaws/v1/bibs/{mms_id}/portfolios
Parameters
string $mms_id ID of bib
string $limit Max number of portfolios to retrieve
string $offset Offset of the results
Returns
DomDocument Portfolios List object

Definition at line 890 of file grima-lib.php.

References checkForErrorMessage().

890  {
891  $ret = $this->get('/almaws/v1/bibs/{mms_id}/portfolios',
892  array('mms_id' => $mms_id),
893  array('limit' => $limit, $offset = $offset)
894  );
895  $this->checkForErrorMessage($ret);
896  return $ret;
897  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ getElectronicPortfoliosForService()

Grima::getElectronicPortfoliosForService (   $collection_id,
  $service_id,
  $limit,
  $offset 
)

Retrieve Portfolios - retrieve a list of portfolios from Alma.

Makes a call to the API: (API docs)

GET /almaws/v1/electronic/e-collections/{collection_id}/e-services/{service_id}/portfolios
Parameters
string $collection_id ID of collection
string $service_id ID of service
string $limit Max number of portfolios to retrieve
string $offset Offset of the results
Returns
DomDocument Retrieve Portfolios object

Definition at line 866 of file grima-lib.php.

References checkForErrorMessage().

866  {
867  $ret = $this->get('/almaws/v1/electronic/e-collections/{collection_id}/e-services/{service_id}/portfolios',
868  array('collection_id' => $collection_id, 'service_id' => $service_id),
869  array('limit' => $limit, $offset = $offset)
870  );
871  $this->checkForErrorMessage($ret);
872  return $ret;
873  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ getElectronicServices()

Grima::getElectronicServices (   $collection_id )

Retrieve Electronic Services - retrieve a list of services from a collection in Alma.

Makes a call to the API: (API docs)

GET /almaws/v1/electronic/e-collections/{collection_id}/e-services
Parameters
string $collection_id ID of collection
Returns
DomDocument Services object

Definition at line 959 of file grima-lib.php.

References checkForErrorMessage().

959  {
960  $ret = $this->get('/almaws/v1/electronic/e-collections/{collection_id}/e-services',
961  array('collection_id' => $collection_id),
962  array()
963  );
964  $this->checkForErrorMessage($ret);
965  return $ret;
966  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ getHolding()

Grima::getHolding (   $mms_id,
  $holding_id 
)

Retrieve Holdings Record - retrieve holdings record from Alma.

Makes a call to the API: (API docs)

GET /almaws/v1/bibs/{mms_id}/holdings/{holding_id}
Parameters
string $mms_id MMS ID of Alma Bib
string $holding_id Holdings ID of Alma Holding
Returns
DomDocument Holding object

Definition at line 448 of file grima-lib.php.

References checkForErrorMessage().

448  {
449  $ret = $this->get('/almaws/v1/bibs/{mms_id}/holdings/{holding_id}',
450  array(
451  'mms_id' => $mms_id,
452  'holding_id' => $holding_id
453  ),
454  array()
455  );
456  $this->checkForErrorMessage($ret);
457  return $ret;
458  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ getHoldingsList()

Grima::getHoldingsList (   $mms_id )

Retrieve Holdings list - download brief descriptions of holdings for the bib.

Makes a call to the API: (API docs)

GET /almaws/v1/bibs/{mms_id}/holdings
Parameters
string $mms_id MMS ID of Alma Bib to gather holdings from
Returns
DomDocument Holdings List object

Definition at line 418 of file grima-lib.php.

References checkForErrorMessage().

Referenced by Bib\getHoldings(), and Bib\hasInventory().

418  {
419  $ret = $this->get('/almaws/v1/bibs/{mms_id}/holdings',
420  array('mms_id' => $mms_id),
421  array()
422  );
423  $this->checkForErrorMessage($ret);
424  return $ret;
425  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ getItem()

Grima::getItem (   $mms_id,
  $holding_id,
  $item_pid 
)

Retrieve Item and print label information.

Makes a call to the API: (API docs)

GET /almaws/v1/bibs/{mms_id}/holdings/{holding_id}/items/{item_pid}
Parameters
string $mms_id MMS ID of Alma Bib
string $holding_id Holding ID of Alma Holding
string $item_pid Item ID of Alma Holding

Definition at line 584 of file grima-lib.php.

References checkForErrorMessage().

584  {
585  $ret = $this->get('/almaws/v1/bibs/{mms_id}/holdings/{holding_id}/items/{item_pid}', array(
586  'mms_id' => $mms_id,
587  'holding_id' => $holding_id,
588  'item_pid' => $item_pid
589  ),
590  array()
591  );
592  $this->checkForErrorMessage($ret);
593  return $ret;
594  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ getItemBC()

Grima::getItemBC (   $barcode )

Retrieve Item and print label information (by barcode))

Makes a call to the API: (API docs)

GET /almaws/v1/items?item_barcode={item_barcode}
Parameters
string $barcode Barcode of Alma item

Definition at line 608 of file grima-lib.php.

References checkForErrorMessage().

608  {
609  $ret = $this->get('/almaws/v1/items',
610  array(),
611  array(
612  'item_barcode' => $barcode,
613  )
614  );
615  $this->checkForErrorMessage($ret);
616  return $ret;
617  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ getItemList()

Grima::getItemList (   $mms_id,
  $holding_id,
  $limit,
  $offset 
)

Retrieve Items list - retrieve the items list from a holding or bib from Alma.

Makes a call to the API: (API docs)

GET /almaws/v1/bibs/{mms_id}/holdings/{holding_id}/items
Parameters
string $mms_id MMS ID of Alma bib
string $holding_id MMS ID of Alma holding
string $limit Max number of items to retrieve
string $offset Offset of the results returned
Returns
DomDocument Item List object

Definition at line 555 of file grima-lib.php.

References checkForErrorMessage().

Referenced by Holding\deleteTreeFromAlma(), Bib\getItems(), Holding\getItems(), and Holding\hasItems().

555  {
556  $ret = $this->get('/almaws/v1/bibs/{mms_id}/holdings/{holding_id}/items', array('mms_id' => $mms_id, 'holding_id' => $holding_id),
557  array('limit' => $limit, 'offset' => $offset)
558  );
559  $this->checkForErrorMessage($ret);
560  return $ret;
561  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ getLibrary()

Grima::getLibrary (   $libraryCode )

Retrieve a Library - retrieve a Library from Alma.

Makes a call to the API: (API docs)

GET /almaws/v1/conf/libraries/{libraryCode}
Parameters
string $libraryCode ID of the library to retrieve
Returns
DomDocument Library object

Definition at line 988 of file grima-lib.php.

References checkForErrorMessage().

988  {
989  $ret = $this->get('/almaws/v1/conf/libraries/{libraryCode}',
990  array('libraryCode' => $libraryCode),
991  array()
992  );
993  $this->checkForErrorMessage($ret);
994  return $ret;
995  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ getLocation()

Grima::getLocation (   $libraryCode,
  $locationCode 
)

Retrieve Location - retrieve a Library Location from Alma.

Makes a call to the API: (API docs)

GET /almaws/v1/conf/libraries/{libraryCode}/locations/{locationCode}
Parameters
string $libraryCode ID of the library to retrieve
Returns
DomDocument Library object

Definition at line 1059 of file grima-lib.php.

References checkForErrorMessage().

1059  {
1060  $ret = $this->get('/almaws/v1/conf/libraries/{libraryCode}/locations/{locationCode}',
1061  array(
1062  'libraryCode' => $libraryCode,
1063  'locationCode' => $locationCode,
1064  ),
1065  array()
1066  );
1067  $this->checkForErrorMessage($ret);
1068  return $ret;
1069  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ getSet()

Grima::getSet (   $set_id )

Retrieve a Set - retrieve a Set from Alma.

Makes a call to the API: (API docs)

GET /almaws/v1/conf/sets/{set_id}
Parameters
string $set_id ID of the set to retrieve
Returns
DomDocument Set object

Definition at line 1091 of file grima-lib.php.

References checkForErrorMessage().

1091  {
1092  $ret = $this->get('/almaws/v1/conf/sets/{set_id}',
1093  array('set_id' => $set_id),
1094  array()
1095  );
1096  $this->checkForErrorMessage($ret);
1097  return $ret;
1098  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ getSetMembers()

Grima::getSetMembers (   $set_id,
  $limit = 10,
  $offset = 0 
)

get the members of a set, IF IT WORKS?!?!

Makes a call to the API: (API docs)

GET /almaws/v1/conf/sets/{set_id}/members
Parameters
string $set_id Set ID
number $limit How many to return at most (default 10)
number $offset Where to start from, for continuation (default 0, the beginning)

Definition at line 1236 of file grima-lib.php.

References checkForErrorMessage().

1236  {
1237  $ret = $this->get('/almaws/v1/conf/sets/{set_id}/members',
1238  array('set_id' => $set_id),
1239  array('limit' => $limit, 'offset' => $offset)
1240  );
1241  $this->checkForErrorMessage($ret);
1242  return $ret;
1243  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288

◆ post()

Grima::post (   $url,
  $URLparams,
  $QSparams,
  $body 
)

general function for POST (create) API calls

Parameters
string $url - URL pattern string with parameters in {}
array $URLparams - URL parameters
array $QSparams - query string parameters
DomDocument $body - object to add to Alma
Returns
DomDocument $body - object as it now appears in Alma

Definition at line 249 of file grima-lib.php.

References request().

Referenced by createSetFromImport(), postBib(), postElectronicPortfolio(), postElectronicPortfolioOnBib(), postHolding(), postItem(), postJob(), postSet(), and postSetManageMembers().

249  {
250  return $this->request("POST",$url,$URLparams,$QSparams,$body);
251  }
request($method, $url, $URLparams, $QSparams, $body=null)
general function for REST API calls
Definition: grima-lib.php:135

◆ postBib()

Grima::postBib (   $bib )

Create Record - adds a new bib record to Alma.

Makes a call to the API: (API docs)

POST /almaws/v1/bibs
https://developers.exlibrisgroup.com/alma/apis/bibs#Resources
Parameters
DomDocument $bib Bib object to add to Alma as new record
Returns
DomDocument Bib object as it now appears in Alma https://developers.exlibrisgroup.com/alma/apis/xsd/rest_bib.xsd?tags=GET

Definition at line 342 of file grima-lib.php.

References checkForErrorMessage(), and post().

342  {
343  $ret = $this->post('/almaws/v1/bibs',
344  array(),
345  array(),
346  $bib
347  );
348  $this->checkForErrorMessage($ret);
349  return $ret;
350  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288
post($url, $URLparams, $QSparams, $body)
general function for POST (create) API calls
Definition: grima-lib.php:249

◆ postElectronicPortfolio()

Grima::postElectronicPortfolio (   $collection_id,
  $service_id,
  $portfolio 
)

Create Electronic Portfolio - add a new portfolio to Alma.

Makes a call to the API: (API docs)

POST /almaws/v1/electronic/e-collections/{collection_id}/e-services/{service_id}/portfolios/
Parameters
string $collection_id ID of collection
string $service_id ID of service
string $portfolio A portfolio object to add to Alma
Returns
DomDocument Electronic Portfolio object as it appears in Alma

Definition at line 768 of file grima-lib.php.

References checkForErrorMessage(), and post().

768  {
769  $ret = $this->post('/almaws/v1/electronic/e-collections/{collection_id}/e-services/{service_id}/portfolios',
770  array('collection_id' => $collection_id, 'service_id' => $service_id),
771  array(),
772  $portfolio
773  );
774  $this->checkForErrorMessage($ret);
775  return $ret;
776  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288
post($url, $URLparams, $QSparams, $body)
general function for POST (create) API calls
Definition: grima-lib.php:249

◆ postElectronicPortfolioOnBib()

Grima::postElectronicPortfolioOnBib (   $mms_id,
  $portfolio,
  $update = true 
)

Create Electronic Portfolio - add a new portfolio to Alma Bib.

Makes a call to the API: (API docs)

POST /almaws/v1/bibs/{mms_id}/portfolios/
Parameters
string $mms_id ID of bib
ElectronicPortfolio $portfolio portfolio to add
string $mms_id ID of bib
Returns
DomDocument Electronic Portfolio object as it appears in Alma

Definition at line 793 of file grima-lib.php.

References checkForErrorMessage(), and post().

793  {
794  $ret = $this->post('/almaws/v1/bibs/{mms_id}/portfolios/',
795  array('mms_id' => $mms_id),
796  array(),
797  $portfolio
798  );
799  $this->checkForErrorMessage($ret);
800  if ($update) { $portfolio->loadXML($ret->saveXML()); }
801  return $ret;
802  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288
post($url, $URLparams, $QSparams, $body)
general function for POST (create) API calls
Definition: grima-lib.php:249

◆ postHolding()

Grima::postHolding (   $mms_id,
  $holding 
)

Create holding record - add a new holdings record to a bib.

Makes a call to the API: (API docs)

POST /almaws/v1/bibs/{mms_id}/holdings
Parameters
string $mms_id MMS ID of bib record
DomDocument $holding Holding object to add to Alma as new record
Returns
DomDocument Holding object as it now appears in Alma https://developers.exlibrisgroup.com/alma/apis/xsd/rest_bib.xsd?tags=GET

Definition at line 474 of file grima-lib.php.

References checkForErrorMessage(), and post().

474  {
475  $ret = $this->post('/almaws/v1/bibs/{mms_id}/holdings',
476  array('mms_id' => $mms_id),
477  array(),
478  $holding
479  );
480  $this->checkForErrorMessage($ret);
481  return $ret;
482  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288
post($url, $URLparams, $QSparams, $body)
general function for POST (create) API calls
Definition: grima-lib.php:249

◆ postItem()

Grima::postItem (   $mms_id,
  $holding_id,
  $item 
)

Create Item - add a new item to a holding in Alma.

Makes a call to the API: (API docs)

POST /almaws/v1/bibs/{mms_id}/holdings/{holding_id}/items
Parameters
string $mms_id - MMS ID of Bib record
string $holding_id - Holding ID of Holding record
DomDocument $item - Item object to add to Alma as new record
Returns
DomDocument Bib object as it now appears in Alma https://developers.exlibrisgroup.com/alma/apis/xsd/rest_bib.xsd?tags=GET

Definition at line 634 of file grima-lib.php.

References checkForErrorMessage(), and post().

634  {
635  $ret = $this->post('/almaws/v1/bibs/{mms_id}/holdings/{holding_id}/items',
636  array('mms_id' => $mms_id, 'holding_id' => $holding_id),
637  array(),
638  $item
639  );
640  $this->checkForErrorMessage($ret);
641  return $ret;
642  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288
post($url, $URLparams, $QSparams, $body)
general function for POST (create) API calls
Definition: grima-lib.php:249

◆ postJob()

Grima::postJob (   $job_id,
  $op,
  $job 
)

Submit a manual or scheduled job.

Makes a call to the API: (API docs)

POST /almaws/v1/conf/jobs/{job_id}
Parameters
string $job_id of job to run
op $op operation to perform
DomDocument $job job to run
Returns
DomDocument ??

Definition at line 1283 of file grima-lib.php.

References checkForErrorMessage(), and post().

1283  {
1284  $ret = $this->post('/almaws/v1/conf/jobs/{job_id}',
1285  array('job_id' => $job_id),
1286  array('op' => $op),
1287  $job
1288  );
1289  $this->checkForErrorMessage($ret);
1290  return $ret;
1291  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288
post($url, $URLparams, $QSparams, $body)
general function for POST (create) API calls
Definition: grima-lib.php:249

◆ postSet()

Grima::postSet (   $set )

Create a Set - add a new set to Alma.

Makes a call to the API: (API docs)

POST /almaws/v1/conf/sets
Returns
DomDocument Set object

Definition at line 1112 of file grima-lib.php.

References checkForErrorMessage(), and post().

1112  {
1113  $ret = $this->post('/almaws/v1/conf/sets/',
1114  array(),
1115  array(),
1116  $set
1117  );
1118  $this->checkForErrorMessage($ret);
1119  return $ret;
1120  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288
post($url, $URLparams, $QSparams, $body)
general function for POST (create) API calls
Definition: grima-lib.php:249

◆ postSetManageMembers()

Grima::postSetManageMembers (   $set_id,
  $id_type,
  $op,
  $set 
)

Manage Members - modify sets in Alma.

Makes a call to the API: (API docs)

POST /almaws/v1/conf/sets/{set_id}
Parameters
string $set_id ID of the set to retrieve
string $id_type type of identifier used to identify members
string $op operation to perform on the set
DomDocument $set to do the operation with
Returns
DomDocument Set object

Definition at line 1138 of file grima-lib.php.

References checkForErrorMessage(), and post().

1138  {
1139  $ret = $this->post('/almaws/v1/conf/sets/{set_id}',
1140  array('set_id' => $set_id),
1141  array('id_type' => $id_type, 'op' => $op),
1142  $set
1143  );
1144  $this->checkForErrorMessage($ret);
1145  return $ret;
1146  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288
post($url, $URLparams, $QSparams, $body)
general function for POST (create) API calls
Definition: grima-lib.php:249

◆ put()

Grima::put (   $url,
  $URLparams,
  $QSparams,
  $body 
)

general function for PUT (update) API calls

Parameters
string $url - URL pattern string with parameters in {}
array $URLparams - URL parameters
array $QSparams - query string parameters
DomDocument $body - record to update Alma record with
Returns
DomDocument - record as it now appears in Alma

Definition at line 264 of file grima-lib.php.

References request().

Referenced by Set\getMembers(), putBib(), putElectronicCollection(), putElectronicPortfolioOnBib(), putHolding(), and putItem().

264  {
265  return $this->request("PUT",$url,$URLparams,$QSparams,$body);
266  }
request($method, $url, $URLparams, $QSparams, $body=null)
general function for REST API calls
Definition: grima-lib.php:135

◆ putBib()

Grima::putBib (   $mms_id,
  $bib 
)

Update Bib Record - updates the copy of the bib in Alma.

Makes a call to the API: (API docs)

PUT /almaws/v1/bibs/{mms_id}

Parameters
string $mms_id Alma Bib record to update
DomDocument $bib Bib to replace old record
Returns
DomDocument Bib object as it now appears in Alma https://developers.exlibrisgroup.com/alma/apis/xsd/rest_bib.xsd?tags=GET

Definition at line 366 of file grima-lib.php.

References checkForErrorMessage(), and put().

366  {
367  $ret = $this->put('/almaws/v1/bibs/{mms_id}',
368  array('mms_id' => $mms_id),
369  array(),
370  $bib
371  );
372  $this->checkForErrorMessage($ret);
373  return $ret;
374  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288
put($url, $URLparams, $QSparams, $body)
general function for PUT (update) API calls
Definition: grima-lib.php:264

◆ putElectronicCollection()

Grima::putElectronicCollection (   $collection_id,
  $collection 
)

Update Electronic Collection Record - updates the copy of the collection in Alma.

Makes a call to the API: (API docs)

PUT /almaws/v1/electronic/e-collections/{collection_id}

Parameters
string $collection_id Alma ElectronicCollection record to update
DomDocument $collection ElectronicCollection to replace old record
Returns
DomDocument ElectronicCollection object as it now appears in Alma https://developers.exlibrisgroup.com/alma/apis/xsd/rest_bib.xsd?tags=GET

Definition at line 935 of file grima-lib.php.

References checkForErrorMessage(), and put().

935  {
936  $ret = $this->put('/almaws/v1/electronic/e-collections/{collection_id}',
937  array('collection_id' => $collection_id),
938  array(),
939  $collection
940  );
941  $this->checkForErrorMessage($ret);
942  return $ret;
943  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288
put($url, $URLparams, $QSparams, $body)
general function for PUT (update) API calls
Definition: grima-lib.php:264

◆ putElectronicPortfolioOnBib()

Grima::putElectronicPortfolioOnBib (   $mms_id,
  $portfolio_id,
  $portfolio 
)

Update Electronic Portfolio - update portfolio in Alma.

Makes a call to the API: (API docs)

PUT /almaws/v1/bibs/{mms_id}/portfolios/{portfolio_id}
Parameters
string $mms_id ID of bibliographic record
string $portfolio_id ID of portfolio
Returns
DomDocument Electronic Portfolio object as it appears in Alma

Definition at line 818 of file grima-lib.php.

References checkForErrorMessage(), and put().

818  {
819  $ret = $this->put('/almaws/v1/bibs/{mms_id}/portfolios/{portfolio_id}',
820  array('mms_id' => $mms_id, 'portfolio_id' => $portfolio_id),
821  array(),
822  $portfolio
823  );
824  $this->checkForErrorMessage($ret);
825  return $ret;
826  }
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
Definition: grima-lib.php:288
put($url, $URLparams, $QSparams, $body)
general function for PUT (update) API calls
Definition: grima-lib.php:264

◆ putHolding()

Grima::putHolding (   $mms_id,
  $holding_id,
  $holding 
)

Update Holdings Record - replace the holdings record in Alma.

Makes a call to the API: (API docs)

PUT /almaws/v1/bibs/{mms_id}/holdings/{holding_id}
Parameters
string $mms_id MMS ID of Bib
string $holding_id Holding ID of holding to replace
DomDocument $holding Holding object to add to Alma as new record
Returns
DomDocument Bib object as it now appears in Alma https://developers.exlibrisgroup.com/alma/apis/xsd/rest_bib.xsd?tags=GET

Definition at line 499 of file grima-lib.php.

References put().

499  {
500  $ret = $this->put('/almaws/v1/bibs/{mms_id}/holdings/{holding_id}',
501  array('mms_id' => $mms_id, 'holding_id' => $holding_id),
502  array(),
503  $holding
504  );
505  }
put($url, $URLparams, $QSparams, $body)
general function for PUT (update) API calls
Definition: grima-lib.php:264

◆ putItem()

Grima::putItem (   $mms_id,
  $holding_id,
  $item_pid,
  $item 
)

Update Item information - replace item record in Alma.

Makes a call to the API: (API docs)

PUT /almaws/v1/bibs/{mms_id}/holdings/{holding_id}/items/{item_pid}
Parameters
string $mms_id MMS ID of Bib record
string $holding_id Holding ID of Holding record
string $item_pid Item ID of Item record
DomDocument $item Item object to update record with in Alma
Returns
DomDocument Bib object as it now appears in Alma https://developers.exlibrisgroup.com/alma/apis/xsd/rest_bib.xsd?tags=GET

Definition at line 660 of file grima-lib.php.

References put().

660  {
661  $ret = $this->put('/almaws/v1/bibs/{mms_id}/holdings/{holding_id}/items/{item_pid}',
662  array('mms_id' => $mms_id, 'holding_id' => $holding_id, 'item_pid' => $item_pid),
663  array(),
664  $item
665  );
666  return $ret;
667  }
put($url, $URLparams, $QSparams, $body)
general function for PUT (update) API calls
Definition: grima-lib.php:264

◆ request()

Grima::request (   $method,
  $url,
  $URLparams,
  $QSparams,
  $body = null 
)

general function for REST API calls

Parameters
string $method - GET, POST, PUT, or DELETE
string $url - URL pattern string with parameters in {}
array $URLparams - URL parameters
array $QSparams - query string parameters
array $body - body content (xml)
Returns
DomDocument of requested record

Definition at line 135 of file grima-lib.php.

References arrayToXml().

Referenced by delete(), get(), post(), and put().

135  {
136  $headers = array(
137  'Authorization: apikey ' . urlencode($this->apikey),
138  "Accept: application/xml",
139  );
140 
141  // Change "/almaws/v1/users/{user_id}" to "/almaws/v1/users/${URLparams['user_id']}"
142  foreach ($URLparams as $k => $v) {
143  if (!$v) { throw new Exception("URL parameter $k is empty in $method $url"); }
144  $url = str_replace('{'.$k.'}',urlencode($v),$url);
145  }
146 
147  // Include APIKey in url
148  $url = $this->server . $url . '?apikey=' . urlencode($this->apikey) . '&format=xml';
149 
150  // Include query string parameters too
151  foreach ($QSparams as $k => $v) {
152  $url .= "&$k=$v";
153  }
154 
155  // Include XML based body as well
156  // XXX: detect if JSON is more appropriate?
157  if ($body) {
158  $bodyxml = $body->saveXML();
159  $headers[] = 'Content-Type: application/xml';
160  }
161 
162  $ch = curl_init();
163  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
164  curl_setopt($ch, CURLOPT_URL, $url);
165  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
166  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
167 
168  $headerCapture = new HeaderCapture();
169  curl_setopt($ch, CURLOPT_HEADERFUNCTION, [&$headerCapture,"capture"]);
170 
171  # ExLibris / Debian interoperability problem
172  # https://github.com/openssl/openssl/issues/7126
173  # error_log("OPENSSL_VERSION_NUMBER=" .dechex(OPENSSL_VERSION_NUMBER));
174  # 0x01000214f on reclaim
175  if (OPENSSL_VERSION_NUMBER >= 0x010101000) {
176  // debian 10 workaround until Ex Libris patches their servers
177  curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, "DEFAULT@SECLEVEL=1");
178  }
179 
180 
181  if (isset($bodyxml)) {
182  curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyxml);
183  }
184  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers );
185 
186  $response = curl_exec($ch);
187  #error_log( print_r($headerCapture,true) );
188 
189  $code = curl_getinfo($ch,CURLINFO_HTTP_CODE);
190  if (curl_errno($ch)) {
191  throw new Exception("Network error: " . curl_error($ch));
192  }
193  curl_close($ch);
194  if ($code == 204) return; // no body
195 
196  $xml = new DOMDocument();
197  $xml->formatOutput = true;
198  try {
199  if (preg_match(',^application/json,',$headerCapture->headers['content-type'])) {
200  $array = json_decode ($response, true);
201  $xml->loadXML('<?xml version="1.0"?' . '><json/>');
202  arrayToXml($array, $xml->documentElement);
203  } else if (!preg_match('/^</',$response)) {
204  $xml->loadXML(
205  '<?xml version="1.0"?' . '><html><body><h1>Not xml</h1><pre>'
206  . htmlspecialchars($response).
207  '</pre></body></html>'
208  );
209  } else {
210  $xml->loadXML($response);
211  }
212  } catch (Exception $e) {
213  throw new Exception("Malformed XML from Alma:\n$method $url -> $code\n$e");
214  }
215 
216  $xml->rawText = $response;
217  $xml->httpCode = $code;
218  $xml->headers = $headerCapture->headers;
219  $xml->rawHeaders = $headerCapture->rawHeaders;
220 
221  return $xml;
222  }
arrayToXml($array, &$xml)
Definition: grima-util.php:77

◆ session_destroy()

Grima::session_destroy ( )

Definition at line 65 of file grima-lib.php.

References getenvWithFileFallbackAndDefault(), and session_init().

65  {
66  $session_module_name = getenvWithFileFallbackAndDefault('SESSION_MODULE','encrypted_cookie');
67  if ($session_module_name === "none") return;
68  $_SESSION = [];
69  if ( ini_get("session.use_cookies") ) {
70  $params = session_get_cookie_params();
71  $params['expires'] = time() - 42000;
72  unset($params['lifetime']);
73  setcookie(session_name(), '', $params );
74  }
75  $this->session_init(true);
76  $_SESSION = [];
78  }
session_init( $force=false)
Definition: grima-lib.php:21
session_destroy()
Definition: grima-lib.php:65
getenvWithFileFallbackAndDefault( $env_name, $default=false)
Definition: grima-util.php:52

◆ session_init()

Grima::session_init (   $force = false )

Definition at line 21 of file grima-lib.php.

References getenvWithFileFallbackAndDefault(), and join_paths().

Referenced by __construct(), session_destroy(), and session_save().

21  {
22  # Session Module
23  $session_module_name = getenvWithFileFallbackAndDefault('SESSION_MODULE','encrypted_cookie');
24  if ($session_module_name=="none") {
25  return;
26  } else if ($session_module_name=="encrypted_cookie") {
27  $session_key = base64_decode( getenvWithFileFallbackAndDefault( 'SESSION_KEY',
28  "base64EncodedGrimaKeyOf32BytesTotallyRandom=" ) );
29  session_set_save_handler(new EncryptedCookieSession($session_key));
30  ini_set("session.use_cookies",false);
31  } else if ($session_module_name) {
32  $new_name = session_module_name($session_module_name);
33  if ($new_name != $session_module_name) {
34  session_name( "grima_failsafe" );
35  session_start();
36  return;
37  }
38  }
39  # Session Name
40  $session_name = getenvWithFileFallbackAndDefault('SESSION_NAME', 'grima');
41  session_name( $session_name );
42  # Session Path
43  $session_path = getenvWithFileFallbackAndDefault('SESSION_PATH', join_paths( sys_get_temp_dir(), 'grima' ) );
44  if (session_module_name()==='files') {
45  @mkdir($session_path, 0700, true);
46  }
47  session_save_path($session_path);
48  # Session lifetime
49  session_set_cookie_params(365*24*60*60); # one year
50  ini_set('session.gc_maxlifetime',525600*60); # of love
51  # Start session
52  session_start();
53  }
getenvWithFileFallbackAndDefault( $env_name, $default=false)
Definition: grima-util.php:52
join_paths(... $paths)
Definition: grima-util.php:156

◆ session_save()

Grima::session_save (   $result )

Definition at line 55 of file grima-lib.php.

References $key, getenvWithFileFallbackAndDefault(), and session_init().

55  {
56  $session_module_name = getenvWithFileFallbackAndDefault('SESSION_MODULE','encrypted_cookie');
57  if ($session_module_name === "none") return;
58  $this->session_init(true);
59  foreach( $result as $key => $value ) {
60  $_SESSION[$key] = $value;
61  }
62  session_write_close();
63  }
$key
Definition: encrypt.php:4
session_init( $force=false)
Definition: grima-lib.php:21
getenvWithFileFallbackAndDefault( $env_name, $default=false)
Definition: grima-util.php:52

Member Data Documentation

◆ $apikey

Grima::$apikey

Definition at line 17 of file grima-lib.php.

Referenced by __construct().

◆ $server

Grima::$server

Definition at line 16 of file grima-lib.php.

Referenced by __construct().


The documentation for this class was generated from the following file: