About Features Downloads Getting Started Documentation Events Support GitHub

Love VuFind®? Consider becoming a financial supporter. Your support helps build a better VuFind®!

Site Tools


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.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
expanded_driver_func [2010/02/11 12:15] l.osullivanexpanded_driver_func [2014/06/13 13:14] (current) – external edit 127.0.0.1
Line 1: Line 1:
-**Bold Text**====== Expanded Driver Functionality ====== +====== Expanded Driver Functionality ====== 
- +This page is no longer needed -- see [[http://blog.library.villanova.edu/libtech/2011/06/02/expanded-ils-functionality-in-vufind/|this blog post]] for details on the final implementation of this functionality.
- +
-===== SVN Source ===== +
- +
-**%%https://vufind.svn.sourceforge.net/svnroot/vufind/branches/luke%%** +
- +
-===== Purpose ===== +
-To create a flexible and gracefully degrading solution for the 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:  Driver.php**  +
- +
-public function getConfig($function) +
-    { +
-    if(isset($this->config[$function]) && $this->config[$function]['enabled'] == true) { +
-        $functionConfig = $this->config[$function]; +
-    } +
-    else { +
-        $functionConfig = false;     +
-    } +
-      return $functionConfig; +
-    } +
- +
-Accepts a string argument which must correspond with an array key in $this->config which is loaded from driver.ini. If he array key ‘enabled’ is true, it returns the corresponding driver.ini settings as an array. If the array key ‘enabled’ is false, it returns false. +
- +
- +
- +
- +
- +
-==== checkFunction($function) ==== +
-  +
-**Location: CatalogConnection.php** +
- +
-Sample: Holds +
- +
-<code> +
-function checkFunction($function) +
-    { +
-     +
-        if (!method_exists($this->driver, 'getConfig')) { +
-            return false; +
-        } +
-         +
-        switch ($function) { +
-            case "Holds": +
-                                 +
-                $functionConfig = $this->driver->getConfig("Holds"); +
-                 +
-                if(!$functionConfig) { +
-                    return false; +
-                } +
-                 +
-                if (method_exists($this->driver, 'placeHold') && method_exists($this->driver, 'getPickUpLocations') && $functionConfig['link'] != "" && $functionConfig['required'] != "") { +
-                     $response['function'] = "placeHold"; +
-                     $response['type'] = $functionConfig['type']; +
-                     $response['link'] = explode(":", $functionConfig['link']); +
-                     $response['required'] = explode(":", $functionConfig['required']); +
-                     $response['optional'] = explode(":", $functionConfig['optional']); +
-                 +
-                } +
-                 +
-                else if (method_exists($this->driver, 'getHoldLink') && $functionConfig['opacurl'] != "") { +
- +
-                    $response['function'] = "getHoldLink"; +
-                    $response['type'] = $functionConfig['type']; +
-                    $response['link'] = explode(":", $functionConfig['link']); +
-                    $response['opacurl'] = $functionConfig['opacurl']; +
-                } +
-                 +
-                else { +
-                    return false; +
-                } +
-                     +
-                return $response; +
-                break; +
-                   … +
-                default: return false; +
-             } +
- +
-    } +
-</code> +
- +
-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.  If getConfig exists, the function parameters set in driver.ini are loaded into $functionConfig . It also checks for the correct method to use with the function. If the function is not enabled, it returns false. +
- +
-==== getPickUpLocations ($patron) ==== +
-  +
-**Location: CatalogConnection.php / Driver** +
- +
-Accepts an array argument of patron information returned by patronLogin ($patron = $this->catalog->patronLogin($user->cat_username, $user->cat_password);). It returns an array of associative arrays.  In this instance, each associative array includes the keys lib_id (the system library id) and lib_name (the system library name). +
- +
- +
-==== 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('id' => $id, +
-                        'item_id' => $row['ITEM_ID'], // Site Specific Example +
-                                     'availability' => $availability['available'], +
-                                     'status' => $row['STATUS'], +
-                                     'location' => htmlentities($row['LOCATION']), +
-                                     'reserve' => $row['ON_RESERVE'], +
-                                     'callnumber' => $row['CALLNUMBER'], +
-                                     'duedate' => $row['DUEDATE'], +
-                                     'number' => $number, +
-                                     'barcode' => $row['ITEM_BARCODE'], +
-                                     'holdtype' => 'RECALL'); +
- +
-==== 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  function.  +
- +
- +
-                                     $transList[] = array('id' => $row['BIB_ID'],'ils_details' => array( +
-                                     'duedate' => $row['DUEDATE'], +
-         'item_id' => $row['ITEM_ID']));  // Site Specific Example +
- +
-==== 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:  'item_id', the individual id of the item for which a renewal was attempted, 'new_date', the new due date of the item, 'success' a Boolean true or false indicating if the item was renewed or not and sysmessage, any system messages regarding the operation. +
- +
-==== placeHold($holdDetails) ==== +
-  +
-**Location: Driver.php** +
- +
-Must accept an array of key / value pairs . Returns an array with two main keys:  'success',  a Boolean true or false indicating if the hold was successful and ‘sysmessage’, any system messages regarding the operation. +
- +
-==== cancelHold($holdDetails) ==== +
-  +
-**Location: Driver.php** +
- +
-Must accept an array of key / value pairs . Returns an array with two main keys:  'success',  a Boolean true or false indicating if the hold was successful and ‘sysmessage’, any system messages regarding the operation. +
- +
-===== Place Hold / Get Hold Link ===== +
- +
- +
- +
- +
- +
-==== Files Affected ==== +
- +
-**CatalogConnection.php** +
- +
-**conf/config.ini** +
- +
-**Drivers/All** +
- +
-**Services/Record/Holdings.php** +
- +
-**Services/Record/Hold.php** +
- +
-**Services/Record/Hold.tpl** +
- +
-**Services/MyResearch/Holds.php** +
- +
-**Interface/MyResearch/view-holdings.tpl** +
- +
- +
-====New Files==== +
-**Interface/Record/hold-submit.tpl +
- +
-Services/Record/catalog-login.tpl** +
- +
- +
-==== 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.  The method takes GET information supplied by Holdings.php and view-holdings.tpl , passes it to the driver and returns the response. If getHoldLink is the preferred Holds method, a link to the native OPAC will be generated and displayed in view-holdings.tpl. +
- +
-NB: Hypertext link could be converted to form element in order to provide a POST option for continuity between methods. +
- +
- +
- +
- +
- +
- +
- +
- +
-==== Process ==== +
- +
-**conf/driver.ini** +
- +
-[Holds] +
-enabled = true +
- +
-type = availability +
- +
-link = item_id:holdtype +
- +
-required = id:item_id:holdtype:patron:pickuplib +
- +
-optional = comment:required_by +
- +
-opacurl = %%http://opac.swan.ac.uk/holdingsInfo/placehold%% +
- +
-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:  id, item_id, availability, status, location, reserve, callnumber,  duedate, number,  barcode and holdtype. +
- +
-A call is made to checkFunction and the response is assigned to $checkHolds. +
- +
-<code> +
-// Are holds allows? +
-        $checkHolds = $catalog->checkFunction("Holds"); +
- if($checkHolds != false) { +
- +
- +
-            // Function which we will submit data to +
-            $function = $checkHolds['function']; +
- +
-            $type = $checkHolds['type']; +
-</code> +
- +
-Holdings.php then loops through each item to determine if any copies are available and sets the $any_available variable.  +
- +
-<code> +
-// 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['availability'] == true) { +
-                            $any_availability = true; +
-                        } +
-                    } +
-                } +
-</code> +
- +
-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”. +
- +
-<code> +
-// Generate Links +
-            // Loop through each holding +
-                foreach ($holdings as $location_key => $location) { +
-                    foreach ($location as $copy_key => $copy) { +
- +
-                        switch($type) {  +
-                            case "all": +
-                                $addlink = true; // always provide link +
-                                break; +
-                            case "holds": +
-                                $addlink = $copy['availability']; +
-                                break; +
-                            case "recalls": +
-                                $addlink = !$copy['availability']; +
-                                break; +
-                            case "availability": +
-                                $addlink = ($copy['availability'] == false && $any_availability == false); +
-                                break; +
-                            default: +
-                                $addlink = false; +
-                                break; +
-                        } +
- +
-                        if ($addlink) { +
-                            if ($function == "getHoldLink"){ +
-                            /* Build opac link */ +
-                                foreach($checkHolds['link'] as $link) {  +
-                                    $opacArray[$link] = $copy[$link]; +
-                                } +
- +
-                                // Assign the Opac Link to the Holdsings Array +
-                                $holdings[$location_key][$copy_key]['link'] = $catalog->getHoldLink($opacArray);  +
-                            }  +
-                            else { +
-                            /* Build non-opac link */ +
-                            $site_url = $configArray['Site']['url']; +
-                            $id = $copy['id']; +
-                            $holdLink = $site_url."/Record/".urlencode($id)."/Hold?"; +
-                            $i = 0; +
-                                foreach($checkHolds['link'] as $link) { +
-                                    if ($i == 0) { +
-                                        $holdLink .= $link."=".urlencode($copy[$link]); +
-                                    } +
-                                    else { +
-                                        $holdLink .= "&".$link."=".urlencode($copy[$link]); +
-                                   } +
-                                   $i++; +
-                                } +
-                            $holdings[$location_key][$copy_key]['link'] = $holdLink; +
-                            } +
-                        } +
-                    } +
-</code> +
- +
-Finally, the template is set and the holdings array is assigned to Smarty. +
- +
-       $interface->assign('subTemplate', 'view-holdings.tpl'); +
-        $interface->assign('holdings', $holdings); +
-        $interface->setTemplate('view.tpl'); +
-         +
-        // Display Page +
-        $interface->display('layout.tpl'); +
- +
- +
-=== Interface/MyResearch/view-holdings.tpl === +
- +
-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.  +
- +
-<code> +
-{* Begin Available Items (Holds) *} +
-          {if $row.availability}  +
-      <span class="available">{translate text="Available"}</span> +
- +
-        {if $row.link} +
-            | <a href="{$row.link|escape}">{translate text="Place a Hold"}</a> +
- +
-         +
-        {/if} +
-      +
-          +
-       {* Begin Unavailable Items (Recalls) *} +
- +
-       {else} +
- +
-       <span class="checkedout">{$row.status}</span> +
-          {if $row.duedate} +
-            {translate text="Due"}: {$row.duedate} +
-          {/if} +
-             +
-              {if $row.link} +
-                | <a href="{$row.link|escape}">{translate text="Place a Request"}</a> +
- +
-              {/if}     {/if}  +
-</code> +
-=== 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. +
- +
-<code> +
-// Are Holds Allowed? +
- +
-        $checkHolds = $catalog->checkFunction("Holds"); +
- +
-        if($checkHolds != false) { +
-              +
-            // Function which we will submit data to +
- +
-            $function = $checkHolds['function']; …. +
-+
-else { +
-        // Shouldn't Be Here +
-        header('Location: ../../Record/'.urlencode($this->id));  +
-        exit(); +
-        }  +
-</code> +
- +
-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. +
- +
-<code> +
-// Get Values Passed to Page from holdings.php +
-            // Could be removed and rely on response from driver to produce error messages +
-            $linked = $checkHolds['link']; +
-     $i=0; +
-            foreach($linked as $details) { +
-                $this->gatheredDetails[$details] = $_GET[$details]; +
-                // Build Logon URL +
-                if ($i == 0) { +
-                    $logonURL .= "?".$details."=".$_GET[$details]; +
-                } +
-                else { +
-                    $logonURL .= "&".$details."=".$_GET[$details]; +
-                } +
-                $i++; +
-            } +
- +
-           // Assign Required and Optional Variables +
-            $required = $checkHolds['required']; +
-            $optional =  $checkHolds['optional']; +
-             +
-            $form_fields = array_merge($required, $optional); +
-            $interface->assign('form_fields', $form_fields); +
- +
-            $interface->assign('gatheredDetails', $this->gatheredDetails); +
- +
-// User Must be Logged in and have a catalog username To Place Hold +
-             +
-     if ($user && $user->cat_username) {          …. +
-       }  +
-</code>        +
- +
-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. +
- +
-<code> +
-// Connect to Database  +
-                $this->catalog = new CatalogConnection($configArray['Catalog']['driver']); +
-                 +
-                // Register User Details +
-                $patron = $this->catalog->patronLogin($user->cat_username, $user->cat_password); +
-                if (PEAR::isError($patron)) +
-                    PEAR::raiseError($patron); +
-                 +
-                // Get List of PickUp Libraries +
- +
-                $libs = $this->catalog->getPickUpLocations($patron); +
-                $interface->assign('pickup', $libs); +
- +
-                // Assign Default Required By Date +
-                $nextmonth  = mktime(0, 0, 0, date("m")+1,   date("d"),   date("Y")); +
-                $defaultduedate = date("Y-m-d", $nextmonth); +
-                $interface->assign('defaultduedate', $defaultduedate); +
-</code> +
- +
-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->holdDetails. The array keys of $this->holdDetails are then checked against the required config values. If any of the keys are missing or if the date does not match the ISO format, the $proceed variable is set to false.  If the form has not been submitted, the hold-submit.tpl template is displayed. +
- +
-<code> +
-                // Form Has Been Submitted +
-                if(isset($_POST['placeHold'])) { +
- +
-                     // Collect all gathered Details and assign them to variable incase hold fails +
-                     $gatheredDetails = $_POST['gatheredDetails']; +
-                     $interface->assign('gatheredDetails', $gatheredDetails); +
- +
-                    // Add Patron Data to Submitted Data +
-                    $gatheredDetails['patron'] = $patron; +
-                    $this->holdDetails = $gatheredDetails; +
- +
- +
-                    // Confirm Essential Variables are available and place the Hold +
-                    // Could be removed and rely on response from driver to produce error messages +
- +
-                    $required = $checkHolds['required']; +
-                    $proceed = true; +
- +
-                    // Check Date is Valid                     +
-                    if (isset($this->holdDetails['required_by'])) {               +
- +
-                        $validateDate = preg_match('/^(\d{4})-(0[1-9]|1[0-2])-([12]\d|0[1-9]|3[01])$/', $this->holdDetails['required_by']); +
-                        if($validateDate == false) { +
-                            $proceed = false; +
-                            $this->holdDetails['required_by'] = $defaultduedate; +
-                        } +
-                        +
-                    } +
- +
-                    foreach($required as $key) { +
-                        if(!array_key_exists($key, $this->holdDetails)) { +
-                        $proceed = false;         +
-                        } +
-                    } +
-                  … +
- +
-                // No Submissions +
-                else { +
- +
-                // Display Hold Form +
- $interface->assign('subTemplate', 'hold-submit.tpl'); +
- +
-                } +
-</code> +
- +
-If $proceed is true, then the hold attempt is made using defined function.  The function returns an array with a mandatory success key which must be a Boolean true or false. In this instance, it also returns a status message which gives more information on the result. If result is true, then the user is redirected to MyResearch/Holds to list all their holds. If it is false, the results array is assigned to the template and the template is displayed. +
-<code> +
-                       if($proceed == true) { +
- +
-                        $results = $this->catalog->$function($this->holdDetails); +
-                        // Success: Go to Display Holds +
-                        if($results['success'] == true) {  +
-                        header('Location: ../../MyResearch/Holds?success=true');  +
-                        exit(); +
-                        } +
- +
-                        // Fail: Display Form for Try Again  +
-                        else { +
- +
-                        // Get as much data back as possible +
-                        $interface->assign('results', $results);                       +
- $interface->assign('subTemplate', 'hold-submit.tpl'); +
-                        }        +
- +
-                    }  +
-</code> +
- +
-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. +
- +
-<code> +
-// Require User Log On +
-     else if ($user && empty($user->cat_username)) { +
- +
-            $followup = $action; +
- +
-         +
-            $interface->assign('followup', $followup); +
-            $interface->assign('followupModule', $module); +
-            $interface->assign('followupAction', $action.$logonURL); +
- +
-            $interface->assign('subTemplate', 'catalog-login.tpl');  +
-                     +
-     } +
-</code> +
- +
-If the user is not logged in, logged Hold.php redirects users to the login page with the details necessary for a follow up. +
-<code> +
-            else{ +
- +
-                header('Location: ../../MyResearch/Login?recordId='.urlencode$id = $this->recordDriver->getUniqueID()).'&followupModule=Record&followupAction=Hold'.urlencode($logonURL));  +
-                exit();  +
-                     +
-     } +
-</code> +
- +
-=== 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. +
- +
-<code> +
-{if $results.sysmessage} +
-<p class="error">{translate text=$results.sysmessage|escape}</p> +
-{/if} +
-</code> +
- +
-The form action is generated using the variables passed from Holdings.php and view-holdings-holds.tpl.  Each form element is displayed only if its key exists in the $form_fields array. If the array received from the getPickUpLocations  function has only one entry, a hidden input is generated with the library id as the valueIf the array has multiple entries, a select box is generatedAt present, the entire form is hardcoded but it could be dynamically created using the link and required config  values. +
- +
-<code> +
-  <div class="hold-form"> +
- +
-  <form action="{$url|escape}/Record/{$id|escape}/Hold?item_id={$gatheredDetails.item_id|escape}&amp;holdtype={$gatheredDetails.holdtype|escape}" method="post"> +
-     +
-    {if in_array("comment", $form_fields)} +
-    <div> +
-    <strong>{translate text="Comments"}:</strong><br> +
-    <textarea name="gatheredDetails[comment]">{$gatheredDetails.comment|escape}</textarea> +
-    </div> +
-    {/if} +
-    +
-    {if in_array("required_by", $form_fields)} +
-    <div> +
-    <strong>{translate text="Required By"}: ({translate text=hold_date_format})</strong><br /> +
-    <input class="DatePicker" type="text" name="gatheredDetails[required_by]" size="10" value="{if $gatheredDetails.required_by !=""}{$gatheredDetails.required_by|escape}{else}{$defaultduedate}{/if}"><br /> +
-    </div> +
-    {/if} +
-     +
-    {if in_array("pickuplib", $form_fields)} +
-    <div> +
-    {if count($pickup) > 1} +
-     +
-    <strong>{translate text="Pick Up Library"}:</strong><br> +
-    <select name="gatheredDetails[pickuplib]"> +
-    {foreach from=$pickup item=lib name=loop} +
-      <option value="{$lib.libid|escape}" {if $lib.libid == $gatheredDetails.pickUp}selected="selected"{/if}>{$lib.libname|escape}</option> +
-    {/foreach} +
-    </select> +
- +
-    {else} +
-      <input type="hidden" name="gatheredDetails[pickuplib]" value="{$pickup.0.libid|escape}" /> +
-    {/if} +
-    </div>   +
-    {/if} +
-     +
-    <input type="hidden" name="gatheredDetails[id]" value="{$id}|escape" /> +
-     +
-    {if in_array("item_id", $form_fields)} +
-    <input type="hidden" name="gatheredDetails[item_id]" value="{$gatheredDetails.item_id|escape}" /> +
-    {/if} +
-     +
-    {if in_array("holdtype", $form_fields)} +
-    <input type="hidden" name="gatheredDetails[holdtype]" value="{$gatheredDetails.holdtype|escape}" /> +
-    {/if} +
-     +
-    <input type="submit" name="placeHold" value="{translate text="Place Hold"}"> +
-  </form> +
-   +
-  </div> +
-</code> +
- +
-=== 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/config.ini +
-Drivers/All +
-Services/MyResearch/Holds.php +
-Interface/MyResearch/Holds.tpl +
- +
-==== Description ==== +
- +
-If enabled, the Cancel Holds method allows vufind users to cancel their holds. If it is not enabled, then none of the functionality is displayed.  The method either takes information supplied via a POST form, passes it to the driver and returns the response or generates a url link to the native OPAC. +
- +
- +
- +
-==== Process ==== +
- +
-conf/driver.ini +
- +
-[cancelHolds] +
- +
-enabled = true +
- +
-link = item_id:recall_id +
- +
-opacurl = %%http://opac.swan.ac.uk/holdingsInfo/cancelHold%% +
- +
- +
-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, an array key of item_id must be returned by getMyHolds in the ils_details array. +
- +
-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.  +
-<code> +
-        // Is Cancelling Holds allowed? +
-        $this->cancelHolds = $this->catalog->checkFunction("CancelHolds"); +
-</code> +
- +
-=== Holds.php === +
- +
-Holds.php begins as usual by confirming that the user is signed in+
-<code> +
- +
-// Get My Holds +
-        if ($this->catalog->status) { +
-            if ($user->cat_username) { +
-                $patron = $this->catalog->patronLogin($user->cat_username, $user->cat_password); +
-                if (PEAR::isError($patron)) +
-                    PEAR::raiseError($patron); +
-</code> +
- +
-It then proceeds to determine if cancelling holds is enabled and retrieves any messages received from services/Record/Hold.php. +
- +
-<code> +
-// Is cancelling Holds Available +
-         if($this->cancelHolds != false) { +
-  +
-                $function = $this->cancelHolds['function']; +
- +
-                    // Get Message from Hold.php +
-                    if(isset($_GET['success']) && $_GET['success'] != "") { +
-                        $cancelResults['success'] = $_GET['success']; +
-                    } +
-</code> +
- +
-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.  +
- +
-<code> +
-    // Process Submitted Form +
- +
-                    if(isset($_POST['cancelHold'])) { +
- +
-                        $gatheredDetails['details'] = $_POST['cancelHold']; +
-                        // Add Patron Data to Submitted Data +
-                        $gatheredDetails['patron'] = $patron; +
-                        $this->cancelDetails = $gatheredDetails; +
-  +
-                        $cancelResults = $this->catalog->$function($this->cancelDetails);                       +
-                         +
-             } +
-                $interface->assign('cancelResults', $cancelResults); +
-                } +
-</code> +
- +
-A call is then made to the getMyHolds function: +
- +
-<code> +
-$result = $this->catalog->getMyHolds($patron); +
- +
-                if (!PEAR::isError($result)) {  +
-                    if (count($result)) { +
-                        // Setup Search Engine Connection +
-                        $class = $configArray['Index']['engine']; +
-                        $db = new $class($configArray['Index']['url']); +
-                        if ($configArray['System']['debug']) { +
-                            $db->debug = true; +
-                        } +
-</code> +
- +
-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. +
- +
-<code> +
-                        // Get BIB Details and add "ils_details" details to result +
-                        // Addition of values like "date created" etc moved to "ils_details" array key in Driver to negate need to edit Holds.php  +
-                        $recordList = array(); +
-                        foreach ($result as $row) { +
-                            $record = $db->getRecord($row['id']); +
-                            $record['ils_details'] = $row['ils_details']; +
- +
-                            // Generate Form Details for cancelling Holds if Cancelling Holds is enabled +
-                           +
-                            if($this->cancelHolds != false) { +
-                                $cancel_details = ""; +
-                                $i = 1; +
-                                $count = count($this->cancelHolds['link']); +
-                                 +
-                                // Build OPAC URL +
-                                if ($function == “getcancelHoldLink” { +
-                                     foreach($this->cancelHolds['link'] as $link) {  +
-                                         $opacArray[$link] = $row['ils_details'][$link]; +
-                                     } +
-                                     $record['ils_details']['cancel_link'] = $this->catalog->$function($opacArray); +
-                                     $interface->assign('cancelOption', "OPAC"); +
-                                } +
- +
-                                // Form Details +
-                                else { +
- +
-                                    $interface->assign('cancelOption', "vufind"); +
-                                    foreach($this->cancelHolds['link'] as $link) { +
-                                        if($i == $count) { +
-                                            $cancel_details .= $row['ils_details'][$link]; +
-                                        } +
-                                        else { +
-                                            $cancel_details .= $row['ils_details'][$link]."|"; +
-                                        } +
-                                    $i++; +
-                                    $record['ils_details']['cancel_details'] = $cancel_details; +
-                                  +
-                                    } +
-                                }     +
-                            } +
-                            $recordList[] = $record; +
-                        } +
-</code> +
- +
-Finally, the recordList array is assigned to holds.tpl and the page is displayed. +
- +
-<code> +
-  $interface->assign('recordList', $recordList); +
-                     +
-                    } else { +
-                        $interface->assign('recordList', 'You do not have any holds'); +
-                    } +
-                } +
-            } +
-        } +
-         $interface->setTemplate('holds.tpl'); +
-        $interface->assign('results', $results); +
-        $interface->setPageTitle('My Holds'); +
-        $interface->display('layout.tpl'); +
-    } +
-</code> +
- +
-=== Holds.tpl === +
- +
-Smarty first checks to see if any system messages have been set: +
- +
-          {if $cancelResults.sysmessage} +
-   <p>{translate text="Your Request was Successful."}</p> +
-          {/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:  +
- +
-<code> +
-{if is_array($recordList)} +
- +
-            {if $cancelOption == "vufind"+
-            <form name="cancelAll" action="{$url|escape}/MyResearch/Holds" method="POST" id="cancelAll"> +
-            {foreach from=$recordList item=resource} +
-            <input type="hidden" name="cancelHold[]" value="{$resource.ils_details.cancel_details|escape}" /> +
-            {/foreach} +
-            <p> +
-            <input type="submit" name="cancel" class="cancelHold" value="{translate text="Cancel All Holds"}" /> +
-     </p> +
-            </form> +
-             +
-            <form name="cancelForm" action="{$url|escape}/MyResearch/Holds" method="POST" id="cancelHold"> +
-            {/if} +
-</code> +
- +
-The second uses checkboxes to give users the option of selecting individual holds to cancel. It is generated as part of the recordList  list operation. +
- +
-<code> +
-<ul class="filters"> +
-        {foreach from=$recordList item=resource name="recordLoop"+
-          {if ($smarty.foreach.recordLoop.iteration % 2) == 0} +
-          <li class="result alt"> +
-          {else} +
-          <li class="result"> +
-          {/if} +
-            <div class="yui-ge"> +
-              <div class="yui-u first"> +
-                <img src="{$path|escape}/bookcover.php?isn={$resource.isbn.0|@formatISBN|escape}&amp;size=small" class="alignleft"> +
- +
-                <div class="resultitem"> +
-                  <a href="{$url|escape}/Record/{$resource.id|escape:"url"}" class="title">{$resource.title|escape}</a><br> +
-                  {if $resource.author} +
-                  {translate text='by'}: <a href="{$url|escape}/Author/Home?author={$resource.author|escape:"url"}">{$resource.author|escape}</a><br> +
-                  {/if} +
-                  {if $resource.tags} +
-                  {translate text='Your Tags'}: +
-                  {foreach from=$resource.tags item=tag name=tagLoop} +
-                    <a href="{$url}/Search/Results?tag={$tag->tag|escape:"url"}">{$tag->tag|escape}</a>{if !$smarty.foreach.tagLoop.last},{/if} +
-                  {/foreach} +
-                  <br> +
-                  {/if} +
-                  {if $resource.notes} +
-                  {translate text='Notes'}: {$resource.notes|escape}<br> +
-                  {/if} +
-                   +
-                  {if is_array($resource.format)} +
-                    {foreach from=$resource.format item=format} +
-                      <span class="iconlabel {$format|lower|regex_replace:"/[^a-z0-9]/":""}">{translate text=$format}</span> +
-                    {/foreach} +
-                  {else} +
-                    <span class="iconlabel {$resource.format|lower|regex_replace:"/[^a-z0-9]/":""}">{translate text=$resource.format}</span> +
-                  {/if} +
- +
-                  <br> +
- +
-                 <b>{translate text='Created'}:</b> {$resource.ils_details.createdate|escape} | +
-                 <b>{translate text='Expires'}:</b> {$resource.ils_details.expiredate|escape} +
-                 <br> +
-                 <strong>{translate text='Position in Queue'}:</strong> {$resource.ils_details.position|escape} +
-     <br /> +
-                 {if $cancelOption == "vufind"+
-                 {translate text='Cancel Hold'}: <input type="checkbox" name="cancelHold[]" value="{$resource.ils_details.cancel_details|escape}" class="cancelcheck" /> +
-                 {elseif $cancelOption == "OPAC"+
-                 <a href="{$resource.ils_details.cancel_link|escape}">{translate text='Cancel Hold'}</a> +
-                 {/if} +
-                 +
-               </div> +
-              </div> +
-            </div> +
-          </li> +
-        {/foreach} +
-        </ul> +
-</code> +
- +
-holds.tpl finally determines if vufind is being used to cancel holds, supplies a submit button and finishes the form. +
- +
-<code> +
-{if $cancelOption} +
-   <br />   +
-   <input type="submit" name="cancel" class="cancelHold" value="{translate text="Cancel Selected Holds"}" /> +
-   </form> +
-          {/if} +
-</code> +
- +
-==== New Smarty Variables / Text ==== +
- +
-Cancel All Holds +
-Cancel Selected Holds +
-Cancel Hold +
- +
-===== Renew Items ===== +
- +
-==== Files Affected ==== +
- +
-CatalogConnection.php +
-conf/config.ini +
-Drivers/All +
-Services/MyResearch/MyResearch.php +
-Services/MyResearch/CheckedOut.php +
-Interface/MyResearch/checkedout.tpl +
- +
-==== 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.  The method either takes information supplied via a POST form, passes it to the driver and returns the response or generates a url link to the native OPAC. +
- +
-==== Process ==== +
- +
-conf/driver.ini +
- +
-Renewals] +
-enabled = true +
-link = item_id +
-opacurl = http://opac.swan.ac.uk/renewItems +
- +
-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, an array key of item_id must be returned by getMyTransactions in the ils_details array. +
- +
-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->checkRenew = $this->catalog->checkFunction("Renewals"); +
- +
-==== CheckedOut.php ==== +
- +
-CheckedOut.php begins as usual by confirming that the driver is available and that the user is logged  in: +
- +
-       // Get My Transactions +
-        if ($this->catalog->status) { +
-            if ($user->cat_username) { +
-                $patron = $this->catalog->patronLogin($user->cat_username, $user->cat_password); +
-                if (PEAR::isError($patron)) +
-                    PEAR::raiseError($patron); +
- +
-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->catalog->getMyTransactions($patron); +
-                if (!PEAR::isError($result)) { +
-                    $transList = array(); +
-                    foreach ($result as $data) { +
-                        $record = $this->db->search('id:' . $data['id']); +
-                        // Due Date etc added to extra in driver to negate need to edit this file +
-                        $transList[= array('id'      => $data['id'], +
-      'ils_details' => $data['ils_details'], +
-                                             'isbn'    => $record['response']['docs'][0]['isbn'], +
-                                             'author'  => $record['response']['docs'][0]['author'], +
-                                             'title'   => $record['response']['docs'][0]['title'], +
-                                             'format'  => $record['response']['docs'][0]['format']); +
-                         +
-                    } +
- +
-Once the transaction list has been established, CheckedOut.php checks to see if the renewal function is enabled. If it is, it sets the name of the function and assigns the information required to renew each item to the ils_details array. If function is set to “renewMyItemsLink”, it passes the array key values set in the “link field” of driver.ini to renewMyItemsLink and receives a ur which is assigned to the “ils_details” array with the “renew_link” key. If the function is not “renewMyItemsLink”, it assigns the array keys set in the “link” field of  driver.ini file to the “ils_details” array with the “renew_details” key. A renewOption variable of OPAC or vufind is assigned to CheckedOut.tpl for form display options. +
- +
-if($this->checkRenew) { +
-                     +
-                        $function = $this->checkRenew['function']; +
- +
-                        foreach($transList as $key => $item) { +
- +
-                            // Reset $renew_details for next item  +
-                            $renew_details = ""; +
-                            $i = 1; +
-                            $count = count($this->checkRenew['link']); +
-                             +
-                            // Build OPAC URL +
-                            if ($function == “renewMyItemsLink”) { +
-                                 foreach($this->checkRenew['link'] as $link) {  +
-                                     $opacArray[$link] = $item['ils_details'][$link]; +
-                                 } +
-                                 $transList[$key]['ils_details']['renew_link'] = $this->catalog->$function($opacArray); +
-                                 $interface->assign('renewOption', "OPAC"); +
-                            } +
- +
-                            // Form Details +
-                            else { +
-                                foreach($this->checkRenew['link'] as $link) { +
-                                    if($i == $count) {  +
-                                        $renew_details .= $item['ils_details'][$link]; +
-                                    } +
-                                    else { +
-                                        $renew_details .= $item['ils_details'][$link]."|"; +
-                                    } +
-                                $i++; +
-                                $transList[$key]['ils_details']['renew_details'] = $renew_details; +
-                              +
-                                } +
-                            $interface->assign('renewOption', "vufind"); +
-                            }     +
-                         +
-                        } +
-                    } +
- +
-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['details'] array together with the patron information. CheckedOut.php then calls the driver renewal function and assigns the results to the template. It also extracts the array keys and assigns them to the renewArray variable so that smarty can determine which items have returned a renew response. +
- +
-                             // Rewew Items +
-                 +
- if(isset($_POST['renew'])) { +
-  +
-                            $gatheredDetails['details'] = $_POST['renew']; +
-                            // Add Patron Data to Submitted Data +
-                            $gatheredDetails['patron'] = $patron; +
-                            $this->renewDetails = $gatheredDetails; +
- +
-                            $renewResult = $this->catalog->$function($this->renewDetails); +
-                                         $renewResult = $this->catalog->$function($this->renewDetails); +
-                            +
-     // Assign Results to the Template +
-                            $interface->assign('renewResult', $renewResult); +
- +
-                            // Extract id keys and assign them to the Template +
- +
-                            $ids = array_keys($renewResult); +
-                            $interface->assign('renewArray', $ids); +
-                                    } +
- +
-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 == "vufind"+
-                <form name="renewall" action="{$url|escape}/MyResearch/CheckedOut" method="POST" id="renewall">  +
- <div> +
- <div class="renewall"> +
-                {foreach from=$transList item=resource} +
-                  <input type="hidden" name="renew[]" value="{$resource.ils_details.item_id}" /> +
-                {/foreach} +
- +
-                  <input type="submit" name="submitall" value="{translate text='Renew All Items'}" /> +
- </div>  +
- </form> +
- <br class="clear" /> +
- </div> +
-             +
-                <form name="renewals" action="{$url}/MyResearch/CheckedOut" method="POST" id="renewals"> +
-              {/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="filters"> +
-          {foreach from=$transList item=resource name="recordLoop"+
-            {if ($smarty.foreach.recordLoop.iteration % 2) == 0} +
-            <li class="result alt"> +
-            {else} +
-            <li class="result"> +
-            {/if} +
-              <div class="yui-ge"> +
-                <div class="yui-u first"> +
-                  <img src="{$path}/bookcover.php?isn={$resource.isbn|@formatISBN}&amp;size=small" class="alignleft"> +
- +
-                  <div class="resultitem"> +
-                    <a href="{$url}/Record/{$resource.id|escape:"url"}" class="title">{$resource.title|escape}</a><br> +
-                    {if $resource.author} +
-                    {translate text='by'}: <a href="{$url}/Author/Home?author={$resource.author|escape:"url"}">{$resource.author|escape}</a><br> +
-                    {/if} +
-                    {if $resource.tags} +
-                    {translate text='Your Tags'}: +
-                    {foreach from=$resource.tags item=tag name=tagLoop} +
-                      <a href="{$url}/Search/Results?tag={$tag->tag|escape:"url"}">{$tag->tag|escape}</a>{if !$smarty.foreach.tagLoop.last},{/if} +
-                    {/foreach} +
-                    <br> +
-                    {/if} +
-                    {if $resource.notes} +
-                    {translate text='Notes'}: {$resource.notes|escape}<br> +
-                    {/if} +
- +
-                    {if is_array($resource.format)} +
-                      {foreach from=$resource.format item=format} +
-                        <span class="iconlabel {$format|lower|regex_replace:"/[^a-z0-9]/":""}">{translate text=$format}</span> +
-                      {/foreach} +
-                    {else} +
-                      <span class="iconlabel {$resource.format|lower|regex_replace:"/[^a-z0-9]/":""}">{translate text=$resource.format}</span> +
-                    {/if} +
- +
-                    <br> +
-                     +
- +
-                    {* Make sure a renewResult is available *}  +
-                    {if $renewResult} +
-                        {* Check if a renew attempt has been made *} +
-                        {if in_array($resource.ils_details.item_id, $renewArray)} +
-                            {* 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 =="true"+
-                                        <b>{translate text='Due'}: {$item_info.new_date}</b> +
-                                        <br /> +
-                                        {translate text='Renew Successful'+
-                                        {else} +
-                                        <b>{translate text='Due'}:{$resource.ils_details.duedate}</b> +
-                                        <br /> +
-                                        {translate text='Renew Unsuccessful'}{if $item_info.sysmessage}: {$item_info.sysmessage}{/if}  +
-                                        {/if} +
-                                    {/if}      +
-             {/foreach} +
-         {else} +
-         <b>{translate text='Due'}: {$resource.ils_details.duedate}</b> +
-                        {/if} +
-                    {else} +
-                    <b>{translate text='Due'}: {$resource.ils_details.duedate}</b> +
-                    {/if}  +
-                     +
-     <br /> +
-                    {if $renewOption == "vufind"  +
-     {translate text='Renew Item'}: <input type="checkbox" name="renew[]" value="{$resource.ils_details.item_id}" class="renewcheck" /> +
-     {elseif $renewOption == "OPAC"+
-                    <a href="{$resource.ils_details.renew_link|escape}">{translate text='Cancel Hold'}</a>  +
-                    {/if} +
-      +
- +
-                  </div> +
-                </div> +
- +
-              </div> +
-            </li> +
-          {/foreach} +
-          </ul> +
- +
-checkedout.tpl finally determines if vufind is being to renew items, supplies a submit button and finishes the form. +
-    +
-{if $renewOption == "vufind"+
-   <br />   +
- <input type="submit" class="renewsubmit" value="{translate text="Renew Selected Items"}" /> +
- </form> +
-   {/if} +
- +
-==== New Smarty Variables / Text ==== +
- +
-Renew All Items +
-Renew Successful +
-Renew Unsuccessful +
-Renew Item +
-Renew Selected Items +
- +
- +
- +
- +
 ---- struct data ---- ---- struct data ----
 +properties.Page Owner : 
 ---- ----
  
expanded_driver_func.1265890551.txt.gz · Last modified: 2014/06/13 13:12 (external edit)