Warning: This page has not been updated in over over a year and may be outdated or deprecated.
expanded_driver_func
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
expanded_driver_func [2010/02/11 12:21] – l.osullivan | expanded_driver_func [2011/06/15 12:45] – demiankatz | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | **Bold Text**====== Expanded Driver Functionality ====== | + | ====== Expanded Driver Functionality ====== |
- | + | This page is no longer needed | |
- | + | ||
- | ===== SVN Source ===== | + | |
- | + | ||
- | **%%https:// | + | |
- | + | ||
- | + | ||
- | ===== Purpose ===== | + | |
- | To create a flexible and gracefully degrading solution for Item Loan Renewals, Placing Hold and cancelling Holds. | + | |
- | + | ||
- | //**NB:** | + | |
- | + | ||
- | driver.ini refers to the ILS-specific configuration file found in the config directory. E.g. voyager.ini | + | |
- | + | ||
- | driver.php refers to the ILS-specific driver e.g. Voyager.php// | + | |
- | + | ||
- | ===== New Functions ===== | + | |
- | + | ||
- | ==== getConfig($function) ==== | + | |
- | + | ||
- | **Location: | + | |
- | + | ||
- | public function getConfig($function) | + | |
- | { | + | |
- | if(isset($this-> | + | |
- | $functionConfig = $this-> | + | |
- | } | + | |
- | else { | + | |
- | $functionConfig = false; | + | |
- | } | + | |
- | return $functionConfig; | + | |
- | } | + | |
- | + | ||
- | Accepts a string argument which must correspond with an array key in $this-> | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | ==== checkFunction($function) ==== | + | |
- | + | ||
- | **Location: CatalogConnection.php** | + | |
- | + | ||
- | Sample: Holds | + | |
- | + | ||
- | < | + | |
- | function checkFunction($function) | + | |
- | { | + | |
- | + | ||
- | if (!method_exists($this->driver, ' | + | |
- | return false; | + | |
- | } | + | |
- | + | ||
- | switch ($function) { | + | |
- | case " | + | |
- | + | ||
- | $functionConfig = $this-> | + | |
- | + | ||
- | if(!$functionConfig) { | + | |
- | return false; | + | |
- | } | + | |
- | + | ||
- | if (method_exists($this-> | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | + | ||
- | } | + | |
- | + | ||
- | else if (method_exists($this-> | + | |
- | + | ||
- | $response[' | + | |
- | $response[' | + | |
- | $response[' | + | |
- | $response[' | + | |
- | } | + | |
- | + | ||
- | else { | + | |
- | return false; | + | |
- | } | + | |
- | + | ||
- | return $response; | + | |
- | break; | + | |
- | … | + | |
- | default: return false; | + | |
- | } | + | |
- | + | ||
- | } | + | |
- | </ | + | |
- | + | ||
- | Accepts a string argument which must correspond with options in its switch statement. When a match is made, it looks to see if the getConfig function is available in the driver. If it is not, it returns false. | + | |
- | + | ||
- | ==== getPickUpLocations ($patron) ==== | + | |
- | + | ||
- | **Location: CatalogConnection.php / Driver** | + | |
- | + | ||
- | Accepts an array argument of patron information returned by patronLogin ($patron = $this-> | + | |
- | + | ||
- | + | ||
- | ==== getHoldLink($details) ==== | + | |
- | + | ||
- | **Location: Driver.php** | + | |
- | + | ||
- | A function for making a hold request via the native OPAC. Must accept an array of key / value pairs and return a valid url. | + | |
- | + | ||
- | + | ||
- | ==== getCancelHoldLink($details) ==== | + | |
- | + | ||
- | **Location: Driver.php** | + | |
- | + | ||
- | A function for cancelling a hold request via the native OPAC. Must accept an array of key / value pairs and return a valid url. | + | |
- | + | ||
- | + | ||
- | ==== renewMyItemsLink ($details) ==== | + | |
- | + | ||
- | **Location: Driver.php** | + | |
- | + | ||
- | A function renewing an item via the native OPAC. Must accept an array of key / value pairs and return a valid url. | + | |
- | + | ||
- | ===== Effected Functions ===== | + | |
- | + | ||
- | ==== getHoldings($id) ==== | + | |
- | + | ||
- | **Location: Driver.php** | + | |
- | + | ||
- | The array keys and values returned by this function must correspond to the array keys and values required by the hold function. | + | |
- | + | ||
- | $holding[$i] = array(' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | + | ||
- | ==== getMyTransactions($id) ==== | + | |
- | + | ||
- | **Location: Driver.php** | + | |
- | + | ||
- | The array keys and values contained in the ils_details array must correspond to the array keys and values required by the renewMyItems | + | |
- | + | ||
- | + | ||
- | | + | |
- | ' | + | |
- | ' | + | |
- | + | ||
- | ==== renewMyItems($renewDetails) ==== | + | |
- | + | ||
- | **Location: Driver.php** | + | |
- | + | ||
- | Must accept an array of key / value pairs . | + | |
- | + | ||
- | Returns an associative array with the item id (or bib id as required) as the key for each result. Each result is an array containing the following keys: ' | + | |
- | + | ||
- | ==== placeHold($holdDetails) ==== | + | |
- | + | ||
- | **Location: Driver.php** | + | |
- | + | ||
- | Must accept an array of key / value pairs . Returns an array with two main keys: ' | + | |
- | + | ||
- | ==== cancelHold($holdDetails) ==== | + | |
- | + | ||
- | **Location: Driver.php** | + | |
- | + | ||
- | Must accept an array of key / value pairs . Returns an array with two main keys: ' | + | |
- | + | ||
- | ===== Place Hold / Get Hold Link ===== | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | ==== Files Affected ==== | + | |
- | + | ||
- | **CatalogConnection.php** | + | |
- | + | ||
- | **conf/ | + | |
- | + | ||
- | **Drivers/ | + | |
- | + | ||
- | **Services/ | + | |
- | + | ||
- | **Services/ | + | |
- | + | ||
- | **Services/ | + | |
- | + | ||
- | **Services/ | + | |
- | + | ||
- | **Interface/ | + | |
- | + | ||
- | + | ||
- | ====New Files==== | + | |
- | **Interface/ | + | |
- | + | ||
- | Services/ | + | |
- | + | ||
- | + | ||
- | ==== Description ==== | + | |
- | + | ||
- | If enabled, the PlaceHold method allows vufind users to place a hold, request or recall on catalogue items. If it is not enabled, then none of the functionality is displayed. | + | |
- | + | ||
- | NB: Hypertext link could be converted to form element in order to provide a POST option for continuity between methods. | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | ==== Process ==== | + | |
- | + | ||
- | **conf/ | + | |
- | + | ||
- | [Holds] | + | |
- | enabled = true | + | |
- | + | ||
- | type = availability | + | |
- | + | ||
- | link = item_id: | + | |
- | + | ||
- | required = id: | + | |
- | + | ||
- | optional = comment: | + | |
- | + | ||
- | opacurl = %%http://opac.swan.ac.uk/ | + | |
- | + | ||
- | The enabled field determines whether or not Holds are in use. | + | |
- | + | ||
- | The type refers to the logic you wish to use to display the holds link. Options are all (Show links for all items - Place Hold for Available Items and Place Request for unavailable items), recall (Only show links for unavailable items), holds (Only show links for available items), availability (Only show a recall link if no other copies are available). | + | |
- | + | ||
- | The link field contains a list of array key values which are required by Hold.php or the native OPAC. Each value entered here must correspond with an array key value returned by the getHoldings function. E.g. If you want item_id to be passed to hold.php, an array key of item_id must be returned by getHoldings. | + | |
- | + | ||
- | The required field contains a list of array key values which are required by the function responsible for placing the hold. If any of them are missing, the Hold attempt will not be made. | + | |
- | + | ||
- | The optional field contains a list of array key values which may be included with the Hold request but not essential to its completion. Both the required and optional arrays could be used for client-side form checking. | + | |
- | + | ||
- | The opacurl is the url of the native opac to be used by getHoldLink to generate hold and recall links. | + | |
- | + | ||
- | === Holdings.php == | + | |
- | + | ||
- | The driver method getHoldings is called from Holdings.php. It is responsible for returning an array with keys which correspond to the variables required by the system to place a hold. In this instance, each record returns the following: | + | |
- | + | ||
- | A call is made to checkFunction and the response is assigned to $checkHolds. | + | |
- | + | ||
- | < | + | |
- | // Are holds allows? | + | |
- | $checkHolds = $catalog-> | + | |
- | if($checkHolds != false) { | + | |
- | + | ||
- | + | ||
- | // Function which we will submit data to | + | |
- | $function = $checkHolds[' | + | |
- | + | ||
- | $type = $checkHolds[' | + | |
- | </ | + | |
- | + | ||
- | Holdings.php then loops through each item to determine if any copies are available and sets the $any_available variable. | + | |
- | + | ||
- | < | + | |
- | // Check to see if any copies are available | + | |
- | $any_available = false; | + | |
- | + | ||
- | foreach ($holdings as $location_key => $location) { | + | |
- | foreach ($location as $copy_key => $copy) { | + | |
- | if($copy[' | + | |
- | $any_availability = true; | + | |
- | } | + | |
- | } | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | Holdings.php then performs another loop through each item and creates links for place a hold based on the hold behaviour set in the driver.ini file. This link is attached to the holdings array with the key “link”. | + | |
- | + | ||
- | < | + | |
- | // Generate Links | + | |
- | // Loop through each holding | + | |
- | foreach ($holdings as $location_key => $location) { | + | |
- | foreach ($location as $copy_key => $copy) { | + | |
- | + | ||
- | switch($type) { | + | |
- | case " | + | |
- | $addlink = true; // always provide link | + | |
- | break; | + | |
- | case " | + | |
- | $addlink = $copy[' | + | |
- | break; | + | |
- | case " | + | |
- | $addlink = !$copy[' | + | |
- | break; | + | |
- | case " | + | |
- | $addlink = ($copy[' | + | |
- | break; | + | |
- | default: | + | |
- | $addlink = false; | + | |
- | break; | + | |
- | } | + | |
- | + | ||
- | if ($addlink) { | + | |
- | if ($function == " | + | |
- | /* Build opac link */ | + | |
- | foreach($checkHolds[' | + | |
- | $opacArray[$link] = $copy[$link]; | + | |
- | } | + | |
- | + | ||
- | // Assign the Opac Link to the Holdsings Array | + | |
- | $holdings[$location_key][$copy_key][' | + | |
- | } | + | |
- | else { | + | |
- | /* Build non-opac link */ | + | |
- | $site_url = $configArray[' | + | |
- | $id = $copy[' | + | |
- | $holdLink = $site_url."/ | + | |
- | $i = 0; | + | |
- | foreach($checkHolds[' | + | |
- | if ($i == 0) { | + | |
- | $holdLink .= $link." | + | |
- | } | + | |
- | else { | + | |
- | $holdLink .= "&" | + | |
- | } | + | |
- | | + | |
- | } | + | |
- | $holdings[$location_key][$copy_key][' | + | |
- | } | + | |
- | } | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | Finally, the template is set and the holdings array is assigned to Smarty. | + | |
- | + | ||
- | | + | |
- | $interface-> | + | |
- | $interface-> | + | |
- | + | ||
- | // Display Page | + | |
- | $interface-> | + | |
- | + | ||
- | + | ||
- | === Interface/ | + | |
- | + | ||
- | View-holdings.tpl is responsible for displaying the holdings for each item. Smarty checks if the item is available and outputs an appropriate link if it has been set in holdings.php. | + | |
- | + | ||
- | < | + | |
- | {* Begin Available Items (Holds) *} | + | |
- | {if $row.availability} | + | |
- | <span class=" | + | |
- | + | ||
- | {if $row.link} | + | |
- | | <a href=" | + | |
- | + | ||
- | + | ||
- | {/if} | + | |
- | + | ||
- | + | ||
- | {* Begin Unavailable Items (Recalls) *} | + | |
- | + | ||
- | | + | |
- | + | ||
- | < | + | |
- | {if $row.duedate} | + | |
- | {translate text=" | + | |
- | {/if} | + | |
- | + | ||
- | {if $row.link} | + | |
- | | <a href=" | + | |
- | + | ||
- | {/if} {/if} | + | |
- | </ | + | |
- | === Hold.php === | + | |
- | + | ||
- | Hold.php first checks if Holds are enabled. If they are, it registers the function to be used . If they are not, the user is directed back to the holdings page. | + | |
- | + | ||
- | < | + | |
- | // Are Holds Allowed? | + | |
- | + | ||
- | $checkHolds = $catalog-> | + | |
- | + | ||
- | if($checkHolds != false) { | + | |
- | + | ||
- | // Function which we will submit data to | + | |
- | + | ||
- | $function = $checkHolds[' | + | |
- | } | + | |
- | else { | + | |
- | // Shouldn' | + | |
- | header(' | + | |
- | exit(); | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | Next, it checks to see if it has been sent any information from holdings.php or login.php using the link values set in config.ini. If it has, it assigns them to a gatheredDetails array and builds a logon url which will be used to redirected users to a logon screen as required. Hold.php also assigns the required and optional values to PHP variables and also send them to the Smarty template so that the correct form elements can be displayed. | + | |
- | + | ||
- | < | + | |
- | // Get Values Passed to Page from holdings.php | + | |
- | // Could be removed and rely on response from driver to produce error messages | + | |
- | $linked = $checkHolds[' | + | |
- | $i=0; | + | |
- | foreach($linked as $details) { | + | |
- | $this-> | + | |
- | // Build Logon URL | + | |
- | if ($i == 0) { | + | |
- | $logonURL .= "?" | + | |
- | } | + | |
- | else { | + | |
- | $logonURL .= "&" | + | |
- | } | + | |
- | $i++; | + | |
- | } | + | |
- | + | ||
- | // Assign Required and Optional Variables | + | |
- | $required = $checkHolds[' | + | |
- | $optional = $checkHolds[' | + | |
- | + | ||
- | $form_fields = array_merge($required, | + | |
- | $interface-> | + | |
- | + | ||
- | $interface-> | + | |
- | + | ||
- | // User Must be Logged in and have a catalog username To Place Hold | + | |
- | + | ||
- | if ($user && $user-> | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | If the user is logged in and has a catalog username, Holds.php continues by assigning the catalog, registering user details and retrieving a list of pickup libraries based on the patron’s information. This list is assigned to the template. Hold.php also adds a defaultdue date variable using the ISO 8601 format of YYYY-MM-DD. | + | |
- | + | ||
- | < | + | |
- | // Connect to Database | + | |
- | $this-> | + | |
- | + | ||
- | // Register User Details | + | |
- | $patron = $this-> | + | |
- | if (PEAR:: | + | |
- | PEAR:: | + | |
- | + | ||
- | // Get List of PickUp Libraries | + | |
- | + | ||
- | $libs = $this-> | + | |
- | $interface-> | + | |
- | + | ||
- | // Assign Default Required By Date | + | |
- | $nextmonth | + | |
- | $defaultduedate = date(" | + | |
- | $interface-> | + | |
- | </ | + | |
- | + | ||
- | If the Hold.tpl form has been submitted, the data is added to the $gatherdDetails array and also re-assigned to the template in case there is insufficient data to place the hold. The patron data is then added to the $gatheredDetails array and assigned to $this-> | + | |
- | + | ||
- | < | + | |
- | // Form Has Been Submitted | + | |
- | if(isset($_POST[' | + | |
- | + | ||
- | // Collect all gathered Details and assign them to variable incase hold fails | + | |
- | | + | |
- | | + | |
- | + | ||
- | // Add Patron Data to Submitted Data | + | |
- | $gatheredDetails[' | + | |
- | $this-> | + | |
- | + | ||
- | + | ||
- | // Confirm Essential Variables are available and place the Hold | + | |
- | // Could be removed and rely on response from driver to produce error messages | + | |
- | + | ||
- | $required = $checkHolds[' | + | |
- | $proceed = true; | + | |
- | + | ||
- | // Check Date is Valid | + | |
- | if (isset($this-> | + | |
- | + | ||
- | $validateDate = preg_match('/ | + | |
- | if($validateDate == false) { | + | |
- | $proceed = false; | + | |
- | $this-> | + | |
- | } | + | |
- | + | ||
- | } | + | |
- | + | ||
- | foreach($required as $key) { | + | |
- | if(!array_key_exists($key, | + | |
- | $proceed = false; | + | |
- | } | + | |
- | } | + | |
- | … | + | |
- | + | ||
- | // No Submissions | + | |
- | else { | + | |
- | + | ||
- | // Display Hold Form | + | |
- | $interface-> | + | |
- | + | ||
- | } | + | |
- | </ | + | |
- | + | ||
- | If $proceed is true, then the hold attempt is made using defined function. | + | |
- | < | + | |
- | | + | |
- | + | ||
- | $results = $this-> | + | |
- | // Success: Go to Display Holds | + | |
- | if($results[' | + | |
- | header(' | + | |
- | exit(); | + | |
- | } | + | |
- | + | ||
- | // Fail: Display Form for Try Again | + | |
- | else { | + | |
- | + | ||
- | // Get as much data back as possible | + | |
- | $interface-> | + | |
- | $interface-> | + | |
- | } | + | |
- | + | ||
- | } | + | |
- | </ | + | |
- | + | ||
- | If the user is logged in but does not have a user name, Hold.php displays a form for entering their catalog username and password and assigns the data necessary for a follow up. | + | |
- | + | ||
- | < | + | |
- | // Require User Log On | + | |
- | else if ($user && empty($user-> | + | |
- | + | ||
- | $followup = $action; | + | |
- | + | ||
- | + | ||
- | $interface-> | + | |
- | $interface-> | + | |
- | $interface-> | + | |
- | + | ||
- | $interface-> | + | |
- | + | ||
- | } | + | |
- | </ | + | |
- | + | ||
- | If the user is not logged in, logged Hold.php redirects users to the login page with the details necessary for a follow up. | + | |
- | < | + | |
- | else{ | + | |
- | + | ||
- | header(' | + | |
- | exit(); | + | |
- | + | ||
- | } | + | |
- | </ | + | |
- | + | ||
- | === hold.tpl === | + | |
- | + | ||
- | + | ||
- | This has been modified to remove the toolbar and the tabnav bar. Either option could be put back in but either a new Holds Tab would need to be created or Holds would have to become part of the Holdings Tab. | + | |
- | + | ||
- | === hold-submit.tpl === | + | |
- | + | ||
- | + | ||
- | This sub template contains the form required for POSTing data back to Hold.php. It first displays any status messages which can only have been assigned if an error has occurred. | + | |
- | + | ||
- | < | + | |
- | {if $results.sysmessage} | + | |
- | <p class=" | + | |
- | {/if} | + | |
- | </ | + | |
- | + | ||
- | The form action is generated using the variables passed from Holdings.php and view-holdings-holds.tpl. | + | |
- | + | ||
- | < | + | |
- | <div class=" | + | |
- | + | ||
- | <form action=" | + | |
- | + | ||
- | {if in_array(" | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | </ | + | |
- | {/if} | + | |
- | + | ||
- | {if in_array(" | + | |
- | < | + | |
- | < | + | |
- | <input class=" | + | |
- | </ | + | |
- | {/if} | + | |
- | + | ||
- | {if in_array(" | + | |
- | < | + | |
- | {if count($pickup) > 1} | + | |
- | + | ||
- | < | + | |
- | <select name=" | + | |
- | {foreach from=$pickup item=lib name=loop} | + | |
- | <option value=" | + | |
- | {/ | + | |
- | </ | + | |
- | + | ||
- | {else} | + | |
- | <input type=" | + | |
- | {/if} | + | |
- | </ | + | |
- | {/if} | + | |
- | + | ||
- | <input type=" | + | |
- | + | ||
- | {if in_array(" | + | |
- | <input type=" | + | |
- | {/if} | + | |
- | + | ||
- | {if in_array(" | + | |
- | <input type=" | + | |
- | {/if} | + | |
- | + | ||
- | <input type=" | + | |
- | </ | + | |
- | + | ||
- | </ | + | |
- | </ | + | |
- | + | ||
- | === New Smarty Variables / Text === | + | |
- | + | ||
- | == view-holdings-holds.tpl == | + | |
- | + | ||
- | Copy | + | |
- | On Reserve - Ask at Circulation Desk | + | |
- | Recall This | + | |
- | + | ||
- | == hold.tpl == | + | |
- | + | ||
- | Place a Hold | + | |
- | + | ||
- | == hold-submit.tpl == | + | |
- | + | ||
- | Comments | + | |
- | Required By | + | |
- | Pick Up Library | + | |
- | Place Hold | + | |
- | + | ||
- | ===== Cancel Holds ===== | + | |
- | + | ||
- | ==== Files Affected ==== | + | |
- | + | ||
- | CatalogConnection.php | + | |
- | conf/ | + | |
- | Drivers/ | + | |
- | Services/ | + | |
- | Interface/ | + | |
- | + | ||
- | ==== Description ==== | + | |
- | + | ||
- | If enabled, the Cancel Holds method allows vufind users to cancel their holds. If it is not enabled, then none of the functionality | + | |
- | + | ||
- | + | ||
- | + | ||
- | ==== Process ==== | + | |
- | + | ||
- | conf/ | + | |
- | + | ||
- | [cancelHolds] | + | |
- | + | ||
- | enabled = true | + | |
- | + | ||
- | link = item_id: | + | |
- | + | ||
- | opacurl = %%http:// | + | |
- | + | ||
- | + | ||
- | The enabled field determines whether or not Cancel Holds is in use. | + | |
- | + | ||
- | The link field contains a list of array key values which are required by the cancelHolds function or the native OPAC. Each value entered here must correspond with an array key value returned by the getMyHolds function. E.g. If you want item_id to be passed to cancelHolds, | + | |
- | + | ||
- | The opacurl is the url of the native OPAC to be used by getCancelHoldLink to generate renew links. | + | |
- | + | ||
- | === MyResearch.php === | + | |
- | + | ||
- | A call is made to checkFunction and the response is assigned to $cancelHolds. | + | |
- | < | + | |
- | // Is Cancelling Holds allowed? | + | |
- | $this-> | + | |
- | </ | + | |
- | + | ||
- | === Holds.php === | + | |
- | + | ||
- | Holds.php begins as usual by confirming that the user is signed | + | |
- | < | + | |
- | + | ||
- | // Get My Holds | + | |
- | if ($this-> | + | |
- | if ($user-> | + | |
- | $patron = $this-> | + | |
- | if (PEAR:: | + | |
- | PEAR:: | + | |
- | </ | + | |
- | + | ||
- | It then proceeds to determine if cancelling holds is enabled and retrieves any messages received from services/ | + | |
- | + | ||
- | < | + | |
- | // Is cancelling Holds Available | + | |
- | if($this-> | + | |
- | + | ||
- | $function = $this-> | + | |
- | + | ||
- | // Get Message from Hold.php | + | |
- | if(isset($_GET[' | + | |
- | $cancelResults[' | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | Holds.php then checks if any data has been submitted. If it has, it assigns it to the cancelDetails variable, adds the patron array, calls the required function and assigns the results to the cancelResults array. The cancelResults variable is then assigned to hold.tpl. | + | |
- | + | ||
- | < | + | |
- | // Process Submitted Form | + | |
- | + | ||
- | if(isset($_POST[' | + | |
- | + | ||
- | $gatheredDetails[' | + | |
- | // Add Patron Data to Submitted Data | + | |
- | $gatheredDetails[' | + | |
- | $this-> | + | |
- | + | ||
- | $cancelResults = $this-> | + | |
- | + | ||
- | } | + | |
- | $interface-> | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | A call is then made to the getMyHolds function: | + | |
- | + | ||
- | < | + | |
- | $result = $this-> | + | |
- | + | ||
- | if (!PEAR:: | + | |
- | if (count($result)) { | + | |
- | // Setup Search Engine Connection | + | |
- | $class = $configArray[' | + | |
- | $db = new $class($configArray[' | + | |
- | if ($configArray[' | + | |
- | $db-> | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | Holds.php then loops through each result item and assigns the details to the recordList array, If cancel holds is enabled and the function is set as “getcancelHoldLink” , an OPAC url will be added to the cancel_link key in the ils_details array. If no opacurl key is present, the link field in the driver.ini is used to assign an associate array of values to the cancel_details key of the ils_details array. | + | |
- | + | ||
- | < | + | |
- | // Get BIB Details and add " | + | |
- | // Addition of values like "date created" | + | |
- | $recordList = array(); | + | |
- | foreach ($result as $row) { | + | |
- | $record = $db-> | + | |
- | $record[' | + | |
- | + | ||
- | // Generate Form Details for cancelling Holds if Cancelling Holds is enabled | + | |
- | + | ||
- | if($this-> | + | |
- | $cancel_details = ""; | + | |
- | $i = 1; | + | |
- | $count = count($this-> | + | |
- | + | ||
- | // Build OPAC URL | + | |
- | if ($function == “getcancelHoldLink” { | + | |
- | | + | |
- | | + | |
- | } | + | |
- | | + | |
- | | + | |
- | } | + | |
- | + | ||
- | // Form Details | + | |
- | else { | + | |
- | + | ||
- | $interface-> | + | |
- | foreach($this-> | + | |
- | if($i == $count) { | + | |
- | $cancel_details .= $row[' | + | |
- | } | + | |
- | else { | + | |
- | $cancel_details .= $row[' | + | |
- | } | + | |
- | $i++; | + | |
- | $record[' | + | |
- | + | ||
- | } | + | |
- | } | + | |
- | } | + | |
- | $recordList[] = $record; | + | |
- | } | + | |
- | </code> | + | |
- | + | ||
- | Finally, the recordList array is assigned to holds.tpl and the page is displayed. | + | |
- | + | ||
- | < | + | |
- | $interface-> | + | |
- | + | ||
- | } else { | + | |
- | $interface-> | + | |
- | } | + | |
- | } | + | |
- | } | + | |
- | } | + | |
- | | + | |
- | $interface-> | + | |
- | $interface-> | + | |
- | $interface-> | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | === Holds.tpl === | + | |
- | + | ||
- | Smarty first checks to see if any system messages have been set: | + | |
- | + | ||
- | {if $cancelResults.sysmessage} | + | |
- | < | + | |
- | {/if} | + | |
- | + | ||
- | Next, if recordList is an array, holds.tpl first determines if vufind is being used to cancel holds. If it is, it will create two forms which POST data back to holds.php. The first cancels all items and uses information in the ils_details array assigned by the driver: | + | |
- | + | ||
- | < | + | |
- | {if is_array($recordList)} | + | |
- | + | ||
- | {if $cancelOption == " | + | |
- | <form name=" | + | |
- | {foreach from=$recordList item=resource} | + | |
- | <input type=" | + | |
- | {/ | + | |
- | <p> | + | |
- | <input type=" | + | |
- | </ | + | |
- | </ | + | |
- | + | ||
- | <form name=" | + | |
- | {/if} | + | |
- | </ | + | |
- | + | ||
- | The second uses checkboxes to give users the option of selecting individual holds to cancel. It is generated as part of the recordList | + | |
- | + | ||
- | < | + | |
- | <ul class=" | + | |
- | {foreach from=$recordList item=resource name=" | + | |
- | {if ($smarty.foreach.recordLoop.iteration % 2) == 0} | + | |
- | <li class=" | + | |
- | {else} | + | |
- | <li class=" | + | |
- | {/if} | + | |
- | <div class=" | + | |
- | <div class=" | + | |
- | <img src=" | + | |
- | + | ||
- | <div class=" | + | |
- | <a href=" | + | |
- | {if $resource.author} | + | |
- | {translate text=' | + | |
- | {/if} | + | |
- | {if $resource.tags} | + | |
- | {translate text=' | + | |
- | {foreach from=$resource.tags item=tag name=tagLoop} | + | |
- | <a href=" | + | |
- | {/ | + | |
- | < | + | |
- | {/if} | + | |
- | {if $resource.notes} | + | |
- | {translate text=' | + | |
- | {/if} | + | |
- | + | ||
- | {if is_array($resource.format)} | + | |
- | {foreach from=$resource.format item=format} | + | |
- | <span class=" | + | |
- | {/ | + | |
- | {else} | + | |
- | <span class=" | + | |
- | {/if} | + | |
- | + | ||
- | < | + | |
- | + | ||
- | < | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | <br /> | + | |
- | {if $cancelOption == " | + | |
- | | + | |
- | | + | |
- | <a href=" | + | |
- | | + | |
- | + | ||
- | </ | + | |
- | </ | + | |
- | </ | + | |
- | </ | + | |
- | {/ | + | |
- | </ | + | |
- | </ | + | |
- | + | ||
- | holds.tpl finally determines if vufind is being used to cancel holds, supplies a submit button and finishes the form. | + | |
- | + | ||
- | < | + | |
- | {if $cancelOption} | + | |
- | <br /> | + | |
- | <input type=" | + | |
- | </ | + | |
- | {/if} | + | |
- | </ | + | |
- | + | ||
- | + | ||
- | ==== New Smarty Variables / Text ==== | + | |
- | + | ||
- | Cancel All Holds | + | |
- | + | ||
- | Cancel Selected Holds | + | |
- | + | ||
- | Cancel Hold | + | |
- | + | ||
- | ===== Renew Items ===== | + | |
- | + | ||
- | ==== Files Affected ==== | + | |
- | + | ||
- | CatalogConnection.php | + | |
- | conf/ | + | |
- | Drivers/ | + | |
- | Services/ | + | |
- | Services/ | + | |
- | Interface/ | + | |
- | + | ||
- | ==== Description ==== | + | |
- | + | ||
- | If enabled, the Renew Items method allows vufind users to renew their transactions. If it is not enabled, then none of the functionality is displayed. | + | |
- | + | ||
- | + | ||
- | ==== Process ==== | + | |
- | + | ||
- | conf/ | + | |
- | + | ||
- | [Renewals] | + | |
- | + | ||
- | enabled = true | + | |
- | + | ||
- | link = item_id | + | |
- | + | ||
- | opacurl = %%http:// | + | |
- | + | ||
- | The enabled field determines whether or not Renewals is in use. | + | |
- | + | ||
- | The link field contains a list of array key values which are required by the renewMyItems function or the native OPAC. Each value entered here must correspond an array key value returned by the getMyTransactions function. E.g. If you want item_id to be passed to renewMyItems, | + | |
- | + | ||
- | The opacurl is the url of the native OPAC to be used by renewMyItemsLink to generate renew links. | + | |
- | + | ||
- | ==== MyResearch.php ==== | + | |
- | + | ||
- | A call is made to checkFunction and the response is assigned to $checkRenew. | + | |
- | + | ||
- | // Is Renewing Items allowed? | + | |
- | $this-> | + | |
- | + | ||
- | + | ||
- | ==== CheckedOut.php ==== | + | |
- | + | ||
- | CheckedOut.php begins as usual by confirming that the driver is available and that the user is logged | + | |
- | + | ||
- | <code | + | |
- | // Get My Transactions | + | |
- | if ($this-> | + | |
- | if ($user-> | + | |
- | $patron = $this-> | + | |
- | if (PEAR:: | + | |
- | PEAR:: | + | |
- | </ | + | |
- | + | ||
- | It then proceeds to get a list of user transactions. All the data assigned by the driver (duedate and item_id in this instance) is stored in an array with a key of “ils_details” so that system specific values will not have to be added to CheckedOut.php: | + | |
- | + | ||
- | < | + | |
- | $result = $this-> | + | |
- | if (!PEAR:: | + | |
- | $transList = array(); | + | |
- | foreach ($result as $data) { | + | |
- | $record = $this-> | + | |
- | // Due Date etc added to extra in driver to negate need to edit this file | + | |
- | $transList[] = array(' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | + | ||
- | } | + | |
- | </ | + | |
- | + | ||
- | Once the transaction list has been established, | + | |
- | + | ||
- | < | + | |
- | if($this-> | + | |
- | + | ||
- | $function = $this-> | + | |
- | + | ||
- | foreach($transList as $key => $item) { | + | |
- | + | ||
- | // Reset $renew_details for next item | + | |
- | $renew_details = ""; | + | |
- | $i = 1; | + | |
- | $count = count($this-> | + | |
- | + | ||
- | // Build OPAC URL | + | |
- | if ($function == “renewMyItemsLink”) { | + | |
- | | + | |
- | | + | |
- | } | + | |
- | | + | |
- | | + | |
- | } | + | |
- | + | ||
- | // Form Details | + | |
- | else { | + | |
- | foreach($this-> | + | |
- | if($i == $count) { | + | |
- | $renew_details .= $item[' | + | |
- | } | + | |
- | else { | + | |
- | $renew_details .= $item[' | + | |
- | } | + | |
- | $i++; | + | |
- | $transList[$key][' | + | |
- | + | ||
- | } | + | |
- | $interface-> | + | |
- | } | + | |
- | + | ||
- | } | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | If renewals are enabled, it then checks to see if it has received any POST data. If it has, it adds it to the $gatheredDetails[' | + | |
- | + | ||
- | < | + | |
- | // Rewew Items | + | |
- | + | ||
- | if(isset($_POST[' | + | |
- | + | ||
- | $gatheredDetails[' | + | |
- | // Add Patron Data to Submitted Data | + | |
- | $gatheredDetails[' | + | |
- | $this-> | + | |
- | + | ||
- | $renewResult = $this-> | + | |
- | $renewResult = $this-> | + | |
- | + | ||
- | // Assign Results to the Template | + | |
- | $interface-> | + | |
- | + | ||
- | // Extract id keys and assign them to the Template | + | |
- | + | ||
- | $ids = array_keys($renewResult); | + | |
- | $interface-> | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | In this instance, the $_POST data is an array of item ids. The driver returns an array with two main keys. The first, “details” contains an array of details for each renew attempt. In this instance, that includes a Boolean success key (true or false), the item_id and a sysmessage key which holds any message returned by the system (e.g. Items with hold requests may not be renewed.) The second main key is id_array which contains a list of all the item_ids for which a renewal has been attempted. It is included for convenient use in the checkedout template. | + | |
- | + | ||
- | ==== checkedout.tpl ==== | + | |
- | + | ||
- | checkedout.tpl first determines if vufind is being used to renew items. If it is, it will create two forms which POST data back to checkedout.php. The first renews all items and uses information in the ils_details array assigned by the driver: | + | |
- | + | ||
- | < | + | |
- | {if $renewOption == " | + | |
- | <form name=" | + | |
- | < | + | |
- | <div class=" | + | |
- | {foreach from=$transList item=resource} | + | |
- | <input type=" | + | |
- | {/ | + | |
- | + | ||
- | <input type=" | + | |
- | </ | + | |
- | </ | + | |
- | <br class=" | + | |
- | </ | + | |
- | + | ||
- | <form name=" | + | |
- | {/if} | + | |
- | </ | + | |
- | + | ||
- | The second uses checkboxes to give users the option of selecting individual items to renew. It is generated as part of the transaction list operation. | + | |
- | + | ||
- | < | + | |
- | <ul class=" | + | |
- | {foreach from=$transList item=resource name=" | + | |
- | {if ($smarty.foreach.recordLoop.iteration % 2) == 0} | + | |
- | <li class=" | + | |
- | {else} | + | |
- | <li class=" | + | |
- | {/if} | + | |
- | <div class=" | + | |
- | <div class=" | + | |
- | <img src=" | + | |
- | + | ||
- | <div class=" | + | |
- | <a href=" | + | |
- | {if $resource.author} | + | |
- | {translate text=' | + | |
- | {/if} | + | |
- | {if $resource.tags} | + | |
- | {translate text=' | + | |
- | {foreach from=$resource.tags item=tag name=tagLoop} | + | |
- | <a href=" | + | |
- | {/ | + | |
- | < | + | |
- | {/if} | + | |
- | {if $resource.notes} | + | |
- | {translate text=' | + | |
- | {/if} | + | |
- | + | ||
- | {if is_array($resource.format)} | + | |
- | {foreach from=$resource.format item=format} | + | |
- | <span class=" | + | |
- | {/ | + | |
- | {else} | + | |
- | <span class=" | + | |
- | {/if} | + | |
- | + | ||
- | < | + | |
- | + | ||
- | + | ||
- | {* Make sure a renewResult is available *} | + | |
- | {if $renewResult} | + | |
- | {* Check if a renew attempt has been made *} | + | |
- | {if in_array($resource.ils_details.item_id, | + | |
- | {* Loop Through renewmsg and display details if there is a match to the current item *} | + | |
- | {foreach from=$renewResult item=item_info key=item_id} | + | |
- | + | ||
- | {if $item_id == $resource.ils_details.item_id} | + | |
- | {if $item_info.success ==" | + | |
- | < | + | |
- | <br /> | + | |
- | {translate text=' | + | |
- | {else} | + | |
- | < | + | |
- | <br /> | + | |
- | {translate text=' | + | |
- | {/if} | + | |
- | {/ | + | |
- | {/ | + | |
- | {else} | + | |
- | < | + | |
- | {/if} | + | |
- | {else} | + | |
- | < | + | |
- | {/if} | + | |
- | + | ||
- | <br /> | + | |
- | {if $renewOption == " | + | |
- | {translate text=' | + | |
- | {elseif $renewOption == " | + | |
- | <a href=" | + | |
- | {/if} | + | |
- | + | ||
- | + | ||
- | </ | + | |
- | </ | + | |
- | + | ||
- | </ | + | |
- | </ | + | |
- | {/ | + | |
- | </ | + | |
- | </ | + | |
- | + | ||
- | checkedout.tpl finally determines if vufind is being to renew items, supplies a submit button and finishes the form. | + | |
- | + | ||
- | < | + | |
- | {if $renewOption == " | + | |
- | <br /> | + | |
- | <input type=" | + | |
- | </ | + | |
- | {/if} | + | |
- | </ | + | |
- | + | ||
- | ==== New Smarty Variables / Text ==== | + | |
- | + | ||
- | Renew All Items | + | |
- | Renew Successful | + | |
- | Renew Unsuccessful | + | |
- | Renew Item | + | |
- | Renew Selected Items | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
---- struct data ---- | ---- struct data ---- | ||
---- | ---- | ||
expanded_driver_func.txt · Last modified: 2014/06/13 13:14 by 127.0.0.1