Subversion Repositories OPAC

[/] [Dynix/] [class.dynix.php] - Rev 2

Compare with Previous | Blame | View Log

<?php
/**
  * class.dynix.php - A PHP class for interacting with a Dynix OPAC.
  *
  * Provides to retrieve books checked out, books on hold, and blocks/fines in place.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or (at
  * your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  * USA
  *
  * @version 0.1, February 26, 2008
  * @link http://ruk.ca/wiki/Class.dynix.php Documentation
  * @author Peter Rukavina <peter@rukavina.net>
  * @copyright Copyright &copy; 2008, Reinvented Inc.
  * @license http://www.fsf.org/licensing/licenses/gpl.txt GNU Public License
  */

class Dynix {

    
/**
      * Create a Dynix object.
      * @param string $opac_url the base URL of the Dynix web host -- i.e. http://24.224.240.205/ipac20/ipac.jsp
      * @param string $opac_username the patron's Dynix username (their library card number?)
      * @param string $opac_password the patron's Dynix username (their telephone number is often the default)
      */
    
function __construct($opac_url,$opac_username,$opac_password) {
        
$this->opac_url $opac_url;
        
$this->opac_username $opac_username;
        
$this->opac_password $opac_password;
    }

    
/**
      * Get XML from the Dynix server
      * @param string $url the URL to retrieve from
      * @param string $opac_username the patron's Dynix username (their library card number?)
      * @return object $opac a SimpleXMLElement object of the results returned
      */
    
private function getXML($url) {
        
$url $this->opac_url $url ;
        
$fp fopen($url,"r");
        
$xml stream_get_contents($fp);
        
fclose($fp);
        
$opac = new SimpleXMLElement($xml);
        return 
$opac;
    }
    
    
/**
      * Get a session from the Dynix server
      * @param string $status the value for "submenu" to send (either "holds" or "itemsout" right now)
      */    
    
private function getSession($status) {
        
$url "?profile=pac&menu=account&submenu=" $status "&GetXML=true";
        
$opac $this->getXML($url);
        
$this->session $opac->session;
    }

    
/**
      * Get items from the Dynix server
      * @param string $status the value for "submenu" to send (either "holds" or "itemsout" right now)
      * @return object $opac a SimpleXMLElement object of the results returned
      */
    
private function getItems($status) {
        
$this->getSession($status);
        
$url "?profile=pac&menu=account&submenu=" $status "&GetXML=true&session=" $this->session "&sec1=" $this->opac_username "&sec2=" $this->opac_password;
        
$opac $this->getXML($url);
        return (
$opac);
    }

    
/**
      * Get items "checked out"
      * @return array $opac an array of SimpleXMLElement objects for items checked out
      */
    
function getItemsOut() {
        
$opac $this->getItems('itemsout');
        return (
$opac->itemsoutdata->itemout);
    }    

    
/**
      * Get items "on hold"
      * @return array $opac an array of SimpleXMLElement objects for items on hold
      */
    
function getHolds() {
        
$opac $this->getItems('holds');
        return (
$opac->holdsdata->waiting->waitingitem);
    }    

    
/**
      * Get items "on hold"
      * @return array $blocks an array with two elements: blocks count and total money owing
      */    
    
function getBlocks() {
        
$url "?profile=pac&menu=account&submenu=subtab164&GetXML=true&session=" $this->session "&sec1=" $this->opac_username "&sec2=" $this->opac_password;
        
$opac $this->getXML($url);
        
$blocks = array();
        
$blocks['count'] = intval($opac->blockdata->totalcount);
        
$blocks['amount'] = number_format($opac->blockdata->totalamount,2);
        return (
$blocks);
    }    
}

Compare with Previous | Blame | View Log