-
Notifications
You must be signed in to change notification settings - Fork 355
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
Email the service desk after a hold is placed #3955
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -375,6 +375,10 @@ renewals_enabled = false | |
; if available, but not supported by all drivers) | ||
title_level_holds_mode = "disabled" | ||
|
||
; Email submitted request notifications to and from these addresses | ||
;holds_email_to = "[email protected]" | ||
;holds_email_from = "[email protected]" | ||
|
||
; Determines how holdings are grouped in the record display, using fields from | ||
; the item information provided by the ILS driver. | ||
; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,6 +195,7 @@ public function holdAction() | |
|
||
// Success: Go to Display Holds | ||
if (isset($results['success']) && $results['success'] == true) { | ||
$this->emailRequestPlaced($holdDetails); | ||
$msg = [ | ||
'html' => true, | ||
'msg' => empty($gatheredDetails['proxiedUser']) | ||
|
@@ -282,4 +283,57 @@ public function holdAction() | |
$view->setTemplate('record/hold'); | ||
return $view; | ||
} | ||
|
||
/** | ||
* Email the successful request to staff as a notification. | ||
* | ||
* @param array $holdDetails Details about the successful hold request | ||
* | ||
* @return void | ||
*/ | ||
protected function emailRequestPlaced($holdDetails) | ||
{ | ||
$config = $this->getConfig(); | ||
$to = $this->getEmailRecipient($holdDetails); | ||
$from = $config->Catalog->holds_email_from ?? null; | ||
if (!$to || !$from) { | ||
return; | ||
} | ||
|
||
$renderer = $this->getViewRenderer(); | ||
$message = $renderer->render( | ||
'Email/request-placed.phtml', | ||
['hold_details' => $holdDetails] | ||
); | ||
|
||
$subject = $this->translate('request_email_subject', [ | ||
'%%id%%' => $holdDetails['id'] ?? '', | ||
'%%barcode%%' => $holdDetails['barcode'] ?? '', | ||
]); | ||
try { | ||
$mailer = $this->getService(\VuFind\Mailer\Mailer::class); | ||
$mailer->send( | ||
$to, | ||
$from, | ||
$subject, | ||
$message | ||
); | ||
} catch (\VuFind\Exception\Mail $e) { | ||
return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't want to throw an exception, after all the hold succeeded. Might be helpful to log the error but I wasn't sure if it was worth using LoggerAwareTrait for the one message. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could also use |
||
} | ||
} | ||
|
||
/** | ||
* Get the appropriate staff email recipient for a hold request. This falls back | ||
* on a configured default but may be overridden to vary based on the hold details. | ||
* | ||
* @param array $holdDetails Details about the successful hold request | ||
* | ||
* @return string The email address | ||
*/ | ||
protected function getEmailRecipient($holdDetails) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic I'll be implementing locally is to look at the pickup location and do a mapping from that to a particular email address. Not sure if that is generic enough to share. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could that be generalized to something like a prioritized list of $holdDetails properties mapped to email addresses? This is pretty ugly, but something like:
(Obviously this would lend itself better to YAML or JSON configuration, but if we have to use .ini, it might work). |
||
{ | ||
$config = $this->getConfig(); | ||
return $config->Catalog->holds_email_to ?? null; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php // This is a text-only email template; do not include HTML! ?> | ||
<?=$this->translate('request_email_item_message', ['%%id%%' => $hold_details['id']])?> | ||
|
||
|
||
----- | ||
|
||
<?=$this->translate('patron_barcode')?>: <?=$hold_details['patron']['cat_username'] ?? ''?> | ||
|
||
<?=$this->translate('item_barcode')?>: <?=$hold_details['barcode'] ?? ''?> | ||
|
||
<?=$this->translate('Title')?>: <?=$hold_details['itemTitle'] ?? ''?> | ||
|
||
<?=$this->translate('Call Number')?>: <?=$hold_details['callNo'] ?? ''?> | ||
|
||
<?=$this->translate('Location')?>: <?=$hold_details['homeLocation'] ?? ''?> | ||
|
||
<?=$this->translate('Comments')?>: <?=$hold_details['comment'] ?? ''?> | ||
|
||
<?php /* Request Group: <?=$this->translate('request_group')?>: <?=$hold_details['requestGroupId'] ?? ''?> */ ?> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll finish using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VuFind calls these user actions both holds (too specific) and requests (maybe too general). I use requests where possible but holds where the term is already used i.e. in that config section.