8 require_once(
"grima-util.php");
9 require_once(
"grima-xmlbag.php");
10 require_once
"grima-splats.php";
21 if( !isset($_SESSION) ) {
22 $session_name =
'grima';
23 $session_dir =
join_paths( sys_get_temp_dir(),
'grima' );
24 @mkdir($session_dir, 0777,
true);
25 session_save_path($session_dir);
26 session_name( $session_name );
27 session_set_cookie_params(365*24*60*60); # one year
28 ini_set(
'session.gc_maxlifetime',525600*60); # of love
29 if( $force || isset($_COOKIE[$session_name]) ) {
37 foreach( $result as $key => $value ) {
38 $_SESSION[$key] = $value;
40 session_write_close();
46 if (ini_get(
"session.use_cookies")) {
47 $params = session_get_cookie_params();
48 setcookie(session_name(),
'', time() - 42000,
49 $params[
"path"], $params[
"domain"],
50 $params[
"secure"], $params[
"httponly"]
66 # $_REQUEST, $_SESSION, $_SERVER, $_ENV, grima-config.php 68 if (isset($_REQUEST[
'apikey']) and isset($_REQUEST[
'server']) and
69 ($_REQUEST[
'apikey']) and ($_REQUEST[
'server'])
72 'apikey' => $_REQUEST[
'apikey'],
73 'server' => $_REQUEST[
'server']
75 $this->apikey = $_REQUEST[
'apikey'];
76 $this->server = $_REQUEST[
'server'];
81 if ( isset($_SESSION) ) {
82 session_write_close();
84 isset($_SESSION[
'apikey']) and
85 isset($_SESSION[
'server']) and
86 ($_SESSION[
'apikey']) and
89 $this->apikey = $_SESSION[
'apikey'];
90 $this->server = $_SESSION[
'server'];
95 if ( isset($_SERVER[
'apikey']) and isset($_SERVER[
'server']) and
96 ($_SERVER[
'apikey']) and ($_SERVER[
'server'])) {
97 $this->apikey = $_SERVER[
'apikey'];
98 $this->server = $_SERVER[
'server'];
102 if ( isset($_ENV[
'apikey']) and isset($_ENV[
'server']) and
103 ($_ENV[
'apikey']) and ($_ENV[
'server'])) {
104 $this->apikey = $_ENV[
'apikey'];
105 $this->server = $_ENV[
'server'];
109 if( file_exists(
"grima-config.php") ) {
110 require(
'grima-config.php'); #
this should
set those
130 function get($url,$URLparams,$QSparams) {
131 # returns a DOM document 132 foreach ($URLparams as $k => $v) {
133 $url = str_replace(
'{'.$k.
'}',urlencode($v),$url);
135 $url = $this->server . $url .
'?apikey=' . urlencode($this->apikey);
136 foreach ($QSparams as $k => $v) {
140 curl_setopt($ch, CURLOPT_URL, $url);
141 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
142 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
143 curl_setopt($ch, CURLOPT_HEADER, FALSE);
144 curl_setopt($ch, CURLOPT_CUSTOMREQUEST,
'GET');
145 $response = curl_exec($ch);
146 $code = curl_getinfo($ch,CURLINFO_HTTP_CODE);
147 if (curl_errno($ch)) {
148 throw new Exception(
"Network error: " . curl_error($ch));
151 $xml =
new DOMDocument();
153 if (!preg_match(
'/^</',$response)) {
154 throw new Exception($url);
156 $xml->loadXML($response);
157 }
catch (Exception $e) {
158 throw new Exception(
"Malformed XML from Alma: $e");
174 function post($url,$URLparams,$QSparams,$body) {
175 foreach ($URLparams as $k => $v) {
176 $url = str_replace(
'{'.$k.
'}',urlencode($v),$url);
178 $url = $this->server . $url .
'?apikey=' . urlencode($this->apikey);
179 foreach ($QSparams as $k => $v) {
183 $bodyxml = $body->saveXML();
186 curl_setopt($ch, CURLOPT_URL, $url);
187 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
188 curl_setopt($ch, CURLOPT_HEADER, FALSE);
189 curl_setopt($ch, CURLOPT_CUSTOMREQUEST,
'POST');
190 curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyxml);
191 curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/xml'));
192 $response = curl_exec($ch);
193 $code = curl_getinfo($ch,CURLINFO_HTTP_CODE);
194 if (curl_errno($ch)) {
195 throw new Exception(
"Network error: " . curl_error($ch));
198 $xml =
new DOMDocument();
200 $xml->loadXML($response);
201 }
catch (Exception $e) {
202 throw new Exception(
"Malformed XML from Alma: $e");
218 function put($url,$URLparams,$QSparams,$body) {
219 foreach ($URLparams as $k => $v) {
220 $url = str_replace(
'{'.$k.
'}',urlencode($v),$url);
222 $url = $this->server . $url .
'?apikey=' . urlencode($this->apikey);
223 foreach ($QSparams as $k => $v) {
227 $bodyxml = $body->saveXML();
230 curl_setopt($ch, CURLOPT_URL, $url);
231 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
232 curl_setopt($ch, CURLOPT_HEADER, FALSE);
233 curl_setopt($ch, CURLOPT_CUSTOMREQUEST,
'PUT');
234 curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyxml);
235 curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/xml'));
236 $response = curl_exec($ch);
237 $code = curl_getinfo($ch,CURLINFO_HTTP_CODE);
238 if (curl_errno($ch)) {
239 throw new Exception(
"Network error: " . curl_error($ch));
242 $xml =
new DOMDocument();
244 $xml->loadXML($response);
245 }
catch (Exception $e) {
246 throw new Exception(
"Malformed XML from Alma: $e");
260 function delete($url,$URLparams,$QSparams) {
261 foreach ($URLparams as $k => $v) {
262 $url = str_replace(
'{'.$k.
'}',urlencode($v),$url);
264 $url = $this->server . $url .
'?apikey=' . urlencode($this->apikey);
265 foreach ($QSparams as $k => $v) {
269 curl_setopt($ch, CURLOPT_URL, $url);
270 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
271 curl_setopt($ch, CURLOPT_HEADER, FALSE);
272 curl_setopt($ch, CURLOPT_HTTPHEADER,
273 array (
"Accept: application/xml"));
274 curl_setopt($ch, CURLOPT_CUSTOMREQUEST,
'DELETE');
275 $response = curl_exec($ch);
276 $code = curl_getinfo($ch,CURLINFO_HTTP_CODE);
277 if (curl_errno($ch)) {
278 throw new Exception(
"Network error: " . curl_error($ch));
282 $xml =
new DOMDocument();
284 $xml->loadXML($response);
285 }
catch (Exception $e) {
286 throw new Exception(
"Malformed XML from Alma: $e");
299 if ($xml instanceOf DomDocument) {
300 $xpath =
new DomXpath($xml);
301 $xpath->registerNamespace(
"err",
"http://com/exlibris/urm/general/xmlbeans");
302 $error = $xpath->query(
'//err:errorMessage');
303 if ($error->length > 0) {
304 throw new Exception(
"Alma says: " . $error[0]->nodeValue);
330 function getBib($mms_id, $view =
'full', $expand =
'None') {
331 $ret = $this->
get(
'/almaws/v1/bibs/{mms_id}',
332 array(
'mms_id' => $mms_id),
333 array(
'view' => $view,
'expand' => $expand)
353 $ret = $this->
post(
'/almaws/v1/bibs',
377 $ret = $this->
put(
'/almaws/v1/bibs/{mms_id}',
378 array(
'mms_id' => $mms_id),
400 $ret = $this->
delete(
'/almaws/v1/bibs/{mms_id}',
401 array(
'mms_id' => $mms_id),
402 array(
'override' => $override)
429 $ret = $this->
get(
'/almaws/v1/bibs/{mms_id}/holdings',
430 array(
'mms_id' => $mms_id),
459 $ret = $this->
get(
'/almaws/v1/bibs/{mms_id}/holdings/{holding_id}',
462 'holding_id' => $holding_id
485 $ret = $this->
post(
'/almaws/v1/bibs/{mms_id}/holdings',
486 array(
'mms_id' => $mms_id),
510 $ret = $this->
put(
'/almaws/v1/bibs/{mms_id}/holdings/{holding_id}',
511 array(
'mms_id' => $mms_id,
'holding_id' => $holding_id),
532 $ret = $this->
delete(
'/almaws/v1/bibs/{mms_id}/holdings/{holding_id}',
535 'holding_id' => $holding_id
537 array(
'override' => $override)
566 $ret = $this->
get(
'/almaws/v1/bibs/{mms_id}/holdings/{holding_id}/items', array(
'mms_id' => $mms_id,
'holding_id' => $holding_id),
567 array(
'limit' => $limit,
'offset' => $offset)
594 function getItem($mms_id,$holding_id,$item_pid) {
595 $ret = $this->
get(
'/almaws/v1/bibs/{mms_id}/holdings/{holding_id}/items/{item_pid}', array(
597 'holding_id' => $holding_id,
598 'item_pid' => $item_pid
619 $ret = $this->
get(
'/almaws/v1/items',
622 'item_barcode' => $barcode,
645 $ret = $this->
post(
'/almaws/v1/bibs/{mms_id}/holdings/{holding_id}/items',
646 array(
'mms_id' => $mms_id,
'holding_id' => $holding_id),
670 function putItem($mms_id,$holding_id,$item_pid,$item) {
671 $ret = $this->
put(
'/almaws/v1/bibs/{mms_id}/holdings/{holding_id}/items/{item_pid}',
672 array(
'mms_id' => $mms_id,
'holding_id' => $holding_id,
'item_pid' => $item_pid),
695 function deleteItem($mms_id,$holding_id,$item_pid,$override =
"false",
696 $holdings =
"retain") {
697 $ret = $this->
delete(
'/almaws/v1/bibs/{mms_id}/holdings/{holding_id}/items/{item_pid}', array(
699 'holding_id' => $holding_id,
700 'item_pid' => $item_pid
702 'override' => $override,
703 'holdings' => $holdings
732 $ret = $this->
get(
'/almaws/v1/electronic/e-collections/{collection_id}/e-services/{service_id}/portfolios/{portfolio_id}',
733 array(
'collection_id' => $collection_id,
'service_id' => $service_id,
'portfolio_id' => $portfolio_id),
755 $ret = $this->
get(
'/almaws/v1/bibs/{mms_id}/portfolios/{portfolio_id}',
756 array(
'mms_id' => $mms_id,
'portfolio_id' => $portfolio_id),
779 $ret = $this->
post(
'/almaws/v1/electronic/e-collections/{collection_id}/e-services/{service_id}/portfolios',
780 array(
'collection_id' => $collection_id,
'service_id' => $service_id),
802 $ret = $this->
post(
'/almaws/v1/bibs/{mms_id}/portfolios/',
803 array(
'mms_id' => $mms_id),
826 $ret = $this->
put(
'/almaws/v1/bibs/{mms_id}/portfolios/{portfolio_id}',
827 array(
'mms_id' => $mms_id,
'portfolio_id' => $portfolio_id),
850 $ret = $this->
delete(
'/almaws/v1/electronic/e-collections/{collection_id}/e-services/{service_id}/portfolios/{portfolio_id}',
851 array(
'collection_id' => $collection_id,
'service_id' => $service_id,
'portfolio_id' => $portfolio_id),
874 $ret = $this->
get(
'/almaws/v1/electronic/e-collections/{collection_id}/e-services/{service_id}/portfolios',
875 array(
'collection_id' => $collection_id,
'service_id' => $service_id),
876 array(
'limit' => $limit, $offset = $offset)
898 $ret = $this->
get(
'/almaws/v1/bibs/{mms_id}/portfolios',
899 array(
'mms_id' => $mms_id),
900 array(
'limit' => $limit, $offset = $offset)
920 $ret = $this->
get(
'/almaws/v1/electronic/e-collections/{collection_id}',
921 array(
'collection_id' => $collection_id),
943 $ret = $this->
get(
'/almaws/v1/electronic/e-collections/{collection_id}/e-services',
944 array(
'collection_id' => $collection_id),
972 $ret = $this->
get(
'/almaws/v1/conf/libraries/{libraryCode}',
973 array(
'libraryCode' => $libraryCode),
1001 $ret = $this->
get(
'/almaws/v1/conf/libraries/{libraryCode}/locations/{locationCode}',
1003 'libraryCode' => $libraryCode,
1004 'locationCode' => $locationCode,
1033 $ret = $this->
get(
'/almaws/v1/conf/sets/{set_id}',
1034 array(
'set_id' => $set_id),
1063 $body =
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?' .
'> 1065 <name>Grima set from ' . $job_instance_id .
'</name> 1066 <description>members of ' . $job_instance_id .
'</description> 1067 <type desc="Itemized">ITEMIZED</type> 1068 <content desc="All Titles">BIB_MMS</content> 1069 <private desc="No">false</private> 1090 $bodyxml =
new DomDocument();
1091 $bodyxml->loadXML($body);
1093 $ret = $this->
post(
'/almaws/v1/conf/sets', array(), array(
'job_instance_id' => $job_instance_id,
'population' => $population),$bodyxml);
1112 $ret = $this->
delete(
'/almaws/v1/conf/sets/{set_id}',
1114 'set_id' => $set_id,
1136 $ret = $this->
get(
'/almaws/v1/conf/sets/{set_id}/members',
1137 array(
'set_id' => $set_id),
1138 array(
'limit' => $limit,
'offset' => $offset)
1152 # XXX check if blank filter is ok 1154 return $this->
get(
'/almaws/v1/analytics/reports',
1156 array(
'path' => urlencode($path),
'filter' => urlencode($filter),
1157 'limit' => $limit,
'token' => $token)
1185 return isset($this->args[$offset]);
1189 return $this->args[$offset];
1193 $this->args[$offset] = $value;
1197 unset($this->args[$offset]);
1202 $base = get_class($this);
1203 if (file_exists(
join_paths($webroot,$base,
"$base.xml")) and (!isset($this->formxml))) {
1204 $this->formxml = file_get_contents(
join_paths($webroot,$base,
"$base.xml"));
1206 if (isset($this->formxml)) {
1208 $this->form->fromXML($this->formxml);
1214 $basename = get_class($this);
1218 $this->splat->addBases(array(
1219 "$webroot/$basename/splats",
1223 $this->splatVars = array(
1224 'title' => $this->form->title,
1225 'basename' => $basename,
1226 'webroot' => $webroot,
1227 'local_stylesheets' => array(
'Grima.css'),
1228 'form' => &$this->form,
1229 'messages' => &$this->messages,
1232 if (isset($this[
'redirect_url'])) {
1233 $this->splatVars[
'redirect_url'] = $this[
'redirect_url'];
1238 $this->form->loadValues($this);
1239 $this->splat->splat(
'print_form', $this->splatVars );
1243 $this->form->loadPersistentValues($this);
1244 $this->splat->splat(
'print_success', $this->splatVars );
1248 $this->form->loadValues($this);
1249 $this->splat->splat(
'print_failure', $this->splatVars );
1254 if (isset(
$grima->apikey) and isset(
$grima->server) and
1258 do_redirect(
'../Login/Login.php?redirect_url=' . urlencode($_SERVER[
'PHP_SELF']));
1269 $this->
check_login(); #
if not logged in, print login form
1270 $this->error =
false;
1276 }
catch (Exception $e) {
1278 $this->error =
true;
1292 $task =
new static();
1297 if (isset($this->form)) {
1298 if (php_sapi_name() ==
"cli") { # command line
1312 foreach ($this->form->fields as $field) {
1313 if (isset($_REQUEST[$field->name])) {
1314 $this[$field->name] = $_REQUEST[$field->name];
1326 if (isset($this->form)) {
1328 foreach ($this->form->fields as $field) {
1329 if ($field->required) {
1330 if (!isset($this[$field->name]) or
1331 !($this[$field->name])) {
1332 $field->error_condition =
"error";
1333 $field->error_message =
"Field is required\n";
1334 $input_good =
false;
1341 foreach ($this->auto_args as $k => $v) {
1342 if (preg_match(
'/[^:]:$/',$k)) {
1343 if (!isset($this->args[$v]) or !($this->args[$v])) {
1353 if (php_sapi_name() ==
"cli") { # command line
1354 if ($options = getopt(implode(array_keys($param)))) {
1355 foreach ($param as $k => $v) {
1356 $this->args[$v] = $options[$k[0]];
1359 $this->
usage(); exit;
1362 $this->
usage(); exit;
1365 foreach ($param as $k => $v) {
1366 if (isset($_REQUEST[$v])) {
1367 $this->args[$v] = $_REQUEST[$v];
1378 function usage() { # XXX rewrite
for grima form
1380 print
"Usage: php ${argv[0]} ";
1381 foreach ($this->auto_args as $k => $v) {
1382 if (preg_match(
'/^(.):$/',$k,$m)) {
1383 print
"-${m[1]} <$v> ";
1385 if (preg_match(
'/^(.)::$/',$k,$m)) {
1386 print
"[ -${m[1]} <$v> ] ";
1388 if (preg_match(
'/^.$/',$k)) {
1399 $url = rtrim(
"../$grimaname/$grimaname.php?" . http_build_query(
$args),
"?");
1417 $this->type =
$type;
1440 foreach ($this->fields as $field) {
1441 if (isset($obj[$field->name])) {
1442 $field->value = $obj[$field->name];
1455 foreach ($this->fields as $field) {
1456 if (($field->persistent) and isset($obj[$field->name])) {
1457 $field->value = $obj[$field->name];
1471 $doc =
new DomDocument();
1472 $doc->loadXML($xml);
1473 $xpath =
new DomXpath($doc);
1474 $this->title = $xpath->query(
'//Title')[0]->nodeValue;
1475 $this->action = basename($_SERVER[
'PHP_SELF']); # allow
set?
1477 $nodes = $xpath->query(
'//Field');
1478 foreach ($nodes as $node) {
1479 $this->fields[$node->getAttribute(
'name')] =
new GrimaFormField($node);
1517 function booly($str, $default =
'undefined') {
1518 switch(strtolower($str)) {
1544 $this->name = $field->getAttribute(
'name');
1545 $this->label = $field->getAttribute(
'label');
1546 $this->placeholder = $field->getAttribute(
'placeholder');
1547 $this->rows = $field->getAttribute(
'rows');
1548 $this->type = $field->getAttribute(
'type');
1550 $this->type =
'input';
1552 $this->required = $this->
booly($field->getAttribute(
'required'),
true);
1553 $this->persistent = $this->
booly($field->getAttribute(
'persistent'),
false);
1554 $this->autocomplete = $this->
booly($field->getAttribute(
'autocomplete'),
false);
1555 $this->visible = $this->
booly($field->getAttribute(
'visible'),
true);
1556 $this->options = array();
1557 foreach ($field->getElementsByTagName(
"option") as $option) {
1558 $this->options[] = $option->ownerDocument->saveXML( $option );
1581 $this->xml =
new DomDocument();
1582 $blankRecord = get_class($this);
1583 $this->xml->loadXML(file_get_contents(
"{$this->templateDir}/{$blankRecord}.xml"));
1588 if (isset($this->el_override)) {
1589 return array_key_exists($offset, $this->el_override);
1591 return array_key_exists($offset, $this->el_access);
1595 if ((isset($this->el_override)) and
1596 (isset($this->el_override[$offset]))) {
1597 return $this->el_override[$offset];
1599 $xpath =
new DomXpath($this->xml);
1600 $node = $xpath->query($this->el_address[$offset]);
1601 if (count($node) >= 1) {
1602 return $node[0]->nodeValue;
1608 $xpath =
new DomXpath($this->xml);
1609 $node = $xpath->query($this->el_address[$offset]);
1610 $node[0]->nodeValue = $value;
1614 $xpath =
new DomXpath($this->xml);
1615 $node = $xpath->query($this->el_address[$offset]);
1616 $node[0]->nodeValue = null;
1639 $frag =
"<datafield ind1=\"$ind1\" ind2=\"$ind2\" tag=\"$tag\">";
1640 foreach ($subfields as $k => $v) {
1641 $frag .=
"<subfield code=\"$k\">$v</subfield>";
1643 $frag .=
"</datafield>";
1644 $xpath =
new DomXpath($this->xml);
1645 $record = $xpath->query(
"//record");
1658 $xpath =
new DomXpath($this->xml);
1659 $tag = preg_replace(
'/X*$/',
'',$tag);
1660 $tag = preg_replace(
'/\.*$/',
'',$tag);
1661 $fields = $xpath->query(
"//record/datafield[starts-with(@tag,'$tag')]");
1662 $fieldarr = array();
1663 foreach ($fields as $field) {
1664 $subfieldarr = array();
1665 foreach ($field->childNodes as $child) {
1666 $subfieldarr[] = array(
1667 $child->attributes[0]->value,
1671 $fieldarr[] = $subfieldarr;
1686 $xpath =
new DomXpath($this->xml);
1687 $subfields = $xpath->query(
"//record/datafield[@tag='$tag']/subfield[@code='$code']");
1689 foreach ($subfields as $subfield) {
1690 $arr[] = $subfield->nodeValue;
1703 $xpath =
new DomXpath($this->xml);
1704 $fields = $xpath->query(
"//record/datafield[@tag='$tag']");
1705 foreach( $fields as $field ) {
1706 $field->parentNode->removeChild( $field );
1718 $xpath =
new DomXPath($this->xml);
1719 $subfs = $xpath->query(
"//datafield[@tag='$tag']/subfield[@code='$code']");
1720 foreach ($subfs as $subf) {
1721 if (preg_match($regex,$subf->nodeValue)) {
1722 $subf->parentNode->removeChild($subf);
1737 # very shady but sometimes needed 1738 $xpath =
new DomXpath($this->xml);
1739 $fields = $xpath->query(
"//record/datafield[@tag='$tag']");
1740 if (
sizeof($fields) == 0) {
1741 $this->
appendField($tag,
' ',
' ',array($code => $value));
1744 foreach ($fields[0]->childNodes as $subfield) {
1745 if($subfield->nodeType !== 1) {
1748 if ($subfield->getAttribute(
"code") == $code) {
1749 $subfield->nodeValue = $value;
1755 $subfield = $this->xml->createElement(
"subfield");
1756 $subfield->setAttribute(
"code",$code);
1757 $subfield->appendChild($this->xml->createTextNode($value));
1758 $fields[0]->appendChild($subfield);
1797 'mms_id' =>
'//mms_id',
1798 'leader' =>
'//leader',
1799 'record_format' =>
'//record_format',
1800 'title' =>
'//title',
1801 'author' =>
'//author',
1802 'place_of_publication' =>
'//place_of_publication',
1803 'publisher_const' =>
'//publisher_const',
1804 'publisher' =>
'//publisher_const' 1808 if ($offset ==
'Type') {
1809 $leader = $this[
'leader'];
1812 if ($offset ==
'BLvl') {
1813 $leader = $this[
'leader'];
1816 if ($offset ==
'ELvl') {
1817 $leader = $this[
'leader'];
1820 if ($offset ==
'Desc') {
1821 $leader = $this[
'leader'];
1824 return parent::offsetGet($offset);
1827 # override because these go multiple places 1829 parent::offsetSet($offset,$value);
1830 if ($offset ==
'author') {
1833 if ($offset ==
'title') {
1836 if (($offset ==
'publisher_const') or ($offset ==
'publisher')) {
1839 if ($offset ==
'place_of_publication') {
1852 $this->xml =
$grima->getBib($mms_id);
1863 $this->xml =
$grima->postBib($this->xml);
1873 $this->xml =
$grima->putBib($this[
'mms_id'],$this->xml);
1883 $grima->deleteBib($this[
'mms_id']);
1894 foreach ($this->holdings as $holding) {
1895 $holding->deleteTreeFromAlma(); #XXX
1898 $grima->deleteBib($this[
'mms_id']);
1908 if (count($this->holdingsList->entries) > 0) {
1912 if (count($this->portfolioList) > 0) {
1913 print_r($this->portfolioList);
1926 $xpath =
new DomXPath($this->xml);
1927 $nodes = $xpath->query(
"//linked_record_id[@type='CZ']");
1928 return (count($nodes) > 0);
1938 $xpath =
new DomXPath($this->xml);
1939 $nodes = $xpath->query(
"//linked_record_id[@type='CZ']");
1940 foreach ($nodes as $node) {
1941 $node->parentNode->removeChild($node);
1953 foreach ($this->holdingsList->entries as $entry) {
1955 $holding->loadFromAlma($this[
'mms_id'],$entry[
'holding_id']);
1956 $holding[
'mms_id'] = $this[
'mms_id'];
1957 $this->holdings[] = $holding;
1969 foreach($this->portfolioList as $portfolio) {
1970 $portfolio->deleteFromAlma();
1972 $this->portfolioList = array();
1983 $this->holdingsList =
new HoldingsList($this[
'mms_id']);
1993 $limit = 10; $offset = 0; # where to allow passing
1994 $ret =
$grima->getElectronicPortfoliosForBib($this[
'mms_id'],$limit,$offset);
1995 $xpath =
new DOMXpath($ret);
1996 $ports = $xpath->query(
'//portfolio');
1997 foreach ($ports as $portnode) {
1999 $newport->loadFromPortfolioListNode($portnode);
2000 $this->portfolioList[] = $newport;
2002 return count($ports);
2021 $xpath =
new DomXpath($this->xml);
2022 $title = $xpath->query(
"//record/datafield[@tag='245']/subfield[@code='a']");
2023 return preg_replace(
"/[ \/=:,;\.]*$/",
"",$title[0]->nodeValue);
2046 $xpath =
new DomXPath($this->xml);
2048 foreach (array(
'050',
'090') as $tag) {
2049 foreach ($xpath->query(
"//datafield[@tag='$tag']") as $call) {
2055 foreach ($calls as $node) {
2056 $classs = $xpath->query(
"subfield[@code='a']",$node);
2057 $items = $xpath->query(
"subfield[@code='b']",$node);
2058 if ((count($classs) > 0) and (count($items) > 0)) {
2059 $ret = array($classs[0]->nodeValue,$items[0]->nodeValue);
2074 'mms_id' =>
'//mms_id',
2075 'title' =>
'//title',
2076 'author' =>
'//author',
2079 #public $holdings = array(); # should this go in BIB? 2083 if (!is_null($mms_id)) {
2090 $this->xml =
$grima->getHoldingsList($mms_id);
2091 $xpath =
new DomXpath($this->xml);
2092 $hs = $xpath->query(
'//holding');
2093 $this->entries = array(); # clear
2094 #$this->holdings = array(); # clear 2095 foreach ($hs as $h) {
2096 #$this->holdings[] = new HoldingsListEntry($h,$mms_id); 2108 'holding_id' =>
'//holding_id',
2109 'call_number' =>
'//holding/call_number',
2110 'library_code' =>
'//holding/library',
2111 'library' =>
'//holding/library/@desc',
2112 'location_code' =>
'//holding/location',
2113 'location' =>
'//holding/location/@desc' 2118 $this->xml =
new DomDocument();
2119 $this->xml->appendChild($this->xml->importNode($node,
true));
2120 $this->el_override[
'mms_id'] = $mms_id;
2125 $this->getMmsIfNeeded();
2126 $this->itemList =
new ItemList($this[
'mms_id'], $this[
'holding_id'], $limit);
2141 $req_limit = ($limit == -1)?100:$limit;
2144 if ($curr_offset > 0) {
2145 if (($curr_offset+1)*100 > $limit) {
2146 $req_limit = $limit - $curr_offset*100;
2151 $xml =
$grima->getItemList($mms_id,$holding_id,$req_limit,$curr_offset*100);
2152 $xpath =
new DomXpath(
$xml);
2153 $is = $xpath->query(
'//item');
2154 foreach ($is as $i) {
2155 $new_item =
new Item();
2156 $new_item->loadFromItemListNode($i);
2157 $this->items[] = $new_item;
2159 $xpath =
new DomXPath(
$xml);
2160 if (!$curr_offset) {
2161 $length = $xpath->query(
'//items/@total_record_count')[0]->nodeValue;
2162 if ($limit == -1) { $limit = $length; }
2166 }
while (($curr_offset*100 < $length) and ($curr_offset*100 < $limit));
2182 if ($offset ==
"mms_id") {
2183 $this->el_override[
'mms_id'] = $value;
2185 parent::offsetSet($offset,$value);
2190 if ($offset ==
"library") {
2192 $lib->loadFromAlma($this[
'library_code']);
2193 return $lib[
'name'];
2195 if ($offset ==
"location") {
2197 $loc->loadFromAlma($this[
'library_code'],$this[
'location_code']);
2198 return $loc[
'name'];
2200 if ($offset ==
"call_number") {
2204 foreach ($Hs as $h) {
2207 foreach ($Is as $i) {
2212 return parent::offsetGet($offset);
2217 'holding_id' =>
'//holding_id',
2218 'inst_code' =>
"/holding/record/datafield[@tag='852']/subfield[@code='a']",
2219 'library_code' =>
"/holding/record/datafield[@tag='852']/subfield[@code='b']",
2220 'location_code' =>
"/holding/record/datafield[@tag='852']/subfield[@code='c']",
2233 $this->xml =
$grima->getHolding($mms_id,$holding_id);
2234 $this[
'mms_id'] = $mms_id;
2247 $report->path =
"/shared/UK Libraries- University of Kentucky (UKY)/Reports/Kathryn/HoldingToMMS";
2249 <sawx:expr xsi:type="sawx:comparison" op="equal" xmlns:saw="com.siebel.analytics.web/report/v1.1" 2250 xmlns:sawx="com.siebel.analytics.web/expression/v1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 2251 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 2252 <sawx:expr xsi:type="sawx:sqlExpression">"Holding Details"."Holding Id"</sawx:expr><sawx:expr xsi:type="xsd:string">{holding_id}</sawx:expr> 2255 $report->runReport(array(
'holding_id' => $holding_id), 1);
2256 if (count($report->rows) == 1) {
2257 return $report->rows[0][1];
2272 if (!isset($this[
'mms_id']) or (!$this[
'mms_id'])) {
2288 $this->xml =
$grima->getHolding($mms_id,$holding_id);
2289 $this[
'mms_id'] = $mms_id;
2301 $this->xml =
$grima->postHolding($mms_id,$this->xml);
2302 $this[
'mms_id'] = $mms_id;
2312 $grima->putHolding($this[
'mms_id'],$this[
'holding_id'],$this->xml);
2322 $grima->deleteHolding($this[
'mms_id'],$this[
'holding_id']);
2339 # call number object? 2342 $xpath =
new DomXpath($this->xml);
2343 $xpath->query(
"//record/datafield[@tag='852']")->item(0)->setAttribute(
"ind1",$ind1);
2345 $field852 = $xpath->query(
"//record/datafield[@tag='852']")->item(0);
2346 $subfieldHs = $xpath->query(
"subfield[@code='h']",$field852);
2347 foreach ($subfieldHs as $subfieldH) {
2348 $subfieldH->parentNode->removeChild($subfieldH);
2350 $subfieldIs = $xpath->query(
"subfield[@code='i']",$field852);
2351 foreach ($subfieldIs as $subfieldI) {
2352 $subfieldI->parentNode->removeChild($subfieldI);
2377 $this->items =& $this->itemList->items;
2388 $this->itemList =
new ItemList($this[
'mms_id'],$this[
'holding_id']);
2399 foreach ($this->itemList->items as $item) {
2400 $item->deleteFromAlma(
"true");
2438 'item_pid' =>
'//pid',
2439 'barcode' =>
'//barcode',
2440 'creation_date' =>
'//creation_date',
2441 'modification_date' =>
'//modification_date',
2442 'base_status' =>
'//base_status',
2443 'physical_material_type_code' =>
'//physical_material_type',
2444 'physical_material_type' =>
'//physical_material_type/@desc',
2445 'location' =>
'//location/@desc',
2446 'location_code' =>
'//location',
2447 'library' =>
'//location/@desc',
2448 'library_code' =>
'//location',
2449 'policy' =>
'//policy',
2450 'item_policy' =>
'//policy',
2451 'provenance' =>
'//provenance',
2452 'po_line' =>
'//po_line',
2453 'is_magnetic' =>
'//is_magnetic',
2454 'arrival_date' =>
'//arrival_date',
2455 'year_of_issue' =>
'//year_of_issue',
2456 'enumeration_a' =>
'//enumeration_a',
2457 'enumeration_b' =>
'//enumeration_b',
2458 'enumeration_c' =>
'//enumeration_c',
2459 'enumeration_d' =>
'//enumeration_d',
2460 'enumeration_e' =>
'//enumeration_e',
2461 'enumeration_f' =>
'//enumeration_f',
2462 'enumeration_g' =>
'//enumeration_g',
2463 'enumeration_h' =>
'//enumeration_h',
2464 'chronology_i' =>
'//chronology_i',
2465 'chronology_j' =>
'//chronology_j',
2466 'chronology_k' =>
'//chronology_k',
2467 'chronology_l' =>
'//chronology_l',
2468 'chronology_m' =>
'//chronology_m',
2469 'description' =>
'//description',
2470 'alternative_call_number' =>
'//alternative_call_number',
2471 'alternative_call_number_type' =>
'//alternative_call_number_type',
2472 'storage_location_id' =>
'//storage_location_id',
2473 'receiving_operator' =>
'//receiving_operator',
2474 'process_type' =>
'//process_type',
2475 'in_temp_location' =>
'//in_temp_location',
2476 'mms_id' =>
'//mms_id',
2477 'holding_id' =>
'//holding_id',
2478 'title' =>
'//title',
2479 'call_number' =>
'//call_number',
2480 'pages' =>
'//pages',
2481 'pieces' =>
'//pieces',
2482 'public_note' =>
'//public_note',
2483 'fulfillment_note' =>
'//fulfillment_note',
2484 'internal_note_1' =>
'//internal_note_1',
2485 'internal_note_2' =>
'//internal_note_2',
2486 'internal_note_3' =>
'//internal_note_3',
2487 'statistics_note_1' =>
'//statistics_note_1',
2488 'statistics_note_2' =>
'//statistics_note_2',
2489 'statistics_note_3' =>
'//statistics_note_3',
2490 'requested' =>
'//requested',
2491 'physical_condition' =>
'//physical_condition',
2492 'temp_library' =>
'//temp_library',
2493 'temp_location' =>
'//temp_location',
2506 $this->xml =
$grima->getItem($mms_id,$holding_id,$item_pid);
2517 $this->xml =
$grima->getItem(
'X',
'X',$item_pid);
2528 $this->xml =
$grima->getItemBC($barcode);
2541 if (preg_match(
"/^23.*/",$id)) { # item_pid
2542 # probably should know about suffix too 2557 $this->xml =
new DomDocument();
2558 $this->xml->appendChild($this->xml->importNode($node,
true));
2571 $this->mms_id = $mms_id;
2572 $this->holding_id = $holding_id;
2573 $this->xml =
$grima->postItem($mms_id,$holding_id,$this->xml);
2587 $this[
'holding_id'],
2603 $grima->deleteItem($this[
'mms_id'],$this[
'holding_id'],$this[
'item_pid'],$override,$holdings);
2621 'collection_id' =>
'//id',
2633 $this->xml =
$grima->getElectronicCollection($collection_id);
2634 #$this['collection_id'] = $collection_id; 2645 $ret =
$grima->getElectronicServices($this[
'collection_id']);
2646 $xpath =
new DomXpath($ret);
2647 $eservices = $xpath->query(
'//electronic_services/electronic_service');
2648 foreach ($eservices as $service) {
2649 $service_id = $service->firstChild->nodeValue; # XXX really?
2651 $ser->loadFromServiceListNode($service);
2652 $this->services[] = $ser;
2670 'service_id' =>
'//id',
2676 # load from template 2680 if ($offset ==
"collection_id") {
2681 $this->el_override[
'collection_id'] = $value;
2683 parent::offsetSet($offset,$value);
2694 $this->xml =
$grima->getElectronicService($collection_id,$service_id);
2695 $this[
'collection_id'] = $collection_id;
2706 $this->xml =
new DomDocument();
2707 $this->xml->appendChild($this->xml->importNode($node,
true));
2708 $xpath =
new DomXPath($this->xml);
2709 $service_link = $xpath->query(
'//electronic_service')->item(0)->attributes[
'link']->nodeValue;
2710 preg_match(
'!/e-collections/(.*)/e-services/!',$service_link,$m);
2711 $this[
'collection_id'] = $m[1];
2718 $curr_offset += 100;
2719 }
while ($retrieved == 100);
2731 #function retrievePortfolios($limit = 10, $offset = 0) { # RENAME 2734 $ret =
$grima->getElectronicPortfoliosForService($this[
'collection_id'],$this[
'service_id'],$limit,$offset);
2735 $xpath =
new DOMXpath($ret);
2736 $ports = $xpath->query(
'//portfolio');
2737 foreach ($ports as $portnode) {
2739 $newport->loadFromPortfolioListNode($portnode);
2740 $this->portfolios[] = $newport;
2742 return count($ports);
2756 foreach($this->portfolios as $portfolio) {
2757 $portfolio->deleteFromAlma($bib_treat);
2759 $this->portfolios = array();
2793 'portfolio_id' =>
'//portfolio/id',
2794 'is_local' =>
'//is_local',
2795 'is_standalone' =>
'//is_standalone',
2796 'mms_id' =>
'//mms_id',
2797 'title' =>
'//title',
2798 'service' =>
'//service',
2800 'static_url' =>
'//static_url',
2801 'availability' =>
'//availability',
2802 'collection_id' =>
'//electronic_collection/id',
2803 'service_id' =>
'//electronic_collection/service',
2804 'material_type' =>
'//material_type',
2805 'url_type' =>
'//url_type',
2806 'public_note' =>
'//public_note' 2819 $ret =
$grima->postElectronicPortfolio($collection_id, $service_id, $this->xml);
2834 $ret =
$grima->postElectronicPortfolioOnBib($mms_id, $this->xml);
2847 $this->xml =
$grima->getElectronicPortfolio(
'X',
'X',$portfolio_id);
2852 $this->xml =
$grima->getElectronicPortfolio(
'X',
'X',$portfolio_id);
2863 $this->xml =
new DomDocument();
2864 $this->xml->appendChild($this->xml->importNode($node,
true));
2874 $this->xml =
$grima->putElectronicPortfolioOnBib($this[
'mms_id'],$this[
'portfolio_id'],$this->xml);
2886 $mms_id = $this[
'mms_id'];
2887 $grima->deleteElectronicPortfolio(
'X',
'X',
2888 $this[
'portfolio_id']);
2889 if ($bib_treat ==
"delete") {
2891 $bib->loadFromAlma($mms_id);
2893 if (! $bib->hasInventory()) {
2894 if ($bib->linkedToCZ()) {
2895 print
"LINKED TO CZ";
2896 $bib->unlinkFromCZ();
2899 $bib->deleteFromAlma();
2927 'set_id' =>
'//set/id',
2934 $this->xml =
$grima->createSetFromImport($job_id,$population);
2945 $this->xml =
$grima->getSet($set_id);
2950 # limit -1 means all 2952 if ($limit == -1) { #
get them all
2953 $xml =
$grima->getSetMembers($this[
'set_id'],0);
2954 $xpath =
new DomXpath(
$xml);
2955 $this->size = $xpath->query(
"//members")->item(0)->getAttribute(
"total_record_count");
2956 $limit = $this->size;
2959 for ($j = 0; $j < ceil($limit/100); $j++) { # how many queries
2960 $xml =
$grima->getSetMembers($this[
'id'],100,$j*100);
2961 $xpath =
new DomXpath(
$xml);
2962 foreach ($xpath->query(
"//member") as $member) {
2964 $member->childNodes[0]->nodeValue,
2965 $member->childNodes[1]->nodeValue
2978 $grima->deleteSet($this[
'set_id']);
3015 'resource_sharing' =>
'//resource_sharing',
3026 $this->xml =
$grima->getLibrary($code);
3050 $this->xml =
$grima->getLocation($libraryCode, $locationCode);
3073 function runReport($filter_params=array(), $limit = -1, $token =
"") {
3075 if (isset($this->filter)) {
3077 foreach ($filter_params as $k => $v) {
3078 $passfilter = str_replace(
'{'.$k.
'}',urlencode($v),$passfilter);
3084 if ($limit == -1) { $limit = 1000; } # no limit
3085 if ($limit < 25) { $limit = 25; } # must be in chunks of 25
3086 $this->reportXml =
$grima->getAnalytics($this->path, $passfilter, $limit, $token);
3088 $xpath =
new DomXpath($this->reportXml);
3089 $xpath->registerNamespace(
"x",
"urn:schemas-microsoft-com:xml-analysis:rowset");
3091 $rows = $xpath->query(
'//x:Row');
3092 foreach (
$rows as $row) {
3094 $cols = $xpath->query(
"./*[contains(name(),'Column')]", $row);
3095 foreach ($cols as $col) {
3096 $newrow[] = $col->nodeValue;
3098 $this->rows[] = $newrow;
3114 $table_esc =
"\"" . preg_replace(
"/\"/",
"\"\"", $table ) .
"\"";
3116 $result = $pdo->query(
"SELECT 1 FROM $table_esc LIMIT 1");
3117 }
catch (Exception $e) {
3122 return $result !== FALSE;
3132 class GrimaDB implements ArrayAccess, IteratorAggregate {
3135 $db = self::getDb();
3137 $db->exec(
"CREATE TABLE institutions ( institution VARCHAR(100) PRIMARY KEY, apikey VARCHAR(100), server VARCHAR(100) )");
3140 $db->exec(
"CREATE TABLE users ( institution VARCHAR(100), username VARCHAR(100), password VARCHAR(255), isAdmin BOOLEAN )");
3143 }
catch(Exception $x) {
3144 # create the database 3150 $db = self::getDb();
3151 $result =
$db->query(
'SELECT COUNT(*) as c FROM institutions' );
3152 foreach( $result as $row ) {
3153 if ($row[
'c']>0)
return false;
3160 $db_url = getenv(
'DATABASE_URL');
3161 if (!$db_url) $db_url =
"sqlite:" .
join_paths( sys_get_temp_dir(),
"grima/grima.sql");
3162 self::$db =
new PDO($db_url);
3167 return defined(
"PASSWORD_ARGON2I") ? constant(
"PASSWORD_ARGON2I") : PASSWORD_DEFAULT;
3174 return isset($this->info[$offset]);
3178 return isset($this->info[$offset]) ? $this->info[$offset] :
'';
3182 $this->info[$offset] = $value;
3186 unset($this->info[$offset]);
3190 return new ArrayIterator($this->info);
3204 $query =
$db->prepare(
'INSERT INTO institutions(institution,apikey,server) VALUES (:institution,:apikey,:server)' );
3206 $errorCode =
$db->errorCode();
3207 $errorInfo =
$db->errorInfo();
3208 throw new Exception(
3209 "Could not even prepare to insert into institution database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}" 3212 $success = $query->execute( array(
3213 'institution' => $this[
'institution'],
3214 'apikey' => $this[
'apikey'],
3215 'server' => $this[
'server'],
3218 $errorCode = $query->errorCode();
3219 $errorInfo = $query->errorInfo();
3220 throw new Exception(
3221 "Could not insert into user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}" 3236 foreach ( $data as $key => $val ) {
3242 public static function LookupUser($username, $institution =
'', $password = FALSE) {
3243 $db = self::getDb();
3244 $query =
$db->prepare(
3246 'FROM institutions NATURAL JOIN users '.
3247 'WHERE institution=:institution '.
3248 'AND username=:username' 3250 $success = $query->execute( array(
3251 'institution' => $institution,
3252 'username' => $username,
3255 $row = $query->fetch(PDO::FETCH_ASSOC);
3256 if ($row===
false)
return false;
3258 if ( ($password !== FALSE) && ($user[
'password']!=
'') ) {
3259 if ( !password_verify( $password, $user[
'password'] ) )
return false;
3260 if ( password_needs_rehash( $user[
'password'], $user->getPasswordAlgorithm() ) ) {
3261 $user[
'password'] = $password;
3265 unset( $user[
'password'] );
3268 $errorCode = $query->errorCode();
3269 $errorInfo = $query->errorInfo();
3270 throw new Exception(
3271 "Could not select from user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}" 3276 public static function RenameUser( $username, $institution, $newusername ) {
3277 $db = self::getDb();
3278 $query =
$db->prepare(
3280 'SET username=:newusername ' .
3281 'WHERE institution=:institution '.
3282 'AND username=:username' 3284 $success = $query->execute( array(
3285 'institution' => $institution,
3286 'username' => $username,
3287 'newusername' => $newusername,
3292 $errorCode = $query->errorCode();
3293 $errorInfo = $query->errorInfo();
3294 throw new Exception(
3295 "Could not update user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}" 3301 $db = self::getDb();
3302 $query =
$db->prepare(
3304 'SET password=:password ' .
3305 'WHERE institution=:institution '.
3306 'AND username=:username' 3308 $passwordHash = password_hash( $password, self::getPasswordAlgorithm() );
3309 $success = $query->execute( array(
3310 'institution' => $institution,
3311 'username' => $username,
3312 'password' => $passwordHash,
3317 $errorCode = $query->errorCode();
3318 $errorInfo = $query->errorInfo();
3319 throw new Exception(
3320 "Could not update user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}" 3328 session_write_close();
3329 if (!isset($_SESSION))
return false;
3336 if ( $user !==
false ) {
3337 if (isset($_SESSION)) {
3338 session_write_close();
3341 $grima->session_save($user);
3349 $query =
$db->prepare(
'INSERT INTO users( username, password, institution, isAdmin ) VALUES (:username, :password, :institution, :isAdmin)' );
3351 $errorCode =
$db->errorCode();
3352 $errorInfo =
$db->errorInfo();
3353 throw new Exception(
3354 "Could not even prepare to insert into user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}" 3357 $success = $query->execute( array(
3358 'username' => $this[
'username'],
3360 'institution' => $this[
'institution'],
3361 'isAdmin' => $this[
'isAdmin'],
3364 $errorCode = $query->errorCode();
3365 $errorInfo = $query->errorInfo();
3366 throw new Exception(
3367 "Could not insert into user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}" 3374 $query =
$db->prepare(
'UPDATE users SET isAdmin=:isAdmin, password=:password WHERE username=:username AND institution=:institution' );
3376 $errorCode =
$db->errorCode();
3377 $errorInfo =
$db->errorInfo();
3378 throw new Exception(
3379 "Could not even prepare to update user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}" 3382 $success = $query->execute( array(
3383 'username' => $this[
'username'],
3385 'institution' => $this[
'institution'],
3386 'isAdmin' => $this[
'isAdmin'],
3389 $errorCode = $query->errorCode();
3390 $errorInfo = $query->errorInfo();
3391 throw new Exception(
3392 "Could not update user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}" 3399 $query =
$db->prepare(
'DELETE FROM users WHERE username=:username AND institution=:institution' );
3401 $errorCode =
$db->errorCode();
3402 $errorInfo =
$db->errorInfo();
3403 throw new Exception(
3404 "Could not even prepare to delete from user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}" 3407 $success = $query->execute( array(
3408 'username' => $this[
'username'],
3409 'institution' => $this[
'institution'],
3412 $errorCode = $query->errorCode();
3413 $errorInfo = $query->errorInfo();
3414 throw new Exception(
3415 "Could not delete from user database: [$errorCode] {$errorInfo[0]} {$errorInfo[2]}" 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
runReport($filter_params=array(), $limit=-1, $token="")
pull Analytics report from Alma
unlinkFromCZ()
does this work : Not supported for CZ
deleteAllPortfolios()
delete all portfolios from the bib
offsetSet($offset, $value)
loadFromAlma($mms_id, $holding_id, $item_pid)
populates item record from Alma
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
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)
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.
postElectronicPortfolioOnBib($mms_id, $portfolio)
Create Electronic Portfolio - add a new portfolio to Alma Bib.
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)
MARC fields for use in bibs and holdings.
offsetSet($offset, $value)
class ElectronicPortfolio
getElectronicPortfoliosForService($collection_id, $service_id, $limit, $offset)
Retrieve Portfolios - retrieve a list of portfolios from Alma.
loadFromAlma($code)
populate library with info from Alma
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
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.
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)
loadFromPortfolioListNode($node)
populate item record from the information in an PortfolioList node
deleteFromAlma()
delete set from Alma
getItemList()
populates itemList property from Alma
deleteFromAlma()
delete the holding record from Alma
loadFromAlmaBarcode($barcode)
populates item record from Alma, using barcode
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)
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. ...
offsetSet($offset, $value)
postElectronicPortfolio($collection_id, $service_id, $portfolio)
Create Electronic Portfolio - add a new portfolio to Alma.
getAnalytics($path, $filter, $limit=25, $token=null)
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
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())
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($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?
loadFromAlma($collection_id)
load record from Alma
A thin wrapper around a message and urgency level.
getPortfolioList()
populate portfolioList property with info from Alma
deleteField($tag)
delete all $tag fields from the MARC record
createFromImport($job_id, $population)
class ElectronicCollection
replaceOrAddSubfield($tag, $code, $value)
replace or add subfield value in marc
addToAlmaBib($mms_id)
add portfolio to Bib in Alma : Insufficient permission
__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
static getMmsFromHoldingID($holding_id)
populates the MMS ID
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.
deleteSubfieldMatching($tag, $code, $regex)
delete subfields matching a regex
__construct($mms_id=null)
loadFromAlmaX($holding_id)
populates the record from Alma - only requires holding_id
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.
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.