/** * Test citation generation * * @return void * @access public */ public function testDates() { global $configArray; // Clear out config array date settings to ensure we always test defaults // in code: unset($configArray['Site']['displayDateFormat']); unset($configArray['Site']['displayTimeFormat']); // Build an object to test with: $date = new VuFindDate(); // Try some conversions: $this->_checkDate('11-29-1973', $date->convertToDisplayDate('U', 123456879)); $this->_checkDate('11-29-1973', $date->convertToDisplayDate('m-d-y', '11-29-73')); $this->_checkDate('11-29-1973', $date->convertToDisplayDate('m-d-y', '11-29-1973')); $this->_checkDate('11-29-1973', $date->convertToDisplayDate('m-d-y H:i', '11-29-73 23:01')); $this->_checkDate('23:01', $date->convertToDisplayTime('m-d-y H:i', '11-29-73 23:01')); $this->_checkDate('01-02-2001', $date->convertToDisplayDate('m-d-y', '01-02-01')); $this->_checkDate('01-02-2001', $date->convertToDisplayDate('m-d-y', '01-02-2001')); $this->_checkDate('01-02-2001', $date->convertToDisplayDate('m-d-y H:i', '01-02-01 05:11')); $this->_checkDate('05:11', $date->convertToDisplayTime('m-d-y H:i', '01-02-01 05:11')); $this->_checkDate('01-02-2001', $date->convertToDisplayDate('Y-m-d', '2001-01-02')); $this->_checkDate('01-02-2001', $date->convertToDisplayDate('Y-m-d H:i', '2001-01-02 05:11')); $this->_checkDate('05:11', $date->convertToDisplayTime('Y-m-d H:i', '2001-01-02 05:11')); $this->_checkDate('01-2001', $date->convertFromDisplayDate('m-Y', '01-02-2001')); // Check for proper handling of known problems: $bad = $date->convertToDisplayDate('U', 'invalid'); $this->assertTrue(PEAR::isError($bad)); $this->assertTrue((bool) stristr($bad->getMessage(), 'failed to parse time string')); $bad = $date->convertToDisplayDate('d-m-Y', '31-02-2001'); $this->assertTrue(PEAR::isError($bad)); $this->assertTrue((bool) stristr($bad->getMessage(), 'parsed date was invalid')); }
/** * Place Hold * * Attempts to place a hold or recall on a particular item * * @param array $holdDetails An array of item and patron data * * @return array An array of data on the request including * whether or not it was successful and a system message (if available) * @access public */ public function placeHold($holdDetails) { $patron = $holdDetails['patron']; // convert expire date from display format // to the format Symphony/Unicorn expects $expire = $holdDetails['requiredBy']; $formatDate = new VuFindDate(); $expire = $formatDate->convertFromDisplayDate($this->ilsConfigArray['Catalog']['server_date_format'], $expire); // query sirsi $params = array('query' => 'hold', 'itemId' => $holdDetails['item_id'], 'patronId' => $patron['cat_username'], 'pin' => $patron['cat_password'], 'pickup' => $holdDetails['pickUpLocation'], 'expire' => $expire, 'comments' => $holdDetails['comment'], 'holdType' => $holdDetails['level'], 'callnumber' => $holdDetails['callnumber'], 'override' => $holdDetails['override']); $response = $this->querySirsi($params); // process the API response if ($response == 'invalid_login') { return array('success' => false, 'sysMessage' => "authentication_error_admin"); } $matches = array(); preg_match('/\\^MN([0-9][0-9][0-9])/', $response, $matches); if (isset($matches[1])) { $status = $matches[1]; if ($status == '209') { return array('success' => true); } else { return array('success' => false, 'sysMessage' => $this->ilsConfigArray['ApiMessages'][$status]); } } return array('success' => false); }