public function placeHoldViaSIP($recordId, $patronId, $comment, $type) { global $configArray; global $user; //Place the hold via SIP 2 $mysip = new sip2(); $mysip->hostname = $configArray['SIP2']['host']; $mysip->port = $configArray['SIP2']['port']; $hold_result = array(); $hold_result['result'] = false; if ($mysip->connect()) { //send selfcheck status message $in = $mysip->msgSCStatus(); $msg_result = $mysip->get_message($in); // Make sure the response is 98 as expected if (preg_match("/^98/", $msg_result)) { $result = $mysip->parseACSStatusResponse($msg_result); // Use result to populate SIP2 setings $mysip->AO = $result['variable']['AO'][0]; /* set AO to value returned */ $mysip->AN = $result['variable']['AN'][0]; /* set AN to value returned */ $mysip->patron = $user->cat_username; $mysip->patronpwd = $user->cat_password; if (isset($_REQUEST['campus'])) { $campus = trim($_REQUEST['campus']); } else { $campus = $user->homeLocationId; //Get the code for the location $locationLookup = new Location(); $locationLookup->locationId = $campus; $locationLookup->find(); if ($locationLookup->N > 0) { $locationLookup->fetch(); $campus = $locationLookup->code; } } //place the hold if ($type == 'cancel' || $type == 'recall') { $mode = '-'; } elseif ($type == 'update') { $mode = '*'; } else { $mode = '+'; } //expire the hold in 2 years by default $expirationTime = time() + 2 * 365 * 24 * 60 * 60; $in = $mysip->msgHold($mode, $expirationTime, '2', '', $recordId, '', $campus); $msg_result = $mysip->get_message($in); $hold_result['title'] = $this->getRecordTitle($recordId); $hold_result['id'] = $recordId; if (preg_match("/^16/", $msg_result)) { $result = $mysip->parseHoldResponse($msg_result); $hold_result['result'] = $result['fixed']['Ok'] == 1; $hold_result['message'] = $result['variable']['AF'][0]; //Get the hold position. if ($result['fixed']['Ok'] == 1) { $holds = $this->getMyHolds($user); //Find the correct hold (will be unavailable) foreach ($holds['holds']['unavailable'] as $key => $holdInfo) { if ($holdInfo['id'] == $recordId) { $hold_result['message'] .= " You are number <b>" . $holdInfo['position'] . "</b> in the queue."; break; } } } } } } return $hold_result; }