Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #145

Merged
merged 8 commits into from
Mar 4, 2024
Merged

Dev #145

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 27 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ they valididate all inputs and will throw exceptions
if presented with inappropriate inputs.

- authenticate_patron($token, $patron_id, $password)
- change_barcode($token, $patron_key, $patron_id)
- change_barcode($token, $patron_key, $patron_id, $options)<br>
Options array may include: role, client_id
- change_item_library($token, $item_key, $library)
- change_patron_password($token, $json)
- change_patron_password($token, $json, $options)<br>
Options array may include: role, client_id
- delete_patron($token, $patron_key)
- describe_bib($token)
- describe_item($token)
Expand Down Expand Up @@ -68,13 +70,18 @@ or evaluating data from the Symphony system.
- get_patron_checkouts($token, $patron_key, $include_fields)
- get_patron_indexes($token)
- prepare_search($terms)
- register_patron($patron, $token, $addr_num, $role, $client_id, $template, $subject)
- reset_patron_password($token, $patron_id, $url, $email, $role, $client_id)
- register_patron($patron, $token, $addr_num, $options)<br>
Options array may include: role, client_id, template, subject
- reset_patron_password($token, $patron_id, $url, $email)<br>
Optional: email
- search_authenticate($token, $index, $search, $password)
- search_bib($token, $index, $value, $params)
- search_bib($token, $index, $value, $params)<br>
Params array may include: q, ct, rw, j, includeFields
- update_patron($patron, $token, $patron_key, $addr_num)
- update_patron_activeid($token, $patron_key, $patron_id, $option)
- update_phone_list($phone_list, $token, $patron_key)
- update_patron_activeid($token, $patron_key, $patron_id, $option)<br>
Option may be: a, i, d
- update_phone_list($phone_list, $token, $patron_key, $options)<br>
Options array may include: role, client_id

## Date and Telephone Number Formats
For the convenience of developers, the code library accepts
Expand Down Expand Up @@ -134,7 +141,12 @@ $response = $ilsws->get_patron_attributes($token, $patron_key);
```
/**
* The order of the fields doesn't matter. Not all of these are actually required.
* See the YAML configuration file to determine which fields are required.
* See the YAML configuration file to determine which fields are required. If an
* email template name is included in the options array, an email will be sent to the
* patron. Actual template files must include a language extension (for example .en for
* English. The system will look for template that matches the patrons language
* preference. If one is found, it will use that, otherwise it will attempt to
* find and use an English template.
*/
$patron = [
'birthDate' => '1962-03-07',
Expand Down Expand Up @@ -165,10 +177,14 @@ $patron = [
];

$addr_num = 1;
$role = 'STAFF';
$client_id = 'StaffClient';

$response = $ilsws->register_patron($patron, $token, $addr_num, $role, $client_id, $template);
$options = [];
$options['role'] = 'STAFF';
$options['client_id'] = 'StaffClient';
$options['template'] = 'template.html.twig';
$options['subject'] = 'Welcome to the library!';

$response = $ilsws->register_patron($patron, $token, $addr_num, $options);
```

### Update Patron Record
Expand Down
18 changes: 8 additions & 10 deletions src/DataHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

class DataHandler
{

// Set to 1 for dubugging messages
private $debug = 0;

/**
* Validates various types of incoming field data
* Sample fields hash with validation rules:
Expand Down Expand Up @@ -67,7 +63,7 @@ public function validate ($value, $validation_rule) {
switch ($type) {
case "b":
// Value must be undefined
if ( ! defined($value) ) {
if ( !defined($value) ) {
$retval = 1;
}
break;
Expand All @@ -85,14 +81,16 @@ public function validate ($value, $validation_rule) {
break;
case "i":
// Must be an integer of length specified
list($min_range, $max_range) = preg_split('/,/', $param);
if ( filter_var($value, FILTER_VALIDATE_INT, ['options' => ['min_range' => $min_range, 'max_range' => $max_range]]) ) {
$retval = 1;
if ( preg_match('/^-?\d+$/', $value) ) {
list($min_range, $max_range) = preg_split('/,/', $param);
if ( filter_var($value, FILTER_VALIDATE_INT, ['options' => ['min_range' => $min_range, 'max_range' => $max_range]]) ) {
$retval = 1;
}
}
break;
case "j":
// Must be valid JSON
if ( ! empty($value) ) {
if ( !empty($value) ) {
json_decode($value);
if ( json_last_error() == JSON_ERROR_NONE ) {
$retval = 1;
Expand Down Expand Up @@ -129,7 +127,7 @@ public function validate ($value, $validation_rule) {
break;
case "s":
// Check string for length
if ( ! defined($value) || strlen($value) <= $param ) {
if ( !defined($value) || strlen($value) <= $param ) {
$retval = 1;
}
break;
Expand Down
Loading
Loading