Skip to content

Commit

Permalink
add ils notification check
Browse files Browse the repository at this point in the history
  • Loading branch information
catsoup11789 committed Jul 29, 2024
1 parent 2ecb889 commit 37f7c3f
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions code/web/sys/Account/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -4301,27 +4301,28 @@ public function canReceiveNotifications($alertType): bool {
}

public function canReceiveILSNotification($code): bool {
$userHomeLocation = $this->homeLocationId;
$userLocation = new Location();
$userLocation->locationId = $this->homeLocationId;
if($userLocation->find(true)) {
$userLibrary = $userLocation->getParentLibrary();
if ($userLibrary) {
require_once ROOT_DIR . '/sys/AspenLiDA/NotificationSetting.php';
$settings = new NotificationSetting();
$settings->id = $userLibrary->lidaNotificationSettingId;
if ($settings->find(true)) {
$ilsMessageTypes = new ILSMessageType();
$ilsMessageTypes->ilsNotificationSettingId = $settings->ilsNotificationSettingId;
$ilsMessageTypes->code = $code;
$ilsMessageTypes->isEnabled = 1;
if($ilsMessageTypes->find(true)) {
return true;
if($this->isNotificationHistoryEnabled()) { // check if ils notifications are enabled for the ils
$userHomeLocation = $this->homeLocationId;
$userLocation = new Location();
$userLocation->locationId = $this->homeLocationId;
if($userLocation->find(true)) {
$userLibrary = $userLocation->getParentLibrary();
if ($userLibrary) {
require_once ROOT_DIR . '/sys/AspenLiDA/NotificationSetting.php';
$settings = new NotificationSetting();
$settings->id = $userLibrary->lidaNotificationSettingId;
if ($settings->find(true)) {
$ilsMessageTypes = new ILSMessageType();
$ilsMessageTypes->ilsNotificationSettingId = $settings->ilsNotificationSettingId;
$ilsMessageTypes->code = $code;
$ilsMessageTypes->isEnabled = 1;
if($ilsMessageTypes->find(true)) {
return true;
}
}
}
}
}

return false;
}

Expand Down Expand Up @@ -4654,6 +4655,11 @@ public function showRenewalLink(AccountSummary $ilsAccountSummary) : bool {
}
return $showRenewalLink;
}

public function isNotificationHistoryEnabled(): bool {
$catalogDriver = $this->getCatalogDriver();
return $catalogDriver->hasIlsInbox();
}
}

function modifiedEmpty($var) {
Expand Down

0 comments on commit 37f7c3f

Please sign in to comment.