8 require_once(
"grima-util.php");
9 require_once(
"grima-xmlbag.php");
10 require_once(
"grima-splats.php");
11 require_once(
"MARC21.php");
24 if ($session_module_name==
"none") {
26 }
else if ($session_module_name==
"encrypted_cookie") {
28 "base64EncodedGrimaKeyOf32BytesTotallyRandom=" ) );
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" );
41 session_name( $session_name );
44 if (session_module_name()===
'files') {
45 @mkdir($session_path, 0700,
true);
47 session_save_path($session_path);
49 session_set_cookie_params(365*24*60*60); # one year
50 ini_set(
'session.gc_maxlifetime',525600*60); # of love
57 if ($session_module_name ===
"none")
return;
59 foreach( $result as
$key => $value ) {
60 $_SESSION[
$key] = $value;
62 session_write_close();
67 if ($session_module_name ===
"none")
return;
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 );
88 isset($_REQUEST[
'apikey']) && $_REQUEST[
'apikey'] ? $_REQUEST[
'apikey'] : (
89 isset($_SESSION[
'apikey']) && $_SESSION[
'apikey'] ? $_SESSION[
'apikey'] : (
93 isset($_REQUEST[
'server']) && $_REQUEST[
'server'] ? $_REQUEST[
'server'] : (
94 isset($_SESSION[
'server']) && $_SESSION[
'server'] ? $_SESSION[
'server'] : (
97 if (strlen($this->server)==2) {
98 $this->server =
"https://api-" . $this->server .
".hosted.exlibrisgroup.com";
101 if (!preg_match(
'!https://api-[a-z]*\.hosted\.exlibrisgroup\.com!',$this->server)) {
105 if ($this->apikey==
'EDITME') {
109 if ($this->apikey && $this->server) {
114 session_write_close();
135 function request($method, $url, $URLparams, $QSparams, $body=null) {
137 'Authorization: apikey ' . urlencode($this->apikey),
138 "Accept: application/xml",
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);
148 $url = $this->server . $url .
'?apikey=' . urlencode($this->apikey) .
'&format=xml';
151 foreach ($QSparams as $k => $v) {
158 $bodyxml = $body->saveXML();
159 $headers[] =
'Content-Type: application/xml';
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);
169 curl_setopt($ch, CURLOPT_HEADERFUNCTION, [&$headerCapture,
"capture"]);
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) {
177 curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST,
"DEFAULT@SECLEVEL=1");
181 if (isset($bodyxml)) {
182 curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyxml);
184 curl_setopt($ch, CURLOPT_HTTPHEADER, $headers );
186 $response = curl_exec($ch);
187 #error_log( print_r($headerCapture,true) );
189 $code = curl_getinfo($ch,CURLINFO_HTTP_CODE);
190 if (curl_errno($ch)) {
191 throw new Exception(
"Network error: " . curl_error($ch));
194 if ($code == 204)
return;
196 $xml =
new DOMDocument();
197 $xml->formatOutput =
true;
199 if (preg_match(
',^application/json,',$headerCapture->headers[
'content-type'])) {
200 $array = json_decode ($response,
true);
201 $xml->loadXML(
'<?xml version="1.0"?' .
'><json/>');
203 }
else if (!preg_match(
'/^</',$response)) {
205 '<?xml version="1.0"?' .
'><html><body><h1>Not xml</h1><pre>'
206 . htmlspecialchars($response).
207 '</pre></body></html>'
210 $xml->loadXML($response);
212 }
catch (Exception $e) {
213 throw new Exception(
"Malformed XML from Alma:\n$method $url -> $code\n$e");
216 $xml->rawText = $response;
217 $xml->httpCode = $code;
218 $xml->headers = $headerCapture->headers;
219 $xml->rawHeaders = $headerCapture->rawHeaders;
234 function get($url,$URLparams,$QSparams) {
235 return $this->
request(
"GET",$url,$URLparams,$QSparams,null);
249 function post($url,$URLparams,$QSparams,$body) {
250 return $this->
request(
"POST",$url,$URLparams,$QSparams,$body);
264 function put($url,$URLparams,$QSparams,$body) {
265 return $this->
request(
"PUT",$url,$URLparams,$QSparams,$body);
278 function delete($url,$URLparams,$QSparams) {
279 return $this->
request(
"DELETE",$url,$URLparams,$QSparams,null);
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);
320 function getBib($mms_id, $view =
'full', $expand =
'None') {
321 $ret = $this->
get(
'/almaws/v1/bibs/{mms_id}',
322 array(
'mms_id' => $mms_id),
323 array(
'view' => $view,
'expand' => $expand)
343 $ret = $this->
post(
'/almaws/v1/bibs',
367 $ret = $this->
put(
'/almaws/v1/bibs/{mms_id}',
368 array(
'mms_id' => $mms_id),
390 $ret = $this->
delete(
'/almaws/v1/bibs/{mms_id}',
391 array(
'mms_id' => $mms_id),
392 array(
'override' => $override)
419 $ret = $this->
get(
'/almaws/v1/bibs/{mms_id}/holdings',
420 array(
'mms_id' => $mms_id),
449 $ret = $this->
get(
'/almaws/v1/bibs/{mms_id}/holdings/{holding_id}',
452 'holding_id' => $holding_id
475 $ret = $this->
post(
'/almaws/v1/bibs/{mms_id}/holdings',
476 array(
'mms_id' => $mms_id),
500 $ret = $this->
put(
'/almaws/v1/bibs/{mms_id}/holdings/{holding_id}',
501 array(
'mms_id' => $mms_id,
'holding_id' => $holding_id),
522 $ret = $this->
delete(
'/almaws/v1/bibs/{mms_id}/holdings/{holding_id}',
525 'holding_id' => $holding_id
527 array(
'override' => $override)
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)
584 function getItem($mms_id,$holding_id,$item_pid) {
585 $ret = $this->
get(
'/almaws/v1/bibs/{mms_id}/holdings/{holding_id}/items/{item_pid}', array(
587 'holding_id' => $holding_id,
588 'item_pid' => $item_pid
609 $ret = $this->
get(
'/almaws/v1/items',
612 'item_barcode' => $barcode,
635 $ret = $this->
post(
'/almaws/v1/bibs/{mms_id}/holdings/{holding_id}/items',
636 array(
'mms_id' => $mms_id,
'holding_id' => $holding_id),
660 function putItem($mms_id,$holding_id,$item_pid,$item) {
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),
685 function deleteItem($mms_id,$holding_id,$item_pid,$override =
"false",
686 $holdings =
"retain") {
687 $ret = $this->
delete(
'/almaws/v1/bibs/{mms_id}/holdings/{holding_id}/items/{item_pid}', array(
689 'holding_id' => $holding_id,
690 'item_pid' => $item_pid
692 'override' => $override,
693 'holdings' => $holdings
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),
745 $ret = $this->
get(
'/almaws/v1/bibs/{mms_id}/portfolios/{portfolio_id}',
746 array(
'mms_id' => $mms_id,
'portfolio_id' => $portfolio_id),
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),
794 $ret = $this->
post(
'/almaws/v1/bibs/{mms_id}/portfolios/',
795 array(
'mms_id' => $mms_id),
800 if ($update) { $portfolio->loadXML($ret->saveXML()); }
819 $ret = $this->
put(
'/almaws/v1/bibs/{mms_id}/portfolios/{portfolio_id}',
820 array(
'mms_id' => $mms_id,
'portfolio_id' => $portfolio_id),
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),
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)
891 $ret = $this->
get(
'/almaws/v1/bibs/{mms_id}/portfolios',
892 array(
'mms_id' => $mms_id),
893 array(
'limit' => $limit, $offset = $offset)
913 $ret = $this->
get(
'/almaws/v1/electronic/e-collections/{collection_id}',
914 array(
'collection_id' => $collection_id),
936 $ret = $this->
put(
'/almaws/v1/electronic/e-collections/{collection_id}',
937 array(
'collection_id' => $collection_id),
960 $ret = $this->
get(
'/almaws/v1/electronic/e-collections/{collection_id}/e-services',
961 array(
'collection_id' => $collection_id),
989 $ret = $this->
get(
'/almaws/v1/conf/libraries/{libraryCode}',
990 array(
'libraryCode' => $libraryCode),
1010 $ret = $this->
get(
'/almaws/v1/conf/libraries',
1031 $ret = $this->
get(
'/almaws/v1/conf/libraries/{libraryCode}/locations',
1032 array(
'libraryCode' => $libraryCode),
1060 $ret = $this->
get(
'/almaws/v1/conf/libraries/{libraryCode}/locations/{locationCode}',
1062 'libraryCode' => $libraryCode,
1063 'locationCode' => $locationCode,
1092 $ret = $this->
get(
'/almaws/v1/conf/sets/{set_id}',
1093 array(
'set_id' => $set_id),
1113 $ret = $this->
post(
'/almaws/v1/conf/sets/',
1139 $ret = $this->
post(
'/almaws/v1/conf/sets/{set_id}',
1140 array(
'set_id' => $set_id),
1141 array(
'id_type' => $id_type,
'op' => $op),
1164 $body =
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?' .
'>
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>
1191 $bodyxml =
new DomDocument();
1192 $bodyxml->loadXML($body);
1194 $ret = $this->
post(
'/almaws/v1/conf/sets', array(), array(
'job_instance_id' => $job_instance_id,
'population' => $population),$bodyxml);
1213 $ret = $this->
delete(
'/almaws/v1/conf/sets/{set_id}',
1215 'set_id' => $set_id,
1237 $ret = $this->
get(
'/almaws/v1/conf/sets/{set_id}/members',
1238 array(
'set_id' => $set_id),
1239 array(
'limit' => $limit,
'offset' => $offset)
1253 # XXX check if blank filter is ok
1255 return $this->
get(
'/almaws/v1/analytics/reports',
1257 array(
'path' => urlencode($path),
'filter' => urlencode($filter),
1258 'limit' => $limit,
'token' => $token)
1284 $ret = $this->
post(
'/almaws/v1/conf/jobs/{job_id}',
1285 array(
'job_id' => $job_id),
1308 public $error =
false;
1309 public $args = array();
1310 public $el_override = array();
1312 public $auto_args = array();
1314 public $messages = array();
1317 return isset($this->args[$offset]);
1321 return $this->args[$offset];
1325 $this->args[$offset] = $value;
1329 unset($this->args[$offset]);
1334 $base = get_class($this);
1335 if (file_exists(
join_paths($webroot,$base,
"$base.xml")) and (!isset($this->formxml))) {
1336 $this->formxml = file_get_contents(
join_paths($webroot,$base,
"$base.xml"));
1338 if (isset($this->formxml)) {
1340 $this->form->fromXML($this->formxml);
1346 $basename = get_class($this);
1350 $this->splat->addBases(array(
1351 "$webroot/$basename/splats",
1355 $this->splatVars = array(
1356 'title' => $this->form->title,
1357 'basename' => $basename,
1358 'webroot' => $webroot,
1359 'local_stylesheets' => array(
'Grima.css'),
1360 'form' => &$this->form,
1361 'messages' => &$this->messages,
1364 if (isset($this[
'redirect_url'])) {
1365 $this->splatVars[
'redirect_url'] = $this[
'redirect_url'];
1370 $this->form->loadValues($this);
1371 $this->splat->splat(
'print_form', $this->splatVars );
1375 $this->form->loadPersistentValues($this);
1376 $this->splat->splat(
'print_success', $this->splatVars );
1380 $this->form->loadValues($this);
1381 $this->splat->splat(
'print_failure', $this->splatVars );
1386 if (isset($grima->apikey) and isset($grima->server) and
1387 ($grima->apikey) and ($grima->server)) {
1401 $this->check_login(); #
if not logged in, print login form
1402 $this->error =
false;
1404 $this->setup_splat(); # should happen after form xml read in get_input
1405 if ($this->check_input()) {
1408 }
catch (Exception $e) {
1409 $this->addMessage(
'error',$e->getMessage());
1410 $this->error =
true;
1413 $this->print_form();
1417 $this->print_failure();
1419 $this->print_success();
1424 $task =
new static();
1429 if (isset($this->form)) {
1430 if (php_sapi_name() ==
"cli") { # command line
1444 foreach ($this->form->fields as $field) {
1445 if (isset($_REQUEST[$field->name])) {
1446 $this[$field->name] = $_REQUEST[$field->name];
1453 $this->get_input_param($this->auto_args);
1458 if (isset($this->form)) {
1460 foreach ($this->form->fields as $field) {
1461 if ($field->required) {
1462 if (!isset($this[$field->name]) or
1463 !($this[$field->name])) {
1464 $field->error_condition =
"error";
1465 $field->error_message =
"Field is required\n";
1466 $input_good =
false;
1473 foreach ($this->auto_args as $k => $v) {
1474 if (preg_match(
'/[^:]:$/',$k)) {
1475 if (!isset($this->args[$v]) or !($this->args[$v])) {
1485 if (php_sapi_name() ==
"cli") { # command line
1486 if ($options = getopt(implode(array_keys($param)))) {
1487 foreach ($param as $k => $v) {
1488 $this->args[$v] = $options[$k[0]];
1490 if (!$this->check_input()) {
1491 $this->usage(); exit;
1494 $this->usage(); exit;
1497 foreach ($param as $k => $v) {
1498 if (isset($_REQUEST[$v])) {
1499 $this->args[$v] = $_REQUEST[$v];
1502 if (!$this->check_input()) {
1503 $this->print_form(); exit;
1508 abstract function do_task();
1510 function usage() { # XXX rewrite
for grima form
1512 print
"Usage: php ${argv[0]} ";
1513 foreach ($this->auto_args as $k => $v) {
1514 if (preg_match(
'/^(.):$/',$k,$m)) {
1515 print
"-${m[1]} <$v> ";
1517 if (preg_match(
'/^(.)::$/',$k,$m)) {
1518 print
"[ -${m[1]} <$v> ] ";
1520 if (preg_match(
'/^.$/',$k)) {
1530 public static function call($grimaname,$args = array()) {
1531 $url = rtrim(
"../$grimaname/$grimaname.php?" . http_build_query($args),
"?");
1549 $this->type = $type;
1550 $this->message = $message;
1561 public $fields = array();
1572 foreach ($this->fields as $field) {
1573 if (isset($obj[$field->name])) {
1574 $field->value = $obj[$field->name];
1587 foreach ($this->fields as $field) {
1588 if (($field->persistent) and isset($obj[$field->name])) {
1589 $field->value = $obj[$field->name];
1601 $doc =
new DomDocument();
1602 $doc->loadXML($xml);
1603 $xpath =
new DomXpath($doc);
1604 $this->title = $xpath->query(
'//Title')[0]->nodeValue;
1605 $this->action = basename($_SERVER[
'PHP_SELF']); # allow
set?
1607 $nodes = $xpath->query(
'//Field');
1608 foreach ($nodes as $node) {
1609 $this->fields[$node->getAttribute(
'name')] =
new GrimaFormField($node);
1639 $this->item =
new Item();
1641 $this->item->loadFromAlmaBarcode($ds_barcode);
1642 }
catch (Exception $e) {
1646 $this->
bib->loadFromAlma($this->item[
'mms_id']);
1647 $this->
bib->useNormac();
1653 $fields = $this->
bib->marc->getFields(
'ZEM');
1654 foreach($fields as $field) {
1655 $keys = $field->getSubfields(
'k');
1656 if ($keys[0]->data == $offset) {
1664 $fields = $this->
bib->marc->getFields(
'ZEM');
1665 foreach($fields as $field) {
1666 $keys = $field->getSubfields(
'k');
1667 if ($keys[0]->data == $offset) {
1668 $values = $field->getSubfields(
'v');
1669 return $values[0]->data;
1676 $fields = $this->
bib->marc->getFields(
'ZEM');
1677 foreach($fields as $field) {
1678 $keys = $field->getSubfields(
'k');
1679 if ($keys[0]->data == $offset) {
1680 $values = $field->getSubfields(
'v');
1681 $values[0]->data = $value;
1682 $this->
bib->updateAlma();
1691 $this->
bib->marc->appendField($field);
1692 $this->
bib->updateAlma();
1697 $fields = $this->
bib->marc->getFields(
'ZEM');
1698 foreach($fields as $field) {
1699 $keys = $field->getSubfields(
'k');
1700 if ($keys[0]->data == $offset) {
1702 $this->
bib->updateAlma();
1718 $bib[
'title'] =
"GRIMA'S DATA STORE"; # XXX indicators 00?
1719 $bib[
'suppress_from_publishing'] =
"true";
1722 $this->
bib->useNormac();
1725 $location = $library->getOneLocation();
1728 $holding[
'library_code'] = $library[
'code'];
1729 $holding[
'location_code'] = $location[
'code'];
1730 $holding->addToAlmaBib($bib[
'mms_id']);
1731 $this->holding = $holding;
1735 $item->addToAlmaHolding($bib[
'mms_id'],$holding[
'holding_id']);
1736 $this->item = $item;
1738 preg_match(
'/\d{5}$/',$bib[
'mms_id'],$m);
1739 $this[
'alma institution code'] = $m[0];
1752 $item->loadFromAlmaBarcode($ds_barcode);
1754 }
catch (Exception $e) {
1769 $item->loadFromAlmaBarcode($ds_barcode);
1771 $bib->loadFromAlma($item[
'mms_id']);
1772 $bib->deleteTreeFromAlma();
1800 public $error_condition =
"";
1801 public $error_message =
"";
1811 function booly($str, $default =
'undefined') {
1812 switch(strtolower($str)) {
1838 $this->name = $field->getAttribute(
'name');
1839 $this->label = $field->getAttribute(
'label');
1840 $this->placeholder = $field->getAttribute(
'placeholder');
1841 $this->rows = $field->getAttribute(
'rows');
1842 $this->type = $field->getAttribute(
'type');
1844 $this->type =
'input';
1846 $this->required = $this->booly($field->getAttribute(
'required'),
true);
1847 $this->persistent = $this->booly($field->getAttribute(
'persistent'),
false);
1848 $this->autocomplete = $this->booly($field->getAttribute(
'autocomplete'),
false);
1849 $this->visible = $this->booly($field->getAttribute(
'visible'),
true);
1850 $this->dataset = $field->getAttribute(
'dataset');
1851 $this->options = array();
1852 if ($this->dataset) {
1853 if ($this->dataset ==
"institutions") {
1856 foreach ($institutions as $institution) {
1857 $i = htmlspecialchars($institution);
1858 $s = ($institution === $currentUser[
'institution']) ?
' selected="selected"' :
'';
1859 $this->options[] =
"<option value=\"$i\"$s>$i</option>";
1863 foreach ($field->getElementsByTagName(
"option") as $option) {
1864 $this->options[] = $option->ownerDocument->saveXML( $option );
1879 public $el_access = array();
1881 public $templateDir = __DIR__ .
"/templates";
1888 $this->xml =
new DomDocument();
1889 $blankRecord = get_class($this);
1890 $this->xml->loadXML(file_get_contents(
"{$this->templateDir}/{$blankRecord}.xml"));
1895 if (isset($this->el_override)) {
1896 return array_key_exists($offset, $this->el_override);
1898 return array_key_exists($offset, $this->el_access);
1902 if ((isset($this->el_override)) and
1903 (isset($this->el_override[$offset]))) {
1904 return $this->el_override[$offset];
1906 $xpath =
new DomXpath($this->xml);
1907 $node = $xpath->query($this->el_address[$offset]);
1908 if (
sizeof($node) >= 1) {
1909 return $node[0]->nodeValue;
1916 $xpath =
new DomXpath($this->xml);
1917 $node = $xpath->query($this->el_address[$offset]);
1918 $node[0]->nodeValue = $value;
1922 $xpath =
new DomXpath($this->xml);
1923 $node = $xpath->query($this->el_address[$offset]);
1924 $node[0]->nodeValue = null;
1940 if (isset($this->marc)) {
return; }
1942 #error_log("LOADING:");
1943 #error_log($this->xml->saveXML());
1944 $this->marc->loadFromString($this->xml->saveXML());
1955 $this->useNormac(); #
this function uses normac
1956 $subarray = array();
1958 $this->marc->AppendField($field,
true);
1971 $this->useNormac(); #
this function uses normac
1972 $subarray = array();
1973 foreach ($subfields as $k => $v) {
1976 $field =
new ISO2709Field($tag, null, $indicators, $subarray);
1977 $this->marc->AppendField($field,
true);
1986 if (isset($this->marc)) {
1987 $newRecord =
new DOMDocument;
1988 $newRecord->loadXML($this->marc->asXMLString());
1990 $xpath =
new DOMXpath($this->xml);
1991 $record = $xpath->query(
'//record');
1993 $node->parentNode->removeChild($node);
1995 $node = $this->xml->importNode($newRecord->documentElement,
true);
1996 $this->xml->documentElement->appendChild($node);
2012 $frag =
"<datafield ind1=\"$ind1\" ind2=\"$ind2\" tag=\"$tag\">";
2013 foreach ($subfields as $k => $v) {
2014 $frag .=
"<subfield code=\"$k\">$v</subfield>";
2016 $frag .=
"</datafield>";
2017 $xpath =
new DomXpath($this->xml);
2018 $record = $xpath->query(
"//record");
2031 $this->useNormac(); #
this function uses normac
2032 return $this->marc->getFields($tag);
2044 $xpath =
new DomXpath($this->xml);
2045 $tag = preg_replace(
'/X*$/',
'',$tag);
2046 $tag = preg_replace(
'/\.*$/',
'',$tag);
2047 $fields = $xpath->query(
"//record/datafield[starts-with(@tag,'$tag')]");
2048 $fieldarr = array();
2049 foreach ($fields as $field) {
2050 $marcfield =
new MARCField();
2052 $subfieldarr = array();
2053 foreach ($field->childNodes as $child) {
2054 $subfieldarr[] = array(
2055 $child->attributes[0]->value,
2059 $fieldarr[] = $subfieldarr;
2074 $xpath =
new DomXpath($this->xml);
2075 $subfields = $xpath->query(
"//record/datafield[@tag='$tag']/subfield[@code='$code']");
2077 foreach ($subfields as $subfield) {
2078 $arr[] = $subfield->nodeValue;
2091 $xpath =
new DomXpath($this->xml);
2092 $fields = $xpath->query(
"//record/datafield[@tag='$tag']");
2093 foreach( $fields as $field ) {
2094 $field->parentNode->removeChild( $field );
2106 $xpath =
new DomXPath($this->xml);
2107 $subfs = $xpath->query(
"//datafield[@tag='$tag']/subfield[@code='$code']");
2108 foreach ($subfs as $subf) {
2109 if (preg_match($regex,$subf->nodeValue)) {
2110 $subf->parentNode->removeChild($subf);
2125 # very shady but sometimes needed
2126 $xpath =
new DomXpath($this->xml);
2127 $fields = $xpath->query(
"//record/datafield[@tag='$tag']");
2128 if (
sizeof($fields) == 0) {
2129 $this->appendField($tag,
' ',
' ',array($code => $value));
2132 foreach ($fields[0]->childNodes as $subfield) {
2133 if($subfield->nodeType !== 1) {
2136 if ($subfield->getAttribute(
"code") == $code) {
2137 $subfield->nodeValue = $value;
2143 $subfield = $this->xml->createElement(
"subfield");
2144 $subfield->setAttribute(
"code",$code);
2145 $subfield->appendChild($this->xml->createTextNode($value));
2146 $fields[0]->appendChild($subfield);
2161 public $holdings = array();
2164 public $items = array();
2166 public $portfolioList = array(); # just an array
for now
2170 protected $el_address = array(
2171 'mms_id' =>
'//mms_id',
2172 'leader' =>
'//leader',
2173 'record_format' =>
'//record_format',
2174 'title' =>
'//title',
2175 'author' =>
'//author',
2176 'place_of_publication' =>
'//place_of_publication',
2177 'publisher_const' =>
'//publisher_const',
2178 'publisher' =>
'//publisher_const',
2179 'suppress_from_publishing' =>
'//suppress_from_publishing',
2183 if ($offset ==
'Type') {
2184 $leader = $this[
'leader'];
2187 if ($offset ==
'BLvl') {
2188 $leader = $this[
'leader'];
2191 if ($offset ==
'ELvl') {
2192 $leader = $this[
'leader'];
2195 if ($offset ==
'Desc') {
2196 $leader = $this[
'leader'];
2199 return parent::offsetGet($offset);
2202 # override because these go multiple places
2204 parent::offsetSet($offset,$value);
2205 if ($offset ==
'author') {
2206 $this->replaceOrAddSubfield(
'100',
'a',$value);
2208 if ($offset ==
'title') {
2209 $this->replaceOrAddSubfield(
'245',
'a',$value);
2211 if (($offset ==
'publisher_const') or ($offset ==
'publisher')) {
2212 $this->replaceOrAddSubfield(
'264',
'b',$value);
2214 if ($offset ==
'place_of_publication') {
2215 $this->replaceOrAddSubfield(
'264',
'a',$value);
2227 $this->xml = $grima->getBib($mms_id);
2238 $this->xml = $grima->postBib($this->xml);
2249 $this->normacToXML();
2250 $this->xml = $grima->putBib($this[
'mms_id'],$this->xml);
2260 $grima->deleteBib($this[
'mms_id']);
2270 $this->getHoldings();
2271 foreach ($this->holdings as $holding) {
2272 $holding->deleteTreeFromAlma(); #XXX
2274 $this->deleteAllPortfolios($this[
'mms_id']); #XXX
2275 $grima->deleteBib($this[
'mms_id']);
2285 if (count($this->holdingsList->entries) > 0) {
2288 $this->getPortfolioList();
2289 if (count($this->portfolioList) > 0) {
2290 print_r($this->portfolioList);
2303 $xpath =
new DomXPath($this->xml);
2304 $nodes = $xpath->query(
"//linked_record_id[@type='CZ']");
2305 return (count($nodes) > 0);
2315 $xpath =
new DomXPath($this->xml);
2316 $nodes = $xpath->query(
"//linked_record_id[@type='CZ']");
2317 foreach ($nodes as $node) {
2318 $node->parentNode->removeChild($node);
2320 $this->updateAlma();
2330 foreach ($this->holdingsList->entries as $entry) {
2332 $holding->loadFromAlma($this[
'mms_id'],$entry[
'holding_id']);
2333 $holding[
'mms_id'] = $this[
'mms_id'];
2334 $this->holdings[] = $holding;
2336 return $this->holdings;
2346 while ($this->getPortfolioList()) {
2347 foreach($this->portfolioList as $portfolio) {
2348 error_log(
"deleting " . $portfolio[
'pid'] .
"\n");
2349 $portfolio->deleteFromAlma();
2351 $this->portfolioList = array();
2362 $this->holdingsList =
new HoldingsList($this[
'mms_id']);
2372 $limit = 10; $offset = 0; # where to allow passing
2373 $ret = $grima->getElectronicPortfoliosForBib($this[
'mms_id'],$limit,$offset);
2374 $xpath =
new DOMXpath($ret);
2375 $ports = $xpath->query(
'//portfolio');
2376 foreach ($ports as $portnode) {
2378 $newport->loadFromPortfolioListNode($portnode);
2379 $this->portfolioList[] = $newport;
2381 return count($ports); # XXX is
this the right thing to
return?
2390 $this->getPortfolioList();
2391 foreach($this->portfolioList as $port) {
2392 $port->loadFromAlma($port[
'portfolio_id']);
2394 return $this->portfolioList;
2404 $this->items =& $this->itemList->items;
2405 return $this->items;
2415 $this->itemList =
new ItemList($this[
'mms_id'],
'ALL');
2424 $xpath =
new DomXpath($this->xml);
2425 $title = $xpath->query(
"//record/datafield[@tag='245']/subfield[@code='a']");
2426 return preg_replace(
"/[ \/=:,;\.]*$/",
"",$title[0]->nodeValue);
2449 $xpath =
new DomXPath($this->xml);
2451 foreach (array(
'050',
'090') as $tag) {
2452 foreach ($xpath->query(
"//datafield[@tag='$tag']") as $call) {
2458 foreach ($calls as $node) {
2459 $classs = $xpath->query(
"subfield[@code='a']",$node);
2460 $items = $xpath->query(
"subfield[@code='b']",$node);
2461 if ((count($classs) > 0) and (count($items) > 0)) {
2462 $ret = array($classs[0]->nodeValue,$items[0]->nodeValue);
2476 public $el_address = array(
2477 'mms_id' =>
'//mms_id',
2478 'title' =>
'//title',
2479 'author' =>
'//author',
2482 #public $holdings = array(); # should this go in BIB?
2486 if (!is_null($mms_id)) {
2487 $this->loadFromAlma($mms_id);
2493 $this->xml = $grima->getHoldingsList($mms_id);
2494 $xpath =
new DomXpath($this->xml);
2495 $hs = $xpath->query(
'//holding');
2496 $this->entries = array(); # clear
2497 #$this->holdings = array(); # clear
2498 foreach ($hs as $h) {
2499 #$this->holdings[] = new HoldingsListEntry($h,$mms_id);
2510 protected $el_address = array(
2511 'holding_id' =>
'//holding_id',
2512 'call_number' =>
'//holding/call_number',
2513 'library_code' =>
'//holding/library',
2514 'library' =>
'//holding/library/@desc',
2515 'location_code' =>
'//holding/location',
2516 'location' =>
'//holding/location/@desc'
2521 $this->xml =
new DomDocument();
2522 $this->xml->appendChild($this->xml->importNode($node,
true));
2523 $this->el_override[
'mms_id'] = $mms_id;
2528 $this->getMmsIfNeeded();
2529 $this->itemList =
new ItemList($this[
'mms_id'], $this[
'holding_id'], $limit);
2538 public $items = array(); #maybe ok as is
2544 $req_limit = ($limit == -1)?100:$limit;
2547 if ($curr_offset > 0) {
2548 if (($curr_offset+1)*100 > $limit) {
2549 $req_limit = $limit - $curr_offset*100;
2554 $xml = $grima->getItemList($mms_id,$holding_id,$req_limit,$curr_offset*100);
2555 $xpath =
new DomXpath($xml);
2556 $is = $xpath->query(
'//item');
2557 foreach ($is as $i) {
2558 $new_item =
new Item();
2559 $new_item->loadFromItemListNode($i);
2560 $this->items[] = $new_item;
2562 $xpath =
new DomXPath($xml);
2563 if (!$curr_offset) {
2564 $length = $xpath->query(
'//items/@total_record_count')[0]->nodeValue;
2565 if ($limit == -1) { $limit = $length; }
2569 }
while (($curr_offset*100 < $length) and ($curr_offset*100 < $limit));
2581 public $items = array();
2585 if ($offset ==
"mms_id") {
2586 $this->el_override[
'mms_id'] = $value;
2588 parent::offsetSet($offset,$value);
2593 if ($offset ==
"library") {
2595 $lib->loadFromAlma($this[
'library_code']);
2596 return $lib[
'name'];
2598 if ($offset ==
"location") {
2600 $loc->loadFromAlma($this[
'library_code'],$this[
'location_code']);
2601 return $loc[
'name'];
2603 if ($offset ==
"call_number") {
2604 $Hs = $this->getSubfieldValues(
"852",
"h");
2605 $Is = $this->getSubfieldValues(
"852",
"i");
2607 foreach ($Hs as $h) {
2610 foreach ($Is as $i) {
2615 return parent::offsetGet($offset);
2619 public $el_address = array(
2620 'holding_id' =>
'//holding_id',
2621 'inst_code' =>
"/holding/record/datafield[@tag='852']/subfield[@code='a']",
2622 'library_code' =>
"/holding/record/datafield[@tag='852']/subfield[@code='b']",
2623 'location_code' =>
"/holding/record/datafield[@tag='852']/subfield[@code='c']",
2625 'classification_part' =>
"/holding/record/datafield[@tag='852']/subfield[@code='h']",
2626 '852h' =>
"/holding/record/datafield[@tag='852']/subfield[@code='h']",
2628 'item_part' =>
"/holding/record/datafield[@tag='852']/subfield[@code='i']",
2629 '852i' =>
"/holding/record/datafield[@tag='852']/subfield[@code='i']",
2630 'shelving_scheme' =>
"/holding/record/datafield[@tag='852']/@ind1",
2643 $this->xml = $grima->getHolding($mms_id,$holding_id);
2644 $this[
'mms_id'] = $mms_id;
2657 # $report->path = "/shared/UK Libraries- University of Kentucky (UKY)/Reports/Kathryn/HoldingToMMS";
2658 $report->path =
"/shared/Community/Reports/Institutions/University of Kentucky/Kathryn/HoldingToMMS";
2660 <sawx:expr xsi:type="sawx:comparison" op="equal" xmlns:saw="com.siebel.analytics.web/report/v1.1"
2661 xmlns:sawx="com.siebel.analytics.web/expression/v1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2662 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
2663 <sawx:expr xsi:type="sawx:sqlExpression">"Holding Details"."Holding Id"</sawx:expr><sawx:expr xsi:type="xsd:string">{holding_id}</sawx:expr>
2666 $report->runReport(array(
'holding_id' => $holding_id), 1);
2667 if (count($report->rows) == 1) {
2668 return $report->rows[0][1];
2670 throw new Exception(
"No MMS for Holding ID $holding_id");
2683 if (!isset($this[
'mms_id']) or (!$this[
'mms_id'])) {
2699 $this->xml = $grima->getHolding($mms_id,$holding_id);
2700 $this[
'mms_id'] = $mms_id;
2712 $this->xml = $grima->postHolding($mms_id,$this->xml);
2713 $this[
'mms_id'] = $mms_id;
2724 return (
sizeof($this->itemList->items) > 0); # XXX
test
2734 $grima->putHolding($this[
'mms_id'],$this[
'holding_id'],$this->xml);
2744 $grima->deleteHolding($this[
'mms_id'],$this[
'holding_id']);
2748 # call number object?
2751 # must have mms_id set? confirm
2752 # must have shelving set? confirm
2755 $bib->loadFromAlma(); # link?
2757 switch($this[
"shelving_scheme"]) {
2758 case '0': #
Library of Congress
2759 $fields = $bib->getFields(
"090");
2760 foreach ($fields as $field) {
2761 $subfields = $field->getSubfields(
"a");
2762 print $field[
"ind1"];
2763 $field[
"ind1"] =
"4";
2764 foreach ($subfields as $subfield) {
2765 print $subfield[
"value"];
2766 $subfield[
"value"] =
"joe";
2775 $xpath =
new DomXpath($this->xml);
2776 $xpath->query(
"//record/datafield[@tag='852']")->item(0)->setAttribute(
"ind1",$ind1);
2778 $field852 = $xpath->query(
"//record/datafield[@tag='852']")->item(0);
2779 $subfieldHs = $xpath->query(
"subfield[@code='h']",$field852);
2780 foreach ($subfieldHs as $subfieldH) {
2781 $subfieldH->parentNode->removeChild($subfieldH);
2783 $subfieldIs = $xpath->query(
"subfield[@code='i']",$field852);
2784 foreach ($subfieldIs as $subfieldI) {
2785 $subfieldI->parentNode->removeChild($subfieldI);
2799 $this->deleteFromAlma();
2800 $this->addToAlmaBib($mms_id);
2810 $this->items =& $this->itemList->items;
2811 return $this->items;
2821 $this->getMmsIfNeeded();
2822 $this->itemList =
new ItemList($this[
'mms_id'],$this[
'holding_id']);
2833 foreach ($this->itemList->items as $item) {
2834 $item->deleteFromAlma(
"true");
2836 $this->deleteFromAlma();
2871 public $el_address = array(
2872 'item_pid' =>
'//pid',
2873 'barcode' =>
'//barcode',
2874 'creation_date' =>
'//creation_date',
2875 'modification_date' =>
'//modification_date',
2876 'base_status' =>
'//base_status',
2877 'physical_material_type_code' =>
'//physical_material_type',
2878 'physical_material_type' =>
'//physical_material_type/@desc',
2879 'location' =>
'//location/@desc',
2880 'location_code' =>
'//location',
2881 'library' =>
'//location/@desc',
2882 'library_code' =>
'//library',
2883 'policy' =>
'//policy',
2884 'item_policy' =>
'//policy',
2885 'provenance' =>
'//provenance',
2886 'po_line' =>
'//po_line',
2887 'is_magnetic' =>
'//is_magnetic',
2888 'arrival_date' =>
'//arrival_date',
2889 'year_of_issue' =>
'//year_of_issue',
2890 'enumeration_a' =>
'//enumeration_a',
2891 'enumeration_b' =>
'//enumeration_b',
2892 'enumeration_c' =>
'//enumeration_c',
2893 'enumeration_d' =>
'//enumeration_d',
2894 'enumeration_e' =>
'//enumeration_e',
2895 'enumeration_f' =>
'//enumeration_f',
2896 'enumeration_g' =>
'//enumeration_g',
2897 'enumeration_h' =>
'//enumeration_h',
2898 'chronology_i' =>
'//chronology_i',
2899 'chronology_j' =>
'//chronology_j',
2900 'chronology_k' =>
'//chronology_k',
2901 'chronology_l' =>
'//chronology_l',
2902 'chronology_m' =>
'//chronology_m',
2903 'description' =>
'//description',
2904 'alternative_call_number' =>
'//alternative_call_number',
2905 'alternative_call_number_type' =>
'//alternative_call_number_type',
2906 'storage_location_id' =>
'//storage_location_id',
2907 'receiving_operator' =>
'//receiving_operator',
2908 'process_type' =>
'//process_type',
2909 'in_temp_location' =>
'//in_temp_location',
2910 'mms_id' =>
'//mms_id',
2911 'holding_id' =>
'//holding_id',
2912 'title' =>
'//title',
2913 'author' =>
'//author',
2914 'call_number' =>
'//call_number',
2915 'pages' =>
'//pages',
2916 'pieces' =>
'//pieces',
2917 'public_note' =>
'//public_note',
2918 'fulfillment_note' =>
'//fulfillment_note',
2919 'internal_note_1' =>
'//internal_note_1',
2920 'internal_note_2' =>
'//internal_note_2',
2921 'internal_note_3' =>
'//internal_note_3',
2922 'statistics_note_1' =>
'//statistics_note_1',
2923 'statistics_note_2' =>
'//statistics_note_2',
2924 'statistics_note_3' =>
'//statistics_note_3',
2925 'requested' =>
'//requested',
2926 'physical_condition' =>
'//physical_condition',
2927 'temp_library' =>
'//temp_library',
2928 'temp_location' =>
'//temp_location',
2941 $this->xml = $grima->getItem($mms_id,$holding_id,$item_pid);
2952 $this->xml = $grima->getItem(
'X',
'X',$item_pid);
2963 $this->xml = $grima->getItemBC($barcode);
2976 if (preg_match(
"/^23.*/",$id)) { # item_pid
2977 # probably should know about suffix too
2978 $this->loadFromAlmaX($id);
2980 $this->loadFromAlmaBarcode($id);
2992 $this->xml =
new DomDocument();
2993 $this->xml->appendChild($this->xml->importNode($node,
true));
3006 $this->mms_id = $mms_id;
3007 $this->holding_id = $holding_id;
3008 $this->xml = $grima->postItem($mms_id,$holding_id,$this->xml);
3021 $this->addToAlmaHolding(
'X',$holding_id);
3033 return $grima->putItem(
3035 $this[
'holding_id'],
3051 $grima->deleteItem($this[
'mms_id'],$this[
'holding_id'],$this[
'item_pid'],$override,$holdings);
3064 public $services = array();
3068 public $el_address = array( # XXX many more fields here
3069 'collection_id' =>
'//id',
3071 'public_name' =>
'//public_name',
3082 $this->xml = $grima->getElectronicCollection($collection_id);
3083 #$this['collection_id'] = $collection_id;
3094 $this->xml = $grima->putElectronicCollection($this[
'collection_id'], $this->xml);
3105 $ret = $grima->getElectronicServices($this[
'collection_id']);
3106 $xpath =
new DomXpath($ret);
3107 $eservices = $xpath->query(
'//electronic_services/electronic_service');
3108 foreach ($eservices as $service) {
3109 $service_id = $service->firstChild->nodeValue; # XXX really?
3111 $ser->loadFromServiceListNode($service);
3112 $this->services[] = $ser;
3126 public $portfolios = array();
3128 public $el_address = array(
3130 'service_id' =>
'//id',
3133 public $el_override = array();
3136 # load from template
3140 if ($offset ==
"collection_id") {
3141 $this->el_override[
'collection_id'] = $value;
3143 parent::offsetSet($offset,$value);
3154 $this->xml = $grima->getElectronicService($collection_id,$service_id);
3155 $this[
'collection_id'] = $collection_id;
3166 $this->xml =
new DomDocument();
3167 $this->xml->appendChild($this->xml->importNode($node,
true));
3168 $xpath =
new DomXPath($this->xml);
3169 $service_link = $xpath->query(
'//electronic_service')->item(0)->attributes[
'link']->nodeValue;
3170 preg_match(
'!/e-collections/(.*)/e-services/!',$service_link,$m);
3171 $this[
'collection_id'] = $m[1];
3177 $retrieved = $this->getPortfolios(100, $curr_offset);
3178 $curr_offset += 100;
3179 }
while ($retrieved == 100);
3191 #function retrievePortfolios($limit = 10, $offset = 0) { # RENAME
3194 $ret = $grima->getElectronicPortfoliosForService($this[
'collection_id'],$this[
'service_id'],$limit,$offset);
3195 $xpath =
new DOMXpath($ret);
3196 $ports = $xpath->query(
'//portfolio');
3197 foreach ($ports as $portnode) {
3199 $newport->loadFromPortfolioListNode($portnode);
3200 $this->portfolios[] = $newport;
3202 return count($ports);
3215 while ($this->getPortfolios(100,0)) {
3216 foreach($this->portfolios as $portfolio) {
3217 $portfolio->deleteFromAlma($bib_treat);
3219 $this->portfolios = array();
3252 public $el_address = array(
3253 'portfolio_id' =>
'//portfolio/id',
3254 'is_local' =>
'//is_local',
3255 'is_standalone' =>
'//is_standalone',
3256 'mms_id' =>
'//mms_id',
3257 'title' =>
'//title',
3258 'service' =>
'//service',
3260 'static_url' =>
'//static_url',
3261 'availability' =>
'//availability',
3262 'collection_id' =>
'//electronic_collection/id',
3263 'service_id' =>
'//electronic_collection/service',
3264 'material_type' =>
'//material_type',
3265 'url_type' =>
'//url_type',
3266 'public_note' =>
'//public_note',
3267 'proxy_enabled' =>
'//proxy_enabled',
3268 'library' =>
'//library'
3281 $ret = $grima->postElectronicPortfolio($collection_id, $service_id, $this->xml);
3296 $ret = $grima->postElectronicPortfolioOnBib($mms_id, $this->xml);
3309 $this->xml = $grima->getElectronicPortfolio(
'X',
'X',$portfolio_id);
3314 $this->xml = $grima->getElectronicPortfolio(
'X',
'X',$portfolio_id);
3325 $this->xml =
new DomDocument();
3326 $this->xml->appendChild($this->xml->importNode($node,
true));
3336 $this->xml = $grima->putElectronicPortfolioOnBib($this[
'mms_id'],$this[
'portfolio_id'],$this->xml);
3348 $mms_id = $this[
'mms_id'];
3349 $grima->deleteElectronicPortfolio(
'X',
'X',
3350 $this[
'portfolio_id']);
3351 if ($bib_treat ==
"delete") {
3353 $bib->loadFromAlma($mms_id);
3355 if (! $bib->hasInventory()) {
3356 if ($bib->linkedToCZ()) {
3357 print
"LINKED TO CZ";
3358 $bib->unlinkFromCZ();
3361 $bib->deleteFromAlma();
3376 public $members = array();
3388 public $el_address = array(
3389 'set_id' =>
'//set/id',
3391 'name' =>
'//set/name',
3392 'description' =>
'//set/description',
3393 'type' =>
'//set/type',
3394 'content' =>
'//content',
3395 'private' =>
'//private',
3396 'status' =>
'//status',
3397 'status_date' =>
'//status_date',
3399 'created_by' =>
'//created_by',
3400 'created_date' =>
'//created_date',
3401 'query' =>
'//query',
3402 'number_of_members' =>
'//number_of_members',
3403 'additional_info' =>
'//additional_info',
3413 $this->xml = $grima->postSet($this->xml);
3425 $this->xml = $grima->getSet($set_id);
3438 $this->xml = $grima->createSetFromImport($job_id,$population);
3450 function runOnElements($function, $args = array(), $filter = null, $filter_args = array()) {
3452 $xml = $grima->getSetMembers($this[
'set_id'],0);
3453 $xpath =
new DomXpath($xml);
3454 $this->size = $xpath->query(
"//members")->item(0)->getAttribute(
"total_record_count");
3455 $limit = $this->size;
3456 for ($j = 0; $j < ceil($limit/100); $j++) { # how many queries
3457 $xml = $grima->getSetMembers($this[
'id'],100,$j*100);
3458 $xpath =
new DomXpath($xml);
3459 foreach ($xpath->query(
"//member") as $member) {
3460 $id = $member->childNodes[0]->nodeValue;
3461 if (!isset($filter) or ($filter($id,$filter_args))) {
3462 $function($id, $args);
3471 # limit -1 means all
3473 if ($limit == -1) { #
get them all
3474 $xml = $grima->getSetMembers($this[
'set_id'],0);
3475 $xpath =
new DomXpath($xml);
3476 $this->size = $xpath->query(
"//members")->item(0)->getAttribute(
"total_record_count");
3477 $limit = $this->size;
3480 for ($j = 0; $j < ceil($limit/100); $j++) { # how many queries
3481 $xml = $grima->getSetMembers($this[
'id'],100,$j*100);
3482 $xpath =
new DomXpath($xml);
3483 foreach ($xpath->query(
"//member") as $member) {
3485 $member->childNodes[0]->nodeValue,
3486 $member->childNodes[1]->nodeValue
3499 $grima->deleteSet($this[
'set_id']);
3511 $frag =
"<member><id>$id</id></member>";
3512 $source =
new DOMDocument();
3513 $source->loadXML($frag);
3515 $xpath =
new DomXpath($this->xml);
3516 $members = $xpath->query(
'//members')->item(0);
3517 $members->appendChild($this->xml->importNode($source->documentElement,
true));
3530 $grima->postSetManageMembers($this[
'set_id'],null,
'add_members',
3542 $emptyset =
new Set();
3543 $emptyset->addMember(
'9941266686802636');
3544 $grima->postSetManageMembers($this[
'set_id'],null,
'replace_members',
3546 $grima->postSetManageMembers($this[
'set_id'],null,
'delete_members',
3564 $this->description = $description;
3573 public $el_address = array(
3577 'resource_sharing' =>
'//resource_sharing',
3588 $this->xml = $grima->getLibrary($code);
3600 $xml = $grima->getAllLibraries();
3601 $xpath =
new DomXpath($xml);
3602 $codes = $xpath->query(
'//library/code');
3603 $libarray = array();
3604 foreach ($codes as $code) {
3606 $lib->loadFromAlma($code->nodeValue);
3622 $xml = $grima->getAllLibraries();
3623 $xpath =
new DomXpath($xml);
3624 $codes = $xpath->query(
'//library/code');
3626 foreach ($codes as $code) {
3627 if (! in_array($code,$otherthan)) {
3629 $lib->loadFromAlma($code);
3633 throw new Exception(
"No libraries found.");
3645 $xml = $grima->getAllLocations($this[
'code']);
3646 $xpath =
new DomXpath($xml);
3647 $codes = $xpath->query(
'//location/code');
3648 $locarray = array();
3649 foreach ($codes as $code) {
3651 $loc->loadFromAlma($this[
'code'], $code->nodeValue);
3667 $xml = $grima->getAllLocations($this[
'code']);
3668 $xpath =
new DomXpath($xml);
3669 $codes = $xpath->query(
'//location/code');
3670 foreach ($codes as $code) {
3671 if (! in_array($code->nodeValue,$otherthan)) {
3673 $loc->loadFromAlma($this[
'code'],$code->nodeValue);
3677 throw new Exception(
"No locations found.");
3692 $xml = $grima->getAllLibraries();
3693 $xpath =
new DomXpath($xml);
3694 $library_codes = $xpath->query(
'//library/code');
3696 foreach ($library_codes as $library_code) {
3698 $lib->loadFromAlma($library_code->nodeValue);
3700 foreach ($otherthan as $other) {
3701 if ($other[0] == $library_code->nodeValue) {
3706 $loc = $lib->getOneLocation($arr);
3708 }
catch (Exception $e) {
3712 throw new Exception(
"No suitable library/location found.");
3724 public $el_override_fields = array(
'library_code',
'flag');
3726 public $el_address = array(
3729 'external_name' =>
'//external_name',
3731 'remote_storage' =>
'//remote_storage',
3733 'suppress_from_publishing' =>
'//suppress_from_publishing',
3734 'fulfillment_unit' =>
'//fulfillment_unit',
3735 'accession_placement' =>
'//accession_placement',
3736 'call_number_type' =>
'//call_number_type',
3740 if (in_array($offset,$this->el_override_fields)) {
3741 $this->el_override[$offset] = $value;
3743 parent::offsetSet($offset,$value);
3762 $this->xml = $grima->getLocation($libraryCode, $locationCode);
3763 $this[
'library_code'] = $libraryCode;
3774 public $el_address = array(
3777 'description' =>
'//description',
3779 'category' =>
'//category',
3780 'content' =>
'//content',
3781 'schedule' =>
'//schedule',
3782 'creator' =>
'//creator',
3783 'next_run' =>
'//next_run',
3784 'related_profile' =>
'//related_profile',
3785 'additional_info' =>
'//additional_info',
3796 $frag =
"<parameter><name>$name</name><value>$value</value></parameter>";
3797 $source =
new DOMDocument();
3798 $source->loadXML($frag);
3800 $xpath =
new DomXpath($this->xml);
3801 $members = $xpath->query(
'//parameters')->item(0);
3802 $members->appendChild($this->xml->importNode($source->documentElement,
true));
3814 $grima->postJob($this[
'id'],
'run',$this->xml);
3829 public $rows = array();
3837 function runReport($filter_params=array(), $limit = -1, $token =
"") {
3839 if (isset($this->filter)) {
3840 $passfilter = $this->filter;
3841 foreach ($filter_params as $k => $v) {
3842 $passfilter = str_replace(
'{'.$k.
'}',urlencode($v),$passfilter);
3848 if ($limit == -1) { $limit = 1000; } # no limit
3849 if ($limit < 25) { $limit = 25; } # must be in chunks of 25
3850 $this->reportXml = $grima->getAnalytics($this->path, $passfilter, $limit, $token);
3852 $xpath =
new DomXpath($this->reportXml);
3853 $xpath->registerNamespace(
"x",
"urn:schemas-microsoft-com:xml-analysis:rowset");
3855 $rows = $xpath->query(
'//x:Row');
3856 foreach ($rows as $row) {
3858 $cols = $xpath->query(
"./*[contains(name(),'Column')]", $row);
3859 foreach ($cols as $col) {
3860 $newrow[] = $col->nodeValue;
3862 $this->rows[] = $newrow;
3878 $table_esc =
"\"" . preg_replace(
"/\"/",
"\"\"", $table ) .
"\"";
3880 $result = $pdo->query(
"SELECT 1 FROM $table_esc LIMIT 1");
3881 }
catch (Exception $e) {
3886 return $result !== FALSE;
3896 class GrimaDB implements ArrayAccess, IteratorAggregate {
3898 private static $db = FALSE;
3902 return self::getDb();
3906 $db = self::getDb();
3907 $result = $db->query(
'SELECT COUNT(*) as c FROM institutions' );
3908 foreach( $result as $row ) {
3909 if ($row[
'c']>0)
return false;
3915 $db = self::getDb();
3916 return $db ===
'stateless';
3925 if ($db_user && $db_pass) {
3926 self::$db =
new PDO($db_url, $db_user, $db_pass);
3928 self::$db =
new PDO($db_url);
3931 self::$db->exec(
"CREATE TABLE institutions ( institution VARCHAR(100) PRIMARY KEY, apikey VARCHAR(100), server VARCHAR(100) )");
3934 self::$db->exec(
"CREATE TABLE users ( institution VARCHAR(100), username VARCHAR(100), password VARCHAR(255), isAdmin INTEGER )");
3936 }
catch (Exception $e) {
3937 self::$db =
'stateless';
3944 return defined(
"PASSWORD_ARGON2I") ? constant(
"PASSWORD_ARGON2I") : PASSWORD_DEFAULT;
3950 $db = self::getDb();
3951 $result = $db->query(
'SELECT institution FROM institutions' );
3952 foreach( $result as $row ) {
3953 $ret[] = $row[
'institution'];
3955 }
catch (Exception $e) {
3961 return isset($this->info[$offset]);
3965 return isset($this->info[$offset]) ? $this->info[$offset] :
'';
3969 $this->info[$offset] = $value;
3973 unset($this->info[$offset]);
3977 return new ArrayIterator($this->info);
3990 $db = $this->getDb();
3991 $query = $db->prepare(
'INSERT INTO institutions(institution,apikey,server) VALUES (:institution,:apikey,:server)' );
3993 $errorCode = $db->errorCode();
3994 $errorInfo = $db->errorInfo();
3995 throw new Exception(
3996 "Could not even prepare to insert into institution database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
3999 $success = $query->execute( array(
4000 'institution' => $this[
'institution'],
4001 'apikey' => $this[
'apikey'],
4002 'server' => $this[
'server'],
4005 $errorCode = $query->errorCode();
4006 $errorInfo = $query->errorInfo();
4007 throw new Exception(
4008 "Could not insert into user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
4023 foreach ( $data as
$key => $val ) {
4029 public static function LookupUser($username, $institution =
'', $password = FALSE) {
4030 $db = self::getDb();
4031 $query = $db->prepare(
4033 'FROM institutions NATURAL JOIN users '.
4034 'WHERE institution=:institution '.
4035 'AND username=:username'
4037 $success = $query->execute( array(
4038 'institution' => $institution,
4039 'username' => $username,
4042 $row = $query->fetch(PDO::FETCH_ASSOC);
4043 if ($row===
false)
return false;
4045 if ( ($password !== FALSE) && ($user[
'password']!=
'') ) {
4046 if ( !password_verify( $password, $user[
'password'] ) )
return false;
4047 if ( password_needs_rehash( $user[
'password'], $user->getPasswordAlgorithm() ) ) {
4048 $user[
'password'] = $password;
4052 unset( $user[
'password'] );
4055 $errorCode = $query->errorCode();
4056 $errorInfo = $query->errorInfo();
4057 throw new Exception(
4058 "Could not select from user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
4063 public static function RenameUser( $username, $institution, $newusername ) {
4064 $db = self::getDb();
4065 $query = $db->prepare(
4067 'SET username=:newusername ' .
4068 'WHERE institution=:institution '.
4069 'AND username=:username'
4071 $success = $query->execute( array(
4072 'institution' => $institution,
4073 'username' => $username,
4074 'newusername' => $newusername,
4079 $errorCode = $query->errorCode();
4080 $errorInfo = $query->errorInfo();
4081 throw new Exception(
4082 "Could not update user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
4088 $db = self::getDb();
4089 $query = $db->prepare(
4091 'SET password=:password ' .
4092 'WHERE institution=:institution '.
4093 'AND username=:username'
4095 $passwordHash = password_hash( $password, self::getPasswordAlgorithm() );
4096 $success = $query->execute( array(
4097 'institution' => $institution,
4098 'username' => $username,
4099 'password' => $passwordHash,
4104 $errorCode = $query->errorCode();
4105 $errorInfo = $query->errorInfo();
4106 throw new Exception(
4107 "Could not update user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
4113 if (!isset($_SESSION))
return false;
4120 if ( $user !==
false ) {
4121 $grima->session_save($user);
4129 $grima->session_destroy();
4133 $db = $this->getDb();
4134 $query = $db->prepare(
'INSERT INTO users( username, password, institution, isAdmin ) VALUES (:username, :password, :institution, :isAdmin)' );
4136 $errorCode = $db->errorCode();
4137 $errorInfo = $db->errorInfo();
4138 throw new Exception(
4139 "Could not even prepare to insert into user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
4142 $success = $query->execute( array(
4143 'username' => $this[
'username'],
4144 'password' => password_hash( $this[
'password'], $this->getPasswordAlgorithm() ),
4145 'institution' => $this[
'institution'],
4146 'isAdmin' => $this[
'isAdmin'],
4149 $errorCode = $query->errorCode();
4150 $errorInfo = $query->errorInfo();
4151 throw new Exception(
4152 "Could not insert into user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
4158 $db = $this->getDb();
4159 $query = $db->prepare(
'UPDATE users SET isAdmin=:isAdmin, password=:password WHERE username=:username AND institution=:institution' );
4161 $errorCode = $db->errorCode();
4162 $errorInfo = $db->errorInfo();
4163 throw new Exception(
4164 "Could not even prepare to update user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
4167 $success = $query->execute( array(
4168 'username' => $this[
'username'],
4169 'password' => password_hash( $this[
'password'], $this->getPasswordAlgorithm() ),
4170 'institution' => $this[
'institution'],
4171 'isAdmin' => $this[
'isAdmin'],
4174 $errorCode = $query->errorCode();
4175 $errorInfo = $query->errorInfo();
4176 throw new Exception(
4177 "Could not update user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
4183 $db = $this->getDb();
4184 $query = $db->prepare(
'DELETE FROM users WHERE username=:username AND institution=:institution' );
4186 $errorCode = $db->errorCode();
4187 $errorInfo = $db->errorInfo();
4188 throw new Exception(
4189 "Could not even prepare to delete from user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
4192 $success = $query->execute( array(
4193 'username' => $this[
'username'],
4194 'institution' => $this[
'institution'],
4197 $errorCode = $query->errorCode();
4198 $errorInfo = $query->errorInfo();
4199 throw new Exception(
4200 "Could not delete from user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}"
4213 implements SessionHandlerInterface {
4221 $this->session_key =
$key;
4222 $this->last_read =
"Not This";
4225 public function open ( $save_path, $session_name ) {
4226 $this->save_path = $save_path;
4227 $this->session_name = $session_name;
4228 #error_log("session_open($save_path,$session_name)");
4233 #error_log("session_close()");
4238 #error_log("session_destroy($session_id)");
4239 $params = session_get_cookie_params();
4240 $params[
'expires'] = time() - 42000;
4241 unset($params[
'lifetime']);
4242 setcookie( $this->session_name,
'', $params );
4246 public function gc ($maxlifetime) {
4247 #error_log("session_gc($maxlifetime)");
4251 public function read ($session_id) {
4252 #error_log("session_read($session_id)");
4253 $nonce_ciphertext_b64 = isset( $_COOKIE[$this->session_name] ) ? $_COOKIE[$this->session_name] :
"";
4254 if ($nonce_ciphertext_b64) {
4255 $nonce_ciphertext = base64_decode( $nonce_ciphertext_b64 );
4256 if (strlen($nonce_ciphertext)>24+16) {
4257 $nonce = substr( $nonce_ciphertext, 0, 24 );
4260 #error_log("session_read -> $plaintext");
4264 error_log(
"cookie too short: $nonce_ciphertext_b64");
4267 #error_log("cookie not set or empty");
4272 public function write ($session_id, $session_data) {
4273 #error_log("session_write($session_id,$session_data)");
4274 if (!$session_data)
return true;
4275 if ($this->last_read == $session_data)
return true;
4276 $nonce = random_bytes(24);
4277 $ciphertext = sodium_crypto_secretbox( $session_data, $nonce, $this->session_key );
4278 $nonce_ciphertext = $nonce.$ciphertext;
4279 $nonce_ciphertext_b64 = base64_encode( $nonce_ciphertext );
4280 $options = session_get_cookie_params();
4281 if (isset($options[
'expires']) && $options[
'expires']) {
4282 $options[
'expires'] += time();
4284 unset($options[
'lifetime']);
4285 setcookie( $this->session_name, $nonce_ciphertext_b64, $options );
putBib($mms_id, $bib)
Update Bib Record - updates the copy of the bib in Alma.
getPortfolios($limit=10, $offset=0)
get list of portfolios from Alma
static exists()
checks whether a grima data store has been set up in Alma
request($method, $url, $URLparams, $QSparams, $body=null)
general function for REST API calls
postSetManageMembers($set_id, $id_type, $op, $set)
Manage Members - modify sets in Alma.
hasItems()
checks whether a holding record has any items
runReport($filter_params=array(), $limit=-1, $token="")
pull Analytics report from Alma
offsetSet($offset, $value)
unlinkFromCZ()
does this work : Not supported for CZ
offsetSet($offset, $value)
deleteAllPortfolios()
delete all portfolios from the bib
offsetSet($offset, $value)
loadFromAlma($mms_id, $holding_id, $item_pid)
populates item record from Alma
write($session_id, $session_data)
removeAllMembersInAlma()
remove all members of the set
getBib($mms_id, $view='full', $expand='None')
Retrieve Bib - retrieve a bib record from Alma.
deleteTreeFromAlma()
deletes the Bib and its inventory #XXX
addToAlmaHolding($mms_id, $holding_id)
add new item record to holding in Alma
getAllLibraries()
Retrieve Libraries - retrieve all libraries.
deleteHolding($mms_id, $holding_id, $override='false')
Delete Holdings Record - delete the holdings record from Alma.
deleteBib($mms_id, $override='false')
Delete Bib Record - deletes the bib record from Alma.
putItem($mms_id, $holding_id, $item_pid, $item)
Update Item information - replace item record in Alma.
static ResetPassword( $username, $institution, $password)
runInAlma()
run a job in Alma
getHolding($mms_id, $holding_id)
Retrieve Holdings Record - retrieve holdings record from Alma.
loadFromAlma($mms_id, $holding_id)
populates the record from Alma
loadFromAlma($set_id)
populate set with info from Alma
static RenameUser( $username, $institution, $newusername)
deleteFromAlma($override="false", $holdings="retain")
delete record from Alma
loadFromServiceListNode($node)
populate item record from the information in an ServiceList node
deleteAllPortfolios($bib_treat)
delete all portfolios from the service
putHolding($mms_id, $holding_id, $holding)
Update Holdings Record - replace the holdings record in Alma.
updateAlma()
update holding record in Alma
getSetMembers($set_id, $limit=10, $offset=0)
get the members of a set, IF IT WORKS?!?!
getElectronicCollection($collection_id)
Retrieve Electronic Collection - retrieve a collection record from Alma.
open( $save_path, $session_name)
updateAlma()
replaces the Portfolio in Alma
getLCCallNumber()
get LC call number, giving pref to 090 and later fields
addToAlmaBib($mms_id)
adds a new holding record to the specified bib
loadFromAlmaX($portfolio_id)
offsetSet($offset, $value)
class ElectronicPortfolio
postElectronicPortfolioOnBib($mms_id, $portfolio, $update=true)
Create Electronic Portfolio - add a new portfolio to Alma Bib.
getElectronicPortfoliosForService($collection_id, $service_id, $limit, $offset)
Retrieve Portfolios - retrieve a list of portfolios from Alma.
loadFromAlma($code)
populate library with info from Alma
postJob($job_id, $op, $job)
Submit a manual or scheduled job.
static SetCurrentUser( $username, $password, $institution='')
loadFromItemListNode($node)
populate item record from the information in an ItemList node
getItem($mms_id, $holding_id, $item_pid)
Retrieve Item and print label information.
getElectronicPortfolio($collection_id, $service_id, $portfolio_id)
Retrieve Portfolio - retrieve a portfolio record from Alma.
updateAlma()
replace item record in Alma
setCallNumber($h, $i, $ind1)
getHoldings()
populate holdings property with Holdings items
static LogoutCurrentUser()
getHoldingsList($mms_id)
Retrieve Holdings list - download brief descriptions of holdings for the bib.
deleteElectronicPortfolio($collection_id, $service_id, $portfolio_id)
Delete Electronic Portfolio - delete portfolio from Alma.
getMarcFields($tag)
get fields for the given MARC tag
offsetSet($offset, $value)
getFields($tag)
get fields for the given MARC tag
loadFromAlmaBCorX($id)
populates item record from Alma using either identifier
deleteFromAlma($bib_treat="retain")
delete portfolio from Alma
session_init( $force=false)
tableExists($pdo, $table)
hasInventory()
populate holdings property with Holdings items
appendInnerXML( $elt, $xmlString)
static getOneLibraryLocation($otherthan=array())
get one library configured by the institution
addParameter($name, $value)
add a parameter to the job
loadFromPortfolioListNode($node)
populate item record from the information in an PortfolioList node
deleteFromAlma()
delete set from Alma
addToAlmaHoldingX($holding_id)
add new item record to holding in Alma
getItemList()
populates itemList property from Alma
deleteFromAlma()
delete the holding record from Alma
loadFromAlmaBarcode($barcode)
populates item record from Alma, using barcode
getPortfolios()
get full portfolios for the bib
putElectronicPortfolioOnBib($mms_id, $portfolio_id, $portfolio)
Update Electronic Portfolio - update portfolio in Alma.
Shared access to the database for GrimaUser and GrimaInstitution.
offsetSet($offset, $value)
grima-lib.php - a library for running API calls in Alma
__construct($type, $message)
getenvWithFileFallbackAndDefault( $env_name, $default=false)
getElectronicPortfoliosForBib($mms_id, $limit, $offset)
Retrieve Portfolios list (Bib) - retrieve a list of portfolios from Alma.
loadFromAlma($portfolio_id)
populate portfolio with info from Alma
The base class for most "grimas".
Interface to the GrimaDB database to check password and get institution's apikey. ...
static getOneLibrary($otherthan=array())
get one library configured by the institution
offsetSet($offset, $value)
appendInAlma($setToAppend)
add elements to a set
postElectronicPortfolio($collection_id, $service_id, $portfolio)
Create Electronic Portfolio - add a new portfolio to Alma.
getAnalytics($path, $filter, $limit=25, $token=null)
addDataField($tag, $indicators, $subfields)
add a data field to the MARC record using Normac
getHoldingsList()
populate holdingsList property with info from Alma
offsetSet($offset, $value)
deleteFromAlma()
deletes the Bib from Alma
__construct()
create new blank Alma Object
postHolding($mms_id, $holding)
Create holding record - add a new holdings record to a bib.
__construct($id, $description)
Methods for fields and subfields in Alma's MARCXML.
getMmsIfNeeded()
populates the MMS ID if not already known
addToAlmaService($collection_id, $service_id)
populate item record from the information in an PortfolioList node : Insufficient permission ...
getLibrary($libraryCode)
Retrieve a Library - retrieve a Library from Alma.
Interface to the GrimaDB database to retrieve API keys.
getSubfieldValues($tag, $code)
get subfield value
addToAlma()
adds Set to Alma, updates object with current Alma version
postBib($bib)
Create Record - adds a new bib record to Alma.
getSet($set_id)
Retrieve a Set - retrieve a Set from Alma.
Base class for objects returned from alma APIs (mostly just array access)
loadFromAlma($mms_id)
populates the bib with a record from Alma
static call($grimaname, $args=array())
static getAllLibraries()
get all libraries configured for the institution
checkForErrorMessage($xml)
checks for errorMessage tag, throws exceptions
loadFromAlmaX($item_pid)
populates item record from Alma, only needs item_pid
put($url, $URLparams, $QSparams, $body)
general function for PUT (update) API calls
__construct()
make sure it exists
__construct($node, $mms_id)
addMessage($type, $message)
getElectronicPortfolioFromBib($mms_id, $portfolio_id)
Retrieve Portfolio - retrieve a portfolio record from Alma.
linkedToCZ()
is the bib linked to the community zone?
postSet($set)
Create a Set - add a new set to Alma.
loadFromAlma($collection_id)
load record from Alma
A thin wrapper around a message and urgency level.
getItemList()
populates itemList property from Alma
getPortfolioList()
populate portfolioList property with brief info from Alma
deleteField($tag)
delete all $tag fields from the MARC record
normacToXML()
convert normac fields back to XML
createFromImport($job_id, $population)
create a new set in Alma based on a job that just ran
class ElectronicCollection
replaceOrAddSubfield($tag, $code, $value)
replace or add subfield value in marc
bib records returned from alma
addToAlmaBib($mms_id)
add portfolio to Bib in Alma : Insufficient permission
addControlField($tag, $data)
add a data field to the MARC record using Normac
__construct($mms_id, $holding_id, $limit=-1)
loadFromAlma($libraryCode, $locationCode)
populate location with info from Alma
getItemBC($barcode)
Retrieve Item and print label information (by barcode))
get_title_proper()
a tidy title proper
getItems()
populate items property with Items objects ## XXX TEST
destroy()
remove the grima data store from Alma
getOneLocation($otherthan=array())
get one location configured for the library
addMember($id)
add member to a local set
arrayToXml($array, &$xml)
static getMmsFromHoldingID($holding_id)
populates the MMS ID
getAllLocations($libraryCode)
Retrieve Locations - retrieve all locations in a library.
addToAlma()
adds record as a new record to Alma, updates Bib with current Alma version
getLocation($libraryCode, $locationCode)
Retrieve Location - retrieve a Library Location from Alma.
updateAlma()
replaces the Bib in Alma
deleteItem($mms_id, $holding_id, $item_pid, $override="false", $holdings="retain")
Withdraw Item - delete an item record from Alma.
getItemList($mms_id, $holding_id, $limit, $offset)
Retrieve Items list - retrieve the items list from a holding or bib from Alma.
loadFromAlma($collection_id, $service_id)
load record from Alma
deleteSet($set_id)
Delete a Set - delete a set (not its items) from Alma.
updateAlma()
replace the collection record in Alma
deleteSubfieldMatching($tag, $code, $regex)
delete subfields matching a regex
__construct($mms_id=null)
getItems()
populate items property with Items objects ## XXX TEST
loadFromAlmaX($holding_id)
populates the record from Alma - only requires holding_id
setup()
create the record structure in Alma
runOnElements($function, $args=array(), $filter=null, $filter_args=array())
run a function on every element in the set
getAllLocations()
get all locations configured for the library
This object lets grima store data in a catalog record.
static LookupUser($username, $institution='', $password=FALSE)
moveToBib($mms_id)
moves the holding from one bib to another – only for empty holdings!
createSetFromImport($job_instance_id, $population)
Create a Set from an import job.
putElectronicCollection($collection_id, $collection)
Update Electronic Collection Record - updates the copy of the collection in Alma. ...
deleteTreeFromAlma()
delete the holding and all of its items
appendField($tag, $ind1, $ind2, $subfields)
add a field to the MARC record
getElectronicServices($collection_id)
Retrieve Electronic Services - retrieve a list of services from a collection in Alma.
getServices()
load record from Alma
post($url, $URLparams, $QSparams, $body)
general function for POST (create) API calls
postItem($mms_id, $holding_id, $item)
Create Item - add a new item to a holding in Alma.